1818class TypeSpec :
1919 # Type used within Godot `extension_api.json`
2020 gdapi_type : str
21- # Type used when calling C api functions
22- c_type : str
2321 # Type used for PEP 484 Python typing
2422 py_type : str
23+ # Type used when calling C api functions
24+ c_type : str
2525 # Type used in Cython, basically similar to c_type for scalars&enums
2626 # and to py_type for Godot objects&builtins
27- cy_type : str = None
27+ cy_type : str
2828 # Type is a Godot object (i.e. defined in api.json)
2929 is_object : bool = False
3030 # Type is a Godot builtin (e.g. Vector2)
@@ -40,7 +40,6 @@ class TypeSpec:
4040 variant_type_name : str = "<n/a>"
4141
4242 def __post_init__ (self ):
43- self .cy_type = self .cy_type or self .py_type
4443 if self .is_scalar :
4544 assert not self .is_object
4645 assert not self .is_builtin
@@ -59,27 +58,32 @@ def __post_init__(self):
5958
6059
6160TYPES_DB : Dict [str , TypeSpec ] = {
62- "Variant" : TypeSpec (gdapi_type = "Variant" , c_type = "CVariant" , py_type = "GDAny" , is_builtin = True ),
61+ "Variant" : TypeSpec (
62+ gdapi_type = "Variant" , c_type = "CVariant" , cy_type = "object" , py_type = "GDAny" , is_builtin = True
63+ ),
6364 # Types marked as `meta` are used in the classes method args/return types
6465 "meta:int8" : TypeSpec (
6566 gdapi_type = "int8" ,
6667 c_type = "int8_t" ,
68+ cy_type = "int8_t" ,
6769 py_type = "int" ,
6870 variant_type_name = "GDNATIVE_VARIANT_TYPE_INT" ,
6971 is_scalar = True ,
7072 is_stack_only = True ,
7173 ),
72- "meta:int32" : TypeSpec (
73- gdapi_type = "int32" ,
74- c_type = "int32_t" ,
74+ "meta:int16" : TypeSpec (
75+ gdapi_type = "int16" ,
76+ c_type = "int16_t" ,
77+ cy_type = "int16_t" ,
7578 py_type = "int" ,
7679 variant_type_name = "GDNATIVE_VARIANT_TYPE_INT" ,
7780 is_scalar = True ,
7881 is_stack_only = True ,
7982 ),
80- "meta:int16" : TypeSpec (
81- gdapi_type = "int16" ,
82- c_type = "int16_t" ,
83+ "meta:int32" : TypeSpec (
84+ gdapi_type = "int32" ,
85+ c_type = "int32_t" ,
86+ cy_type = "int32_t" ,
8387 py_type = "int" ,
8488 variant_type_name = "GDNATIVE_VARIANT_TYPE_INT" ,
8589 is_scalar = True ,
@@ -88,6 +92,7 @@ def __post_init__(self):
8892 "meta:int64" : TypeSpec (
8993 gdapi_type = "int64" ,
9094 c_type = "int64_t" ,
95+ cy_type = "int64_t" ,
9196 py_type = "int" ,
9297 variant_type_name = "GDNATIVE_VARIANT_TYPE_INT" ,
9398 is_scalar = True ,
@@ -96,6 +101,7 @@ def __post_init__(self):
96101 "meta:uint8" : TypeSpec (
97102 gdapi_type = "uint8" ,
98103 c_type = "uint8_t" ,
104+ cy_type = "uint8_t" ,
99105 py_type = "int" ,
100106 variant_type_name = "GDNATIVE_VARIANT_TYPE_INT" ,
101107 is_scalar = True ,
@@ -104,6 +110,7 @@ def __post_init__(self):
104110 "meta:uint16" : TypeSpec (
105111 gdapi_type = "uint16" ,
106112 c_type = "uint16_t" ,
113+ cy_type = "uint16_t" ,
107114 py_type = "int" ,
108115 variant_type_name = "GDNATIVE_VARIANT_TYPE_INT" ,
109116 is_scalar = True ,
@@ -112,6 +119,7 @@ def __post_init__(self):
112119 "meta:uint32" : TypeSpec (
113120 gdapi_type = "uint32" ,
114121 c_type = "uint32_t" ,
122+ cy_type = "uint32_t" ,
115123 py_type = "int" ,
116124 variant_type_name = "GDNATIVE_VARIANT_TYPE_INT" ,
117125 is_scalar = True ,
@@ -120,6 +128,17 @@ def __post_init__(self):
120128 "meta:uint64" : TypeSpec (
121129 gdapi_type = "uint64" ,
122130 c_type = "uint64_t" ,
131+ cy_type = "uint64_t" ,
132+ py_type = "int" ,
133+ variant_type_name = "GDNATIVE_VARIANT_TYPE_INT" ,
134+ is_scalar = True ,
135+ is_stack_only = True ,
136+ ),
137+ # int is always 8bytes long
138+ "int" : TypeSpec (
139+ gdapi_type = "int" ,
140+ c_type = "uint64_t" ,
141+ cy_type = "uint64_t" ,
123142 py_type = "int" ,
124143 variant_type_name = "GDNATIVE_VARIANT_TYPE_INT" ,
125144 is_scalar = True ,
@@ -128,6 +147,7 @@ def __post_init__(self):
128147 "meta:float" : TypeSpec (
129148 gdapi_type = "float" ,
130149 c_type = "float" ,
150+ cy_type = "float" ,
131151 py_type = "float" ,
132152 variant_type_name = "GDNATIVE_VARIANT_TYPE_FLOAT" ,
133153 is_scalar = True ,
@@ -136,6 +156,7 @@ def __post_init__(self):
136156 "meta:double" : TypeSpec (
137157 gdapi_type = "double" ,
138158 c_type = "double" ,
159+ cy_type = "double" ,
139160 py_type = "float" ,
140161 variant_type_name = "GDNATIVE_VARIANT_TYPE_FLOAT" ,
141162 is_scalar = True ,
@@ -159,6 +180,7 @@ def register_builtins_in_types_db(builtins: Iterable["BuiltinSpec"]) -> None:
159180 # Cython provide a `bint` type for boolean, however it is defined in C as
160181 # a `int` (so 32bits), so I guess it won't work for Godot's 8bits bool
161182 c_type = f"uint{ spec .size * 8 } _t" ,
183+ cy_type = f"uint{ spec .size * 8 } _t" ,
162184 is_stack_only = True ,
163185 is_scalar = True ,
164186 variant_type_name = spec .variant_type_name ,
@@ -194,6 +216,7 @@ def register_classes_in_types_db(classes: Iterable["ClassSpec"]) -> None:
194216 gdapi_type = spec .original_name ,
195217 py_type = spec .name ,
196218 c_type = "Object" ,
219+ cy_type = "Object" ,
197220 variant_type_name = "GDNATIVE_VARIANT_TYPE_OBJECT" ,
198221 )
199222 TYPES_DB [ts .gdapi_type ] = ts
@@ -202,6 +225,7 @@ def register_classes_in_types_db(classes: Iterable["ClassSpec"]) -> None:
202225 gdapi_type = f"enum::{ spec .original_name } .{ e .original_name } " ,
203226 py_type = f"{ spec .name } .{ e .name } " ,
204227 c_type = "int" ,
228+ cy_type = f"{ spec .name } .{ e .name } " ,
205229 is_scalar = True ,
206230 is_stack_only = True ,
207231 is_enum = True ,
@@ -216,6 +240,7 @@ def register_global_enums_in_types_db(enums: Iterable["GlobalEnumSpec"]) -> None
216240 gdapi_type = f"enum::{ spec .original_name } " ,
217241 py_type = spec .name ,
218242 c_type = "int" ,
243+ cy_type = spec .name ,
219244 is_scalar = True ,
220245 is_stack_only = True ,
221246 is_enum = True ,
@@ -230,7 +255,6 @@ class TypeInUse:
230255
231256 def __repr__ (self ) -> str :
232257 try :
233- raise KeyError
234258 resolved = self .resolve ()
235259 except KeyError :
236260 resolved = "<not resolved yet>"
@@ -242,7 +266,6 @@ def resolve(self) -> TypeSpec:
242266 try :
243267 return TYPES_DB [self .type_name ]
244268 except KeyError :
245- breakpoint ()
246269 return
247270
248271 def __getattr__ (self , name : str ):
0 commit comments