-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmongoose.cpp
55 lines (43 loc) · 1.22 KB
/
mongoose.cpp
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
extern "C" {
#include <TH.h>
#include <luaT.h>
}
#include "THpp.hpp"
using namespace std;
using namespace TH;
#include "mongoose.h"
static int InitMongoose(lua_State* L) {
setLuaState(L);
string tty = FromLuaStack<string>(1);
Mongoose* mongoose = new Mongoose(tty);
if (mongoose->file == NULL)
lua_pushnil(L);
else
lua_pushlightuserdata(L, (void*)mongoose);
return 1;
}
static int ReleaseMongoose(lua_State* L) {
setLuaState(L);
Mongoose* mongoose = (Mongoose*)lua_touserdata(L, 1);
delete mongoose;
return 0;
}
//============================================================
// Register functions in LUA
//
#define torch_(NAME) TH_CONCAT_3(torch_, Real, NAME)
#define torch_Tensor TH_CONCAT_STRING_3(torch.,Real,Tensor)
#define libmongoose_(NAME) TH_CONCAT_3(libmongoose_, Real, NAME)
static const luaL_reg libmongoose_init [] = {
{"initMongoose", InitMongoose},
{"releaseMongoose", ReleaseMongoose},
{NULL, NULL}
};
#include "generic/mongoose.cpp"
#include "THGenerateFloatTypes.h"
LUA_EXTERNC DLL_EXPORT int luaopen_libmongoose(lua_State *L) {
luaL_register(L, "libmongoose", libmongoose_init);
libmongoose_FloatMain_init(L);
libmongoose_DoubleMain_init(L);
return 1;
}