Skip to content

Commit

Permalink
panda3d-stubs: Correct the mapping of char types
Browse files Browse the repository at this point in the history
Fixes #14
  • Loading branch information
WMOkiishi committed Jan 4, 2024
1 parent b3919fd commit 3a37b9e
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 28 deletions.
3 changes: 3 additions & 0 deletions idbstubs/typedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ def get_type_name(idb_type: IDBType) -> str:
# Wrapped types and local typedefs aren't exposed to Python.
return get_type_name(idb_type.wrapped_type)
if idb_type.is_atomic:
# `signed char` and `unsigned char` are mapped to `int` instead of `str`.
if idb_type.name in ('signed char', 'unsigned char'):
return 'int'
return ATOMIC_TYPES[idb_type.atomic_token]
# We can't use `str.removeprefix` because of `ParamValue< std::string >`
name = idb_type.scoped_name.replace('std::', '')
Expand Down
32 changes: 16 additions & 16 deletions src/panda3d-stubs/core/_express.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,16 @@ class PointerToArrayBase_unsigned_char(PointerToBase_ReferenceCountedVector_unsi
class ConstPointerToArray_unsigned_char(PointerToArrayBase_unsigned_char):
def __init__(self, copy: ConstPointerToArray_unsigned_char | PointerToArray_unsigned_char) -> None: ...
def __len__(self) -> int: ...
def __getitem__(self, n: int) -> str: ...
def __getitem__(self, n: int) -> int: ...
def __deepcopy__(self, memo) -> ConstPointerToArray_unsigned_char: ...
def __copy__(self) -> Self: ...
def __iter__(self) -> Iterator[str]: ... # Doesn't actually exist
def get_element(self, n: int) -> str: ...
def __iter__(self) -> Iterator[int]: ... # Doesn't actually exist
def get_element(self, n: int) -> int: ...
def get_data(self) -> bytes: ...
def get_subdata(self, n: int, count: int) -> bytes: ...
def get_ref_count(self) -> int: ...
def get_node_ref_count(self) -> int: ...
def count(self, __param0: str) -> int: ...
def count(self, __param0: int) -> int: ...
getElement = get_element
getData = get_data
getSubdata = get_subdata
Expand Down Expand Up @@ -337,28 +337,28 @@ class PointerToArray_unsigned_char(PointerToArrayBase_unsigned_char):
@overload
def __init__(self, copy: PointerToArray_unsigned_char) -> None: ...
@overload
def __init__(self, source: Sequence[str]) -> None: ...
def __init__(self, source: Sequence[int]) -> None: ...
@overload
def __init__(self, type_handle: TypeHandle | type = ...) -> None: ...
def __len__(self) -> int: ...
def __getitem__(self, n: int) -> str: ...
def __setitem__(self, n: int, value: str) -> None: ...
def __getitem__(self, n: int) -> int: ...
def __setitem__(self, n: int, value: int) -> None: ...
def __deepcopy__(self, memo) -> PointerToArray_unsigned_char: ...
def __copy__(self) -> Self: ...
def __iter__(self) -> Iterator[str]: ... # Doesn't actually exist
def __iter__(self) -> Iterator[int]: ... # Doesn't actually exist
@staticmethod
def empty_array(n: int, type_handle: TypeHandle | type = ...) -> PointerToArray_unsigned_char: ...
def push_back(self, x: str) -> None: ...
def push_back(self, x: int) -> None: ...
def pop_back(self) -> None: ...
def get_element(self, n: int) -> str: ...
def set_element(self, n: int, value: str) -> None: ...
def get_element(self, n: int) -> int: ...
def set_element(self, n: int, value: int) -> None: ...
def get_data(self) -> bytes: ...
def set_data(self, data: bytes) -> None: ...
def get_subdata(self, n: int, count: int) -> bytes: ...
def set_subdata(self, n: int, count: int, data: str) -> None: ...
def get_ref_count(self) -> int: ...
def get_node_ref_count(self) -> int: ...
def count(self, __param0: str) -> int: ...
def count(self, __param0: int) -> int: ...
emptyArray = empty_array
pushBack = push_back
popBack = pop_back
Expand Down Expand Up @@ -694,9 +694,9 @@ class Datagram(TypedObject):
"""
def add_bool(self, value: bool) -> None:
"""Adds a boolean value to the datagram."""
def add_int8(self, value: str) -> None:
def add_int8(self, value: int) -> None:
"""Adds a signed 8-bit integer to the datagram."""
def add_uint8(self, value: str) -> None:
def add_uint8(self, value: int) -> None:
"""Adds an unsigned 8-bit integer to the datagram."""
def add_int16(self, value: int) -> None:
"""Adds a signed 16-bit integer to the datagram."""
Expand Down Expand Up @@ -909,9 +909,9 @@ class DatagramIterator:
def __deepcopy__(self, __memo: object) -> Self: ...
def get_bool(self) -> bool:
"""Extracts a boolean value."""
def get_int8(self) -> str:
def get_int8(self) -> int:
"""Extracts a signed 8-bit integer."""
def get_uint8(self) -> str:
def get_uint8(self) -> int:
"""Extracts an unsigned 8-bit integer."""
def get_int16(self) -> int:
"""Extracts a signed 16-bit integer."""
Expand Down
2 changes: 1 addition & 1 deletion src/panda3d-stubs/core/_net.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class NetAddress:
in host byte order.
@deprecated Does not work with IPv6 addresses.
"""
def get_ip_component(self, n: int) -> str:
def get_ip_component(self, n: int) -> int:
"""Returns the nth 8-bit component of the IP address. An IP address has four
components; component 0 is the first (leftmost), and component 3 is the
last (rightmost) in the dotted number convention.
Expand Down
8 changes: 4 additions & 4 deletions src/panda3d-stubs/core/_pnmimage.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1968,10 +1968,10 @@ class PNMPainter:
drawLine = draw_line
drawRectangle = draw_rectangle

def decode_sRGB_float(val: float | str) -> float: ...
def decode_sRGB_uchar(val: float | str) -> str: ...
def encode_sRGB_float(val: float | str) -> float: ...
def encode_sRGB_uchar(val: float | str) -> str: ...
def decode_sRGB_float(val: float) -> float: ...
def decode_sRGB_uchar(val: float) -> int: ...
def encode_sRGB_float(val: float) -> float: ...
def encode_sRGB_uchar(val: float) -> int: ...
decodeSRGBFloat = decode_sRGB_float
decodeSRGBUchar = decode_sRGB_uchar
encodeSRGBFloat = encode_sRGB_float
Expand Down
8 changes: 4 additions & 4 deletions src/panda3d-stubs/core/_prc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1602,9 +1602,9 @@ class StreamReader:
"""Returns the stream in use."""
def get_bool(self) -> bool:
"""Extracts a boolean value."""
def get_int8(self) -> str:
def get_int8(self) -> int:
"""Extracts a signed 8-bit integer."""
def get_uint8(self) -> str:
def get_uint8(self) -> int:
"""Extracts an unsigned 8-bit integer."""
def get_int16(self) -> int:
"""Extracts a signed 16-bit integer."""
Expand Down Expand Up @@ -1720,9 +1720,9 @@ class StreamWriter:
"""Returns the stream in use."""
def add_bool(self, value: bool) -> None:
"""Adds a boolean value to the stream."""
def add_int8(self, value: str) -> None:
def add_int8(self, value: int) -> None:
"""Adds a signed 8-bit integer to the stream."""
def add_uint8(self, value: str) -> None:
def add_uint8(self, value: int) -> None:
"""Adds an unsigned 8-bit integer to the stream."""
def add_int16(self, value: int) -> None:
"""Adds a signed 16-bit integer to the stream."""
Expand Down
6 changes: 3 additions & 3 deletions src/panda3d-stubs/ode.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ class OdeWorld(TypedObject):
def step(self, stepsize: float) -> None: ...
def quick_step(self, stepsize: float) -> None: ...
def compare_to(self, other: OdeWorld) -> int: ...
def init_surface_table(self, num_surfaces: str) -> None: ...
def init_surface_table(self, num_surfaces: int) -> None: ...
def add_body_dampening(self, body: OdeBody, surface: int) -> None:
"""void assign_surface_body(OdeBody& body, int surface);"""
def set_surface_entry(
self,
pos1: str,
pos2: str,
pos1: int,
pos2: int,
mu: float,
bounce: float,
bounce_vel: float,
Expand Down

0 comments on commit 3a37b9e

Please sign in to comment.