Skip to content

Commit

Permalink
compute requiredArgs at compile-time
Browse files Browse the repository at this point in the history
  • Loading branch information
aubade committed Jun 2, 2014
1 parent 663add7 commit 4de6685
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions luad/conversions/functions.d
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,11 @@ extern(C) int methodWrapper(T, Class, bool virtual)(lua_State* L)

//Check arguments
int top = lua_gettop(L);
auto requiredArgs = Args.length + 1;

if (variadicFunctionStyle!T == Variadic.typesafe) requiredArgs--;
static if (variadicFunctionStyle!T == Variadic.typesafe)
enum requiredArgs = Args.length;
else
enum requiredArgs = Args.length + 1;

if(top < requiredArgs)
argsError(L, top, requiredArgs);
Expand Down Expand Up @@ -193,8 +195,10 @@ extern(C) int functionWrapper(T)(lua_State* L)
//Check arguments
int top = lua_gettop(L);

auto requiredArgs = Args.length;
if (variadicFunctionStyle!T == Variadic.typesafe) requiredArgs--;
static if (variadicFunctionStyle!T == Variadic.typesafe)
enum requiredArgs = Args.length - 1;
else
enum requiredArgs = Args.length;

if(top < requiredArgs)
argsError(L, top, requiredArgs);
Expand Down

0 comments on commit 4de6685

Please sign in to comment.