-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "lualib.h" | ||
#include "lauxlib.h" | ||
|
||
#include "tenum.h" | ||
|
||
Status checkenum (Order o) | ||
{ | ||
if (o == FIRST) | ||
return TRUE; | ||
else | ||
return FALSE; | ||
} | ||
|
||
int main (void) | ||
{ | ||
int errcode = 0; | ||
int tolua_tenum_open (lua_State*); | ||
lua_State* L = luaL_newstate(); | ||
|
||
luaL_openlibs(L); | ||
tolua_tenum_open(L); | ||
|
||
if (luaL_dofile(L,"tenum.lua") != 0) { | ||
fprintf(stderr, "%s", lua_tostring(L,-1)); | ||
errcode = 1; | ||
} | ||
|
||
lua_close(L); | ||
return errcode; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef tenum_h | ||
#define tenum_h | ||
|
||
|
||
typedef enum { | ||
FIRST, | ||
SECOND | ||
} Order; | ||
|
||
typedef enum { | ||
FALSE, | ||
TRUE | ||
} Status; | ||
|
||
Status checkenum (Order o); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
local a = FIRST | ||
local b = SECOND | ||
|
||
assert(checkenum(a)==TRUE) | ||
assert(checkenum(b)==FALSE) | ||
|
||
print("Enum test OK") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
$#include "tenum.h" | ||
|
||
enum Order { | ||
FIRST, | ||
SECOND | ||
}; | ||
|
||
typedef enum { | ||
FALSE, | ||
TRUE | ||
} Status; | ||
|
||
Status checkenum (Order o); |