CHDK_DE Vorschauversion  Trunk Rev. 5575
 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 902 der Datei ubasic.c.

903 {
904  char currLabel[MAX_STRINGLEN];
906  currLabel[0] = 0;
908  tokenizer_next();
909  if (tokenizer_token() == TOKENIZER_LABEL) {
910  tokenizer_label(currLabel, sizeof(currLabel));
911  tokenizer_next();
912  if(strcmp(label, currLabel) == 0) {
914  DEBUG_PRINTF("jump_linenum: Found line %d\n", tokenizer_line_number());
915  break;
916  }
917  }
918  }
921  DEBUG_PRINTF("Label %s not found", label);
923  }
924  return 0;
925  } else {
926  return 1;
927  }
928 }
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 2752 der Datei ubasic.c.

2752  {
2753 }
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 2687 der Datei ubasic.c.

2688 {
2689  unsigned start_tick = get_tick_count();
2690  unsigned lines = 0;
2691  flag_yield = 0;
2692 
2693  do
2694  {
2695  if ( ended || tokenizer_finished() )
2696  {
2697  DEBUG_PRINTF("uBASIC program finished\n");
2698  if (ubasic_error)
2699  {
2700  // Generate error message
2701  char buf[100];
2702  const char *msg;
2704  {
2706  }
2707  else
2708  {
2710  }
2711  sprintf(buf, "uBASIC:%d %s ", ubasic_linenumber(), msg);
2712  // Show error message
2713  script_console_add_error((long)buf);
2715  return SCRIPT_RUN_ERROR;
2716  }
2717  // Show 'Finished' message
2719  return SCRIPT_RUN_ENDED;
2720  }
2721 
2722  line_statement();
2723 
2724  // Return control to CHDK only if external processing required
2725  if ( flag_yield )
2726  return SCRIPT_RUN_RUNNING;
2727 
2728  lines++;
2729  } while (lines < yield_max_lines && get_tick_count() - start_tick < yield_max_ms);
2730 
2731  return SCRIPT_RUN_RUNNING;
2732 }
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 2757 der Datei ubasic.c.

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

Definiert in Zeile 2735 der Datei ubasic.c.

2736 {
2737  if(varnum >= 0 && varnum < MAX_VARNUM) {
2738  variables[varnum] = value;
2739  }
2740 }

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.