src/lua_console.c
branchlua-threads
changeset 205 c13d2fc7b480
parent 203 ffdf53fd0337
child 213 f0e52e026197
equal deleted inserted replaced
204:7dfc3d7bd92b 205:c13d2fc7b480
    18 };
    18 };
    19 
    19 
    20 /**
    20 /**
    21  * Line finished execution
    21  * Line finished execution
    22  */
    22  */
    23 static void lua_console_on_thread (struct lua_thread *thread, const error_t *err, void *arg)
    23 static void lua_console_on_thread (const error_t *err, void *arg)
    24 {
    24 {
    25     struct lua_console *lc = arg;
    25     struct lua_console *lc = arg;
    26 
    26 
    27     if (err)
    27     if (err)
    28         // display error message
    28         // display error message
    39  */
    39  */
    40 static enum console_line_status lua_console_on_line (const char *line, void *arg)
    40 static enum console_line_status lua_console_on_line (const char *line, void *arg)
    41 {
    41 {
    42     struct lua_console *lc = arg;
    42     struct lua_console *lc = arg;
    43     error_t err;
    43     error_t err;
       
    44     int ret;
    44 
    45 
    45     // ignore empty lines and EOF
    46     // ignore empty lines and EOF
    46     if (!line || !(*line))
    47     if (!line || !(*line))
    47         return CONSOLE_CONTINUE;
    48         return CONSOLE_CONTINUE;
    48     
    49     
    49     // exec it in our thread
    50     // exec it in our thread
    50     if (lua_thread_start(&lc->thread, line, &err)) {
    51     if ((ret = lua_thread_start(&lc->thread, line, &err)) < 0) {
    51         // display error message
    52         // display error message
    52         console_print(lc->console, error_msg(&err));
    53         console_print(lc->console, error_msg(&err));
    53 
    54 
    54         return CONSOLE_CONTINUE;
    55         return CONSOLE_CONTINUE;
    55     } 
    56     }
    56 
    57 
    57     // wait for it to execute
    58     // waiting?
    58     return CONSOLE_WAIT;
    59     if (ret)
       
    60         return CONSOLE_WAIT;
       
    61 
       
    62     else
       
    63         return CONSOLE_CONTINUE;
    59 }
    64 }
    60 
    65 
    61 static void lua_console_on_eof (void *arg)
    66 static void lua_console_on_eof (void *arg)
    62 {
    67 {
    63     struct lua_console *lc = arg;
    68     struct lua_console *lc = arg;