FreeWRL/FreeX3D  3.0.0
EAI_swigMe.h
1 
2 /****************************************************************************
3  This file is part of the FreeWRL/FreeX3D Distribution.
4 
5  Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
6 
7  FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
8  it under the terms of the GNU Lesser Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  FreeWRL/FreeX3D is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
19 ****************************************************************************/
20 
21 
22 #ifndef __X3D_NODE_HEADERS__
23 #define __X3D_NODE_HEADERS__
24 /*EAIswigMe.h - for swigging */
25 /* garbage collection - in your script call X3D_freeNode(X3DNode*) for anything that returns an X3DNode* to your script. */
26 /* most of this is a copy from X3DNode.h - could be refactored to elliminate duplication
27  Except swig specifics - see bottom for SWIG-specific swig-venience function prototypes
28  (see EAI_swigExtras.c for implementation) */
29 /* Node section */
30 #ifdef SWIG
31 typedef struct { int type; int value; } _intX3D_SFBool;
32 typedef struct { int type; float value; } _intX3D_SFFloat;
33 typedef struct { int type; double value; } _intX3D_SFTime;
34 typedef struct { int type; int value; } _intX3D_SFInt32;
35 typedef struct { int type; int adr; } _intX3D_SFNode;
36 typedef struct { int type; float r[4]; } _intX3D_SFRotation;
37 typedef struct { int type; float c[2]; } _intX3D_SFVec2f;
38 typedef struct { int type; double c[2]; } _intX3D_SFVec2d;
39 typedef struct { int type; float c[3]; } _intX3D_SFColor;
40 typedef struct { int type; float c[3]; } _intX3D_SFVec3f;
41 typedef struct { int type; double c[3]; } _intX3D_SFVec3d;
42 typedef struct { int type; float r[4]; } _intX3D_SFColorRGBA;
43 typedef struct { int type; int len; char *strptr;} _intX3D_SFString;
44 typedef struct { int type; int len; char *strptr;} _intX3D_SFImage;
45 
46 typedef struct { int type; int n; _intX3D_SFColor *p; } _intX3D_MFColor;
47 typedef struct { int type; int n; _intX3D_SFColorRGBA *p; } _intX3D_MFColorRGBA;
48 typedef struct { int type; int n; _intX3D_SFFloat *p; } _intX3D_MFFloat;
49 typedef struct { int type; int n; _intX3D_SFTime *p; } _intX3D_MFTime;
50 typedef struct { int type; int n; _intX3D_SFRotation *p; } _intX3D_MFRotation;
51 typedef struct { int type; int n; _intX3D_SFVec3d *p; } _intX3D_MFVec3d;
52 typedef struct { int type; int n; _intX3D_SFVec2d *p; } _intX3D_MFVec2d;
53 typedef struct { int type; int n; _intX3D_SFVec3f *p; } _intX3D_MFVec3f;
54 typedef struct { int type; int n; _intX3D_SFVec2f *p; } _intX3D_MFVec2f;
55 typedef struct { int type; int n; _intX3D_SFBool *p; } _intX3D_MFBool;
56 typedef struct { int type; int n; _intX3D_SFInt32 *p; } _intX3D_MFInt32;
57 typedef struct { int type; int n; _intX3D_SFNode *p; } _intX3D_MFNode;
58 typedef struct { int type; int n; _intX3D_SFString *p; } _intX3D_MFString;
59 typedef struct { int type; int n; _intX3D_SFImage *p; } _intX3D_MFImage;
60 
61 
62 typedef union _X3DNode {
63  int type;
64  _intX3D_MFBool X3D_MFBool;
65  _intX3D_SFBool X3D_SFBool;
66  _intX3D_SFFloat X3D_SFFloat;
67  _intX3D_SFTime X3D_SFTime;
68  _intX3D_SFInt32 X3D_SFInt32;
69  _intX3D_MFColor X3D_MFColor;
70  _intX3D_MFColorRGBA X3D_MFColorRGBA;
71  _intX3D_SFString X3D_SFString;
72  _intX3D_SFNode X3D_SFNode;
73  _intX3D_SFRotation X3D_SFRotation;
74  _intX3D_SFVec2f X3D_SFVec2f;
75  _intX3D_SFVec2d X3D_SFVec2d;
76  _intX3D_SFColor X3D_SFColor;
77  _intX3D_SFColor X3D_SFVec3f;
78  _intX3D_SFVec3d X3D_SFVec3d;
79  _intX3D_SFColorRGBA X3D_SFColorRGBA;
80  _intX3D_MFFloat X3D_MFFloat;
81  _intX3D_MFTime X3D_MFTime;
82  _intX3D_MFInt32 X3D_MFInt32;
83  _intX3D_MFString X3D_MFString;
84  _intX3D_MFNode X3D_MFNode;
85  _intX3D_MFRotation X3D_MFRotation;
86  _intX3D_MFVec2f X3D_MFVec2f;
87  _intX3D_MFVec3f X3D_MFVec3f;
88  _intX3D_MFImage X3D_MFImage;
89  _intX3D_MFVec3d X3D_MFVec3d;
90 } X3DNode;
91 
92 /* field section */
93 X3DNode *X3D_newSFVec3f (float a, float b, float c);
94 X3DNode *X3D_newSFColor (float a, float b, float c);
95 X3DNode *X3D_newSFVec2f (float a, float b);
96 X3DNode *X3D_newSFRotation (float a, float b,float c, float d);
97 X3DNode *X3D_newSFColorRGBA (float a, float b,float c, float d);
98 X3DNode *X3D_newSFVec3d (double a, double b,double c);
99 X3DNode *X3D_newSFVec2d (double a, double b);
100 X3DNode *X3D_newSFBool (int a);
101 X3DNode *X3D_newSFFloat (float a);
102 X3DNode *X3D_newSFTime (double a);
103 X3DNode *X3D_newSFInt32 (int a);
104 X3DNode *X3D_newSFString(char* string); /*()*/
105 X3DNode *X3D_newSFNode(); /*not implemented yet*/
106 X3DNode *X3D_newSFImage(); /*not implemented yet*/
107 
108 /* these prototypes dont match the .c - use X3D_newMF plus: setItem and/or appendToMF*.
109 X3DNode *X3D_newMFColor();
110 X3DNode *X3D_newMFFloat();
111 X3DNode *X3D_newMFTime();
112 X3DNode *X3D_newMFInt32();
113 X3DNode *X3D_newMFString();
114 X3DNode *X3D_newMFNode();
115 X3DNode *X3D_newMFRotation();
116 X3DNode *X3D_newMFVec2f();
117 X3DNode *X3D_newMFVec3f();
118 X3DNode *X3D_newMFColorRGBA();
119 X3DNode *X3D_newMFBool();
120 X3DNode *X3D_newMFVec3d();
121 X3DNode *X3D_newMFVec2d();
122 */
123 
124 
125 /* browser section */
126 struct _intX3DEventIn {
127  int nodeptr;
128  int offset;
129  int datatype;
130  int datasize;
131  int scripttype;
132  char *field;
133 };
134 
135 #define X3DEventIn struct _intX3DEventIn
136 #define X3DEventOut struct _intX3DEventIn
137 void X3D_freeEventIn(X3DEventIn* ev);
138 void X3D_freeEventOut(X3DEventOut* ev);
139 /* single value structures */
140 
141 X3DNode *X3D_getNode (char *name);
142 X3DEventIn *X3D_getEventIn(X3DNode *node, char *name);
143 X3DEventOut *X3D_getEventOut(X3DNode *node, char *name);
144 X3DNode* X3D_getValue (X3DEventOut *src);
145 void X3D_freeNode(X3DNode* node);
146 
147 void X3D_setValue (X3DEventIn *dest, X3DNode *node);
148 void X3D_addRoute (X3DEventOut *from, X3DEventIn *to);
149 void X3D_deleteRoute (X3DEventOut *from, X3DEventIn *to);
150 
151 /* initialize, shutdown public methods */
152 void X3D_initialize(char *);
153 void X3D_shutdown();
154 
155 /* float public methods */
156 float X3D_getCurrentSpeed();
157 float X3D_getCurrentFrameRate();
158 
159 /* null public methods */
160 void X3D_firstViewpoint();
161 void X3D_lastViewpoint();
162 void X3D_nextViewpoint();
163 void X3D_previousViewpoint();
164 void X3D_setDescription(char *newDescription);
165 
166 /* string return val public methods */
167 char *X3D_getDescription();
168 char *X3D_getName();
169 char *X3D_getVersion();
170 char *X3D_getWorldURL();
171 
172 /* MFNode public methods */
173 X3DNode *X3D_createVrmlFromString(char *str);
174 
175 void X3D_error(char *msg);
176 int X3DAdvise(X3DEventOut *node, void *fn);
177 
178 
179 /* findField.. not swig specific, but needed as helper by swig-venience functions */
180 int findFieldInFIELDTYPES(char *fieldtype);
181 
182 /* SWIG-SPECIFIC */
183 void *freewrlSwigThread(void*);
184 
185 
186 
187 /* SWIG does scalars well including char* but not C arrays which appear as opaque binary blobs.
188 The following 'swig-venience' functions elliminate the need for passing C arrays by providing getters and setters*/
189 
190 /*the first 2 swig-venience functions should be minimally sufficient
191 but require parsing code to interpret the stringFromField on the script side*/
192 X3DNode* X3D_swigFieldFromString(char* fieldtype, char* values);
193 char * X3D_swigStringFromField(X3DNode* field);
194 
195 /* the following 4 would also be sufficient (but do not confuse with any "live" field functions in the main libeai) */
196 X3DNode *X3D_swigNewMF(char *fieldtype, int num );
197 void X3D_swigAppendToMF(X3DNode* mfnode, X3DNode* sfitem);
198 void X3D_swigSetItem(X3DNode* node, int item, X3DNode* value);
199 X3DNode* X3D_swigGetItem(X3DNode* node, int item);
200 
201 /* the following is what you call right after a port style Advise notification, to get the field data */
202 X3DNode* X3D_swigCallbackDataFetch(char *ListenerTableIndex);
203 
204 #endif //SWIG
205 
206 #endif //__X3D_NODE_HEADERS__