FreeWRL / FreeX3D 4.3.0
FWTYPE.h
1/*
2=INSERT_TEMPLATE_HERE=
3
4$Id: FWTYPE.h,v 1.9 2010/02/26 19:34:44 sdumoulin Exp $
5
6Local include for world_script directory.
7
8*/
9
10/****************************************************************************
11 This file is part of the FreeWRL/FreeX3D Distribution.
12
13 Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
14
15 FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
16 it under the terms of the GNU Lesser Public License as published by
17 the Free Software Foundation, either version 3 of the License, or
18 (at your option) any later version.
19
20 FreeWRL/FreeX3D is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
27****************************************************************************/
28
29
30#ifndef __FWTYPE_H__
31#define __FWTYPE_H__
32
33typedef struct FWPropertySpec {
34 const char *name; //NULL means index int: SFVec3f[0], MF[i]
35 short index; //stable property index for switch/casing instead of strcmp on name
36 char type; //0 = null, F=Float D=Double I=Integer B=Boolean S=String, W=Object-web3d O-js Object P=ptr Z=flexiString(SFString,MFString[0] or ecmaString)
37 char readOnly; //T/F
39
40typedef struct ArgListType {
41 char nfixedArg;
42 char iVarArgStartsAt; //-1 no varargs
43 char fillMissingFixedWithZero; //T/F if F then complain if short
44 char *argtypes; //if varargs, then argtypes[nfixedArg] == type of varArg, and all varargs are assumed the same type
46
47struct FWTYPE;
48typedef struct FWTYPE *FWType;
49struct FWVAL;
50typedef struct FWVAL *FWval;
51struct WEB3DNATIVE;
52typedef struct WEB3DNATIVE FWPointer;
53
54typedef void * (* FWConstructor)(FWType fwtype, int ic, FWval fwpars);
55typedef int (* FWFunction)(FWType fwtype, void* ec, void * fwn, int argc, FWval fwpars, FWval fwretval);
56typedef int (* FWGet)(FWType fwtype, int index, void *ec, void * fwn, FWval fwretval);
57typedef int (* FWSet)(FWType fwtype, int index, void *ec, void * fwn, FWval fwsetval);
58typedef int (* FWIterator)(int index, FWType fwt, FWPointer *pointer, const char **name, int *lastProp, int *jndex, char *type, char *readOnly);
59
60typedef struct FWFunctionSpec {
61 const char *name;
62 FWFunction call;
63 char retType; //0 = null, N=numeric I=Integer B=Boolean S=String, W=Object-web3d F-jsFunc P=ptr
64 struct ArgListType arglist;
66
67struct FWTYPE{
68 int itype; //AUXTYPE_ or FIELDTYPE_
69 char ctype; //what it maps to in fwval.itype: B,I,F,D,S,W,P
70 char *name;
71 //int index; //index into an array of FWTYPES
72 int size_of; //for mallocing in constructor
73 FWConstructor Constructor;
74 struct ArgListType *ConstructorArgs;
75 FWPropertySpec *Properties;
76 FWIterator iterator; //if NULL and Properties, then will use generic function to has, else if !Properties and iterator, then will iterator in has
77 FWGet Getter; //Q should I have a virtual Getter that takes a char* key and does its own lookup?
78 FWSet Setter;
79 char takesIndexer; char indexerReadOnly;//getter can take in integer index ie MF[33]. put 0 or FALSE for no, else put the type the property takes/gives ie 'W' 'S' 'I' 'N' 'B' 'P'
80 FWFunctionSpec *Functions;
81};
82
83//wrapper around *native with a few extras
85 int fieldType; //type of vrml field (use FIELDTYPE_SFNode for nodes, else ie FIELDTYPE_SFVec3f)
86 union {
87 void *native; //pointer to auxtype - you would assign to this
88 union anyVrml *anyvrml; //pointer to anyVrml - you can use this during debugging to inspect the native you assigned
89 };
90 int *valueChanged; //pointer to valueChanged != NULL if this FWNATIVe is a reference to a Script->Field
91 int kind; //inputOnly, outputOnly, initializeOnly, inputOutput in PKW_ constant values
92 char gc; //'T' or 1 if you malloced the pointer and want the engine to free() when it garbage collects the related obj
93};
94
95#define AUXTYPE_X3DConstants 1001
96#define AUXTYPE_X3DBrowser 1002
97#define AUXTYPE_ComponentInfoArray 1010
98#define AUXTYPE_ProfileInfoArray 1011
99#define AUXTYPE_ComponentInfo 1012
100#define AUXTYPE_ProfileInfo 1013
101#define AUXTYPE_X3DRoute 1014
102#define AUXTYPE_X3DRouteArray 1015
103#define AUXTYPE_X3DScene 1016
104#define AUXTYPE_X3DExecutionContext 1017
105#define AUXTYPE_X3DProto 1018
106#define AUXTYPE_X3DProtoArray 1019
107#define AUXTYPE_X3DExternProto 1020
108#define AUXTYPE_X3DExternProtoArray 1021
109#define AUXTYPE_X3DFieldDefinition 1022
110#define AUXTYPE_X3DFieldDefinitionArray 1023
111#define AUXTYPE_X3DMatrix3 1023
112#define AUXTYPE_X3DMatrix4 1024
113
114//our version of a variant, except in C types and our union anyVrml
115struct FWVAL{
116 char itype; //0 = null, F=Float D=Double I=Integer B=Boolean S=String, Z=flexiString (MF or S) W=Object-web3d O-js Object P=ptr
117 union {
118 //union anyScalar{
119 int _null;
120 double _numeric;
121 int _integer;
122 int _boolean;
123 const char* _string;
124 //}
125 FWPointer _pointer;
126 FWPointer _web3dval;
127 void* _jsobject; //placeholder for js function callback objects
128 };
129};
130FWval FWvalsNew(int argc);
131
132//typedef void (* FWFinalizer)(FWType fwtype, FWNative fwn);
133struct Multi_Any {int n; char *p;}; //should be same size as {int n, double *p} or {int n, struct X3D_Node **p} - an int and a pointer
134
135
136
137#endif /* __FWTYPE_H__ */