[finsh] convert tab to space and split export API to finsh_api.h

This commit is contained in:
Bernard Xiong committed 2018-03-01 21:01:20 +08:00
1 parent 15fa3084c3
commit f9a7ba050a
20 files changed
+2333 -2296

No files matched your search

+6 -6
View File
@@ -106,11 +106,11 @@ static long _list_thread(struct rt_list_node *list)
rt_kprintf( " --- ------- ---------- ---------- ------ ---------- ---\n");
for (node = list->next; node != list; node = node->next)
{
rt_uint8_t stat;
rt_uint8_t stat;
thread = rt_list_entry(node, struct rt_thread, list);
rt_kprintf("%-*.*s %3d ", maxlen, RT_NAME_MAX, thread->name, thread->current_priority);
stat = (thread->stat & RT_THREAD_STAT_MASK);
stat = (thread->stat & RT_THREAD_STAT_MASK);
if (stat == RT_THREAD_READY) rt_kprintf(" ready ");
else if (stat == RT_THREAD_SUSPEND) rt_kprintf(" suspend");
else if (stat == RT_THREAD_INIT) rt_kprintf(" init ");
@@ -607,7 +607,7 @@ int list_module(void)
{
module = (struct rt_module *)(rt_list_entry(node, struct rt_object, list));
rt_kprintf("%-*.*s %-04d 0x%08x\n",
maxlen, RT_NAME_MAX,
maxlen, RT_NAME_MAX,
module->parent.name, module->nref, module->module_space);
}
@@ -634,14 +634,14 @@ int list_mod_detail(const char *name)
/* list main thread in module */
if (module->module_thread != RT_NULL)
{
rt_uint8_t stat;
rt_uint8_t stat;
rt_kprintf("main thread pri status sp stack size max used left tick error\n");
rt_kprintf("------------- ---- ------- ---------- ---------- ---------- ---------- ---\n");
thread = module->module_thread;
rt_kprintf("%-8.*s 0x%02x", RT_NAME_MAX, thread->name, thread->current_priority);
stat = (thread->stat & RT_THREAD_STAT_MASK);
stat = (thread->stat & RT_THREAD_STAT_MASK);
if (stat == RT_THREAD_READY) rt_kprintf(" ready ");
else if (stat == RT_THREAD_SUSPEND) rt_kprintf(" suspend");
else if (stat == RT_THREAD_INIT) rt_kprintf(" init ");
+91 -285
View File
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+20 -20
View File
@@ -33,42 +33,42 @@ uint8_t global_errno;
static const char * finsh_error_string_table[] =
{
"No error",
"Invalid token",
"Expect a type",
"Unknown type",
"Variable exist",
"Expect a operater",
"Memory full",
"Unknown operator",
"Unknown node",
"Expect a character",
"Unexpect end",
"Unknown token",
"Float not supported",
"Unknown symbol",
"Null node"
"Invalid token",
"Expect a type",
"Unknown type",
"Variable exist",
"Expect a operater",
"Memory full",
"Unknown operator",
"Unknown node",
"Expect a character",
"Unexpect end",
"Unknown token",
"Float not supported",
"Unknown symbol",
"Null node"
};
int finsh_error_init()
{
global_errno = FINSH_ERROR_OK;
global_errno = FINSH_ERROR_OK;
return 0;
return 0;
}
int finsh_error_set(uint8_t type)
{
global_errno = type;
global_errno = type;
return 0;
return 0;
}
uint8_t finsh_errno()
{
return global_errno;
return global_errno;
}
const char* finsh_error_string(uint8_t type)
{
return finsh_error_string_table[type];
return finsh_error_string_table[type];
}
File diff suppressed because it is too large. Load diff
+18 -18
View File
@@ -37,15 +37,15 @@
int finsh_init(struct finsh_parser* parser)
{
finsh_parser_init(parser);
finsh_parser_init(parser);
/* finsh init */
finsh_node_init();
finsh_var_init();
finsh_error_init();
finsh_heap_init();
/* finsh init */
finsh_node_init();
finsh_var_init();
finsh_error_init();
finsh_heap_init();
return 0;
return 0;
}
long finsh_stack_bottom()
@@ -55,22 +55,22 @@ long finsh_stack_bottom()
int finsh_flush(struct finsh_parser* parser)
{
finsh_parser_init(parser);
finsh_parser_init(parser);
/* finsh init */
finsh_node_init();
finsh_error_init();
/* finsh init */
finsh_node_init();
finsh_error_init();
return 0;
return 0;
}
int finsh_reset(struct finsh_parser* parser)
{
/* finsh init */
finsh_node_init();
finsh_var_init();
finsh_error_init();
finsh_heap_init();
/* finsh init */
finsh_node_init();
finsh_var_init();
finsh_error_init();
finsh_heap_init();
return 0;
return 0;
}
File diff suppressed because it is too large. Load diff
+36 -36
View File
@@ -31,46 +31,46 @@
#include <finsh.h>
#define FINSH_NODE_UNKNOWN 0
#define FINSH_NODE_ID 1
#define FINSH_NODE_UNKNOWN 0
#define FINSH_NODE_ID 1
#define FINSH_NODE_VALUE_CHAR 2
#define FINSH_NODE_VALUE_INT 3
#define FINSH_NODE_VALUE_LONG 4
#define FINSH_NODE_VALUE_STRING 5
#define FINSH_NODE_VALUE_NULL 6
#define FINSH_NODE_VALUE_CHAR 2
#define FINSH_NODE_VALUE_INT 3
#define FINSH_NODE_VALUE_LONG 4
#define FINSH_NODE_VALUE_STRING 5
#define FINSH_NODE_VALUE_NULL 6
#define FINSH_NODE_SYS_ADD 7
#define FINSH_NODE_SYS_SUB 8
#define FINSH_NODE_SYS_MUL 9
#define FINSH_NODE_SYS_DIV 10
#define FINSH_NODE_SYS_MOD 11
#define FINSH_NODE_SYS_AND 12
#define FINSH_NODE_SYS_OR 13
#define FINSH_NODE_SYS_XOR 14
#define FINSH_NODE_SYS_BITWISE 15
#define FINSH_NODE_SYS_SHL 16
#define FINSH_NODE_SYS_SHR 17
#define FINSH_NODE_SYS_FUNC 18
#define FINSH_NODE_SYS_ASSIGN 19
#define FINSH_NODE_SYS_CAST 20
#define FINSH_NODE_SYS_PREINC 21
#define FINSH_NODE_SYS_PREDEC 22
#define FINSH_NODE_SYS_INC 23
#define FINSH_NODE_SYS_DEC 24
#define FINSH_NODE_SYS_ADD 7
#define FINSH_NODE_SYS_SUB 8
#define FINSH_NODE_SYS_MUL 9
#define FINSH_NODE_SYS_DIV 10
#define FINSH_NODE_SYS_MOD 11
#define FINSH_NODE_SYS_AND 12
#define FINSH_NODE_SYS_OR 13
#define FINSH_NODE_SYS_XOR 14
#define FINSH_NODE_SYS_BITWISE 15
#define FINSH_NODE_SYS_SHL 16
#define FINSH_NODE_SYS_SHR 17
#define FINSH_NODE_SYS_FUNC 18
#define FINSH_NODE_SYS_ASSIGN 19
#define FINSH_NODE_SYS_CAST 20
#define FINSH_NODE_SYS_PREINC 21
#define FINSH_NODE_SYS_PREDEC 22
#define FINSH_NODE_SYS_INC 23
#define FINSH_NODE_SYS_DEC 24
#define FINSH_NODE_SYS_GETVALUE 25
#define FINSH_NODE_SYS_GETADDR 26
#define FINSH_NODE_SYS_NULL 27
#define FINSH_NODE_SYS_NULL 27
#define FINSH_DATA_TYPE_VOID 0x00
#define FINSH_DATA_TYPE_BYTE 0x01
#define FINSH_DATA_TYPE_WORD 0x02
#define FINSH_DATA_TYPE_DWORD 0x03
#define FINSH_DATA_TYPE_PTR 0x10
#define FINSH_DATA_TYPE_VOID 0x00
#define FINSH_DATA_TYPE_BYTE 0x01
#define FINSH_DATA_TYPE_WORD 0x02
#define FINSH_DATA_TYPE_DWORD 0x03
#define FINSH_DATA_TYPE_PTR 0x10
#define FINSH_NODE_VALUE 0
#define FINSH_NODE_ADDRESS 1
#define FINSH_NODE_FUNCTION 2
#define FINSH_NODE_VALUE 0
#define FINSH_NODE_ADDRESS 1
#define FINSH_NODE_FUNCTION 2
int finsh_node_init(void);
@@ -82,7 +82,7 @@ struct finsh_node* finsh_node_new_long(long l);
struct finsh_node* finsh_node_new_string(char* s);
struct finsh_node* finsh_node_new_ptr(void* ptr);
#define finsh_node_sibling(node) ((node)->sibling)
#define finsh_node_child(node) ((node)->child)
#define finsh_node_sibling(node) ((node)->sibling)
#define finsh_node_child(node) ((node)->child)
#endif
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+31 -31
View File
@@ -33,42 +33,42 @@
enum finsh_token_type
{
finsh_token_type_left_paren = 1, /* ( */
finsh_token_type_right_paren , /* ) */
finsh_token_type_comma , /* , */
finsh_token_type_semicolon , /* ; */
finsh_token_type_mul , /* * */
finsh_token_type_add , /* + */
finsh_token_type_inc , /* ++ */
finsh_token_type_sub , /* - */
finsh_token_type_dec , /* -- */
finsh_token_type_div , /* / */
finsh_token_type_mod , /* % */
finsh_token_type_assign , /* = */
finsh_token_type_and, /* & */
finsh_token_type_or, /* | */
finsh_token_type_xor, /* ^ */
finsh_token_type_bitwise, /* ~ */
finsh_token_type_shl, /* << */
finsh_token_type_shr, /* >> */
finsh_token_type_comments, /* // */
/*-- data type --*/
finsh_token_type_void, /* void */
finsh_token_type_char, /* char */
finsh_token_type_short, /* short */
finsh_token_type_int, /* int */
finsh_token_type_long, /* long */
finsh_token_type_unsigned, /* unsigned */
finsh_token_type_left_paren = 1, /* ( */
finsh_token_type_right_paren , /* ) */
finsh_token_type_comma , /* , */
finsh_token_type_semicolon , /* ; */
finsh_token_type_mul , /* * */
finsh_token_type_add , /* + */
finsh_token_type_inc , /* ++ */
finsh_token_type_sub , /* - */
finsh_token_type_dec , /* -- */
finsh_token_type_div , /* / */
finsh_token_type_mod , /* % */
finsh_token_type_assign , /* = */
finsh_token_type_and, /* & */
finsh_token_type_or, /* | */
finsh_token_type_xor, /* ^ */
finsh_token_type_bitwise, /* ~ */
finsh_token_type_shl, /* << */
finsh_token_type_shr, /* >> */
finsh_token_type_comments, /* // */
/*-- data type --*/
finsh_token_type_void, /* void */
finsh_token_type_char, /* char */
finsh_token_type_short, /* short */
finsh_token_type_int, /* int */
finsh_token_type_long, /* long */
finsh_token_type_unsigned, /* unsigned */
/* data value type */
finsh_token_type_value_char, /* v:char */
finsh_token_type_value_int, /* v:int */
finsh_token_type_value_long, /* v:long */
finsh_token_type_value_string, /* v:string */
finsh_token_type_value_null, /* NULL */
/*-- others --*/
finsh_token_type_identifier, /* ID */
finsh_token_type_bad, /* bad token */
finsh_token_type_eof
finsh_token_type_value_null, /* NULL */
/*-- others --*/
finsh_token_type_identifier, /* ID */
finsh_token_type_bad, /* bad token */
finsh_token_type_eof
};
#define finsh_token_position(self) (self)->position
File diff suppressed because it is too large. Load diff
+10 -10
View File
@@ -37,18 +37,18 @@
*/
struct finsh_var
{
char name[FINSH_NAME_MAX + 1]; /* the name of variable */
char name[FINSH_NAME_MAX + 1]; /* the name of variable */
uint8_t type; /* the type of variable */
uint8_t type; /* the type of variable */
/* variable value */
union {
char char_value;
short short_value;
int int_value;
long long_value;
void* ptr;
}value;
/* variable value */
union {
char char_value;
short short_value;
int int_value;
long long_value;
void* ptr;
}value;
};
extern struct finsh_var global_variable[];
File diff suppressed because it is too large. Load diff
+8 -8
View File
@@ -34,19 +34,19 @@
#include "finsh_var.h"
union finsh_value {
char char_value;
short short_value;
long long_value;
void* ptr;
char char_value;
short short_value;
long long_value;
void* ptr;
};
extern union finsh_value* finsh_sp; /* stack pointer */
extern uint8_t* finsh_pc; /* PC */
extern union finsh_value* finsh_sp; /* stack pointer */
extern uint8_t* finsh_pc; /* PC */
/* stack */
extern union finsh_value finsh_vm_stack[FINSH_STACK_MAX];
extern union finsh_value finsh_vm_stack[FINSH_STACK_MAX];
/* text segment */
extern uint8_t text_segment[FINSH_TEXT_MAX];
extern uint8_t text_segment[FINSH_TEXT_MAX];
void finsh_vm_run(void);
//void finsh_disassemble(void);
+25 -25
View File
@@ -191,7 +191,7 @@ int cmd_cd(int argc, char **argv)
{
if (chdir(argv[1]) != 0)
{
rt_kprintf("No such directory: %s\n", argv[1]);
rt_kprintf("No such directory: %s\n", argv[1]);
}
}
@@ -262,7 +262,7 @@ int cmd_df(int argc, char** argv)
{
df("/");
}
else
else
{
if ((strcmp(argv[1], "--help") == 0) || (strcmp(argv[1], "-h") == 0))
{
@@ -280,31 +280,31 @@ FINSH_FUNCTION_EXPORT_ALIAS(cmd_df, __cmd_df, disk free);
int cmd_echo(int argc, char** argv)
{
if (argc == 2)
{
rt_kprintf("%s\n", argv[1]);
}
else if (argc == 3)
{
int fd;
if (argc == 2)
{
rt_kprintf("%s\n", argv[1]);
}
else if (argc == 3)
{
int fd;
fd = open(argv[2], O_RDWR | O_APPEND | O_CREAT, 0);
if (fd >= 0)
{
write (fd, argv[1], strlen(argv[1]));
close(fd);
}
else
{
rt_kprintf("open file:%s failed!\n", argv[2]);
}
}
else
{
rt_kprintf("Usage: echo \"string\" [filename]\n");
}
fd = open(argv[2], O_RDWR | O_APPEND | O_CREAT, 0);
if (fd >= 0)
{
write (fd, argv[1], strlen(argv[1]));
close(fd);
}
else
{
rt_kprintf("open file:%s failed!\n", argv[2]);
}
}
else
{
rt_kprintf("Usage: echo \"string\" [filename]\n");
}
return 0;
return 0;
}
FINSH_FUNCTION_EXPORT_ALIAS(cmd_echo, __cmd_echo, echo string to file);
#endif
+1 -1
View File
@@ -233,7 +233,7 @@ static void finsh_wait_auth(void)
rt_size_t cur_pos = 0;
/* password not set */
if (rt_strlen(finsh_get_password()) == 0) return;
while (1)
{
rt_kprintf("Password for login: ");
+16 -16
View File
@@ -42,39 +42,39 @@ long list_mempool(void);
long list_timer(void);
#ifdef FINSH_USING_SYMTAB
struct finsh_syscall *_syscall_table_begin = NULL;
struct finsh_syscall *_syscall_table_end = NULL;
struct finsh_sysvar *_sysvar_table_begin = NULL;
struct finsh_sysvar *_sysvar_table_end = NULL;
struct finsh_syscall *_syscall_table_begin = NULL;
struct finsh_syscall *_syscall_table_end = NULL;
struct finsh_sysvar *_sysvar_table_begin = NULL;
struct finsh_sysvar *_sysvar_table_end = NULL;
#else
struct finsh_syscall _syscall_table[] =
{
{"hello", hello},
{"version", version},
{"list", list},
{"list_thread", list_thread},
{"hello", hello},
{"version", version},
{"list", list},
{"list_thread", list_thread},
#ifdef RT_USING_SEMAPHORE
{"list_sem", list_sem},
{"list_sem", list_sem},
#endif
#ifdef RT_USING_MUTEX
{"list_mutex", list_mutex},
{"list_mutex", list_mutex},
#endif
#ifdef RT_USING_FEVENT
{"list_fevent", list_fevent},
{"list_fevent", list_fevent},
#endif
#ifdef RT_USING_EVENT
{"list_event", list_event},
{"list_event", list_event},
#endif
#ifdef RT_USING_MAILBOX
{"list_mb", list_mailbox},
{"list_mb", list_mailbox},
#endif
#ifdef RT_USING_MESSAGEQUEUE
{"list_mq", list_msgqueue},
{"list_mq", list_msgqueue},
#endif
#ifdef RT_USING_MEMPOOL
{"list_memp", list_mempool},
{"list_memp", list_mempool},
#endif
{"list_timer", list_timer},
{"list_timer", list_timer},
};
struct finsh_syscall *_syscall_table_begin = &_syscall_table[0];
struct finsh_syscall *_syscall_table_end = &_syscall_table[sizeof(_syscall_table) / sizeof(struct finsh_syscall)];
+1 -1
View File
@@ -564,7 +564,7 @@ void rt_assert_handler(const char *ex, const char *func, rt_size_t line);
#endif /* RT_DEBUG */
#ifdef RT_USING_FINSH
#include <finsh.h>
#include <finsh_api.h>
#endif
/**@}*/