Add char types.

This commit is contained in:
Relintai 2023-06-02 14:01:51 +02:00
parent b9243646fe
commit 2a95c7925b
2 changed files with 38 additions and 7 deletions

View File

@ -89,6 +89,14 @@ ALL_TYPES = [
is_base_type=True,
is_stack_only=True,
),
TypeSpec(
gdapi_type="float",
c_type="float",
cy_type="float",
py_type="float",
is_base_type=True,
is_stack_only=True,
),
TypeSpec(
gdapi_type="wchar_t",
c_type="wchar_t",
@ -96,9 +104,30 @@ ALL_TYPES = [
is_base_type=True,
is_stack_only=True,
),
TypeSpec(
gdapi_type="char16_t",
c_type="char16_t",
cy_type="char16_t",
is_base_type=True,
is_stack_only=True,
),
TypeSpec(
gdapi_type="char32_t",
c_type="char32_t",
cy_type="char32_t",
is_base_type=True,
is_stack_only=True,
),
TypeSpec(
gdapi_type="char", c_type="char", cy_type="char", is_base_type=True, is_stack_only=True
),
TypeSpec(
gdapi_type="pandemonium_char_type",
c_type="pandemonium_char_type",
cy_type="pandemonium_char_type",
is_base_type=True,
is_stack_only=True,
),
TypeSpec(
gdapi_type="schar",
c_type="schar",

View File

@ -13,18 +13,20 @@ from pandemonium._hazmat.gdnative_api_struct cimport (
from pandemonium.builtins cimport GDString, NodePath
# Strings are now char32_t
# TODO remove this id everything works
# Pandemonium string are basically a vector of wchar_t, each wchar_t representing
# a single unicode character (i.e. there is no surrogates support).
# The sad part is wchar_t is not portable: it is 16bits long on Windows and
# 32bits long on Linux and MacOS...
# So we end up with a UCS2 encoding on Windows and UCS4 everywhere else :'(
IF UNAME_SYSNAME == "Windows":
# Specify endianess otherwise `encode` appends a BOM at the start of the converted string
DEF _STRING_ENCODING = "UTF-16-LE"
DEF _STRING_CODEPOINT_LENGTH = 2
ELSE:
DEF _STRING_ENCODING = "UTF-32-LE"
DEF _STRING_CODEPOINT_LENGTH = 4
#IF UNAME_SYSNAME == "Windows":
# # Specify endianess otherwise `encode` appends a BOM at the start of the converted string
# DEF _STRING_ENCODING = "UTF-16-LE"
# DEF _STRING_CODEPOINT_LENGTH = 2
#ELSE:
DEF _STRING_ENCODING = "UTF-32-LE"
DEF _STRING_CODEPOINT_LENGTH = 4
cdef inline str pandemonium_string_to_pyobj(const pandemonium_string *p_gdstr):