Esempio n. 1
0
 def get_class_consts(cls, classname):
     consts = []
     ret = godot_pool_string_array_alloc()
     lib.godot_pool_string_array_new(ret)
     gd_classname = godot_string_from_pyobj(classname)
     gd_true = godot_bool_alloc(True)
     args = ffi.new("void*[2]", [gd_classname, gd_true])
     # 2nd arg should be false, which what we get by not initializing it
     lib.godot_method_bind_ptrcall(cls._meth_get_integer_constant_list,
                                   cls._instance, args, ret)
     for i in range(lib.godot_pool_string_array_size(ret)):
         godot_str = lib.godot_pool_string_array_get(ret, i)
         raw_str = lib.godot_string_wide_str(ffi.addressof(godot_str))
         consts.append(ffi.string(raw_str))
     return consts
Esempio n. 2
0
    def get_class_list(cls):
        ret = godot_pool_string_array_alloc()
        lib.godot_method_bind_ptrcall(cls._meth_get_class_list, cls._instance,
                                      ffi.NULL, ret)

        # Convert Godot return into Python civilized stuff
        unordered = []
        for i in range(lib.godot_pool_string_array_size(ret)):
            godot_str = lib.godot_pool_string_array_get(ret, i)
            raw_str = lib.godot_string_wide_str(ffi.addressof(godot_str))
            unordered.append(ffi.string(raw_str))

        # Order class to have a parent defined before their children
        classes = []
        while len(unordered) != len(classes):
            for classname in unordered:
                parentname = cls.get_parent_class(classname)
                if not parentname or parentname in classes:
                    if classname not in classes:
                        classes.append(classname)

        return classes