summaryrefslogtreecommitdiff
path: root/src/lua5/cdvoid5.c
diff options
context:
space:
mode:
authorscuri <scuri>2008-10-17 06:10:33 +0000
committerscuri <scuri>2008-10-17 06:10:33 +0000
commit7b52cc13af4e85f1ca2deb6b6c77de9c95ea0dcf (patch)
treed0857278bde2eff784227c57dcaf930346ceb7ac /src/lua5/cdvoid5.c
First commit - moving from LuaForge to SourceForge
Diffstat (limited to 'src/lua5/cdvoid5.c')
-rw-r--r--src/lua5/cdvoid5.c130
1 files changed, 130 insertions, 0 deletions
diff --git a/src/lua5/cdvoid5.c b/src/lua5/cdvoid5.c
new file mode 100644
index 0000000..2424e1d
--- /dev/null
+++ b/src/lua5/cdvoid5.c
@@ -0,0 +1,130 @@
+/** \file
+ * \brief CD Void driver for error checking while there is no active canvas
+ *
+ * See Copyright Notice in cd.h
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "cd.h"
+#include "cd_private.h"
+
+#include <lua.h>
+#include <lauxlib.h>
+
+#include "cdlua5_private.h"
+
+
+struct _cdCtxCanvas
+{
+ cdCanvas* canvas;
+ lua_State * L;
+};
+
+void cdlua_setvoidstate(cdCanvas* canvas, lua_State * L)
+{
+ canvas->ctxcanvas->L = L;
+}
+
+static void cdcreatecanvas(cdCanvas *canvas, void *data)
+{
+ cdCtxCanvas *ctxcanvas = (cdCtxCanvas*) malloc(sizeof(cdCtxCanvas));
+ ctxcanvas->canvas = canvas;
+ canvas->ctxcanvas = ctxcanvas;
+ (void)data;
+}
+
+static void cdkillcanvas(cdCtxCanvas* ctxcanvas)
+{
+ free(ctxcanvas);
+}
+
+/***************************************************************************\
+* Echos an error if called. *
+\***************************************************************************/
+static void cdvoid_error(cdCtxCanvas* ctxcanvas)
+{
+ luaL_error(ctxcanvas->L, "cdlua: there is no active canvas");
+}
+
+/***************************************************************************\
+* Dummy. *
+\***************************************************************************/
+static int cdvoid_dummy(void)
+{
+ return CD_OK;
+}
+
+/***************************************************************************\
+* Driver function table. *
+\***************************************************************************/
+
+void cdinittable(cdCanvas* canvas)
+{
+ /* attribute functions can not be set, because of default attributes */
+
+ canvas->cxClip = (int (*)(cdCtxCanvas*, int))cdvoid_error;
+ canvas->cxClipArea = (void (*)(cdCtxCanvas*, int, int, int, int))cdvoid_error;
+ canvas->cxNewRegion = (void (*)(cdCtxCanvas*))cdvoid_error;
+ canvas->cxIsPointInRegion = (int (*)(cdCtxCanvas*, int, int))cdvoid_error;
+ canvas->cxOffsetRegion = (void (*)(cdCtxCanvas*, int, int))cdvoid_error;
+ canvas->cxGetRegionBox = (void (*)(cdCtxCanvas*, int *, int *, int *, int *))cdvoid_error;
+ canvas->cxFlush = (void ( *)(cdCtxCanvas*))cdvoid_error;
+ canvas->cxClear = (void ( *)(cdCtxCanvas*))cdvoid_error;
+ canvas->cxPixel = (void ( *)(cdCtxCanvas*, int ,int ,long ))cdvoid_error;
+ canvas->cxLine = (void ( *)(cdCtxCanvas*, int ,int ,int ,int ))cdvoid_error;
+ canvas->cxPoly = (void ( *)(cdCtxCanvas*, int ,struct _cdPoint *,int ))cdvoid_error;
+ canvas->cxRect = (void ( *)(cdCtxCanvas*, int ,int ,int ,int ))cdvoid_error;
+ canvas->cxBox = (void ( *)(cdCtxCanvas*, int ,int ,int ,int ))cdvoid_error;
+ canvas->cxArc = (void ( *)(cdCtxCanvas*, int ,int ,int ,int ,double ,double ))cdvoid_error;
+ canvas->cxSector = (void ( *)(cdCtxCanvas*, int ,int ,int ,int ,double ,double ))cdvoid_error;
+ canvas->cxChord = (void ( *)(cdCtxCanvas*, int ,int ,int ,int ,double ,double ))cdvoid_error;
+ canvas->cxText = (void (*)(cdCtxCanvas*, int ,int ,const char *))cdvoid_error;
+ canvas->cxGetFontDim = (void (*)(cdCtxCanvas*, int *,int *,int *,int *))cdvoid_error;
+ canvas->cxGetTextSize = (void (*)(cdCtxCanvas*, const char *,int *,int *))cdvoid_error;
+ canvas->cxPutImageRectRGB = (void (*)(cdCtxCanvas*, int ,int ,const unsigned char *,const unsigned char *,const unsigned char *,int ,int ,int ,int ,int ,int ,int ,int ))cdvoid_error;
+ canvas->cxPutImageRectRGBA = (void (*)(cdCtxCanvas*, int ,int ,const unsigned char *,const unsigned char *,const unsigned char *,const unsigned char *,int ,int ,int ,int ,int ,int ,int ,int ))cdvoid_error;
+ canvas->cxPutImageRectMap = (void (*)(cdCtxCanvas*, int ,int ,const unsigned char *,const long *,int ,int ,int ,int ,int ,int ,int ,int ))cdvoid_error;
+ canvas->cxScrollArea = (void (*)(cdCtxCanvas*, int ,int ,int ,int ,int ,int ))cdvoid_error;
+ canvas->cxFLine = (void (*)(cdCtxCanvas*, double ,double ,double ,double ))cdvoid_error;
+ canvas->cxFPoly = (void (*)(cdCtxCanvas*, int , cdfPoint*,int ))cdvoid_error;
+ canvas->cxFRect = (void (*)(cdCtxCanvas*, double ,double ,double ,double ))cdvoid_error;
+ canvas->cxFBox = (void (*)(cdCtxCanvas*, double ,double ,double ,double ))cdvoid_error;
+ canvas->cxFArc = (void (*)(cdCtxCanvas*, double ,double ,double ,double ,double ,double ))cdvoid_error;
+ canvas->cxFSector = (void (*)(cdCtxCanvas*, double ,double ,double ,double ,double ,double ))cdvoid_error;
+ canvas->cxFText = (void (*)(cdCtxCanvas*, double ,double ,const char *))cdvoid_error;
+ canvas->cxStipple = (void (*)(cdCtxCanvas*, int ,int ,const unsigned char *))cdvoid_error;
+ canvas->cxPattern = (void (*)(cdCtxCanvas*, int ,int , const long *))cdvoid_error;
+ canvas->cxNativeFont = (int (*)(cdCtxCanvas*, const char*))cdvoid_error;
+ canvas->cxPalette = (void (*)(cdCtxCanvas*, int ,const long *,int ))cdvoid_error;
+ canvas->cxGetImageRGB = (void (*)(cdCtxCanvas*, unsigned char *,unsigned char *,unsigned char *,int ,int ,int ,int ))cdvoid_error;
+ canvas->cxCreateImage = (cdCtxImage* (*)(cdCtxCanvas*, int ,int ))cdvoid_error;
+ canvas->cxGetImage = (void (*)(cdCtxCanvas*, cdCtxImage*, int ,int ))cdvoid_error;
+ canvas->cxPutImageRect = (void (*)(cdCtxCanvas*, cdCtxImage*,int ,int ,int ,int ,int ,int ))cdvoid_error;
+ canvas->cxKillImage = (void (*)(cdCtxImage*))cdvoid_error;
+ canvas->cxFClipArea = (void (*)(cdCtxCanvas*, double,double,double,double))cdvoid_error;
+
+ /* must not be the error callback */
+ canvas->cxActivate = (int (*)(cdCtxCanvas*))cdvoid_dummy;
+ canvas->cxDeactivate = (void (*)(cdCtxCanvas*))cdvoid_dummy;
+ canvas->cxFont = (int (*)(cdCtxCanvas*, const char *, int, int))cdvoid_dummy;
+
+ canvas->cxKillCanvas = cdkillcanvas;
+}
+
+static cdContext cdVoidContext =
+{
+ 0,
+ 0,
+ cdcreatecanvas,
+ cdinittable,
+ NULL,
+ NULL
+};
+
+cdContext* cdContextVoid(void)
+{
+ return &cdVoidContext;
+}
+