Commit 20bda3d4 authored by Sinus Pi's avatar Sinus Pi
Browse files

Removed string casts.

UseTraceback is now a property.
Whitespace and brace standards and newlines adjusted.
parent 5086d380
...@@ -259,7 +259,7 @@ function luanet.each(o) ...@@ -259,7 +259,7 @@ function luanet.each(o)
end end
end end
"; ";
public bool use_traceback = false; public bool UseTraceback { get; set; } = false;
#region Globals auto-complete #region Globals auto-complete
/// <summary> /// <summary>
...@@ -497,9 +497,9 @@ end ...@@ -497,9 +497,9 @@ end
if (LuaLib.LuaLLoadBuffer(luaState, chunk, chunkName) == 0) if (LuaLib.LuaLLoadBuffer(luaState, chunk, chunkName) == 0)
{ {
int errfunction=0; int errfunction = 0;
if (use_traceback) { if (UseTraceback) {
errfunction=PushDebugTraceback(luaState, 0); errfunction = PushDebugTraceback(luaState, 0);
oldTop++; oldTop++;
} }
...@@ -535,8 +535,7 @@ end ...@@ -535,8 +535,7 @@ end
if (LuaLib.LuaLLoadBuffer(luaState, chunk, chunkName) == 0) if (LuaLib.LuaLLoadBuffer(luaState, chunk, chunkName) == 0)
{ {
int errfunction = 0; int errfunction = 0;
if (use_traceback) if (UseTraceback) {
{
errfunction = PushDebugTraceback(luaState, 0); errfunction = PushDebugTraceback(luaState, 0);
oldTop++; oldTop++;
} }
...@@ -571,8 +570,7 @@ end ...@@ -571,8 +570,7 @@ end
executing = true; executing = true;
int errfunction = 0; int errfunction = 0;
if (use_traceback) if (UseTraceback) {
{
errfunction = PushDebugTraceback(luaState, 0); errfunction = PushDebugTraceback(luaState, 0);
oldTop++; oldTop++;
} }
...@@ -842,8 +840,7 @@ end ...@@ -842,8 +840,7 @@ end
try { try {
int errfunction = 0; int errfunction = 0;
if (use_traceback) if (UseTraceback) {
{
errfunction = PushDebugTraceback(luaState, nArgs); errfunction = PushDebugTraceback(luaState, nArgs);
oldTop++; oldTop++;
} }
......
...@@ -193,7 +193,7 @@ namespace NLua.Method ...@@ -193,7 +193,7 @@ namespace NLua.Method
failedCall = false; failedCall = false;
} catch (TargetInvocationException e) { } catch (TargetInvocationException e) {
// Failure of method invocation // Failure of method invocation
if (_Translator.interpreter.use_traceback) e.GetBaseException().Data["Traceback"] = _Translator.interpreter.GetDebugTraceback() as string; if (_Translator.interpreter.UseTraceback) e.GetBaseException().Data["Traceback"] = _Translator.interpreter.GetDebugTraceback();
return SetPendingException (e.GetBaseException ()); return SetPendingException (e.GetBaseException ());
} catch (Exception e) { } catch (Exception e) {
if (_Members.Length == 1) // Is the method overloaded? if (_Members.Length == 1) // Is the method overloaded?
...@@ -290,7 +290,7 @@ namespace NLua.Method ...@@ -290,7 +290,7 @@ namespace NLua.Method
_Translator.Push (luaState, _LastCalledMethod.cachedMethod.Invoke (targetObject, _LastCalledMethod.args)); _Translator.Push (luaState, _LastCalledMethod.cachedMethod.Invoke (targetObject, _LastCalledMethod.args));
} }
} catch (TargetInvocationException e) { } catch (TargetInvocationException e) {
if (_Translator.interpreter.use_traceback) e.GetBaseException().Data["Traceback"] = _Translator.interpreter.GetDebugTraceback() as string; if (_Translator.interpreter.UseTraceback) e.GetBaseException().Data["Traceback"] = _Translator.interpreter.GetDebugTraceback();
return SetPendingException (e.GetBaseException ()); return SetPendingException (e.GetBaseException ());
} catch (Exception e) { } catch (Exception e) {
return SetPendingException (e); return SetPendingException (e);
......
...@@ -245,14 +245,14 @@ namespace NLua ...@@ -245,14 +245,14 @@ namespace NLua
if (message != null) { if (message != null) {
// Wrap Lua error (just a string) and store the error location // Wrap Lua error (just a string) and store the error location
if (interpreter.use_traceback) message += "\r\n"+interpreter.GetDebugTraceback() as string; if (interpreter.UseTraceback) message += Environment.NewLine + interpreter.GetDebugTraceback();
e = new LuaScriptException (message, errLocation); e = new LuaScriptException (message, errLocation);
} else { } else {
var ex = e as Exception; var ex = e as Exception;
if (ex != null) { if (ex != null) {
// Wrap generic .NET exception as an InnerException and store the error location // Wrap generic .NET exception as an InnerException and store the error location
if (interpreter.use_traceback) ex.Data["Traceback"] = interpreter.GetDebugTraceback() as string; if (interpreter.UseTraceback) ex.Data["Traceback"] = interpreter.GetDebugTraceback();
e = new LuaScriptException (ex, errLocation); e = new LuaScriptException (ex, errLocation);
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment