Menu

[r760]: / trunk / lispbuilder-openrm / build / openrmswig.i  Maximize  Restore  History

Download this file

329 lines (282 with data), 8.4 kB

  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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
%insert("lisphead")
%{
;;;; OpenRM CFFI lisp wrapper
;;;; Part of the CL-Gardeners project
;;;; http://wiki.alu.org/Application_Builder
;;;; (C)2006 Luke J Crook
;;;; See COPYING for license
;;;;
;;;; This .i file has been tested with SDL version 1.2.11
(in-package :lispbuilder-openrm-cffi)
;;; This is to handle a C macro where 1 is shifted left n times
(defun 1<<(x) (ash 1 x))
(cl:eval-when (:compile-toplevel :load-toplevel)
(cl:unless (cl:fboundp 'openrm-lispify)
(defun openrm-lispify (name flag &optional (package *package*))
(labels ((find-sub (src lst)
(when (>= (length lst)
(length src))
(if (and (equal src (subseq lst 0 (length src)))
(not (equal (nth (length src)
lst) #\_)))
t
nil)))
(replace-sub (new old lis)
(append new (nthcdr (length old) lis)))
(next-char (char)
(if char
(cond
((upper-case-p char)
'upper)
((lower-case-p char)
'lower)
(t nil))
nil))
(helper (lst last prev-last rest &aux (c (car lst)))
(declare (ignore prev-last))
(cond
((null lst)
rest)
((upper-case-p c)
(let ((new '(#\R #\M #\_)) (old '(#\R #\M)))
(when (and (not (find-sub '(#\R #\M #\I #\_) lst))
(find-sub old lst))
(setf lst (replace-sub new old lst)
c (first new))))
(helper (cdr lst) 'upper last
(cond
((or (equal last 'lower)
;; (equal last 'digit)
)
(list* c #\- rest))
((and (equal last 'upper)
(equal (next-char (cadr lst)) 'lower))
(list* c #\- rest))
(t (cons c rest)))))
((lower-case-p c)
(helper (cdr lst) 'lower last (cons (char-upcase c) rest)))
((digit-char-p c)
(helper (cdr lst) 'digit last
(case last
((upper lower) (list* c #\- rest))
(t (cons c rest)))))
((char-equal c #\_)
(helper (cdr lst) '_ last (cons #\- rest)))
(t
(error "Invalid character: ~A" c)))))
(let ((fix (case flag
((constant variable) "*")
(enumvalue "")
(t ""))))
(intern
(concatenate
'string
fix
(nreverse (helper (concatenate 'list name) nil nil nil))
fix)
package))))
))
;;;; Lispifies the following 'C' keywords:
;;;; scancode = SCANCODE
;;;; SDL_ALL_HOTKEYS = *SDL-ALL-HOTKEYS*
;;;; SDLKey = SDL-KEY
;;;; RMenum = RM-ENUM
;;;; SDL_GetKeyRepeat = SDL-GET-KEY-REPEAT
;;;; SDL_RWFromFP = SDL-RW-FROM-FP
;;;; SDL_HasSSE = SDL-HAS-SSE
;;;; SDL_HasSSE2 = SDL-HAS-SSE-2
;;;; RMcolor4D = RM-COLOR-4D
;;;; SDL_Has3DNow = SDL-HAS-3D-NOW
;;;; SDL_WriteBE32 = SDL-WRITE-BE-32
;;;; SDLK_SLASH = :KEY-SLASH
;;;; SDLK_F1 = :KEY-F-1
;;;; KMOD_LSHIFT = :KEY-MOD-LSHIFT
;;;; FLOAT-POINTER is used by the CFFI translation functions
;;;; see the typemap definition below.
(defctype float-pointer :pointer)
;; (defcstruct RMmatrix
;; (m :float :count 16))
;; See "rmtypes.h" below.
(defcstruct _object_info
(name :char :count 64)
(posted :int)
(rpass_vdims :int)
(rpass_opacity :int)
(channel :int)
(pickEnable :int))
;; See "rmtypes.h" below.
(defcstruct RMpipe
(offscreen :int)
(processingMode :int)
(channel_format :int)
(xwindow_width :int)
(xwindow_height :int)
(xflags :int)
(opaque3DEnable :int)
(transparent3DEnable :int)
(opaque2DEnable :int)
(initMatrixStack :int)
(frameNumber :int)
(displayListEnableBool :int)
(contextCache :pointer)
(displayLists :pointer)
(mtControl :pointer)
(hdc :pointer)
(hwnd :pointer)
(hRC :pointer)
(myRank :int)
(globalNPE :int)
(targetPlatform :int)
(channel_render_func :pointer)
(postRenderBarrierFunc :pointer)
(postrenderfunc :pointer)
(postrender_depthbufferfunc :pointer)
(swapBuffersFunc :pointer)
(shutdownFunc :pointer)
(postFBClearBarrierFunc :pointer)
(createContextFunc :pointer)
(targetFrameRate :int)
(timePerFrame :pointer)
(timePerFrameMS :double)
(lastTimeStart :pointer)
(lastRenderTime :pointer)
(timeSyncFunc :pointer)
(caps :pointer)
(fbClearNode :pointer)
(localMaskStack :int :count 65)
(localMaskStackTop :int))
%}
%module openrm
%feature("intern_function","openrm-lispify");
%typemap(cin) float* "float-pointer";
// "rmdefs.h"
// TODO: Fix %ignores
%ignore RM_MIN; // Use MIN
%ignore RM_MAX; // Use MAX
%ignore RM_DEGREES_TO_RADIANS; // Implemented in Lisp above
%ignore RM_RADIANS_TO_DEGREES; // Implemented in Lisp above
%include "rmdefs.h"
// "rmthread.h"
#define RM_WIN
#define RM_EXPORT_API
typedef void *HANDLE;
//typedef HANDLE RMmutex;
//typedef unsigned long RMthread;
%include "rmthread.h"
//%include "rmcmpmgr.h" // Skip this one. Will include if ever required.
// "rmtypes.h"
// TODO:
// Check the stuct RMpipeOGLCapabilities. Function pointers do not seem to be defined correctly.
// Need to modify for Linux. Check RM_X.
#define GLAPIENTRY
#define MAX_MASK_STACK_DEPTH 64 // Defined inline in RMpipe. Not cool.
#define MAX_FRAME_SAMPLES 6 // Defined inline in RMpipe. Not cool.
//%typemap(cin) char name[OBJECT_NAME_LENGTH] "(name :char :count 64)";
%ignore _object_info; // Defined above as this contains a staticly defined array of chars.
%ignore RMpipe; // Defined above as this contains a staticly defined array of ints.
typedef unsigned int GLenum;
typedef unsigned char GLboolean;
typedef unsigned int GLbitfield;
typedef signed char GLbyte;
typedef short GLshort;
typedef int GLint;
typedef int GLsizei;
typedef unsigned char GLubyte;
typedef unsigned short GLushort;
typedef unsigned int GLuint;
typedef float GLfloat;
typedef float GLclampf;
typedef double GLdouble;
typedef double GLclampd;
typedef void GLvoid;
struct HINSTANCE__ { int unused; };
typedef struct HINSTANCE__ *HINSTANCE;
struct HWND__ { int unused; };
typedef struct HWND__ *HWND;
struct HGLRC__ { int unused; };
typedef struct HGLRC__ *HGLRC;
struct HDC__ { int unused; };
typedef struct HDC__ *HDC;
%include "rmtypes.h"
// "rmx.h"
// TODO:
// Not supported in this version.
// %include "rmx.h" // X.
// "rmvmap.h"
// VERIFY:
%include "rmvmap.h"
// "rmw.h"
// VERIFY:
%include "rmw.h" // Win32
// %include "rmcr.h" // Chromium support. Not used.
// "rmpipe.h"
// VERIFY:
%include "rmpipe.h"
// "rmpublic.h"
// TODO:
// VCOPY
// V3COPY
// V2COPY
// V4COPY
// rmInternalMarker2DGetNpts
// rmInternalMarker2DSetNpts
// rmInternalMarker2DGetVerts
// rmInternalMarker2DSetBFlag
// rmInternalMarker2DGetBFlag
%ignore rmColor3DNew; // Defined in Lisp above.
%ignore rmColor3DDelete; // Defined in Lisp above.
%include "rmpublic.h"
// "rmdeflts.h"
%ignore RM_PS_PORTRAIT; // This is an enum, not a #define. SWIG can't assign an enum to a define.
%ignore RM_SHADER_SMOOTH; // This is an enum, not a #define. SWIG can't assign an enum to a define.
#define RM_PS_PORTRAIT 0x0100;
#define RM_SHADER_SMOOTH 0x0220;
%include "rmdeflts.h"
%include "rmps.h"
#define WINAPI
%include "rmaux.h"
%include "rm.h"
%include "rmppm.h"
%include "rmjpeg.h"
%insert("lisphead") %{
;;;; "rmdefs.h"
;; //#define RM_DEGREES_TO_RADIANS(a) ((a)*0.017453292)
(defun RM_DEGREES_TO_RADIANS (a)
(* a 0.017453292))
;; //#define RM_RADIANS_TO_DEGREES(a) ((a) * 57.29577951)
(defun RM_RADIANS_TO_DEGREES (a)
(* a 57.29577951))
;; "rmcmpmgr.h"
(defconstant PAGE_SIZE_BITS 12);; /* 2^12 = 4096 */
(defun NUM_PAGES_BITS ()
(- 32 PAGE_SIZE_BITS))
(defun NUM_ITEMS_PER_PAGE ()
(ash 1 PAGE_SIZE_BITS))
(defun OFFSET_MASK ()
(- (NUM_ITEMS_PER_PAGE) 1))
(defun NUM_PAGES ()
(ash 1 (NUM_PAGES_BITS)))
(defun PAGE_INDEX_MASK ()
(- (NUM_PAGES) 1))
;; //#define rmCompManagerGetPage(a) ( ((a) >> PAGE_SIZE_BITS) & PAGE_INDEX_MASK )
(defun rmCompManagerGetPage (a)
(logand (PAGE_INDEX_MASK) (ash a (- PAGE_SIZE_BITS))))
;; //#define rmCompManagerGetOffset(a) ( ((a) & OFFSET_MASK) )
(defun rmCompManagerGetOffset (a)
(logand a (OFFSET_MASK)))
;; //#define rmCompManagerSetPage(a, b) ( (a) | (((b) & PAGE_INDEX_MASK) << PAGE_SIZE_BITS) )
(defun rmCompManagerSetPage (a b)
(logior a
(ash (logand b (PAGE_INDEX_MASK))
PAGE_SIZE_BITS)))
;; //#define rmCompManagerSetOffset(a, b) ( ((a) & (OFFSET_MASK)) | ( (b) & OFFSET_MASK) )
(defun rmCompManagerSetOffset (a b)
(logior (logand a (OFFSET_MASK))
(logand b (OFFSET_MASK))))
;; See "rmpublic.h" below.
(defun rm-Color-3D-New (a)
(rm-Vertex-3D-New a))
;; See "rmpublic.h" below.
(defun rm-Color-3D-Delete (a)
(rm-Vertex-3D-Delete a))
%}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.