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

Method Call

Assets/XLua/Src/MethodWarpsCache.cs:178–277  ·  view source on GitHub ↗
(RealStatePtr L)

Source from the content-addressed store, hash-verified

176 }
177
178 public int Call(RealStatePtr L)
179 {
180 try
181 {
182#if UNITY_EDITOR && !DISABLE_OBSOLETE_WARNING
183 if (method.IsDefined(typeof(ObsoleteAttribute), true))
184 {
185 ObsoleteAttribute info = Attribute.GetCustomAttribute(method, typeof(ObsoleteAttribute)) as ObsoleteAttribute;
186 UnityEngine.Debug.LogWarning("Obsolete Method [" + method.DeclaringType.ToString() + "." + method.Name + "]: " + info.Message);
187 }
188#endif
189 object target = null;
190 MethodBase toInvoke = method;
191
192 if (luaStackPosStart > 1)
193 {
194 target = translator.FastGetCSObj(L, 1);
195 if (target is Delegate)
196 {
197 Delegate delegateInvoke = (Delegate)target;
198#if UNITY_WSA && !UNITY_EDITOR
199 toInvoke = delegateInvoke.GetMethodInfo();
200#else
201 toInvoke = delegateInvoke.Method;
202#endif
203 }
204 }
205
206
207 int luaTop = LuaAPI.lua_gettop(L);
208 int luaStackPos = luaStackPosStart;
209
210 for (int i = 0; i < castArray.Length; i++)
211 {
212 //UnityEngine.Debug.Log("inPos:" + inPosArray[i]);
213 if (luaStackPos > luaTop) //after check
214 {
215 if (paramsType != null && i == castArray.Length - 1)
216 {
217 args[inPosArray[i]] = Array.CreateInstance(paramsType, 0);
218 }
219 else
220 {
221 args[inPosArray[i]] = defaultValueArray[i];
222 }
223 }
224 else
225 {
226 if (paramsType != null && i == castArray.Length - 1)
227 {
228 args[inPosArray[i]] = translator.GetParams(L, luaStackPos, paramsType);
229 }
230 else
231 {
232 args[inPosArray[i]] = castArray[i](L, luaStackPos, null);
233 }
234 luaStackPos++;
235 }

Callers

nothing calls this directly

Calls 10

IsDefinedMethod · 0.80
GetCustomAttributeMethod · 0.80
FastGetCSObjMethod · 0.80
lua_gettopMethod · 0.80
GetParamsMethod · 0.80
InvokeMethod · 0.80
IsValueTypeMethod · 0.80
PushAnyMethod · 0.80
ToStringMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected