-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathtypemaps.i
97 lines (84 loc) · 2.69 KB
/
typemaps.i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* -----------------------------------------------------------------------------
* This is a set of typemaps for wxString <-> Lua String conversion
* Based on the SWIG file std_string.i
* ----------------------------------------------------------------------------- */
%{
#include <wx/string.h>
#include <wx/arrstr.h>
%}
//This allows us to get a filed from a table, returns a bool
%{
bool getfield(lua_State *L, int index, const char *key, bool bldefault){
bool ret = bldefault;
lua_getfield(L, index, key);
if(!lua_isboolean(L, -1)){
lua_pop(L, 1);
return ret;
}
ret = (lua_toboolean(L, -1) != 0);
lua_pop(L, 1);
return ret;
}
%}
%naturalvar wxString;
%naturalvar wxArrayString;
%typemap(in,checkfn="lua_isstring") wxString
%{$1 = wxString(lua_tostring(L,$input), *wxConvCurrent);%}
%typemap(in,checkfn="lua_isstring") const wxString& (wxString temp)
%{temp = wxString(lua_tostring(L,$input), *wxConvCurrent); $1=&temp;%}
%typemap(out) wxString
%{ lua_pushlstring(L,$1.data(),$1.size()); SWIG_arg++;%}
%typemap(out) const wxString&
%{ lua_pushlstring(L,$1->data(),$1->size()); SWIG_arg++;%}
%typemap(in,checkfn="lua_istable") const wxArrayString& (wxArrayString array, int i = 0)
%{
while(1)
{
lua_rawgeti(L,$input,i+1);
if (lua_isnil(L,-1))
{
lua_pop(L,1);
break;
}
//If we find something that is not a string then fail
if (!lua_isstring(L,-1))
{
lua_pop(L,1);
return 0;
}
array.Add(wxString(lua_tostring(L,-1), *wxConvCurrent));
lua_pop(L,1);
++i;
}
$1 = &array;
%}
%typemap(in,checkfn="lua_istable") SyncChecks()
%{
//By default we check size and short byte
$1.Size = getfield(L, $input,"size", $1.Size);
$1.Time = getfield(L, $input, "time", $1.Time);
$1.Short = getfield(L, $input,"short", $1.Short);
$1.Full = getfield(L, $input,"full", $1.Full);
%}
%typemap(in,checkfn="lua_istable") SyncOptions()
%{
$1.TimeStamps = getfield(L, $input,"timestamps", $1.TimeStamps);
$1.Attributes = getfield(L, $input,"attributes", $1.Attributes);
$1.IgnoreRO = getfield(L, $input,"ignorero", $1.IgnoreRO);
$1.Recycle = getfield(L, $input,"recycle", $1.Recycle);
$1.PreviewChanges = getfield(L, $input,"previewchanges", $1.PreviewChanges);
$1.NoSkipped = getfield(L, $input,"noskipped", $1.NoSkipped);
%}
%typemap(in,checkfn="lua_istable") BackupOptions()
%{
$1.Password = getfield(L, $input,"password", $1.Password);
$1.Test = getfield(L, $input,"test", $1.Test);
$1.Solid = getfield(L, $input, "solid", $1.Solid);
%}
// and the typechecks
%typecheck(SWIG_TYPECHECK_STRING) wxString,const wxString& {
$1 = lua_isstring(L,$input);
}
%typecheck(SWIG_TYPECHECK_STRING_ARRAY) const wxArrayString&, SyncChecks, SyncOptions, BackupOptions {
$1 = lua_istable(L,$input);
}