diff --git a/CMakeLists.txt b/CMakeLists.txt index c2b2a9ca29..6b28f7c0f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -306,15 +306,11 @@ project (Jerry CXX C ASM) # Jerry's Core add_subdirectory(jerry-core) - # Plugins - add_subdirectory(plugins) - # Targets declaration string(TOLOWER "${PLATFORM_EXT}" PLATFORM_L) function(declare_targets_for_build_mode BUILD_MODE) set(TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}}.${PLATFORM_L}) - set(PLUGINS_TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}}.plugins.${PLATFORM_L}.lib) set(LIBC_TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}}.jerry-libc.${PLATFORM_L}.lib) function(declare_target_with_modifiers ) # modifiers are passed in ARGN implicit argument @@ -353,7 +349,7 @@ project (Jerry CXX C ASM) target_include_directories(${TARGET_NAME} PRIVATE ${INCLUDE_CORE_INTERFACE}) target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${INCLUDE_LIBC_INTERFACE}) target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${INCLUDE_EXTERNAL_LIBS_INTERFACE}) - target_link_libraries(${TARGET_NAME} ${PLUGINS_TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME} + target_link_libraries(${TARGET_NAME} ${CORE_TARGET_NAME} ${LIBC_TARGET_NAME} ${FDLIBM_TARGET_NAME} ${PREFIX_IMPORTED_LIB}libgcc ${PREFIX_IMPORTED_LIB}libgcc_eh) add_cppcheck_target(${TARGET_NAME}) @@ -386,7 +382,7 @@ project (Jerry CXX C ASM) target_include_directories(${MAIN_MODULE_TARGET_NAME} SYSTEM PRIVATE ${INCLUDE_EXTERNAL_LIBS_INTERFACE}) add_custom_target(${TARGET_NAME} ALL) - add_dependencies(${TARGET_NAME} ${MAIN_MODULE_TARGET_NAME} ${FDLIBM_TARGET_NAME} ${PLUGINS_TARGET_NAME} ${CORE_TARGET_NAME}) + add_dependencies(${TARGET_NAME} ${MAIN_MODULE_TARGET_NAME} ${FDLIBM_TARGET_NAME}${CORE_TARGET_NAME}) add_custom_command(TARGET ${TARGET_NAME} POST_BUILD @@ -394,7 +390,6 @@ project (Jerry CXX C ASM) COMMAND echo $ $ - $ $ > ${CMAKE_BINARY_DIR}/${TARGET_NAME}/list) if(${USE_JERRY_LIBC}) diff --git a/Makefile b/Makefile index e1909f42c9..7c890cc328 100644 --- a/Makefile +++ b/Makefile @@ -215,8 +215,6 @@ $(BUILD_ALL)_native: $(BUILD_DIRS_NATIVE) (echo "Build failed. See $(OUT_DIR)/$@/make.log for details."; exit 1;) @ $(MAKE) -C $(BUILD_DIR)/native jerry-fdlibm-all VERBOSE=1 &>$(OUT_DIR)/$@/make.log || \ (echo "Build failed. See $(OUT_DIR)/$@/make.log for details."; exit 1;) - @ $(MAKE) -C $(BUILD_DIR)/native plugins-all VERBOSE=1 &>$(OUT_DIR)/$@/make.log || \ - (echo "Build failed. See $(OUT_DIR)/$@/make.log for details."; exit 1;) @ $(MAKE) -C $(BUILD_DIR)/native $(JERRY_LINUX_TARGETS) unittests VERBOSE=1 &>$(OUT_DIR)/$@/make.log || \ (echo "Build failed. See $(OUT_DIR)/$@/make.log for details."; exit 1;) @@ -230,8 +228,6 @@ $(JERRY_NUTTX_TARGETS): $(BUILD_DIR)/nuttx $(BUILD_ALL)_nuttx: $(BUILD_DIRS_NUTTX) @ mkdir -p $(OUT_DIR)/$@ - @ $(MAKE) -C $(BUILD_DIR)/nuttx plugins-all VERBOSE=1 &>$(OUT_DIR)/$@/make.log || \ - (echo "Build failed. See $(OUT_DIR)/$@/make.log for details."; exit 1;) @ $(MAKE) -C $(BUILD_DIR)/nuttx $(JERRY_NUTTX_TARGETS) VERBOSE=1 &>$(OUT_DIR)/$@/make.log || \ (echo "Build failed. See $(OUT_DIR)/$@/make.log for details."; exit 1;) @@ -248,8 +244,6 @@ $(BUILD_ALL)_stm32f3: $(BUILD_DIRS_STM32F3) @ mkdir -p $(OUT_DIR)/$@ @ $(MAKE) -C $(BUILD_DIR)/stm32f3 jerry-libc-all VERBOSE=1 &>$(OUT_DIR)/$@/make.log || \ (echo "Build failed. See $(OUT_DIR)/$@/make.log for details."; exit 1;) - @ $(MAKE) -C $(BUILD_DIR)/stm32f3 plugins-all VERBOSE=1 &>$(OUT_DIR)/$@/make.log || \ - (echo "Build failed. See $(OUT_DIR)/$@/make.log for details."; exit 1;) @ $(MAKE) -C $(BUILD_DIR)/stm32f3 $(JERRY_STM32F3_TARGETS) VERBOSE=1 &>$(OUT_DIR)/$@/make.log || \ (echo "Build failed. See $(OUT_DIR)/$@/make.log for details."; exit 1;) @@ -266,8 +260,6 @@ $(BUILD_ALL)_stm32f4: $(BUILD_DIRS_STM32F4) @ mkdir -p $(OUT_DIR)/$@ @ $(MAKE) -C $(BUILD_DIR)/stm32f4 jerry-libc-all VERBOSE=1 &>$(OUT_DIR)/$@/make.log || \ (echo "Build failed. See $(OUT_DIR)/$@/make.log for details."; exit 1;) - @ $(MAKE) -C $(BUILD_DIR)/stm32f4 plugins-all VERBOSE=1 &>$(OUT_DIR)/$@/make.log || \ - (echo "Build failed. See $(OUT_DIR)/$@/make.log for details."; exit 1;) @ $(MAKE) -C $(BUILD_DIR)/stm32f4 $(JERRY_STM32F4_TARGETS) VERBOSE=1 &>$(OUT_DIR)/$@/make.log || \ (echo "Build failed. See $(OUT_DIR)/$@/make.log for details."; exit 1;) diff --git a/jerry-core/config.h b/jerry-core/config.h index 1e8b033b10..249574910e 100644 --- a/jerry-core/config.h +++ b/jerry-core/config.h @@ -160,26 +160,6 @@ // #define CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN #endif /* CONFIG_ECMA_COMPACT_PROFILE */ -/** - * Size of character buffer used to exchange character data between core and extensions' routine - */ -#define CONFIG_EXTENSION_CHAR_BUFFER_SIZE 2048 - -/** - * Maximum number of registered extensions - */ -#define CONFIG_EXTENSION_MAX_NUMBER_OF_EXTENSIONS 32 - -/** - * Maximum number of functions in an extension - */ -#define CONFIG_EXTENSION_MAX_FUNCTIONS_IN_EXTENSION 1024 - -/** - * Maximum number of arguments in a function - */ -#define CONFIG_EXTENSION_MAX_ARGUMENTS_IN_FUNCTION 16 - /** * Run GC after execution of each opcode */ diff --git a/jerry-core/ecma/base/ecma-globals.h b/jerry-core/ecma/base/ecma-globals.h index 887fde5a63..49d6988676 100644 --- a/jerry-core/ecma/base/ecma-globals.h +++ b/jerry-core/ecma/base/ecma-globals.h @@ -396,9 +396,7 @@ typedef enum ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION, /** One of built-in functions described in section 15 of ECMA-262 v5 specification */ ECMA_OBJECT_TYPE_ARGUMENTS, /**< Arguments object (10.6) */ - ECMA_OBJECT_TYPE_ARRAY, /**< Array object (15.4) */ - ECMA_OBJECT_TYPE_EXTENSION, /**< Extension (implementation-defined) object - * See also: ecma_extension_instantiate */ + ECMA_OBJECT_TYPE_ARRAY /**< Array object (15.4) */ // ECMA_OBJECT_TYPE_HOST /**< Host object */ } ecma_object_type_t; diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-global.inc.h b/jerry-core/ecma/builtin-objects/ecma-builtin-global.inc.h index 23dafebc5a..a300c76f84 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-global.inc.h +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-global.inc.h @@ -133,13 +133,6 @@ OBJECT_VALUE (ECMA_MAGIC_STRING_DATE_UL, ECMA_PROPERTY_CONFIGURABLE) #endif /* CONFIG_ECMA_COMPACT_PROFILE_DISABLE_DATE_BUILTIN */ -// Implementation-defined property for accessing the engine's extensions */ -OBJECT_VALUE (ECMA_MAGIC_STRING_JERRY_UL, - ecma_builtin_get (ECMA_BUILTIN_ID_JERRY), - ECMA_PROPERTY_NOT_WRITABLE, - ECMA_PROPERTY_NOT_ENUMERABLE, - ECMA_PROPERTY_NOT_CONFIGURABLE) - // ECMA-262 v5, 15.1.4.8 CP_UNIMPLEMENTED_VALUE (ECMA_MAGIC_STRING_REG_EXP_UL, ecma_builtin_get (ECMA_BUILTIN_ID_REGEXP), diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-jerry.cpp b/jerry-core/ecma/builtin-objects/ecma-builtin-jerry.cpp deleted file mode 100644 index b1b3cd370c..0000000000 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-jerry.cpp +++ /dev/null @@ -1,592 +0,0 @@ -/* Copyright 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "ecma-alloc.h" -#include "ecma-builtins.h" -#include "ecma-exceptions.h" -#include "ecma-extension.h" -#include "ecma-gc.h" -#include "ecma-helpers.h" -#include "ecma-objects-general.h" - -#define ECMA_BUILTINS_INTERNAL -#include "ecma-builtins-internal.h" - -/** - * List of registered extensions - */ -static jerry_extension_descriptor_t *jerry_extensions_list_p = NULL; - -/** - * Index to assign to next registered extension - */ -static uint32_t jerry_extensions_next_index = 0; - -/** - * If the property's name is one of built-in properties of the built-in object - * that is not instantiated yet, instantiate the property and - * return pointer to the instantiated property. - * - * @return pointer property, if one was instantiated, - * NULL - otherwise. - */ -ecma_property_t* -ecma_builtin_jerry_try_to_instantiate_property (ecma_object_t *obj_p, /**< object */ - ecma_string_t *extension_name_p) /**< property's name */ -{ - JERRY_ASSERT (ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_JERRY)); - JERRY_ASSERT (ecma_find_named_property (obj_p, extension_name_p) == NULL); - - ssize_t req_buffer_size = ecma_string_to_zt_string (extension_name_p, NULL, 0); - JERRY_ASSERT (req_buffer_size < 0); - - ecma_property_t *prop_p = NULL; - - MEM_DEFINE_LOCAL_ARRAY (extension_name_zt_buf_p, -req_buffer_size, uint8_t); - - req_buffer_size = ecma_string_to_zt_string (extension_name_p, extension_name_zt_buf_p, -req_buffer_size); - JERRY_ASSERT (req_buffer_size > 0); - -#if CONFIG_ECMA_CHAR_ENCODING != CONFIG_ECMA_CHAR_ASCII - JERRY_UNIMPLEMENTED ("Only ASCII encoding support is implemented."); -#else /* CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_ASCII */ - const char *name_p = (const char*) extension_name_zt_buf_p; - - jerry_extension_descriptor_t *desc_p; - for (desc_p = jerry_extensions_list_p; - desc_p != NULL; - desc_p = desc_p->next_p) - { - if (!strcmp (name_p, desc_p->name_p)) - { - break; - } - } - - if (desc_p == NULL) - { - /* no extension with specified name was found */ - prop_p = NULL; - } - else - { - prop_p = ecma_create_named_data_property (obj_p, - extension_name_p, - ECMA_PROPERTY_NOT_WRITABLE, - ECMA_PROPERTY_NOT_ENUMERABLE, - ECMA_PROPERTY_NOT_CONFIGURABLE); - - ecma_object_t *extension_object_p = ecma_create_object (NULL, - false, - ECMA_OBJECT_TYPE_EXTENSION); - ecma_set_object_is_builtin (extension_object_p, true); - ecma_property_t *extension_id_prop_p = ecma_create_internal_property (extension_object_p, - ECMA_INTERNAL_PROPERTY_EXTENSION_ID); - extension_id_prop_p->u.internal_property.value = desc_p->index; - - ecma_named_data_property_assign_value (obj_p, prop_p, ecma_make_object_value (extension_object_p)); - - ecma_deref_object (extension_object_p); - } -#endif /* CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_ASCII */ - - MEM_FINALIZE_LOCAL_ARRAY (extension_name_zt_buf_p); - - return prop_p; -} /* ecma_builtin_jerry_try_to_instantiate_property */ - -/** - * Stub for dispatcher of the built-in's routines - * - * Warning: - * does not return (the stub should be unreachable) - */ -ecma_completion_value_t -ecma_builtin_jerry_dispatch_routine (uint16_t builtin_routine_id, /**< built-in wide identifier of routine */ - ecma_value_t this_arg_value __attr_unused___, /**< 'this' argument value */ - const ecma_value_t arguments_list[], /**< list of arguments - * passed to routine */ - ecma_length_t arguments_number) /**< length of arguments' list */ -{ - uint32_t extension_object_index = builtin_routine_id / ECMA_EXTENSION_MAX_FUNCTIONS_IN_EXTENSION; - uint32_t function_index = builtin_routine_id % ECMA_EXTENSION_MAX_FUNCTIONS_IN_EXTENSION; - - jerry_extension_descriptor_t *desc_p; - for (desc_p = jerry_extensions_list_p; - desc_p != NULL; - desc_p = desc_p->next_p) - { - if (desc_p->index == extension_object_index) - { - break; - } - } - JERRY_ASSERT (desc_p != NULL); - - JERRY_ASSERT (function_index < desc_p->functions_count); - jerry_extension_function_t *function_p = &desc_p->functions_p[function_index]; - - bool throw_type_error = false; - if (function_p->args_number != arguments_number) - { - throw_type_error = true; - } - else - { - uint32_t arg_index; - for (arg_index = 0; arg_index < function_p->args_number; arg_index++) - { - jerry_api_value_t *arg_p = &function_p->args_p[arg_index]; - const ecma_value_t arg_value = arguments_list[arg_index]; - - if (arg_p->type == JERRY_API_DATA_TYPE_BOOLEAN) - { - if (!ecma_is_value_boolean (arg_value)) - { - break; - } - else - { - arg_p->v_bool = ecma_is_value_true (arg_value); - } - } - else if (arg_p->type == JERRY_API_DATA_TYPE_FLOAT32 - || arg_p->type == JERRY_API_DATA_TYPE_FLOAT64 - || arg_p->type == JERRY_API_DATA_TYPE_UINT32) - { - if (!ecma_is_value_number (arg_value)) - { - break; - } - else - { - ecma_number_t num_value = *ecma_get_number_from_value (arg_value); - if (arg_p->type == JERRY_API_DATA_TYPE_FLOAT32) - { - arg_p->v_float32 = (float) num_value; - } - else if (arg_p->type == JERRY_API_DATA_TYPE_FLOAT64) - { -#if CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT32 - JERRY_UNREACHABLE (); -#elif CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT64 - arg_p->v_float64 = num_value; -#endif /* CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT64 */ - } - else if (arg_p->type == JERRY_API_DATA_TYPE_UINT32) - { - arg_p->v_uint32 = ecma_number_to_uint32 (num_value); - } - } - } - else if (arg_p->type == JERRY_API_DATA_TYPE_STRING) - { - if (!ecma_is_value_string (arg_value)) - { - break; - } - else - { - arg_p->v_string = ecma_get_string_from_value (arg_value); - } - } - else - { - JERRY_ASSERT (arg_p->type == JERRY_API_DATA_TYPE_OBJECT); - - if (!ecma_is_value_object (arg_value)) - { - break; - } - else - { - arg_p->v_object = ecma_get_object_from_value (arg_value); - } - } - } - - uint32_t initialized_args_count = arg_index; - - if (initialized_args_count != function_p->args_number) - { - throw_type_error = true; - } - else - { - function_p->function_wrapper_p (function_p); - } - - for (arg_index = 0; - arg_index < initialized_args_count; - arg_index++) - { - jerry_api_value_t *arg_p = &function_p->args_p[arg_index]; - - if (arg_p->type == JERRY_API_DATA_TYPE_STRING) - { - arg_p->v_string = NULL; - } - else if (arg_p->type == JERRY_API_DATA_TYPE_OBJECT) - { - arg_p->v_object = NULL; - } - else - { - JERRY_ASSERT (arg_p->type == JERRY_API_DATA_TYPE_BOOLEAN - || arg_p->type == JERRY_API_DATA_TYPE_FLOAT32 - || arg_p->type == JERRY_API_DATA_TYPE_FLOAT64 - || arg_p->type == JERRY_API_DATA_TYPE_UINT32); - } - } - } - - if (throw_type_error) - { - return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); - } - else - { - jerry_api_value_t& ret_value = function_p->ret_value; - ecma_completion_value_t completion; - - if (ret_value.type == JERRY_API_DATA_TYPE_VOID) - { - completion = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED); - } - else if (ret_value.type == JERRY_API_DATA_TYPE_BOOLEAN) - { - if (ret_value.v_bool) - { - completion = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE); - } - else - { - completion = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); - } - } - else if (ret_value.type == JERRY_API_DATA_TYPE_UINT32 - || ret_value.type == JERRY_API_DATA_TYPE_FLOAT32 - || ret_value.type == JERRY_API_DATA_TYPE_FLOAT64) - { - ecma_number_t* num_value_p = ecma_alloc_number (); - if (ret_value.type == JERRY_API_DATA_TYPE_FLOAT32) - { - *num_value_p = ret_value.v_float32; - } - else if (ret_value.type == JERRY_API_DATA_TYPE_FLOAT64) - { -#if CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT32 - JERRY_UNREACHABLE (); -#elif CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT64 - *num_value_p = ret_value.v_float64; -#endif /* CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT64 */ - } - else - { - JERRY_ASSERT (ret_value.type == JERRY_API_DATA_TYPE_UINT32); - - *num_value_p = ecma_uint32_to_number (ret_value.v_uint32); - } - - completion = ecma_make_normal_completion_value (ecma_make_number_value (num_value_p)); - } - else if (ret_value.type == JERRY_API_DATA_TYPE_STRING) - { - completion = ecma_make_normal_completion_value (ecma_make_string_value (ret_value.v_string)); - - ret_value.v_string = NULL; - } - else - { - JERRY_ASSERT (ret_value.type == JERRY_API_DATA_TYPE_OBJECT); - - completion = ecma_make_normal_completion_value (ecma_make_object_value (ret_value.v_object)); - - ret_value.v_object = NULL; - } - - return completion; - } -} /* ecma_builtin_jerry_dispatch_routine */ - -bool -ecma_extension_register (jerry_extension_descriptor_t *extension_desc_p) /**< extension description */ -{ - if (jerry_extensions_next_index >= ECMA_EXTENSION_MAX_NUMBER_OF_EXTENSIONS) - { - return false; - } - - if (extension_desc_p->functions_count > ECMA_EXTENSION_MAX_FUNCTIONS_IN_EXTENSION) - { - return false; - } - - /* Check names intersection */ - for (uint32_t i = 0; i < extension_desc_p->fields_count; i++) - { - for (uint32_t j = 0; j < extension_desc_p->fields_count; j++) - { - if (i != j - && !strcmp (extension_desc_p->fields_p[i].field_name_p, - extension_desc_p->fields_p[j].field_name_p)) - { - return false; - } - } - } - - for (uint32_t i = 0; i < extension_desc_p->functions_count; i++) - { - if (extension_desc_p->functions_p[i].args_number >= ECMA_EXTENSION_MAX_ARGUMENTS_IN_FUNCTION) - { - return false; - } - -#if CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT32 - /* Check if we can represent the arguments' values */ - for (uint32_t j = 0; j < extension_desc_p->functions_p[i].args_number; j++) - { - if (extension_desc_p->functions_p[i].args_p[j].type == JERRY_API_DATA_TYPE_FLOAT64) - { - return false; - } - } -#endif /* CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT32 */ - - for (uint32_t j = 0; j < extension_desc_p->functions_count; j++) - { - if (i != j - && !strcmp (extension_desc_p->functions_p[i].function_name_p, - extension_desc_p->functions_p[j].function_name_p)) - { - return false; - } - } - } - - for (uint32_t i = 0; i < extension_desc_p->fields_count; i++) - { -#if CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT32 - /* Check if we can represent the field's value */ - - if (extension_desc_p->fields_p[i].type == JERRY_API_DATA_TYPE_FLOAT64) - { - return false; - } - - if (extension_desc_p->fields_p[i].type == JERRY_API_DATA_TYPE_UINT32 - && (ecma_number_to_uint32 (ecma_uint32_to_number (extension_desc_p->fields_p[i].v_uint32)) - != extension_desc_p->fields_p[i].v_uint32)) - { - return false; - } -#endif /* CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT32 */ - - for (uint32_t j = 0; j < extension_desc_p->functions_count; j++) - { - if (!strcmp (extension_desc_p->fields_p[i].field_name_p, - extension_desc_p->functions_p[j].function_name_p)) - { - return false; - } - } - } - - for (jerry_extension_descriptor_t *desc_iter_p = jerry_extensions_list_p; - desc_iter_p != NULL; - desc_iter_p = desc_iter_p->next_p) - { - if (desc_iter_p == extension_desc_p - || !strcmp (desc_iter_p->name_p, extension_desc_p->name_p)) - { - /* The extension already registered or an extension with the same name already registered */ - return false; - } - } - - extension_desc_p->next_p = jerry_extensions_list_p; - jerry_extensions_list_p = extension_desc_p; - extension_desc_p->index = jerry_extensions_next_index++; - - return true; -} /* ecma_extension_register */ - -/** - * [[GetOwnProperty]] Implementation extension object's operation - * - * @return property descriptor - */ -ecma_property_t* -ecma_op_extension_object_get_own_property (ecma_object_t *obj_p, /**< the extension object */ - ecma_string_t *property_name_p) /**< property name */ -{ - JERRY_ASSERT (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_EXTENSION); - - // 1. - ecma_property_t *prop_p = ecma_op_general_object_get_own_property (obj_p, property_name_p); - - // 2. - if (prop_p != NULL) - { - return prop_p; - } - -#if CONFIG_ECMA_CHAR_ENCODING != CONFIG_ECMA_CHAR_ASCII - JERRY_UNIMPLEMENTED ("Only ASCII encoding support is implemented."); -#else /* CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_ASCII */ - ssize_t req_buffer_size = ecma_string_to_zt_string (property_name_p, NULL, 0); - JERRY_ASSERT (req_buffer_size < 0); - - MEM_DEFINE_LOCAL_ARRAY (property_name_zt_buf_p, -req_buffer_size, uint8_t); - - req_buffer_size = ecma_string_to_zt_string (property_name_p, property_name_zt_buf_p, -req_buffer_size); - JERRY_ASSERT (req_buffer_size > 0); - - const char *name_p = (const char*) property_name_zt_buf_p; - - ecma_property_t *extension_id_prop_p = ecma_get_internal_property (obj_p, - ECMA_INTERNAL_PROPERTY_EXTENSION_ID); - uint32_t extension_object_index = extension_id_prop_p->u.internal_property.value; - - jerry_extension_descriptor_t *desc_p; - for (desc_p = jerry_extensions_list_p; - desc_p != NULL; - desc_p = desc_p->next_p) - { - if (desc_p->index == extension_object_index) - { - break; - } - } - JERRY_ASSERT (desc_p != NULL); - - uint32_t field_index; - for (field_index = 0; - field_index < desc_p->fields_count; - field_index++) - { - if (!strcmp (name_p, desc_p->fields_p[field_index].field_name_p)) - { - break; - } - } - - if (field_index < desc_p->fields_count) - { - const jerry_extension_field_t *field_p = &desc_p->fields_p[field_index]; - - ecma_value_t value; - prop_p = ecma_create_named_data_property (obj_p, - property_name_p, - ECMA_PROPERTY_NOT_WRITABLE, - ECMA_PROPERTY_NOT_ENUMERABLE, - ECMA_PROPERTY_NOT_CONFIGURABLE); - - if (field_p->type == JERRY_API_DATA_TYPE_UNDEFINED) - { - value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED); - } - else if (field_p->type == JERRY_API_DATA_TYPE_NULL) - { - value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_NULL); - } - else if (field_p->type == JERRY_API_DATA_TYPE_BOOLEAN) - { - value = ecma_make_simple_value (field_p->v_bool ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE); - } - else if (field_p->type == JERRY_API_DATA_TYPE_FLOAT32) - { - ecma_number_t *num_p = ecma_alloc_number (); - *num_p = field_p->v_float32; - value = ecma_make_number_value (num_p); - } -#if CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT64 - else if (field_p->type == JERRY_API_DATA_TYPE_FLOAT64) - { - JERRY_UNREACHABLE (); - ecma_number_t *num_p = ecma_alloc_number (); - *num_p = field_p->v_float64; - value = ecma_make_number_value (num_p); - } -#endif /* CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT64 */ - else if (field_p->type == JERRY_API_DATA_TYPE_UINT32) - { - ecma_number_t *num_p = ecma_alloc_number (); - *num_p = ecma_uint32_to_number (field_p->v_uint32); - JERRY_ASSERT (ecma_number_to_uint32 (*num_p) == field_p->v_uint32); - value = ecma_make_number_value (num_p); - } - else - { - JERRY_ASSERT (field_p->type == JERRY_API_DATA_TYPE_STRING); - const ecma_char_t *string_p = (const ecma_char_t*) field_p->v_string; - ecma_string_t *str_p = ecma_new_ecma_string (string_p); - value = ecma_make_string_value (str_p); - } - - ecma_named_data_property_assign_value (obj_p, prop_p, value); - ecma_free_value (value, true); - } - else - { - uint32_t function_index; - for (function_index = 0; - function_index < desc_p->functions_count; - function_index++) - { - if (!strcmp (name_p, desc_p->functions_p[function_index].function_name_p)) - { - break; - } - } - - if (function_index < desc_p->functions_count) - { - const jerry_extension_function_t *function_p = &desc_p->functions_p[function_index]; - - /* Currently, combined identifier of extension object and extension function should fit in uint16_t. */ - JERRY_STATIC_ASSERT (ECMA_EXTENSION_MAX_NUMBER_OF_EXTENSIONS * ECMA_EXTENSION_MAX_FUNCTIONS_IN_EXTENSION - < (1ull << (sizeof (uint16_t) * JERRY_BITSINBYTE))); - - uint32_t routine_id = desc_p->index * ECMA_EXTENSION_MAX_FUNCTIONS_IN_EXTENSION + function_index; - JERRY_ASSERT ((uint16_t) routine_id == routine_id); - JERRY_STATIC_ASSERT ((ecma_number_t) ECMA_EXTENSION_MAX_ARGUMENTS_IN_FUNCTION - == ECMA_EXTENSION_MAX_ARGUMENTS_IN_FUNCTION); - ecma_number_t args_number = ecma_uint32_to_number (function_p->args_number); - JERRY_ASSERT (function_p->args_number == ecma_number_to_uint32 (args_number)); - ecma_object_t *func_obj_p = ecma_builtin_make_function_object_for_routine (ECMA_BUILTIN_ID_JERRY, - (uint16_t) routine_id, - args_number); - - prop_p = ecma_create_named_data_property (obj_p, - property_name_p, - ECMA_PROPERTY_NOT_WRITABLE, - ECMA_PROPERTY_NOT_ENUMERABLE, - ECMA_PROPERTY_NOT_CONFIGURABLE); - - ecma_named_data_property_assign_value (obj_p, prop_p, ecma_make_object_value (func_obj_p)); - - ecma_deref_object (func_obj_p); - } - } - - MEM_FINALIZE_LOCAL_ARRAY (property_name_zt_buf_p); - - return prop_p; -#endif /* CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_ASCII */ -} /* ecma_op_extension_object_get_own_property */ diff --git a/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h b/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h index 15ca2f7cf1..285588f750 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h +++ b/jerry-core/ecma/builtin-objects/ecma-builtins.inc.h @@ -288,12 +288,4 @@ BUILTIN (ECMA_BUILTIN_ID_GLOBAL, true, global) -/* Jerry's dynamic extension proxy object */ -BUILTIN (ECMA_BUILTIN_ID_JERRY, - ECMA_OBJECT_TYPE_GENERAL, - ECMA_BUILTIN_ID__COUNT, /* no prototype */ - false, - false, - jerry) - #undef BUILTIN diff --git a/jerry-core/ecma/builtin-objects/ecma-extension.h b/jerry-core/ecma/builtin-objects/ecma-extension.h deleted file mode 100644 index 313b3d53ce..0000000000 --- a/jerry-core/ecma/builtin-objects/ecma-extension.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ECMA_EXTENSION_H -#define ECMA_EXTENSION_H - -#include "ecma-globals.h" -#include "jerry-extension.h" - -/** - * Maximum number of registered extensions - */ -#define ECMA_EXTENSION_MAX_NUMBER_OF_EXTENSIONS (CONFIG_EXTENSION_MAX_NUMBER_OF_EXTENSIONS) - -/** - * Maximum number of functions in an extension - */ -#define ECMA_EXTENSION_MAX_FUNCTIONS_IN_EXTENSION (CONFIG_EXTENSION_MAX_FUNCTIONS_IN_EXTENSION) - -/** - * Maximum number of arguments in a function - */ -#define ECMA_EXTENSION_MAX_ARGUMENTS_IN_FUNCTION (CONFIG_EXTENSION_MAX_ARGUMENTS_IN_FUNCTION) - -extern bool ecma_extension_register (jerry_extension_descriptor_t *extension_desc_p); -extern ecma_property_t* ecma_op_extension_object_get_own_property (ecma_object_t*, ecma_string_t*); - -#endif /* ECMA_EXTENSION_H */ diff --git a/jerry-core/ecma/operations/ecma-objects.cpp b/jerry-core/ecma/operations/ecma-objects.cpp index 7440aa489d..f6dd435dc2 100644 --- a/jerry-core/ecma/operations/ecma-objects.cpp +++ b/jerry-core/ecma/operations/ecma-objects.cpp @@ -16,7 +16,6 @@ #include "ecma-array-object.h" #include "ecma-builtins.h" #include "ecma-exceptions.h" -#include "ecma-extension.h" #include "ecma-globals.h" #include "ecma-function-object.h" #include "ecma-lcache.h" @@ -45,7 +44,6 @@ ecma_assert_object_type_is_valid (ecma_object_type_t type) /**< object's impleme || type == ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION || type == ECMA_OBJECT_TYPE_STRING || type == ECMA_OBJECT_TYPE_ARGUMENTS - || type == ECMA_OBJECT_TYPE_EXTENSION || type == ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION); } /* ecma_assert_object_type_is_valid */ @@ -77,7 +75,6 @@ ecma_op_object_get (ecma_object_t *obj_p, /**< the object */ case ECMA_OBJECT_TYPE_BOUND_FUNCTION: case ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION: case ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION: - case ECMA_OBJECT_TYPE_EXTENSION: case ECMA_OBJECT_TYPE_STRING: { return ecma_op_general_object_get (obj_p, property_name_p); @@ -138,20 +135,12 @@ ecma_op_object_get_own_property_longpath (ecma_object_t *obj_p, /**< the object break; } - - case ECMA_OBJECT_TYPE_EXTENSION: - { - prop_p = ecma_op_extension_object_get_own_property (obj_p, property_name_p); - - break; - } } if (unlikely (prop_p == NULL)) { if (is_builtin - && type != ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION - && type != ECMA_OBJECT_TYPE_EXTENSION) + && type != ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION) { prop_p = ecma_builtin_try_to_instantiate_property (obj_p, property_name_p); } @@ -219,7 +208,6 @@ ecma_op_object_get_property (ecma_object_t *obj_p, /**< the object */ * [ECMA_OBJECT_TYPE_BOUND_FUNCTION] = &ecma_op_general_object_get_property, * [ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION] = &ecma_op_general_object_get_property, * [ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION] = &ecma_op_general_object_get_property, - * [ECMA_OBJECT_TYPE_EXTENSION] = &ecma_op_general_object_get_property, * [ECMA_OBJECT_TYPE_ARGUMENTS] = &ecma_op_general_object_get_property, * [ECMA_OBJECT_TYPE_STRING] = &ecma_op_general_object_get_property * }; @@ -262,7 +250,6 @@ ecma_op_object_put (ecma_object_t *obj_p, /**< the object */ * [ECMA_OBJECT_TYPE_BOUND_FUNCTION] = &ecma_op_general_object_put, * [ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION] = &ecma_op_general_object_put, * [ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION] = &ecma_op_general_object_put, - * [ECMA_OBJECT_TYPE_EXTENSION] = &ecma_op_general_object_put, * [ECMA_OBJECT_TYPE_ARGUMENTS] = &ecma_op_general_object_put, * [ECMA_OBJECT_TYPE_STRING] = &ecma_op_general_object_put * }; @@ -303,7 +290,6 @@ ecma_op_object_can_put (ecma_object_t *obj_p, /**< the object */ * [ECMA_OBJECT_TYPE_BOUND_FUNCTION] = &ecma_op_general_object_can_put, * [ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION] = &ecma_op_general_object_can_put, * [ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION] = &ecma_op_general_object_can_put, - * [ECMA_OBJECT_TYPE_EXTENSION] = &ecma_op_general_object_can_put, * [ECMA_OBJECT_TYPE_ARGUMENTS] = &ecma_op_general_object_can_put, * [ECMA_OBJECT_TYPE_STRING] = &ecma_op_general_object_can_put * }; @@ -343,7 +329,6 @@ ecma_op_object_delete (ecma_object_t *obj_p, /**< the object */ case ECMA_OBJECT_TYPE_BOUND_FUNCTION: case ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION: case ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION: - case ECMA_OBJECT_TYPE_EXTENSION: case ECMA_OBJECT_TYPE_STRING: { return ecma_op_general_object_delete (obj_p, @@ -393,7 +378,6 @@ ecma_op_object_default_value (ecma_object_t *obj_p, /**< the object */ * [ECMA_OBJECT_TYPE_BOUND_FUNCTION] = &ecma_op_general_object_default_value, * [ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION] = &ecma_op_general_object_default_value, * [ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION] = &ecma_op_general_object_default_value, - * [ECMA_OBJECT_TYPE_EXTENSION] = &ecma_op_general_object_default_value, * [ECMA_OBJECT_TYPE_ARGUMENTS] = &ecma_op_general_object_default_value, * [ECMA_OBJECT_TYPE_STRING] = &ecma_op_general_object_default_value * }; @@ -434,7 +418,6 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */ case ECMA_OBJECT_TYPE_BOUND_FUNCTION: case ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION: case ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION: - case ECMA_OBJECT_TYPE_EXTENSION: case ECMA_OBJECT_TYPE_STRING: { return ecma_op_general_object_define_own_property (obj_p, @@ -487,7 +470,6 @@ ecma_op_object_has_instance (ecma_object_t *obj_p, /**< the object */ case ECMA_OBJECT_TYPE_GENERAL: case ECMA_OBJECT_TYPE_STRING: case ECMA_OBJECT_TYPE_ARGUMENTS: - case ECMA_OBJECT_TYPE_EXTENSION: { return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); } @@ -555,10 +537,6 @@ ecma_object_get_class_name (ecma_object_t *obj_p) /**< object */ { return ECMA_MAGIC_STRING_ARGUMENTS_UL; } - case ECMA_OBJECT_TYPE_EXTENSION: - { - return ECMA_MAGIC_STRING_OBJECT_UL; - } case ECMA_OBJECT_TYPE_FUNCTION: { ecma_magic_string_id_t class_name; @@ -705,8 +683,7 @@ ecma_object_get_class_name (ecma_object_t *obj_p) /**< object */ #endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ERROR_BUILTINS */ default: { - JERRY_ASSERT (ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_GLOBAL) - || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_JERRY)); + JERRY_ASSERT (ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_GLOBAL)); return ECMA_MAGIC_STRING_OBJECT_UL; } diff --git a/jerry-core/jerry-extension.h b/jerry-core/jerry-extension.h deleted file mode 100644 index 10e6baf55b..0000000000 --- a/jerry-core/jerry-extension.h +++ /dev/null @@ -1,104 +0,0 @@ -/* Copyright 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef JERRY_EXTENSION_H -#define JERRY_EXTENSION_H - -#include -#include -#include -#include - -#include "jerry-api.h" - -/** \addtogroup jerry Jerry engine interface - * @{ - */ - -/** \addtogroup jerry_extension Jerry engine extension interface - * @{ - */ - -/** - * Description of an extension object's fields - */ -typedef struct -{ - const char *field_name_p; /**< field name */ - - const jerry_api_data_type_t type; /**< field data type */ - - /** - * Value description - */ - union - { - const char* v_string; /**< string */ - bool v_bool; /**< boolean */ - float v_float32; /**< 32-bit float */ - double v_float64; /**< 64-bit float */ - uint32_t v_uint32; /**< 32-bit unsigned integer */ - }; -} jerry_extension_field_t; - -/** - * Forward declaration of description of an extension object's function - */ -struct jerry_extension_function_t; - -/** - * Pointer to extension function implementation - */ -typedef void (*jerry_extension_function_pointer_t) (struct jerry_extension_function_t *function_block_p); - -/** - * Description of an extension object's function - */ -typedef struct jerry_extension_function_t -{ - const char* function_name_p; /**< name of function */ - - const jerry_extension_function_pointer_t function_wrapper_p; /**< pointer to function implementation */ - - jerry_api_value_t ret_value; /**< function's return value */ - jerry_api_value_t* args_p; /**< arrays of the function's arguments */ - const uint32_t args_number; /**< number of arguments */ -} jerry_extension_function_t; - -/** - * Description of an extention object - */ -typedef struct jerry_extension_descriptor_t -{ - const uint32_t fields_count; /**< number of fields */ - const uint32_t functions_count; /**< number of functions */ - - const jerry_extension_field_t* const fields_p; /**< array of field descriptor */ - jerry_extension_function_t* const functions_p; /**< array of function descriptors */ - - const char* const name_p; /**< name of the extension */ - struct jerry_extension_descriptor_t *next_p; /**< next descriptor in list of registered extensions */ - uint32_t index; /**< global index of the extension among registered exceptions */ -} jerry_extension_descriptor_t; - -extern EXTERN_C bool -jerry_extend_with (jerry_extension_descriptor_t *desc_p); - -/** - * @} - * @} - */ - -#endif /* !JERRY_EXTENSION_H */ diff --git a/jerry-core/jerry-extension.inc.h b/jerry-core/jerry-extension.inc.h deleted file mode 100644 index fb47259488..0000000000 --- a/jerry-core/jerry-extension.inc.h +++ /dev/null @@ -1,126 +0,0 @@ -/* Copyright 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "jerry.h" - -/* Counting fields */ -enum -{ -#define EXTENSION_FIELD(_field_name, _type, _value) \ - JERRY_EXTENSION_ ## EXTENSION_NAME ## _ ## _field_name, -# include EXTENSION_DESCRIPTION_HEADER -#undef EXTENSION_FIELD - JERRY_EXTENSION_FIELDS_NUMBER -}; - -/* Counting functions */ -enum -{ -#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 - JERRY_EXTENSION_FUNCTIONS_NUMBER -}; - -/* Fields description */ -static const jerry_extension_field_t jerry_extension_fields[JERRY_EXTENSION_FIELDS_NUMBER + 1] = -{ -#define EXTENSION_FIELD(_field_name, _type, _value) \ - { # _field_name, JERRY_API_DATA_TYPE_ ## _type, { _value } }, -# include EXTENSION_DESCRIPTION_HEADER -#undef EXTENSION_FIELD -#define EMPTY_FIELD_ENTRY { NULL, JERRY_API_DATA_TYPE_UNDEFINED, { NULL } } - EMPTY_FIELD_ENTRY -#undef EMPTY_FIELD_ENTRY -}; - -/* Functions wrapper definitions */ -#define EXTENSION_ARG_PASS_BOOL(_arg_index) \ - args_p[_arg_index].v_bool -#define EXTENSION_ARG_PASS_FLOAT32(_arg_index) \ - args_p[_arg_index].v_float32 -#define EXTENSION_ARG_PASS_FLOAT64(_arg_index) \ - args_p[_arg_index].v_float64 -#define EXTENSION_ARG_PASS_UINT32(_arg_index) \ - args_p[_arg_index].v_uint32 -#define EXTENSION_ARG_PASS_STRING(_arg_index) \ - args_p[_arg_index].v_string -#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_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; \ - EXTENSION_RET_VALUE_SET_ ## _ret_value_type _function_to_call (__VA_ARGS__); \ - } -# include EXTENSION_DESCRIPTION_HEADER -#undef EXTENSION_FUNCTION -#undef EXTENSION_ARG -#undef EXTENSION_ARG_PASS_OBJECT -#undef EXTENSION_ARG_PASS_STRING -#undef EXTENSION_ARG_PASS_UINT32 -#undef EXTENSION_ARG_PASS_FLOAT64 -#undef EXTENSION_ARG_PASS_FLOAT32 -#undef EXTENSION_ARG_PASS_BOOL - -/* Functions' arguments description */ -#define EXTENSION_ARG(_arg_index, _type) [_arg_index] = { \ - (JERRY_API_DATA_TYPE_ ## _type), \ - { false } /* just for initialization, should be overwritten upon call */ \ -} -#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__ \ - }; -# include EXTENSION_DESCRIPTION_HEADER -#undef EXTENSION_FUNCTION -#undef EXTENSION_ARG - -/* Functions description */ -static jerry_extension_function_t jerry_extension_functions[JERRY_EXTENSION_FUNCTIONS_NUMBER + 1] = -{ -#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 -#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 = -{ - JERRY_EXTENSION_FIELDS_NUMBER, - JERRY_EXTENSION_FUNCTIONS_NUMBER, - jerry_extension_fields, - jerry_extension_functions, - EXTENSION_NAME, - NULL, - 0 /* just for initialization, should be overwritten upon registration */ -}; diff --git a/jerry-core/jerry.cpp b/jerry-core/jerry.cpp index 4ca954b942..0e8a0627fd 100644 --- a/jerry-core/jerry.cpp +++ b/jerry-core/jerry.cpp @@ -18,7 +18,6 @@ #include "ecma-alloc.h" #include "ecma-builtins.h" #include "ecma-exceptions.h" -#include "ecma-extension.h" #include "ecma-eval.h" #include "ecma-function-object.h" #include "ecma-gc.h" @@ -61,11 +60,6 @@ static bool jerry_api_available; * @{ */ -/** - * Buffer of character data (used for exchange between core and extensions' routines) - */ -char jerry_extension_characters_buffer[CONFIG_EXTENSION_CHAR_BUFFER_SIZE]; - #ifdef JERRY_ENABLE_LOG /** * TODO: @@ -274,20 +268,6 @@ jerry_api_convert_api_value_to_ecma_value (ecma_value_t *out_value_p, /**< out: } /* jerry_api_convert_api_value_to_ecma_value */ -/** - * Extend Global scope with specified extension object - * - * After extension the object is accessible through non-configurable property - * with name equal to builtin_object_name converted to ecma chars. - */ -bool -jerry_extend_with (jerry_extension_descriptor_t *desc_p) /**< description of the extension object */ -{ - jerry_assert_api_available (); - - return ecma_extension_register (desc_p); -} /* jerry_extend_with */ - /** * @} */ diff --git a/jerry-core/jerry.h b/jerry-core/jerry.h index b60e1d70c0..64bd38080f 100644 --- a/jerry-core/jerry.h +++ b/jerry-core/jerry.h @@ -20,7 +20,6 @@ #include #include "jerry-api.h" -#include "jerry-extension.h" /** \addtogroup jerry Jerry engine interface * @{ diff --git a/main-linux.cpp b/main-linux.cpp index f4f59f0694..8ec2f55167 100644 --- a/main-linux.cpp +++ b/main-linux.cpp @@ -19,8 +19,6 @@ #include "jerry.h" #include "jrt/jrt.h" -#include "plugins/io/init.h" - /** * Maximum command line arguments number */ @@ -236,8 +234,6 @@ main (int argc, jerry_init (flags); - plugin_io_init (); - jerry_completion_code_t ret_code = JERRY_COMPLETION_CODE_OK; if (!jerry_parse (source_p, source_size)) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt deleted file mode 100644 index aeec865859..0000000000 --- a/plugins/CMakeLists.txt +++ /dev/null @@ -1,127 +0,0 @@ -# Copyright 2015 Samsung Electronics Co., Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -cmake_minimum_required (VERSION 2.8.12) -project (Jerry_Plugins CXX ASM) - -# Compiler / linker flags - set(COMPILE_FLAGS_PLUGINS "${COMPILE_FLAGS_JERRY} ${CXX_FLAGS_JERRY}") - -# Definitions - # Debug - set(DEFINES_PLUGINS_DEBUG ) - - # Release - set(DEFINES_PLUGINS_RELEASE JERRY_NDEBUG JERRY_DISABLE_HEAVY_DEBUG) - - # Platform-specific - # Linux - set(DEFINES_PLUGINS_LINUX __TARGET_HOST) - # MCU - # stm32f3 - set(DEFINES_PLUGINS_MCU_STM32F3 __TARGET_MCU __TARGET_MCU_STM32F3) - # stm32f4 - set(DEFINES_PLUGINS_MCU_STM32F4 __TARGET_MCU __TARGET_MCU_STM32F4) - # Nuttx - set(DEFINES_PLUGINS_NUTTX __TARGET_NUTTX) - -# Include directories - set(INCLUDE_PLUGINS - io - lib-device-stm) - - # Third-party - # Platform-specific - # Linux - set(INCLUDE_THIRD_PARTY_LINUX ) - - # MCU - # STM32F3 - set(INCLUDE_THIRD_PARTY_MCU_STM32F3 - ${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Project/Demonstration - ${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Device/ST/STM32F30x/Include - ${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/STM32F30x_StdPeriph_Driver/inc - ${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Include - ${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0) - # STM32F4 - set(INCLUDE_THIRD_PARTY_MCU_STM32F4 - ${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Project/Demonstration - ${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Include - ${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/STM32F4xx_StdPeriph_Driver/inc - ${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/Include - ${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0) - - # Nuttx - set(INCLUDE_THIRD_PARTY_NUTTX ) - -# Sources - file(GLOB SOURCE_PLUGINS - io/*.cpp - lib-device-stm/*.cpp) - - # Third-party - # Platform-specific - # MCU - # stm32f3 - set(SOURCE_THIRD_PARTY_MCU_STM32F3 - ${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/CMSIS/Device/ST/STM32F30x/Source/Templates/system_stm32f30x.c - ${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_tim.c - ${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_gpio.c - ${CMAKE_SOURCE_DIR}/third-party/STM32F3-Discovery_FW_V1.1.0/Libraries/STM32F30x_StdPeriph_Driver/src/stm32f30x_rcc.c) - # stm32f4 - set(SOURCE_THIRD_PARTY_MCU_STM32F4 - ${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c - ${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.c - ${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c - ${CMAKE_SOURCE_DIR}/third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c) - -# Platform-specific configuration - set(DEFINES_PLUGINS ${DEFINES_PLUGINS_${PLATFORM_EXT}}) - set(INCLUDE_PLUGINS ${INCLUDE_PLUGINS} ${INCLUDE_THIRD_PARTY_${PLATFORM_EXT}}) - -# Targets declaration - add_custom_target (plugins-all) - - string(TOLOWER ${PLATFORM_EXT} PLATFORM_L) - set(TARGET_NAME plugins.${PLATFORM_L}) - - function(declare_targets_for_build_mode BUILD_MODE) - set(TARGET_NAME ${BUILD_MODE_PREFIX_${BUILD_MODE}}.${TARGET_NAME}) - set(DEFINES_PLUGINS ${DEFINES_PLUGINS} ${DEFINES_PLUGINS_${BUILD_MODE}}) - - # Jerry - add_library(${TARGET_NAME}.lib STATIC ${SOURCE_PLUGINS}) - set_property(TARGET ${TARGET_NAME}.lib - PROPERTY COMPILE_FLAGS "${COMPILE_FLAGS_PLUGINS} ${FLAGS_COMMON_${BUILD_MODE}}") - target_compile_definitions(${TARGET_NAME}.lib PRIVATE ${DEFINES_PLUGINS}) - target_include_directories(${TARGET_NAME}.lib PRIVATE ${INCLUDE_PLUGINS} ${INCLUDE_CORE_INTERFACE}) - target_include_directories(${TARGET_NAME}.lib SYSTEM PRIVATE ${INCLUDE_LIBC_INTERFACE}) - target_include_directories(${TARGET_NAME}.lib SYSTEM PRIVATE ${INCLUDE_EXTERNAL_LIBS_INTERFACE}) - add_dependencies(plugins-all ${TARGET_NAME}.lib) - - # Third-party MCU library - if(DEFINED SOURCE_THIRD_PARTY_${PLATFORM_EXT}) - add_library(${TARGET_NAME}${SUFFIX_THIRD_PARTY_LIB} STATIC ${SOURCE_THIRD_PARTY_${PLATFORM_EXT}}) - set_property(TARGET ${TARGET_NAME}${SUFFIX_THIRD_PARTY_LIB} - PROPERTY COMPILE_FLAGS "${FLAGS_COMMON_${BUILD_MODE}}") - target_include_directories(${TARGET_NAME}${SUFFIX_THIRD_PARTY_LIB} PRIVATE ${INCLUDE_PLUGINS}) - target_include_directories(${TARGET_NAME}${SUFFIX_THIRD_PARTY_LIB} SYSTEM PRIVATE ${INCLUDE_LIBC_INTERFACE}) - target_include_directories(${TARGET_NAME}${SUFFIX_THIRD_PARTY_LIB} SYSTEM PRIVATE ${INCLUDE_EXTERNAL_LIBS_INTERFACE}) - - target_link_libraries(${TARGET_NAME}.lib ${TARGET_NAME}${SUFFIX_THIRD_PARTY_LIB}) - endif() - endfunction() - - declare_targets_for_build_mode(DEBUG) - declare_targets_for_build_mode(RELEASE) diff --git a/plugins/io/init.cpp b/plugins/io/init.cpp deleted file mode 100644 index de44142580..0000000000 --- a/plugins/io/init.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "init.h" -#include "jerry.h" - -static void plugin_io_print_uint32 (uint32_t); -static void plugin_io_print_string (jerry_api_string_t *string_p); - -#include "io-extension-description.inc.h" - -void -plugin_io_init (void) -{ - jerry_extend_with (&jerry_extension); -} /* plugin_io_init */ - -/** - * Print an uint32 number without new-line to standard output - */ -static void -plugin_io_print_uint32 (uint32_t num) /**< uint32 to print */ -{ - printf ("%lu", num); -} /* plugin_io_print_uint32 */ - -/** - * Print a string without new-line to standard output - * - * Note: - * Currently, only strings that require up to 32 bytes with zero character at the end, are supported. - * If string is too long for the function, then nothing will be printed. - */ -static void -plugin_io_print_string (jerry_api_string_t *string_p) /**< string to print */ -{ - char buffer[32]; - - ssize_t req_size = jerry_api_string_to_char_buffer (string_p, buffer, (ssize_t) sizeof (buffer)); - - if (req_size < 0) - { - /* not enough buffer size */ - return; - } - else - { - printf ("%s", buffer); - } -} /* plugin_io_print_string */ diff --git a/plugins/io/init.h b/plugins/io/init.h deleted file mode 100644 index cfc2ac634b..0000000000 --- a/plugins/io/init.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef INIT_H -#define INIT_H - -extern void plugin_io_init (void); - -#endif /* INIT_H */ diff --git a/plugins/io/io-extension-description.inc.h b/plugins/io/io-extension-description.inc.h deleted file mode 100644 index 46c52c4ea3..0000000000 --- a/plugins/io/io-extension-description.inc.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef IO_EXTENSION_DESCRIPTION_INC_H -#define IO_EXTENSION_DESCRIPTION_INC_H - -#define EXTENSION_NAME "io" -#define EXTENSION_DESCRIPTION_HEADER "io-extension-description.inc.h" - -#include "jerry-extension.inc.h" - -#endif /* IO_EXTENSION_DESCRIPTION_INC_H */ - -#if defined (EXTENSION_FUNCTION) -EXTENSION_FUNCTION (print_uint32, plugin_io_print_uint32, - VOID, - 1, - EXTENSION_ARG (0, UINT32)) -EXTENSION_FUNCTION (print_string, plugin_io_print_string, - VOID, - 1, - EXTENSION_ARG (0, STRING)) -#elif defined (EXTENSION_FIELD) -#if defined (__TARGET_HOST) -EXTENSION_FIELD (platform, STRING, "linux") -#elif defined (__TARGET_MCU_STM32F3) -EXTENSION_FIELD (platform, STRING, "mcu_stm32f3") -#elif defined (__TARGET_MCU_STM32F4) -EXTENSION_FIELD (platform, STRING, "mcu_stm32f4") -#endif /* !__TARGET_MCU_STM32F3 && __TARGET_MCU_STM32F4 */ -#endif /* !EXTENSION_FUNCTION && !EXTENSION_FIELD */ diff --git a/plugins/lib-device-stm/actuators.cpp b/plugins/lib-device-stm/actuators.cpp deleted file mode 100644 index bf3b5c120e..0000000000 --- a/plugins/lib-device-stm/actuators.cpp +++ /dev/null @@ -1,233 +0,0 @@ -/* Copyright 2014-2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma GCC optimize "O0" - -#include - -#include "actuators.h" -#include "common-io.h" - -#if defined (__TARGET_HOST) || defined (__TARGET_NUTTX) -/** - * Host stub for LEDToggle operation - */ -void -led_toggle (uint32_t led_id) /**< index of LED */ -{ - printf ("led_toggle: %lu\n", led_id); -} - -/** - * Host stub for LEDOn operation - */ -void -led_on (uint32_t led_id) /**< index of LED */ -{ - printf ("led_on: %lu\n", led_id); -} - -/** - * Host stub for LEDOff operation - */ -void -led_off (uint32_t led_id) /**< index of LED */ -{ - printf ("led_off: %lu\n", led_id); -} - -/** - * Host stub for LEDOnce operation - */ -void -led_blink_once (uint32_t led_id) /**< index of LED */ -{ - printf ("led_blink_once: %lu\n", led_id); -} -#else /* !__TARGET_HOST && !__TARGET_NUTTX */ -#ifndef __TARGET_MCU -# error "!__TARGET_HOST && && !__TARGET_NUTTX !__TARGET_MCU" -#endif /* !__TARGET_MCU */ - -#include "mcu-headers.h" - -#ifdef __TARGET_MCU_STM32F4 -/** - * Number of LEDs on the board - */ -#define LED_NUMBER 4 - -/** - * LEDs' GPIO pins - */ -static const uint16_t led_pins[LED_NUMBER] = -{ - GPIO_Pin_12, /* LD4: Green */ - GPIO_Pin_13, /* LD3: Orange */ - GPIO_Pin_14, /* LD5: Red */ - GPIO_Pin_15 /* LD6: Blue */ -}; - -/** - * LEDs' GPIO ports - */ -static GPIO_TypeDef* leds_port = GPIOD; - -/** - * Initialize LEDs on the board - */ -void -initialize_leds (void) -{ - GPIO_InitTypeDef gpio_init_structure; - - RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOD, ENABLE); - - uint16_t led_pins_mask = 0; - for (uint32_t led_index = 0; - led_index < LED_NUMBER; - led_index++) - { - led_pins_mask |= led_pins[led_index]; - } - - gpio_init_structure.GPIO_Pin = led_pins_mask; - gpio_init_structure.GPIO_Mode = GPIO_Mode_OUT; - gpio_init_structure.GPIO_Speed = GPIO_Speed_100MHz; - GPIO_Init (leds_port, &gpio_init_structure); - - for (uint32_t led_index = 0; - led_index < LED_NUMBER; - led_index++) - { - led_off (led_index); - } -} /* initialize_leds */ - -#else /* !__TARGET_MCU_STM32F4 */ - -# ifndef __TARGET_MCU_STM32F3 -# error "!__TARGET_MCU_STM32F4 && !__TARGET_MCU_STM32F3" -# endif /* !__TARGET_MCU_STM32F3 */ - -/** - * Number of LEDs on the board - */ -#define LED_NUMBER 8 - -/** - * LEDs' GPIO pins - */ -static const uint16_t led_pins[LED_NUMBER] = -{ - GPIO_Pin_15, /* LD6 - Green */ - GPIO_Pin_14, /* LD8 - Orange */ - GPIO_Pin_13, /* LD10 - Red */ - GPIO_Pin_12, /* LD9 - Blue */ - GPIO_Pin_11, /* LD7 - Green */ - GPIO_Pin_10, /* LD5 - Orange */ - GPIO_Pin_9, /* LD3 - Red */ - GPIO_Pin_8 /* LD4 - Blue */ -}; - -/** - * LEDs' GPIO ports - */ -static GPIO_TypeDef* leds_port = GPIOE; - -/** - * Initialize LEDs on the board - */ -void -initialize_leds (void) -{ - GPIO_InitTypeDef gpio_init_structure; - - RCC_AHBPeriphClockCmd (RCC_AHBPeriph_GPIOE, ENABLE); - - uint16_t led_pins_mask = 0; - for (uint32_t led_index = 0; - led_index < LED_NUMBER; - led_index++) - { - led_pins_mask |= led_pins[led_index]; - } - - gpio_init_structure.GPIO_Pin = led_pins_mask; - gpio_init_structure.GPIO_Mode = GPIO_Mode_OUT; - gpio_init_structure.GPIO_OType = GPIO_OType_PP; - gpio_init_structure.GPIO_PuPd = GPIO_PuPd_UP; - gpio_init_structure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init (leds_port, &gpio_init_structure); - - for (uint32_t led_index = 0; - led_index < LED_NUMBER; - led_index++) - { - led_off (led_index); - } -} /* initialize_leds */ -#endif /* !__TARGET_MCU_STM32F4 && __TARGET_MCU_STM32F3 */ - -/** - * Toggle specified LED - */ -void -led_toggle (uint32_t led_id) /**< index of LED */ -{ - if (led_id < LED_NUMBER) - { - leds_port->ODR ^= led_pins[led_id]; - } -} /* led_toggle */ - -/** - * Turn specified LED on - */ -void -led_on (uint32_t led_id) /**< index of LED */ -{ - if (led_id < LED_NUMBER) - { - GPIO_WriteBit (leds_port, led_pins[led_id], Bit_SET); - } -} /* led_on */ - -/** - * Turn specified LED off - */ -void -led_off (uint32_t led_id) /**< index of LED */ -{ - if (led_id < LED_NUMBER) - { - GPIO_WriteBit (leds_port, led_pins[led_id], Bit_RESET); - } -} /* led_off */ - -/** - * Blink once with specified LED - */ -void -led_blink_once (uint32_t led_id) /**< index of LED */ -{ - uint32_t dot = 300; - - led_on (led_id); - wait_ms (dot); - led_off (led_id); -} /* led_blink_once */ - -#endif /* !__TARGET_HOST && !__TARGET_NUTTX && __TARGET_MCU */ diff --git a/plugins/lib-device-stm/actuators.h b/plugins/lib-device-stm/actuators.h deleted file mode 100644 index 01dbc70cc6..0000000000 --- a/plugins/lib-device-stm/actuators.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2014-2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ACTUATORS_H -#define ACTUATORS_H - -#include - -void led_toggle (uint32_t); -void led_on (uint32_t); -void led_off (uint32_t); -void led_blink_once (uint32_t); - -#ifdef __TARGET_MCU -void initialize_leds (void); -#endif - -#endif /* ACTUATORS_H */ - diff --git a/plugins/lib-device-stm/common-io.cpp b/plugins/lib-device-stm/common-io.cpp deleted file mode 100644 index fab2647629..0000000000 --- a/plugins/lib-device-stm/common-io.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* Copyright 2014-2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma GCC optimize "O0" - -#include - -#include "actuators.h" -#include "common-io.h" - -#include "mcu-headers.h" - -int -digital_read (uint32_t arg1, uint32_t arg2) -{ - (void) arg1; - (void) arg2; - - return 0; -} - -void -digital_write (uint32_t arg1, uint32_t arg2) -{ - (void) arg1; - (void) arg2; -} - -int -analog_read (uint32_t arg1, uint32_t arg2) -{ - (void) arg1; - (void) arg2; - - return 0; -} - -void -analog_write (uint32_t arg1, uint32_t arg2) -{ - (void) arg1; - (void) arg2; -} - -#if defined (__TARGET_HOST) || defined (__TARGET_NUTTX) -void -wait_ms (uint32_t time_ms) -{ - printf ("wait_ms: %lu\n", time_ms); -} -#else /* !__TARGET_HOST */ - -#ifndef __TARGET_MCU -# error "!__TARGET_HOST && && !__TARGET_NUTTX !__TARGET_MCU" -#endif /* !__TARGET_MCU */ - -static __IO uint32_t sys_tick_counter; - -void -initialize_sys_tick (void) -{ - /**************************************** - *SystemFrequency/1000 1ms * - *SystemFrequency/100000 10us * - *SystemFrequency/1000000 1us * - *****************************************/ - while (SysTick_Config (SystemCoreClock / 1000000) != 0) - { - } // One SysTick interrupt now equals 1us - -} - -void -set_sys_tick_counter (uint32_t set_value) -{ - sys_tick_counter = set_value; -} - -uint32_t -get_sys_tick_counter (void) -{ - return sys_tick_counter; -} - -void -SysTick_Handler (void) -{ - time_tick_decrement (); -} - -void -time_tick_decrement (void) -{ - if (sys_tick_counter != 0x00) - { - sys_tick_counter --; - } -} - -void -wait_1ms (void) -{ - sys_tick_counter = 1000; - while (sys_tick_counter != 0) - { - } -} - -void -wait_ms (uint32_t time_ms) -{ - while (time_ms --) - { - wait_1ms (); - } -} - -void -fake_exit (void) -{ - uint32_t pin = LED_ORANGE; - volatile int index; - - int dot = 600000; - int dash = dot * 3; - - while (1) - { - led_on (pin); - for (index = 0; index < dot; index ++) - { - }; - led_off (pin); - for (index = 0; index < dash; index ++) - { - }; - } -} -void -initialize_timer () -{ - RCC_APB1PeriphClockCmd (RCC_APB1Periph_TIM2, ENABLE); - - TIM_TimeBaseInitTypeDef timerInitStructure; - timerInitStructure.TIM_Prescaler = 40000; - timerInitStructure.TIM_CounterMode = TIM_CounterMode_Up; - timerInitStructure.TIM_Period = 500; - timerInitStructure.TIM_ClockDivision = TIM_CKD_DIV1; - timerInitStructure.TIM_RepetitionCounter = 0; - TIM_TimeBaseInit (TIM2, &timerInitStructure); - TIM_Cmd (TIM2, ENABLE); -} -#endif /* !__TARGET_HOST && !__TARGET_NUTTX && __TARGET_MCU */ diff --git a/plugins/lib-device-stm/common-io.h b/plugins/lib-device-stm/common-io.h deleted file mode 100644 index 646b76e61e..0000000000 --- a/plugins/lib-device-stm/common-io.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright 2014-2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef COMMON_IO_H -#define COMMON_IO_H - -#include - -int digital_read (uint32_t, uint32_t); -void digital_write (uint32_t, uint32_t); - -int analog_read (uint32_t, uint32_t); -void analog_write (uint32_t, uint32_t); - -void wait_ms (uint32_t); - -#ifdef __TARGET_MCU -void fake_exit (void); - -void initialize_timer (void); -void initialize_sys_tick (void); -void SysTick_Handler (void); - -void time_tick_decrement (void); -void wait_1ms (void); - -void set_sys_tick_counter (uint32_t); -uint32_t get_sys_tick_counter (void); -#endif - -#endif /* COMMON_IO_H */ - diff --git a/plugins/lib-device-stm/init.cpp b/plugins/lib-device-stm/init.cpp deleted file mode 100644 index 43cec67788..0000000000 --- a/plugins/lib-device-stm/init.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "actuators.h" -#include "common-io.h" -#include "init.h" - -void -plugin_device_stm_init (void) -{ -#if defined (__TARGET_MCU_STM32F3) || defined (__TARGET_MCU_STM32F4) - initialize_sys_tick (); - initialize_leds (); - initialize_timer (); -#endif /* __TARGET_MCU_STM32F3 || __TARGET_MCU_STM32F4 */ -} /* plugin_device_stm_init */ diff --git a/plugins/lib-device-stm/init.h b/plugins/lib-device-stm/init.h deleted file mode 100644 index ca7ea4f39f..0000000000 --- a/plugins/lib-device-stm/init.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef INIT_H -#define INIT_H - -extern void plugin_device_stm_init (void); - -#endif /* INIT_H */ diff --git a/plugins/lib-device-stm/mcu-headers.h b/plugins/lib-device-stm/mcu-headers.h deleted file mode 100644 index 28b7ce92b7..0000000000 --- a/plugins/lib-device-stm/mcu-headers.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MCU_HEADERS_H -#define MCU_HEADERS_H - -#ifdef __TARGET_MCU -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wpedantic" -#pragma GCC diagnostic ignored "-Wsign-conversion" -# ifdef __TARGET_MCU_STM32F4 -# include "stm32f4xx_conf.h" -# include "stm32f4xx.h" - -# define LED_GREEN 0 -# define LED_ORANGE 1 -# define LED_RED 2 -# define LED_BLUE 3 -# elif defined (__TARGET_MCU_STM32F3) -# include "stm32f30x_conf.h" -# include "stm32f30x.h" - -# define LED_GREEN 0 -# define LED_ORANGE 1 -# define LED_RED 2 -# define LED_BLUE 3 -# else /* !__TARGET_MCU_STM32F4 && !__TARGET_MCU_STM32F3 */ -# error "!__TARGET_MCU_STM32F4 && !__TARGET_MCU_STM32F3" -# endif /* !__TARGET_MCU_STM32F4 && !__TARGET_MCU_STM32F3 */ -#pragma GCC diagnostic pop -#endif /* __TARGET_MCU */ - -#endif /* !MCU_HEADERS_H */ diff --git a/tests/jerry/extensions.js b/tests/jerry/extensions.js deleted file mode 100644 index 10ccea156c..0000000000 --- a/tests/jerry/extensions.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2015 Samsung Electronics Co., Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// TODO: Test other field types -// TODO: Test functions - -assert(Jerry.io.platform === "linux"); - -Jerry.io.print_uint32 (1); -Jerry.io.print_string (Jerry.io.platform); - -try -{ - // Argument type mismatch - Jerry.io.print_uint32 ('1'); - - assert (false); -} -catch (e) -{ - assert (e instanceof TypeError); -} - -try -{ - // Argument type mismatch - Jerry.io.print_string (1); - - assert (false); -} -catch (e) -{ - assert (e instanceof TypeError); -}