Changeset 484


Ignore:
Timestamp:
Apr 17, 2011, 10:28:20 AM (6 years ago)
Author:
sam
Message:

lisp: populate LispSymbol? with symbol-related methods.

Location:
abuse/trunk/src
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/chars.cpp

    r482 r484  
    8181};
    8282
    83 int character_type::add_state(void *symbol)             // returns index into seq to use
     83int character_type::add_state(void *symbol) // returns index into seq to use
    8484{
    8585  if (item_type(symbol)!=L_SYMBOL)
     
    110110    int sp=current_space;
    111111    current_space=PERM_SPACE;
    112     set_symbol_number(symbol,num);
     112    ((LispSymbol *)symbol)->SetNumber(num);
    113113    current_space=sp;
    114114  }
     
    119119    lbreak("symbol has been assigned value %d, but value already in use by state %s\n"
    120120       "use a different symbol for this state\n",
    121        lstring_value(symbol_name(seq_syms[num])));
     121       lstring_value(((LispSymbol *)seq_syms[num])->GetName()));
    122122    exit(0);
    123123  } else if (num>=ts)
     
    219219           "  with index %d, but %s has a var listed '%s' with same index\n"
    220220           "  try moving definition of %s before previously declared object",
    221            lstring_value(symbol_name(name)),
    222            lstring_value(symbol_name(symbol)),
     221           lstring_value(((LispSymbol *)name)->GetName()),
     222           lstring_value(((LispSymbol *)symbol)->GetName()),
    223223           index,
    224            lstring_value(symbol_name(name)),
    225            lstring_value(symbol_name(vars[index])),
    226            lstring_value(symbol_name(name))
     224           lstring_value(((LispSymbol *)name)->GetName()),
     225           lstring_value(((LispSymbol *)vars[index])->GetName()),
     226           lstring_value(((LispSymbol *)name)->GetName())
    227227           );
    228228    exit(0);
     
    285285  }
    286286  for (i=0;i<tiv;i++)
    287     if (!strcmp(lstring_value(symbol_name(vars[i])),name))
     287    if (!strcmp(lstring_value(((LispSymbol *)vars[i])->GetName()),name))
    288288      return 1;
    289289  return 0;
     
    301301  tiv=0;
    302302
    303   void *l_abil=  make_find_symbol("abilities");
    304   void *l_funs=  make_find_symbol("funs");
    305   void *l_states=make_find_symbol("states");
    306   void *l_flags= make_find_symbol("flags");
    307   void *l_range= make_find_symbol("range");
    308   void *l_draw_range= make_find_symbol("draw_range");
    309   void *l_fields=make_find_symbol("fields");
    310   void *l_logo=  make_find_symbol("logo");
    311   void *l_vars=  make_find_symbol("vars");
     303  LispSymbol *l_abil =   LispSymbol::FindOrCreate("abilities");
     304  LispSymbol *l_funs =   LispSymbol::FindOrCreate("funs");
     305  LispSymbol *l_states = LispSymbol::FindOrCreate("states");
     306  LispSymbol *l_flags =  LispSymbol::FindOrCreate("flags");
     307  LispSymbol *l_range =  LispSymbol::FindOrCreate("range");
     308  LispSymbol *l_draw_range = LispSymbol::FindOrCreate("draw_range");
     309  LispSymbol *l_fields = LispSymbol::FindOrCreate("fields");
     310  LispSymbol *l_logo =   LispSymbol::FindOrCreate("logo");
     311  LispSymbol *l_vars =   LispSymbol::FindOrCreate("vars");
    312312
    313313  memset(fun_table,0,sizeof(fun_table));     // destory all hopes of fun
     
    336336      for (i=0;i<TOTAL_ABILITIES;i++)
    337337      {
    338     Cell *ab=assoc(make_find_symbol(ability_names[i]),l);
     338    Cell *ab=assoc(LispSymbol::FindOrCreate(ability_names[i]),l);
    339339    p_ref r5(ab);
    340340    if (!NILP(ab))
     
    347347      for (i=0;i<TOTAL_OFUNS;i++)
    348348      {
    349     Cell *ab=assoc(make_find_symbol(ofun_names[i]),l);
     349    Cell *ab=assoc(LispSymbol::FindOrCreate(ofun_names[i]),l);
    350350    p_ref r5(ab);
    351351    if (!NILP(ab) && lcar(lcdr(ab)))
     
    358358      for (i=0;i<TOTAL_CFLAGS;i++)
    359359      {
    360     Cell *ab=assoc(make_find_symbol(cflag_names[i]),l);
     360    Cell *ab=assoc(LispSymbol::FindOrCreate(cflag_names[i]),l);
    361361    p_ref r5(ab);
    362362    if (!NILP(ab) && eval(lcar(lcdr(ab))))
     
    440440  if (!seq[stopped])
    441441    lbreak("object (%s) has no stopped state, please define one!\n",
    442        lstring_value(symbol_name(name)));
     442       lstring_value(((LispSymbol *)name)->GetName()));
    443443
    444444/*  char *fn=lstring_value(lcar(desc));
  • abuse/trunk/src/clisp.cpp

    r482 r484  
    3939
    4040// the following are references to lisp symbols
    41 void *l_difficulty,*l_easy,*l_hard,*l_medium,*l_main_menu,*l_extreme,
    42      *l_logo,*l_state_art,*l_abilities,*l_state_sfx,
    43      *l_song_list,*l_filename,*l_sfx_directory,*l_max_hp,*l_default_font,
    44      *l_morph,*l_max_power,*l_default_abilities,*l_default_ai_function,
    45      *l_tile_files,*l_empty_cache,*l_range,*l_hurt_all,*l_death_handler,
     41LispSymbol *l_chat_input, *l_post_render;
     42
     43LispSymbol *l_difficulty, *l_easy, *l_hard, *l_medium, *l_extreme,
     44    *l_max_hp, *l_max_power,
     45    *l_empty_cache;
     46
     47// FIXME: port these to LispSymbol
     48void *l_main_menu, *l_logo,*l_state_art,*l_abilities,*l_state_sfx,
     49     *l_song_list,*l_filename,*l_sfx_directory,*l_default_font,
     50     *l_morph,*l_default_abilities,*l_default_ai_function,
     51     *l_tile_files,*l_range,*l_hurt_all,*l_death_handler,
    4652     *l_title_screen,*l_console_font,*l_fields,*l_dist,*l_pushx,*l_pushy,
    4753     *l_object,*l_tile,*l_fire_object,*l_FIRE,*l_cop_dead_parts,*l_restart_player,
     
    5561     *l_ask_save_slot,
    5662     *l_get_local_input,
    57      *l_post_render,
    58      *l_chat_input,
    5963     *l_player_text_color,
    6064     *l_level_loaded;        // called when a new level is loaded
     
    99103                                             // to irnterface with c
    100104{
    101   l_easy=make_find_symbol("easy");
    102   l_medium=make_find_symbol("medium");
    103   l_hard=make_find_symbol("hard");
    104   l_extreme=make_find_symbol("extreme");
    105 
    106   l_logo=make_find_symbol("logo");
    107   l_morph=make_find_symbol("morph");
    108 
    109   l_pushx=make_find_symbol("pushx");
    110   l_pushy=make_find_symbol("pushy");
    111 
    112   l_dist=make_find_symbol("dist");
    113   l_state_art=make_find_symbol("state_art");
    114   l_abilities=make_find_symbol("abilities");
    115   l_default_abilities=make_find_symbol("default_abilities");
    116   l_state_sfx=make_find_symbol("state_sfx");
    117   l_filename=make_find_symbol("filename");
    118   l_sfx_directory=make_find_symbol("sfx_directory");
    119   l_default_font=make_find_symbol("default_font");
    120   l_console_font=make_find_symbol("console_font");
    121   l_default_ai_function=make_find_symbol("default_ai");
    122   l_tile_files=make_find_symbol("tile_files");
    123   l_empty_cache=make_find_symbol("empty_cache");
    124   l_range=make_find_symbol("range");
    125   l_difficulty=make_find_symbol("difficulty");
    126   l_death_handler=make_find_symbol("death_handler");
    127   l_title_screen=make_find_symbol("title_screen");
    128   l_fields=make_find_symbol("fields");
    129   l_FIRE=make_find_symbol("FIRE");
    130   l_fire_object=make_find_symbol("fire_object");
    131   l_cop_dead_parts=make_find_symbol("cop_dead_parts");  set_symbol_value(l_difficulty,l_hard);
    132   l_restart_player=make_find_symbol("restart_player");
    133   l_help_screens=make_find_symbol("help_screens");
    134   l_save_order=make_find_symbol("save_order");
    135   l_next_song=make_find_symbol("next_song");
    136   l_player_draw=make_find_symbol("player_draw");
    137   l_sneaky_draw=make_find_symbol("sneaky_draw");
    138   l_keep_backup=make_find_symbol("keep_backup");
    139   l_level_loaded=make_find_symbol("level_loaded");
    140 
    141   l_draw_fast=make_find_symbol("draw_fast");
    142   l_player_tints=make_find_symbol("player_tints");
    143 
    144   l_max_hp=make_find_symbol("max_hp");
    145   set_symbol_number(l_max_hp,200);
    146   l_max_power=make_find_symbol("max_power");
    147   l_main_menu=make_find_symbol("main_menu");
    148   set_symbol_number(l_max_power,999);
    149 
    150   set_symbol_number(make_find_symbol("run_state"),RUN_STATE);
    151   set_symbol_number(make_find_symbol("pause_state"),PAUSE_STATE);
    152   set_symbol_number(make_find_symbol("menu_state"),MENU_STATE);
    153   set_symbol_number(make_find_symbol("scene_state"),SCENE_STATE);
    154 
    155   l_statbar_ammo_x=make_find_symbol("statbar_ammo_x");
    156   l_statbar_ammo_y=make_find_symbol("statbar_ammo_y");
    157   l_statbar_ammo_w=make_find_symbol("statbar_ammo_w");
    158   l_statbar_ammo_h=make_find_symbol("statbar_ammo_h");
    159   l_statbar_ammo_bg_color=make_find_symbol("statbar_ammo_bg_color");
    160 
    161   l_statbar_health_x=make_find_symbol("statbar_health_x");
    162   l_statbar_health_y=make_find_symbol("statbar_health_y");
    163   l_statbar_health_w=make_find_symbol("statbar_health_w");
    164   l_statbar_health_h=make_find_symbol("statbar_health_h");
    165   l_statbar_health_bg_color=make_find_symbol("statbar_health_bg_color");
    166 
    167   l_statbar_logo_x=make_find_symbol("statbar_logo_x");
    168   l_statbar_logo_y=make_find_symbol("statbar_logo_y");
    169   l_object=make_find_symbol("object");
    170   l_tile=make_find_symbol("tile");
    171   l_cdc_logo=make_find_symbol("logo");
    172 
    173   l_switch_to_powerful=make_find_symbol("switch_to_powerful");
    174   l_mouse_can_switch=make_find_symbol("mouse_can_switch");
    175   l_ask_save_slot=make_find_symbol("ask_save_slot");
    176 
    177   l_level_load_start=make_find_symbol("level_load_start");
    178   l_level_load_end=make_find_symbol("level_load_end");
    179   l_get_local_input=make_find_symbol("get_local_input");
    180   l_chat_input=make_find_symbol("chat_input");
    181   l_player_text_color=make_find_symbol("player_text_color");
     105  l_easy = LispSymbol::FindOrCreate("easy");
     106  l_medium = LispSymbol::FindOrCreate("medium");
     107  l_hard = LispSymbol::FindOrCreate("hard");
     108  l_extreme = LispSymbol::FindOrCreate("extreme");
     109
     110  l_logo = LispSymbol::FindOrCreate("logo");
     111  l_morph = LispSymbol::FindOrCreate("morph");
     112
     113  l_pushx = LispSymbol::FindOrCreate("pushx");
     114  l_pushy = LispSymbol::FindOrCreate("pushy");
     115
     116  l_dist = LispSymbol::FindOrCreate("dist");
     117  l_state_art = LispSymbol::FindOrCreate("state_art");
     118  l_abilities = LispSymbol::FindOrCreate("abilities");
     119  l_default_abilities = LispSymbol::FindOrCreate("default_abilities");
     120  l_state_sfx = LispSymbol::FindOrCreate("state_sfx");
     121  l_filename = LispSymbol::FindOrCreate("filename");
     122  l_sfx_directory = LispSymbol::FindOrCreate("sfx_directory");
     123  l_default_font = LispSymbol::FindOrCreate("default_font");
     124  l_console_font = LispSymbol::FindOrCreate("console_font");
     125  l_default_ai_function = LispSymbol::FindOrCreate("default_ai");
     126  l_tile_files = LispSymbol::FindOrCreate("tile_files");
     127  l_empty_cache = LispSymbol::FindOrCreate("empty_cache");
     128  l_range = LispSymbol::FindOrCreate("range");
     129  l_difficulty = LispSymbol::FindOrCreate("difficulty");
     130  l_death_handler = LispSymbol::FindOrCreate("death_handler");
     131  l_title_screen = LispSymbol::FindOrCreate("title_screen");
     132  l_fields = LispSymbol::FindOrCreate("fields");
     133  l_FIRE = LispSymbol::FindOrCreate("FIRE");
     134  l_fire_object = LispSymbol::FindOrCreate("fire_object");
     135  l_cop_dead_parts = LispSymbol::FindOrCreate("cop_dead_parts");
     136  l_difficulty->SetValue(l_hard);
     137  l_restart_player = LispSymbol::FindOrCreate("restart_player");
     138  l_help_screens = LispSymbol::FindOrCreate("help_screens");
     139  l_save_order = LispSymbol::FindOrCreate("save_order");
     140  l_next_song = LispSymbol::FindOrCreate("next_song");
     141  l_player_draw = LispSymbol::FindOrCreate("player_draw");
     142  l_sneaky_draw = LispSymbol::FindOrCreate("sneaky_draw");
     143  l_keep_backup = LispSymbol::FindOrCreate("keep_backup");
     144  l_level_loaded = LispSymbol::FindOrCreate("level_loaded");
     145
     146  l_draw_fast = LispSymbol::FindOrCreate("draw_fast");
     147  l_player_tints = LispSymbol::FindOrCreate("player_tints");
     148
     149  l_max_hp = LispSymbol::FindOrCreate("max_hp");
     150  l_max_hp->SetNumber(200);
     151  l_max_power = LispSymbol::FindOrCreate("max_power");
     152  l_main_menu = LispSymbol::FindOrCreate("main_menu");
     153  l_max_power->SetNumber(999);
     154
     155  LispSymbol::FindOrCreate("run_state")->SetNumber(RUN_STATE);
     156  LispSymbol::FindOrCreate("pause_state")->SetNumber(PAUSE_STATE);
     157  LispSymbol::FindOrCreate("menu_state")->SetNumber(MENU_STATE);
     158  LispSymbol::FindOrCreate("scene_state")->SetNumber(SCENE_STATE);
     159
     160  l_statbar_ammo_x = LispSymbol::FindOrCreate("statbar_ammo_x");
     161  l_statbar_ammo_y = LispSymbol::FindOrCreate("statbar_ammo_y");
     162  l_statbar_ammo_w = LispSymbol::FindOrCreate("statbar_ammo_w");
     163  l_statbar_ammo_h = LispSymbol::FindOrCreate("statbar_ammo_h");
     164  l_statbar_ammo_bg_color = LispSymbol::FindOrCreate("statbar_ammo_bg_color");
     165
     166  l_statbar_health_x = LispSymbol::FindOrCreate("statbar_health_x");
     167  l_statbar_health_y = LispSymbol::FindOrCreate("statbar_health_y");
     168  l_statbar_health_w = LispSymbol::FindOrCreate("statbar_health_w");
     169  l_statbar_health_h = LispSymbol::FindOrCreate("statbar_health_h");
     170  l_statbar_health_bg_color = LispSymbol::FindOrCreate("statbar_health_bg_color");
     171
     172  l_statbar_logo_x = LispSymbol::FindOrCreate("statbar_logo_x");
     173  l_statbar_logo_y = LispSymbol::FindOrCreate("statbar_logo_y");
     174  l_object = LispSymbol::FindOrCreate("object");
     175  l_tile = LispSymbol::FindOrCreate("tile");
     176  l_cdc_logo = LispSymbol::FindOrCreate("logo");
     177
     178  l_switch_to_powerful = LispSymbol::FindOrCreate("switch_to_powerful");
     179  l_mouse_can_switch = LispSymbol::FindOrCreate("mouse_can_switch");
     180  l_ask_save_slot = LispSymbol::FindOrCreate("ask_save_slot");
     181
     182  l_level_load_start = LispSymbol::FindOrCreate("level_load_start");
     183  l_level_load_end = LispSymbol::FindOrCreate("level_load_end");
     184  l_get_local_input = LispSymbol::FindOrCreate("get_local_input");
     185  l_chat_input = LispSymbol::FindOrCreate("chat_input");
     186  l_player_text_color = LispSymbol::FindOrCreate("player_text_color");
    182187
    183188  int i;
    184189  for (i=0;i<MAX_STATE;i++)
    185     set_symbol_number(make_find_symbol(state_names[i]),i);
     190    LispSymbol::FindOrCreate(state_names[i])->SetNumber(i);
    186191  for (i=0;i<TOTAL_ABILITIES;i++)
    187     set_symbol_number(make_find_symbol(ability_names[i]),i);
     192    LispSymbol::FindOrCreate(ability_names[i])->SetNumber(i);
    188193  for (i=0;i<TOTAL_CFLAGS;i++)
    189     set_symbol_number(make_find_symbol(cflag_names[i]),i);
    190 
    191   l_song_list=make_find_symbol("song_list");
    192   l_post_render=make_find_symbol("post_render");
     194    LispSymbol::FindOrCreate(cflag_names[i])->SetNumber(i);
     195
     196  l_song_list = LispSymbol::FindOrCreate("song_list");
     197  l_post_render = LispSymbol::FindOrCreate("post_render");
    193198
    194199  add_c_function("distx",0,0,                   1);
     
    756761      if (item_type(sym)!=L_SYMBOL)
    757762      {
    758     lbreak("expecting first arg to def-character to be a symbol!\n");
    759     exit(0);
     763        lbreak("expecting first arg to def-character to be a symbol!\n");
     764        exit(0);
    760765      }
    761766      int sp=current_space;
    762767      current_space=PERM_SPACE;
    763       set_symbol_number(sym,total_objects);   // set the symbol value to the object number
     768      sym->SetNumber(total_objects);   // set the symbol value to the object number
    764769      current_space=sp;
    765770      if (!total_objects)
     
    774779      }
    775780
    776       object_names[total_objects] = strdup(lstring_value(symbol_name(sym)));
     781      object_names[total_objects] = strdup(lstring_value(sym->GetName()));
    777782      figures[total_objects]=new character_type(CDR(args),sym);
    778783      total_objects++;
     
    794799    {
    795800#ifdef __linux__
    796       return make_find_symbol("LINUX");
     801      return LispSymbol::FindOrCreate("LINUX");
    797802#endif
    798803#ifdef __sgi
    799       return make_find_symbol("IRIX");
     804      return LispSymbol::FindOrCreate("IRIX");
    800805#endif
    801806#ifdef __WIN32
    802       return make_find_symbol("WIN32");
     807      return LispSymbol::FindOrCreate("WIN32");
    803808#endif
    804809    } break;
     
    13661371      int id=cache.reg(lstring_value(lcar(args)),NULL,SPEC_EXTERN_SFX,1);
    13671372      if (sym)
    1368         set_symbol_number(sym,id);    // set the symbol value to sfx id               
     1373        sym->SetNumber(id);    // set the symbol value to sfx id
    13691374      current_space=sp;
    13701375      return id;
  • abuse/trunk/src/clisp.h

    r481 r484  
    1414
    1515// variables for the status bar
     16extern LispSymbol *l_chat_input, *l_post_render;
     17
     18// FIXME: port these to LispSymbol
    1619extern void *l_statbar_ammo_x,*l_statbar_ammo_y,
    1720            *l_statbar_ammo_w,*l_statbar_ammo_h,
     
    3437        *l_ask_save_slot,
    3538        *l_get_local_input,
    36         *l_post_render,
    37         *l_chat_input,
    3839        *l_player_text_color,
    3940        *l_level_loaded;        // called when a new level is loaded
     
    4142
    4243/******************************** Lisp objects **********************************/
    43 extern void *l_difficulty,*l_easy,*l_hard,*l_medium,*l_extreme,*l_main_menu,
     44extern LispSymbol *l_difficulty, *l_easy, *l_hard, *l_medium, *l_extreme,
     45    *l_max_hp, *l_max_power,
     46    *l_empty_cache;
     47
     48// FIXME: port these to LispSymbol
     49extern void *l_main_menu,
    4450     *l_logo,*l_state_art,*l_default_abilities,*l_abilities,
    45      *l_default_ai_function,*l_state_sfx,
    46      *l_morph,*l_max_power,
    47      *l_song_list,*l_filename,*l_sfx_directory,*l_max_hp,*l_default_font,
    48      *l_empty_cache,*l_range,*l_joy_file,*l_death_handler,
     51     *l_default_ai_function,*l_state_sfx, *l_morph,
     52     *l_song_list,*l_filename,*l_sfx_directory,*l_default_font,
     53     *l_range,*l_joy_file,*l_death_handler,
    4954     *l_title_screen,*l_console_font,*l_fields,*l_FIRE,*l_fire_object,
    5055     *l_cop_dead_parts,*l_restart_player,*l_help_screens,*l_save_order;
  • abuse/trunk/src/compiled.cpp

    r482 r484  
    4242static int32_t c_state(char const *name)
    4343{
    44   void *sym=find_symbol(name);
     44  void *sym = LispSymbol::Find(name);
    4545  if (sym)
    4646  {
     
    122122  S_DELETE_SND=  c_state("DEL_OBJECT_SND");
    123123
    124   void *b=make_find_symbol("bad_guy_list");
     124  void *b = LispSymbol::FindOrCreate("bad_guy_list");
    125125  if (b && DEFINEDP(symbol_value(b)))
    126126  {
     
    138138  }
    139139
    140   void *v=symbol_value(make_find_symbol("last_save_game"));
     140  void *v = LispSymbol::FindOrCreate("last_save_game")->GetValue();
    141141  if (DEFINEDP(v))
    142142    last_save_game_number=lnumber_value(v);
  • abuse/trunk/src/configuration.cpp

    r481 r484  
    3636    char tmp[40];
    3737    sprintf( tmp, "player%d", player );
    38     Cell *f = find_symbol( tmp );
    39     if( !NILP( f ) && DEFINEDP( symbol_value( f ) ) )
    40     {
    41         void *what = symbol_value( f );
    42         if( what == make_find_symbol( "keyboard" ) )
     38    LispSymbol *f = LispSymbol::Find(tmp);
     39    if( !NILP(f) && DEFINEDP(f->GetValue()))
     40    {
     41        void *what = f->GetValue();
     42        if(what == LispSymbol::FindOrCreate("keyboard"))
    4343            return 1;
    44         else if( what == make_find_symbol( "joystick" ) )
     44        else if(what == LispSymbol::FindOrCreate("joystick"))
    4545            return 2;
    4646    }
  • abuse/trunk/src/cop.cpp

    r483 r484  
    727727    if (o->lvars[just_fired_var])
    728728    {
    729       o->draw_double_tint(lnumber_value(((LispArray *)symbol_value(l_player_tints))->Get(num)),S_bright_tint);
     729      o->draw_double_tint(lnumber_value(((LispArray *)((LispSymbol *)l_player_tints)->GetValue())->Get(num)), S_bright_tint);
    730730      o->lvars[just_fired_var]=0;
    731731    } else
    732       o->draw_tint(lnumber_value(((LispArray *)symbol_value(l_player_tints))->Get(num)));
     732      o->draw_tint(lnumber_value(((LispArray *)((LispSymbol *)l_player_tints)->GetValue())->Get(num)));
    733733  }
    734734  return NULL;
     
    10211021    for (i=0;i<tp;i++)
    10221022    {
    1023       int color=lnumber_value(((LispArray *)symbol_value(l_player_text_color))->Get(sorted_players[i]->get_tint()));
     1023      int color=lnumber_value(((LispArray *)((LispSymbol *)l_player_text_color)->GetValue())->Get(sorted_players[i]->get_tint()));
    10241024      sprintf(msg,"%3ld %s",(long)sorted_players[i]->kills,sorted_players[i]->name);
    10251025      if (sorted_players[i]==local)
     
    10621062  {
    10631063    enum { NAME_LEN=18 } ;
    1064     int color=lnumber_value(((LispArray *)symbol_value(l_player_text_color))->Get(v->get_tint()));
     1064    int color=lnumber_value(((LispArray *)((LispSymbol *)l_player_text_color)->GetValue())->Get(v->get_tint()));
    10651065    char max_name[NAME_LEN];
    10661066    strncpy(max_name,v->name,NAME_LEN-1);
  • abuse/trunk/src/demo.cpp

    r481 r484  
    169169
    170170  the_game->load_level(tname);
    171   initial_difficulty=l_difficulty;
     171  initial_difficulty = l_difficulty;
    172172
    173173  switch (diff)
    174174  {
    175     case 0 :
    176     { set_symbol_value(l_difficulty,l_easy); } break;
    177     case 1 :
    178     { set_symbol_value(l_difficulty,l_medium); } break;
    179     case 2 :
    180     { set_symbol_value(l_difficulty,l_hard); } break;
    181     case 3 :
    182     { set_symbol_value(l_difficulty,l_extreme); } break;
     175    case 0: l_difficulty->SetValue(l_easy); break;
     176    case 1: l_difficulty->SetValue(l_medium); break;
     177    case 2: l_difficulty->SetValue(l_hard); break;
     178    case 3: l_difficulty->SetValue(l_extreme); break;
    183179  }
    184180
     
    207203*/
    208204      delete record_file;
    209       l_difficulty=initial_difficulty;
     205      l_difficulty = initial_difficulty;
    210206      the_game->set_state(MENU_STATE);
    211207      wm->push_event(new event(ID_NULL,NULL));
  • abuse/trunk/src/demo.h

    r481 r484  
    1111#define __DEMO_HPP_
    1212
     13#include "lisp.h"
    1314#include "jwindow.h"
    1415
    1516class demo_manager
    1617{
    17   void *initial_difficulty;
     18  LispSymbol *initial_difficulty;
    1819  bFILE *record_file;
    1920  int skip_next;
  • abuse/trunk/src/dev.cpp

    r481 r484  
    4242char const *symbol_str(char const *name)
    4343{
    44   void *sym=make_find_symbol(name);
    45   if (symbol_value(sym) && item_type(symbol_value(sym))==L_STRING)
    46     return lstring_value(symbol_value(sym));
     44  LispSymbol *sym = LispSymbol::FindOrCreate(name);
     45  if (sym->GetValue() && item_type(sym->GetValue())==L_STRING)
     46    return lstring_value(sym->GetValue());
    4747
    4848
     
    6767
    6868  // check again to see if the symbol is there
    69   sym=make_find_symbol(name);
    70   if (symbol_value(sym) && item_type(symbol_value(sym))==L_STRING)
    71     return lstring_value(symbol_value(sym));
     69  sym = LispSymbol::FindOrCreate(name);
     70  if (sym->GetValue() && item_type(sym->GetValue())==L_STRING)
     71    return lstring_value(sym->GetValue());
    7272
    7373
    7474  // check to see if there is a missing symbol definition
    75   sym=make_find_symbol("missing_sym");
    76   if (symbol_value(sym) && item_type(symbol_value(sym))==L_STRING)
    77     return lstring_value(symbol_value(sym));
     75  sym = LispSymbol::FindOrCreate("missing_sym");
     76  if (sym->GetValue() && item_type(sym->GetValue())==L_STRING)
     77    return lstring_value(sym->GetValue());
    7878
    7979  // last resort, return english string
  • abuse/trunk/src/director.cpp

    r481 r484  
    126126  pan_time=frame_time=text_time=NULL;
    127127  int done=0;
    128   void *pan_symbol=make_find_symbol("pan"),
    129        *text_symbol=make_find_symbol("text");
     128  LispSymbol *pan_symbol = LispSymbol::FindOrCreate("pan"),
     129             *text_symbol = LispSymbol::FindOrCreate("text");
    130130
    131131  JCFont *font=wm->font();
  • abuse/trunk/src/endgame.cpp

    r481 r484  
    153153
    154154
    155   int explo_snd=lnumber_value(symbol_value(make_find_symbol("P_EXPLODE_SND")));
    156   int space_snd=lnumber_value(symbol_value(make_find_symbol("SPACE_SND")));
    157   int zip_snd=lnumber_value(symbol_value(make_find_symbol("SHIP_ZIP_SND")));
     155  int explo_snd = lnumber_value(LispSymbol::FindOrCreate("P_EXPLODE_SND")->GetValue());
     156  int space_snd = lnumber_value(LispSymbol::FindOrCreate("SPACE_SND")->GetValue());
     157  int zip_snd = lnumber_value(LispSymbol::FindOrCreate("SHIP_ZIP_SND")->GetValue());
    158158
    159159
     
    370370    cmap[i]=pal->find_closest(i*256/32,i*256/32,i*256/32);
    371371
    372   void *end_plot=symbol_value(make_find_symbol("plot_end"));
     372  void *end_plot = LispSymbol::FindOrCreate("plot_end")->GetValue();
    373373
    374374
     
    427427  image *im=cache.img(cache.reg("art/endgame.spe","tbc",SPEC_IMAGE,1));
    428428
    429   void *to_be=symbol_value(make_find_symbol("to_be_continued"));
     429  void *to_be = LispSymbol::FindOrCreate("to_be_continued")->GetValue();
    430430  p_ref r1(to_be);
    431431
    432   void *mid_plot=symbol_value(make_find_symbol("plot_middle"));
     432  void *mid_plot = LispSymbol::FindOrCreate("plot_middle")->GetValue();
    433433  p_ref r2(mid_plot);
    434 
    435434
    436435  int dx=(xres+1)/2-im->width()/2,dy=(yres+1)/2-im->height()/2;
     
    486485  int dx=(xres+1)/2-320/2,dy=(yres+1)/2-200/2;
    487486
    488   void *end_plot=symbol_value(make_find_symbol("plot_end"));
     487  void *end_plot = LispSymbol::FindOrCreate("plot_end")->GetValue();
    489488  p_ref r2(end_plot);
    490489
  • abuse/trunk/src/game.cpp

    r482 r484  
    686686static void post_render()
    687687{
    688   if(DEFINEDP(symbol_function(l_post_render)))
     688  if(DEFINEDP(l_post_render->GetFunction()))
    689689  {
    690690    screen->dirt_off();
    691691    clear_tmp();
    692     eval_function((LispSymbol *)l_post_render, NULL);
     692    eval_function(l_post_render, NULL);
    693693    clear_tmp();
    694694    screen->dirt_on();
     
    12321232    }
    12331233
    1234     void *logo_snd = symbol_value(make_find_symbol("LOGO_SND"));
     1234    void *logo_snd = LispSymbol::FindOrCreate("LOGO_SND")->GetValue();
    12351235
    12361236    if(DEFINEDP(logo_snd) && (sound_avail & SFX_INITIALIZED))
     
    12491249    milli_wait(400);
    12501250
    1251     void *space_snd = symbol_value(make_find_symbol("SPACE_SND"));
     1251    void *space_snd = LispSymbol::FindOrCreate("SPACE_SND")->GetValue();
    12521252
    12531253    fade_out(32);
     
    12551255
    12561256    int i;
    1257     char *str = lstring_value(eval(make_find_symbol("plot_start")));
     1257    char *str = lstring_value(eval(LispSymbol::FindOrCreate("plot_start")));
    12581258
    12591259    bFILE *fp = open_file("art/smoke.spe", "rb");
     
    26372637    if(!(main_net_cfg && main_net_cfg->restart_state()))
    26382638    {
    2639       void *end_msg = make_find_symbol("end_msg");
    2640       if(DEFINEDP(symbol_value(end_msg)))
    2641       printf("%s\n", lstring_value(symbol_value(end_msg)));
     2639      LispSymbol *end_msg = LispSymbol::FindOrCreate("end_msg");
     2640      if(DEFINEDP(end_msg->GetValue()))
     2641      printf("%s\n", lstring_value(end_msg->GetValue()));
    26422642    }
    26432643
  • abuse/trunk/src/gamma.cpp

    r481 r484  
    5757static char const *lang_string(char const *symbol)
    5858{
    59   void *v=find_symbol(symbol);
    60   if (!v || !DEFINEDP(symbol_value(v))) return "Language symbol missing!";
    61   else return lstring_value(symbol_value(v));
     59    LispSymbol *v = LispSymbol::Find(symbol);
     60    if (!v || !DEFINEDP(v->GetValue()))
     61        return "Language symbol missing!";
     62    return lstring_value(v->GetValue());
    6263}
    6364
     
    6869
    6970    // see if user has already done this routine
    70     Cell *gs = find_symbol("darkest_gray");
     71    LispSymbol *gs = LispSymbol::Find("darkest_gray");
    7172
    7273    if(old_pal)
     
    7778    }
    7879
    79     if(gs && DEFINEDP(symbol_value(gs)) && !force_menu)
    80     {
    81         dg = lnumber_value(symbol_value(gs));
     80    if(gs && DEFINEDP(gs->GetValue()) && !force_menu)
     81    {
     82        dg = lnumber_value(gs->GetValue());
    8283    }
    8384    else
    8485    {
    85         if(gs && DEFINEDP(symbol_value(gs)))
    86         {
    87             dg = old_dg = lnumber_value(symbol_value(gs));
     86        if(gs && DEFINEDP(gs->GetValue()))
     87        {
     88            dg = old_dg = lnumber_value(gs->GetValue());
    8889        }
    8990        // load in a fine gray palette they can chose from
     
    181182                int sp = current_space;
    182183                current_space = PERM_SPACE;
    183                 set_symbol_value(make_find_symbol("darkest_gray"), new_lisp_number(dg));
     184                LispSymbol::FindOrCreate("darkest_gray")->SetNumber(dg);
    184185
    185186                current_space = sp;
  • abuse/trunk/src/level.cpp

    r482 r484  
    10801080      {
    10811081        if (figures[new_type]->seq[k] &&
    1082            !strcmp(lstring_value(symbol_name(figures[new_type]->seq_syms[k])),old_name))
     1082           !strcmp(lstring_value(((LispSymbol *)figures[new_type]->seq_syms[k])->GetName()),old_name))
    10831083        *(s_remap[i]+j)=k;
    10841084      }
     
    11191119          if (figures[new_type]->vars[k])
    11201120          {
    1121         if (!strcmp(lstring_value(symbol_name(figures[new_type]->vars[k])),old_name))
     1121        if (!strcmp(lstring_value(((LispSymbol *)figures[new_type]->vars[k])->GetName()),old_name))
    11221122          *(v_remap[i]+j)=figures[new_type]->var_index[k];
    11231123          }
     
    15601560    for (;j<figures[i]->ts;j++)
    15611561      if (figures[i]->seq[j])
    1562         size+=1+strlen(lstring_value(symbol_name(figures[i]->seq_syms[j])))+1;
     1562        size+=1+strlen(lstring_value(((LispSymbol *)figures[i]->seq_syms[j])->GetName()))+1;
    15631563  }
    15641564  sd.add_by_hand(new spec_entry(SPEC_DATA_ARRAY,"describe_states",NULL,size,0));
     
    15731573    for (;j<figures[i]->tiv;j++)
    15741574      if (figures[i]->vars[j])
    1575         size+=1+strlen(lstring_value(symbol_name(figures[i]->vars[j])))+1;
     1575        size+=1+strlen(lstring_value(((LispSymbol *)figures[i]->vars[j])->GetName()))+1;
    15761576  }
    15771577  sd.add_by_hand(new spec_entry(SPEC_DATA_ARRAY,"describe_lvars",NULL,size,0));
     
    18271827  } else
    18281828  {
    1829     void *fun=make_find_symbol("set_player_defaults");
    1830     if (DEFINEDP(symbol_function(fun)))
     1829    LispSymbol *fun = LispSymbol::FindOrCreate("set_player_defaults");
     1830    if (DEFINEDP(fun->GetFunction()))
    18311831    {
    18321832      view *f;
     
    18381838      current_object=f->focus;
    18391839      void *m=mark_heap(TMP_SPACE);
    1840       eval_function((LispSymbol *)fun,NULL);
     1840      eval_function(fun,NULL);
    18411841      restore_heap(m,TMP_SPACE);
    18421842    }
     
    18871887      if (figures[i]->seq[j])
    18881888      {
    1889     char *state_name=lstring_value(symbol_name(figures[i]->seq_syms[j]));
     1889    char *state_name=lstring_value(((LispSymbol *)figures[i]->seq_syms[j])->GetName());
    18901890    fp->write_uint8(strlen(state_name)+1);
    18911891    fp->write(state_name,strlen(state_name)+1);
     
    19061906        if (figures[i]->vars[j] && figures[i]->var_index[j]==x)
    19071907    {
    1908       char *var_name=lstring_value(symbol_name(figures[i]->vars[j]));
     1908      char *var_name=lstring_value(((LispSymbol *)figures[i]->vars[j])->GetName());
    19091909      fp->write_uint8(strlen(var_name)+1);
    19101910      fp->write(var_name,strlen(var_name)+1);
  • abuse/trunk/src/lisp/lisp.cpp

    r483 r484  
    820820*/
    821821
    822 LispSymbol *find_symbol(char const *name)
    823 {
    824   LispSymbol *p=lsym_root;
    825   while (p)
    826   {
    827     int cmp=strcmp(name, ((char *)p->name)+sizeof(LispString));
    828     if (cmp==0) return p;
    829     else if (cmp<0) p=p->left;
    830     else p=p->right;
    831   }
    832   return NULL;
    833 }
    834 
    835 
    836 
    837 LispSymbol *make_find_symbol(char const *name)
    838 {
    839   LispSymbol *p=lsym_root;
    840   LispSymbol **parent=&lsym_root;
    841   while (p)
    842   {
    843     int cmp=strcmp(name, ((char *)p->name)+sizeof(LispString));
    844     if (cmp==0) return p;
    845     else if (cmp<0)
    846     {
    847       parent=&p->left;
    848       p=p->left;
    849     }
    850     else
    851     {
    852       parent=&p->right;
    853       p=p->right;
    854     }
    855   }
    856   int sp=current_space;
    857   if (current_space!=GC_SPACE)
    858      current_space=PERM_SPACE;       // make sure all symbols get defined in permanant space
    859 
    860   p=(LispSymbol *)malloc(sizeof(LispSymbol));
    861   p->type=L_SYMBOL;
    862   p->name=new_lisp_string(name);
    863 
    864   if (name[0]==':')     // constant, set the value to ourself
    865     p->value=p;
    866   else
    867     p->value=l_undefined;
    868   p->function=l_undefined;
     822LispSymbol *LispSymbol::Find(char const *name)
     823{
     824    LispSymbol *p = lsym_root;
     825    while (p)
     826    {
     827        int cmp = strcmp(name, ((char *)p->name) + sizeof(LispString));
     828        if (cmp == 0)
     829            return p;
     830        p = (cmp < 0) ? p->left : p->right;
     831    }
     832    return NULL;
     833}
     834
     835LispSymbol *LispSymbol::FindOrCreate(char const *name)
     836{
     837    LispSymbol *p = lsym_root;
     838    LispSymbol **parent = &lsym_root;
     839    while (p)
     840    {
     841        int cmp = strcmp(name, ((char *)p->name) + sizeof(LispString));
     842        if (cmp == 0)
     843            return p;
     844        parent = (cmp < 0) ? &p->left : &p->right;
     845        p = *parent;
     846    }
     847
     848    // Make sure all symbols get defined in permanant space
     849    int sp = current_space;
     850    if (current_space != GC_SPACE)
     851       current_space = PERM_SPACE;
     852
     853    p = (LispSymbol *)malloc(sizeof(LispSymbol));
     854    p->type = L_SYMBOL;
     855    p->name = new_lisp_string(name);
     856
     857    // If constant, set the value to ourself
     858    p->value = (name[0] == ':') ? p : l_undefined;
     859    p->function = l_undefined;
    869860#ifdef L_PROFILE
    870   p->time_taken=0;
    871 #endif
    872   p->left=p->right=NULL;
    873   *parent=p;
    874   ltotal_syms++;
    875 
    876   current_space=sp;
    877   return p;
    878 }
    879 
     861    p->time_taken = 0;
     862#endif
     863    p->left = p->right = NULL;
     864    *parent = p;
     865    ltotal_syms++;
     866
     867    current_space = sp;
     868    return p;
     869}
    880870
    881871void ldelete_syms(LispSymbol *root)
     
    898888    {
    899889      if (lisp_eq(CAR(CAR(list)), item))
    900         return lcar(list);   
     890        return lcar(list);
    901891      list=(LispList *)(CDR(list));
    902892    }
     
    967957}
    968958
    969 void *lookup_symbol_function(void *symbol)
    970 {
    971   return ((LispSymbol *)symbol)->function;
    972 }
    973 
    974 void set_symbol_function(void *symbol, void *function)
    975 {
    976   ((LispSymbol *)symbol)->function=function;
    977 }
    978 
    979 void *lookup_symbol_value(void *symbol)
    980 {
    981 #ifdef TYPE_CHECKING
    982   if (((LispSymbol *)symbol)->value!=l_undefined)
    983 #endif
    984     return ((LispSymbol *)symbol)->value;
    985 #ifdef TYPE_CHECKING
    986   else
    987   {
    988     lprint(symbol);
    989     lbreak(" has no value\n");
    990     exit(0);
    991   }
    992 #endif
    993   return NULL;
    994 }
    995 
    996 void set_variable_value(void *symbol, void *value)
    997 {
    998   ((LispSymbol *) symbol)->value=value;
     959void LispSymbol::SetFunction(void *fun)
     960{
     961    function = fun;
    999962}
    1000963
     
    1002965{
    1003966  need_perm_space("add_sys_function");
    1004   LispSymbol *s=make_find_symbol(name);
     967  LispSymbol *s = LispSymbol::FindOrCreate(name);
    1005968  if (s->function!=l_undefined)
    1006969  {
     
    1018981  if (s->value!=l_undefined)
    1019982  {
    1020     lbreak("add_c_object -> symbol %s already has a value\n", lstring_value(symbol_name(s)));
     983    lbreak("add_c_object -> symbol %s already has a value\n", lstring_value(s->GetName()));
    1021984    exit(0);
    1022985  }
     
    1029992  total_user_functions++;
    1030993  need_perm_space("add_c_function");
    1031   LispSymbol *s=make_find_symbol(name);
     994  LispSymbol *s = LispSymbol::FindOrCreate(name);
    1032995  if (s->function!=l_undefined)
    1033996  {
     
    10431006  total_user_functions++;
    10441007  need_perm_space("add_c_bool_fun");
    1045   LispSymbol *s=make_find_symbol(name);
     1008  LispSymbol *s = LispSymbol::FindOrCreate(name);
    10461009  if (s->function!=l_undefined)
    10471010  {
     
    10581021  total_user_functions++;
    10591022  need_perm_space("add_c_bool_fun");
    1060   LispSymbol *s=make_find_symbol(name);
     1023  LispSymbol *s = LispSymbol::FindOrCreate(name);
    10611024  if (s->function!=l_undefined)
    10621025  {
     
    12861249      void *cs=new_cons_cell(), *c2=NULL, *tmp;
    12871250      p_ref r4(cs), r5(c2);
    1288       tmp=make_find_symbol("function");
     1251      tmp = LispSymbol::FindOrCreate("function");
    12891252      ((LispList *)cs)->car=tmp;
    12901253      c2=new_cons_cell();
     
    13001263    }
    13011264  } else {
    1302     ret = make_find_symbol(n);
     1265    ret = LispSymbol::FindOrCreate(n);
    13031266  }
    13041267  return ret;
     
    15871550    {
    15881551      char st[100];
    1589       sprintf(st, "%20s %f\n", lstring_value(symbol_name(p)), ((LispSymbol *)p)->time_taken);
     1552      sprintf(st, "%20s %f\n", lstring_value(p->GetName()), p->time_taken);
    15901553      out->write(st, strlen(st));
    15911554    }
     
    21492112    case SYS_FUNC_DEFUN:
    21502113    {
    2151       void *symbol=CAR(arg_list);
     2114      LispSymbol *symbol = (LispSymbol *)CAR(arg_list);
    21522115#ifdef TYPE_CHECKING
    21532116      if (item_type(symbol)!=L_SYMBOL)
     
    21742137      LispUserFunction *ufun=new_lisp_user_function(lcar(lcdr(arg_list)), block_list);
    21752138#endif
    2176       set_symbol_function(symbol, ufun);
     2139      symbol->SetFunction(ufun);
    21772140      ret=symbol;
    21782141    } break;
     
    22792242    } break;
    22802243    case SYS_FUNC_FUNCTION:
    2281       ret=lookup_symbol_function(eval(CAR(arg_list)));
     2244      ret = ((LispSymbol *)eval(CAR(arg_list)))->GetFunction();
    22822245    break;
    22832246    case SYS_FUNC_MAPCAR:
     
    24022365            {
    24032366                delete fp;
    2404                 if( DEFINEDP(symbol_value(load_warning)) && symbol_value(load_warning) )
     2367                if( DEFINEDP(((LispSymbol *)load_warning)->GetValue())
     2368                     && ((LispSymbol *)load_warning)->GetValue())
    24052369                    dprintf("Warning : file %s does not exist\n", st);
    24062370                ret = NULL;
     
    25602524    case SYS_FUNC_FOR:
    25612525    {
    2562       void *bind_var=CAR(arg_list); arg_list=CDR(arg_list);
     2526      LispSymbol *bind_var = (LispSymbol *)CAR(arg_list);
     2527      arg_list = CDR(arg_list);
    25632528      p_ref r1(bind_var);
    25642529      if (item_type(bind_var)!=L_SYMBOL)
     
    25782543      void *block=NULL, *ret=NULL;
    25792544      p_ref r3(block);
    2580       l_user_stack.push(symbol_value(bind_var));  // save old symbol value
     2545      l_user_stack.push(bind_var->GetValue());  // save old symbol value
    25812546      while (ilist)
    25822547      {
    2583                 set_symbol_value(bind_var, CAR(ilist));
     2548                bind_var->SetValue(CAR(ilist));
    25842549                for (block=arg_list;block;block=CDR(block))
    25852550                  ret=eval(CAR(block));
    25862551                ilist=CDR(ilist);
    25872552      }
    2588       set_symbol_value(bind_var, l_user_stack.pop(1));
     2553      bind_var->SetValue(l_user_stack.pop(1)); // restore symbol value
    25892554      ret=ret;
    25902555    } break;
     
    27292694      p_ref r1(init_var);
    27302695      int i, ustack_start=l_user_stack.son;      // restore stack at end
    2731       void *sym=NULL;
     2696      LispSymbol *sym = NULL;
    27322697      p_ref r2(sym);
    27332698
     
    27352700      for (init_var=CAR(arg_list);init_var;init_var=CDR(init_var))
    27362701      {
    2737                 sym=CAR(CAR(init_var));
     2702                sym = (LispSymbol *)CAR(CAR(init_var));
    27382703                if (item_type(sym)!=L_SYMBOL)
    27392704                { lbreak("expecting symbol name for iteration var\n"); exit(0); }
    2740                 l_user_stack.push(symbol_value(sym));
     2705                l_user_stack.push(sym->GetValue());
    27412706      }
    27422707
     
    27492714      for (init_var=CAR(arg_list);init_var;init_var=CDR(init_var), do_evaled++)
    27502715      {
    2751                 sym=CAR(CAR(init_var));
    2752                 set_symbol_value(sym, *do_evaled);
     2716                sym = (LispSymbol *)CAR(CAR(init_var));
     2717                sym->SetValue(*do_evaled);
    27532718      }
    27542719
     
    27712736      for (init_var=CAR(arg_list);init_var;init_var=CDR(init_var), do_evaled++)
    27722737      {
    2773                 sym=CAR(CAR(init_var));
    2774                 set_symbol_value(sym, *do_evaled);
     2738                sym = (LispSymbol *)CAR(CAR(init_var));
     2739                sym->SetValue(*do_evaled);
    27752740      }
    27762741
     
    30503015        else
    30513016                {
    3052                   ret=lookup_symbol_value(prog);
     3017                  ret = ((LispSymbol *)prog)->GetValue();
    30533018                  if (item_type(ret)==L_OBJECT_VAR)
    30543019                    ret=l_obj_get(((LispObjectVar *)ret)->number);
     
    31623127}
    31633128
    3164 void *symbol_name(void *symbol)
    3165 {
    3166   return ((LispSymbol *)symbol)->name;
    3167 }
    3168 
    3169 
    3170 void *set_symbol_number(void *symbol, long num)
     3129void *LispSymbol::GetName()
    31713130{
    31723131#ifdef TYPE_CHECKING
    3173   if (item_type(symbol)!=L_SYMBOL)
    3174   {
    3175     lprint(symbol);
    3176     lbreak("is not a symbol\n");
    3177     exit(0);
    3178   }
    3179 #endif
    3180   if (((LispSymbol *)symbol)->value!=l_undefined &&
    3181       item_type(((LispSymbol *)symbol)->value)==L_NUMBER)
    3182     ((LispNumber *)((LispSymbol *)symbol)->value)->num=num;
    3183   else
    3184     ((LispSymbol *)(symbol))->value=new_lisp_number(num);
    3185 
    3186   return ((LispSymbol *)(symbol))->value;
    3187 }
    3188 
    3189 void *set_symbol_value(void *symbol, void *value)
     3132    if (item_type(this) != L_SYMBOL)
     3133    {
     3134        lprint(this);
     3135        lbreak("is not a symbol\n");
     3136        exit(0);
     3137    }
     3138#endif
     3139    return name;
     3140}
     3141
     3142void *LispSymbol::SetNumber(long num)
    31903143{
    31913144#ifdef TYPE_CHECKING
    3192   if (item_type(symbol)!=L_SYMBOL)
    3193   {
    3194     lprint(symbol);
    3195     lbreak("is not a symbol\n");
    3196     exit(0);
    3197   }
    3198 #endif
    3199   ((LispSymbol *)(symbol))->value=value;
    3200   return value;
    3201 }
    3202 
    3203 void *symbol_function(void *symbol)
     3145    if (item_type(this) != L_SYMBOL)
     3146    {
     3147        lprint(this);
     3148        lbreak("is not a symbol\n");
     3149        exit(0);
     3150    }
     3151#endif
     3152    if (value != l_undefined && item_type(value) == L_NUMBER)
     3153        ((LispNumber *)value)->num = num;
     3154    else
     3155        value = new_lisp_number(num);
     3156
     3157    return value;
     3158}
     3159
     3160void *LispSymbol::SetValue(void *val)
    32043161{
    32053162#ifdef TYPE_CHECKING
    3206   if (item_type(symbol)!=L_SYMBOL)
    3207   {
    3208     lprint(symbol);
    3209     lbreak("is not a symbol\n");
    3210     exit(0);
    3211   }
    3212 #endif
    3213   return ((LispSymbol *)symbol)->function;
    3214 }
    3215 
    3216 void *symbol_value(void *symbol)
     3163    if (item_type(this) != L_SYMBOL)
     3164    {
     3165        lprint(this);
     3166        lbreak("is not a symbol\n");
     3167        exit(0);
     3168    }
     3169#endif
     3170    value = val;
     3171    return value;
     3172}
     3173
     3174void *LispSymbol::GetFunction()
    32173175{
    32183176#ifdef TYPE_CHECKING
    3219   if (item_type(symbol)!=L_SYMBOL)
    3220   {
    3221     lprint(symbol);
    3222     lbreak("is not a symbol\n");
    3223     exit(0);
    3224   }
    3225 #endif
    3226   return ((LispSymbol *)symbol)->value;
    3227 }
    3228 
    3229 
    3230 
    3231 
    3232 
    3233 
     3177    if (item_type(this) != L_SYMBOL)
     3178    {
     3179        lprint(this);
     3180        lbreak("is not a symbol\n");
     3181        exit(0);
     3182    }
     3183#endif
     3184    return function;
     3185}
     3186
     3187void *LispSymbol::GetValue()
     3188{
     3189#ifdef TYPE_CHECKING
     3190    if (item_type(this) != L_SYMBOL)
     3191    {
     3192        lprint(this);
     3193        lbreak("is not a symbol\n");
     3194        exit(0);
     3195    }
     3196#endif
     3197    return value;
     3198}
     3199
  • abuse/trunk/src/lisp/lisp.h

    r483 r484  
    7171};
    7272
     73struct LispString : LispObject
     74{
     75};
     76
    7377struct LispSymbol : LispObject
    7478{
     79    static LispSymbol *Find(char const *name);
     80    static LispSymbol *FindOrCreate(char const *name);
     81
     82    void *GetName();
     83    void *GetFunction();
     84    void *GetValue();
     85
     86    void SetFunction(void *fun);
     87    void *SetValue(void *value);
     88    void *SetNumber(long num);
     89
    7590#ifdef L_PROFILE
    7691    float time_taken;
    7792#endif
    78     void *value, *function, *name;
     93    void *value, *function;
     94    LispString *name;
    7995    LispSymbol *left, *right; // tree structure
    8096};
     
    107123private:
    108124    LispObject *data[1];
    109 };
    110 
    111 struct LispString : LispObject
    112 {
    113125};
    114126
     
    147159void *lisp_eq(void *n1, void *n2);
    148160void *lisp_equal(void *n1, void *n2);
    149 LispSymbol *find_symbol(char const *name);
    150161long list_length(void *i);
    151162void lprint(void *i);
     
    155166void *eval_user_fun(LispSymbol *sym, void *arg_list);
    156167void *compile(char const *&s);
    157 void *symbol_value(void *symbol);
    158 void *symbol_function(void *symbol);
    159 void *set_symbol_number(void *symbol, long num);
    160 void *set_symbol_value(void *symbol, void *value);
    161 void *symbol_name(void *symbol);
    162168void *assoc(void *item, void *list);
    163169void resize_tmp(int new_size);
    164170void resize_perm(int new_size);
    165 LispSymbol *make_find_symbol(char const *name);
    166171
    167172void push_onto_list(void *object, void *&list);
     
    222227extern void l_obj_print(long number);  // exten lisp function switches on number
    223228
    224 
    225 
    226 #endif
     229// FIXME: get rid of this later
     230static inline void *symbol_value(void *sym) { return ((LispSymbol *)sym)->GetValue(); }
     231
     232
     233
     234#endif
  • abuse/trunk/src/lisp/lisp_gc.cpp

    r483 r484  
    224224    root->value = collect_object(root->value);
    225225    root->function = collect_object(root->function);
    226     root->name = collect_object(root->name);
     226    root->name = (LispString *)collect_object(root->name);
    227227    collect_symbols(root->left);
    228228    collect_symbols(root->right);
  • abuse/trunk/src/lisp/lisp_gc.h

    r483 r484  
    2525  p_ref(LispObject *&ref) { l_ptr_stack.push((void **)&ref); }
    2626  p_ref(LispArray *&ref) { l_ptr_stack.push((void **)&ref); }
     27  p_ref(LispSymbol *&ref) { l_ptr_stack.push((void **)&ref); }
    2728  ~p_ref() { l_ptr_stack.pop(1); }
    2829} ;
  • abuse/trunk/src/lisp/lisp_opt.cpp

    r482 r484  
    9191}
    9292
    93 
    9493void l_comp_init()
    9594{
    96   l_undefined=make_find_symbol(":UNDEFINED");  // this needs to be defined first
    97   ((LispSymbol *)l_undefined)->function=NULL;  // collection problems result if we don't do this
    98   ((LispSymbol *)l_undefined)->value=NULL;
     95    // This needs to be defined first
     96    l_undefined = LispSymbol::FindOrCreate(":UNDEFINED");
    9997
     98    // Collection problems result if we don't do this
     99    ((LispSymbol *)l_undefined)->function = NULL;
     100    ((LispSymbol *)l_undefined)->value = NULL;
    100101
    101   true_symbol=make_find_symbol("T");
     102    true_symbol = LispSymbol::FindOrCreate("T");
    102103
     104    list_symbol = LispSymbol::FindOrCreate("list");
     105    string_symbol = LispSymbol::FindOrCreate("string");
     106    quote_symbol = LispSymbol::FindOrCreate("quote");
     107    backquote_symbol = LispSymbol::FindOrCreate("backquote");
     108    comma_symbol = LispSymbol::FindOrCreate("comma");
     109    in_symbol = LispSymbol::FindOrCreate("in");
     110    do_symbol = LispSymbol::FindOrCreate("do");
     111    aref_symbol = LispSymbol::FindOrCreate("aref");
     112    colon_initial_contents = LispSymbol::FindOrCreate(":initial-contents");
     113    colon_initial_element = LispSymbol::FindOrCreate(":initial-element");
    103114
    104   list_symbol=make_find_symbol("list");
    105   string_symbol=make_find_symbol("string");
    106   quote_symbol=make_find_symbol("quote");
    107   backquote_symbol=make_find_symbol("backquote");
    108   comma_symbol=make_find_symbol("comma");
    109   in_symbol=make_find_symbol("in");
    110   do_symbol=make_find_symbol("do");
    111   aref_symbol=make_find_symbol("aref");
    112   colon_initial_contents=make_find_symbol(":initial-contents");
    113   colon_initial_element=make_find_symbol(":initial-element");
     115    if_1progn = LispSymbol::FindOrCreate("if-1progn");
     116    if_2progn = LispSymbol::FindOrCreate("if-2progn");
     117    if_12progn = LispSymbol::FindOrCreate("if-12progn");
     118    if_symbol = LispSymbol::FindOrCreate("if");
     119    progn_symbol = LispSymbol::FindOrCreate("progn");
     120    not_symbol = LispSymbol::FindOrCreate("not");
     121    eq_symbol = LispSymbol::FindOrCreate("eq");
     122    zero_symbol = LispSymbol::FindOrCreate("0");
     123    eq0_symbol = LispSymbol::FindOrCreate("eq0");
     124    car_symbol = LispSymbol::FindOrCreate("car");
     125    cdr_symbol = LispSymbol::FindOrCreate("cdr");
     126    load_warning = LispSymbol::FindOrCreate("load_warning");
     127}
    114128
    115   if_1progn=make_find_symbol("if-1progn");
    116   if_2progn=make_find_symbol("if-2progn");
    117   if_12progn=make_find_symbol("if-12progn");
    118   if_symbol=make_find_symbol("if");
    119   progn_symbol=make_find_symbol("progn");
    120   not_symbol=make_find_symbol("not");
    121   eq_symbol=make_find_symbol("eq");
    122   zero_symbol=make_find_symbol("0");
    123   eq0_symbol=make_find_symbol("eq0");
    124   car_symbol=make_find_symbol("car");
    125   cdr_symbol=make_find_symbol("cdr");
    126   load_warning=make_find_symbol("load_warning");
    127 }
  • abuse/trunk/src/loader2.cpp

    r481 r484  
    367367
    368368  char const *ff;
    369   if (DEFINEDP(symbol_value(make_find_symbol("frame_file"))))
    370     ff=lstring_value(symbol_value(make_find_symbol("frame_file")));
     369  // FIXME: unnecessary duplicate call
     370  if (DEFINEDP(LispSymbol::FindOrCreate("frame_file")->GetValue()))
     371    ff = lstring_value(LispSymbol::FindOrCreate("frame_file")->GetValue());
    371372  else
    372     ff="art/frame.spe";
     373    ff = "art/frame.spe";
    373374
    374375  ok_button   =      cache.reg(ff,"dev_ok",SPEC_IMAGE);
     
    415416  {
    416417    if (!strcmp(argv[i],"-ec"))
    417       set_symbol_value(l_empty_cache,true_symbol);
     418      l_empty_cache->SetValue(true_symbol);
    418419    if (!strcmp(argv[i],"-t"))
    419420    {
  • abuse/trunk/src/menu.cpp

    r481 r484  
    377377void show_sell(int abortable)
    378378{
    379   void *ss=make_find_symbol("sell_screens");
    380   if (!DEFINEDP(symbol_value(ss)))
     379  LispSymbol *ss = LispSymbol::FindOrCreate("sell_screens");
     380  if (!DEFINEDP(ss->GetValue()))
    381381  {
    382382    int sp=current_space;
     
    385385//    char *prog="((\"art/endgame.spe\" . \"credit\") (\"art/help.spe\" . \"sell6\"))";
    386386    char const *prog="((\"art/endgame.spe\" . \"credit\"))";
    387     set_symbol_value(ss,compile(prog));
     387    ss->SetValue(compile(prog));
    388388    current_space=sp;
    389389  }
    390390
    391   if (DEFINEDP(symbol_value(ss)))
     391  if (DEFINEDP(ss->GetValue()))
    392392  {
    393393    image blank(2,2); blank.clear();
    394394    wm->set_mouse_shape(blank.copy(),0,0);      // don't show mouse
    395395
    396     ss=symbol_value(ss);
     396    LispObject *tmp = (LispObject *)ss->GetValue();
    397397    int quit=0;
    398     while (ss && !quit)
    399     {
    400       int im=cache.reg_object("art/help.spe",CAR(ss),SPEC_IMAGE,1);
     398    while (tmp && !quit)
     399    {
     400      int im=cache.reg_object("art/help.spe",CAR(tmp),SPEC_IMAGE,1);
    401401      fade_in(cache.img(im),16);
    402402
     
    409409        quit=1;
    410410      fade_out(16);
    411       ss=CDR(ss);
     411      tmp = (LispObject *)CDR(tmp);
    412412    }
    413413    wm->set_mouse_shape(cache.img(c_normal)->copy(),1,1);
     
    469469    case ID_MEDIUM :
    470470    {
    471       set_symbol_value(l_difficulty,l_medium);
     471      l_difficulty->SetValue(l_medium);
    472472      save_difficulty();
    473473    } break;
    474474    case ID_HARD :
    475475    {
    476       set_symbol_value(l_difficulty,l_hard);
     476      l_difficulty->SetValue(l_hard);
    477477      save_difficulty();
    478478    } break;
    479479    case ID_EXTREME :
    480480    {
    481       set_symbol_value(l_difficulty,l_extreme);
     481      l_difficulty->SetValue(l_extreme);
    482482      save_difficulty();
    483483    } break;
    484484    case ID_EASY :
    485485    {
    486       set_symbol_value(l_difficulty,l_easy);
     486      l_difficulty->SetValue(l_easy);
    487487      save_difficulty();
    488488    } break;
     
    696696                if (!current_demo)
    697697                {
    698                     void *d=make_find_symbol("demos");
    699                     if (DEFINEDP(symbol_value(d)))
    700                         current_demo=symbol_value(d);
     698                    LispSymbol *d = LispSymbol::FindOrCreate("demos");
     699                    if (DEFINEDP(d->GetValue()))
     700                        current_demo = d->GetValue();
    701701                }
    702702                if (current_demo)
  • abuse/trunk/src/objects.cpp

    r482 r484  
    105105  for (i=0;i<figures[otype]->tiv;i++)
    106106  {
    107     if (!strcmp(lstring_value(symbol_name(figures[otype]->vars[i])),name))
     107    if (!strcmp(lstring_value(((LispSymbol *)figures[otype]->vars[i])->GetName()),name))
    108108    {
    109109      return lvars[figures[otype]->var_index[i]];
     
    135135  }
    136136  for (i=0;i<figures[otype]->tiv;i++)
    137     if (!strcmp(lstring_value(symbol_name(figures[otype]->vars[i])),name))
     137    if (!strcmp(lstring_value(((LispSymbol *)figures[otype]->vars[i])->GetName()),name))
    138138    {
    139139      lvars[figures[otype]->var_index[i]]=value;
  • abuse/trunk/src/particle.cpp

    r482 r484  
    7070  int sp=current_space;
    7171  current_space=PERM_SPACE;
    72   set_symbol_number(sym,total_pseqs);  // set the symbol value to the object number
     72  sym->SetNumber(total_pseqs); // set the symbol value to the object number
    7373  current_space=sp;
    7474  pseqs=(part_sequence **)realloc(pseqs,sizeof(part_sequence *)*(total_pseqs+1));
  • abuse/trunk/src/statbar.cpp

    r481 r484  
    4141  char sbname[100];
    4242  char iname[20];
    43   void *l_name=make_find_symbol("sbar_file");
     43  void *l_name = LispSymbol::FindOrCreate("sbar_file");
    4444  if (symbol_value(l_name)!=l_undefined)
    4545    strcpy(sbname,lstring_value(symbol_value(l_name)));
  • abuse/trunk/src/view.cpp

    r482 r484  
    453453  if (len>38 || key==JK_ENTER)
    454454  {
    455     if (DEFINEDP(symbol_function(l_chat_input)))
     455    if (DEFINEDP(l_chat_input->GetFunction()))
    456456    {
    457457      game_object *o=current_object;
Note: See TracChangeset for help on using the changeset viewer.