PTLib
Version 2.12.9
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
lua.h
Go to the documentation of this file.
1
/*
2
* lua.h
3
*
4
* Interface library for Lua interpreter
5
*
6
* Portable Tools Library
7
*
8
* Copyright (C) 2010 by Post Increment
9
*
10
* The contents of this file are subject to the Mozilla Public License
11
* Version 1.0 (the "License"); you may not use this file except in
12
* compliance with the License. You may obtain a copy of the License at
13
* http://www.mozilla.org/MPL/
14
*
15
* Software distributed under the License is distributed on an "AS IS"
16
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17
* the License for the specific language governing rights and limitations
18
* under the License.
19
*
20
* The Original Code is Portable Tools Library.
21
*
22
* The Initial Developer of the Original Code is Post Increment
23
*
24
* Contributor(s): Craig Southeren
25
* Robert Jongbloed
26
*
27
* $Revision: 28224 $
28
* $Author: rjongbloed $
29
* $Date: 2012-08-21 18:09:25 +1000 (Tue, 21 Aug 2012) $
30
*/
31
32
#ifndef PTLIB_LUA_H
33
#define PTLIB_LUA_H
34
35
#ifdef P_USE_PRAGMA
36
#pragma interface
37
#endif
38
39
#include <ptlib.h>
40
#include <ptbuildopts.h>
41
42
#if P_LUA
43
44
#include <
ptclib/script.h
>
45
#include <
ptclib/vartype.h
>
46
47
48
struct
lua_State;
49
50
52
61
class
PLua :
public
PScriptLanguage
62
{
63
PCLASSINFO
(PLua,
PScriptLanguage
)
64
public:
69
PLua();
70
72
~PLua();
74
79
virtual
bool
LoadFile(
80
const
PFilePath
& filename
81
);
82
85
virtual
bool
LoadText(
86
const
PString
& text
87
);
88
95
virtual
bool
Run(
96
const
char
* script = NULL
97
);
98
104
bool
CreateTable(
105
const
PString
& name,
106
const
PString
& metatable =
PString
::Empty()
107
);
108
114
bool
DeleteTable(
115
const
PString
& name,
116
bool
metaTable = false
117
);
118
119
125
virtual
bool
CreateComposite(
126
const
PString
& name
127
);
128
132
virtual
bool
GetVar(
133
const
PString
& name,
134
PVarType
& var
135
);
136
140
virtual
bool
SetVar(
141
const
PString
& name,
142
const
PVarType
& var
143
);
144
148
bool
GetBoolean(
149
const
PString
& name
150
);
151
155
bool
SetBoolean(
156
const
PString
& name,
157
bool
value
158
);
159
163
int
GetInteger(
164
const
PString
& name
165
);
166
170
bool
SetInteger(
171
const
PString
& name,
172
int
value
173
);
174
178
double
GetNumber(
179
const
PString
& name
180
);
181
185
bool
SetNumber(
186
const
PString
& name,
187
double
value
188
);
189
193
PString
GetString(
194
const
PString
& name
195
);
196
200
bool
SetString(
201
const
PString
& name,
202
const
char
* value
203
);
204
210
virtual
bool
ReleaseVariable(
211
const
PString
& name
212
);
213
240
bool
Call(
241
const
PString
& name,
242
const
char
* sigString = NULL,
243
...
244
);
245
bool
Call(
246
const
PString
& name,
247
Signature & signature
248
);
249
250
251
#define PDECLARE_LuaFunctionNotifier(cls, fn) PDECLARE_NOTIFIER2(PLua, cls, fn, PScriptLanguage::Signature &)
252
256
bool
SetFunction
(
257
const
PString
& name,
258
const
FunctionNotifier & func
259
);
261
262
protected
:
265
virtual
bool
OnLuaError(
int
code,
const
PString
& str =
PString::Empty
(),
int
pop = 0);
266
267
bool
ParseVariableName(
const
PString
& name,
PStringArray
& vars);
268
bool
InternalGetVariable(
const
PString
& name);
269
bool
InternalSetVariable(
const
PString
& name);
270
static
int
InternalCallback(lua_State * state);
271
int
InternalCallback();
272
273
lua_State * m_lua;
274
};
275
276
277
#endif // P_LUA
278
279
#endif // PTLIB_LUA_H
280
include
ptclib
lua.h
Generated on Mon Feb 17 2014 13:12:51 for PTLib by
1.8.3.1