Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not HEADER then http.Get("http://oohh.googlecode.com/svn/trunk/source/oohh/game_sdk/CryEngine/CryAction/IEffectSystem.h", "", function(str) HEADER = str end) end
- local trans =
- {
- ["CWeapon"] = "ToEntity<CWeapon>",
- ["bool"] = "ToBool",
- ["const char*"] = "ToString",
- ["float"] = "ToNumber<float>",
- ["int"] = "ToNumber<int>",
- }
- function translate(type)
- return trans[type] or (type:find("*", nil, true) and ("ToEntity<" .. type:gsub("*","") .. ">"))
- end
- function DefineToBind(type, content)
- local defines = {}
- for key, value in pairs(content:Split(";")) do
- if #value > 5 and value:find("%a+%(.+%)") and not value:find("{", nil, true) and not value:find("//", nil, true) then
- table.insert(defines, value:Trim())
- end
- end
- local funcs = {}
- for key, line in pairs(defines) do
- local retrn, func, args = line:match("virtual%s*([%a_]-*?)%s+(.-)%((.+)%)")
- if retrn and func and args then
- args = args:Split(",")
- for k,v in pairs(args) do
- args[k] = v:match("(.-)%a+$"):Trim():gsub("%s?%*%s?", "*")
- end
- funcs[func] = {retrn = retrn, args = args}
- end
- end
- local cpp = ""
- for func, data in pairs(funcs) do
- local str = ""
- str = str .. "LUAMTA_FUNCTION(" .. type .. ", " .. func .. ")\n"
- str = str .. "{\n"
- str = str .. "\toh->"
- if data.retrn == "void" then
- local trans = translate(type)
- if not trans then continue end
- str = str .. trans .. "(1)->" .. func .. "("
- else
- local trans = translate(type)
- if not trans then continue end
- str = str .. "Push(" .. "oh->" .. trans .. "(1)->" .. func .. "("
- end
- local failed = false
- for index, arg_type in pairs(data.args) do
- index = index + 1
- local trans = translate(arg_type)
- if not trans then failed = true break end
- str = str .. "oh->" .. trans .. "(" .. index .. ")"
- if index-1 ~= #data.args then
- str = str .. ", "
- end
- end
- if failed then continue end
- if data.retrn == "void" then
- str = str .. ");\n\n"
- str = str .. "\treturn 0;\n"
- else
- str = str .. "));\n\n"
- str = str .. "\treturn 1;\n"
- end
- str = str .. "}\n\n"
- cpp = cpp .. str
- end
- PrintTable(defines)
- print(cpp)
- end
- DefineToBind("CWeapon", HEADER)
- --[[
- [1] = "virtual bool Update(float delta) = 0",
- [2] = "virtual bool Deactivating(float delta) = 0",
- [3] = "virtual void GetMemoryStatistics(ICrySizer * s) = 0",
- [4] = "virtual void SetFlags(int flags) = 0",
- [5] = "virtual bool SetParticleEffect(const char* name) = 0",
- [6] = "virtual void Update(float delta) = 0",
- [7] = "virtual void GetMemoryStatistics(ICrySizer * s) = 0",
- [8] = "virtual EffectId GetEffectId(const char* name) = 0",
- [9] = "virtual void Activate(const EffectId& eid) = 0",
- [10] = "virtual bool BindEffect(const char* name, IEffect* pEffect) = 0",
- [11] = "virtual IGroundEffect* CreateGroundEffect(IEntity* pEntity) = 0",
- [12] = "DECLARE_GAMEOBJECT_FACTORY(IEffect)",
- LUAMTA_FUNCTION(CWeapon, SetParticleEffect)
- {
- oh->Push(oh->ToEntity<CWeapon>(1)->SetParticleEffect(oh->ToString(2)));
- return 1;
- }
- LUAMTA_FUNCTION(CWeapon, Update)
- {
- oh->ToEntity<CWeapon>(1)->Update(oh->ToNumber<float>(2));
- return 0;
- }
- LUAMTA_FUNCTION(CWeapon, CreateGroundEffect)
- {
- oh->Push(oh->ToEntity<CWeapon>(1)->CreateGroundEffect(oh->ToEntity<IEntity>(2)));
- return 1;
- }
- LUAMTA_FUNCTION(CWeapon, BindEffect)
- {
- oh->Push(oh->ToEntity<CWeapon>(1)->BindEffect(oh->ToString(2), oh->ToEntity<IEffect>(3)));
- return 1;
- }
- LUAMTA_FUNCTION(CWeapon, GetEffectId)
- {
- oh->Push(oh->ToEntity<CWeapon>(1)->GetEffectId(oh->ToString(2)));
- return 1;
- }
- LUAMTA_FUNCTION(CWeapon, SetFlags)
- {
- oh->ToEntity<CWeapon>(1)->SetFlags(oh->ToNumber<int>(2));
- return 0;
- }
- LUAMTA_FUNCTION(CWeapon, Deactivating)
- {
- oh->Push(oh->ToEntity<CWeapon>(1)->Deactivating(oh->ToNumber<float>(2)));
- return 1;
- }
- LUAMTA_FUNCTION(CWeapon, GetMemoryStatistics)
- {
- oh->ToEntity<CWeapon>(1)->GetMemoryStatistics(oh->ToEntity<ICrySizer>(2));
- return 0;
- }
- ]]
Advertisement
Add Comment
Please, Sign In to add comment