Variant initial rework.

This commit is contained in:
Relintai 2023-05-26 20:40:25 +02:00
parent fae93fe632
commit e350ce381d
2 changed files with 127 additions and 55 deletions

View File

@ -286,8 +286,6 @@ void GDAPI pandemonium_print_error(const char *p_description, const char *p_func
void GDAPI pandemonium_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line);
void GDAPI pandemonium_print(const pandemonium_string *p_message);
// GDNATIVE CORE 1.0.1
bool GDAPI pandemonium_is_instance_valid(const pandemonium_object *p_object);
//tags used for safe dynamic casting

View File

@ -50,6 +50,7 @@ typedef enum pandemonium_variant_type {
PANDEMONIUM_VARIANT_TYPE_NIL,
// atomic types
PANDEMONIUM_VARIANT_TYPE_BOOL,
PANDEMONIUM_VARIANT_TYPE_INT,
PANDEMONIUM_VARIANT_TYPE_REAL,
@ -57,32 +58,48 @@ typedef enum pandemonium_variant_type {
// math types
PANDEMONIUM_VARIANT_TYPE_VECTOR2, // 5
PANDEMONIUM_VARIANT_TYPE_RECT2,
PANDEMONIUM_VARIANT_TYPE_RECT2, // 5
PANDEMONIUM_VARIANT_TYPE_RECT2I,
PANDEMONIUM_VARIANT_TYPE_VECTOR2,
PANDEMONIUM_VARIANT_TYPE_VECTOR2I,
PANDEMONIUM_VARIANT_TYPE_VECTOR3,
PANDEMONIUM_VARIANT_TYPE_TRANSFORM2D,
PANDEMONIUM_VARIANT_TYPE_VECTOR3I, // 10
PANDEMONIUM_VARIANT_TYPE_VECTOR4,
PANDEMONIUM_VARIANT_TYPE_VECTOR4I,
PANDEMONIUM_VARIANT_TYPE_PLANE,
PANDEMONIUM_VARIANT_TYPE_QUATERNION, // 10
PANDEMONIUM_VARIANT_TYPE_QUATERNION,
PANDEMONIUM_VARIANT_TYPE_AABB,
PANDEMONIUM_VARIANT_TYPE_BASIS,
PANDEMONIUM_VARIANT_TYPE_TRANSFORM,
PANDEMONIUM_VARIANT_TYPE_TRANSFORM2D,
PANDEMONIUM_VARIANT_TYPE_PROJECTION,
// misc types
PANDEMONIUM_VARIANT_TYPE_COLOR,
PANDEMONIUM_VARIANT_TYPE_NODE_PATH, // 15
PANDEMONIUM_VARIANT_TYPE_COLOR, // 20
PANDEMONIUM_VARIANT_TYPE_NODE_PATH,
PANDEMONIUM_VARIANT_TYPE_RID,
PANDEMONIUM_VARIANT_TYPE_OBJECT,
PANDEMONIUM_VARIANT_TYPE_DICTIONARY,
PANDEMONIUM_VARIANT_TYPE_ARRAY, // 20
PANDEMONIUM_VARIANT_TYPE_STRING_NAME,
PANDEMONIUM_VARIANT_TYPE_DICTIONARY, // 25
PANDEMONIUM_VARIANT_TYPE_ARRAY,
// arrays
PANDEMONIUM_VARIANT_TYPE_POOL_BYTE_ARRAY,
PANDEMONIUM_VARIANT_TYPE_POOL_INT_ARRAY,
PANDEMONIUM_VARIANT_TYPE_POOL_REAL_ARRAY,
PANDEMONIUM_VARIANT_TYPE_POOL_STRING_ARRAY,
PANDEMONIUM_VARIANT_TYPE_POOL_VECTOR2_ARRAY, // 25
PANDEMONIUM_VARIANT_TYPE_POOL_STRING_ARRAY, //30
PANDEMONIUM_VARIANT_TYPE_POOL_VECTOR2_ARRAY,
PANDEMONIUM_VARIANT_TYPE_POOL_VECTOR2I_ARRAY,
PANDEMONIUM_VARIANT_TYPE_POOL_VECTOR3_ARRAY,
PANDEMONIUM_VARIANT_TYPE_POOL_VECTOR3I_ARRAY,
PANDEMONIUM_VARIANT_TYPE_POOL_VECTOR4_ARRAY, //35
PANDEMONIUM_VARIANT_TYPE_POOL_VECTOR4I_ARRAY,
PANDEMONIUM_VARIANT_TYPE_POOL_COLOR_ARRAY,
//VARIANT_MAX // 38
} pandemonium_variant_type;
typedef enum pandemonium_variant_call_error_error {
@ -169,38 +186,78 @@ extern "C" {
#endif
pandemonium_variant_type GDAPI pandemonium_variant_get_type(const pandemonium_variant *p_v);
//static String get_type_name(Variant::Type p_type);
void GDAPI pandemonium_variant_new_copy(pandemonium_variant *r_dest, const pandemonium_variant *p_src);
//static bool can_convert(Type p_type_from, Type p_type_to);
//static bool can_convert_strict(Type p_type_from, Type p_type_to);
void GDAPI pandemonium_variant_new_nil(pandemonium_variant *r_dest);
//bool is_ref() const;
//_FORCE_INLINE_ bool is_num() const { return type == INT || type == REAL; };
//_FORCE_INLINE_ bool is_array() const { return type >= ARRAY; };
//_FORCE_INLINE_ bool is_null() const { return type == NIL; };
//bool is_shared() const;
//bool is_zero() const;
//bool is_one() const;
void GDAPI pandemonium_variant_new_bool(pandemonium_variant *r_dest, const pandemonium_bool p_b);
void GDAPI pandemonium_variant_new_uint(pandemonium_variant *r_dest, const uint64_t p_i);
void GDAPI pandemonium_variant_new_int(pandemonium_variant *r_dest, const int64_t p_i);
void GDAPI pandemonium_variant_new_real(pandemonium_variant *r_dest, const double p_r);
void GDAPI pandemonium_variant_new_string(pandemonium_variant *r_dest, const pandemonium_string *p_s);
void GDAPI pandemonium_variant_new_vector2(pandemonium_variant *r_dest, const pandemonium_vector2 *p_v2);
void GDAPI pandemonium_variant_new_rect2(pandemonium_variant *r_dest, const pandemonium_rect2 *p_rect2);
void GDAPI pandemonium_variant_new_vector3(pandemonium_variant *r_dest, const pandemonium_vector3 *p_v3);
void GDAPI pandemonium_variant_new_transform2d(pandemonium_variant *r_dest, const pandemonium_transform2d *p_t2d);
void GDAPI pandemonium_variant_new_plane(pandemonium_variant *r_dest, const pandemonium_plane *p_plane);
void GDAPI pandemonium_variant_new_quaternion(pandemonium_variant *r_dest, const pandemonium_quaternion *p_quaternion);
void GDAPI pandemonium_variant_new_aabb(pandemonium_variant *r_dest, const pandemonium_aabb *p_aabb);
void GDAPI pandemonium_variant_new_basis(pandemonium_variant *r_dest, const pandemonium_basis *p_basis);
void GDAPI pandemonium_variant_new_transform(pandemonium_variant *r_dest, const pandemonium_transform *p_trans);
void GDAPI pandemonium_variant_new_color(pandemonium_variant *r_dest, const pandemonium_color *p_color);
void GDAPI pandemonium_variant_new_node_path(pandemonium_variant *r_dest, const pandemonium_node_path *p_np);
void GDAPI pandemonium_variant_new_rid(pandemonium_variant *r_dest, const pandemonium_rid *p_rid);
void GDAPI pandemonium_variant_new_object(pandemonium_variant *r_dest, const pandemonium_object *p_obj);
void GDAPI pandemonium_variant_new_dictionary(pandemonium_variant *r_dest, const pandemonium_dictionary *p_dict);
void GDAPI pandemonium_variant_new_array(pandemonium_variant *r_dest, const pandemonium_array *p_arr);
void GDAPI pandemonium_variant_new_pool_byte_array(pandemonium_variant *r_dest, const pandemonium_pool_byte_array *p_pba);
void GDAPI pandemonium_variant_new_pool_int_array(pandemonium_variant *r_dest, const pandemonium_pool_int_array *p_pia);
void GDAPI pandemonium_variant_new_pool_real_array(pandemonium_variant *r_dest, const pandemonium_pool_real_array *p_pra);
void GDAPI pandemonium_variant_new_pool_string_array(pandemonium_variant *r_dest, const pandemonium_pool_string_array *p_psa);
void GDAPI pandemonium_variant_new_pool_vector2_array(pandemonium_variant *r_dest, const pandemonium_pool_vector2_array *p_pv2a);
void GDAPI pandemonium_variant_new_pool_vector3_array(pandemonium_variant *r_dest, const pandemonium_pool_vector3_array *p_pv3a);
void GDAPI pandemonium_variant_new_pool_color_array(pandemonium_variant *r_dest, const pandemonium_pool_color_array *p_pca);
//ObjectID get_object_instance_id() const;
//bool is_invalid_object() const;
pandemonium_string GDAPI pandemonium_variant_get_operator_name(pandemonium_variant_operator p_op);
void GDAPI pandemonium_variant_evaluate(pandemonium_variant_operator p_op, const pandemonium_variant *p_a, const pandemonium_variant *p_b, pandemonium_variant *r_ret, pandemonium_bool *r_valid);
//static _FORCE_INLINE_ Variant evaluate(const Operator &p_op, const Variant &p_a, const Variant &p_b) {
//void zero();
//Variant duplicate(bool deep = false) const;
//static void blend(const Variant &a, const Variant &b, float c, Variant &r_dst);
//static void interpolate(const Variant &a, const Variant &b, float c, Variant &r_dst);
//static void sub(const Variant &a, const Variant &b, Variant &r_dst);
//void call_ptr(const StringName &p_method, const Variant **p_args, int p_argcount, Variant *r_ret, CallError &r_error);
pandemonium_variant GDAPI pandemonium_variant_call(pandemonium_variant *p_self, const pandemonium_string *p_method, const pandemonium_variant **p_args, const pandemonium_int p_argcount, pandemonium_variant_call_error *r_error);
//Variant call(const StringName &p_method, const Variant &p_arg1 = Variant(), const Variant &p_arg2 = Variant(), const Variant &p_arg3 = Variant(), const Variant &p_arg4 = Variant(), const Variant &p_arg5 = Variant(), const Variant &p_arg6 = Variant(), const Variant &p_arg7 = Variant(), const Variant &p_arg8 = Variant());
//static String get_call_error_text(Object *p_base, const StringName &p_method, const Variant **p_argptrs, int p_argcount, const Variant::CallError &ce);
//static Variant construct(const Variant::Type, const Variant **p_args, int p_argcount, CallError &r_error, bool p_strict = true);
//void get_method_list(List<MethodInfo> *p_list) const;
pandemonium_bool GDAPI pandemonium_variant_has_method(const pandemonium_variant *p_self, const pandemonium_string *p_method);
//static Vector<Variant::Type> get_method_argument_types(Variant::Type p_type, const StringName &p_method);
//static Vector<Variant> get_method_default_arguments(Variant::Type p_type, const StringName &p_method);
//static Variant::Type get_method_return_type(Variant::Type p_type, const StringName &p_method, bool *r_has_return = nullptr);
//static Vector<StringName> get_method_argument_names(Variant::Type p_type, const StringName &p_method);
//static bool is_method_const(Variant::Type p_type, const StringName &p_method);
//void set_named(const StringName &p_index, const Variant &p_value, bool *r_valid = nullptr);
//Variant get_named(const StringName &p_index, bool *r_valid = nullptr) const;
//void set(const Variant &p_index, const Variant &p_value, bool *r_valid = nullptr);
//Variant get(const Variant &p_index, bool *r_valid = nullptr) const;
//bool in(const Variant &p_index, bool *r_valid = nullptr) const;
//bool iter_init(Variant &r_iter, bool &r_valid) const;
//bool iter_next(Variant &r_iter, bool &r_valid) const;
//Variant iter_get(const Variant &r_iter, bool &r_valid) const;
//void get_property_list(List<PropertyInfo> *p_list) const;
//bool deep_equal(const Variant &p_variant, int p_recursion_count = 0) const;
pandemonium_bool GDAPI pandemonium_variant_operator_equal(const pandemonium_variant *p_self, const pandemonium_variant *p_other);
pandemonium_bool GDAPI pandemonium_variant_operator_less(const pandemonium_variant *p_self, const pandemonium_variant *p_other);
//uint32_t hash() const;
pandemonium_bool GDAPI pandemonium_variant_hash_compare(const pandemonium_variant *p_self, const pandemonium_variant *p_other);
pandemonium_bool GDAPI pandemonium_variant_booleanize(const pandemonium_variant *p_self);
//void static_assign(const Variant &p_variant);
//static bool has_constant(Variant::Type p_type, const StringName &p_value);
//static Variant get_constant_value(Variant::Type p_type, const StringName &p_value, bool *r_valid = nullptr);
//typedef String (*ObjectDeConstruct)(const Variant &p_object, void *ud);
//typedef void (*ObjectConstruct)(const String &p_text, void *ud, Variant &r_value);
//String get_construct_string() const;
//static void construct_from_string(const String &p_string, Variant &r_value, ObjectConstruct p_obj_construct = nullptr, void *p_construct_ud = nullptr);
pandemonium_bool GDAPI pandemonium_variant_as_bool(const pandemonium_variant *p_self);
uint64_t GDAPI pandemonium_variant_as_uint(const pandemonium_variant *p_self);
@ -229,25 +286,42 @@ pandemonium_pool_string_array GDAPI pandemonium_variant_as_pool_string_array(con
pandemonium_pool_vector2_array GDAPI pandemonium_variant_as_pool_vector2_array(const pandemonium_variant *p_self);
pandemonium_pool_vector3_array GDAPI pandemonium_variant_as_pool_vector3_array(const pandemonium_variant *p_self);
pandemonium_pool_color_array GDAPI pandemonium_variant_as_pool_color_array(const pandemonium_variant *p_self);
//add the new ones
pandemonium_variant GDAPI pandemonium_variant_call(pandemonium_variant *p_self, const pandemonium_string *p_method, const pandemonium_variant **p_args, const pandemonium_int p_argcount, pandemonium_variant_call_error *r_error);
void GDAPI pandemonium_variant_new_copy(pandemonium_variant *r_dest, const pandemonium_variant *p_src);
pandemonium_bool GDAPI pandemonium_variant_has_method(const pandemonium_variant *p_self, const pandemonium_string *p_method);
pandemonium_bool GDAPI pandemonium_variant_operator_equal(const pandemonium_variant *p_self, const pandemonium_variant *p_other);
pandemonium_bool GDAPI pandemonium_variant_operator_less(const pandemonium_variant *p_self, const pandemonium_variant *p_other);
pandemonium_bool GDAPI pandemonium_variant_hash_compare(const pandemonium_variant *p_self, const pandemonium_variant *p_other);
pandemonium_bool GDAPI pandemonium_variant_booleanize(const pandemonium_variant *p_self);
void GDAPI pandemonium_variant_new_nil(pandemonium_variant *r_dest);
void GDAPI pandemonium_variant_new_bool(pandemonium_variant *r_dest, const pandemonium_bool p_b);
void GDAPI pandemonium_variant_new_uint(pandemonium_variant *r_dest, const uint64_t p_i);
void GDAPI pandemonium_variant_new_int(pandemonium_variant *r_dest, const int64_t p_i);
void GDAPI pandemonium_variant_new_real(pandemonium_variant *r_dest, const double p_r);
void GDAPI pandemonium_variant_new_string(pandemonium_variant *r_dest, const pandemonium_string *p_s);
void GDAPI pandemonium_variant_new_vector2(pandemonium_variant *r_dest, const pandemonium_vector2 *p_v2);
void GDAPI pandemonium_variant_new_rect2(pandemonium_variant *r_dest, const pandemonium_rect2 *p_rect2);
void GDAPI pandemonium_variant_new_vector3(pandemonium_variant *r_dest, const pandemonium_vector3 *p_v3);
void GDAPI pandemonium_variant_new_transform2d(pandemonium_variant *r_dest, const pandemonium_transform2d *p_t2d);
void GDAPI pandemonium_variant_new_plane(pandemonium_variant *r_dest, const pandemonium_plane *p_plane);
void GDAPI pandemonium_variant_new_quaternion(pandemonium_variant *r_dest, const pandemonium_quaternion *p_quaternion);
void GDAPI pandemonium_variant_new_aabb(pandemonium_variant *r_dest, const pandemonium_aabb *p_aabb);
void GDAPI pandemonium_variant_new_basis(pandemonium_variant *r_dest, const pandemonium_basis *p_basis);
void GDAPI pandemonium_variant_new_transform(pandemonium_variant *r_dest, const pandemonium_transform *p_trans);
void GDAPI pandemonium_variant_new_color(pandemonium_variant *r_dest, const pandemonium_color *p_color);
void GDAPI pandemonium_variant_new_node_path(pandemonium_variant *r_dest, const pandemonium_node_path *p_np);
void GDAPI pandemonium_variant_new_rid(pandemonium_variant *r_dest, const pandemonium_rid *p_rid);
void GDAPI pandemonium_variant_new_object(pandemonium_variant *r_dest, const pandemonium_object *p_obj);
void GDAPI pandemonium_variant_new_dictionary(pandemonium_variant *r_dest, const pandemonium_dictionary *p_dict);
void GDAPI pandemonium_variant_new_array(pandemonium_variant *r_dest, const pandemonium_array *p_arr);
void GDAPI pandemonium_variant_new_pool_byte_array(pandemonium_variant *r_dest, const pandemonium_pool_byte_array *p_pba);
void GDAPI pandemonium_variant_new_pool_int_array(pandemonium_variant *r_dest, const pandemonium_pool_int_array *p_pia);
void GDAPI pandemonium_variant_new_pool_real_array(pandemonium_variant *r_dest, const pandemonium_pool_real_array *p_pra);
void GDAPI pandemonium_variant_new_pool_string_array(pandemonium_variant *r_dest, const pandemonium_pool_string_array *p_psa);
void GDAPI pandemonium_variant_new_pool_vector2_array(pandemonium_variant *r_dest, const pandemonium_pool_vector2_array *p_pv2a);
void GDAPI pandemonium_variant_new_pool_vector3_array(pandemonium_variant *r_dest, const pandemonium_pool_vector3_array *p_pv3a);
void GDAPI pandemonium_variant_new_pool_color_array(pandemonium_variant *r_dest, const pandemonium_pool_color_array *p_pca);
//add the new ones
void GDAPI pandemonium_variant_destroy(pandemonium_variant *p_self);
// GDNative core 1.1
pandemonium_string GDAPI pandemonium_variant_get_operator_name(pandemonium_variant_operator p_op);
void GDAPI pandemonium_variant_evaluate(pandemonium_variant_operator p_op, const pandemonium_variant *p_a, const pandemonium_variant *p_b, pandemonium_variant *r_ret, pandemonium_bool *r_valid);
#ifdef __cplusplus
}
#endif