Skip to content

Commit f7f8d0e

Browse files
committed
Update to Godot 4.0-beta10
1 parent 5568200 commit f7f8d0e

33 files changed

+68899
-58450
lines changed

godot_headers/extension_api.json

Lines changed: 67662 additions & 57338 deletions
Large diffs are not rendered by default.

godot_headers/godot/gdextension_interface.h

Lines changed: 619 additions & 0 deletions
Large diffs are not rendered by default.

godot_headers/godot/gdnative_interface.h

Lines changed: 0 additions & 612 deletions
This file was deleted.

scripts/cython_godot_extension_class_preprocessor/__init__.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,17 @@ def godot_python_patched_create_pipeline(context, mode, exclude_classes=()):
124124

125125

126126
TYPES_TO_META = {
127-
None: "GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_NONE",
128-
"uint8_t": "GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT8",
129-
"uint16_t": "GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT16",
130-
"uint32_t": "GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT32",
131-
"uint64_t": "GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT64",
132-
"int8_t": "GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT8",
133-
"int16_t": "GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT16",
134-
"int32_t": "GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT32",
135-
"int64_t": "GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT64",
136-
"float": "GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_FLOAT",
137-
"double": "GDNATIVE_EXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_DOUBLE",
127+
None: "GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE",
128+
"uint8_t": "GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT8",
129+
"uint16_t": "GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT16",
130+
"uint32_t": "GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT32",
131+
"uint64_t": "GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT64",
132+
"int8_t": "GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT8",
133+
"int16_t": "GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT16",
134+
"int32_t": "GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT32",
135+
"int64_t": "GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT64",
136+
"float": "GDEXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_FLOAT",
137+
"double": "GDEXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_DOUBLE",
138138
}
139139

140140

scripts/extension_api_parser/api.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ def parse(cls, item: dict) -> "NativeStructureSpec":
130130
if not raw_field:
131131
continue
132132
raw_field, *_ = raw_field.split("=", 1) # Ignore default value
133+
# Handle function pointer (yeah detection is pretty fragile, but it is good enough for now)
134+
if "(*" in raw_field:
135+
# TODO: better typping support for function pointer ?
136+
raw_field = "void *foo"
133137
field_type, field_name = raw_field.split()
134138
# Handle Enum
135139
if "::" in field_type:
@@ -139,6 +143,9 @@ def parse(cls, item: dict) -> "NativeStructureSpec":
139143
if field_name[0] == "*":
140144
field_name = field_name[1:]
141145
field_type = field_type + "*"
146+
# TODO: better support of void* ?
147+
if field_type == "void*":
148+
field_type = "Object*"
142149
if field_type != "Object*":
143150
raise RuntimeError(f"Unsupported pointer type `{field_type}` in `{name}`")
144151
field_type = "Object"
@@ -225,15 +232,6 @@ def merge_builtins_size_info(api_json: dict, build_config: BuildConfig) -> None:
225232
)
226233
builtin_class_member_offsets = {x["name"]: x["members"] for x in builtin_class_member_offsets}
227234

228-
# TODO: remove me once https://github.com/godotengine/godot/pull/64690 is merged
229-
if "Projection" not in builtin_class_member_offsets:
230-
builtin_class_member_offsets["Projection"] = [
231-
{"member": "x", "offset": 0},
232-
{"member": "y", "offset": builtin_class_sizes["Vector4"]},
233-
{"member": "z", "offset": 2 * builtin_class_sizes["Vector4"]},
234-
{"member": "w", "offset": 3 * builtin_class_sizes["Vector4"]},
235-
]
236-
237235
for item in api_json["builtin_classes"]:
238236
name = item["name"]
239237
item["size"] = builtin_class_sizes[name]

scripts/extension_api_parser/builtins.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,35 @@ class BuiltinVariantOperatorValue:
1414

1515
VARIANT_OPERATORS = {
1616
# comparison
17-
"==": ("equal", "GDNATIVE_VARIANT_OP_EQUAL"),
18-
"!=": ("not_equal", "GDNATIVE_VARIANT_OP_NOT_EQUAL"),
19-
"<": ("less", "GDNATIVE_VARIANT_OP_LESS"),
20-
"<=": ("less_equal", "GDNATIVE_VARIANT_OP_LESS_EQUAL"),
21-
">": ("greater", "GDNATIVE_VARIANT_OP_GREATER"),
22-
">=": ("greater_equal", "GDNATIVE_VARIANT_OP_GREATER_EQUAL"),
17+
"==": ("equal", "GDEXTENSION_VARIANT_OP_EQUAL"),
18+
"!=": ("not_equal", "GDEXTENSION_VARIANT_OP_NOT_EQUAL"),
19+
"<": ("less", "GDEXTENSION_VARIANT_OP_LESS"),
20+
"<=": ("less_equal", "GDEXTENSION_VARIANT_OP_LESS_EQUAL"),
21+
">": ("greater", "GDEXTENSION_VARIANT_OP_GREATER"),
22+
">=": ("greater_equal", "GDEXTENSION_VARIANT_OP_GREATER_EQUAL"),
2323
# mathematic
24-
"+": ("add", "GDNATIVE_VARIANT_OP_ADD"),
25-
"-": ("subtract", "GDNATIVE_VARIANT_OP_SUBTRACT"),
26-
"*": ("multiply", "GDNATIVE_VARIANT_OP_MULTIPLY"),
27-
"/": ("divide", "GDNATIVE_VARIANT_OP_DIVIDE"),
28-
"unary-": ("negate", "GDNATIVE_VARIANT_OP_NEGATE"),
29-
"unary+": ("positive", "GDNATIVE_VARIANT_OP_POSITIVE"),
30-
"%": ("module", "GDNATIVE_VARIANT_OP_MODULE"),
31-
"**": ("power", "GDNATIVE_VARIANT_OP_POWER"),
24+
"+": ("add", "GDEXTENSION_VARIANT_OP_ADD"),
25+
"-": ("subtract", "GDEXTENSION_VARIANT_OP_SUBTRACT"),
26+
"*": ("multiply", "GDEXTENSION_VARIANT_OP_MULTIPLY"),
27+
"/": ("divide", "GDEXTENSION_VARIANT_OP_DIVIDE"),
28+
"unary-": ("negate", "GDEXTENSION_VARIANT_OP_NEGATE"),
29+
"unary+": ("positive", "GDEXTENSION_VARIANT_OP_POSITIVE"),
30+
"%": ("module", "GDEXTENSION_VARIANT_OP_MODULE"),
31+
"**": ("power", "GDEXTENSION_VARIANT_OP_POWER"),
3232
# bitwise
33-
"<<": ("shift_left", "GDNATIVE_VARIANT_OP_SHIFT_LEFT"),
34-
">>": ("shift_right", "GDNATIVE_VARIANT_OP_SHIFT_RIGHT"),
35-
"&": ("bit_and", "GDNATIVE_VARIANT_OP_BIT_AND"),
36-
"|": ("bit_or", "GDNATIVE_VARIANT_OP_BIT_OR"),
37-
"^": ("bit_xor", "GDNATIVE_VARIANT_OP_BIT_XOR"),
38-
"~": ("bit_negate", "GDNATIVE_VARIANT_OP_BIT_NEGATE"),
33+
"<<": ("shift_left", "GDEXTENSION_VARIANT_OP_SHIFT_LEFT"),
34+
">>": ("shift_right", "GDEXTENSION_VARIANT_OP_SHIFT_RIGHT"),
35+
"&": ("bit_and", "GDEXTENSION_VARIANT_OP_BIT_AND"),
36+
"|": ("bit_or", "GDEXTENSION_VARIANT_OP_BIT_OR"),
37+
"^": ("bit_xor", "GDEXTENSION_VARIANT_OP_BIT_XOR"),
38+
"~": ("bit_negate", "GDEXTENSION_VARIANT_OP_BIT_NEGATE"),
3939
# logic
40-
"and": ("and", "GDNATIVE_VARIANT_OP_AND"),
41-
"or": ("or", "GDNATIVE_VARIANT_OP_OR"),
42-
"xor": ("xor", "GDNATIVE_VARIANT_OP_XOR"),
43-
"not": ("not", "GDNATIVE_VARIANT_OP_NOT"),
40+
"and": ("and", "GDEXTENSION_VARIANT_OP_AND"),
41+
"or": ("or", "GDEXTENSION_VARIANT_OP_OR"),
42+
"xor": ("xor", "GDEXTENSION_VARIANT_OP_XOR"),
43+
"not": ("not", "GDEXTENSION_VARIANT_OP_NOT"),
4444
# containment
45-
"in": ("in", "GDNATIVE_VARIANT_OP_IN"),
45+
"in": ("in", "GDEXTENSION_VARIANT_OP_IN"),
4646
}
4747

4848

@@ -395,7 +395,7 @@ def _parse_builtin(spec: dict) -> BuiltinTypeSpec:
395395

396396
py_type = cy_type
397397

398-
variant_type_name = f"GDNATIVE_VARIANT_TYPE_{snake_name.upper()}"
398+
variant_type_name = f"GDEXTENSION_VARIANT_TYPE_{snake_name.upper()}"
399399
constructors = [BuiltinConstructorSpec.parse(x, c_name_prefix) for x in spec["constructors"]]
400400
operators = [BuiltinOperatorSpec.parse(x, c_name_prefix) for x in spec["operators"]]
401401
methods = [BuiltinMethodSpec.parse(x, c_name_prefix) for x in spec["methods"]]

scripts/extension_api_parser/classes.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class ClassMethodSpec:
5656
is_vararg: bool
5757
is_static: bool
5858
is_virtual: bool
59+
is_property_accessor: bool
5960
hash: Optional[int]
6061
return_type: TypeInUse
6162
arguments: List[ClassMethodArgumentSpec]
@@ -79,6 +80,7 @@ def parse(cls, item: dict) -> "ClassMethodSpec":
7980
is_vararg=item["is_vararg"],
8081
is_static=item["is_static"],
8182
is_virtual=item["is_virtual"],
83+
is_property_accessor=item["is_property_accessor"],
8284
hash=item["hash"],
8385
return_type=item["return_type"],
8486
arguments=[ClassMethodArgumentSpec.parse(x) for x in item["arguments"]],
@@ -167,7 +169,7 @@ def __init__(self, **kwargs):
167169
super().__init__(
168170
c_type="gd_object_t",
169171
cy_type=kwargs["py_type"],
170-
variant_type_name="GDNATIVE_VARIANT_TYPE_OBJECT",
172+
variant_type_name="GDEXTENSION_VARIANT_TYPE_OBJECT",
171173
# Of course the object instance live on the heap, but we are talking
172174
# here about the pointer
173175
is_stack_only=True,
@@ -202,28 +204,6 @@ def parse_class(spec: dict, object_size: int) -> ClassTypeSpec:
202204
if spec["name"] == "Object":
203205
spec["name"] = "GDObject"
204206

205-
# TODO: remove me once https://github.com/godotengine/godot/pull/64427 is merged
206-
for prop in spec["properties"]:
207-
if prop.get("getter") == "":
208-
prop.pop("getter")
209-
if prop.get("setter") == "":
210-
prop.pop("setter")
211-
if prop.get("index") == -1:
212-
prop.pop("index")
213-
214-
# TODO: remove me once https://github.com/godotengine/godot/pull/64428 is merged
215-
def _filter_bad_property(prop: dict) -> bool:
216-
if "/" in prop["name"]:
217-
return False
218-
# e.g. `Modifications,modifications/`
219-
if "/" in prop["type"]:
220-
return False
221-
if "getter" not in prop:
222-
return False
223-
return True
224-
225-
spec["properties"] = [prop for prop in spec["properties"] if _filter_bad_property(prop)]
226-
227207
return ClassTypeSpec(
228208
size=object_size,
229209
original_name=original_name,

scripts/extension_api_parser/type_spec.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class TypeSpec:
2222
cy_type: str
2323
# Type doesn't use the heap (hence no need for freeing it)
2424
is_stack_only: bool
25-
# e.g. `GDNATIVE_VARIANT_TYPE_BOOL`
25+
# e.g. `GDEXTENSION_VARIANT_TYPE_BOOL`
2626
variant_type_name: str
2727

2828
def __repr__(self):
@@ -93,7 +93,7 @@ def __init__(self, **kwargs):
9393
is_stack_only=True,
9494
size=4,
9595
c_type="int",
96-
variant_type_name="GDNATIVE_VARIANT_TYPE_INT",
96+
variant_type_name="GDEXTENSION_VARIANT_TYPE_INT",
9797
**kwargs,
9898
)
9999

@@ -113,7 +113,7 @@ def __init__(self):
113113
size=0,
114114
original_name="Nil",
115115
is_stack_only=True,
116-
variant_type_name="GDNATIVE_VARIANT_TYPE_NIL",
116+
variant_type_name="GDEXTENSION_VARIANT_TYPE_NIL",
117117
py_type="", # Never accessed dummy value
118118
c_type="", # Never accessed dummy value
119119
cy_type="", # Never accessed dummy value
@@ -169,7 +169,7 @@ def TYPES_DB_REGISTER_TYPE(id: str, type_spec: "TypeSpec") -> None:
169169
c_type="uint8_t",
170170
cy_type="uint8_t",
171171
py_type="bool",
172-
variant_type_name="GDNATIVE_VARIANT_TYPE_BOOL",
172+
variant_type_name="GDEXTENSION_VARIANT_TYPE_BOOL",
173173
),
174174
# int is always 8bytes long
175175
"int": ScalarTypeSpec(
@@ -178,7 +178,7 @@ def TYPES_DB_REGISTER_TYPE(id: str, type_spec: "TypeSpec") -> None:
178178
c_type="uint64_t",
179179
cy_type="uint64_t",
180180
py_type="int",
181-
variant_type_name="GDNATIVE_VARIANT_TYPE_INT",
181+
variant_type_name="GDEXTENSION_VARIANT_TYPE_INT",
182182
),
183183
# Types marked as `meta` are used in the classes method args/return types
184184
"meta:int8": ScalarTypeSpec(
@@ -187,79 +187,79 @@ def TYPES_DB_REGISTER_TYPE(id: str, type_spec: "TypeSpec") -> None:
187187
c_type="int8_t",
188188
cy_type="int8_t",
189189
py_type="int",
190-
variant_type_name="GDNATIVE_VARIANT_TYPE_INT",
190+
variant_type_name="GDEXTENSION_VARIANT_TYPE_INT",
191191
),
192192
"meta:int16": ScalarTypeSpec(
193193
size=2,
194194
original_name="int16",
195195
c_type="int16_t",
196196
cy_type="int16_t",
197197
py_type="int",
198-
variant_type_name="GDNATIVE_VARIANT_TYPE_INT",
198+
variant_type_name="GDEXTENSION_VARIANT_TYPE_INT",
199199
),
200200
"meta:int32": ScalarTypeSpec(
201201
size=4,
202202
original_name="int32",
203203
c_type="int32_t",
204204
cy_type="int32_t",
205205
py_type="int",
206-
variant_type_name="GDNATIVE_VARIANT_TYPE_INT",
206+
variant_type_name="GDEXTENSION_VARIANT_TYPE_INT",
207207
),
208208
"meta:int64": ScalarTypeSpec(
209209
size=8,
210210
original_name="int64",
211211
c_type="int64_t",
212212
cy_type="int64_t",
213213
py_type="int",
214-
variant_type_name="GDNATIVE_VARIANT_TYPE_INT",
214+
variant_type_name="GDEXTENSION_VARIANT_TYPE_INT",
215215
),
216216
"meta:uint8": ScalarTypeSpec(
217217
size=1,
218218
original_name="uint8",
219219
c_type="uint8_t",
220220
cy_type="uint8_t",
221221
py_type="int",
222-
variant_type_name="GDNATIVE_VARIANT_TYPE_INT",
222+
variant_type_name="GDEXTENSION_VARIANT_TYPE_INT",
223223
),
224224
"meta:uint16": ScalarTypeSpec(
225225
size=2,
226226
original_name="uint16",
227227
c_type="uint16_t",
228228
cy_type="uint16_t",
229229
py_type="int",
230-
variant_type_name="GDNATIVE_VARIANT_TYPE_INT",
230+
variant_type_name="GDEXTENSION_VARIANT_TYPE_INT",
231231
),
232232
"meta:uint32": ScalarTypeSpec(
233233
size=4,
234234
original_name="uint32",
235235
c_type="uint32_t",
236236
cy_type="uint32_t",
237237
py_type="int",
238-
variant_type_name="GDNATIVE_VARIANT_TYPE_INT",
238+
variant_type_name="GDEXTENSION_VARIANT_TYPE_INT",
239239
),
240240
"meta:uint64": ScalarTypeSpec(
241241
size=8,
242242
original_name="uint64",
243243
c_type="uint64_t",
244244
cy_type="uint64_t",
245245
py_type="int",
246-
variant_type_name="GDNATIVE_VARIANT_TYPE_INT",
246+
variant_type_name="GDEXTENSION_VARIANT_TYPE_INT",
247247
),
248248
"meta:float": ScalarTypeSpec(
249249
size=4,
250250
original_name="float",
251251
c_type="float",
252252
cy_type="float",
253253
py_type="float",
254-
variant_type_name="GDNATIVE_VARIANT_TYPE_FLOAT",
254+
variant_type_name="GDEXTENSION_VARIANT_TYPE_FLOAT",
255255
),
256256
"meta:double": ScalarTypeSpec(
257257
size=8,
258258
original_name="double",
259259
c_type="double",
260260
cy_type="double",
261261
py_type="float",
262-
variant_type_name="GDNATIVE_VARIANT_TYPE_FLOAT",
262+
variant_type_name="GDEXTENSION_VARIANT_TYPE_FLOAT",
263263
),
264264
# The rest of the types will be added during parsing of builtins&classes
265265
}

scripts/generate_gdnative_interface_pxd.py renamed to scripts/generate_gdextension_interface_pxd.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def visit_ArrayDecl(self, node):
305305

306306

307307
if __name__ == "__main__":
308-
parser = argparse.ArgumentParser(description="Convert gdnative_interface.h into Cython .pxd")
308+
parser = argparse.ArgumentParser(description="Convert gdextension_interface.h into Cython .pxd")
309309
parser.add_argument(
310310
"--input",
311311
"-i",
@@ -347,7 +347,7 @@ def visit_ArrayDecl(self, node):
347347
ast = parser.parse(preprocessed) # type: ignore
348348

349349
# Step 3: .pxd generation
350-
p = PatchedAutoPxd(hdrname="godot/gdnative_interface.h")
350+
p = PatchedAutoPxd(hdrname="godot/gdextension_interface.h")
351351
p.visit(ast)
352352

353353
pxd_cdef = p.lines()
@@ -357,11 +357,11 @@ def visit_ArrayDecl(self, node):
357357
pxd_cdef_body = "\n".join(pxd_cdef[1:])
358358
pxd = f"""
359359
# /!\\ Autogenerated code, modifications will be lost /!\\
360-
# see `scripts/generate_gdnative_interface_pxd.py`
360+
# see `scripts/generate_gdextension_interface_pxd.py`
361361
from libc.stddef cimport wchar_t, size_t
362362
from libc.stdint cimport {', '.join(STDLIB_INCLUDES['stdint.h'])}
363363
364-
cdef extern from "godot/gdnative_interface.h" nogil:
364+
cdef extern from "godot/gdextension_interface.h" nogil:
365365
{pxd_cdef_body}
366366
"""
367367

0 commit comments

Comments
 (0)