You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by jd...@apache.org on 2009/04/22 19:25:51 UTC

svn commit: r767594 [6/43] - in /incubator/etch/trunk/binding-c/runtime/c: ./ ext/ ext/hashtab/ ext/lib/ inc/ lib/ project/ project/$etchstop/ project/bin/ project/etch/ project/logcli/ project/logsrv/ project/notes/ project/test/ project/test/logcli/ ...

Added: incubator/etch/trunk/binding-c/runtime/c/inc/etchhash.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etchhash.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etchhash.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etchhash.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,227 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/*
+ * etchhash.h 
+ * etch hashtable 
+ */
+
+#ifndef ETCHHASH_H
+#define ETCHHASH_H
+
+#include "etch.h"
+#include "etch_collection.h"
+
+#define MAX_INITIAL_HASHTABLE_SIZE  32768
+#define MIN_INITIAL_HASHTABLE_SIZE  4
+#define ETCH_DEFAULT_HASHTABLE_SIZE 16
+#define ETCHHASHTABLE_CONTENT_OPAQUE        0
+#define ETCHHASHTABLE_CONTENT_OBJECT        1   /* opaque key */
+#define ETCHHASHTABLE_CONTENT_INT_OBJECT    2   
+#define ETCHHASHTABLE_CONTENT_LONG_OBJECT   3
+#define ETCHHASHTABLE_CONTENT_STRING_OBJECT 4
+#define ETCHHASHTABLE_CONTENT_OBJECT_OBJECT 5   /* etch_map */
+#define ETCHHASHTABLE_CONTENT_OBJECT_NONE   6   /* etch_set */
+
+#define HASHTABLE_DEFAULT_READONLY_KEYS   TRUE
+#define HASHTABLE_DEFAULT_READONLY_VALUES TRUE
+#define HASHTABLE_DEFAULT_TRACKED_MEMORY  TRUE
+#define HASHTABLE_DEFAULT_CONTENT_TYPE    0
+
+typedef int (*mapcallback) (void*, void*); /* hashtable callback signature */
+
+int string_to_object_clear_handler (wchar_t* key, objmask* value); 
+int object_to_object_clear_handler (objmask* key, objmask* value);  
+int etch_noop_clear_handler (objmask* key, objmask* value);  
+ 
+
+
+/** 
+ *  etch_hashitem  
+ *  an entry in a hashtable. 
+ */
+typedef struct etch_hashitem
+{
+    char* key;
+    void* value; 
+    unsigned hash;
+       
+} etch_hashitem;
+
+
+/** 
+ * the etch C hashtable interface.
+ * all methods of this interface should have implementations (i.e. not be null).
+ */
+typedef struct i_hashtable    
+{
+    unsigned int    hashkey;    
+    unsigned short  obj_type; 
+    unsigned short  class_id;
+    struct i_hashtable* vtab;
+    int  (*destroy)(void*);
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;
+    struct objmask* parent;
+    etchresult*     result;
+    unsigned int    refcount;       
+    unsigned int    length;     
+    unsigned char   is_null;    
+    unsigned char   is_copy;   
+    unsigned char   is_static;  
+    unsigned char   reserved;
+
+    etchparentinfo* inherits_from; 
+
+    int (*create)  (const int size,  void* in, void** out);
+
+    int (*hdestroy)(void* realtable, void* in, void** out);
+
+    int (*insert)  (void* realtable, void* key, const int keylen, 
+                    void* data, const int datalen, void* in, void** out);
+
+    int (*inserth) (void* realtable, void* key, void* data, 
+                    void* in, void** out);
+
+    int (*find)    (void* realtable, void* key, const int keylen, 
+                    void* in, void** out);
+
+    int (*findh)   (void* realtable, const unsigned key, void* in, void** out);
+
+    int (*first)   (void* realtable, void* in, void** out);
+
+    int (*next)    (void* realtable, void* in, void** out);
+
+    int (*current) (void* realtable, void* in, void** out);
+
+    int (*remove)  (void* realtable, void* key, const int keylen, 
+                    void* in, void** out);
+
+    int (*removeh) (void* realtable, const unsigned key, void* in, void** out);
+
+    int (*clear)   (void* realtable, const int freekey, const int freeval,
+                    void* in, void** out);
+
+    int (*count)   (void* realtable, void* in, void** out);
+
+    int (*size)    (void* realtable, void* in, void** out);
+
+    int (*stats)   (void* realtable, void* in, void** out);
+
+    int (*hash)    (void* realtable, void* key, const int keylen, 
+                    const int priorhash, void* in, void** out); 
+
+} i_etch_hashtable;
+
+
+/**
+ * etch_hashtable
+ * hashtable object
+ */
+typedef struct etch_hashtable   
+{
+    unsigned int    hashkey;
+    unsigned short  obj_type; 
+    unsigned short  class_id;
+    struct i_hashtable* vtab;
+    int  (*destroy)(void*);
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;
+    struct objmask* parent;
+    etchresult*     result;
+    unsigned int    refcount;
+    unsigned int    length;
+    unsigned char   is_null;
+    unsigned char   is_copy;
+    unsigned char   is_static;
+    unsigned char   reserved;
+                            
+    void* realtable;  /* implementation's hashtable object */
+    unsigned short content_obj_type; /* todo: populate */  
+    unsigned short content_class_id; /* todo: populate */ 
+    unsigned char is_readonly_keys;
+    unsigned char is_readonly_values;
+    unsigned char is_tracked_memory;
+    unsigned char content_type; 
+      
+    /* this object may be masked by etch_collection_mask to determine content
+     * type and class, so do not add any fields above this comment */
+
+    i_iterable  iterable;   /* iterable interface */
+    mapcallback freehook;   /* clear() callback if any */
+    mapcallback synchook;   /* hook for list synchronization */
+    void*       synclock;   /* synchronization mutex */
+
+} etch_hashtable;
+
+
+etch_hashtable* new_hashtable(const int initialsize);
+etch_hashtable* new_etch_hashtable();
+etch_hashtable* new_etch_map(const int initialsize);
+etch_hashtable* new_etch_set(const int initialsize);
+int  destroy_hashtable(etch_hashtable* hashtable, const int is_free_k, const int is_free_v);
+
+typedef etch_hashtable etch_set;
+etch_set* new_set(const int initialsize);
+
+#define is_etch_set(x) (x && (x->obj_type == ETCHTYPEB_HASHTABLE) \
+ && (((etch_hashtable*)x)->content_type == ETCHHASHTABLE_CONTENT_OBJECT_NONE))
+
+int jenkins_insert (void* realtable, void* key, const int keylen, 
+    void* data, const int datalen, void* in, void** out);
+int jenkins_inserth(void* realtable, void* key, void* data, void* in, void** out);
+int jenkins_find   (void* realtable, void* key, const int keylen, void* in, void** out);
+int jenkins_findh  (void* realtable, const unsigned int hashed, void* in, void** out);
+int jenkins_first  (void* realtable, void* in, void** out);
+int jenkins_next   (void* realtable, void* in, void** out);
+int jenkins_current(void* realtable, void* in, void** out);
+int jenkins_remove (void* realtable, void* key, const int keylen, void* in, void** out);
+int jenkins_clear  (void* realtable, const int freekey, const int freeval, void* in, void** out);
+int jenkins_count  (void* realtable, void* in, void** out);
+int jenkins_size   (void* realtable, void* in, void** out); 
+int jenkins_stats  (void* realtable, void* in, void** out);
+int jenkins_hash   (void* realtable, char* key, const int keylen, 
+    const int priorhash, void* in, void** out);
+int jenkins_hashx  (char* key, const int keylen, const int priorhash);  
+int jenkins_destroy(void* realtable, void* in, void** out); 
+int jenkins_create (const int initialsize_items, void* in, void** out);
+etch_hashtable* ctor_jenkins_hashtable(const int initialsize_bits);
+etch_hashtable* new_systemhashtable   (const int initialsize_items);
+void delete_systemhashtable(etch_hashtable*);
+
+
+/* 
+ * explicit synchronization locking methods.
+ * these should be used only for locking a map during map iteration.   
+ * for synchronization of map operations, the presence of map.synchook  
+ * and map.synclock is sufficient. 
+ */
+int   hashtable_getlock (etch_hashtable*);
+int   hashtable_trylock (etch_hashtable*);
+int   hashtable_rellock (etch_hashtable*);
+
+int   hashtable_defsynchook(void* action, void* mutex);
+
+
+/* i_iterable function overrides */
+int   hashtable_iterable_first   (etch_iterator*);
+int   hashtable_iterable_next    (etch_iterator*);
+int   hashtable_iterable_has_next(etch_iterator*);
+
+
+#endif /* #ifndef ETCHHASH_H */
\ No newline at end of file

Added: incubator/etch/trunk/binding-c/runtime/c/inc/etchlog.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etchlog.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etchlog.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etchlog.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,61 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/* 
+ * etchlog.h 
+ * logger for the c binding
+ */
+#ifndef ETCHLOG_H
+#define ETCHLOG_H
+
+#include "etch_config.h"  
+
+ typedef enum etchlog_level 
+ {  ETCHLOG_XDEBUG = 0, /* extended debug for low-level or voluminous detail */
+    ETCHLOG_DEBUG,      /* traces of connection open close send receive etc */
+    ETCHLOG_INFO,       /* display server and client open and close etc */
+    ETCHLOG_WARNING,    /* messages that should be noted regardless */
+    ETCHLOG_ERROR,      /* failures */
+ } etchlog_level;
+ 
+ /**
+  * etchlog(), etchlogw()
+  * write a log message to console/file/system log depending on configuration.
+  * @param cat the category name for this message. should be four characters,
+  * upper case, identifying the module originating the log message.
+  * @param level logging level of the message. 
+  * @param fmt the format string ala printf.
+  * @... a variable length argument list ala printf.
+  */
+void  etchlog (char *cat, etchlog_level level, const char *fmt, ...);
+
+void  etchlogw (wchar_t *comp, etchlog_level level, const wchar_t *fmt, ...);
+
+int   etchlog_open (const int is_client);
+int   etchlog_openx(char* filepath);
+int   etchlog_open_client();
+int   etchlog_open_server();
+int   etchlog_close();
+int   etchlog_write(char*);
+int   etchlog_get_logfile_count();
+void  etchlog_set_logfile_count(const int);
+char* etchlog_get_dirpath();
+
+
+#endif /* ETCHLOG_H */
+ 
\ No newline at end of file

Added: incubator/etch/trunk/binding-c/runtime/c/inc/etchmap.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etchmap.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etchmap.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etchmap.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,64 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/* 
+ * etchmap.h -- generic string to object map
+ */
+
+#ifndef ETCHMAP_H
+#define ETCHMAP_H
+
+#include "etch.h"
+#include "etchhash.h"
+
+#define ETCHMAP_MAX_IKEYSIZE 31
+
+void* etchmap_find         (etch_hashtable*, const unsigned int key, void** out);
+void* etchmap_findx        (etch_hashtable*, char* key, void** out);
+void* etchmap_findxw       (etch_hashtable*, wchar_t* key, void** out);
+void* etchmap_findxl       (etch_hashtable*, char* key, unsigned keylen, void** out);
+void* etchmap_find_by_hash (etch_hashtable*, const unsigned hash, void** out);
+
+void* etchmap_del          (etch_hashtable*, const unsigned int key);
+void* etchmap_delx         (etch_hashtable*, char* key);
+void* etchmap_delxw        (etch_hashtable*, wchar_t* key);
+void* etchmap_delxl        (etch_hashtable*, char* ckey, const unsigned keylen);
+
+int etchmap_add            (etch_hashtable*, const unsigned int key, void* data);
+int etchmap_addx           (etch_hashtable*, char* key, void* data);
+int etchmap_addxw          (etch_hashtable*, wchar_t* key, void* data);
+int etchmap_insert         (etch_hashtable*, const unsigned, void*, const int is_check);
+int etchmap_insertx        (etch_hashtable*, char* key, void* data, const int is_check);
+int etchmap_insertxw       (etch_hashtable*, wchar_t* key, void* data, const int is_check);
+int etchmap_insertxl       (etch_hashtable*, char*, const unsigned, void*, const int); 
+int etchmap_insertxlw      (etch_hashtable*, wchar_t*, const unsigned, void*, const int); 
+
+int etchmap_count(etch_hashtable*);
+
+etch_hashitem* etchmap_current(etch_hashtable*);
+
+int etchmap_map_add (etch_hashtable* map, objmask* key, objmask* value); 
+int etchmap_map_find(etch_hashtable* map, objmask* key, etch_hashitem** out);
+int etchmap_set_add (etch_hashtable* set, objmask* key); 
+int etchmap_is_object_key(etch_hashtable*);
+
+int string_to_etchobject_clear_handler    (char* key, objmask* value);  
+int string_to_genericobject_clear_handler (char* key, void* value);  
+
+
+#endif /* #ifndef ETCHMAP_H*/ 
\ No newline at end of file

Added: incubator/etch/trunk/binding-c/runtime/c/inc/etchmem.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etchmem.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etchmem.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etchmem.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,108 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/*
+ * etchmem.h -- heap memory allocate and free.
+ * The c binding wraps the heap allocator in order to track allocations. we supply 
+ * the etch_malloc macro which, when ETCH_DEBUGALLOC is defined,  will accept module 
+ * name and code line number, along with object type and allocation size, in order  
+ * to track heap allocations and frees, and to subsequently report memory leaks. 
+ */
+
+#ifndef ETCHMEM_H
+#define ETCHMEM_H
+
+#include "etch.h"
+#include "etchhash.h"
+
+
+#define ETCH_DEBUGALLOC
+
+/*
+ * map etch_malloc() to the standard allocator or the debug allocator, 
+ * depending on whether ETCH_DEBUGALLOC is defined. likewise etch_free().
+ */
+#ifdef  ETCH_DEBUGALLOC
+
+void* debug_malloc(size_t nbytes, const short objtype, char* file, const short line);
+void* debug_realloc(void* p, size_t nbytes, const short objtype, char* file, const short line);
+int   debug_free(void* p, char* file, const short line); /* __FILE__ is not unicode */ 
+int   debug_showmem(const int is_freeitem, const int is_console);
+void  debug_dumpmem();
+
+#define etch_malloc(n,o) debug_malloc(n,o,__FILE__,(const short) __LINE__)
+#define etch_realloc(p,n,o) debug_realloc(p,n,o,__FILE__,(const short) __LINE__)
+#define etch_free(n) debug_free(n,__FILE__,(const short) __LINE__)
+#define etch_showmem(f,c) debug_showmem(f,c) 
+#define etch_dumpmem() debug_dumpmem()
+
+#else   /* ETCH_DEBUGALLOC */
+
+#define etch_malloc(n,o) malloc(n)
+#define etch_realloc(p,n,o) realloc(p,n)
+#define etch_free(n) free(n)
+#define etch_showmem(f,c)  
+#define etch_dumpmem()
+
+#endif  /* ETCH_DEBUGALLOC */
+
+
+
+#ifdef ETCH_DEBUGALLOC
+
+#define DEFETCHHEAPTABLESIZE 1024 /* initial size of heap tracking table */
+
+/* compile time memory debugging switches */
+#define IS_TRACKING_ETCHHEAP 1    /* 1 to watch alloc address or memory */
+#define IS_USING_ALLOC_ID    1    /* 1 to store an ID # with each alloc */
+#define IS_USING_DEBUGBREAK  1    /* 1 to break at alloc# etch_watch_id */
+
+
+/*
+ * memrec is a record of an individual memory allocation
+ */
+typedef struct memrec
+{
+  size_t   size;     /* allocated bytes */
+  short    objtype;  /* type of allocation */
+  short    line;     /* source line number */
+  unsigned filehash; /* hash of filepath */
+  #if IS_USING_ALLOC_ID
+  unsigned id;      /* allocation serial number */
+  #endif
+} memrec;
+
+
+/*
+ * memtable is the hash table used for heap allocation tracking.
+ */
+etch_hashtable* memtable;
+int  is_memtable_instance;  /* indicator to not etch_malloc() the memtable */
+size_t etchheap_currbytes;  /* total bytes currently etch_malloc() 'ed */
+size_t etchheap_maxbytes;   /* high water mark - number of bytes */
+unsigned curr_alloc_id;     /* current memory allocation serial number */
+unsigned etchheap_count;    /* current number of allocations */
+unsigned etchheap_hiwater;  /* high water mark - number of allocations */
+
+size_t etch_watch_addr;     /* a memory address to watch */
+unsigned etch_watch_id;     /* an allocation # to watch */
+
+
+#endif /* ETCH_DEBUGALLOC */
+
+#endif /* #ifndef ETCHMEM_H*/ 
\ No newline at end of file

Added: incubator/etch/trunk/binding-c/runtime/c/inc/etchmsgutl.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etchmsgutl.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etchmsgutl.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etchmsgutl.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,64 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/*
+ * etchmsgutl.h -- includes common to the etch message components
+ */
+
+#ifndef ETCHMSGUTL_H
+#define ETCHMSGUTL_H
+
+#include "etchobj.h"
+#include "etch_type.h"
+#include "etch_field.h"
+
+#define ETCH_ARRAYVALUE_DEFAULT_INITSIZE 32
+#define ETCH_ARRAYVALUE_DEFAULT_DELTSIZE 0
+#define ETCH_ARRAYVALUE_DEFAULT_READONLY TRUE
+#define ETCH_ARRAYVALUE_DEFAULT_SYNCHRONIZED FALSE
+#define ETCH_ARRAYVALUE_DEFAULT_CONTENT_TYPE ETCHARRAYLIST_CONTENT_OBJECT
+
+#define ETCH_STRUCT_CONTENT_TYPE_OBJ 1
+#define ETCH_STRUCT_DEFAULT_INITSIZE 64
+#define ETCH_STRUCT_DEFAULT_READONLY_KEY TRUE
+#define ETCH_STRUCT_DEFAULT_READONLY_VAL TRUE
+#define ETCH_STRUCT_DEFAULT_TRACKED_MEM  TRUE
+#define ETCH_STRUCT_DEFAULT_CONTENT_TYPE ETCH_STRUCT_CONTENT_TYPE_OBJ
+
+/**
+ * equate java array element to an object.
+ * we do so to facilitate porting of the java code.
+ */
+typedef etch_object ETCH_ARRAY_ELEMENT;
+
+
+/**
+ * etch_struct_element
+ */
+typedef struct etch_struct_element
+{
+  etch_field* key;
+  objmask*    value;
+
+} etch_struct_element;
+
+
+etch_struct_element* new_struct_element(etch_field*, objmask*, etch_struct_element*);
+
+
+#endif /* #ifndef ETCHMSGUTL_H */
\ No newline at end of file

Added: incubator/etch/trunk/binding-c/runtime/c/inc/etchmutex.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etchmutex.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etchmutex.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etchmutex.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,148 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/*
+ * etchmutex.h -- thread mutex implementation
+ * currently wraps APR mutex. 
+ */
+
+#ifndef ETCHMUTEX_H
+#define ETCHMUTEX_H
+
+#include "etchobj.h"
+
+typedef struct etchmutex etchmutex;
+typedef struct etchwait  etchwait;
+#define ETCHMUTEX_NESTED TRUE
+#define ETCHMUTEX_UNNESTED FALSE
+
+
+/** signature of a mutex operation */
+typedef int (*etchmutex_operation)  (struct etchmutex*); 
+
+/** signatures of a wait operation */
+typedef int (*etchwait_operation)(etchwait*);
+typedef int (*etchwait_timedsig) (etchwait*, int);
+typedef int (*etchwait_condition)(etchwait*, int64*, int64);
+typedef int (*etchwait_timedcond)(etchwait*, int64*, int64, int);
+typedef int (*etchwait_setcond)  (etchwait*, int64); 
+
+
+/** 
+ *  etchmutex: mutex object
+ */
+struct etchmutex
+{
+    unsigned int    hashkey;
+    unsigned short  obj_type; 
+    unsigned short  class_id;
+    struct i_iterable* vtab;
+    int  (*destroy)(void*);
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;
+    struct objmask* parent;
+    etchresult*     result;
+    unsigned int    refcount;
+    unsigned int    length;
+    unsigned char   is_null;
+    unsigned char   is_copy;
+    unsigned char   is_static;
+    unsigned char   reserved;
+
+    void* impl; 
+    int   lockcount;
+
+    etchmutex_operation acquire;
+    etchmutex_operation tryacquire;
+    etchmutex_operation release;
+};
+
+typedef struct etchmutex etchmutex;
+
+etchmutex* new_mutex(void* params, const int is_nestable);
+int destroy_etchmutex(etchmutex*);
+
+int etchmutex_hookproc(int action, void* mutex);
+
+
+/** 
+ * etchwait: condition variable object with associated mutex.
+ * similar to the java binding's monitor except that a monitored variable state 
+ * is not tracked automatically -- instead the etchwait object's set() method 
+ * must be invoked to change the monitored variable's value. waiting threads
+ * can always be unblocked with signal(). if set() is used, waiters will be 
+ * unblocked if the value being set() is equal to the value specified at 
+ * invocation of waitequal() or timed_waitequal().
+ */
+typedef struct etchwait
+{
+    unsigned int    hashkey;
+    unsigned short  obj_type; 
+    unsigned short  class_id;
+    struct i_iterable* vtab;
+    int  (*destroy)(void*);
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;
+    struct objmask* parent;
+    etchresult*     result;
+    unsigned int    refcount;
+    unsigned int    length;
+    unsigned char   is_null;
+    unsigned char   is_copy;
+    unsigned char   is_static;
+    unsigned char   reserved;  
+
+    void*  impl;          /* wait implementation - owned */
+    int    timeoutms;     /* optional timeout: 0 forever */
+    int64* cond_var;      /* optional condition variable */
+    int64  cond_waitfor;  /* optional value to wait for */
+    int    threadcount;   /* count of threads waiting */
+    etchmutex* mutex;     /* associated mutex - owned */
+
+    /** block until signal */
+    etchwait_operation  wait;
+
+    /** block until signal or timeout */
+    etchwait_timedsig   timed_wait;
+
+    /** block until condition variable equal */
+    etchwait_condition  waitequal;
+
+    /** block until condition equal or timeout */
+    etchwait_timedcond  timed_waitequal;
+
+    /** unblock waiter */
+    etchwait_operation  signal;
+
+    /** unblock all waiters */
+    etchwait_operation  broadcast;
+
+    /** set monitored value and signal if condition met */
+    etchwait_setcond    set; 
+
+} etchwait;
+
+
+etchwait* new_wait(void* params);
+int destroy_etchwait (etchwait*);
+int etchmutex_release(etchmutex*);
+int etchmutex_acquire(etchmutex*);  
+int etchmutex_tryacquire(etchmutex*);
+
+
+#endif /* #ifndef ETCHMUTEX_H */

Added: incubator/etch/trunk/binding-c/runtime/c/inc/etchobj.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etchobj.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etchobj.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etchobj.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,914 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/* 
+ * etchobj.h 
+ * etch object definitions
+ */
+
+#ifndef ETCHOBJ_H
+#define ETCHOBJ_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include "etch.h"
+
+#define ETCH_MAX_NATIVE_DIM 3 /* arbitrary limit on native array dimensions */
+struct etchexception; /* declared in etchexcp.h which we can't include here */
+struct vtabmask;
+
+
+/**
+ * when an etchobject is returned from a request such as a method, it will contain
+ * an etchresult to indicate the result of the request, and any possible exception.
+ */ 
+typedef struct etchresult
+{
+    int resultcode;   
+    int reasoncode;
+    struct etchexception* exception; 
+
+} etchresult;
+
+
+/**
+ * function signatures for object virtuals
+ */
+typedef int   (*objdtor)  (void*);
+typedef void* (*objclone) (void*);
+typedef int   (*etch_destructor) (void*);
+
+typedef struct objmask objmask;
+typedef int  (*obj_gethashkey) (objmask*);
+struct etch_id_name;
+
+
+/**
+ * objmask
+ * mask over all etch objects
+ */
+typedef struct objmask
+{
+    unsigned int     hashkey;     /* unique key used by a hash map */
+    unsigned short   obj_type;    /* type of this object */
+    unsigned short   class_id;    /* class identifier */
+    struct vtabmask* vtab;        /* virtual function table */
+    int   (*destroy)(void*);      /* destructor */
+    void* (*clone)  (void*);      /* copy constructor */ 
+    obj_gethashkey   get_hashkey; /* hash key calculation override */
+    struct objmask*  parent;      /* class from which this derives */
+    etchresult*      result;      /* embedded result and exception */
+    unsigned int     refcount;    /* non-zero implies ref counted  */
+    unsigned int     length;      /* byte count of the flat object */
+    unsigned char    is_null;     /* does object wrap a null value */
+    unsigned char    is_copy;     /* is object content not owned   */
+    unsigned char    is_static;   /* should destructor free object */
+    unsigned char    reserved;
+
+} objmask;
+
+
+/**
+ * etch_object  
+ * object wrapper for any object 
+ */
+struct etch_object
+{
+    unsigned int     hashkey;    
+    unsigned short   obj_type;  
+    unsigned short   class_id;   
+    struct vtabmask* vtab;       
+    int   (*destroy)(void*);     
+    void* (*clone)  (void*); 
+    obj_gethashkey   get_hashkey;   
+    struct objmask*  parent;    
+    etchresult*      result;    
+    unsigned int     refcount;      
+    unsigned int     length;     
+    unsigned char    is_null;   
+    unsigned char    is_copy;  
+    unsigned char    is_static;  
+    unsigned char    reserved;
+
+    void* value; 
+ 
+    unsigned char   is_value_object;
+    unsigned char   is_value_owned; 
+    unsigned char   unused[2];
+}; 
+
+
+/**
+ * etchparentinfo
+ * object inheritance list entry 
+ */
+typedef struct etchparentinfo
+{
+   union {
+   unsigned short  obj_type; 
+   unsigned short  list_size;  /* entry[0] in any inheritance list */
+   };
+   union {
+   unsigned short  class_id;   
+   unsigned short  list_count; /* entry[0] in any inheritance list */ 
+   };
+   
+} etchparentinfo;
+                          
+
+/**
+ * vtabmask
+ * mask over any vtable 
+ */
+struct vtabmask
+{
+    unsigned int     hashkey;    
+    unsigned short   obj_type;          
+    unsigned short   class_id;   
+    struct vtabmask* vtab;       
+    int   (*destroy)(void*);     
+    void* (*clone)  (void*); 
+    obj_gethashkey   get_hashkey;    
+    struct objmask*  parent;     
+    etchresult*      result;     
+    unsigned int     refcount;       
+    unsigned int     length;     
+    unsigned char    is_null;   
+    unsigned char    is_copy;   
+    unsigned char    is_static;  
+    unsigned char    reserved;
+
+    etchparentinfo*  inherits_from;  /* inheritance list */ 
+
+    unsigned char unused[4];
+    
+    /* function pointers start here */              
+};
+
+typedef struct vtabmask vtabmask;
+
+
+
+/**
+ * lastresult global objects  
+ */
+objmask   _lastresobj;
+objmask*   lastresobj;
+etchresult lastresult;
+void clear_lastresult();
+
+
+/**
+ * etch_byte - wrapped byte 
+ * note that this and all CLASSID_PRIMITIVE_XXXX wrapped primitives are expected
+ * by code which generalizes such objects, to have the object's value as the first
+ * non-header item in the object.
+ */
+struct etch_byte
+{
+    unsigned int    hashkey;    
+    unsigned short  obj_type;   
+    unsigned short  class_id;   
+    vtabmask*       vtab;       
+    int  (*destroy)(void*);     
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;    
+    struct objmask* parent;     
+    etchresult*     result;     
+    unsigned int    refcount;       
+    unsigned int    length;     
+    unsigned char   is_null;   
+    unsigned char   is_copy;   
+    unsigned char   is_static;  
+    unsigned char   reserved;
+
+    signed char value;  
+
+    unsigned char unused[7];  
+};
+
+/**
+ * etch_boolean - wrapped boolean 
+ * note that this and all CLASSID_PRIMITIVE_XXXX wrapped primitives are expected
+ * by code which generalizes such objects, to have the object's value as the first
+ * non-header item in the object.
+ */
+struct etch_boolean
+{
+    unsigned int    hashkey;    
+    unsigned short  obj_type;   
+    unsigned short  class_id;   
+    vtabmask*       vtab;      
+    int  (*destroy)(void*);     
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;    
+    struct objmask* parent;     
+    etchresult*     result;     
+    unsigned int    refcount;       
+    unsigned int    length;     
+    unsigned char   is_null;   
+    unsigned char   is_copy;   
+    unsigned char   is_static;  
+    unsigned char   reserved;
+
+    unsigned char value; 
+
+    unsigned char unused[7];     
+};
+
+/**
+ * etch_int8 - wrapped 8-bit integer 
+ * note that this and all CLASSID_PRIMITIVE_XXXX wrapped primitives are expected
+ * by code which generalizes such objects, to have the object's value as the first
+ * non-header item in the object.
+ */
+struct etch_int8
+{
+    unsigned int    hashkey;    
+    unsigned short  obj_type;   
+    unsigned short  class_id;   
+    vtabmask*       vtab;     
+    int  (*destroy)(void*);     
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;    
+    struct objmask* parent;     
+    etchresult*     result;     
+    unsigned int    refcount;       
+    unsigned int    length;     
+    unsigned char   is_null;   
+    unsigned char   is_copy;   
+    unsigned char   is_static;  
+    unsigned char   reserved;
+
+    signed char value; 
+
+    unsigned char unused[7];     
+};
+
+/**
+ * etch_int16 - wrapped 16-bit integer 
+ * note that this and all CLASSID_PRIMITIVE_XXXX wrapped primitives are expected
+ * by code which generalizes such objects, to have the object's value as the first
+ * non-header item in the object.
+ */
+struct etch_int16
+{
+    unsigned int    hashkey;    
+    unsigned short  obj_type;   
+    unsigned short  class_id;   
+    vtabmask*       vtab;       
+    int  (*destroy)(void*);     
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;    
+    struct objmask* parent;     
+    etchresult*     result;     
+    unsigned int    refcount;       
+    unsigned int    length;     
+    unsigned char   is_null;   
+    unsigned char   is_copy;   
+    unsigned char   is_static;  
+    unsigned char   reserved;
+
+    signed short value; 
+
+    unsigned char unused[6];     
+};
+
+/**
+ * etch_int32 - wrapped 32-bit integer 
+ * note that this and all CLASSID_PRIMITIVE_XXXX wrapped primitives are expected
+ * by code which generalizes such objects, to have the object's value as the first
+ * non-header item in the object.
+ */
+struct etch_int32
+{
+    unsigned int    hashkey;    
+    unsigned short  obj_type;   
+    unsigned short  class_id;   
+    vtabmask*       vtab;       
+    int  (*destroy)(void*);     
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;    
+    struct objmask* parent;     
+    etchresult*     result;     
+    unsigned int    refcount;       
+    unsigned int    length;     
+    unsigned char   is_null;   
+    unsigned char   is_copy;   
+    unsigned char   is_static;  
+    unsigned char   reserved;
+
+    signed int value;
+
+    unsigned char unused[4];   
+};
+
+/**
+ * etch_int64 - wrapped 64-bit integer 
+ * note that this and all CLASSID_PRIMITIVE_XXXX wrapped primitives are expected
+ * by code which generalizes such objects, to have the object's value as the first
+ * non-header item in the object.
+ */
+struct etch_int64
+{
+    unsigned int    hashkey;    
+    unsigned short  obj_type;   
+    unsigned short  class_id;   
+    vtabmask*       vtab;       
+    int  (*destroy)(void*);     
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;    
+    struct objmask* parent;     
+    etchresult*     result;     
+    unsigned int    refcount;       
+    unsigned int    length;     
+    unsigned char   is_null;   
+    unsigned char   is_copy;   
+    unsigned char   is_static;  
+    unsigned char   reserved;
+
+    int64 value;    
+};
+
+/**
+ * etch_float - wrapped 32-bit float 
+ * note that this and all CLASSID_PRIMITIVE_XXXX wrapped primitives are expected
+ * by code which generalizes such objects, to have the object's value as the first
+ * non-header item in the object.
+ */
+struct etch_float
+{
+    unsigned int    hashkey;    
+    unsigned short  obj_type;   
+    unsigned short  class_id;   
+    vtabmask*       vtab;       
+    int  (*destroy)(void*);     
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;    
+    struct objmask* parent;     
+    etchresult*     result;     
+    unsigned int    refcount;       
+    unsigned int    length;     
+    unsigned char   is_null;   
+    unsigned char   is_copy;   
+    unsigned char   is_static;  
+    unsigned char   reserved;
+
+    float value;   
+
+    unsigned char unused[4];   
+};
+
+/**
+ * etch_double - wrapped 64-bit float 
+ * note that this and all CLASSID_PRIMITIVE_XXXX wrapped primitives are expected
+ * by code which generalizes such objects, to have the object's value as the first
+ * non-header item in the object.
+ */
+struct etch_double
+{
+    unsigned int    hashkey;    
+    unsigned short  obj_type;   
+    unsigned short  class_id;   
+    vtabmask*       vtab;      
+    int  (*destroy)(void*);     
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;    
+    struct objmask* parent;     
+    etchresult*     result;     
+    unsigned int    refcount;       
+    unsigned int    length;     
+    unsigned char   is_null;   
+    unsigned char   is_copy;   
+    unsigned char   is_static;  
+    unsigned char   reserved;
+
+    double value;    
+};
+
+
+typedef union etch_charptr
+{ void*    value;
+  wchar_t* valw;
+  char*    valc;
+} etch_charptr;
+
+
+/**
+ * etch_string - wrapped pointer to unicode string  
+ * note that this and all CLASSID_PRIMITIVE_XXXX wrapped primitives are expected
+ * by code which generalizes such objects, to have the object's value as the first
+ * non-header item in the object.
+ */
+struct etch_string
+{
+    unsigned int    hashkey;    
+    unsigned short  obj_type;   
+    unsigned short  class_id;   
+    vtabmask*       vtab;       
+    int  (*destroy)(void*);     
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;    
+    struct objmask* parent;     
+    etchresult*     result;     
+    unsigned int    refcount;       
+    unsigned int    length;     
+    unsigned char   is_null;   
+    unsigned char   is_copy;   
+    unsigned char   is_static;  
+    unsigned char   encoding;  
+
+    union etch_charptr v;     /* pointer to string value */
+    unsigned int char_count;  /* number of characters */
+    unsigned int byte_count;  /* including terminator */
+};
+
+/**
+ * etch_date - date object 
+ */
+struct etch_date
+{
+    unsigned int    hashkey;    
+    unsigned short  obj_type;   
+    unsigned short  class_id;   
+    vtabmask*       vtab;        
+    int  (*destroy)(void*);     
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;     
+    struct objmask* parent;     
+    etchresult*     result;     
+    unsigned int    refcount;       
+    unsigned int    length;     
+    unsigned char   is_null;   
+    unsigned char   is_copy;   
+    unsigned char   is_static;  
+    unsigned char   reserved;
+
+  /* if we have a number of seconds then just add the seconds to the time_t.
+   * otherwise call localtime() to get a pointer to struct tm, adjust the  
+   * hours, minutes or seconds accordingly, and invoke mktime() to normalize
+   * the tm object. for example to increment the current time by 9 hours,
+   * add 9 to tm_hours with no concern for whether the result may be > 24.
+   */
+
+    time_t  value; 
+    clock_t ticks; 
+};
+
+/**
+ * etch_exception - wrapped etchexception   
+ */
+struct etch_exception
+{
+    unsigned int    hashkey;    
+    unsigned short  obj_type;   
+    unsigned short  class_id;   
+    vtabmask*       vtab;        
+    int  (*destroy)(void*);     
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;    
+    struct objmask* parent;     
+    etchresult*     result;     
+    unsigned int    refcount;       
+    unsigned int    length;     
+    unsigned char   is_null;   
+    unsigned char   is_copy;   
+    unsigned char   is_static;  
+    unsigned char   reserved;
+
+    struct etchexception* value; 
+};
+
+
+/**
+ * etch_collection_mask  
+ * masks etch object collections such as etch_nativearray, etch_arraylist, 
+ * and etch_hashtable. not instantiated.
+ */
+typedef struct etch_collection_mask
+{
+    unsigned int    hashkey;    
+    unsigned short  obj_type;  
+    unsigned short  class_id;   
+    vtabmask*       vtab;       
+    int  (*destroy)(void*);     
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;   
+    struct objmask* parent;    
+    etchresult*     result;    
+    unsigned int    refcount;      
+    unsigned int    length;     
+    unsigned char   is_null;   
+    unsigned char   is_copy;  
+    unsigned char   is_static;  
+    unsigned char   reserved;  
+
+    void* p;     
+    unsigned short content_obj_type;   
+    unsigned short content_class_id;   
+    unsigned int n;
+
+} etch_collection_mask; 
+
+
+/**
+ * etch_arraytype is used as a mask over etch_nativearray and etch_arrayvalue.
+ * a function using an etch_arraytype* parameter will test for one or the other
+ * and possibly convert the passed array to the other type.
+ */  
+typedef struct etch_collection_mask etch_arraytype;
+
+
+/**
+ * etch_nativearray  
+ * object wrapper and methods for an n-dimensioned array of any type
+ * represented in memory as a single byte vector.
+ */
+struct etch_nativearray
+{
+    unsigned int    hashkey;    
+    unsigned short  obj_type;  
+    unsigned short  class_id;   
+    vtabmask*       vtab;       
+    int  (*destroy)(void*);     
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;   
+    struct objmask* parent;    
+    etchresult*     result;    
+    unsigned int    refcount;      
+    unsigned int    length;     
+    unsigned char   is_null;   
+    unsigned char   is_copy;  
+    unsigned char   is_static;  
+    unsigned char   is_content_owned; /* is content memory owned by this object */
+
+    void*  values;  /* flattened array content */
+    unsigned short content_obj_type;   /* ETCHTYPEB_INT32 means content is int */
+    unsigned short content_class_id;  /* CLASSID_NONE means content not wrapped */
+    int  numdims;   /* number of dimensions, e.g., 2 for x[3][4]  */
+
+    /* this object may be masked by etch_collection_mask to determine content
+     * type and class, so do not add any fields above this comment */
+
+    size_t itemsize;  /* size in bytes of an item, e.g. sizeof(int) */
+    size_t bytecount; /* length in bytes of array content (values)  */
+    size_t dimension[ETCH_MAX_NATIVE_DIM]; /* for int x[2][3] [0] is 3, [1] is 2  */
+    size_t dimsize  [ETCH_MAX_NATIVE_DIM]; /* for int x[2][3] [0] is 4, [1] is 12 */
+    size_t counts   [ETCH_MAX_NATIVE_DIM]; /* optional actual population counts */
+
+    int (*put1) (struct etch_nativearray*, void* v, int i); 
+    int (*put2) (struct etch_nativearray*, void* v, int i, int j); 
+    int (*put3) (struct etch_nativearray*, void* v, int i, int j, int k);
+    int (*get1) (struct etch_nativearray*, void* v, int i); 
+    int (*get2) (struct etch_nativearray*, void* v, int i, int j); 
+    int (*get3) (struct etch_nativearray*, void* v, int i, int j, int k); 
+}; 
+
+
+typedef struct etch_object  etch_object;
+typedef struct etch_byte    etch_byte;
+typedef struct etch_boolean etch_boolean;
+typedef struct etch_int8    etch_int8;
+typedef struct etch_int16   etch_int16;
+typedef struct etch_int32   etch_int32;
+typedef struct etch_int64   etch_int64;
+typedef struct etch_float   etch_float;
+typedef struct etch_double  etch_double;
+typedef struct etch_string  etch_string;
+typedef struct etch_date    etch_date;
+typedef struct etch_date    etch_date;
+typedef struct etch_exception   etch_exception;
+typedef struct etch_nativearray etch_nativearray;
+
+
+/**
+ * etch_objclass
+ * parameter structure identifying an etch object type
+ */
+typedef struct etch_objclass
+{
+    unsigned short  obj_type;
+    unsigned short  class_id;
+    unsigned short  content_obj_type;
+    unsigned short  content_class_id;
+    unsigned short  vtable_class_id;
+    unsigned int    numdims;
+    etchparentinfo* inherits_from; 
+    objmask* parent;
+
+} etch_objclass;
+
+
+/**
+ * etch_component_type_params
+ * parameter and result structure for get_component_type() etc.
+ */
+typedef struct etch_component_type_params
+{
+    unsigned int   dimensions;
+    unsigned short origl_class_id;
+    unsigned short origl_obj_type;
+    unsigned short final_obj_type;
+    unsigned short final_class_id;
+    etch_nativearray* origl_array;
+    etch_nativearray* final_array;
+
+} etch_component_type_params;
+
+
+typedef struct etch_array_id_params
+{
+    unsigned short array_obj_type;
+    unsigned short array_class_id;
+    unsigned short content_obj_type;
+    unsigned short content_class_id;
+   
+} etch_array_id_params;
+
+
+/* 
+ * default base object virtual method implementations
+ */
+int  destroy_object(objmask*);
+int  destroy_objectex(objmask*);
+int  destroy_string(etch_string*);
+objmask*  clone_object (objmask*);
+objmask*  clone_null(objmask*);
+objmask*  new_object(const int objsize, 
+    const unsigned short obj_type, const unsigned short class_id);
+
+/* 
+ * wide char string clone
+ */
+wchar_t* new_wchar(const wchar_t* s);
+
+/* 
+ * narrow char string clone
+ */
+char* new_char(const char* s);
+
+typedef etch_object etch_who; 
+typedef etch_int32  etch_event;
+typedef etch_int32  etch_query;
+typedef etch_int32  etch_control;
+etch_who* new_who(void* whoobj, const int is_owned); 
+objmask*  new_nullobj();
+
+int destroy_etch_object_value(etch_object*);
+objmask* etchobj_assign_to(objmask*, objmask*);
+
+
+/* 
+ * etch primitive constructors
+ */
+etch_byte*      new_byte(const signed char);
+etch_boolean*   new_boolean(boolean);
+etch_int8*      new_int8(signed char);
+etch_int16*     new_int16(short);
+etch_int32*     new_int32(int);
+etch_int64*     new_int64(int64);
+etch_float*     new_float(float);
+etch_double*    new_double(double);
+etch_string*    new_string(const void*, const unsigned char encoding);
+etch_string*    new_stringw(const void*); 
+etch_string*    new_stringa(const void*); 
+etch_string*    new_string_from(const void*, const unsigned char encoding);
+etch_date*      new_date(); 
+etch_object*    new_etch_object(const unsigned short class_id, void* value);
+objmask*        new_primitive(const unsigned, const unsigned short);
+
+etchresult* new_etchresult(const int result, const int reason);
+
+/* these are wrapped integers for now. if we need more data, we can define dedicated objects */
+etch_event*   new_etch_event  (const unsigned short class_id, const int value);
+etch_query*   new_etch_query  (const unsigned short class_id, const int value);
+etch_control* new_etch_control(const unsigned short class_id, const int value);
+
+#define ETCH_NOREFCOUNT_MARKER 0xffffffff
+#define is_etchobj_refcount_decremented(x) (x->hashkey == ETCH_NOREFCOUNT_MARKER)
+
+#define ETCHOBJCLASS(x) ETCHMAKECLASS(x->obj_type, x->class_id)
+#define ETCH_CONX_SIG 0xe5d4c3b2
+
+#define ETCHOBJ_DESTROY(x) do { if (x) x->destroy(x); x = NULL; } while(0);
+#define ETCHOBJ_FREE(x) do { if (x) etch_free(x); x = NULL; } while(0);
+
+
+typedef union  
+{ char   vbyte;  short vint16; int vint32; int64 vint64; double vdouble; 
+  float  vfloat; void* vaddr;  etch_string* vstring; 
+  struct objmask* vobjmask; 
+  struct etch_nativearray* vnatarray; struct etch_structvalue* vsv; 
+  struct etch_arrayvalue*  varrayval; struct etch_arraylist* varraylist;
+  int64  all; 
+} union_alltypes;
+
+etch_nativearray* new_nativearray (unsigned short class_id, const size_t itemsize, const int numdims, 
+    const int dim0, const int dim1, const int dim2);
+etch_nativearray* new_nativearray_from (void* values, unsigned short class_id, const size_t itemsize, 
+    const int numdims, const int dim0, const int dim1, const int dim2);
+etch_nativearray* new_nativearray_of(unsigned short content_obj_type, unsigned short content_class_id,  
+    const int numdims, const int dim0, const int dim1, const int dim2);
+etch_nativearray* new_subarray(etch_nativearray* a, const int i); 
+etch_nativearray* etch_nativearray_assign_to(etch_nativearray*, etch_nativearray*);
+objmask* etch_nativearray_get_element(etch_nativearray*, const int i); 
+int etch_nativearray_get_component_type(etch_object* classobj, etch_component_type_params*);
+int etch_nativearray_get_wrapped_component(etch_nativearray*, const int i, objmask** out);
+int destroy_nativearray_content(etch_nativearray*);
+int destroy_nativearray(etch_nativearray*);
+size_t etch_nativearray_off1 (etch_nativearray* a, int i);
+size_t etch_nativearray_off2 (etch_nativearray* a, int i, int j);
+size_t etch_nativearray_off3 (etch_nativearray* a, int i, int j, int k);
+
+#define is_etch_byte(x)         (x && ((objmask*)x)->class_id == CLASSID_PRIMITIVE_BYTE)
+#define is_etch_boolean(x)      (x && ((objmask*)x)->class_id == CLASSID_PRIMITIVE_BOOL)
+#define is_etch_int8(x)         (x && ((objmask*)x)->class_id == CLASSID_PRIMITIVE_INT8)
+#define is_etch_int16(x)        (x && ((objmask*)x)->class_id == CLASSID_PRIMITIVE_INT16)
+#define is_etch_int32(x)        (x && ((objmask*)x)->class_id == CLASSID_PRIMITIVE_INT32)
+#define is_etch_int64(x)        (x && ((objmask*)x)->class_id == CLASSID_PRIMITIVE_INT64)
+#define is_etch_float(x)        (x && ((objmask*)x)->class_id == CLASSID_PRIMITIVE_FLOAT)
+#define is_etch_double(x)       (x && ((objmask*)x)->class_id == CLASSID_PRIMITIVE_DOUBLE)
+#define is_etch_primitive(x)    (x && ((objmask*)x)->obj_type == ETCHTYPEB_PRIMITIVE)
+#define is_etch_struct(x)       (x && ((objmask*)x)->obj_type == ETCHTYPEB_STRUCTVAL)
+#define is_etch_validator(x)    (x && ((objmask*)x)->obj_type == ETCHTYPEB_VALIDATOR)
+#define is_etch_arraylist(x)    (x && ((objmask*)x)->obj_type == ETCHTYPEB_ARRAYLIST)
+#define is_etch_arrayvalue(x)   (x && ((objmask*)x)->obj_type == ETCHTYPEB_ARRAYVAL)
+#define is_etch_valuefact(x)    (x && ((objmask*)x)->obj_type == ETCHTYPEB_VALUEFACTORY)
+#define is_etch_valuefactimpl(x)(x && ((objmask*)x)->obj_type == ETCHTYPEB_VALUEFACTIMP)
+#define is_etch_exception(x)    (x && ((objmask*)x)->obj_type == ETCHTYPEB_EXCEPTION)
+#define is_etch_queue(x)        (x && ((objmask*)x)->obj_type == ETCHTYPEB_ETCHQUEUE)
+#define is_etch_wait(x)         (x && ((objmask*)x)->obj_type == ETCHTYPEB_WAIT)
+#define is_etch_mailbox(x)      (x && ((objmask*)x)->obj_type == ETCHTYPEB_MAILBOX)
+#define is_etch_imailbox(x)     (x && ((objmask*)x)->obj_type == ETCHTYPEB_MAILBOXINT)
+#define is_etch_mailboxmgr(x)   (x && ((objmask*)x)->obj_type == ETCHTYPEB_MBOXMGR_IMPL)
+#define is_etch_imailboxmgr(x)  (x && ((objmask*)x)->obj_type == ETCHTYPEB_MBOX_MANAGER)
+#define is_etch_sessionmsg(x)   (x && ((objmask*)x)->obj_type == ETCHTYPEB_SESSIONMSG)
+#define is_etch_transportmsg(x) (x && ((objmask*)x)->obj_type == ETCHTYPEB_TRANSPORTMSG)
+#define is_etch_hashtable(x)    (x && ((objmask*)x)->obj_type == ETCHTYPEB_HASHTABLE) 
+#define is_etch_nativearray(x)  (x && ((objmask*)x)->obj_type == ETCHTYPEB_NATIVEARRAY)
+#define is_etch_deliverysvc(x)  (x && ((objmask*)x)->obj_type == ETCHTYPEB_DELIVERYSVC_IMPL)
+#define is_etch_ideliverysvc(x) (x && ((objmask*)x)->obj_type == ETCHTYPEB_DELIVERYSVCINT)
+#define is_etch_tcpserver(x)    (x && ((objmask*)x)->obj_type == ETCHTYPEB_TCPSERVER)
+#define is_etch_sessionlxr(x)   (x && ((objmask*)x)->obj_type == ETCHTYPEB_SESSIONLXR)
+#define is_etch_sessionpacket(x)(x && ((objmask*)x)->obj_type == ETCHTYPEB_SESSIONPKT) 
+#define is_etch_transportpkt(x) (x && ((objmask*)x)->obj_type == ETCHTYPEB_TRANSPORTPKT) 
+#define is_etch_sessiondata(x)  (x && ((objmask*)x)->obj_type == ETCHTYPEB_SESSIONDATA) 
+#define is_etch_transportdata(x)(x && ((objmask*)x)->obj_type == ETCHTYPEB_TRANSPORTDATA) 
+#define is_etch_packetizer(x)   (x && ((objmask*)x)->obj_type == ETCHTYPEB_PACKETIZER) 
+#define is_etch_messagizer(x)   (x && ((objmask*)x)->obj_type == ETCHTYPEB_MESSAGIZER) 
+#define is_etch_serverimpl(x)   (x && ((objmask*)x)->obj_type == ETCHTYPEB_EXESERVERIMPL) 
+#define is_etch_serverbase(x)   (x && ((objmask*)x)->obj_type == ETCHTYPEB_EXESERVERBASE) 
+#define is_etch_factoryparams(x)(x && ((objmask*)x)->obj_type == ETCHTYPEB_FACTORYPARAMS) 
+#define is_etch_clientsession(x)(x && ((objmask*)x)->obj_type == ETCHTYPEB_CLIENT_SESSION) 
+#define is_etch_remote_server(x)(x && ((objmask*)x)->obj_type == ETCHTYPEB_REMOTESERVER) 
+#define is_etch_client_impl(x)  (x && ((objmask*)x)->obj_type == ETCHTYPEB_EXECLIENTIMPL) 
+#define is_etch_client_stub(x)  (x && ((objmask*)x)->obj_type == ETCHTYPEB_CLIENTSTUB) 
+#define is_etch_server_stub(x)  (x && ((objmask*)x)->obj_type == ETCHTYPEB_SERVERSTUB) 
+#define is_etch_client_base(x)  (x && ((objmask*)x)->obj_type == ETCHTYPEB_EXECLIENTBASE) 
+#define is_etch_threadpool(x)   (x && ((objmask*)x)->obj_type == ETCHTYPEB_THREADPOOL)
+#define is_etch_flexbuffer(x)   (x && ((objmask*)x)->obj_type == ETCHTYPEB_FLEXBUF) 
+#define is_etch_message(x)      (x && ((objmask*)x)->obj_type == ETCHTYPEB_MESSAGE) 
+#define is_etch_socket(x)       (x && ((objmask*)x)->obj_type == ETCHTYPEB_SOCKET) 
+#define is_etch_thread(x)       (x && ((objmask*)x)->obj_type == ETCHTYPEB_THREAD) 
+                   
+#define is_etch_string(x)      (x && ((objmask*)x)->class_id == CLASSID_STRING \
+ && ((objmask*)x)->obj_type == ETCHTYPEB_PRIMITIVE)  
+
+#define is_etch_date(x) (x && ((objmask*)x)->class_id == CLASSID_DATE \
+ && ((objmask*)x)->obj_type == ETCHTYPEB_PRIMITIVE) 
+
+#define is_etch_object(x)     (x && ((objmask*)x)->obj_type == ETCHTYPEB_ETCHOBJECT) 
+#define is_etch_object_type(a,b)(a == ETCHTYPEB_ETCHOBJECT || b == CLASSID_OBJECT ) 
+#define is_etch_nativearray_type(t,c) (t == ETCHTYPEB_NATIVEARRAY)
+#define is_etch_arraylist_type(t,c)   (t == ETCHTYPEB_ARRAYLIST)
+#define is_etch_objarray_type(t,c)    (c == CLASSID_ARRAY_OBJECT)
+
+#define is_etch_tcpconnection(x) (x \
+ && ((objmask*)x)->obj_type == ETCHTYPEB_CONNECTION \
+ && ((objmask*)x)->class_id == CLASSID_TCP_CONNECTION) 
+
+#define is_etch_serverparams(x) (x \
+ && ((objmask*)x)->obj_type == ETCHTYPEB_FACTORYPARAMS \
+ && ((objmask*)x)->class_id == CLASSID_SERVERFACTORY) 
+
+#define is_etch_clientparams(x) (x \
+ && ((objmask*)x)->obj_type == ETCHTYPEB_FACTORYPARAMS \
+ && ((objmask*)x)->class_id == CLASSID_CLIENTFACTORY) 
+
+#define is_etch_combo_validator(x) (x \
+ && ((objmask*)x)->obj_type == ETCHTYPEB_VALIDATOR \
+ && ((objmask*)x)->class_id == CLASSID_COMBO_VALIDATOR) 
+
+#define is_etch_primitive_number(x) (x \
+ && ((objmask*)x)->class_id >= CLASSID_PRIMITIVE_BYTE \
+ && ((objmask*)x)->class_id <= CLASSID_PRIMITIVE_DOUBLE)
+
+#define is_etch_arraytype(x) (x \
+ && (((objmask*)x)->obj_type >= ETCHTYPEB_NATIVEARRAY \
+  || ((objmask*)x)->obj_type <= ETCHTYPEB_ARRAYVAL))
+
+#define is_etch_unwantedmsg(x) (x \
+ && ((objmask*)x)->obj_type == ETCHTYPEB_EVENT \
+ && ((objmask*)x)->class_id == CLASSID_EVENT_UNWANTMSG) 
+
+
+#define is_etch_objparams(x,a,b) (x && ((objmask*)x)->obj_type == a && ((objmask*)x)->class_id == b)  
+
+#define is_etch_connection(cx) (cx && (*(unsigned*)cx) == ETCH_CONX_SIG)
+
+/**
+ * macros to interpret state of the object byteflag is_static 
+ */
+#define ETCHOBJ_IMMUTABLE_SHELL   1   /* object shell not to be freed */
+#define ETCHOBJ_IMMUTABLE_CONTENT 2   /* object content not to be freed */
+#define ETCHOBJ_IMMUTABLE_ALL     3   /* entire object not to be freed */
+#define ETCHOBJ_STATIC_RESOURCE   4   /* object will not be destroyed by resources mgr */
+#define is_etchobj_static_shell(x)   (  ( x->is_static  &  ETCHOBJ_IMMUTABLE_SHELL ) != 0 )
+#define is_etchobj_static_shellonly(x)  ( x->is_static ==  ETCHOBJ_IMMUTABLE_SHELL )
+#define is_etchobj_static_content(x)    ( x->is_static >=  ETCHOBJ_IMMUTABLE_CONTENT ) 
+#define is_etchobj_static_contonly(x)   ( x->is_static ==  ETCHOBJ_IMMUTABLE_CONTENT )
+#define is_etchobj_static_all(x)        ( x->is_static ==  ETCHOBJ_IMMUTABLE_ALL )
+#define is_etchobj_static_resource(x) ( ( x->is_static  &  ETCHOBJ_STATIC_RESOURCE) != 0 )
+#define set_etchobj_static_all(x)       ( x->is_static |=  ETCHOBJ_IMMUTABLE_ALL )
+#define set_etchobj_static_shell(x)     ( x->is_static |=  ETCHOBJ_IMMUTABLE_SHELL )
+#define set_etchobj_static_content(x)   ( x->is_static |=  ETCHOBJ_IMMUTABLE_CONTENT )
+#define set_etchobj_static_resource(x)  ( x->is_static |=  ETCHOBJ_STATIC_RESOURCE )
+#define clear_etchobj_static_shell(x)   ( x->is_static &= ~ETCHOBJ_IMMUTABLE_SHELL )
+#define clear_etchobj_static_content(x) ( x->is_static &= ~ETCHOBJ_IMMUTABLE_CONTENT )
+#define clear_etchobj_static_all(x)     ( x->is_static &= ~ETCHOBJ_IMMUTABLE_ALL )
+#define clear_etchobj_static_resource(x)( x->is_static &= ~ETCHOBJ_STATIC_RESOURCE )
+
+/**
+ * macros to interpret etchobject etchresult and etchexception content
+ */
+#define is_exception(x)  ( x && (x->obj_type == ETCHTYPEB_EXCEPTION || (x->result && x->result->exception)))
+#define etch_catch(x)    ( x->result && x->result->exception? x: 0 )
+#define get_exception(x) ( x->result? x->result->exception: NULL ) 
+#define get_result(x)    ( x->result? x->result->resultcode: 0 )
+#define get_reason(x)    ( x->result? x->result->reasoncode: 0 )
+#define is_resulterror(x)( x->result? x->result->resultcode < 0: 0 )
+#define is_good_result(o)( o && (!o->result || !o->result->exception || o->result->resultcode >= 0) ) 
+
+/**
+ * macros to get size/count from etch object inheritance list
+ */        
+#define has_parents(obj) {obj && ((vtabmask*)obj->vtab)->inherits_from \
+     && ((vtabmask*)obj->vtab)->inherits_from[0].list_count > 0))     
+#define get_etchobj_parent_count(obj) \
+  (obj && obj->vtab && ((vtabmask*)obj->vtab)->inherits_from? \
+  ((vtabmask*)obj->vtab)->inherits_from[0].list_count: 0)
+#define get_etchobj_parent_listsize(obj) \
+  (obj && obj->vtab && ((vtabmask*)obj->vtab)->inherits_from? \
+  ((vtabmask*)obj->vtab)->inherits_from[0].list_size: 0) 
+
+/**
+ * methods to access and/or instantiate object's inheritance hierarchy
+ */ 
+etchparentinfo* get_vtab_inheritance_list(objmask*, 
+   const short size, const short count, const short vtabclass);
+etchparentinfo* new_etch_inheritance_list(const short size, const short count, 
+   etchparentinfo* oldlist);
+etchparentinfo* get_next_etch_parent(objmask*, int current_index);
+etchparentinfo* get_next_etch_parentex(const unsigned short class_id, 
+   etchparentinfo* inhertlist, int current_index);
+
+int  etchobj_is_assignable_from(etch_objclass* target, etch_objclass* source);
+int  etchobj_is_assignable_fromobj(objmask* targetobj, objmask* sourceobj);
+void set_etch_assignable_arg_from(etch_objclass*, objmask*);
+
+unsigned etch_get_char_hashkey (const char*);
+unsigned etch_get_wchar_hashkey(const wchar_t*);
+
+int      is_derives_from_object(objmask*);
+int      is_derives_from_object_class(const unsigned short class_id);
+int      verify_object(objmask*, const unsigned short, const unsigned short, void** out);
+void*    new_vtable(const void* parentvtab, const size_t size, const short classid);
+short    short_type(unsigned i, unsigned j); 
+void*    get_base_vtable(objmask*); 
+unsigned etch_addref(objmask*);
+unsigned etch_release(objmask*);
+unsigned etch_release_wrapper(etch_object*);
+unsigned defgethashkey(objmask*);
+unsigned etch_number_get_hashkey(objmask*);
+unsigned get_vtable_cachehkey(unsigned short class_id);
+unsigned get_class_cachekey(unsigned short obj_type, unsigned short class_id);
+
+
+#endif /* #ifndef ETCHOBJ_H */
\ No newline at end of file

Added: incubator/etch/trunk/binding-c/runtime/c/inc/etchobjtypes.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etchobjtypes.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etchobjtypes.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etchobjtypes.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,355 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/* 
+ * etchobjtypes.h -- constants for internal object types.
+ */
+
+#ifndef ETCHOBJTYPES_H
+#define ETCHOBJTYPES_H 
+
+
+/** 
+ * identifies a class object's data type or content type
+ */
+typedef enum objtype_b   
+{  
+    ETCHTYPEB_UNDEFINED       = 0x0, 
+    ETCHTYPEB_NONE            = 0x0, 
+    ETCHTYPEB_BYTE            = 0x1, 
+    ETCHTYPEB_BOOL            = 0x2, 
+    ETCHTYPEB_INT8            = 0x3,    
+    ETCHTYPEB_INT16           = 0x4,
+    ETCHTYPEB_INT32           = 0x5,
+    ETCHTYPEB_INT64           = 0x6,
+    ETCHTYPEB_IEEE32          = 0x7,
+    ETCHTYPEB_IEEE64          = 0x8,
+    ETCHTYPEB_STRING          = 0x9, 
+    ETCHTYPEB_CLASS           = 0xa,
+    ETCHTYPEB_RAWOBJECT       = 0xb,  
+    ETCHTYPEB_CUSTOM          = 0xc,   
+    ETCHTYPEB_EXTERN          = 0xd,  
+    ETCHTYPEB_ETCHOBJECT      = 0xe,  
+    ETCHTYPEB_HASHTABLE       = 0xf,  
+    ETCHTYPEB_VTABLE          = 0x10,  
+    ETCHTYPEB_EXCEPTION       = 0x11,  
+    ETCHTYPEB_CACHEREC        = 0x12,  
+    ETCHTYPEB_BYTES           = 0x13,  
+    ETCHTYPEB_ID_NAME         = 0x14,
+    ETCHTYPEB_FIELD           = 0x15,
+    ETCHTYPEB_TYPE            = 0x16,
+    ETCHTYPEB_STRUCTVAL       = 0x17,
+    ETCHTYPEB_ARRAYVAL        = 0x18,
+    ETCHTYPEB_VALUEFACTORY    = 0x19,
+    ETCHTYPEB_VALUEFACTOBJ    = 0x1a,
+    ETCHTYPEB_VALUEFACTIMP    = 0x1b,
+    ETCHTYPEB_MESSAGE         = 0x1c,
+    ETCHTYPEB_TAGDATA         = 0x1d,
+    ETCHTYPEB_TAGDATAINP      = 0x1e,
+    ETCHTYPEB_TAGDATAOUT      = 0x1f,
+    ETCHTYPEB_TDIOBJ          = 0x20,
+    ETCHTYPEB_TDOOBJ          = 0x21,
+    ETCHTYPEB_ARRAYELEMENT    = 0x22,
+    ETCHTYPEB_STRUCTELEMENT   = 0x23,
+    ETCHTYPEB_INSTANCEDATA    = 0x24,
+    ETCHTYPEB_COLLECTION      = 0x25,
+    ETCHTYPEB_LINKLIST        = 0x26,
+    ETCHTYPEB_ITERATOR        = 0x27,
+    ETCHTYPEB_RESULT          = 0x28,
+    ETCHTYPEB_PRIMITIVE       = 0x29,
+    ETCHTYPEB_DATE            = 0x2a,
+    ETCHTYPEB_URL             = 0x2b,
+    ETCHTYPEB_XPORTFACT       = 0x2c,
+    ETCHTYPEB_CONNECTION      = 0x2d,
+    ETCHTYPEB_TCPSERVER       = 0x2e,
+    ETCHTYPEB_TCPCLIENT       = 0x2f,
+    ETCHTYPEB_SOCKET          = 0x30,
+    ETCHTYPEB_FLEXBUF         = 0x31,
+    ETCHTYPEB_WHO             = 0x32,
+    ETCHTYPEB_ARRAYLIST       = 0x33, 
+    ETCHTYPEB_BINARYTDI       = 0x34,
+    ETCHTYPEB_BINARYTDO       = 0x35,
+    ETCHTYPEB_IDNAMEIMPL      = 0x36,
+    ETCHTYPEB_SERIALIZER      = 0x37,
+    ETCHTYPEB_FORMATFACT      = 0x38,
+    ETCHTYPEB_VALIDATOR       = 0x39,
+    ETCHTYPEB_NATIVEARRAY     = 0x3a, 
+    ETCHTYPEB_SESSIONMSG      = 0x3b,
+    ETCHTYPEB_TRANSPORTMSG    = 0x3c,       
+    ETCHTYPEB_SESSIONDATA     = 0x3d,
+    ETCHTYPEB_SESSIONPKT      = 0x3e,
+    ETCHTYPEB_SESSIONLXR      = 0x3f,
+    ETCHTYPEB_DEFAULT_VF      = 0x40,
+    ETCHTYPEB_DEFAULT_VFOBJ   = 0x41,
+    ETCHTYPEB_DEFAULT_VFIMP   = 0x42,
+    ETCHTYPEB_THREAD          = 0x43,
+    ETCHTYPEB_THREADPOOL      = 0x44,
+    ETCHTYPEB_MUTEX           = 0x45,
+    ETCHTYPEB_THREADPARAMS    = 0x46,
+    ETCHTYPEB_WAIT            = 0x47, 
+    ETCHTYPEB_OBJSESSION      = 0x48,
+    ETCHTYPEB_MSGHANDLER      = 0x49,
+    ETCHTYPEB_SOURCE          = 0x4a,
+    ETCHTYPEB_SOURCEHDLR      = 0x4b,
+    ETCHTYPEB_MSGSOURCE       = 0x4c,
+    ETCHTYPEB_PACKETIZER      = 0x4d,
+    ETCHTYPEB_MESSAGIZER      = 0x4e,
+    ETCHTYPEB_PACKETHANDLER   = 0x4f,
+    ETCHTYPEB_ETCHLIST        = ETCHTYPEB_ARRAYLIST,
+    ETCHTYPEB_ETCHMAP         = ETCHTYPEB_HASHTABLE,
+    ETCHTYPEB_ETCHSET         = 0x50,
+    ETCHTYPEB_ETCHQUEUE       = 0x51,
+    ETCHTYPEB_UNUSED1         = 0x52,
+    ETCHTYPEB_SERVERIMPL      = 0x53,
+    ETCHTYPEB_EVENT           = 0x54,
+    ETCHTYPEB_MAILBOX         = 0x55,
+    ETCHTYPEB_MBOX_ELEMENT    = 0x56,
+    ETCHTYPEB_MBOX_MANAGER    = 0x57,
+    ETCHTYPEB_MBOXMGR_IMPL    = 0x58,
+    ETCHTYPEB_MAILBOXINT      = 0x59,
+    ETCHTYPEB_TRANSPORTDATA   = 0x5b,
+    ETCHTYPEB_TRANSPORTPKT    = 0x5c,
+    ETCHTYPEB_DELIVERYSVC     = 0x5d,
+    ETCHTYPEB_DELIVERYSVCINT  = 0x5e,
+    ETCHTYPEB_DELIVERYSVC_IMPL= 0x5f,
+    ETCHTYPEB_SERVERFACT      = 0x60,
+    ETCHTYPEB_CLIENTFACT      = 0x61,
+    ETCHTYPEB_SERVERFACT_IMPL = 0x62,
+    ETCHTYPEB_CLIENTFACT_IMPL = 0x63,
+    ETCHTYPEB_SVCINTERFACE    = 0x64,
+    ETCHTYPEB_EXESERVERBASE   = 0x66,
+    ETCHTYPEB_EXESERVERIMPL   = 0x67,
+    ETCHTYPEB_EXECLIENTBASE   = 0x68,
+    ETCHTYPEB_EXECLIENTIMPL   = 0x69,
+    ETCHTYPEB_REMOTE          = 0x6a,
+    ETCHTYPEB_REMOTECLIENT    = 0x6b,
+    ETCHTYPEB_REMOTESERVER    = 0x6c,
+    ETCHTYPEB_CLIENT_SESSION  = 0x74,
+    ETCHTYPEB_STUB            = 0x70,
+    ETCHTYPEB_CLIENTSTUB      = 0x71,    
+    ETCHTYPEB_SERVERSTUB      = 0x72,
+    ETCHTYPEB_FACTORYPARAMS   = 0x73,
+
+    ETCHTYPEB_EODMARK         = 0x7f,
+
+    ETCHTYPEB_DYNAMIC         = 0x80,
+
+    ETCHTYPEB_USER            = 0xa0,
+
+}  objtype_b;   
+
+
+/** 
+ * class IDs
+ */
+typedef enum etch_classid   
+{   
+    CLASSID_NONE               = 0x0, 
+    CLASSID_ANY                = 0x0, 
+    CLASSID_UNWRAPPED          = 0x0, 
+    CLASSID_PRIMITIVE_BYTE     = 0x1, /* primitive class IDs must start at 1 */
+    CLASSID_PRIMITIVE_BOOL     = 0x2,  
+    CLASSID_PRIMITIVE_INT8     = 0x3,
+    CLASSID_PRIMITIVE_INT16    = 0x4,
+    CLASSID_PRIMITIVE_INT32    = 0x5,
+    CLASSID_PRIMITIVE_INT64    = 0x6,
+    CLASSID_PRIMITIVE_FLOAT    = 0x7,
+    CLASSID_PRIMITIVE_DOUBLE   = 0x8,
+    CLASSID_STRING             = 0x9,
+    CLASSID_DATE               = 0xa,
+    CLASSID_OBJECT             = 0xf,
+    CLASSID_DEF_VF             = 0x10,  
+    CLASSID_DEF_VF_OBJ         = 0x11,  
+    CLASSID_DEF_VF_IMPL        = 0x12,  
+    CLASSID_DEF_VF_VTAB        = 0x13, 
+    CLASSID_BINARYTDI_VTAB     = 0x14,
+    CLASSID_BINARYTDO_VTAB     = 0x15,
+    CLASSID_TAGDATA            = 0x16,
+    CLASSID_BINARYTDI          = 0x17,
+    CLASSID_BINARYTDO          = 0x18,
+    CLASSID_ETCHMESSAGE        = 0x1a,
+    CLASSID_HASHTABLE          = 0x1b,
+    CLASSID_ETCH_MAP           = CLASSID_HASHTABLE,
+    CLASSID_HASHTABLE_VTAB     = 0x20, 
+    CLASSID_ITERABLE_VTAB      = 0x21, 
+    CLASSID_ITERATOR           = 0x22, 
+    CLASSID_ID_NAME            = 0x23, 
+    CLASSID_ID_FIELD           = 0x24, 
+    CLASSID_ID_TYPE            = 0x25, 
+    CLASSID_TDI_VTAB           = 0x26,
+    CLASSID_TDO_VTAB           = 0x27,
+    CLASSID_BINTDI_VTAB        = 0x28,
+    CLASSID_BINTDO_VTAB        = 0x29,
+    CLASSID_AVAILABLE_VTAB     = 0x2a,
+    CLASSID_TYPEIMPL           = 0x2b,
+    CLASSID_VTAB_FIELD         = 0x2c,
+    CLASSID_VTAB_TYPE          = 0x2d,
+    CLASSID_ETCH_ARRAYLIST     = 0x2e,
+    CLASSID_ETCH_LIST          = CLASSID_ETCH_ARRAYLIST,
+    CLASSID_ETCH_SET           = 0x2f,
+    CLASSID_STRUCTVALUE        = 0x30,
+    CLASSID_ARRAYVALUE         = 0x31,
+    CLASSID_ARRAYELEMENT       = 0x32,
+    CLASSID_VALUEFACTORY       = 0x33,
+    CLASSID_TAGDATAINP         = 0x34,
+    CLASSID_TAGDATAOUT         = 0x35,
+    CLASSID_EXCEPTION          = 0x36,
+    CLASSID_THREAD             = 0x39,
+    CLASSID_THREADPOOL         = 0x3a,
+    CLASSID_MUTEX              = 0x3b,
+    CLASSID_WAIT               = 0x3c,
+    CLASSID_STUB               = 0x3d,
+    CLASSID_SERVERIMPL         = 0x3e,
+    CLASSID_MSGSOURCE          = 0x3f,
+    CLASSID_MESSAGIZER         = 0x40,
+    CLASSID_MSGHANDLER         = 0x41,
+    CLASSID_SOURCE             = 0x42,
+    CLASSID_SOURCEHDLR         = 0x43,
+    CLASSID_URL                = 0x49,
+    CLASSID_PACKETIZER         = 0x4a,
+    CLASSID_PACKETHANDLER      = 0x4b,
+    CLASSID_FLEXBUF            = 0x4e,
+    CLASSID_WHO                = 0x4f,
+    CLASSID_ARRAY_OBJECT       = 0x50, 
+    CLASSID_ARRAY_BYTE         = 0x51,
+    CLASSID_ARRAY_BOOL         = 0x52,
+    CLASSID_ARRAY_INT8         = 0x53,
+    CLASSID_ARRAY_INT16        = 0x54,
+    CLASSID_ARRAY_INT32        = 0x55,
+    CLASSID_ARRAY_INT64        = 0x56,
+    CLASSID_ARRAY_FLOAT        = 0x57,
+    CLASSID_ARRAY_DOUBLE       = 0x58,
+    CLASSID_ARRAY_STRING       = 0x59,
+    CLASSID_ARRAY_STRUCT       = 0x5a,
+    CLASSID_ETCHQUEUE          = 0x5b,
+    CLASSID_ETCHSOCKET         = 0x5c,
+    CLASSID_CLIENT_SESSION     = 0x5d,
+    CLASSID_UNUSED_1           = 0x5e,
+    CLASSID_XPORTFACT          = 0x5f,
+    CLASSID_FORMATFACT         = 0x60,
+    CLASSID_FORMATFACT_BINARY  = 0x61,
+    CLASSID_FORMATFACT_XML     = 0x62,
+    CLASSID_TCP_CONNECTION     = 0x63,  
+    CLASSID_TCP_LISTENER       = 0x64, 
+    CLASSID_TCP_CLIENT         = 0x65, 
+    CLASSID_SOCKET             = 0x66,
+    CLASSID_UNUSED_2           = 0x67,
+    CLASSID_UNUSED_3           = 0x68,
+    CLASSID_SESSIONMSG         = 0x69,
+    CLASSID_TRANSPORTMSG       = 0x6a,
+    CLASSID_TRANSPORTPKT       = 0x6b,
+    CLASSID_SESSIONDATA        = 0x6c,
+    CLASSID_TRANSPORTDATA      = 0x6d,
+    CLASSID_SESSIONPKT         = 0x6e,
+    CLASSID_SESSIONLXR         = 0x6f,
+    CLASSID_VALIDATOR          = 0x70,
+    CLASSID_COMBO_VALIDATOR    = 0x71,
+    CLASSID_VALIDATOR_BOOL     = 0x72, 
+    CLASSID_VALIDATOR_BYTE     = 0x73, 
+    CLASSID_VALIDATOR_INT8     = 0x74, 
+    CLASSID_VALIDATOR_INT16    = 0x75, 
+    CLASSID_VALIDATOR_INT32    = 0x76, 
+    CLASSID_VALIDATOR_INT64    = 0x77, 
+    CLASSID_VALIDATOR_FLOAT    = 0x78, 
+    CLASSID_VALIDATOR_DOUBLE   = 0x79, 
+    CLASSID_VALIDATOR_STRING   = 0x7a,
+    CLASSID_VALIDATOR_OBJECT   = 0x7b,
+    CLASSID_VALIDATOR_EXCEPTION= 0x7c,
+    CLASSID_VALIDATOR_STRUCT   = 0x7d,
+    CLASSID_VALIDATOR_EOD      = 0x7e,
+    CLASSID_VALIDATOR_CUSTOM   = 0x7f,
+
+    CLASSID_RUNTIME_EXCEPTION  = 0x80, 
+    CLASSID_AUTH_EXCEPTION     = 0x81,
+    CLASSID_SERIALIZER_EXCP    = 0x82, 
+    CLASSID_SERIALIZER_RTXCP   = 0x83,
+    CLASSID_SERIALIZER_AUTHXCP = 0x84,
+    CLASSID_SERIALIZER_LIST    = 0x85,
+    CLASSID_SERIALIZER_MAP     = 0x86,
+    CLASSID_SERIALIZER_SET     = 0x87,
+    CLASSID_SERIALIZER_DATE    = 0x88,
+
+    CLASSID_EVENT_UNWANTMSG    = 0x90,
+    CLASSID_MAILBOX            = 0x91,
+    CLASSID_MAILBOXINT         = 0x92,
+    CLASSID_MBOX_ELEMENT       = 0x93,
+    CLASSID_PLAIN_MAILBOX      = 0x94,
+    CLASSID_MBOX_MANAGER       = 0x95,
+    CLASSID_PLAIN_MBOXMGR      = 0x96,
+    CLASSID_DELIVERYSVC        = 0x97,
+    CLASSID_TCP_DELIVERYSVC    = 0x98,
+    CLASSID_CLIENTSTUB         = 0x99,
+    CLASSID_SERVERSTUB         = 0x9a,
+    CLASSID_SERVERFACTORY      = 0x9b,
+    CLASSID_CLIENTFACTORY      = 0x9c,
+
+    CLASSID_TCP_XPORTFACT      = 0xb0,
+    CLASSID_SERVERFACT         = 0xb1,
+    CLASSID_CLIENTFACT         = 0xb2,
+    CLASSID_EXECLIENT_IMPL     = 0xb3,
+    CLASSID_EXECLIENTBASE_IMPL = 0xb4,
+    CLASSID_EXESERVER_IMPL     = 0xb5,
+    CLASSID_EXESERVERBASE_IMPL = 0xb6,
+
+    CLASSID_CONTROL_START         = 0x101, 
+    CLASSID_CONTROL_START_WAITUP  = 0x102, 
+    CLASSID_CONTROL_STOP          = 0x103, 
+    CLASSID_CONTROL_STOP_WAITDOWN = 0x104, 
+    CLASSID_WAITUP                = 0x105,
+    CLASSID_WAITDOWN              = 0x106, 
+ 
+    CLASSID_QUERY_IS_UP           = 0x110, 
+    CLASSID_QUERY_LOCALADDR       = 0x111, 
+    CLASSID_QUERY_REMOTEADDR      = 0x112, 
+    CLASSID_QUERY_WAITUP          = 0x113, 
+    CLASSID_QUERY_WAITDOWN        = 0x114, 
+
+    CLASSID_DYNAMIC_START         = 0x400, 
+
+}  etch_classid;   
+
+
+	
+/*
+ * ranges of numeric types 
+ */
+#define ETCHTYPE_MIN_TINY   ((signed char)(0xc0))      /* -64 */
+#define ETCHTYPE_MAX_TINY   ((signed char)(0x7f))      /* 127 */
+#define ETCHTYPE_MIN_BYTE   ((signed char)(0x80))      /* -128 (-(2^7))  */
+#define ETCHTYPE_MAX_BYTE   ((signed char)(0x7f))      /* 127  ((2^7)-1) */
+#define ETCHTYPE_MIN_INT16  ((signed short)(0x8000))   /* -65536 (-(2^15))  */
+#define ETCHTYPE_MAX_INT16  ((signed short)(0x7fff))   /* 65535  ((2^15)-1) */
+#define ETCHTYPE_MIN_INT32  ((signed int)(0x80000000)) /* (-(2^31))  */
+#define ETCHTYPE_MAX_INT32  ((signed int)(0x7fffffff)) /* ((2^31)-1) */
+#define ETCHTYPE_MIN_INT64  ((signed long long)(0x8000000000000000))  /* (-(2^63))  */ 
+#define ETCHTYPE_MAX_INT64  ((signed long long)(0x7fffffffffffffff))  /* ((2^63)-1) */ 
+#define ETCHTYPE_MIN_FLOAT  (1.4e-45f) 
+#define ETCHTYPE_MAX_FLOAT  (3.40282346e+38f)  
+#define ETCHTYPE_MIN_DOUBLE (4.9e-324) 
+#define ETCHTYPE_MAX_DOUBLE (1.7976931348623157e+308) 
+
+#define is_inrange_bool(n) (n == 0 || n == 1)
+#define is_inrange_tiny(n) (n >= ETCHTYPE_MIN_TINY  && n <= ETCHTYPE_MAX_TINY)
+#define is_inrange_byte(n) (n >= ETCHTYPE_MIN_BYTE  && n <= ETCHTYPE_MAX_BYTE)
+#define is_inrange_int8(n) (n >= ETCHTYPE_MIN_BYTE  && n <= ETCHTYPE_MAX_BYTE)
+#define is_inrange_int16(n)(n >= ETCHTYPE_MIN_INT16 && n <= ETCHTYPE_MAX_INT16)
+#define is_inrange_int32(n)(n >= ETCHTYPE_MIN_INT32 && n <= ETCHTYPE_MAX_INT32)
+#define is_inrange_int64(n)(n >= ETCHTYPE_MIN_INT64 && n <= ETCHTYPE_MAX_INT64)
+
+
+#endif  /* ETCHOBJTYPES_H */ 
\ No newline at end of file

Added: incubator/etch/trunk/binding-c/runtime/c/inc/etchrun.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etchrun.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etchrun.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etchrun.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,88 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/*
+ * etchrun.h -- runtime data management 
+ */
+
+#ifndef ETCHRUN_H
+#define ETCHRUN_H
+
+#include "etch.h"
+#include "etchhash.h"
+
+
+/*
+ * objrec is a node in a runtime cache of instantiated objects, specifically
+ * object vtables. The idea is, when we create an object, such as an etch_
+ * hashtable, for example, we check this cache to see if that object has
+ * been implemented previously; if not, we allocate the abstract part of
+ * the object (the vtable), implement it with pointers to concrete methods,  
+ * allocate a bucket for it, and add it to this cache. Thus each etch object
+ * carries around its own instance data of course, but points to its vtable.
+ */
+struct objrec /* DEPRECATED */
+{
+   unsigned obj_type;    /* four 8-bit fields -- see etchobjtypes.h */
+   void*    obj_impl;    /* "value" of the object */
+   struct objrec* next;  /* link pointer */
+}; 
+typedef struct objrec objrec; /* DEPRECATED */
+
+
+/*
+ * runtable is the runtime list of instantiated objects, specifically
+ * object vtables. See comments above. 
+ */
+objrec* runtable, *runtable_tail;  /* DEPRECATED */ 
+
+
+/*
+ * runtime cache
+ */
+etch_hashtable* global_cache;
+
+
+/*
+ * method signatures
+ */
+objrec* objrec_find(const unsigned int typ); /* DEPRECATED */
+void*   objrec_get (const unsigned int typ); /* DEPRECATED */
+void*   objrec_del (const unsigned int typ); /* DEPRECATED */
+objrec* objrec_add (const unsigned int typ, void* data);  /* DEPRECATED */
+int     objtable_clear(); /* DEPRECATED */
+int     objtable_count(); /* DEPRECATED */
+
+etch_hashtable* cache_create();
+void* cache_find   (const unsigned int typ, void** out);
+void* cache_del    (const unsigned int typ); 
+int   cache_add    (const unsigned int typ, void* data);  
+int   cache_insert (const unsigned int objtype, void* data, const int is_check);
+void* cache_findx  (char* key, void** out);
+void* cache_delx   (char* key);
+int   cache_addx   (char* key, void* data);
+int   cache_insertx(char* key, void* data, const int is_check);
+void* cache_find_by_hash(const unsigned hash, void** out);
+etch_hashitem* cache_current();
+int   cache_destroy();
+int   cache_clear();   
+int   cache_count();  
+int   cache_dump();  
+
+
+#endif /* #ifndef ETCHRUN_H*/ 
\ No newline at end of file

Added: incubator/etch/trunk/binding-c/runtime/c/inc/etchthread.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etchthread.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etchthread.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etchthread.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,239 @@
+/* $Id$ 
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
+ * contributor license agreements. See the NOTICE file distributed with  
+ * this work for additional information regarding copyright ownership. 
+ * The ASF licenses this file to you under the Apache License, Version  
+ * 2.0 (the "License"); you may not use this file except in compliance  
+ * with the License. You may obtain a copy of the License at 
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and 
+ * limitations under the License. 
+ */ 
+
+/*
+ * etchpool.h -- threads and thread pool 
+ */
+
+#ifndef ETCHPOOL_H
+#define ETCHPOOL_H
+
+#include "apr_thread_proc.h"
+#include "apr_atomic.h"
+
+#include "etchobj.h"
+#include "etchmutex.h"
+#include "etch_arraylist.h"
+
+#define ETCH_THREADSTATE_INITIAL    0
+#define ETCH_THREADSTATE_STARTED    4
+#define ETCH_THREADSTATE_STOPPING   7
+#define ETCH_THREADSTATE_STOPPED    8
+#define ETCH_THREADSTATE_DEFUNCT    9
+
+#define ETCH_DEFAULT_POOLTHREADS    4
+#define ETCH_THREADPARAMS_SIGNATURE 0xcafef00d
+
+unsigned thread_id_farm;
+unsigned next_etch_threadid();
+int etch_apr_init();
+apr_pool_t* etch_apr_mempool;
+apr_pool_t* get_etch_aprpool();
+etchmutex*  loglock;
+struct etch_threadpool;  
+struct etch_thread;
+int etch_init_static_mutex(etchmutex*, const int is_nestable);
+
+typedef struct etch_thread etch_thread;
+typedef struct etch_threadpool etch_threadpool;
+
+/** signature of a thread procedure */
+typedef void (*etch_threadproc) (void*); 
+
+/** signature of a thread procedure callback */
+typedef int (*etch_thread_callback) (void*); 
+
+/** interface to run a pool thread */
+typedef void* (*etch_run) (struct etch_threadpool*, etch_threadproc, void*); 
+
+/*
+  for reference, here are the APR thread structs. the content is ordinarily  
+  not addressable, getters and setters are defined instead. however not all  
+  content has a getter.
+
+   struct apr_thread_t 
+    {
+        apr_pool_t *pool;
+        HANDLE      td;
+        apr_int32_t cancel;
+        apr_int32_t cancel_how;
+        void       *data;
+        apr_thread_start_t func;
+        apr_status_t exitval;
+    };
+
+    struct apr_threadattr_t 
+    {
+        apr_pool_t *pool;
+        apr_int32_t detach;
+        apr_size_t  stacksize;
+    };
+*/
+
+
+/**
+ * etch_apr_threaddata
+ * thread parameters specific to the apache portable runtime. 
+ * this object memory is always managed by the caller, regardless of
+ * thread params is_xxxx configuration.
+ */
+typedef struct etch_apr_threaddata
+{
+    apr_pool_t*       mempool;
+    apr_thread_t*     thread;
+    apr_threadattr_t* threadattr;  
+    unsigned char     threadstate;
+    unsigned char     is_dedicated_mempool;
+
+} etch_apr_threaddata;
+
+
+/**
+ * etch_threadparams
+ * parameters to any thread start. 
+ * an internal threadproc invokes the user threadproc, 
+ * so we supply this object to the internal threadproc as data.
+ */
+typedef struct etch_threadparams
+{
+    unsigned int signature;           /* thread params sig */
+    int etch_thread_id;               /* our sequential ID */
+    etch_threadproc threadproc;       /* user thread proc */ 
+    etch_thread_callback on_start;    /* thread start hook */ 
+    etch_thread_callback on_exit;     /* thread exit hook */ 
+    etch_apr_threaddata* libdata;     /* thread library data*/
+    etch_threadpool* etchpool;        /* thread pool if any */
+    etch_thread* etchobj;             /* etch_thread object */ 
+    etchwait* waitobj;                /* post-start waiter */  
+    void*  data;                      /* actual thread data */
+    unsigned char is_own_data;        /* does thread own data */
+    unsigned char is_data_etchobject; /* is destroy() in play */
+    unsigned char threadstate;        /* current start state */
+    unsigned char unused;          
+
+} etch_threadparams;
+
+
+/** 
+ *  etch_thread: thread object
+ */
+typedef struct etch_thread
+{
+    unsigned int    hashkey;   
+    unsigned short  obj_type; 
+    unsigned short  class_id;
+    struct objmask* vtab;  
+    int  (*destroy)(void*);
+    void*(*clone)  (void*); 
+    obj_gethashkey  get_hashkey;
+    struct objmask* parent;
+    etchresult*     result;
+    unsigned int    refcount;
+    unsigned int    length;
+    unsigned char   is_null;
+    unsigned char   is_copy;
+    unsigned char   is_static;
+    unsigned char   is_joined;
+
+    int (*start) (void*);
+    int (*stop)  (void*);
+
+    etch_threadparams    params;
+    etch_apr_threaddata  aprdata;
+    etchwait*            waiter;
+    etchmutex*           objlock;  
+    
+} etch_thread;
+
+
+/** 
+ *  etch_threadpool: thread pool object
+ */
+typedef struct etch_threadpool
+{
+    unsigned int    hashkey;  
+    unsigned short  obj_type; 
+    unsigned short  class_id;
+    struct objmask* vtab;  
+    int  (*destroy)(void*);
+    void*(*clone)  (void*);
+    obj_gethashkey  get_hashkey;
+    struct objmask* parent;
+    etchresult*     result;
+    unsigned int    refcount;
+    unsigned int    length;
+    unsigned char   is_null;
+    unsigned char   is_copy;
+    unsigned char   is_static;
+    unsigned char   reserved;
+
+    etch_run run;
+
+    etchmutex* pool_lock;
+
+    /* to do: embed underlying queued threadpool here, such as APR pool */
+
+    etch_arraylist* threadlist;
+    etchmutex*      threadlist_lock; 
+    unsigned int    threadpool_id;  
+    int (*count) (); /* implementation should return threadlist.count */
+
+    unsigned char   pooltype;      /* queued or free */
+    unsigned char   is_defunct;    /* is pool forcibly destroying threads */
+    unsigned char   is_iterating;  /* is pool currently being iterated */
+    unsigned char   is_free_data;  /* will thread free its data memory */
+    unsigned char   is_free_threads;     /* is poolthread memory freed */
+    unsigned char   is_data_etchobject;  /* can thread call destroy() on data */
+    unsigned char   is_manual_start;     /* is explicit thread.start() required */
+    unsigned char   unused;      
+    
+} etch_threadpool;
+
+
+/* 
+ * global free thread pool
+ */
+etch_threadpool* global_free_threadpool;  
+etch_threadpool* etch_glopool();
+int etch_glopool_exit();
+unsigned short etch_threadpool_id_farm;
+
+#define ETCH_HAS_QUEUED_THREADPOOL (0)
+
+
+etch_threadpool* new_threadpool(const unsigned pooltype, const int initsize); 
+etch_thread* new_thread (etch_threadproc, void*);
+etch_thread* threadpool_remove_entry (etch_threadpool*, const int thread_id);
+etch_thread* threadpool_thread (etch_threadpool*, const int i);
+int    threadpool_waitfor_all(etch_threadpool*, const int is_cancel);
+int    threadpool_remove (etch_threadpool*, const int id);
+int    destroy_threadpool(etch_threadpool*); 
+void   etch_init_threadparams (etch_threadparams*);
+int    etch_createthread (etch_threadparams*);
+int    etch_thread_join  (etch_threadparams*);
+int    etch_thread_cancel(etch_thread*);
+int    etch_thread_stop  (etch_thread*);
+int    etch_join(etch_thread*);
+void   etch_thread_yield ();
+int    etch_on_threadstart(void*);
+int    etch_on_threadexit (void*);
+size_t etch_get_threadid  (void* threadstruct);
+void   etch_sleep(const int ms);
+
+
+#endif /* #ifndef ETCHPOOL_H */
\ No newline at end of file