@@ -124,6 +124,15 @@ jerry_make_api_unavailable (void)
124
124
jerry_api_available = false;
125
125
} /* jerry_make_api_unavailable */
126
126
127
+ /**
128
+ * Returns whether the given jerry_value_t is error.
129
+ */
130
+ bool
131
+ jerry_value_is_error (const jerry_value_t value ) /**< api value */
132
+ {
133
+ return ECMA_IS_VALUE_ERROR (value );
134
+ } /* jerry_value_is_error */
135
+
127
136
/**
128
137
* Returns whether the given jerry_value_t is null.
129
138
*/
@@ -310,10 +319,10 @@ jerry_create_string_value (jerry_string_t *str_p) /**< jerry_string_t from which
310
319
*
311
320
* @return completion code
312
321
*/
313
- inline static jerry_completion_code_t __attr_always_inline___
314
- jerry_convert_eval_completion_to_retval (jerry_value_t * retval_p , /**< [out] api value */
315
- ecma_value_t completion ) /**< completion of 'eval'-mode
322
+ static inline jerry_completion_code_t __attr_always_inline___
323
+ jerry_convert_eval_completion_to_retval (ecma_value_t completion , /**< completion of 'eval'-mode
316
324
* code execution */
325
+ jerry_value_t * retval_p ) /**< [out] api value */
317
326
{
318
327
* retval_p = completion ;
319
328
@@ -715,9 +724,9 @@ jerry_dispatch_external_function (ecma_object_t *function_object_p, /**< externa
715
724
716
725
bool is_successful = ((jerry_external_handler_t ) handler_p ) (function_object_p ,
717
726
this_arg_value ,
718
- & ret_value ,
719
727
arguments_list_p ,
720
- arguments_list_len );
728
+ arguments_list_len ,
729
+ & ret_value );
721
730
722
731
if (!is_successful )
723
732
{
@@ -877,14 +886,13 @@ jerry_delete_object_field (jerry_object_t *object_p, /**< object to delete field
877
886
* - there is field with specified name in the object;
878
887
* false - otherwise.
879
888
*/
880
- bool jerry_get_object_field_value ( jerry_object_t * object_p , /**< object */
881
- const jerry_char_t * field_name_p , /**< field name */
882
- jerry_value_t * field_value_p ) /**< [out] field value */
889
+ jerry_value_t
890
+ jerry_get_object_field_value ( jerry_object_t * object_p , /**< object */
891
+ const jerry_char_t * field_name_p ) /**< field name */
883
892
{
884
893
return jerry_get_object_field_value_sz (object_p ,
885
894
field_name_p ,
886
- lit_zt_utf8_string_size (field_name_p ),
887
- field_value_p );
895
+ lit_zt_utf8_string_size (field_name_p ));
888
896
} /* jerry_get_object_field_value */
889
897
890
898
/**
@@ -946,35 +954,29 @@ jerry_foreach_object_field (jerry_object_t *object_p, /**< object */
946
954
* if value was retrieved successfully, it should be freed
947
955
* with jerry_release_value just when it becomes unnecessary.
948
956
*
949
- * @return true, if field value was retrieved successfully, i.e. upon the call:
950
- * - there is field with specified name in the object;
951
- * false - otherwise.
957
+ * @return ecma value
952
958
*/
953
- bool
959
+ jerry_value_t
954
960
jerry_get_object_field_value_sz (jerry_object_t * object_p , /**< object */
955
961
const jerry_char_t * field_name_p , /**< name of the field */
956
- jerry_size_t field_name_size , /**< size of field name in bytes */
957
- jerry_value_t * field_value_p ) /**< [out] field value, if retrieved successfully */
962
+ jerry_size_t field_name_size ) /**< size of field name in bytes */
958
963
{
959
964
jerry_assert_api_available ();
960
965
961
966
ecma_string_t * field_name_str_p = ecma_new_ecma_string_from_utf8 ((lit_utf8_byte_t * ) field_name_p ,
962
967
(lit_utf8_size_t ) field_name_size );
963
968
964
- * field_value_p = ecma_op_object_get (object_p , field_name_str_p );
969
+ ecma_value_t field_value = ecma_op_object_get (object_p , field_name_str_p );
965
970
966
971
ecma_deref_ecma_string (field_name_str_p );
967
972
968
- return (!ECMA_IS_VALUE_ERROR (* field_value_p )
969
- && !ecma_is_value_undefined (* field_value_p ));
973
+ return field_value ;
970
974
} /* jerry_get_object_field_value_sz */
971
975
972
976
/**
973
977
* Set value of field in the specified object
974
978
*
975
- * @return true, if field value was set successfully, i.e. upon the call:
976
- * - field value is writable;
977
- * false - otherwise.
979
+ * @return ecma value
978
980
*/
979
981
bool
980
982
jerry_set_object_field_value (jerry_object_t * object_p , /**< object */
@@ -1098,11 +1100,9 @@ jerry_set_object_native_handle (jerry_object_t *object_p, /**< object to set han
1098
1100
* If function is invoked as constructor, it should support [[Construct]] method,
1099
1101
* otherwise, if function is simply called - it should support [[Call]] method.
1100
1102
*
1101
- * @return true, if invocation was performed successfully, i.e.:
1102
- * - no unhandled exceptions were thrown in connection with the call;
1103
- * false - otherwise.
1103
+ * @return TODO
1104
1104
*/
1105
- static bool
1105
+ static jerry_value_t
1106
1106
jerry_invoke_function (bool is_invoke_as_constructor , /**< true - invoke function as constructor
1107
1107
* (this_arg_p should be NULL, as it is ignored),
1108
1108
* false - perform function call */
@@ -1112,9 +1112,6 @@ jerry_invoke_function (bool is_invoke_as_constructor, /**< true - invoke functio
1112
1112
* if function is invoked as constructor;
1113
1113
* in case of simple function call set 'this'
1114
1114
* binding to the global object) */
1115
- jerry_value_t * retval_p , /**< pointer to place for function's
1116
- * return value / thrown exception value
1117
- * or NULL (to ignore the values) */
1118
1115
const jerry_value_t args_p [], /**< function's call arguments
1119
1116
* (NULL if arguments number is zero) */
1120
1117
jerry_length_t args_count ) /**< number of the arguments */
@@ -1123,8 +1120,6 @@ jerry_invoke_function (bool is_invoke_as_constructor, /**< true - invoke functio
1123
1120
JERRY_STATIC_ASSERT (sizeof (args_count ) == sizeof (ecma_length_t ),
1124
1121
size_of_args_count_must_be_equal_to_size_of_ecma_length_t );
1125
1122
1126
- bool is_successful = true;
1127
-
1128
1123
ecma_value_t call_completion ;
1129
1124
1130
1125
if (is_invoke_as_constructor )
@@ -1157,29 +1152,19 @@ jerry_invoke_function (bool is_invoke_as_constructor, /**< true - invoke functio
1157
1152
args_count );
1158
1153
}
1159
1154
1160
- if (ECMA_IS_VALUE_ERROR (call_completion ))
1161
- {
1162
- /* unhandled exception during the function call */
1163
- is_successful = false;
1164
- }
1165
-
1166
- if (retval_p != NULL )
1167
- {
1168
- * retval_p = call_completion ;
1169
- }
1170
-
1171
- return is_successful ;
1155
+ return call_completion ;
1172
1156
} /* jerry_invoke_function */
1173
1157
1174
1158
/**
1175
1159
* Construct new TypeError object
1160
+ *
1161
+ * @return TypeError object value
1176
1162
*/
1177
- static void
1178
- jerry_construct_type_error (jerry_value_t * retval_p ) /**< [out] value with constructed
1179
- * TypeError object */
1163
+ static inline jerry_value_t __attr_always_inline___
1164
+ jerry_construct_type_error (void )
1180
1165
{
1181
1166
ecma_object_t * type_error_obj_p = ecma_new_standard_error (ECMA_ERROR_TYPE );
1182
- * retval_p = ecma_make_object_value (type_error_obj_p );
1167
+ return ecma_make_error_obj_value (type_error_obj_p );
1183
1168
} /* jerry_construct_type_error */
1184
1169
1185
1170
/**
@@ -1189,20 +1174,12 @@ jerry_construct_type_error (jerry_value_t *retval_p) /**< [out] value with const
1189
1174
* returned value should be freed with jerry_release_value
1190
1175
* just when the value becomes unnecessary.
1191
1176
*
1192
- * @return true, if call was performed successfully, i.e.:
1193
- * - specified object is a function object (see also jerry_is_function);
1194
- * - no unhandled exceptions were thrown in connection with the call;
1195
- * false - otherwise, 'retval_p' contains thrown exception:
1196
- * if called object is not function object - a TypeError instance;
1197
- * else - exception, thrown during the function call.
1177
+ * @return TODO
1198
1178
*/
1199
- bool
1179
+ jerry_value_t
1200
1180
jerry_call_function (jerry_object_t * function_object_p , /**< function object to call */
1201
1181
jerry_object_t * this_arg_p , /**< object for 'this' binding
1202
1182
* or NULL (set 'this' binding to the global object) */
1203
- jerry_value_t * retval_p , /**< pointer to place for function's
1204
- * return value / thrown exception value
1205
- * or NULL (to ignore the values) */
1206
1183
const jerry_value_t args_p [], /**< function's call arguments
1207
1184
* (NULL if arguments number is zero) */
1208
1185
uint16_t args_count ) /**< number of the arguments */
@@ -1211,17 +1188,10 @@ jerry_call_function (jerry_object_t *function_object_p, /**< function object to
1211
1188
1212
1189
if (jerry_is_function (function_object_p ))
1213
1190
{
1214
- return jerry_invoke_function (false, function_object_p , this_arg_p , retval_p , args_p , args_count );
1191
+ return jerry_invoke_function (false, function_object_p , this_arg_p , args_p , args_count );
1215
1192
}
1216
- else
1217
- {
1218
- if (retval_p != NULL )
1219
- {
1220
- jerry_construct_type_error (retval_p );
1221
- }
1222
1193
1223
- return false;
1224
- }
1194
+ return jerry_construct_type_error ();
1225
1195
} /* jerry_call_function */
1226
1196
1227
1197
/**
@@ -1231,18 +1201,10 @@ jerry_call_function (jerry_object_t *function_object_p, /**< function object to
1231
1201
* returned value should be freed with jerry_release_value
1232
1202
* just when the value becomes unnecessary.
1233
1203
*
1234
- * @return true, if construction was performed successfully, i.e.:
1235
- * - specified object is a constructor function object (see also jerry_is_constructor);
1236
- * - no unhandled exceptions were thrown in connection with the invocation;
1237
- * false - otherwise, 'retval_p' contains thrown exception:
1238
- * if specified object is not a constructor function object - a TypeError instance;
1239
- * else - exception, thrown during the invocation.
1204
+ * @return TODO
1240
1205
*/
1241
- bool
1206
+ jerry_value_t
1242
1207
jerry_construct_object (jerry_object_t * function_object_p , /**< function object to call */
1243
- jerry_value_t * retval_p , /**< pointer to place for function's
1244
- * return value / thrown exception value
1245
- * or NULL (to ignore the values) */
1246
1208
const jerry_value_t args_p [], /**< function's call arguments
1247
1209
* (NULL if arguments number is zero) */
1248
1210
uint16_t args_count ) /**< number of the arguments */
@@ -1251,17 +1213,10 @@ jerry_construct_object (jerry_object_t *function_object_p, /**< function object
1251
1213
1252
1214
if (jerry_is_constructor (function_object_p ))
1253
1215
{
1254
- return jerry_invoke_function (true, function_object_p , NULL , retval_p , args_p , args_count );
1216
+ return jerry_invoke_function (true, function_object_p , NULL , args_p , args_count );
1255
1217
}
1256
- else
1257
- {
1258
- if (retval_p != NULL )
1259
- {
1260
- jerry_construct_type_error (retval_p );
1261
- }
1262
1218
1263
- return false;
1264
- }
1219
+ return jerry_construct_type_error ();
1265
1220
} /* jerry_construct_object */
1266
1221
1267
1222
/**
@@ -1306,7 +1261,7 @@ jerry_eval (const jerry_char_t *source_p, /**< source code */
1306
1261
is_direct ,
1307
1262
is_strict );
1308
1263
1309
- status = jerry_convert_eval_completion_to_retval (retval_p , completion );
1264
+ status = jerry_convert_eval_completion_to_retval (completion , retval_p );
1310
1265
1311
1266
return status ;
1312
1267
} /* jerry_eval */
@@ -2086,7 +2041,7 @@ jerry_exec_snapshot (const void *snapshot_p, /**< snapshot */
2086
2041
/* vm should be already initialized */
2087
2042
ecma_value_t completion = vm_run_eval (bytecode_p , false);
2088
2043
2089
- ret_code = jerry_convert_eval_completion_to_retval (retval_p , completion );
2044
+ ret_code = jerry_convert_eval_completion_to_retval (completion , retval_p );
2090
2045
2091
2046
ecma_free_value (completion );
2092
2047
}
0 commit comments