def str_to_gd_node_path(path, to_variant=False):
    gd_str = pyobj_to_gdobj(path)
    gd_ptr = godot_node_path_alloc()
    lib.godot_node_path_new(gd_ptr, gd_str)
    if to_variant:
        gdvar_ptr = godot_variant_alloc()
        lib.godot_variant_new_node_path(gdvar_ptr, gd_ptr)
    return gd_ptr
示例#2
0
godot_aabb_alloc = partial(ffi.new, "godot_aabb*")
godot_rect2_alloc = partial(ffi.new, "godot_rect2*")
godot_quat_alloc = partial(ffi.new, "godot_quat*")
godot_plane_alloc = partial(ffi.new, "godot_plane*")
godot_color_alloc = partial(ffi.new, "godot_color*")
godot_basis_alloc = partial(ffi.new, "godot_basis*")
# Use a custom memory allocator to handle destructors
godot_variant_alloc = alloc_with_destructor_factory("godot_variant*",
                                                    lib.godot_variant_new_nil,
                                                    lib.godot_variant_destroy)
godot_string_alloc = alloc_with_destructor_factory("godot_string*",
                                                   lib.godot_string_new,
                                                   lib.godot_string_destroy)
godot_node_path_alloc = alloc_with_destructor_factory(
    "godot_node_path*",
    lambda data, path=godot_string_alloc(): lib.godot_node_path_new(
        data, path),
    lib.godot_node_path_destroy,
)
godot_dictionary_alloc = alloc_with_destructor_factory(
    "godot_dictionary*", lib.godot_dictionary_new,
    lib.godot_dictionary_destroy)
godot_array_alloc = alloc_with_destructor_factory("godot_array*",
                                                  lib.godot_array_new,
                                                  lib.godot_array_destroy)
godot_pool_byte_array_alloc = alloc_with_destructor_factory(
    "godot_pool_byte_array*",
    lib.godot_pool_byte_array_new,
    lib.godot_pool_byte_array_destroy,
)
godot_pool_int_array_alloc = alloc_with_destructor_factory(
    "godot_pool_int_array*",
 def __init__(self, path):
     self._check_param_type("path", path, str)
     gd_str = pyobj_to_gdobj(path)
     self._gd_ptr = godot_node_path_alloc()
     lib.godot_node_path_new(self._gd_ptr, gd_str)