MCPcopy Create free account
hub / github.com/Tencent/xLua / LoadFromCustomLoaders

Function LoadFromCustomLoaders

Assets/XLua/Src/StaticLuaCallbacks.cs:774–805  ·  view source on GitHub ↗
(RealStatePtr L)

Source from the content-addressed store, hash-verified

772#endif
773
774 [MonoPInvokeCallback(typeof(LuaCSFunction))]
775 internal static int LoadFromCustomLoaders(RealStatePtr L)
776 {
777 try
778 {
779 string filename = LuaAPI.lua_tostring(L, 1);
780
781 LuaEnv self = ObjectTranslatorPool.Instance.Find(L).luaEnv;
782
783 foreach (var loader in self.customLoaders)
784 {
785 string real_file_path = filename;
786 byte[] bytes = loader(ref real_file_path);
787 if (bytes != null)
788 {
789 if (LuaAPI.xluaL_loadbuffer(L, bytes, bytes.Length, "@" + real_file_path) != 0)
790 {
791 return LuaAPI.luaL_error(L, String.Format("error loading module {0} from CustomLoader, {1}",
792 LuaAPI.lua_tostring(L, 1), LuaAPI.lua_tostring(L, -1)));
793 }
794 return 1;
795 }
796 }
797 LuaAPI.lua_pushstring(L, string.Format(
798 "\n\tno such file '{0}' in CustomLoaders!", filename));
799 return 1;
800 }
801 catch (System.Exception e)
802 {
803 return LuaAPI.luaL_error(L, "c# exception in LoadFromCustomLoaders:" + e);
804 }
805 }
806
807 [MonoPInvokeCallback(typeof(LuaCSFunction))]
808 public static int LoadAssembly(RealStatePtr L)

Callers

nothing calls this directly

Calls 5

lua_tostringMethod · 0.80
FindMethod · 0.80
xluaL_loadbufferMethod · 0.80
luaL_errorMethod · 0.80
lua_pushstringMethod · 0.80

Tested by

no test coverage detected