forked from enlightenment/efl
elua: update eolian bindings
This commit is contained in:
parent
e6954d143d
commit
fd28d213a7
|
@ -2,6 +2,7 @@
|
|||
-- For use with Elua
|
||||
|
||||
local ffi = require("ffi")
|
||||
local bit = require("bit")
|
||||
|
||||
ffi.cdef [[
|
||||
typedef unsigned char Eina_Bool;
|
||||
|
@ -13,6 +14,9 @@ ffi.cdef [[
|
|||
typedef struct _Eolian_Function_Parameter Eolian_Function_Parameter;
|
||||
typedef struct _Eolian_Implement Eolian_Implement;
|
||||
typedef struct _Eolian_Event Eolian_Event;
|
||||
typedef struct _Eolian_Expression Eolian_Expression;
|
||||
typedef struct _Eolian_Variable Eolian_Variable;
|
||||
typedef struct _Eolian_Value Eolian_Value;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -44,7 +48,7 @@ ffi.cdef [[
|
|||
{
|
||||
EOLIAN_SCOPE_PUBLIC,
|
||||
EOLIAN_SCOPE_PROTECTED
|
||||
} Eolian_Function_Scope;
|
||||
} Eolian_Object_Scope;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -52,12 +56,76 @@ ffi.cdef [[
|
|||
EOLIAN_TYPE_VOID,
|
||||
EOLIAN_TYPE_REGULAR,
|
||||
EOLIAN_TYPE_REGULAR_STRUCT,
|
||||
EOLIAN_TYPE_REGULAR_ENUM,
|
||||
EOLIAN_TYPE_POINTER,
|
||||
EOLIAN_TYPE_FUNCTION,
|
||||
EOLIAN_TYPE_STRUCT,
|
||||
EOLIAN_TYPE_ALIAS
|
||||
EOLIAN_TYPE_STRUCT_OPAQUE,
|
||||
EOLIAN_TYPE_ENUM,
|
||||
EOLIAN_TYPE_ALIAS,
|
||||
EOLIAN_TYPE_CLASS
|
||||
} Eolian_Type_Type;
|
||||
|
||||
typedef enum {
|
||||
EOLIAN_EXPR_UNKNOWN = 0,
|
||||
EOLIAN_EXPR_INT,
|
||||
EOLIAN_EXPR_UINT,
|
||||
EOLIAN_EXPR_LONG,
|
||||
EOLIAN_EXPR_ULONG,
|
||||
EOLIAN_EXPR_LLONG,
|
||||
EOLIAN_EXPR_ULLONG,
|
||||
EOLIAN_EXPR_FLOAT,
|
||||
EOLIAN_EXPR_DOUBLE,
|
||||
EOLIAN_EXPR_STRING,
|
||||
EOLIAN_EXPR_CHAR,
|
||||
EOLIAN_EXPR_NULL,
|
||||
EOLIAN_EXPR_BOOL,
|
||||
EOLIAN_EXPR_NAME,
|
||||
EOLIAN_EXPR_ENUM,
|
||||
EOLIAN_EXPR_UNARY,
|
||||
EOLIAN_EXPR_BINARY
|
||||
} Eolian_Expression_Type;
|
||||
|
||||
typedef enum {
|
||||
EOLIAN_MASK_SINT = 1 << 0,
|
||||
EOLIAN_MASK_UINT = 1 << 1,
|
||||
EOLIAN_MASK_INT = EOLIAN_MASK_SINT | EOLIAN_MASK_UINT,
|
||||
EOLIAN_MASK_FLOAT = 1 << 2,
|
||||
EOLIAN_MASK_BOOL = 1 << 3,
|
||||
EOLIAN_MASK_STRING = 1 << 4,
|
||||
EOLIAN_MASK_CHAR = 1 << 5,
|
||||
EOLIAN_MASK_NULL = 1 << 6,
|
||||
EOLIAN_MASK_NUMBER = EOLIAN_MASK_INT | EOLIAN_MASK_FLOAT,
|
||||
EOLIAN_MASK_ALL = EOLIAN_MASK_NUMBER | EOLIAN_MASK_BOOL
|
||||
| EOLIAN_MASK_STRING | EOLIAN_MASK_CHAR
|
||||
| EOLIAN_MASK_NULL
|
||||
} Eolian_Expression_Mask;
|
||||
|
||||
typedef enum {
|
||||
EOLIAN_VAR_UNKNOWN = 0,
|
||||
EOLIAN_VAR_CONSTANT,
|
||||
EOLIAN_VAR_GLOBAL
|
||||
} Eolian_Variable_Type;
|
||||
|
||||
typedef union {
|
||||
char c;
|
||||
Eina_Bool b;
|
||||
const char *s;
|
||||
signed int i;
|
||||
unsigned int u;
|
||||
signed long l;
|
||||
unsigned long ul;
|
||||
signed long long ll;
|
||||
unsigned long long ull;
|
||||
float f;
|
||||
double d;
|
||||
} Eolian_Value_Union;
|
||||
|
||||
typedef struct _Eolian_Value_t {
|
||||
Eolian_Expression_Type type;
|
||||
Eolian_Value_Union value;
|
||||
} Eolian_Value_t;
|
||||
|
||||
Eina_Bool eolian_eo_file_parse(const char *filename);
|
||||
Eina_Bool eolian_eot_file_parse(const char *filepath);
|
||||
int eolian_init(void);
|
||||
|
@ -69,6 +137,9 @@ ffi.cdef [[
|
|||
Eina_Bool eolian_show_class(const Eolian_Class *klass);
|
||||
Eina_Bool eolian_show_typedef(const char *alias);
|
||||
Eina_Bool eolian_show_struct(const char *name);
|
||||
Eina_Bool eolian_show_enum(const char *name);
|
||||
Eina_Bool eolian_show_global(const char *name);
|
||||
Eina_Bool eolian_show_constant(const char *name);
|
||||
void eolian_show_all();
|
||||
const Eolian_Class *eolian_class_get_by_name(const char *class_name);
|
||||
const Eolian_Class *eolian_class_get_by_file(const char *file_name);
|
||||
|
@ -85,49 +156,63 @@ ffi.cdef [[
|
|||
Eina_Iterator *eolian_class_inherits_get(const Eolian_Class *klass);
|
||||
Eina_Iterator *eolian_class_functions_get(const Eolian_Class *klass, Eolian_Function_Type func_type);
|
||||
Eolian_Function_Type eolian_function_type_get(const Eolian_Function *function_id);
|
||||
Eolian_Function_Scope eolian_function_scope_get(const Eolian_Function *function_id);
|
||||
Eolian_Object_Scope eolian_function_scope_get(const Eolian_Function *function_id);
|
||||
const char *eolian_function_name_get(const Eolian_Function *function_id);
|
||||
const char *eolian_function_full_c_name_get(const Eolian_Function *function_id, const char *prefix);
|
||||
const Eolian_Function *eolian_class_function_get_by_name(const Eolian_Class *klass, const char *func_name, Eolian_Function_Type f_type);
|
||||
const char *eolian_function_data_get(const Eolian_Function *function_id, const char *key);
|
||||
const char *eolian_function_legacy_get(const Eolian_Function *function_id, Eolian_Function_Type f_type);
|
||||
const char *eolian_function_description_get(const Eolian_Function *function_id, Eolian_Function_Type f_type);
|
||||
Eina_Bool eolian_function_is_virtual_pure(const Eolian_Function *function_id, Eolian_Function_Type f_type);
|
||||
Eina_Bool eolian_function_is_class(const Eolian_Function *function_id);
|
||||
const Eolian_Function_Parameter *eolian_function_parameter_get_by_name(const Eolian_Function *function_id, const char *param_name);
|
||||
Eina_Iterator *eolian_property_keys_get(const Eolian_Function *foo_id);
|
||||
Eina_Iterator *eolian_property_values_get(const Eolian_Function *foo_id);
|
||||
Eina_Iterator *eolian_function_parameters_get(const Eolian_Function *function_id);
|
||||
void eolian_parameter_information_get(const Eolian_Function_Parameter *param_desc, Eolian_Parameter_Dir *param_dir, const Eolian_Type **type, const char **name, const char **description);
|
||||
Eolian_Parameter_Dir eolian_parameter_direction_get(const Eolian_Function_Parameter *param);
|
||||
const Eolian_Type *eolian_parameter_type_get(const Eolian_Function_Parameter *param);
|
||||
const char *eolian_parameter_name_get(const Eolian_Function_Parameter *param);
|
||||
const char *eolian_parameter_description_get(const Eolian_Function_Parameter *param);
|
||||
Eina_Bool eolian_parameter_const_attribute_get(const Eolian_Function_Parameter *param_desc, Eina_Bool is_get);
|
||||
Eina_Bool eolian_parameter_is_nonull(const Eolian_Function_Parameter *param_desc);
|
||||
const Eolian_Type *eolian_function_return_type_get(const Eolian_Function *function_id, Eolian_Function_Type ftype);
|
||||
const char *eolian_function_return_default_value_get(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
|
||||
const Eolian_Expression *eolian_function_return_default_value_get(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
|
||||
const char *eolian_function_return_comment_get(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
|
||||
Eina_Bool eolian_function_return_is_warn_unused(const Eolian_Function *foo_id, Eolian_Function_Type ftype);
|
||||
Eina_Bool eolian_function_object_is_const(const Eolian_Function *function_id);
|
||||
Eina_Bool eolian_type_is_extern(const Eolian_Type *tp);
|
||||
const char *eolian_implement_full_name_get(const Eolian_Implement *impl);
|
||||
Eina_Bool eolian_implement_information_get(const Eolian_Implement *impl, const Eolian_Class *klass, const Eolian_Function *function, Eolian_Function_Type *type);
|
||||
const Eolian_Class *eolian_implement_class_get(const Eolian_Implement *impl);
|
||||
const Eolian_Function *eolian_implement_function_get(const Eolian_Implement *impl, Eolian_Function_Type *func_type);
|
||||
Eina_Iterator *eolian_class_implements_get(const Eolian_Class *klass);
|
||||
Eina_Iterator *eolian_class_events_get(const Eolian_Class *klass);
|
||||
Eina_Bool eolian_class_event_information_get(const Eolian_Event *event, const char **event_name, const Eolian_Type **event_type, const char **event_desc);
|
||||
const char *eolian_event_name_get(const Eolian_Event *event);
|
||||
const Eolian_Type *eolian_event_type_get(const Eolian_Event *event);
|
||||
const char *eolian_event_description_get(const Eolian_Event *event);
|
||||
Eolian_Object_Scope eolian_event_scope_get(const Eolian_Event *event);
|
||||
Eina_Bool eolian_class_ctor_enable_get(const Eolian_Class *klass);
|
||||
Eina_Bool eolian_class_dtor_enable_get(const Eolian_Class *klass);
|
||||
const Eolian_Type *eolian_type_alias_get_by_name(const char *name);
|
||||
const Eolian_Type *eolian_type_struct_get_by_name(const char *name);
|
||||
const Eolian_Type *eolian_type_enum_get_by_name(const char *name);
|
||||
Eina_Iterator *eolian_type_aliases_get_by_file(const char *fname);
|
||||
Eina_Iterator *eolian_type_structs_get_by_file(const char *fname);
|
||||
Eina_Iterator *eolian_type_enums_get_by_file(const char *fname);
|
||||
Eolian_Type_Type eolian_type_type_get(const Eolian_Type *tp);
|
||||
Eina_Iterator *eolian_type_arguments_get(const Eolian_Type *tp);
|
||||
Eina_Iterator *eolian_type_subtypes_get(const Eolian_Type *tp);
|
||||
Eina_Iterator *eolian_type_struct_field_names_get(const Eolian_Type *tp);
|
||||
const Eolian_Type *eolian_type_struct_field_get(const Eolian_Type *tp, const char *field);
|
||||
const char *eolian_type_struct_field_description_get(const Eolian_Type *tp, const char *field);
|
||||
Eina_Iterator *eolian_type_enum_field_names_get(const Eolian_Type *tp);
|
||||
Eina_Bool eolian_type_enum_field_exists(const Eolian_Type *tp, const char *field);
|
||||
const Eolian_Expression *eolian_type_enum_field_get(const Eolian_Type *tp, const char *field);
|
||||
const char *eolian_type_enum_field_description_get(const Eolian_Type *tp, const char *field);
|
||||
const char *eolian_type_enum_legacy_prefix_get(const Eolian_Type *tp);
|
||||
const char *eolian_type_description_get(const Eolian_Type *tp);
|
||||
const char *eolian_type_file_get(const Eolian_Type *tp);
|
||||
const Eolian_Type *eolian_type_return_type_get(const Eolian_Type *tp);
|
||||
const Eolian_Type *eolian_type_base_type_get(const Eolian_Type *tp);
|
||||
const Eolian_Class *eolian_type_class_get(const Eolian_Type *tp);
|
||||
Eina_Bool eolian_type_is_own(const Eolian_Type *tp);
|
||||
Eina_Bool eolian_type_is_const(const Eolian_Type *tp);
|
||||
const char *eolian_type_c_type_named_get(const Eolian_Type *tp, const char *name);
|
||||
|
@ -135,6 +220,24 @@ ffi.cdef [[
|
|||
const char *eolian_type_name_get(const Eolian_Type *tp);
|
||||
const char *eolian_type_full_name_get(const Eolian_Type *tp);
|
||||
Eina_Iterator *eolian_type_namespaces_get(const Eolian_Type *tp);
|
||||
|
||||
Eolian_Value_t eolian_expression_eval(const Eolian_Expression *expr, Eolian_Expression_Mask m);
|
||||
Eolian_Value_t eolian_expression_eval_type(const Eolian_Expression *expr, const Eolian_Type *type);
|
||||
const char *eolian_expression_value_to_literal(const Eolian_Value *v);
|
||||
const char *eolian_expression_serialize(const Eolian_Expression *expr);
|
||||
const Eolian_Variable *eolian_variable_global_get_by_name(const char *name);
|
||||
const Eolian_Variable *eolian_variable_constant_get_by_name(const char *name);
|
||||
Eina_Iterator *eolian_variable_globals_get_by_file(const char *fname);
|
||||
Eina_Iterator *eolian_variable_constants_get_by_file(const char *fname);
|
||||
Eolian_Variable_Type eolian_variable_type_get(const Eolian_Variable *var);
|
||||
const char *eolian_variable_description_get(const Eolian_Variable *var);
|
||||
const char *eolian_variable_file_get(const Eolian_Variable *var);
|
||||
const Eolian_Type *eolian_variable_base_type_get(const Eolian_Variable *var);
|
||||
const Eolian_Expression *eolian_variable_value_get(const Eolian_Variable *var);
|
||||
const char *eolian_variable_name_get(const Eolian_Variable *var);
|
||||
const char *eolian_variable_full_name_get(const Eolian_Variable *var);
|
||||
Eina_Iterator *eolian_variable_namespaces_get(const Eolian_Variable *var);
|
||||
Eina_Bool eolian_variable_is_extern(const Eolian_Variable *var);
|
||||
]]
|
||||
|
||||
local cutil = require("cutil")
|
||||
|
@ -160,6 +263,12 @@ end
|
|||
|
||||
cutil.init_module(init, shutdown)
|
||||
|
||||
M.object_scope = {
|
||||
PUBLIC = 0,
|
||||
PRIVATE = 1,
|
||||
PROTECTED = 2
|
||||
}
|
||||
|
||||
M.directory_scan = function(dir)
|
||||
return eolian.eolian_directory_scan(dir) ~= 0
|
||||
end
|
||||
|
@ -196,6 +305,18 @@ M.show_struct = function(name)
|
|||
return eolian.eolian_show_typedef(name) ~= 0
|
||||
end
|
||||
|
||||
M.show_enum = function(name)
|
||||
return eolian.eolian_show_enum(name) ~= 0
|
||||
end
|
||||
|
||||
M.show_global = function(name)
|
||||
return eolian.eolian_show_global(name) ~= 0
|
||||
end
|
||||
|
||||
M.show_consatnt = function(name)
|
||||
return eolian.eolian_show_constant(name) ~= 0
|
||||
end
|
||||
|
||||
M.show_all = function()
|
||||
eolian.eolian_show_all()
|
||||
end
|
||||
|
@ -205,10 +326,14 @@ M.type_type = {
|
|||
VOID = 1,
|
||||
REGULAR = 2,
|
||||
REGULAR_STRUCT = 3,
|
||||
POINTER = 4,
|
||||
FUNCTION = 5,
|
||||
STRUCT = 6,
|
||||
ALIAS = 7,
|
||||
REGULAR_ENUM = 4,
|
||||
POINTER = 5,
|
||||
FUNCTION = 6,
|
||||
STRUCT = 7,
|
||||
STRUCT_OPAQUE = 8,
|
||||
ENUM = 9,
|
||||
ALIAS = 10,
|
||||
CLASS = 11
|
||||
}
|
||||
|
||||
M.Type = ffi.metatype("Eolian_Type", {
|
||||
|
@ -244,6 +369,33 @@ M.Type = ffi.metatype("Eolian_Type", {
|
|||
return ffi.string(v)
|
||||
end,
|
||||
|
||||
enum_field_names_get = function(self)
|
||||
return iterator.String_Iterator(
|
||||
eolian.eolian_type_enum_field_names_get(self))
|
||||
end,
|
||||
|
||||
enum_field_exists = function(self, field)
|
||||
return eolian.eolian_type_enum_field_exists(self, field) ~= 0
|
||||
end,
|
||||
|
||||
enum_field_get = function(self, field)
|
||||
local v = eolian.eolian_type_enum_field_get(self, field)
|
||||
if v == nil thenr eturn nil end
|
||||
return v
|
||||
end,
|
||||
|
||||
enum_field_description_get = function(self, name)
|
||||
local v = eolian.eolian_type_enum_field_description_get(self, name)
|
||||
if v == nil then return nil end
|
||||
return ffi.string(v)
|
||||
end,
|
||||
|
||||
enum_legacy_prefix_get = function(self)
|
||||
local v = eolian.eolian_type_enum_legacy_prefix_get(self)
|
||||
if v == nil then return nil end
|
||||
return ffi.string(v)
|
||||
end,
|
||||
|
||||
description_get = function(self, name)
|
||||
local v = eolian.eolian_type_description_get(self)
|
||||
if v == nil then return nil end
|
||||
|
@ -268,6 +420,12 @@ M.Type = ffi.metatype("Eolian_Type", {
|
|||
return v
|
||||
end,
|
||||
|
||||
class_get = function(self)
|
||||
local v = eolian.eolian_type_class_get(self)
|
||||
if v == nil then return nil end
|
||||
return v
|
||||
end,
|
||||
|
||||
is_own = function(self)
|
||||
return eolian.eolian_type_is_own(self) ~= 0
|
||||
end,
|
||||
|
@ -311,6 +469,13 @@ M.Type = ffi.metatype("Eolian_Type", {
|
|||
}
|
||||
})
|
||||
|
||||
M.Expression = ffi.metatype("Eolian_Expression", {
|
||||
__index = {
|
||||
eval = function(self, mask)
|
||||
end
|
||||
}
|
||||
})
|
||||
|
||||
M.function_type = {
|
||||
UNRESOLVED = 0,
|
||||
PROPERTY = 1,
|
||||
|
@ -320,11 +485,6 @@ M.function_type = {
|
|||
CTOR = 5
|
||||
}
|
||||
|
||||
M.function_scope = {
|
||||
PUBLIC = 0,
|
||||
PROTECTED = 1
|
||||
}
|
||||
|
||||
M.Function = ffi.metatype("Eolian_Function", {
|
||||
__index = {
|
||||
type_get = function(self)
|
||||
|
@ -347,14 +507,16 @@ M.Function = ffi.metatype("Eolian_Function", {
|
|||
return ffi.string(v)
|
||||
end,
|
||||
|
||||
data_get = function(self, key)
|
||||
local v = eolian.eolian_function_data_get(self, key)
|
||||
legacy_get = function(self, ftype)
|
||||
local v = eolian.eolian_function_legacy_get(self, ftype)
|
||||
if v == nil then return nil end
|
||||
return ffi.string(v)
|
||||
end,
|
||||
|
||||
description_get = function(self, key)
|
||||
return self:data_get(key)
|
||||
description_get = function(self, ftype)
|
||||
local v = eolian.eolian_function_description_get(self, ftype)
|
||||
if v == nil then return nil end
|
||||
return ffi.string(v)
|
||||
end,
|
||||
|
||||
is_virtual_pure = function(self, ftype)
|
||||
|
@ -395,7 +557,7 @@ M.Function = ffi.metatype("Eolian_Function", {
|
|||
return_default_value_get = function(self, ftype)
|
||||
local v = eolian.eolian_function_return_default_value_get(self, ftype)
|
||||
if v == nil then return nil end
|
||||
return ffi.string(v)
|
||||
return v
|
||||
end,
|
||||
|
||||
return_comment_get = function(self, ftype)
|
||||
|
@ -423,16 +585,8 @@ M.parameter_dir = {
|
|||
|
||||
ffi.metatype("Eolian_Function_Parameter", {
|
||||
__index = {
|
||||
information_get = function(self)
|
||||
local dir = ffi.new("Eolian_Parameter_Dir[1]")
|
||||
local str = ffi.new("const char*[2]")
|
||||
local tp = ffi.new("const Eolian_Type*[1]")
|
||||
eolian.eolian_parameter_information_get(self, dir, tp, str, str + 1)
|
||||
local tp, nm, dsc = tp[0], str[0], str[1]
|
||||
tp, nm, dsc = (tp ~= nil) and tp or nil,
|
||||
(nm ~= nil) and ffi.string(nm ) or nil,
|
||||
(dsc ~= nil) and ffi.string(dsc) or nil
|
||||
return dir[0], tp, nm, dsc
|
||||
direction_get = function(self)
|
||||
return eolian.eolian_parameter_direction_get(self)
|
||||
end,
|
||||
|
||||
type_get = function(self)
|
||||
|
@ -447,6 +601,12 @@ ffi.metatype("Eolian_Function_Parameter", {
|
|||
return ffi.string(v)
|
||||
end,
|
||||
|
||||
description_get = function(self)
|
||||
local v = eolian.eolian_parameter_description_get(self)
|
||||
if v == nil then return nil end
|
||||
return ffi.string(v)
|
||||
end,
|
||||
|
||||
const_attribute_get = function(self, get)
|
||||
return eolian.eolian_parameter_const_attribute_get(self, get) ~= 0
|
||||
end,
|
||||
|
@ -465,27 +625,43 @@ ffi.metatype("Eolian_Implement", {
|
|||
return ffi.string(v)
|
||||
end,
|
||||
|
||||
information_get = function(self)
|
||||
local cl = ffi.new("const Eolian_Class*[1]")
|
||||
local fn = ffi.new("const Eolian_Function*[1]")
|
||||
class_get = function(self)
|
||||
local v = eolian.eolian_implement_class_get(self)
|
||||
if v == nil then return nil end
|
||||
return v
|
||||
end,
|
||||
|
||||
function_get = function(self)
|
||||
local tp = ffi.new("Eolian_Function_Type[1]")
|
||||
eolian.eolian_implement_information_get(self, cl, fn, tp)
|
||||
return cl[0], fn[0], tp[0]
|
||||
local v = eolian.eolian_implement_class_get(self, tp)
|
||||
if v == nil then return nil end
|
||||
return v, tp[0]
|
||||
end
|
||||
}
|
||||
})
|
||||
|
||||
ffi.metatype("Eolian_Event", {
|
||||
__index = {
|
||||
information_get = function(self)
|
||||
local ev = ffi.new("const char*[2]")
|
||||
local tp = ffi.new("const Eolian_Type*[1]");
|
||||
eolian.eolian_class_event_information_get(self, ev, tp, ev + 1)
|
||||
local en, et, ed = ev[0], tp[0], ev[1]
|
||||
en, et, ed = (en ~= nil) and ffi.string(en) or nil,
|
||||
(et ~= nil) and et or nil,
|
||||
(ed ~= nil) and ffi.string(ed) or nil
|
||||
return en, et, ed
|
||||
name_get = function(self)
|
||||
local v = eolian.eolian_event_name_get(self)
|
||||
if v == nil then return nil end
|
||||
return ffi.string(v)
|
||||
end,
|
||||
|
||||
type_get = function(self)
|
||||
local v = eolian.eolian_event_type_get(self)
|
||||
if v == nil then return nil end
|
||||
return v
|
||||
end,
|
||||
|
||||
description_get = function(self)
|
||||
local v = eolian.eolian_event_description_get(self)
|
||||
if v == nil then return nil end
|
||||
return ffi.string(v)
|
||||
end,
|
||||
|
||||
scope_get = function(self)
|
||||
return eolian.eolian_event_scope_get(self)
|
||||
end
|
||||
}
|
||||
})
|
||||
|
@ -621,6 +797,12 @@ M.type_struct_get_by_name = function(name)
|
|||
return v
|
||||
end
|
||||
|
||||
M.type_enum_get_by_name = function(name)
|
||||
local v = eolian.eolian_type_enum_get_by_name(name)
|
||||
if v == nil then return nil end
|
||||
return v
|
||||
end
|
||||
|
||||
M.type_aliases_get_by_file = function(fname)
|
||||
return Ptr_Iterator("const Eolian_Type*",
|
||||
eolian.eolian_type_aliases_get_by_file(self))
|
||||
|
@ -631,4 +813,188 @@ M.type_structs_get_by_file = function(fname)
|
|||
eolian.eolian_type_structs_get_by_file(self))
|
||||
end
|
||||
|
||||
M.type_enums_get_by_file = function(fname)
|
||||
return Ptr_Iterator("const Eolian_Type*",
|
||||
eolian.eolian_type_enums_get_by_file(self))
|
||||
end
|
||||
|
||||
M.expression_type = {
|
||||
UNKNOWN = 0,
|
||||
INT = 1,
|
||||
UINT = 2,
|
||||
LONG = 3,
|
||||
ULONG = 4,
|
||||
LLONG = 5,
|
||||
ULLONG = 6,
|
||||
FLOAT = 7,
|
||||
DOUBLE = 8,
|
||||
STRING = 9,
|
||||
CHAR = 10,
|
||||
NULL = 11,
|
||||
BOOL = 12,
|
||||
NAME = 13,
|
||||
ENUM = 14,
|
||||
UNARY = 15,
|
||||
BINARY = 16
|
||||
}
|
||||
|
||||
local etype = M.expression_type
|
||||
|
||||
M.expression_mask = {
|
||||
SINT = bit.lshift(1, 0),
|
||||
UINT = bit.lshift(1, 1),
|
||||
FLOAT = bit.lshift(1, 2),
|
||||
BOOL = bit.lshift(1, 3),
|
||||
STRING = bit.lshift(1, 4),
|
||||
CHAR = bit.lshift(1, 5),
|
||||
NULL = bit.lshift(1, 6)
|
||||
}
|
||||
|
||||
local emask = M.expression_mask
|
||||
|
||||
emask.INT = bit.bor(emask.SINT , emask.UINT )
|
||||
emask.NUMBER = bit.bor(emask.INT , emask.FLOAT)
|
||||
emask.ALL = bit.bor(emask.NUMBER, emask.BOOL,
|
||||
emask.STRING, emask.CHAR, emask.NULL)
|
||||
|
||||
M.variable_type = {
|
||||
UNKNOWN = 0,
|
||||
CONSTANT = 1,
|
||||
GLOBAL = 2
|
||||
}
|
||||
|
||||
local value_con = {
|
||||
[etype.INT ] = function(v) return tonumber(v.value.i ) end,
|
||||
[etype.UINT ] = function(v) return tonumber(v.value.u ) end,
|
||||
[etype.LONG ] = function(v) return tonumber(v.value.l ) end,
|
||||
[etype.ULONG ] = function(v) return tonumber(v.value.ul ) end,
|
||||
[etype.LLONG ] = function(v) return tonumber(v.value.ll ) end,
|
||||
[etype.ULLONG] = function(v) return tonumber(v.value.ull ) end,
|
||||
[etype.FLOAT ] = function(v) return tonumber(v.value.f ) end,
|
||||
[etype.DOUBLE] = function(v) return tonumber(v.value.d ) end,
|
||||
[etype.STRING] = function(v) return ffi.string(v.value.s ) end,
|
||||
[etype.CHAR ] = function(v) return string.char(v.value.c) end,
|
||||
[etype.NULL ] = function(v) return nil end,
|
||||
[etype.BOOL ] = function(v) return v.value.b ~= 0 end
|
||||
}
|
||||
|
||||
M.Value = ffi.metatype("Eolian_Value", {
|
||||
__index = {
|
||||
get_type = function(self)
|
||||
return ffi.cast("Eolian_Value_t*", self).type
|
||||
end,
|
||||
|
||||
get_value = function(self)
|
||||
local tp = self:get_type()
|
||||
local fun = value_con[tonumber(tp)]
|
||||
if not fun then return nil end
|
||||
return fun()
|
||||
end,
|
||||
|
||||
to_literal = function(self)
|
||||
local v = eolian.eolian_expression_value_to_literal(self)
|
||||
if v == nil then return nil end
|
||||
return ffi.string(v)
|
||||
end
|
||||
}
|
||||
})
|
||||
|
||||
M.Expression = ffi.metatype("Eolian_Expression", {
|
||||
__index = {
|
||||
eval = function(self, mask)
|
||||
mask = mask or emask.ALL
|
||||
local v = eolian.eolian_expression_eval(self, mask)
|
||||
if v == nil then return nil end
|
||||
return ffi.cast("Eolian_Value*", v)
|
||||
end,
|
||||
|
||||
eval_type = function(self, tp)
|
||||
local v = eolian.eolian_expression_eval_type(self, tp)
|
||||
if v == nil then return nil end
|
||||
return ffi.cast("Eolian_Value*", v)
|
||||
end,
|
||||
|
||||
serialize = function(self)
|
||||
local v = eolian.eolian_expression_serialize(self)
|
||||
if v == nil then return nil end
|
||||
return ffi.string(v)
|
||||
end
|
||||
}
|
||||
})
|
||||
|
||||
M.variable_global_get_by_name = function(name)
|
||||
local v = eolian.eolian_variable_global_get_by_name(name)
|
||||
if v == nil then return nil end
|
||||
return v
|
||||
end
|
||||
|
||||
M.variable_constant_get_by_name = function(name)
|
||||
local v = eolian.eolian_variable_constant_get_by_name(name)
|
||||
if v == nil then return nil end
|
||||
return v
|
||||
end
|
||||
|
||||
M.variable_globals_get_by_file = function(fname)
|
||||
return Ptr_Iterator("const Eolian_Variable*",
|
||||
eolian.eolian_variable_globals_get_by_file(self))
|
||||
end
|
||||
|
||||
M.variable_constants_get_by_file = function(fname)
|
||||
return Ptr_Iterator("const Eolian_Variable*",
|
||||
eolian.eolian_variable_constants_get_by_file(self))
|
||||
end
|
||||
|
||||
M.Variable = ffi.metatype("Eolian_Variable", {
|
||||
__index = {
|
||||
type_get = function(self)
|
||||
return eolian.eolian_variable_type_get(self)
|
||||
end,
|
||||
|
||||
description_get = function(self)
|
||||
local v = eolian.eolian_variable_description_get(self)
|
||||
if v == nil then return nil end
|
||||
return ffi.string(v)
|
||||
end,
|
||||
|
||||
file_get = function(self)
|
||||
local v = eolian.eolian_variable_file_get(self)
|
||||
if v == nil then return nil end
|
||||
return ffi.string(v)
|
||||
end,
|
||||
|
||||
base_type_get = function(self)
|
||||
local v = eolian.eolian_variable_base_type_get(self)
|
||||
if v == nil then return nil end
|
||||
return v
|
||||
end,
|
||||
|
||||
value_get = function(self)
|
||||
local v = eolian.eolian_variable_value_get(self)
|
||||
if v == nil then return nil end
|
||||
return v
|
||||
end,
|
||||
|
||||
name_get = function(self)
|
||||
local v = eolian.eolian_variable_name_get(self)
|
||||
if v == nil then return nil end
|
||||
return ffi.string(v)
|
||||
end,
|
||||
|
||||
full_name_get = function(self)
|
||||
local v = eolian.eolian_variable_full_name_get(self)
|
||||
if v == nil then return nil end
|
||||
return ffi.string(v)
|
||||
end,
|
||||
|
||||
namespaces_get = function(self)
|
||||
return iterator.String_Iterator(
|
||||
eolian.eolian_variable_namespaces_get(self))
|
||||
end,
|
||||
|
||||
is_extern = function(self)
|
||||
return eolian.eolian_variable_is_extern(self) ~= 0
|
||||
end
|
||||
}
|
||||
})
|
||||
|
||||
return M
|
||||
|
|
Loading…
Reference in New Issue