*/}}
Преглед на файлове

lua_pcall for drivers for error logging.

YimingWu преди 4 месеца
родител
ревизия
cbbaf9a5ac
променени са 2 файла, в които са добавени 6 реда и са изтрити 4 реда
  1. 1 1
      la_audio.c
  2. 5 3
      la_tns_kernel.c

+ 1 - 1
la_audio.c

@@ -559,7 +559,7 @@ void laInitAudio(){
 
     laInitMiniAudio();
 
-    laRegisterUiTemplate("LA_synthesizers","Synthesizers",laui_Synthersizers,lauidetached_Synthersizers,0,"Audio",0,0,0);
+    laRegisterUiTemplate("LAUI_synthesizers","Synthesizers",laui_Synthersizers,lauidetached_Synthersizers,0,"Audio",0,0,0);
 
     laCreateOperatorType("LA_new_synth", "New Synthesizer", "Add a synthesizer",0,0,0,OPINV_ShedNewSynth,0,'+',0);
     laCreateOperatorType("LA_remove_synth", "Remove Synthesizer", "Remove a synthesizer",OPCHK_IslaSynth,0,0,OPINV_ShedRemoveSynth,OPMOD_FinishOnData,L'🗴',0)

+ 5 - 3
la_tns_kernel.c

@@ -4002,8 +4002,10 @@ void tnsLuaRunNode(lua_State* L, tnsEvaluatedNode* en, char* func, tnsObject* ro
                     if(!(rp->UseScript&&rp->Script&&rp->Script->Ptr)){ continue; }
                     char* debug_name=rp->Name&&rp->Name->Ptr?rp->Name->Ptr:"unamed_driver_page";
                     lua_pushinteger(L,lua_objlen(L,-1)+1);
-                    if(!luaL_loadbuffer(L,rp->Script->Ptr,strlen(rp->Script->Ptr),debug_name)){ lua_call(L,0,1); lua_settable(L,-3); }
-                    else{ lua_pop(L,2); /* pop error and index */ }
+                    if(!luaL_loadbuffer(L,rp->Script->Ptr,strlen(rp->Script->Ptr),debug_name)){
+                        if(lua_pcall(L,0,1,0)){ lua_getglobal(L,"log"); lua_insert(L,-2); if(lua_pcall(L,1,0,0)){ lua_pop(L,1); } }
+                        else{ lua_settable(L,-3); }
+                    }else{ lua_getglobal(L,"log"); lua_insert(L,-2); if(lua_pcall(L,1,0,0)){ lua_pop(L,1); } lua_pop(L,1); /* pop index */ }
                 }
                 root->LuaCacheID=en->LuaID;
             }
@@ -4015,7 +4017,7 @@ void tnsLuaRunNode(lua_State* L, tnsEvaluatedNode* en, char* func, tnsObject* ro
 
     lua_pushnil(L); while(lua_next(L,-2)){
         lua_getfield(L,-1,func); if((!lua_isnil(L,-1))&&lua_isfunction(L,-1)){
-            lua_pushvalue(L,-2); lua_call(L,1,0);
+            lua_pushvalue(L,-2); if(lua_pcall(L,1,0,0)){ lua_getglobal(L,"log"); lua_insert(L,-2); if(lua_pcall(L,1,0,0)){ lua_pop(L,1); } }
         }
         lua_pop(L,1);
     }