summaryrefslogtreecommitdiff
path: root/cd/include/cdlua5_private.h
blob: 3051fb6843faaa0f089d3d060620fdd01396aeed (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/** \file
* \brief Private Lua 5 Binding Functions
* 
* See Copyright Notice in cd.h
*/

#ifndef __CDLUA5_PRIVATE_H
#define __CDLUA5_PRIVATE_H

#ifdef __cplusplus
extern "C" {
#endif


/* context management */

typedef struct _cdluaCallback {
  int lock;
  const char* name;
  cdCallback func;
} cdluaCallback;

typedef struct _cdluaContext {
  int id;
  const char* name;
  cdContext* (*ctx)(void);
  void* (*checkdata)(lua_State* L,int param);
  cdluaCallback* cb_list;
  int cb_n;
} cdluaContext;

typedef struct _cdluaLuaState {
  cdCanvas* void_canvas;            /* the VOID canvas to avoid a NULL active canvas */
  cdluaContext* drivers[50];  /* store the registered drivers, map integer values to cdContext */
  int numdrivers;
} cdluaLuaState;

/* metatables */

typedef struct _cdluaStipple {
  unsigned char* stipple;
  int width;
  int height;
  long int size;
} cdluaStipple;

typedef struct _cdluaPattern {
  long* pattern;
  int width;
  int height;
  long int size;
} cdluaPattern;

/* this is the same declaration used in the IM toolkit for imPalette in Lua */
typedef struct _cdluaPalette {
  long* color;
  int count;
} cdluaPalette;

typedef struct _cdluaImageRGB {
  unsigned char* red;
  unsigned char* green;
  unsigned char* blue;
  int width;
  int height;
  long int size;
  int free;
} cdluaImageRGB;

typedef struct _cdluaImageRGBA {
  unsigned char* red;
  unsigned char* green;
  unsigned char* blue;
  unsigned char* alpha;
  int width;
  int height;
  long int size;
  int free;
} cdluaImageRGBA;
         
typedef struct _cdluaImageMap {
  unsigned char* index;
  int width;
  int height;
  long int size;
} cdluaImageMap;

typedef struct _cdluaImageChannel {
  unsigned char* channel;
  long int size;
} cdluaImageChannel;


cdluaLuaState* cdlua_getstate(lua_State* L);
cdluaContext* cdlua_getcontext(lua_State* L, int param);

lua_State* cdlua_getplaystate(void);
void cdlua_setplaystate(lua_State* L);

void cdlua_kill_active(lua_State* L, cdCanvas* canvas);
void cdlua_open_active(lua_State* L, cdluaLuaState* cdL);

void cdlua_open_canvas(lua_State* L);

void cdlua_addcontext(lua_State* L, cdluaLuaState* cdL, cdluaContext* luactx);
void cdlua_initdrivers(lua_State* L, cdluaLuaState* cdL);

cdluaPalette* cdlua_checkpalette(lua_State* L, int param);
cdluaStipple* cdlua_checkstipple(lua_State* L, int param);
cdluaPattern* cdlua_checkpattern(lua_State* L, int param);
cdluaImageRGB* cdlua_checkimagergb(lua_State* L, int param);
cdluaImageRGBA* cdlua_checkimagergba(lua_State* L, int param);
cdluaImageMap* cdlua_checkimagemap(lua_State* L, int param);
cdluaImageChannel* cdlua_checkchannel(lua_State* L, int param);

long cdlua_checkcolor(lua_State* L, int param);
cdImage* cdlua_checkimage(lua_State* L, int param);
cdState* cdlua_checkstate(lua_State* L, int param);
cdBitmap* cdlua_checkbitmap(lua_State* L, int param);

void cdlua_pushpalette(lua_State* L, long* palette, int size);
void cdlua_pushstipple(lua_State* L, unsigned char* stipple, int width, int height);
void cdlua_pushpattern(lua_State* L, long int* pattern, int width, int height);
void cdlua_pushimagergb(lua_State* L, unsigned char* red, unsigned char* green, unsigned char* blue, int width, int height);
void cdlua_pushimagergba(lua_State* L, unsigned char* red, unsigned char* green, unsigned char* blue, unsigned char* alpha, int width, int height);
void cdlua_pushimagemap(lua_State* L, unsigned char* index, int width, int height);
void cdlua_pushchannel(lua_State* L, unsigned char* channel, int size);

void cdlua_pushimage(lua_State* L, cdImage* image);
void cdlua_pushstate(lua_State* L, cdState* state);
void cdlua_pushbitmap(lua_State* L, cdBitmap* bitmap);

void cdlua_pushimagergb_ex(lua_State* L, unsigned char* red, unsigned char* green, unsigned char* blue, int width, int height);
void cdlua_pushimagergba_ex(lua_State* L, unsigned char* red, unsigned char* green, unsigned char* blue, unsigned char* alpha, int width, int height);

#if LUA_VERSION_NUM < 502
#define luaL_typeerror luaL_typerror
#endif

#ifdef __cplusplus
}
#endif

#endif