More magic
authorunc0rr
Sun, 13 May 2012 00:50:45 +0400
changeset 7072 159616c24bb8
parent 7071 c431a4a8ab0f
child 7073 26f960656cc9
More magic
hedgewars/pas2c.h
hedgewars/uScript.pas
tools/pas2c.hs
--- a/hedgewars/pas2c.h	Sat May 12 16:45:06 2012 -0400
+++ b/hedgewars/pas2c.h	Sun May 13 00:50:45 2012 +0400
@@ -26,6 +26,8 @@
         char s[16];
     } string15;
 
+typedef string255 shortstring;
+    
 typedef uint8_t Byte;
 typedef int8_t ShortInt;
 typedef uint16_t Word;
--- a/hedgewars/uScript.pas	Sat May 12 16:45:06 2012 -0400
+++ b/hedgewars/uScript.pas	Sun May 13 00:50:45 2012 +0400
@@ -2055,7 +2055,7 @@
 // import some variables
 ScriptSetInteger('LAND_WIDTH', LAND_WIDTH);
 ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT);
-ScriptSetString('L', cLocale);
+ScriptSetString(_S'L', cLocale);
 
 // import game flags
 ScriptSetInteger('gfForts', gfForts);
@@ -2149,90 +2149,90 @@
 ScriptSetInteger('gstInvisible'      ,$00200000);
 
 // register functions
-lua_register(luaState, 'band', @lc_band);
-lua_register(luaState, 'bor', @lc_bor);
-lua_register(luaState, 'bnot', @lc_bnot);
-lua_register(luaState, 'div', @lc_div);
-lua_register(luaState, 'GetInputMask', @lc_getinputmask);
-lua_register(luaState, 'SetInputMask', @lc_setinputmask);
-lua_register(luaState, 'AddGear', @lc_addgear);
-lua_register(luaState, 'DeleteGear', @lc_deletegear);
-lua_register(luaState, 'AddVisualGear', @lc_addvisualgear);
-lua_register(luaState, 'DeleteVisualGear', @lc_deletevisualgear);
-lua_register(luaState, 'GetVisualGearValues', @lc_getvisualgearvalues);
-lua_register(luaState, 'SetVisualGearValues', @lc_setvisualgearvalues);
-lua_register(luaState, 'SpawnHealthCrate', @lc_spawnhealthcrate);
-lua_register(luaState, 'SpawnAmmoCrate', @lc_spawnammocrate);
-lua_register(luaState, 'SpawnUtilityCrate', @lc_spawnutilitycrate);
-lua_register(luaState, 'SpawnFakeHealthCrate', @lc_spawnfakehealthcrate);
-lua_register(luaState, 'SpawnFakeAmmoCrate', @lc_spawnfakeammocrate);
-lua_register(luaState, 'SpawnFakeUtilityCrate', @lc_spawnfakeutilitycrate);
-lua_register(luaState, 'WriteLnToConsole', @lc_writelntoconsole);
-lua_register(luaState, 'GetGearType', @lc_getgeartype);
-lua_register(luaState, 'EndGame', @lc_endgame);
-lua_register(luaState, 'FindPlace', @lc_findplace);
-lua_register(luaState, 'SetGearPosition', @lc_setgearposition);
-lua_register(luaState, 'GetGearPosition', @lc_getgearposition);
-lua_register(luaState, 'SetGearTarget', @lc_setgeartarget);
-lua_register(luaState, 'GetGearTarget', @lc_getgeartarget);
-lua_register(luaState, 'SetGearVelocity', @lc_setgearvelocity);
-lua_register(luaState, 'GetGearVelocity', @lc_getgearvelocity);
-lua_register(luaState, 'ParseCommand', @lc_parsecommand);
-lua_register(luaState, 'ShowMission', @lc_showmission);
-lua_register(luaState, 'HideMission', @lc_hidemission);
-lua_register(luaState, 'AddCaption', @lc_addcaption);
-lua_register(luaState, 'SetAmmo', @lc_setammo);
-lua_register(luaState, 'SetAmmoStore', @lc_setammostore);
-lua_register(luaState, 'PlaySound', @lc_playsound);
-lua_register(luaState, 'AddTeam', @lc_addteam);
-lua_register(luaState, 'AddHog', @lc_addhog);
-lua_register(luaState, 'AddAmmo', @lc_addammo);
-lua_register(luaState, 'GetAmmoCount', @lc_getammocount);
-lua_register(luaState, 'SetHealth', @lc_sethealth);
-lua_register(luaState, 'GetHealth', @lc_gethealth);
-lua_register(luaState, 'SetEffect', @lc_seteffect);
-lua_register(luaState, 'GetEffect', @lc_geteffect);
-lua_register(luaState, 'GetHogClan', @lc_gethogclan);
-lua_register(luaState, 'GetClanColor', @lc_getclancolor);
-lua_register(luaState, 'SetClanColor', @lc_setclancolor);
-lua_register(luaState, 'GetHogTeamName', @lc_gethogteamname);
-lua_register(luaState, 'GetHogName', @lc_gethogname);
-lua_register(luaState, 'SetHogName', @lc_sethogname);
-lua_register(luaState, 'GetHogLevel', @lc_gethoglevel);
-lua_register(luaState, 'SetHogLevel', @lc_sethoglevel);
-lua_register(luaState, 'GetX', @lc_getx);
-lua_register(luaState, 'GetY', @lc_gety);
-lua_register(luaState, 'CopyPV', @lc_copypv);
-lua_register(luaState, 'FollowGear', @lc_followgear);
-lua_register(luaState, 'GetFollowGear', @lc_getfollowgear);
-lua_register(luaState, 'SetState', @lc_setstate);
-lua_register(luaState, 'GetState', @lc_getstate);
-lua_register(luaState, 'SetTag', @lc_settag);
-lua_register(luaState, 'SetTimer', @lc_settimer);
-lua_register(luaState, 'GetTimer', @lc_gettimer);
-lua_register(luaState, 'SetZoom', @lc_setzoom);
-lua_register(luaState, 'GetZoom', @lc_getzoom);
-lua_register(luaState, 'HogSay', @lc_hogsay);
-lua_register(luaState, 'SwitchHog', @lc_switchhog);
-lua_register(luaState, 'HogTurnLeft', @lc_hogturnleft);
-lua_register(luaState, 'CampaignLock', @lc_campaignlock);
-lua_register(luaState, 'CampaignUnlock', @lc_campaignunlock);
-lua_register(luaState, 'GetGearElasticity', @lc_getgearelasticity);
-lua_register(luaState, 'GetGearRadius', @lc_getgearradius);
-lua_register(luaState, 'GetGearMessage', @lc_getgearmessage);
-lua_register(luaState, 'SetGearMessage', @lc_setgearmessage);
-lua_register(luaState, 'GetGearPos', @lc_getgearpos);
-lua_register(luaState, 'SetGearPos', @lc_setgearpos);
-lua_register(luaState, 'GetRandom', @lc_getrandom);
-lua_register(luaState, 'SetWind', @lc_setwind);
-lua_register(luaState, 'GetDataPath', @lc_getdatapath);
-lua_register(luaState, 'GetUserDataPath', @lc_getuserdatapath);
-lua_register(luaState, 'MapHasBorder', @lc_maphasborder);
-lua_register(luaState, 'GetHogHat', @lc_gethoghat);
-lua_register(luaState, 'SetHogHat', @lc_sethoghat);
-lua_register(luaState, 'PlaceGirder', @lc_placegirder);
-lua_register(luaState, 'GetCurAmmoType', @lc_getcurammotype);
-lua_register(luaState, 'TestRectForObstacle', @lc_testrectforobstacle);
+lua_register(luaState, _P'band', @lc_band);
+lua_register(luaState, _P'bor', @lc_bor);
+lua_register(luaState, _P'bnot', @lc_bnot);
+lua_register(luaState, _P'div', @lc_div);
+lua_register(luaState, _P'GetInputMask', @lc_getinputmask);
+lua_register(luaState, _P'SetInputMask', @lc_setinputmask);
+lua_register(luaState, _P'AddGear', @lc_addgear);
+lua_register(luaState, _P'DeleteGear', @lc_deletegear);
+lua_register(luaState, _P'AddVisualGear', @lc_addvisualgear);
+lua_register(luaState, _P'DeleteVisualGear', @lc_deletevisualgear);
+lua_register(luaState, _P'GetVisualGearValues', @lc_getvisualgearvalues);
+lua_register(luaState, _P'SetVisualGearValues', @lc_setvisualgearvalues);
+lua_register(luaState, _P'SpawnHealthCrate', @lc_spawnhealthcrate);
+lua_register(luaState, _P'SpawnAmmoCrate', @lc_spawnammocrate);
+lua_register(luaState, _P'SpawnUtilityCrate', @lc_spawnutilitycrate);
+lua_register(luaState, _P'SpawnFakeHealthCrate', @lc_spawnfakehealthcrate);
+lua_register(luaState, _P'SpawnFakeAmmoCrate', @lc_spawnfakeammocrate);
+lua_register(luaState, _P'SpawnFakeUtilityCrate', @lc_spawnfakeutilitycrate);
+lua_register(luaState, _P'WriteLnToConsole', @lc_writelntoconsole);
+lua_register(luaState, _P'GetGearType', @lc_getgeartype);
+lua_register(luaState, _P'EndGame', @lc_endgame);
+lua_register(luaState, _P'FindPlace', @lc_findplace);
+lua_register(luaState, _P'SetGearPosition', @lc_setgearposition);
+lua_register(luaState, _P'GetGearPosition', @lc_getgearposition);
+lua_register(luaState, _P'SetGearTarget', @lc_setgeartarget);
+lua_register(luaState, _P'GetGearTarget', @lc_getgeartarget);
+lua_register(luaState, _P'SetGearVelocity', @lc_setgearvelocity);
+lua_register(luaState, _P'GetGearVelocity', @lc_getgearvelocity);
+lua_register(luaState, _P'ParseCommand', @lc_parsecommand);
+lua_register(luaState, _P'ShowMission', @lc_showmission);
+lua_register(luaState, _P'HideMission', @lc_hidemission);
+lua_register(luaState, _P'AddCaption', @lc_addcaption);
+lua_register(luaState, _P'SetAmmo', @lc_setammo);
+lua_register(luaState, _P'SetAmmoStore', @lc_setammostore);
+lua_register(luaState, _P'PlaySound', @lc_playsound);
+lua_register(luaState, _P'AddTeam', @lc_addteam);
+lua_register(luaState, _P'AddHog', @lc_addhog);
+lua_register(luaState, _P'AddAmmo', @lc_addammo);
+lua_register(luaState, _P'GetAmmoCount', @lc_getammocount);
+lua_register(luaState, _P'SetHealth', @lc_sethealth);
+lua_register(luaState, _P'GetHealth', @lc_gethealth);
+lua_register(luaState, _P'SetEffect', @lc_seteffect);
+lua_register(luaState, _P'GetEffect', @lc_geteffect);
+lua_register(luaState, _P'GetHogClan', @lc_gethogclan);
+lua_register(luaState, _P'GetClanColor', @lc_getclancolor);
+lua_register(luaState, _P'SetClanColor', @lc_setclancolor);
+lua_register(luaState, _P'GetHogTeamName', @lc_gethogteamname);
+lua_register(luaState, _P'GetHogName', @lc_gethogname);
+lua_register(luaState, _P'SetHogName', @lc_sethogname);
+lua_register(luaState, _P'GetHogLevel', @lc_gethoglevel);
+lua_register(luaState, _P'SetHogLevel', @lc_sethoglevel);
+lua_register(luaState, _P'GetX', @lc_getx);
+lua_register(luaState, _P'GetY', @lc_gety);
+lua_register(luaState, _P'CopyPV', @lc_copypv);
+lua_register(luaState, _P'FollowGear', @lc_followgear);
+lua_register(luaState, _P'GetFollowGear', @lc_getfollowgear);
+lua_register(luaState, _P'SetState', @lc_setstate);
+lua_register(luaState, _P'GetState', @lc_getstate);
+lua_register(luaState, _P'SetTag', @lc_settag);
+lua_register(luaState, _P'SetTimer', @lc_settimer);
+lua_register(luaState, _P'GetTimer', @lc_gettimer);
+lua_register(luaState, _P'SetZoom', @lc_setzoom);
+lua_register(luaState, _P'GetZoom', @lc_getzoom);
+lua_register(luaState, _P'HogSay', @lc_hogsay);
+lua_register(luaState, _P'SwitchHog', @lc_switchhog);
+lua_register(luaState, _P'HogTurnLeft', @lc_hogturnleft);
+lua_register(luaState, _P'CampaignLock', @lc_campaignlock);
+lua_register(luaState, _P'CampaignUnlock', @lc_campaignunlock);
+lua_register(luaState, _P'GetGearElasticity', @lc_getgearelasticity);
+lua_register(luaState, _P'GetGearRadius', @lc_getgearradius);
+lua_register(luaState, _P'GetGearMessage', @lc_getgearmessage);
+lua_register(luaState, _P'SetGearMessage', @lc_setgearmessage);
+lua_register(luaState, _P'GetGearPos', @lc_getgearpos);
+lua_register(luaState, _P'SetGearPos', @lc_setgearpos);
+lua_register(luaState, _P'GetRandom', @lc_getrandom);
+lua_register(luaState, _P'SetWind', @lc_setwind);
+lua_register(luaState, _P'GetDataPath', @lc_getdatapath);
+lua_register(luaState, _P'GetUserDataPath', @lc_getuserdatapath);
+lua_register(luaState, _P'MapHasBorder', @lc_maphasborder);
+lua_register(luaState, _P'GetHogHat', @lc_gethoghat);
+lua_register(luaState, _P'SetHogHat', @lc_sethoghat);
+lua_register(luaState, _P'PlaceGirder', @lc_placegirder);
+lua_register(luaState, _P'GetCurAmmoType', @lc_getcurammotype);
+lua_register(luaState, _P'TestRectForObstacle', @lc_testrectforobstacle);
 
 
 ScriptClearStack; // just to be sure stack is empty
--- a/tools/pas2c.hs	Sat May 12 16:45:06 2012 -0400
+++ b/tools/pas2c.hs	Sun May 13 00:50:45 2012 +0400
@@ -731,6 +731,7 @@
         escape '\'' = "\\\'"
         escape a = [a]-}
 expr2C (StringLiteral s) = addStringConst s
+expr2C (PCharLiteral s) = return . doubleQuotes $ text s
 expr2C (Reference ref) = ref2CF ref
 expr2C (PrefixOp op expr) = do
     e <- expr2C expr