summaryrefslogtreecommitdiff
path: root/src/lua5/cdvoid5.c
blob: ebc965cd0e063f251ba175d9887e4504140831e9 (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
/** \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 *, int))cdvoid_error;
  canvas->cxGetFontDim = (void (*)(cdCtxCanvas*, int *,int *,int *,int *))cdvoid_error;
  canvas->cxGetTextSize = (void (*)(cdCtxCanvas*, const char *,int,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 *,int))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,
  0,
  cdcreatecanvas,
  cdinittable,
  NULL,
  NULL
};

cdContext* cdContextVoid(void)
{
  return &cdVoidContext;
}