32#include <libFreeWRL.h>
38#include "scenegraph/Vector.h"
39#include "vrml_parser/Structs.h"
40#include "main/headers.h"
41#include "vrml_parser/CParseGeneral.h"
42#include "vrml_parser/CFieldDecls.h"
43#include "world_script/JScript.h"
44#include "world_script/CScripts.h"
45#include "world_script/fieldSet.h"
46#include "vrml_parser/CParseParser.h"
47#include "vrml_parser/CParseLexer.h"
48#include "vrml_parser/CParse.h"
49#include "input/InputFunctions.h"
50#include "input/EAIHeaders.h"
51#include "input/EAIHelpers.h"
53#include "x3d_parser/X3DParser.h"
121#ifndef __LIBFREEWRL_DECL_H__
122#define __LIBFREEWRL_DECL_H__
125#ifdef FREEWRL_THREAD_COLORIZED
128#define PRINTF printf_with_colored_threads
129extern int printf_with_colored_threads(
const char *format, ...);
130#define FPRINTF fprintf_with_colored_threads
131extern int fprintf_with_colored_threads(FILE *stream,
const char *format, ...);
136#define FPRINTF fprintf
140#define BOOL_STR(b) (b ? "TRUE" : "FALSE")
144# define DEBUG_(_expr) _expr
146# define DEBUG_(_expr)
151void fw_perror(FILE *f,
const char *format, ...);
153#if defined(WRAP_MALLOC) || defined(DEBUG_MALLOC)
154void freewrlFreeAllRegisteredAllocations();
155bool freewrlIsRegisteringAllocation();
156void freewrlSetShouldRegisterAllocation(
bool shouldRegisterAllocation);
157void freewrlInitMemTable();
158void freewrlDisposeMemTable();
168int DEBUG_FPRINTF(
const char *fmt, ...);
169#define DEBUG_MSG DEBUG_FPRINTF
170#define TRACE_MSG DEBUG_FPRINTF
171#define WARN_MSG DEBUG_FPRINTF
172#define ERROR_MSG DEBUG_FPRINTF
173#define PERROR_MSG DEBUG_FPRINTF
174#define DEBUG_MEM DEBUG_FPRINTF
175#define DEBUG_RENDER DEBUG_FPRINTF
176#define DEBUG_TEX DEBUG_FPRINTF
177#define DEBUG_X3DPARSER DEBUG_FPRINTF
178#define DEBUG_SHADER DEBUG_FPRINTF
179#define DEBUG_RES DEBUG_FPRINTF
180#define DEBUG_CPARSER DEBUG_FPRINTF
201#define DEBUG_MSG(...) DEBUG_(FPRINTF(stdout, __VA_ARGS__))
202#define TRACE_MSG(...) DEBUG_(FPRINTF(stdout, __VA_ARGS__))
203#define WARN_MSG(...) DEBUG_(FPRINTF(stdout, __VA_ARGS__))
205#define ERROR_MSG(...) FPRINTF(stderr, __VA_ARGS__)
206#define PERROR_MSG(...) fw_perror(stderr, __VA_ARGS__)
208#define DEBUG_FW(...) DEBUG_(PRINTF("FW: " __VA_ARGS__))
213#define DEBUG_RES(...) DEBUG_(PRINTF("RES: " __VA_ARGS__))
215#define DEBUG_RES(...)
219#define DEBUG_TEX(...) DEBUG_(PRINTF("TEXTURE: " __VA_ARGS__))
221#define DEBUG_TEX(...)
225#define DEBUG_MEM(...) DEBUG_(PRINTF("MEM: " __VA_ARGS__))
227#define DEBUG_MEM(...)
231#define DEBUG_CPARSER(...) DEBUG_(PRINTF("CPARSER: " __VA_ARGS__))
233#define DEBUG_CPARSER(...)
237#define DEBUG_CPROTO(...) DEBUG_(PRINTF("CPROTO: " __VA_ARGS__))
239#define DEBUG_CPROTO(...)
242#ifdef PLUGINSOCKETVERBOSE
243#define DEBUG_PLUGINSOCKET(...) DEBUG_(PRINTF("PLUGINSOCKET: " __VA_ARGS__))
245#define DEBUG_PLUGINSOCKET(...)
250#define DEBUG_CR(...) DEBUG_(PRINTF("CR: " __VA_ARGS__))
256#ifdef JSVRMLCLASSESVERBOSE
257#define DEBUG_JSVRMLCLASSES(...) DEBUG_(PRINTF("JSVRMLCLASSES: " __VA_ARGS__))
259#define DEBUG_JSVRMLCLASSES(...)
262#ifdef JAVASCRIPTVERBOSE
263#define DEBUG_JS(...) DEBUG_(PRINTF("JS: " __VA_ARGS__))
268#ifdef SETFIELDVERBOSE
269#define DEBUG_SETFIELD(...) DEBUG_(PRINTF("SETFIELD: " __VA_ARGS__))
271#define DEBUG_SETFIELD(...)
275#define DEBUG_RENDER(...) DEBUG_(PRINTF("RENDER: " __VA_ARGS__))
277#define DEBUG_RENDER(...)
281#define DEBUG_CHILD(...) DEBUG_(PRINTF("CHILD: " __VA_ARGS__))
283#define DEBUG_CHILD(...)
288#define DEBUG_SE(...) DEBUG_(PRINTF("SE: " __VA_ARGS__))
293#ifdef STREAM_POLY_VERBOSE
294#define DEBUG_STREAM_POLY(...) DEBUG_(PRINTF("STREAM_POLY: " __VA_ARGS__))
296#define DEBUG_STREAM_POLY(...)
299#ifdef OCCLUSIONVERBOSE
300#define DEBUG_OCCLUSION(...) DEBUG_(PRINTF("OCCLUSION: " __VA_ARGS__))
302#define DEBUG_OCCLUSION(...)
306#define DEBUG_FRUSTUM(...) DEBUG_(PRINTF("FRUSTUM: " __VA_ARGS__))
308#define DEBUG_FRUSTUM(...)
312#define DEBUG_SHADER(...) DEBUG_(PRINTF("SHADER: " __VA_ARGS__))
314#define DEBUG_SHADER(...)
318#define DEBUG_BIND(...) DEBUG_(PRINTF("BIND: " __VA_ARGS__))
320#define DEBUG_BIND(...)
324#ifdef X3DPARSERVERBOSE
325#define DEBUG_X3DPARSER(...) DEBUG_(PRINTF("X3DPARSER: " __VA_ARGS__))
327#define DEBUG_X3DPARSER(...)
331#ifdef CAPABILITIESVERBOSE
332#define DEBUG_CAPABILITIES(...) DEBUG_(PRINTF("CAPABILITIES: " __VA_ARGS__))
334#define DEBUG_CAPABILITIES(...)
339#define DEBUG_SENS(...) DEBUG_(PRINTF("SENS: " __VA_ARGS__))
341#define DEBUG_SENS(...)
345#define DEBUG_SOUND(...) DEBUG_(PRINTF("SOUND: " __VA_ARGS__))
347#define DEBUG_SOUND(...)
351#define DEBUG_FILL(...) DEBUG_(PRINTF("FILL: " __VA_ARGS__))
353#define DEBUG_FILL(...)
357#define DEBUG_TEXT(...) DEBUG_(PRINTF("TEXT: " __VA_ARGS__))
359#define DEBUG_TEXT(...)
363#define DEBUG_ARGS(...) DEBUG_(PRINTF("TEXT: " __VA_ARGS__))
365#define DEBUG_ARGS(...)
369#define DEBUG_XEV(...) DEBUG_(PRINTF("XEV: " __VA_ARGS__))
371#define DEBUG_XEV(...)
375void *mallocn_debug(
int line,
char *file,
void *node,
size_t size);
376void *reallocn_debug(
int line,
char *file,
void *node,
void *pold,
size_t newsize);
377void *mallocn(
void *node,
size_t size);
378void *reallocn(
void *node,
void *pold,
size_t newsize);
385# define TEMPNAM _tempnam
387# define TEMPNAM tempnam
390#if defined(WRAP_MALLOC) || defined(DEBUG_MALLOC)
392void *freewrlMalloc(
int line,
char *file,
size_t sz,
int zeroData);
393void *freewrlRealloc(
int line,
char *file,
void *ptr,
size_t size);
394void freewrlFree(
int line,
char *file,
void *a);
395void *freewrlStrdup(
int line,
char *file,
char *str);
396void *freewrlStrndup(
int line,
char *file,
const char *str,
size_t n);
397#define MALLOCN(_node,_sz) (mallocn_debug(__LINE__,__FILE__,_node,_sz))
398#define REALLOCN(_node,_oldp,_newsz) (reallocn_debug(__LINE__,__FILE__,_node,_oldp,_newsz))
399# define MALLOCV(_sz) (freewrlMalloc(__LINE__, __FILE__, _sz, FALSE))
400# define MALLOC(t,_sz) ((t)freewrlMalloc(__LINE__, __FILE__, _sz, FALSE))
401# define CALLOC(_fill, _sz) freewrlMalloc(__LINE__, __FILE__, _fill * _sz, TRUE);
402# define REALLOC(_a,_b) freewrlRealloc(__LINE__, __FILE__, _a, _b)
403# define FREE(_ptr) freewrlFree(__LINE__, __FILE__, _ptr)
405# define XALLOC(_type) (_type *) CALLOC(1, sizeof(_type))
406# define XFREE(_ptr) {if (_ptr) { FREE(_ptr); _ptr = NULL; }}
408# define STRDUP(_a) freewrlStrdup(__LINE__, __FILE__, _a)
410# define STRNDUP(_a, _n) freewrlStrndup(__LINE__, __FILE__, _a, _n)
412# define UNLINK(_fdd) do { \
413 TRACE_MSG("TRACE: unlink %s at %s:%d\n",_fdd,__FILE__,__LINE__); \
417# define TEMPNAM(_dir,_pfx) tempnam(_dir, _pfx); do { \
418 TRACE_MSG("TRACE: tempnam %s/%s at %s:%d\n", _dir, _pfx, __FILE__, __LINE__); \
421# define ASSERT(_ptr) do { if (!(_ptr)) { \
422 ERROR_MSG("ERROR: assert failed: %s (%s:%d)\n", #_ptr, __FILE__, __LINE__); } \
425# define UNLINK unlink
426# define TEMPNAM tempnam
429# define ASSERT(_ptr) do { if (!(_ptr)) { \
430 ERROR_MSG("ERROR: assert failed: %s (%s:%d)\n", #_ptr, __FILE__, __LINE__); } \
436#define MALLOCN(_node,_sz) (mallocn(_node,_sz))
437#define REALLOCN(_node,_oldp,_newsz) (reallocn(_node,_oldp,_newsz))
439# define MALLOCV(_sz) (malloc(_sz))
440# define MALLOC(t,_sz) ((_sz > 0) ? (t)malloc(_sz) : NULL)
441# define REALLOC realloc
444# define XALLOC(_type) (_type *) calloc(1, sizeof(_type))
445# define XFREE(_ptr) {if (_ptr) { free(_ptr); _ptr = NULL; }}
447# define STRDUP strdup
448# define STRNDUP strndup
449# define UNLINK unlink
450# define TEMPNAM tempnam
452# define ASSERT(_whatever)
456#if defined(_MSC_VER) && defined(W_DEBUG)
457#define CHECK_MEMORY check_memory();
464#define FREE_IF_NZ(_ptr) {if (_ptr) { \
468 DEBUG_MEM("double free: %s:%d\n", __FILE__, __LINE__); \
475#define PTR_REPLACE(_ptr,_newptr) do { \
476 if (_ptr != _newptr) { \
478 DEBUG_MSG("replacing ptr %p with %p\n", _ptr, _newptr); \
482 DEBUG_MSG("ptr newly assigned value %p\n", _newptr); \
486 DEBUG_MSG("replacing ptr with the same value (warning)\n"); \
489#define PTR_REPLACE_DUP(_ptr,_newptr) do { \
490 if (_ptr != _newptr) { \
492 DEBUG_MSG("replacing ptr %p with %p\n", _ptr, _newptr); \
494 _ptr = STRDUP(_newptr); \
496 DEBUG_MSG("ptr newly assigned value %p\n", _newptr); \
497 _ptr = STRDUP(_newptr); \
500 DEBUG_MSG("replacing ptr with the same value (warning)\n"); \
504void register_node_gc(
void *node,
void *p);
505void unregister_node_gc(
void *node,
void *p);
506void free_registered_node_gc(
void *node);
514#define HAVE_BOOLEAN 1
520#define HAVE_BOOLEAN 1
524#define M_PI 3.14159265358979323846
547const char *getNodeName(
struct X3D_Node *node);