aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/libraries/Runnr.h
blob: ba5c17e7f6aeb375f9a893e013fb397d12c7d86e (plain)
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
#ifndef _RUNNR_H_
#define _RUNNR_H_

#include <ctype.h>

#include <Eina.h>
#include <Ecore.h>
#include <Ecore_Con.h>

#include <lua.h>
#include <luajit.h>
#include <lualib.h>
#include <lauxlib.h>

// Stick with Plan C for now.
#define  THREADIT   0

typedef enum
{
  RUNNR_COMPILING,
  RUNNR_NOT_STARTED,
  RUNNR_RUNNING,
  RUNNR_WAIT,
  RUNNR_READY,
  RUNNR_RESET,
  RUNNR_FINISHED
} runnrStatus;

typedef struct _LuaCompile LuaCompile;
typedef void (* compileCb)(LuaCompile *compiler);

typedef struct _LuaCompile
{
  char			*file, *SID, *luaName;
  int			bugCount;
  void			*data;
  Ecore_Con_Client	*client;
  compileCb		cb;
} LuaCompiler;

typedef struct _script script;
typedef void (* RunnrServerCb)(script *me, const char *message);

typedef struct _script
{
  Eina_Clist		node;
#if THREADIT
  Eina_Lock		mutex;
  Ecore_Thread		*me;
#endif
  void			*data;
  char			SID[PATH_MAX];
  char			*name;
  char			fileName[PATH_MAX];
  char			binName[PATH_MAX];
  lua_State		*L;
  struct timeval	startTime;
  float			timerTime;
  runnrStatus		status;
  RunnrServerCb		send2server;
  Eina_Clist		messages;
  Ecore_Con_Client	*client;
  Ecore_Timer		*timer;
} script;

typedef struct
{
  Eina_Clist	node;
  script	*s;
  const char	message[PATH_MAX];
} scriptMessage;


script *scriptAdd(char *file, char *SID, RunnrServerCb send2server, void *data);
void compileScript(LuaCompiler *compiler);
void runScript(script *me);
void resetScript(script *me);
script *getScript(char *SID);
void takeScript(script *me);
void releaseScript(script *me);
void send2script(const char *SID, const char *message);
void printScriptsStatus();

void dumpStack(lua_State *L, int i);
void doLuaString(lua_State *L, char *string, char *module);
int pull_lua(lua_State *L, int i, char *params, ...);
int push_lua(lua_State *L, char *params, ...);

#endif