Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.78 KB | None | 0 0
  1. class CLuaAuto : public lua::Interface
  2. {
  3. public:
  4.     void Initialize(lua::Interface* pLuaInterface)
  5.     {
  6.         assert(pLuaInterface && "NULL Lua Interface");
  7.  
  8.         self = pLuaInterface;
  9.     }
  10.  
  11.     void GetField(int iStackPos, const char* strName)
  12.     {
  13.         assert(self && "NULL Lua Interface");
  14.  
  15.         typedef void(__thiscall * PushNilFn)(Interface*, int, const char*);
  16.         method<PushNilFn>(4, self)(self, iStackPos, strName);
  17.  
  18.         m_LuaStack++;
  19.     }
  20.  
  21.     void PushNil()
  22.     {
  23.         assert(self && "NULL Lua Interface");
  24.  
  25.         typedef void(__thiscall * PushNilFn)(Interface*);
  26.         method<PushNilFn>(28, self)(self);
  27.  
  28.         m_LuaStack++;
  29.     }
  30.  
  31.     void PushString(const char* val, unsigned int iLen = 0)
  32.     {
  33.         assert(self && "NULL Lua Interface");
  34.  
  35.         typedef void(__thiscall * PushStringFn)(Interface*, const char*, unsigned int);
  36.         method<PushStringFn>(29, self)(self, val, iLen);
  37.  
  38.         m_LuaStack++;
  39.     }
  40.  
  41.     void PushNumber(double val)
  42.     {
  43.         assert(self && "NULL Lua Interface");
  44.  
  45.         typedef void(__thiscall * PushNumberFn)(Interface*, double);
  46.         method<PushNumberFn>(30, self)(self, val);
  47.  
  48.         m_LuaStack++;
  49.     }
  50.  
  51.     void PushBool(bool val)
  52.     {
  53.         assert(self && "NULL Lua Interface");
  54.  
  55.         typedef void(__thiscall * PushBoolFn)(Interface*, bool);
  56.         method<PushBoolFn>(31, self)(self, val);
  57.  
  58.         m_LuaStack++;
  59.     }
  60.  
  61.     void PushCFunction()
  62.     {
  63.         assert(self && "NULL Lua Interface");
  64.  
  65.         typedef void(__thiscall * PushBoolFn)(Interface*);
  66.         method<PushBoolFn>(32, self)(self);
  67.  
  68.         m_LuaStack++;
  69.     }
  70.  
  71.     void PushCClosure()
  72.     {
  73.         assert(self && "NULL Lua Interface");
  74.  
  75.         typedef void(__thiscall * PushBoolFn)(Interface*);
  76.         method<PushBoolFn>(33, self)(self);
  77.  
  78.         m_LuaStack++;
  79.     }
  80.  
  81.     void PushUserdata(void* data)
  82.     {
  83.         assert(self && "NULL Lua Interface");
  84.  
  85.         typedef void(__thiscall * PushBoolFn)(Interface*, void*);
  86.         method<PushBoolFn>(34, self)(self, data);
  87.  
  88.         m_LuaStack++;
  89.     }
  90.  
  91.     void PushSpecial(lua::special iType)
  92.     {
  93.         assert(self && "NULL Lua Interface");
  94.  
  95.         typedef void(__thiscall * PushBoolFn)(Interface*, lua::special);
  96.         method<PushBoolFn>(38, self)(self, iType);
  97.  
  98.         m_LuaStack++;
  99.     }
  100.  
  101.     void PushAngle(const Vector& angle)
  102.     {
  103.         assert(self && "NULL Lua Interface");
  104.  
  105.         typedef void(__thiscall * PushAngleFn)(Interface*, const Vector&);
  106.         method<PushAngleFn>(48, self)(self, angle);
  107.  
  108.         m_LuaStack++;
  109.     }
  110.  
  111.     void PushVector(const Vector& vec)
  112.     {
  113.         assert(self && "NULL Lua Interface");
  114.  
  115.         typedef void(__thiscall * PushVectorFn)(Interface*, const Vector&);
  116.         method<PushVectorFn>(49, self)(self, vec);
  117.  
  118.         m_LuaStack++;
  119.     }
  120.  
  121.     void PopStack(int iAmt = 1, bool bPopLocal = true)
  122.     {
  123.         self->Pop(iAmt);
  124.  
  125.         if (bPopLocal) {
  126.             assert(m_LuaStack <= 0 && "Nothing to Pop");
  127.             m_LuaStack--;
  128.         }
  129.     }
  130.  
  131.     void AutoPop()
  132.     {
  133.         PopStack(m_LuaStack);
  134.     }
  135. private:
  136.     lua::Interface* self;
  137.  
  138.     int m_LuaStack;
  139. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement