jerry_create_undefined (), &ret_val, 1); jerry_release_value (ret_val_print); } jerry_release_value (ret_val); return 0; } /* shell_cmd_handler */ #define SHELL_COMMAND(name,cmd) { name, cmd } const struct shell_cmd commands[] = { SHELL_COMMAND ("syntax", shell_cmd_syntax_help), SHELL_COMMAND ("version", shell_cmd_version), SHELL_COMMAND ("test", shell_cmd_test), SHELL_COMMAND ("verbose", shell_cmd_verbose), SHELL_COMMAND (NULL, NULL) }; void main (void) { printf ("Jerry Compilation " __DATE__ " " __TIME__ "\n"); jerry_init (JERRY_INIT_EMPTY); jerry_value_t global_obj_val = jerry_get_global_object (); jerry_value_t print_func_name_val = jerry_create_string ((jerry_char_t *) "print"); print_function = jerry_get_property (global_obj_val, print_func_name_val);
static const char shell_summary_help[] = "shell help"; static const char shell_help_help[] = "[<command>]\n" " [<command>] - the command to get help on.\n" "Without arguments it shows a summary of all the shell commands.\n"; static void shell_func_help(int argc, char **argv); /// shell命令列表的结束标记. #define SHELL_COMMAND_END() {0, 0, 0, 0} static const shell_command_t buildin_shell_commands[] = { #ifdef SHELL_COMMAND_CUSTOM_LIST SHELL_COMMAND_CUSTOM_LIST, #endif SHELL_COMMAND("help", help), SHELL_COMMAND("exit", exit), SHELL_COMMAND_END(), }; static void shell_list_summary_help(const shell_command_t *cmds) { const shell_command_t *pcmd; for (pcmd = cmds; pcmd->cmd != NULL; ++pcmd) { if (strlen(pcmd->summary) > 0) { printf(" %-6s - %s\n", pcmd->cmd, pcmd->summary); } } } static const shell_command_t *shell_detail_help(const shell_command_t *cmds, const char *cmd) { const shell_command_t *pcmd;