示例#1
0
char * X3D_swigStringFromField(X3DNode* field)
{
	/* 
	  issue: swig treats C arrays as opaque pointers - not very helpful. How to get a specific SF from an MF field?
	  but- swig does pass a char * as scalar string properly
	  goal: convert an MF (or SF) field to a string for easy parsing from a swigged scripting language
	  "itype n sf1 sf2 sf3" 
	  sffloat "0 1 -123.456"  - the count will always be 1
	  mffloat "1 2 -123.456 555.444"
	  sfstring "24 \"OK folks let's rock it!\""
	  mfstring "25 2 \"You know...\" \"I'm not so sure about 'rocking' it.\"'
    */
	int type, ismf, count, i, size;
	char** tokens;
	char *string;
	char buf[500];
	type = field->type;
	if(type < 0 || type > 41 ) /*yikes - is there a MAXFIELDTYPE or other validity check? */
		return NULL; /* or should it be " 'NULL' " */
	ismf = type % 2;
	count = 2;
	if( ismf )
		count = count + field->X3D_MFNode.n;
	else
		count = count + 1;
	tokens = (char** )malloc(count*sizeof(char*));
	/*buf = MALLOC(char *, 500); /*just for 1 token - sf string might be the largest*/
	switch (type) 
	{
	case FIELDTYPE_SFFloat:
		tokens[0] = _x3ditoa(FIELDTYPE_SFFloat, buf);
		tokens[1] = _x3ditoa(1,buf);
		tokens[2] = _x3dftoa(field->X3D_SFFloat.value, buf);
		break;
	case FIELDTYPE_MFFloat:
		tokens[0] = _x3ditoa(FIELDTYPE_MFFloat,buf);
		tokens[1] = _x3ditoa(field->X3D_MFNode.n,buf);
		for(i=0;i<count-2;i++)
			tokens[i+2] = _x3dftoa(field->X3D_MFFloat.p[i].value,buf);
		break;
	case FIELDTYPE_MFString:
		tokens[0] = _x3ditoa(FIELDTYPE_MFString,buf);
		tokens[1] = _x3ditoa(field->X3D_MFString.n,buf);
		for(i=0;i<count-2;i++)
			tokens[i+2] = _x3datoa(field->X3D_MFString.p[i].strptr,buf);
		break;
	}
	size = 0;
	for(i=0;i<count;i++) size = size + strlen(tokens[i]);
	/* FREE_IF_NZ(buf); */
	string = MALLOC(char *, (size+1)*sizeof(char));
	string[0] = '\0';
	for(i=0;i<count;i++)
	{
		strcat(string,tokens[i]);
		FREE_IF_NZ(tokens[i]);
	}
	FREE_IF_NZ(tokens);
	return string; /* somebody else has to free this (option: return as X3D_SFString then X3D_free */
}
示例#2
0
void deleteLexer(struct VRMLLexer* me)
{
	#ifdef CPARSERVERBOSE
	printf ("deleteLexer called; deleting lexer %x %u\n",me,me);
	#endif
	 FREE_IF_NZ (me->curID);
 	FREE_IF_NZ (me);
 	//FREE_IF_NZ (p->externProtoPointer);
}
示例#3
0
static void sendToSS(struct X3D_Node *wsk, int key, int upDown) {
	int actionKey;
	#define MYN X3D_STRINGSENSOR(wsk)
	#define MAXSTRINGLEN 512

	/* printf ("SS, %u enabled %d\n",wsk, MYN->enabled); */
	/* printf ("sendToSS, key %x, upDown %d\n",key,upDown); */

	/* if not enabled, do nothing */
	if (!MYN) return;
	if (MYN->__oldEnabled != MYN->enabled) {
		MYN->__oldEnabled = MYN->enabled;
		MARK_EVENT(X3D_NODE(MYN),offsetof (struct X3D_StringSensor, enabled));
	}
	if (!MYN->enabled) return;
	/* printf ("sending key %x %u upDown %d to keySenors\n",key,key,upDown); */

	actionKey = platform2web3dActionKey(key);
	#if !defined(AQUA) && !defined(_MSC_VER)
	/* on Unix, we have to handle control/shift keys ourselves. OSX handles this
	   by itself */
	if (actionKey == SFT_KEY) {
		shiftPressed = (upDown == KEYDOWN);
		return;
	}

	/* do the shift of the A-Z keys if shift pressed */
	if ((key >= 'a') && (key<='z'))
		if (shiftPressed)
			key=key-'a'+'A';
	#endif

	/* ignore the control key here. OSX will not event let one come this far... */
	if (actionKey == CTL_KEY) return;

	/* we only care about key presses here */
	if (upDown != KEYDOWN) return;


	/* is this initialized? */
	if (!MYN->_initialized) {
		FREE_IF_NZ(MYN->enteredText->strptr);
		FREE_IF_NZ(MYN->finalText->strptr);
		MYN->enteredText->strptr = MALLOC(char *, MAXSTRINGLEN+1);
		MYN->finalText->strptr = MALLOC(char *, MAXSTRINGLEN+1);
		MYN->enteredText->len=1;
		MYN->finalText->len=1;
		MYN->enteredText->strptr[0] = '\0';
		MYN->finalText->strptr[0] = '\0';
		MYN->_initialized = TRUE;
		MYN->isActive = FALSE;
	}
示例#4
0
/* end of file on this "stack level" for lexer input */
static int setLexerNextIn(struct VRMLLexer *me) {
	int retval = EOF;

	#ifdef CPARSERVERBOSE
	printf ("set lexerNextIn called \n"); 
	#endif

	if (me->lexerInputLevel > 0) {
		#ifdef CPARSERVERBOSE
		printf ("setlexerNextIn, decrementing; deleting %x, setting nextIn to %x\n", me->startOfStringPtr[me->lexerInputLevel], me->oldNextIn[me->lexerInputLevel]); 
		#endif

		//FREE_IF_NZ (me->startOfStringPtr[me->lexerInputLevel]);
		if(me->startOfStringPtr[me->lexerInputLevel]){
			if(strlen(me->startOfStringPtr[me->lexerInputLevel])){
				FREE_IF_NZ(me->startOfStringPtr[me->lexerInputLevel]);
			}else{
				me->startOfStringPtr[me->lexerInputLevel] = NULL;
			}
		}
		me->nextIn = me->oldNextIn[me->lexerInputLevel];
		me->lexerInputLevel--;
		/* printf ("setlexerNextIn, level now is %d, and nextIn is :%s:\n",me->lexerInputLevel,me->nextIn); */
		retval = (int)*(me->nextIn++);
	}
	#ifdef CPARSERVERBOSE
	printf ("setLexerNextIn returning :%d:\n",retval);
	#endif

	return retval;
}
示例#5
0
void _X3D_setItemMF(X3DNode* node, int item, X3DNode* value)
{
	unsigned long sz;
	char * target;
	char * newstr;
	if( !isSF(value->type) )return; /* we're supposed to be setting an SF into an MF */
	if( node->type != value->type+1 )return; /* must be same type ie mfstring and sfstring, or mfvec2d and sfvec2d */
	if( item < 0 || item >= node->X3D_MFNode.n )return; /*space must have been allocated already, with swigNewMF(,#) or  _grow(,,#) */
	if( value->type == FIELDTYPE_SFString)
	{
		int len = min(value->X3D_SFString.len +1,STRLEN);
		/*free(node->X3D_MFString.p[item].strptr); /* better be reasonably initialized ie to NULL in newSF */
		FREE_IF_NZ(node->X3D_MFString.p[item].strptr);
		newstr = malloc(len*sizeof(char)); /**STRLEN);*/
		strncpy(newstr,value->X3D_SFString.strptr,len); /*policy - a string is owned by only one node (no ref counting). so deep copy so SF and MF both own their own*/
	}
	sz = X3D_sizeof(value->type);
	target = ((char *)(node->X3D_MFNode.p)) + sz*item;
	memcpy(target,value,sz);
	if( value->type == FIELDTYPE_SFString)
	{
		node->X3D_MFString.p[item].strptr = newstr;
		node->X3D_MFString.p[item].len = strnlen(newstr,STRLEN);
	}
}
示例#6
0
/* initialize a script from a url. Expects valid input */
BOOL script_initCodeFromMFUri(struct Shader_Script* me, const struct Multi_String* s) {
	size_t i;
	ppCScripts p = (ppCScripts)gglobal()->CScripts.prv;

	for(i=0; i!=s->n; ++i) {
		FREE_IF_NZ(p->buffer);
		if(script_initCodeFromUri(me, s->p[i]->strptr)) {
			FREE_IF_NZ(p->buffer);
   			return TRUE;
		}
	}

	/* failure... */
	FREE_IF_NZ(p->buffer);
 	return FALSE;
}
示例#7
0
void deleteScript(struct Shader_Script* me)
{
 size_t i;
 for(i=0; i!=vectorSize(me->fields); ++i)
  deleteScriptFieldDecl(vector_get(struct ScriptFieldDecl*, me->fields, i));
 deleteVector(struct ScriptFieldDecl*, me->fields);
 
 FREE_IF_NZ (me);
 /* FIXME:  JS-handle is not freed! */
}
示例#8
0
void killKeySensorNodeList() {
	ppComponent_KeyDevice p = (ppComponent_KeyDevice)gglobal()->Component_KeyDevice.prv;
	FREE_IF_NZ(p->keySink);
	p->keySyncMallocLen = 0; 
	p->keySinkCurMax = 0;

	#ifndef AQUA
	shiftPressed = 0;
	ctrlPressed = 0;
	#endif
}
示例#9
0
void lexer_forceStringCleanup (struct VRMLLexer *me) {
	int i;
	for (i=1; i<me->lexerInputLevel; i++) {
		FREE_IF_NZ(me->startOfStringPtr[i]);
		me->startOfStringPtr[i] = NULL;
	}
	#ifdef CPARSERVERBOSE
	printf ("lexer_forceStringCleanup, level was %d\n",me->lexerInputLevel);
	#endif

	me->lexerInputLevel = -1;
	me->nextIn = NULL;
}
示例#10
0
void deleteVector_(char *file, int line, int elSize, struct Vector** myp) {
#else
void deleteVector_(int elSize, struct Vector** myp) {
#endif

	struct Vector *me = *myp;

	if (!me) {
		ConsoleMessage ("Vector - already empty");
		return;
	}

	ASSERT(me);
	#ifdef DEBUG_MALLOC
		ConsoleMessage ("vector, deleting me %x data %x at %s:%d\n",me,me->data,file,line);
	#endif
	if(me->data) {FREE_IF_NZ(me->data);}
	FREE_IF_NZ(me);
	*myp = NULL;
}

/* Ensures there's at least one space free. */
void vector_ensureSpace_(int elSize, struct Vector* me) {
	ASSERT(me);
	if(me->n==me->allocn) {
		if(me->allocn) me->allocn*=2;
		else me->allocn=1;

		me->data=REALLOC(me->data, elSize*me->allocn);
		#ifdef DEBUG_MALLOC
			printf ("vector, ensureSpace, me %x, data %x\n",me, me->data);
		#endif
		ASSERT(me->data);
	}
	ASSERT(me->n<me->allocn);
}
示例#11
0
void compile_Arc2D (struct X3D_Arc2D *node) {
       /*  have to regen the shape*/
	struct SFVec2f *tmpptr_a, *tmpptr_b;
	int tmpint;

	MARK_NODE_COMPILED
	
	tmpint = 0;
	tmpptr_a = createLines (node->startAngle, node->endAngle, node->radius, NONE, &tmpint, node->_extent);

	/* perform the switch - worry about threading here without locking */
	node->__numPoints = 0;		/* tell us that it has zero points */
	tmpptr_b = node->__points.p;	/* old set of points, for freeing later */
	node->__points.p = tmpptr_a;	/* new points */
	node->__numPoints = tmpint;
	FREE_IF_NZ (tmpptr_b);
	/* switch completed */
	
}
示例#12
0
static void sendToKS(struct X3D_Node* wsk, int key, int upDown) {
	int actionKey;
	int isDown;
	#define MYN X3D_KEYSENSOR(wsk)
	/* printf ("sending key %x %u upDown %d (down %d) to keySenors\n",key,key,upDown,KEYDOWN); */
	
	/* if not enabled, do nothing */
	if (!MYN) 
		return;
	if (MYN->__oldEnabled != MYN->enabled) {
		MYN->__oldEnabled = MYN->enabled;
		MARK_EVENT(X3D_NODE(MYN),offsetof (struct X3D_KeySensor, enabled));
	}
	if (!MYN->enabled) 
		return;

	/* is this an ACTION (tm) key  press or release? */
	isDown = upDown == KeyPress;
	actionKey = platform2web3dActionKey(key);
	if(actionKey)
	{
	  switch (actionKey) {
		case HOME_KEY:
		case PGDN_KEY:
		case LEFT_KEY:
		case END_KEY:
		case UP_KEY:
		case RIGHT_KEY:
		case PGUP_KEY:
		case DOWN_KEY:
		case F1_KEY:
		case F2_KEY:
		case F3_KEY:
		case F4_KEY:
		case F5_KEY:
		case F6_KEY:
		case F7_KEY:
		case F8_KEY:
		case F9_KEY:
		case F10_KEY:
		case F11_KEY:
		case F12_KEY:
		/* no DEL key here*/
			if (isDown)  {
				MYN->actionKeyPress = actionKey; //TRUE; 
				MARK_EVENT(X3D_NODE(MYN), offsetof (struct X3D_KeySensor, actionKeyPress));
			} else {
				MYN->actionKeyRelease = actionKey; //TRUE;
				MARK_EVENT(X3D_NODE(MYN), offsetof (struct X3D_KeySensor, actionKeyRelease));
			}
			break;
		case ALT_KEY:
			/* now, for some of the other keys, the ones that are modifiers, not ACTION (tm) keys. */
			MYN->altKey = isDown;
			MARK_EVENT(X3D_NODE(MYN), offsetof (struct X3D_KeySensor, altKey));
			break;
		case CTL_KEY:
			MYN->controlKey = isDown;
			MARK_EVENT(X3D_NODE(MYN), offsetof (struct X3D_KeySensor, controlKey));
			break;
		case SFT_KEY:
			MYN->shiftKey = isDown;
			MARK_EVENT(X3D_NODE(MYN), offsetof (struct X3D_KeySensor, shiftKey));
			break;
		default:
			break;
	    }/*end switch */
	}  else { 
		/* regular key including RTN */
		if ((MYN->keyPress->len != 2) || (MYN->keyRelease->len != 2)) {
			FREE_IF_NZ(MYN->keyPress->strptr);
			FREE_IF_NZ(MYN->keyRelease->strptr);
			MYN->keyPress = newASCIIString ("a");
			MYN->keyRelease = newASCIIString ("a");
		}
			
		if (isDown) {
			MYN->keyPress->strptr[0] = (char) (key&0xFF);
			MARK_EVENT(X3D_NODE(MYN), offsetof (struct X3D_KeySensor, keyPress));
		} else {
			MYN->keyRelease->strptr[0] = (char) (key&0xFF);
			MARK_EVENT(X3D_NODE(MYN), offsetof (struct X3D_KeySensor, keyRelease));
		}
	}

	/* now, presumably "isActive" means that the key is down... */
	MYN->isActive = isDown;
	MARK_EVENT(X3D_NODE(MYN), offsetof (struct X3D_KeySensor, isActive));
	#undef MYN
	
}
示例#13
0
X3DNode* X3D_swigFieldFromString(char* fieldtype, char* values) 
{
	/* 
	issue: swig treats C arrays as opaque pointers - not very helpful. How to create an MF from a sequence of SF fields? 
	goal: convert string into a field - sf or mf - for easy use from swigged scripting language
	/* mf = X3D_fieldFromString("MFString","111.11 222.22"); will do SF as well */
	X3DNode* retval;
	int type,count;
	char* vals; /* **carray, *c; */
	int len,i,n,start,end, inum;
	float f, *farray, **f2,**f3,**f4;
	double d,*darray, **d2,**d3,**d4;
	char *token = NULL;
	char *delim = " ,";

	if(fieldtype == NULL || values == NULL) return NULL;
	type = findFieldInFIELDTYPES(fieldtype);
	/* if( type == -1 ) return NULL; Q. is there an error return code? Where is ffift defined? */
	/* do some qc */
	len = strlen(values);
	vals = (char*) malloc(len); 
	memcpy(vals,values,len); /* getnumtokens is destructive, and a const string produces error - so use copy from original*/
	switch (type) 
	{
	case FIELDTYPE_SFFloat:
		/*
		token = strtok(values,delim); 
		if( sscanf(token,"%f",&f) == 1)
			retval = X3D_newSFFloat(f);
		break;
		*/
	case FIELDTYPE_MFFloat:
	case FIELDTYPE_SFVec2f:
	case FIELDTYPE_MFVec2f:
	case FIELDTYPE_SFVec3f:
	case FIELDTYPE_MFVec3f:
	case FIELDTYPE_SFRotation:
	case FIELDTYPE_MFRotation:
	case FIELDTYPE_SFColorRGBA:
	case FIELDTYPE_MFColorRGBA:
	case FIELDTYPE_SFColor:
	case FIELDTYPE_MFColor:

		count = getnumtokens(vals,delim);
		farray = MALLOC(float *, count*sizeof(float));
		memcpy(vals,values,len);
		token = strtok(vals,delim);
		count  = 0;
		while (token != NULL) {
			if( sscanf(token,"%f",&f)==1 )/* = strtof(tokens);*/
			{
				farray[count] = f;
				count++;
			}
			token = strtok(NULL,delim);
		}
		f2 = MALLOC(float **, count*sizeof(float*));
		f3 = MALLOC(float **, count*sizeof(float*));
		f4 = MALLOC(float **, count*sizeof(float*));
		for(i=0;i<count;i++) 
		{
			f2[i] = &farray[i*2];
			f3[i] = &farray[i*3];
			f4[i] = &farray[i*4];
		}
		switch(type)
		{
			case FIELDTYPE_SFFloat:
				retval = X3D_newSFFloat(farray[0]);
			case FIELDTYPE_MFFloat:
				retval = X3D_newMFFloat(count, farray);	break;
			case FIELDTYPE_SFVec2f:
				retval = X3D_newSFVec2f(farray[0],farray[1]);break;
			case FIELDTYPE_SFVec3f:
				retval = X3D_newSFVec3f(farray[0],farray[1],farray[2]);break;
			case FIELDTYPE_MFVec3f:
				retval = X3D_newMFVec3f(count,f3);break;
			case FIELDTYPE_SFRotation:
				retval = X3D_newSFRotation(farray[0],farray[1],farray[2],farray[3]);break;
			case FIELDTYPE_MFRotation:
				retval = X3D_newMFRotation(count,f4);break;
			case FIELDTYPE_SFColorRGBA:
				retval = X3D_newSFColorRGBA(farray[0],farray[1],farray[2],farray[3]);break;
			case FIELDTYPE_MFColorRGBA:
				retval = X3D_newMFColorRGBA(count,f4);break;
			case FIELDTYPE_MFColor:
				retval = X3D_newMFColor(count,f3);break;

		}
		FREE_IF_NZ(farray);
		FREE_IF_NZ(f2);
		FREE_IF_NZ(f3);
		FREE_IF_NZ(f4);
		break;
	case FIELDTYPE_SFBool:
	case FIELDTYPE_SFInt32:
		token = strtok(values,delim); /*string delims*/
		if( sscanf(token,"%d",&inum) == 1)
		{
			if(type == FIELDTYPE_SFInt32) retval = X3D_newSFInt32(inum);
			if(type == FIELDTYPE_SFBool) retval = X3D_newSFBool(inum);
		}
		break;
	case FIELDTYPE_SFTime:
	case FIELDTYPE_SFVec2d:
	case FIELDTYPE_SFVec3d:
		count = getnumtokens(vals,delim);
		darray = MALLOC(double *, count*sizeof(double));
		memcpy(vals,values,len);
		token = strtok(vals,delim);
		count  = 0;
		while (token != NULL) {
			if( sscanf(token,"%lf",&d)==1 )/* = strtof(tokens);*/
			{
				darray[count] = d;
				count++;
			}
			token = strtok(NULL,delim);
		}
		d2 = MALLOC(double **, count*sizeof(double*));
		d3 = MALLOC(double **, count*sizeof(double*));
		d4 = MALLOC(double **, count*sizeof(double*));
		for(i=0;i<count;i++) 
		{
			d2[i] = &darray[i*2];
			d3[i] = &darray[i*3];
			d4[i] = &darray[i*4];
		}
		switch(type)
		{
			case FIELDTYPE_SFTime:
				retval = X3D_newSFTime(darray[0]); break;
			case FIELDTYPE_SFVec2d:
				retval = X3D_newSFVec2d(darray[0],darray[1]);break;
			case FIELDTYPE_SFVec3d:
				retval = X3D_newMFVec3d(count,d3); break;
		}
		FREE_IF_NZ(darray);
		FREE_IF_NZ(d2);
		FREE_IF_NZ(d3);
		FREE_IF_NZ(d4);
		break;


	case FIELDTYPE_SFString:
		/*
		retval->X3D_SFString.type = FIELDTYPE_SFString;
		len = strlen(values);
		retval->X3D_SFString.p[count].strptr = MALLOC(char *, (len+1)*sizeof(char));
		strncpy(retval->X3D_SFString.p[count].strptr,values,len);
		retval->X3D_SFString.strptr[len] = '\0';
		retval->X3D_SFString.len = len;
		*/
		retval = X3D_newSFString(values);
		break;

	case FIELDTYPE_MFString:
		retval = malloc(sizeof(X3DNode));
		retval->X3D_MFString.type = FIELDTYPE_MFString; 
		n = 0;
		for(i=0;i<(int)strlen(vals);i++)
			if( vals[i] == '\"' )n++;
		n = n/2;
		/*
		c = MALLOC(char *, n*STRLEN*sizeof(char));
		carray = MALLOC(char **, n*(sizeof(char*)));
		for(i=0;i<n;i++)
			carray[i] = &c[i*STRLEN];
		*/
		retval->X3D_MFString.n = n;
		retval->X3D_MFString.p = malloc(sizeof(X3DNode)*retval->X3D_MFString.n);
		count = 0;
		for(i=0,n=0;i<(int)strlen(vals);i++)
		{
			if( vals[i] == '\"' )
			{ 
				n++;
				if(n%2) start = i;
				else
				{
					end = i;
					len = end - start; /* if "Y" start=0,end=2 need a string 2 long for Y and \0. len=end-start= 2-0=2 */
					retval->X3D_MFString.p[count].strptr = MALLOC(char *, len*sizeof(char));
					strncpy(retval->X3D_MFString.p[count].strptr,&vals[start+1],len-1);
					/*strncpy(carray[count],&vals[start+1],len-1);
					carray[count][len-1] = '\0';*/
					retval->X3D_MFString.p[count].strptr[len-1] = '\0';
					retval->X3D_MFString.p[count].len = len-1;
					count++;
				}
			}
		}
		/*retval = X3D_newMFString(count, carray);*/
		break;
	}
示例#14
0
void deleteScriptFieldDecl(struct ScriptFieldDecl* me)
{
 deleteFieldDecl(me->fieldDecl);
 FREE_IF_NZ (me);
}
示例#15
0
int main(int argc, char* argv[])
{
	X3DNode *mff,*sff,*sff2,*sff3;

/*tests for newMF,setItem,getItem,appendToMF */
	if(1)
	{
	printf("before init - please run browser with root.wrl --eai :");
	getchar();
	X3D_initialize("");
	printf("after init:");
	getchar();
	printf("version=%s %s\n",X3D_getVersion(),X3D_getName());
	}
	if(1)
	{
	sff = X3D_newSFFloat(33.33f);
	printf("sff.val=%f type=%d\n",sff->X3D_SFFloat.value,sff->X3D_SFFloat.type);
	mff = X3D_swigNewMF("SFFloat",2);
	X3D_swigSetItem(mff,0,sff);
	sff->X3D_SFFloat.value = 44.44f;
	X3D_swigSetItem(mff,1,sff);
	printf("loaded 2 sfs into an mf\n");
	sff2 = X3D_swigGetItem(mff,0);
	printf("sff2 mf[0] .val=%f .type=%ld\n",sff2->X3D_SFFloat.value,sff2->X3D_SFFloat.type);
	sff3 = X3D_swigGetItem(mff,1);
	printf("sff3 mf[1] .val=%f .type=%ld\n",sff3->X3D_SFFloat.value,sff3->X3D_SFFloat.type);
	X3D_freeNode(sff);
	X3D_freeNode(mff);
	X3D_freeNode(sff2);
	X3D_freeNode(sff3);
	}
	if(1)
	{
	sff = X3D_newSFFloat(33.33f);
	printf("sff.val=%f type=%d\n",sff->X3D_SFFloat.value,sff->X3D_SFFloat.type);
	mff = X3D_swigNewMF("SFFloat",0);
	X3D_swigAppendToMF(mff,sff);
	sff->X3D_SFFloat.value = 44.44f;
	X3D_swigAppendToMF(mff,sff);
	printf("loaded 2 sfs into an mf\n");
	sff2 = X3D_swigGetItem(mff,0);
	printf("sff2 mf[0] .val=%f .type=%ld\n",sff2->X3D_SFFloat.value,sff2->X3D_SFFloat.type);
	sff3 = X3D_swigGetItem(mff,1);
	printf("sff3 mf[1] .val=%f .type=%ld\n",sff3->X3D_SFFloat.value,sff3->X3D_SFFloat.type);
	X3D_freeNode(sff);
	X3D_freeNode(mff);
	X3D_freeNode(sff2);
	X3D_freeNode(sff3);

	}
/* tests for fieldFromString and stringFromField */
	if(1)
	{
	 /*tests the mf = X3D_fieldFromString("MFString","111.11 222.22"); */
	 X3DNode* mfs,*mff,*sf;
	 char *str[4];
	 int i,j;
	 mfs = X3D_swigNewMF("MFString",2);
	 /*mfs2 = X3D_fieldFromString("MFString"," \"Howdy\" \"Partner\" ");*/
	 str[0] = " 1234.567,891011.23 ";
	 str[1] = "333.33 444.44";
	 str[2] = "666.66 -777.77,";
	 str[3] = "'88.8''99.9'";
	 for(i=0;i<4;i++)
	 {
		 printf("str=%s ",str[i]);
		 mff = X3D_swigFieldFromString("MFFloat",str[i]); /*" 1234.567,891011.23 ");*/
		 for(j=0;j<mff->X3D_MFString.n;j++)
		 {
			sf = X3D_swigGetItem(mff,j);
			printf("sf[%d]=%f ",j,sf->X3D_SFFloat.value);
		 }
		 printf("\n");
	 }
	}
	if(1)
	{
	 /*tests the string = X3D_stringFromField(X3DNode* field); */
	 X3DNode* mfs,*mff,*sf;
	 char *str,*str2;
	 int i,j, itype, ismf, count;
	 mff = X3D_swigFieldFromString("MFFloat","111.11 -222.22 333.33 -444.44");
	 str = X3D_swigStringFromField(mff);
	 sscanf(str,"%d %d",&itype,&count);
	 ismf = itype % 2;
	 printf("type=%d count=%d str=%s\n",itype,count,str);
	 /*free(str);*/
	 FREE_IF_NZ(str);
	
	 mfs = X3D_swigFieldFromString("MFString","\"Howdy\" \"from\" \"my ol' script.\"");
	 printf("OK did a field\n");
	 str2 = X3D_swigStringFromField(mfs);
	 printf("mfs str=[%s]\n",str2);
	 //X3D_freeNode(mff);
	 X3D_freeNode(mfs);
	 /* OK now parse string */
 	 sscanf(str2,"%d %d",&itype,&count);
	 printf("type=%d count=%d\n",itype,count);
	 if( itype == findFieldInFIELDTYPES("MFString") )
	 {
		 for(i=0;i<count;i++)
		 {
			 /* hard work like in the EAI_C_Field swig parsing functions or nextToken */
		 }

	 }

	 /*free(str2);*/
	 FREE_IF_NZ(str2);

	 /*
	 delim = " ,";
	 if( itype == FIELDTYPE_MFString || itype == FIELDTYPE_SFString )
		 delim = "\"";

	 str[0] = " 1234.567,891011.23 ";
	 str[1] = "333.33 444.44";
	 str[2] = "666.66 -777.77,";
	 str[3] = "'88.8''99.9'";
	 for(i=0;i<4;i++)
	 {
		 printf("str=%s ",str[i]);
		 mff = X3D_fieldFromString("MFFloat",str[i]); 
		 for(j=0;j<mff->X3D_MFString.n;j++)
		 {
			sf = X3D_getItem(mff,j);
			printf("sf[%d]=%f ",j,sf->X3D_SFFloat.value);
		 }
		 printf("\n");
	 }
	 */
	}

	printf("hi from main\n");
	getchar();
	return 0;
}