Supporting return values in functions of plugins.
This commit is contained in:
@@ -28,7 +28,7 @@ enum
|
||||
/* Counting functions */
|
||||
enum
|
||||
{
|
||||
#define EXTENSION_FUNCTION(_function_name, _function_wrapper, _args_number, ... /* args */) \
|
||||
#define EXTENSION_FUNCTION(_function_name, _function_wrapper, _ret_value_type, _args_number, ... /* args */) \
|
||||
JERRY_EXTENSION_ ## EXTENSION_NAME ## _ ## _function_name,
|
||||
# include EXTENSION_DESCRIPTION_HEADER
|
||||
#undef EXTENSION_FUNCTION
|
||||
@@ -42,9 +42,9 @@ static const jerry_extension_field_t jerry_extension_fields [JERRY_EXTENSION_FIE
|
||||
{ # _field_name, JERRY_API_DATA_TYPE_ ## _type, _value },
|
||||
# include EXTENSION_DESCRIPTION_HEADER
|
||||
#undef EXTENSION_FIELD
|
||||
{
|
||||
NULL, JERRY_API_DATA_TYPE_UNDEFINED, NULL
|
||||
}
|
||||
#define EMPTY_FIELD_ENTRY { NULL, JERRY_API_DATA_TYPE_UNDEFINED, NULL }
|
||||
EMPTY_FIELD_ENTRY
|
||||
#undef EMPTY_FIELD_ENTRY
|
||||
};
|
||||
|
||||
/* Functions wrapper definitions */
|
||||
@@ -61,11 +61,18 @@ static const jerry_extension_field_t jerry_extension_fields [JERRY_EXTENSION_FIE
|
||||
#define EXTENSION_ARG_PASS_OBJECT(_arg_index) \
|
||||
args_p [_arg_index].v_object
|
||||
#define EXTENSION_ARG(_arg_index, _type) EXTENSION_ARG_PASS_ ## _type(_arg_index)
|
||||
#define EXTENSION_FUNCTION(_function_name, _function_to_call, _args_number, ...) \
|
||||
static void jerry_extension_ ## _function_name ## _wrapper (const jerry_extension_function_t *function_block_p) \
|
||||
#define EXTENSION_RET_VALUE_SET_VOID
|
||||
#define EXTENSION_RET_VALUE_SET_BOOLEAN function_block_p->ret_value.v_bool =
|
||||
#define EXTENSION_RET_VALUE_SET_UINT32 function_block_p->ret_value.v_uint32 =
|
||||
#define EXTENSION_RET_VALUE_SET_FLOAT32 function_block_p->ret_value.v_float32 =
|
||||
#define EXTENSION_RET_VALUE_SET_FLOAT64 function_block_p->ret_value.v_float64 =
|
||||
#define EXTENSION_RET_VALUE_SET_STRING function_block_p->ret_value.v_string =
|
||||
#define EXTENSION_RET_VALUE_SET_OBJECT function_block_p->ret_value.v_object =
|
||||
#define EXTENSION_FUNCTION(_function_name, _function_to_call, _ret_value_type, _args_number, ...) \
|
||||
static void jerry_extension_ ## _function_name ## _wrapper (jerry_extension_function_t *function_block_p) \
|
||||
{ \
|
||||
const jerry_api_value_t *args_p = function_block_p->args_p; \
|
||||
_function_to_call (__VA_ARGS__); \
|
||||
const jerry_api_value_t *args_p = function_block_p->args_p; \
|
||||
EXTENSION_RET_VALUE_SET_ ## _ret_value_type _function_to_call (__VA_ARGS__); \
|
||||
}
|
||||
# include EXTENSION_DESCRIPTION_HEADER
|
||||
#undef EXTENSION_FUNCTION
|
||||
@@ -82,7 +89,7 @@ static const jerry_extension_field_t jerry_extension_fields [JERRY_EXTENSION_FIE
|
||||
(JERRY_API_DATA_TYPE_ ## _type), \
|
||||
false /* just for initialization, should be overwritten upon call */ \
|
||||
}
|
||||
#define EXTENSION_FUNCTION(_function_name, _function_to_call, _args_number, ...) \
|
||||
#define EXTENSION_FUNCTION(_function_name, _function_to_call, _ret_value_type, _args_number, ...) \
|
||||
static jerry_api_value_t jerry_extension_function_ ## _function_name ## _args [_args_number] = { \
|
||||
__VA_ARGS__ \
|
||||
};
|
||||
@@ -91,19 +98,20 @@ static const jerry_extension_field_t jerry_extension_fields [JERRY_EXTENSION_FIE
|
||||
#undef EXTENSION_ARG
|
||||
|
||||
/* Functions description */
|
||||
static const jerry_extension_function_t jerry_extension_functions [JERRY_EXTENSION_FUNCTIONS_NUMBER + 1] =
|
||||
static jerry_extension_function_t jerry_extension_functions [JERRY_EXTENSION_FUNCTIONS_NUMBER + 1] =
|
||||
{
|
||||
#define EXTENSION_FUNCTION(_function_name, _function_wrapper, _args_number, ...) \
|
||||
#define EXTENSION_FUNCTION(_function_name, _function_to_call, _ret_value_type, _args_number, ...) \
|
||||
{ \
|
||||
# _function_name, jerry_extension_ ## _function_name ## _wrapper, \
|
||||
{ JERRY_API_DATA_TYPE_ ## _ret_value_type, false }, \
|
||||
jerry_extension_function_ ## _function_name ## _args, \
|
||||
_args_number \
|
||||
},
|
||||
# include EXTENSION_DESCRIPTION_HEADER
|
||||
#undef EXTENSION_FUNCTION
|
||||
{
|
||||
NULL, NULL, NULL, 0
|
||||
}
|
||||
#define EMPTY_FUNCTION_ENTRY { NULL, NULL, { JERRY_API_DATA_TYPE_VOID, false }, NULL, 0 }
|
||||
EMPTY_FUNCTION_ENTRY
|
||||
#undef EMPTY_FUNCTION_ENTRY
|
||||
};
|
||||
|
||||
static jerry_extension_descriptor_t jerry_extension =
|
||||
|
||||
Reference in New Issue
Block a user