1 /** \file 2 * \brief Private Lua 5 Binding Functions 3 * 4 * See Copyright Notice in cd.h 5 */ 6 7 module cd.lua5_private; 8 9 import cd.cd; 10 11 extern (C) @safe nothrow: 12 13 struct lua_State; 14 struct luaL_Reg; 15 16 /* context management */ 17 18 struct _cdluaCallback { 19 int lock; 20 const(char) * name; 21 cdCallback func; 22 } 23 alias cdluaCallback = _cdluaCallback; 24 25 struct _cdluaContext { 26 int id; 27 const(char) * name; 28 cdContext* function() ctx; 29 void* function(lua_State* L,int param) checkdata; 30 cdluaCallback* cb_list; 31 int cb_n; 32 } 33 alias cdluaContext = _cdluaContext; 34 35 struct _cdluaLuaState { 36 cdCanvas* void_canvas; /* the VOID canvas to avoid a NULL active canvas */ 37 cdluaContext*[50] drivers; /* store the registered drivers, map integer values to cdContext */ 38 int numdrivers; 39 } 40 alias cdluaLuaState = _cdluaLuaState; 41 42 /* metatables */ 43 44 struct _cdluaStipple { 45 ubyte* stipple; 46 int width; 47 int height; 48 long size; 49 } 50 alias cdluaStipple = _cdluaStipple; 51 52 struct _cdluaPattern { 53 long* pattern; 54 int width; 55 int height; 56 long size; 57 } 58 alias cdluaPattern = _cdluaPattern; 59 60 /* this is the same declaration used in the IM toolkit for imPalette in Lua */ 61 struct _cdluaPalette { 62 long* color; 63 int count; 64 } 65 alias cdluaPalette = _cdluaPalette; 66 67 struct _cdluaImageRGB { 68 ubyte* red; 69 ubyte* green; 70 ubyte* blue; 71 int width; 72 int height; 73 long size; 74 int free; 75 } 76 alias cdluaImageRGB = _cdluaImageRGB; 77 78 struct _cdluaImageRGBA { 79 ubyte* red; 80 ubyte* green; 81 ubyte* blue; 82 ubyte* alpha; 83 int width; 84 int height; 85 long size; 86 int free; 87 } 88 alias cdluaImageRGBA = _cdluaImageRGBA; 89 90 struct _cdluaImageMap { 91 ubyte* index; 92 int width; 93 int height; 94 long size; 95 } 96 alias cdluaImageMap = _cdluaImageMap; 97 98 struct _cdluaImageChannel { 99 ubyte* channel; 100 long size; 101 } 102 alias cdluaImageChannel = _cdluaImageChannel; 103 104 105 cdluaLuaState* cdlua_getstate(lua_State* L); 106 cdluaContext* cdlua_getcontext(lua_State* L, int param); 107 108 lua_State* cdlua_getplaystate(); 109 void cdlua_setplaystate(lua_State* L); 110 111 void cdlua_register_lib(lua_State *L, const(luaL_Reg) * funcs); 112 void cdlua_register_funcs(lua_State *L, const(luaL_Reg) * funcs); 113 114 void cdlua_kill_active(lua_State* L, cdCanvas* canvas); 115 void cdlua_open_active(lua_State* L, cdluaLuaState* cdL); 116 117 void cdlua_open_canvas(lua_State* L); 118 119 void cdlua_addcontext(lua_State* L, cdluaLuaState* cdL, cdluaContext* luactx); 120 void cdlua_initdrivers(lua_State* L, cdluaLuaState* cdL); 121 122 cdluaPalette* cdlua_checkpalette(lua_State* L, int param); 123 cdluaStipple* cdlua_checkstipple(lua_State* L, int param); 124 cdluaPattern* cdlua_checkpattern(lua_State* L, int param); 125 cdluaImageRGB* cdlua_checkimagergb(lua_State* L, int param); 126 cdluaImageRGBA* cdlua_checkimagergba(lua_State* L, int param); 127 cdluaImageMap* cdlua_checkimagemap(lua_State* L, int param); 128 cdluaImageChannel* cdlua_checkchannel(lua_State* L, int param); 129 130 long cdlua_checkcolor(lua_State* L, int param); 131 cdImage* cdlua_checkimage(lua_State* L, int param); 132 cdState* cdlua_checkstate(lua_State* L, int param); 133 cdBitmap* cdlua_checkbitmap(lua_State* L, int param); 134 135 void cdlua_pushcolor(lua_State* L, long color); 136 void cdlua_pushpalette(lua_State* L, long* palette, int size); 137 void cdlua_pushstipple(lua_State* L, ubyte* stipple, int width, int height); 138 void cdlua_pushpattern(lua_State* L, long* pattern, int width, int height); 139 void cdlua_pushimagergb(lua_State* L, ubyte* red, ubyte* green, ubyte* blue, int width, int height); 140 void cdlua_pushimagergba(lua_State* L, ubyte* red, ubyte* green, ubyte* blue, ubyte* alpha, int width, int height); 141 void cdlua_pushimagemap(lua_State* L, ubyte* index, int width, int height); 142 void cdlua_pushchannel(lua_State* L, ubyte* channel, int size); 143 144 void cdlua_pushimage(lua_State* L, cdImage* image); 145 void cdlua_pushstate(lua_State* L, cdState* state); 146 void cdlua_pushbitmap(lua_State* L, cdBitmap* bitmap); 147 148 void cdlua_pushimagergb_ex(lua_State* L, ubyte* red, ubyte* green, ubyte* blue, int width, int height); 149 void cdlua_pushimagergba_ex(lua_State* L, ubyte* red, ubyte* green, ubyte* blue, ubyte* alpha, int width, int height);