public static int CEPluginInitialize(string parameters) { if (mainself == null) { mainself = new CESDK(); } if ((Int64)PluginNamePtr == 0) { Type[] x = typeof(CESDKPluginClass).Assembly.GetTypes(); int i; for (i = 0; i < x.Count(); i++) { if (x[i].IsSubclassOf(typeof(CESDKPluginClass))) { currentPlugin = (CESDKPluginClass)Activator.CreateInstance(x[i]); break; } } if (currentPlugin == null) { return(0); } PluginNamePtr = Marshal.StringToHGlobalAnsi(currentPlugin.GetPluginName()); } UInt64 a = UInt64.Parse(parameters); TPluginInit bla; bla.name = PluginNamePtr; bla.GetVersion = Marshal.GetFunctionPointerForDelegate(mainself.delGetVersion); bla.EnablePlugin = Marshal.GetFunctionPointerForDelegate(mainself.delEnablePlugin); bla.DisablePlugin = Marshal.GetFunctionPointerForDelegate(mainself.delDisablePlugin); bla.version = PLUGINVERSION; Marshal.StructureToPtr <TPluginInit>(bla, (IntPtr)a, false); return(1); }
public CESDKLua(CESDK sdk) { //init lua IntPtr hLibLua = LoadLibraryA("lua53-32.dll"); if (hLibLua == IntPtr.Zero) { hLibLua = LoadLibraryA("lua53-64.dll"); } if (hLibLua != IntPtr.Zero) { //load the most commonly used functions lua_gettop = Marshal.GetDelegateForFunctionPointer <dlua_gettop>(GetProcAddress(hLibLua, "lua_gettop")); lua_settop = Marshal.GetDelegateForFunctionPointer <dlua_settop>(GetProcAddress(hLibLua, "lua_settop")); lua_pushvalue = Marshal.GetDelegateForFunctionPointer <dlua_pushvalue>(GetProcAddress(hLibLua, "lua_pushvalue")); lua_rotate = Marshal.GetDelegateForFunctionPointer <dlua_rotate>(GetProcAddress(hLibLua, "lua_rotate")); lua_copy = Marshal.GetDelegateForFunctionPointer <dlua_copy>(GetProcAddress(hLibLua, "lua_copy")); lua_pushcclosure = Marshal.GetDelegateForFunctionPointer <dlua_pushcclosure>(GetProcAddress(hLibLua, "lua_pushcclosure")); lua_setglobal = Marshal.GetDelegateForFunctionPointer <dlua_setglobal>(GetProcAddress(hLibLua, "lua_setglobal")); lua_getglobal = Marshal.GetDelegateForFunctionPointer <dlua_getglobal>(GetProcAddress(hLibLua, "lua_getglobal")); lua_pushnil = Marshal.GetDelegateForFunctionPointer <dlua_pushnil>(GetProcAddress(hLibLua, "lua_pushnil")); lua_pushinteger = Marshal.GetDelegateForFunctionPointer <dlua_pushinteger>(GetProcAddress(hLibLua, "lua_pushinteger")); lua_pushnumber = Marshal.GetDelegateForFunctionPointer <dlua_pushnumber>(GetProcAddress(hLibLua, "lua_pushnumber")); lua_pushlstring = Marshal.GetDelegateForFunctionPointer <dlua_pushlstring>(GetProcAddress(hLibLua, "lua_pushlstring")); lua_pushstring = Marshal.GetDelegateForFunctionPointer <dlua_pushstring>(GetProcAddress(hLibLua, "lua_pushstring")); lua_pushboolean = Marshal.GetDelegateForFunctionPointer <dlua_pushboolean>(GetProcAddress(hLibLua, "lua_pushboolean")); lua_type = Marshal.GetDelegateForFunctionPointer <dlua_type>(GetProcAddress(hLibLua, "lua_type")); lua_isnumber = Marshal.GetDelegateForFunctionPointer <dlua_isnumber>(GetProcAddress(hLibLua, "lua_isnumber")); lua_isinteger = Marshal.GetDelegateForFunctionPointer <dlua_isinteger>(GetProcAddress(hLibLua, "lua_isinteger")); lua_isstring = Marshal.GetDelegateForFunctionPointer <dlua_isstring>(GetProcAddress(hLibLua, "lua_isstring")); lua_iscfunction = Marshal.GetDelegateForFunctionPointer <dlua_iscfunction>(GetProcAddress(hLibLua, "lua_iscfunction")); lua_isuserdata = Marshal.GetDelegateForFunctionPointer <dlua_isuserdata>(GetProcAddress(hLibLua, "lua_isuserdata")); lua_tonumberx = Marshal.GetDelegateForFunctionPointer <dlua_tonumberx>(GetProcAddress(hLibLua, "lua_tonumberx")); lua_tointegerx = Marshal.GetDelegateForFunctionPointer <dlua_tointegerx>(GetProcAddress(hLibLua, "lua_tointegerx")); lua_toboolean = Marshal.GetDelegateForFunctionPointer <dlua_toboolean>(GetProcAddress(hLibLua, "lua_toboolean")); lua_tolstring = Marshal.GetDelegateForFunctionPointer <dlua_tolstring>(GetProcAddress(hLibLua, "lua_tolstring")); lua_touserdata = Marshal.GetDelegateForFunctionPointer <dlua_touserdata>(GetProcAddress(hLibLua, "lua_touserdata")); lua_rawlen = Marshal.GetDelegateForFunctionPointer <dlua_rawlen>(GetProcAddress(hLibLua, "lua_rawlen")); lua_gettable = Marshal.GetDelegateForFunctionPointer <dlua_gettable>(GetProcAddress(hLibLua, "lua_gettable")); lua_settable = Marshal.GetDelegateForFunctionPointer <dlua_settable>(GetProcAddress(hLibLua, "lua_settable")); lua_callk = Marshal.GetDelegateForFunctionPointer <dlua_callk>(GetProcAddress(hLibLua, "lua_callk")); lua_pcallk = Marshal.GetDelegateForFunctionPointer <dlua_pcallk>(GetProcAddress(hLibLua, "lua_pcallk")); luaL_loadstring = Marshal.GetDelegateForFunctionPointer <dluaL_loadstring>(GetProcAddress(hLibLua, "luaL_loadstring")); } LuaRegister = Marshal.GetDelegateForFunctionPointer <dLuaRegister>(sdk.pluginexports.LuaRegister); LuaPushClassInstance = Marshal.GetDelegateForFunctionPointer <dLuaPushClassInstance>(sdk.pluginexports.LuaPushClassInstance); this.sdk = sdk; }