CHDK_DE Vorschauversion  Trunk Rev. 5426
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
ubasic.c-Dateireferenz
#include "camera_info.h"
#include "stdlib.h"
#include "gui.h"
#include "fileutil.h"
#include "conf.h"
#include "script_api.h"
#include "module_def.h"
#include "gui_lang.h"
+ Include-Abhängigkeitsdiagramm für ubasic.c:

gehe zum Quellcode dieser Datei

Funktionen

int ubasic_init (const char *program, int is_ptp)
 
int ubasic_run (void)
 
void ubasic_end (void)
 
void ubasic_set_variable (int varum, int value)
 
void ubasic_set_as_ret (int md_ret)
 
int jump_label (char *label)
 
static int ubasic_run_restore (void)
 
static void _set_variable (char *name, int value, int isBool, int isTable, int labelCount, const char **labels)
 
static int ubasic_init_file (char const *filename)
 
static void ubasic_script_shoot_hook_run (int hook)
 
static int module_unloader ()
 

Variablen

static char * script_source = 0
 
static char last_script [100] = ""
 
libscriptapi_sym _libubasic
 
ModuleInfo _module_info
 

Dokumentation der Funktionen

static void _set_variable ( char *  name,
int  value,
int  isBool,
int  isTable,
int  labelCount,
const char **  labels 
)
static

Definiert in Zeile 24 der Datei ubasic.c.

25 {
26  ubasic_set_variable(name[0] - (name[0]>='a'?'a':('A'-26)), value);
27 }
int jump_label ( char *  label)

Definiert in Zeile 899 der Datei ubasic.c.

900 {
901  char currLabel[MAX_STRINGLEN];
903  currLabel[0] = 0;
905  tokenizer_next();
906  if (tokenizer_token() == TOKENIZER_LABEL) {
907  tokenizer_label(currLabel, sizeof(currLabel));
908  tokenizer_next();
909  if(strcmp(label, currLabel) == 0) {
911  DEBUG_PRINTF("jump_linenum: Found line %d\n", tokenizer_line_number());
912  break;
913  }
914  }
915  }
918  DEBUG_PRINTF("Label %s not found", label);
920  }
921  return 0;
922  } else {
923  return 1;
924  }
925 }
static int module_unloader ( )
static

Definiert in Zeile 52 der Datei ubasic.c.

53 {
54  if (script_source)
55  {
57  script_source = 0;
58  }
59  return 0;
60 }
void ubasic_end ( void  )

Definiert in Zeile 2749 der Datei ubasic.c.

2749  {
2750 }
int ubasic_init ( const char *  program,
int  is_ptp 
)

Definiert in Zeile 186 der Datei ubasic.c.

187 {
188  program_ptr = program;
189  flag_yield = 0;
191  tokenizer_init(program);
192  ended = 0;
196  return 1;
197 }
static int ubasic_init_file ( char const filename)
static

Definiert in Zeile 32 der Datei ubasic.c.

33 {
34  if (strcmp(last_script, filename) != 0)
35  {
36  strcpy(last_script, filename);
37  if (script_source)
39  script_source = load_file(filename, 0, 1);
40  }
41  if (script_source)
42  {
43  return ubasic_init(script_source, 0);
44  }
45  return 0;
46 }
int ubasic_run ( void  )

Definiert in Zeile 2684 der Datei ubasic.c.

2685 {
2686  unsigned start_tick = get_tick_count();
2687  unsigned lines = 0;
2688  flag_yield = 0;
2689 
2690  do
2691  {
2692  if ( ended || tokenizer_finished() )
2693  {
2694  DEBUG_PRINTF("uBASIC program finished\n");
2695  if (ubasic_error)
2696  {
2697  // Generate error message
2698  char buf[100];
2699  const char *msg;
2701  {
2703  }
2704  else
2705  {
2707  }
2708  sprintf(buf, "uBASIC:%d %s ", ubasic_linenumber(), msg);
2709  // Show error message
2710  script_console_add_error((long)buf);
2712  return SCRIPT_RUN_ERROR;
2713  }
2714  // Show 'Finished' message
2716  return SCRIPT_RUN_ENDED;
2717  }
2718 
2719  line_statement();
2720 
2721  // Return control to CHDK only if external processing required
2722  if ( flag_yield )
2723  return SCRIPT_RUN_RUNNING;
2724 
2725  lines++;
2726  } while (lines < yield_max_lines && get_tick_count() - start_tick < yield_max_ms);
2727 
2728  return SCRIPT_RUN_RUNNING;
2729 }
static int ubasic_run_restore ( void  )
static

Definiert in Zeile 22 der Datei ubasic.c.

22 { return jump_label("restore"); }
static void ubasic_script_shoot_hook_run ( int  hook)
static

Definiert in Zeile 49 der Datei ubasic.c.

49 { return; }
void ubasic_set_as_ret ( int  md_ret)

Definiert in Zeile 2754 der Datei ubasic.c.

2755 {
2756  if (ubasic_as_ret_var_num >= 0)
2758 }
void ubasic_set_variable ( int  varum,
int  value 
)

Definiert in Zeile 2732 der Datei ubasic.c.

2733 {
2734  if(varnum >= 0 && varnum < MAX_VARNUM) {
2735  variables[varnum] = value;
2736  }
2737 }

Variablen-Dokumentation

char last_script[100] = ""
static

Definiert in Zeile 30 der Datei ubasic.c.

char* script_source = 0
static

Definiert in Zeile 29 der Datei ubasic.c.