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 [5/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/etch_threadpool_apr.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etch_threadpool_apr.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etch_threadpool_apr.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etch_threadpool_apr.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,299 @@
+/*
+ * 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.
+ */
+
+#ifndef APU_THREAD_POOL_H
+#define APU_THREAD_POOL_H
+
+#include "apu.h"
+#include "apr_thread_proc.h"
+
+/**
+ * @file apr_thread_pool.h
+ * @brief APR Thread Pool Library
+
+ * @remarks This library implements a thread pool using apr_thread_t. A thread
+ * pool is a set of threads that can be created in advance or on demand until a
+ * maximum number. When a task is scheduled, the thread pool will find an idle
+ * thread to handle the task. In case all existing threads are busy and the
+ * number of tasks in the queue is higher than the adjustable threshold, the
+ * pool will try to create a new thread to serve the task if the maximum number
+ * has not been reached. Otherwise, the task will be put into a queue based on
+ * priority, which can be valued from 0 to 255, with higher values being served
+ * first. If there are tasks with the same priority, the new task might be put at
+ * the top or at the bottom - it depends on which function is used to put the task.
+ *
+ * @remarks There may be the case where the thread pool can use up to the maximum
+ * number of threads at peak load, but having those threads idle afterwards. A
+ * maximum number of idle threads can be set so that the extra idling threads will
+ * be terminated to save system resources.
+ */
+#if APR_HAS_THREADS
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @defgroup APR_Util_TP Thread Pool routines
+ * @ingroup APR_Util
+ * @{
+ */
+
+/** Opaque Thread Pool structure. */
+typedef struct apr_thread_pool apr_thread_pool_t;
+
+#define APR_THREAD_TASK_PRIORITY_LOWEST 0
+#define APR_THREAD_TASK_PRIORITY_LOW 63
+#define APR_THREAD_TASK_PRIORITY_NORMAL 127
+#define APR_THREAD_TASK_PRIORITY_HIGH 191
+#define APR_THREAD_TASK_PRIORITY_HIGHEST 255
+
+/**
+ * Create a thread pool
+ * @param me The pointer in which to return the newly created apr_thread_pool
+ * object, or NULL if thread pool creation fails.
+ * @param init_threads The number of threads to be created initially, this number
+ * will also be used as the initial value for the maximum number of idle threads.
+ * @param max_threads The maximum number of threads that can be created
+ * @param pool The pool to use
+ * @return APR_SUCCESS if the thread pool was created successfully. Otherwise,
+ * the error code.
+ */
+apr_status_t etch_apr_thread_pool_create(apr_thread_pool_t **me,
+ apr_size_t init_threads,
+ apr_size_t max_threads,
+ apr_pool_t *pool);
+
+/**
+ * Destroy the thread pool and stop all the threads
+ * @return APR_SUCCESS if all threads are stopped.
+ */
+apr_status_t etch_apr_thread_pool_destroy(apr_thread_pool_t *me);
+
+/**
+ * Schedule a task to the bottom of the tasks of same priority.
+ * @param me The thread pool
+ * @param func The task function
+ * @param param The parameter for the task function
+ * @param priority The priority of the task.
+ * @param owner Owner of this task.
+ * @return APR_SUCCESS if the task had been scheduled successfully
+ */
+apr_status_t etch_apr_thread_pool_push(apr_thread_pool_t *me,
+ apr_thread_start_t func,
+ void *param,
+ apr_byte_t priority,
+ void *owner);
+/**
+ * Schedule a task to be run after a delay
+ * @param me The thread pool
+ * @param func The task function
+ * @param param The parameter for the task function
+ * @param time Time in microseconds
+ * @param owner Owner of this task.
+ * @return APR_SUCCESS if the task had been scheduled successfully
+ */
+apr_status_t etch_apr_thread_pool_schedule(apr_thread_pool_t *me,
+ apr_thread_start_t func,
+ void *param,
+ apr_interval_time_t time,
+ void *owner);
+
+/**
+ * Schedule a task to the top of the tasks of same priority.
+ * @param me The thread pool
+ * @param func The task function
+ * @param param The parameter for the task function
+ * @param priority The priority of the task.
+ * @param owner Owner of this task.
+ * @return APR_SUCCESS if the task had been scheduled successfully
+ */
+apr_status_t etch_apr_thread_pool_top(apr_thread_pool_t *me,
+ apr_thread_start_t func,
+ void *param,
+ apr_byte_t priority,
+ void *owner);
+
+/**
+ * Cancel tasks submitted by the owner. If there is any task from the owner that
+ * is currently running, the function will spin until the task finished.
+ * @param me The thread pool
+ * @param owner Owner of the task
+ * @return APR_SUCCESS if the task has been cancelled successfully
+ * @note The task function should not be calling cancel, otherwise the function
+ * may get stuck forever. The function assert if it detect such a case.
+ */
+apr_status_t etch_apr_thread_pool_tasks_cancel(apr_thread_pool_t *me,
+ void *owner);
+
+/**
+ * Get the current number of tasks waiting in the queue
+ * @param me The thread pool
+ * @return Number of tasks in the queue
+ */
+apr_size_t etch_apr_thread_pool_tasks_count(apr_thread_pool_t *me);
+
+/**
+ * Get the current number of scheduled tasks waiting in the queue
+ * @param me The thread pool
+ * @return Number of scheduled tasks in the queue
+ */
+apr_size_t etch_apr_thread_pool_scheduled_tasks_count(apr_thread_pool_t *me);
+
+/**
+ * Get the current number of threads
+ * @param me The thread pool
+ * @return Total number of threads
+ */
+apr_size_t etch_apr_thread_pool_threads_count(apr_thread_pool_t *me);
+
+/**
+ * Get the current number of busy threads
+ * @param me The thread pool
+ * @return Number of busy threads
+ */
+apr_size_t etch_apr_thread_pool_busy_count(apr_thread_pool_t *me);
+
+/**
+ * Get the current number of idle threads
+ * @param me The thread pool
+ * @return Number of idle threads
+ */
+apr_size_t etch_apr_thread_pool_idle_count(apr_thread_pool_t *me);
+
+/**
+ * Access function for the maximum number of idle threads. Number of current
+ * idle threads will be reduced to the new limit.
+ * @param me The thread pool
+ * @param cnt The number
+ * @return The number of threads that were stopped.
+ */
+apr_size_t etch_apr_thread_pool_idle_max_set(apr_thread_pool_t *me,
+ apr_size_t cnt);
+
+/**
+ * Get number of tasks that have run
+ * @param me The thread pool
+ * @return Number of tasks that have run
+ */
+apr_size_t
+ etch_apr_thread_pool_tasks_run_count(apr_thread_pool_t * me);
+
+/**
+ * Get high water mark of the number of tasks waiting to run
+ * @param me The thread pool
+ * @return High water mark of tasks waiting to run
+ */
+apr_size_t
+ etch_apr_thread_pool_tasks_high_count(apr_thread_pool_t * me);
+
+/**
+ * Get high water mark of the number of threads
+ * @param me The thread pool
+ * @return High water mark of threads in thread pool
+ */
+apr_size_t
+ etch_apr_thread_pool_threads_high_count(apr_thread_pool_t * me);
+
+/**
+ * Get the number of idle threads that were destroyed after timing out
+ * @param me The thread pool
+ * @return Number of idle threads that timed out
+ */
+apr_size_t
+ etch_apr_thread_pool_threads_idle_timeout_count(apr_thread_pool_t * me);
+
+/**
+ * Access function for the maximum number of idle threads
+ * @param me The thread pool
+ * @return The current maximum number
+ */
+apr_size_t etch_apr_thread_pool_idle_max_get(apr_thread_pool_t *me);
+
+/**
+ * Access function for the maximum number of threads.
+ * @param me The thread pool
+ * @param cnt Number of threads
+ * @return The original maximum number of threads
+ */
+apr_size_t etch_apr_thread_pool_thread_max_set(apr_thread_pool_t *me,
+ apr_size_t cnt);
+
+/**
+ * Access function for the maximum wait time (in microseconds) of an
+ * idling thread that exceeds the maximum number of idling threads.
+ * A non-zero value allows for the reaping of idling threads to shrink
+ * over time. Which helps reduce thrashing.
+ * @param me The thread pool
+ * @param timeout The number of microseconds an idle thread should wait
+ * till it reaps itself
+ * @return The original maximum wait time
+ */
+apr_interval_time_t
+ etch_apr_thread_pool_idle_wait_set(apr_thread_pool_t * me,
+ apr_interval_time_t timeout);
+
+/**
+ * Access function for the maximum wait time (in microseconds) of an
+ * idling thread that exceeds the maximum number of idling threads
+ * @param me The thread pool
+ * @return The current maximum wait time
+ */
+apr_interval_time_t
+ etch_apr_thread_pool_idle_wait_get(apr_thread_pool_t * me);
+
+/**
+ * Access function for the maximum number of threads
+ * @param me The thread pool
+ * @return The current maximum number
+ */
+apr_size_t etch_apr_thread_pool_thread_max_get(apr_thread_pool_t *me);
+
+/**
+ * Access function for the threshold of tasks in queue to trigger a new thread.
+ * @param me The thread pool
+ * @param cnt The new threshold
+ * @return The original threshold
+ */
+apr_size_t etch_apr_thread_pool_threshold_set(apr_thread_pool_t *me,
+ apr_size_t val);
+
+/**
+ * Access function for the threshold of tasks in queue to trigger a new thread.
+ * @param me The thread pool
+ * @return The current threshold
+ */
+apr_size_t etch_apr_thread_pool_threshold_get(apr_thread_pool_t * me);
+
+/**
+ * Get owner of the task currently been executed by the thread.
+ * @param thd The thread is executing a task
+ * @param owner Pointer to receive owner of the task.
+ * @return APR_SUCCESS if the owner is retrieved successfully
+ */
+apr_status_t etch_apr_thread_pool_task_owner_get(apr_thread_t *thd,
+ void **owner);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* APR_HAS_THREADS */
+#endif /* !APR_THREAD_POOL_H */
Added: incubator/etch/trunk/binding-c/runtime/c/inc/etch_transport.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etch_transport.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etch_transport.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etch_transport.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,369 @@
+/* $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.
+ */
+
+/*
+ * etch_transport.h -- common transport code
+ */
+
+#ifndef ETCHTRANSPORT_H
+#define ETCHTRANSPORT_H
+
+#include "etch_message.h"
+#include "etch_tcpconxn.h"
+#include "etch_resources.h"
+#include "etch_arraylist.h"
+#include "etch_mailboxmgr.h"
+#include "etch_sessionlisten.h"
+#include "etch_url.h"
+
+typedef int (*etch_delivsvc_begincall)(void* thisx,
+ etch_message*, void** out); /* i_mailbox** out */
+
+typedef int (*etch_delvisvc_endcall) (void* thisx,
+ i_mailbox*, etch_type* response_type, void** out); /* objmask** out */
+
+typedef void* (*main_new_server_funcptr) (void* serverargs, void* sessionargs);
+typedef void* (*new_client_impl_funcptr) (void* argstruct); /* not used */
+
+typedef void* (*helper_new_server_funcptr) (void* serverargs, void* sessionargs);
+typedef void* (*new_client_funcptr) (void* argstruct);
+typedef int (*get_xxxx_resources_funcptr)(void* argstruct);
+
+
+/*
+ * i_delivery_service
+ * the implementor of delivery service will implement i_sessionmessage and
+ * i_session, and copy pointers to the implementations to this interface.
+ */
+typedef struct i_delivery_service
+{
+ 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_delivsvc_begincall begin_call;
+ etch_delvisvc_endcall end_call;
+
+ i_sessionmessage* session; /* not owned */
+ i_transportmessage* transport; /* not owned */
+ i_sessionmessage* ism; /* not owned */
+ i_transportmessage* itm; /* not owned */
+
+ void* thisx;
+ etchmutex* rwlock; /* not owned */
+ unsigned char is_session_owned;
+ unsigned char is_transport_owned;
+
+} i_delivery_service;
+
+
+/*
+ * etch_tcp_delivery_service
+ * java binding does not have one of these, it constructs and returns a
+ * DeliveryService in TcpTransportFactory.newTransport(). we will instead
+ * invoke new_etch_transport(uri, resources), returning an i_delivery_service.
+ */
+typedef struct etch_tcp_delivery_service
+{
+ 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;
+
+ // ***** TODO lose i_deliveryservice instantiation and instead mask
+ // ***** all delivery service with i_deliveryservice. *************
+ i_delivery_service* ids;
+ etch_delivsvc_begincall begin_call;
+ etch_delvisvc_endcall end_call;
+
+ /* i_transportmessage - owns the tcp delivery service */
+ i_transportmessage* transport; /* owned by transportx */
+ i_mailbox_manager* transportx; /* owned */
+
+ /* external implementation of i_session_message */
+ i_sessionmessage* session; /* not owned */
+
+ /* delivery service implementation of i_session_message */
+ i_sessionmessage* sessionmsg; /* owned */
+ etch_session_message session_message;
+ etch_session_control session_control;
+ etch_session_notify session_notify;
+ etch_session_query session_query;
+
+ /* delivery service implementation of i_transport_message */
+ /* owns the tcp delivery service */
+ i_transportmessage* transportmsg; /* owned */
+ etch_transport_message transport_message;
+ etch_transport_control transport_control;
+ etch_transport_notify transport_notify;
+ etch_transport_query transport_query;
+ etch_transport_get_session get_session;
+ etch_transport_set_session set_session;
+
+ /* private component implementations */
+ etch_resources* resources; /* not owned */
+ etch_tcp_connection* tcpconx; /* not owned on server - destroyed on listener exit */
+ etchmutex* rwlock; /* not owned */
+ etchwait* waiter; /* owned by tcpconx */
+ void* packetizer; /* owned */
+ void* messagizer; /* owned */
+ void* mailboxmgr; /* owned */
+
+ unsigned char is_tcpconx_owned;
+ unsigned char unused[3];
+
+} etch_tcp_delivery_service;
+
+
+
+/* - - - - - - - - - - - - - - - - - - - -
+ * factory parameter bundle
+ * - - - - - - - - - - - - - - - - - - - -
+ */
+
+/**
+ * etch_session
+ * server's per-client parameters.
+ * this object wraps all of a server's per-session instance data.
+ */
+typedef struct etch_session
+{
+ 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;
+
+ void* thisx; /* host etch_factory_params* */
+
+ unsigned session_id; /* session key: same as cx.conxid */
+ /* fyi a session's receive thread is available at cx.thread */
+ etch_connection* cx; /* session client accepted connection */
+ i_delivery_service* ds; /* session delivery service */
+ void* client; /* xxxx_remote_client* */
+ void* server; /* i_xxxx_server */
+ void* server_stub; /* xxxx_server_stub* */
+ objmask* conximpl; /* accepted conx impl obj e.g. tcp_connection* */
+
+ /* note that mainlistener.thisx is the server object e.g. etch_tcp_server
+ * and that serverobject.session is this i_sessionlistener */
+ i_sessionlistener* mainlistener; /* accept listener */
+
+} etch_session;
+
+
+/**
+ * etch_factory_params
+ * mask over server or client factory parameter bundle
+ */
+typedef struct etch_factory_params
+{
+ 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;
+
+ void* thisx; /* params owner TODO populate this */
+
+ wchar_t* in_uri;
+ etch_resources* in_resx;
+ etch_value_factory* in_valufact;
+ etch_threadpool* mainpool;
+ etch_threadpool* subpool;
+ etch_threadpool* qpool;
+ etch_threadpool* fpool;
+ etchmutex* mblock;
+ objmask* session;
+ i_session* isession;
+ etch_arraylist* per_connection_params;
+
+ /* factory constructors */
+ void* helper_new_xxxx;
+ void* main_new_xxxx;
+
+} etch_factory_params;
+
+
+/**
+ * etch_server_factory
+ * virtual server constructors and associated parameters.
+ * masked by etch_factory_params
+ */
+typedef struct etch_server_factory
+{
+ 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;
+
+ void* thisx; /* params owner TODO populate this */
+
+ wchar_t* in_uri;
+ etch_resources* in_resx;
+ etch_value_factory* in_valufact;
+ etch_threadpool* mainpool; /* main listener thread manager*/
+ etch_threadpool* subpool;
+ etch_threadpool* qpool; /* session thread manager */
+ etch_threadpool* fpool; /* session thread manager */
+ etchmutex* mblock; /* utility lock */
+ objmask* session; /* i_session_listener* */
+ i_session* isession; /* listener's i_session */
+ etch_arraylist* clientlist; /* create session in new_helper_accepted_server() */
+
+ /* pointer to new_helper_accepted_server() in xxxx_helper */
+ helper_new_server_funcptr helper_new_accepted;
+
+ /* pointer to new_xxxx_server() in [main] */
+ main_new_server_funcptr main_new_server;
+
+} etch_server_factory;
+
+
+/**
+ * etch_client_factory
+ * masked by etch_factory_params
+ */
+typedef struct etch_client_factory
+{
+ 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;
+
+ void* thisx; /* params owner todo populate this */
+
+ wchar_t* in_uri;
+ etch_resources* in_resx;
+ etch_value_factory* in_valufact;
+ etch_threadpool* mainpool;
+ etch_threadpool* subpool;
+ etch_threadpool* qpool;
+ etch_threadpool* fpool;
+ etchmutex* rwlock; /* mailbox read/write lock */
+ objmask* session; /* unused? */
+ i_session* isession;/* unused? */
+ etch_arraylist* per_server; /* unused? */
+
+ new_client_funcptr new_client;
+ new_client_impl_funcptr new_client_impl; /* unused */
+
+ int server_id;
+ void* server; /* xxxx_remote_server* use: is_etch_remote_server(x) */
+ void* iclient; /* i_xxxx_client use: is_etch_client_base(x) */
+ void* stub; /* xxxx_client_stub* */
+ i_delivery_service* dsvc; /* use: is_etch_ideliverysvc(x) */
+
+} etch_client_factory;
+
+
+etch_tcp_delivery_service* new_tcp_delivery_service (etch_url*, etch_factory_params*, etch_tcp_connection*);
+etch_tcp_delivery_service* get_etch_ds_impl (i_delivery_service*);
+
+etch_resources* etch_transport_resources_init(etch_resources*);
+
+etch_resources* get_etch_transport_resources(etch_resources*);
+
+etch_client_factory* new_client_factory (objmask* session,
+ i_session* isession, new_client_funcptr new_client_func);
+
+etch_server_factory* new_server_factory (objmask* session, i_session* isession,
+ helper_new_server_funcptr new_server_callback, main_new_server_funcptr new_server_impl_callback);
+
+i_delivery_service* new_delivery_service_interface(i_sessionmessage*, i_transportmessage*);
+i_delivery_service* new_etch_transport (wchar_t* uri, etch_factory_params*, void* conximpl);
+i_delivery_service* new_etch_transport_a(etch_url* url, etch_factory_params*, void* conximpl);
+
+etch_session* remove_etch_session (etch_server_factory*, const int session_id);
+int get_etch_session (etch_server_factory*, const int session_id, etch_session** out);
+int transport_teardown_client_sessions (i_sessionlistener*);
+int transport_session_count (i_sessionlistener*);
+int transport_thread_id (i_sessionlistener*);
+
+i_sessionlistener* new_etch_listener (wchar_t* uri, etch_resources*,
+ helper_new_server_funcptr,
+ main_new_server_funcptr,
+ get_xxxx_resources_funcptr);
+
+
+#endif /* #ifndef ETCHTRANSPORT_H */
\ No newline at end of file
Added: incubator/etch/trunk/binding-c/runtime/c/inc/etch_transportdata.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etch_transportdata.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etch_transportdata.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etch_transportdata.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,90 @@
+/* $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.
+ */
+
+/*
+ * etch_transportdata.h
+ * i_transportdata interface
+ * interface used to deliver messages to the transport from the transport
+ */
+#ifndef ETCHITRANSPORTDATA_H
+#define ETCHITRANSPORTDATA_H
+
+#if(0)
+
+ TRANSPORTDATA
+ | void transportData(Who to, buffer)
+ - TRANSPORT<SessionData>
+ transportQuery(); transportl(); transport();
+ getSession(); setSession();
+
+#endif
+
+#include "etch_transportint.h"
+
+typedef int (*etch_transport_data) (void* thisx, void* whofrom, void* buffer);
+
+
+/**
+ * i_transportdata
+ * transportdata interface
+ * a message handler delivers messages from a message source
+ */
+typedef struct i_transportdata
+{
+ 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;
+
+ void* thisx; /* object which is the interface implementor */
+
+ /* transport interface */
+ i_transport* itransport; /* owned */
+ etch_transport_control transport_control;
+ etch_transport_notify transport_notify;
+ etch_transport_query transport_query;
+ etch_transport_get_session get_session;
+ etch_transport_set_session set_session;
+
+ /**
+ * transport_data()
+ * delivers data to transport from ...
+ * @param to recipient
+ * @param message the message
+ * @return 0 success, -1 error
+ */
+ etch_transport_data transport_data;
+
+} i_transportdata;
+
+
+i_transportdata* new_transportdata_interface(void* thisx, etch_transport_data, i_transport*);
+
+
+#endif /* ETCHITRANSPORTDATA_H */
\ No newline at end of file
Added: incubator/etch/trunk/binding-c/runtime/c/inc/etch_transportint.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etch_transportint.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etch_transportint.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etch_transportint.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,111 @@
+/* $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.
+ */
+
+/*
+ * etch_transportint.h
+ * transport interface
+ */
+#ifndef ETCHITRANSPORT_H
+#define ETCHITRANSPORT_H
+
+#include "etchobj.h"
+
+/*
+ * the memory ownership contracts for control, notify, and query, are:
+ * caller relinquishes all arguments except of course the this pointer,
+ * regardless of outcome. it follows that only simple and temporal
+ * objects are passed as parameters.
+ */
+typedef int (*etch_transport_control) (void* thisx, void* eventx, void*);
+typedef int (*etch_transport_notify) (void* thisx, void* eventx);
+typedef void* (*etch_transport_query) (void* thisx, void*);
+
+typedef void* (*etch_transport_get_session) (void* thisx);
+typedef void (*etch_transport_set_session) (void* thisx, void*);
+
+
+/**
+ * i_transport
+ * transport interface
+ * not an etch object, ergo no destructor
+ */
+typedef struct i_transport
+{
+ etch_transport_control transport_control;
+ etch_transport_notify transport_notify;
+ etch_transport_query transport_query;
+
+ etch_transport_get_session get_session;
+ etch_transport_set_session set_session;
+
+ void* thisx;
+
+} i_transport;
+
+
+
+/**
+ * i_transport_mask
+ * mask over any implemented transport interface
+ */
+typedef struct i_transport_mask
+{
+ 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;
+
+ void* thisx; /* object which is the interface implementor */
+
+ /* transport interface */
+ i_transport* itransport;
+ etch_transport_control transport_control;
+ etch_transport_notify transport_notify;
+ etch_transport_query transport_query;
+ etch_transport_get_session get_session;
+ etch_transport_set_session set_session;
+
+ void* main_transport_method;
+
+} i_transport_mask;
+
+
+i_transport* new_default_transport_interface();
+
+i_transport* new_transport_interface(void* thisx,
+ etch_transport_control, etch_transport_notify, etch_transport_query);
+
+i_transport* new_transport_interface_ex(void* thisx,
+ etch_transport_control, etch_transport_notify, etch_transport_query,
+ etch_transport_get_session, etch_transport_set_session);
+
+i_transport* clone_transport(void* thisx, const i_transport*) ;
+
+
+#endif /* ETCHITRANSPORT_H */
\ No newline at end of file
Added: incubator/etch/trunk/binding-c/runtime/c/inc/etch_transportmsg.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etch_transportmsg.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etch_transportmsg.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etch_transportmsg.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,91 @@
+/* $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.
+ */
+
+/*
+ * etch_transportmsg.h
+ * i_transportmessage interface
+ * interface used to deliver messages to the transport from the transport
+ */
+
+#ifndef ETCHITRANSPORTMSG_H
+#define ETCHITRANSPORTMSG_H
+
+#if(0)
+
+ TRANSPORTMESSAGE
+ | void transportMessage(Who to, message)
+ - TRANSPORT<SessionMessage>
+ transportQuery(); transportl(); transport();
+ getSession(); setSession();
+
+#endif
+
+#include "etch_transportint.h"
+
+typedef int (*etch_transport_message) (void* thisx, void* whofrom, void* message);
+
+
+/**
+ * i_transportmessage
+ * transportmessage interface
+ * a message handler delivers messages from a message source
+ */
+typedef struct i_transportmessage
+{
+ 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;
+
+ void* thisx; /* object which is the interface implementor */
+
+ /* transport interface */
+ i_transport* itransport;
+ etch_transport_control transport_control;
+ etch_transport_notify transport_notify;
+ etch_transport_query transport_query;
+ etch_transport_get_session get_session;
+ etch_transport_set_session set_session;
+
+ /**
+ * transport_message()
+ * delivers data to transport from ...
+ * @param to recipient
+ * @param message the message
+ * @return 0 success, -1 error
+ */
+ etch_transport_message transport_message;
+
+} i_transportmessage;
+
+
+i_transportmessage* new_transportmsg_interface(void* thisx, etch_transport_message, i_transport*);
+
+
+#endif /* ETCHITRANSPORTMSG_H */
\ No newline at end of file
Added: incubator/etch/trunk/binding-c/runtime/c/inc/etch_transportpkt.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etch_transportpkt.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etch_transportpkt.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etch_transportpkt.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,99 @@
+/* $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.
+ */
+
+/*
+ * etch_transportpkt.h
+ * i_transportpacket interface
+ * interface used to deliver packets to transport from session
+ */
+
+#ifndef ETCHITRANSPORTPACKET_H
+#define ETCHITRANSPORTPACKET_H
+
+#if(0)
+
+ TRANSPORTPACKET
+ | int transportPacket(Who from, packetbuffer)
+ - TRANSPORT
+ transportQuery(); transportControl(); transportNotify();
+
+#endif
+
+
+#include "etch_transportint.h"
+
+typedef int (*etch_transport_packet) (void* thisx, void* whoto, void* buffer);
+typedef int (*etch_transport_packet_headersize) (void* thisx);
+
+
+/**
+ * i_transportpacket
+ * transportpacket interface
+ */
+typedef struct i_transportpacket
+{
+ 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;
+
+ void* thisx; /* object which is the interface implementor */
+
+ /* transport interface */
+ i_transport* itransport;
+ etch_transport_control transport_control;
+ etch_transport_notify transport_notify;
+ etch_transport_query transport_query;
+ etch_transport_get_session get_session;
+ etch_transport_set_session set_session;
+
+ /**
+ * transport_packet()
+ * delivers packet to transport after adding packet header.
+ * @param to recipient
+ * @param buffer buffer positioned at the packet data, with space for header
+ * @return 0 success, -1 error
+ */
+ etch_transport_packet transport_packet;
+
+ /**
+ * etch_transport_packet_headersize()
+ * @return size of packet header in bytes
+ */
+ etch_transport_packet_headersize get_headersize;
+
+ int header_size;
+
+} i_transportpacket;
+
+
+i_transportpacket* new_transportpkt_interface(void* thisx, etch_transport_packet, i_transport*);
+
+
+#endif /* ETCHITRANSPORTPACKET_H */
\ No newline at end of file
Added: incubator/etch/trunk/binding-c/runtime/c/inc/etch_type.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etch_type.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etch_type.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etch_type.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,139 @@
+/* $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.
+ */
+
+/*
+ * etch_type.h
+ * an etch_type is an etch_id_name representing a type of a struct or message
+ */
+
+#ifndef ETCHTYPE_H
+#define ETCHTYPE_H
+
+#include "etch_id_name.h"
+#include "etchhash.h"
+#include "etch_serializer.h"
+
+#define ETCHTYPE_DEFSIZE_VTORMAP 4
+#define ETCHTYPE_DEFSIZE_FIELDMAP 8
+typedef etch_id_name etch_field;
+
+
+/**
+ * etch_type (see etch_id_name.h)
+ */
+typedef etch_id_name etch_type;
+
+/**
+ * nonspecific stub helper callback signature.
+ * the parameter types are in reality (StubBase, DeliveryService, T obj, Who, Message)
+ * however we can't include those headers here.
+ */
+typedef int (*opaque_stubhelper) (void* stub, void* delsvc, void* obj, void* sender, void* msg);
+
+
+/**
+ * etch_type_impl
+ * etch_type instance data extending etch_id_name
+ */
+typedef struct etch_type_impl
+{
+ 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_hashtable* fieldmap; /* map owned, content not owned */
+ etch_hashtable* vtormap; /* map & keys owned, values maybe */
+ /* if validators order is significant we can use etch_arraylist */
+
+ etch_type* result_type; /* not owned */
+ etch_type* super_type; /* not owned */
+ etch_field* response_field; /* not owned */
+
+ opaque_stubhelper stubhelper; /* stub helper method */
+ etch_serializer* impexphelper; /* owned */
+
+ unsigned int timeout; /* ms to wait for response */
+ unsigned int component_class; /* type/class of content, not owned */
+ unsigned char is_run_validators;
+ unsigned char async_mode;
+
+} etch_type_impl;
+
+
+etch_type* new_type(const wchar_t* name);
+etch_type* new_static_type(const wchar_t* name);
+etch_type* clone_type(const etch_type*);
+int destroy_type(etch_type*);
+int destroy_static_type(etch_type*);
+
+etch_field* etchtype_add_field (etch_type*, etch_field* field);
+etch_field* etchtype_get_field_by_id (etch_type*, const unsigned id);
+etch_field* etchtype_get_field_by_name(etch_type*, const wchar_t* name);
+etch_id_name* etchtype_get_key_by_id (etch_hashtable*, const unsigned id);
+etch_id_name* etchtype_get_key_by_name (etch_hashtable*, const wchar_t*);
+int etchtype_set_fields_iterator(etch_type*, etch_iterator*);
+void* etchtype_get_fields (etch_type*);
+int etchtype_fields_count(etch_type*);
+
+int etchtype_put_validator (etch_type*, etch_field*, objmask*);
+objmask* etchtype_get_validator_by_id (etch_type*, const unsigned id);
+objmask* etchtype_get_validator_by_name(etch_type*, const wchar_t* name);
+int etchtype_set_validators_iterator(etch_type*, etch_iterator*);
+int etchtype_clear_validator (etch_type*, etch_field*);
+int etchtype_clear_validators(etch_type*);
+int etchtype_validators_count(etch_type*);
+
+unsigned int etchtype_get_timeout(etch_type*);
+unsigned int etchtype_set_timeout(etch_type*, unsigned int ms);
+etch_field* etchtype_get_response_field(etch_type*);
+etch_field* etchtype_set_response_field(etch_type*, etch_field*);
+unsigned int etchtype_get_component_type(etch_type*);
+unsigned int etchtype_set_component_type(etch_type*, unsigned int typeclass);
+etch_type* etchtype_set_result_type(etch_type*, etch_type* rtype);
+etch_type* etchtype_get_result_type(etch_type*);
+etch_type* etchtype_set_super_type(etch_type*, etch_type* stype);
+etch_type* etchtype_get_super_type(etch_type*);
+unsigned char etchtype_set_run_validators(etch_type*, unsigned char val);
+unsigned char etchtype_get_run_validators(etch_type*);
+unsigned char etchtype_set_async_mode (etch_type*, unsigned char);
+unsigned char etchtype_get_async_mode (etch_type*);
+opaque_stubhelper etchtype_set_type_stubhelper(etch_type*, opaque_stubhelper);
+opaque_stubhelper etchtype_get_type_stubhelper(etch_type*);
+etch_serializer* etchtype_set_impexphelper(etch_type*, etch_serializer*);
+etch_serializer* etchtype_get_impexphelper(etch_type*);
+int etchtype_is_assignable_from(etch_type* type, etch_type* othertype);
+
+#define is_good_type is_good_id_name
+#define is_equal_types is_equal_id_names
+#define compute_type_id compute_id_name_id
+#define compute_type_id_from_widename compute_field_id_from_widename
+
+
+#endif /* #ifndef ETCHTYPE_H*/
\ No newline at end of file
Added: incubator/etch/trunk/binding-c/runtime/c/inc/etch_url.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etch_url.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etch_url.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etch_url.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,89 @@
+/* $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.
+ */
+
+/*
+ * etchurl.h -- URL class
+ * modeled after java binding URL class
+ */
+
+#ifndef ETCHURL_H
+#define ETCHURL_H
+
+#include "etch_collection.h"
+#include "etch_arraylist.h"
+#include "etchhash.h"
+
+#define ETCH_URL_DEFAULT_SCHEME L"http"
+#define ETCH_URL_DEFNUMPARMS 4
+#define ETCH_URL_DEFNUMTERMS 4
+#define ETCH_URL_DEFSUBTERMS 4
+
+
+typedef struct etch_url
+{
+ 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;
+
+ unsigned port;
+
+ wchar_t* raw;
+ wchar_t* scheme;
+ wchar_t* user;
+ wchar_t* password;
+ wchar_t* fragment;
+ wchar_t* host;
+ wchar_t* uri;
+
+ etch_arraylist* params;
+ etch_hashtable* terms;
+
+ size_t charcount;
+ size_t bytecount;
+
+} etch_url;
+
+
+etch_url* new_url(wchar_t* urlstring);
+etch_object* etchurl_get_term (etch_url*, const wchar_t* termname);
+boolean etchurl_get_boolean_term(etch_url*, const wchar_t* termname, boolean* retval);
+etch_iterator* etchurl_get_params(etch_url*);
+objmask* etchurl_remove_term(etch_url*, wchar_t* key);
+int etchurl_get_integer_term(etch_url*, const wchar_t* termname, int* retval);
+int etchurl_add_term(etch_url*, wchar_t* termname, wchar_t* termval);
+int etchurl_add_double_term( etch_url*, wchar_t* termname, const double termval);
+int etchurl_add_integer_term(etch_url*, wchar_t* termname, const int termval);
+int etchurl_paramcount(etch_url*);
+int etchurl_termcount (etch_url*);
+
+int is_url_scheme_http (etch_url*);
+int is_url_scheme_udp (etch_url*);
+
+#endif /* #ifndef ETCHURL_H */
\ No newline at end of file
Added: incubator/etch/trunk/binding-c/runtime/c/inc/etch_validator.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etch_validator.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etch_validator.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etch_validator.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,275 @@
+/* $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.
+ */
+
+/*
+ * etch_validator.h
+ */
+
+#ifndef ETCH_VTOR_H
+#define ETCH_VTOR_H
+
+#include "etchobj.h"
+#include "etch_type.h"
+
+#define ETCHVTOR_MAX_NDIMS 3 /* max array dimensions */
+#define ETCHVTOR_MAX_CACHED 4 /* max cached vtors per type */
+
+struct etch_validator;
+typedef int (*etchvtor_validate) (struct etch_validator*, etch_object*);
+typedef int (*etchvtor_checkvalue) (struct etch_validator*, etch_object*, byte* out);
+typedef etch_object* (*etchvtor_validate_value) (struct etch_validator*, etch_object*);
+typedef struct etch_validator* (*etchvtor_element_validator) (struct etch_validator*);
+
+
+/**
+ * etch_validator
+ * vet message values
+ */
+typedef struct etch_validator
+{
+ 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;
+
+ /* etch_validator virtuals
+ */
+ etchvtor_validate validate;
+ etchvtor_checkvalue check_value;
+ etchvtor_validate_value validate_value;
+ etchvtor_element_validator element_validator;
+
+ /* etch_type_validator instance data
+ */
+ unsigned short expected_obj_type;
+ unsigned short expected_class_id;
+ int numdimensions;
+ char* description; /* owned */
+ etch_type* struct_type; /* not owned */
+ etchparentinfo* inherits_from; /* owned or not, see flag */
+ unsigned char is_cached;
+ unsigned char is_subclassable;
+ unsigned char is_owned_inherits_from;
+ unsigned char unused;
+
+ /* etch_combo_validator instance data
+ */
+ struct etch_validator* vtor_a; /* not owned */
+ struct etch_validator* vtor_b; /* not owned */
+
+} etch_validator;
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * validator constructors and public methods
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+etch_validator* new_validator();
+
+etch_validator* new_validator_from(etchvtor_validate, etchvtor_checkvalue,
+ etchvtor_element_validator, etchvtor_validate_value);
+
+etch_validator* new_type_validator_1
+ (const unsigned short vtor_classid,
+ const unsigned short scalar_obj_type,
+ const unsigned short scalar_classid,
+ const unsigned short scalar_vtabkey,
+ const unsigned short array_classid,
+ const int ndims, char* descr);
+
+etch_validator* new_type_validator_2
+ (const unsigned short vtor_classid,
+ const unsigned short scalar_obj_type,
+ const unsigned short scalar_classid,
+ const unsigned short array_classid,
+ etchparentinfo* inheritlist,
+ const int ndims, char* descr);
+
+int etchvtor_check_dimensions(const int);
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * validator cache
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+
+/* the validator cache is a single memory array, subdivided into caches for
+ * each validator type, which caches instantiated validators. validators are
+ * cached to a max number of dimensions. end of service processing should
+ * iterate the static cache and free memory for validators cached therein,
+ * in order for memory allocation tests to pass. validators have an is_cached
+ * flag, regarded by the etch_validator dtor, so validator user can destroy()
+ * validator regardless of its cache state, the dtor will check the flag and
+ * refuse to destroy if cached. the final cleanup must therefore clear the
+ * is_cached marker on each cached validator prior to calling destroy().
+ */
+#define ETCHVTOR_CACHED_TYPE_COUNT 12 /* count of cached validator types */
+#define ETCHVTOR_BYTES_PER_CACHE (sizeof(void*) * ETCHVTOR_MAX_CACHED)
+
+etch_validator* etchvtor_cache /* the validator cache */
+ [ETCHVTOR_CACHED_TYPE_COUNT * ETCHVTOR_MAX_CACHED];
+
+void etchvtor_clear_cache();
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * boolean validator
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+#define ETCHVTOR_CACHE_SLOT_BOOLEAN 0 /* boolean validator cache slot index */
+etch_validator** etchvtor_cache_boolean; /* boolean validator cache address */
+etch_validator* etchvtor_boolean_get (const int dimensions);
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * byte validator
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+#define ETCHVTOR_CACHE_SLOT_BYTE 1 /* byte validator cache slot index */
+etch_validator** etchvtor_cache_byte; /* byte validator cache address */
+etch_validator* etchvtor_byte_get (const int dimensions);
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * int8 validator
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+#define ETCHVTOR_CACHE_SLOT_INT8 2 /* int8 validator cache slot index */
+etch_validator** etchvtor_cache_int8; /* int8 validator cache address */
+etch_validator* etchvtor_int8_get (const int dimensions);
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * int16 validator
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+#define ETCHVTOR_CACHE_SLOT_INT16 3 /* int16 validator cache slot index */
+etch_validator** etchvtor_cache_int16; /* int16 validator cache address */
+etch_validator* etchvtor_int16_get (const int dimensions);
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * int32 validator
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+#define ETCHVTOR_CACHE_SLOT_INT32 4 /* int32 validator cache slot index */
+etch_validator** etchvtor_cache_int32; /* int32 validator cache address */
+etch_validator* etchvtor_int32_get (const int dimensions);
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * int64 validator
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+#define ETCHVTOR_CACHE_SLOT_INT64 5 /* int64 validator cache slot index */
+etch_validator** etchvtor_cache_int64; /* int64 validator cache address */
+etch_validator* etchvtor_int64_get (const int dimensions);
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * float validator
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+#define ETCHVTOR_CACHE_SLOT_FLOAT 6 /* float validator cache slot index */
+etch_validator** etchvtor_cache_float; /* float validator cache address */
+etch_validator* etchvtor_float_get (const int dimensions);
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * double validator
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+#define ETCHVTOR_CACHE_SLOT_DOUBLE 7 /* double validator cache slot index */
+etch_validator** etchvtor_cache_double; /* double validator cache address */
+etch_validator* etchvtor_double_get (const int dimensions);
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * string validator
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+#define ETCHVTOR_CACHE_SLOT_STRING 8 /* string validator cache slot index */
+etch_validator** etchvtor_cache_string; /* string validator cache address */
+etch_validator* etchvtor_string_get (const int dimensions);
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * object validator (etch_object* anonymous wrapper)
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+#define ETCHVTOR_CACHE_SLOT_OBJECT 9 /* object validator cache slot index */
+etch_validator** etchvtor_cache_object; /* object validator cache address */
+etch_validator* etchvtor_object_get (const int dimensions);
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * exception validator
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+#define ETCHVTOR_CACHE_SLOT_EXCEPTION 10 /* excp validator cache slot index */
+etch_validator** etchvtor_cache_exception; /* excp validator cache address */
+etch_validator* etchvtor_exception_get();
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * eod_validator (end-of-data maker "none")
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+#define ETCHVTOR_CACHE_SLOT_EOD 11 /* eod validator cache slot index */
+etch_validator** etchvtor_cache_eod; /* eod validator cache address */
+etch_validator* etchvtor_eod_get ();
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * struct validator (not cached since unique per type)
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+etch_validator* new_validator_struct();
+etch_validator* etchvtor_struct_get(etch_type*, const int numdims);
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * combo validator (not cached)
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+etch_validator* new_combo_validator(etch_validator* vtor_a, etch_validator* vtor_b);
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ * custom validator (cached in a custom cache)
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ */
+etch_validator* new_validator_custom(const unsigned short obj_type,
+ const unsigned short class_id, etch_type*, const int numdims);
+
+etch_validator* etchvtor_custom_get(const unsigned short obj_type,
+ const unsigned short class_id, etch_type*, const int numdims);
+
+
+#endif /* #ifndef ETCH_VTOR_H */
\ No newline at end of file
Added: incubator/etch/trunk/binding-c/runtime/c/inc/etch_valuefact.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etch_valuefact.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etch_valuefact.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etch_valuefact.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,47 @@
+/*
+ * etch_valuefact.h
+ */
+
+#ifndef ETCHVALFACT_H
+#define ETCHVALFACT_H
+
+#include "etch_structval.h"
+
+
+/*
+ * value factory interface
+ */
+struct i_value_factory
+{
+ unsigned short obj_type;
+ unsigned short class_id;
+ struct i_value_factory* vtab;
+
+};
+
+typedef struct i_value_factory i_value_factory;
+
+
+/*
+ * value factory implementation
+ */
+struct etch_value_factory
+{
+ unsigned short obj_type;
+ unsigned short class_id;
+ i_value_factory* vtab;
+ void* impl;
+};
+
+typedef struct etch_value_factory etch_value_factory;
+
+
+/*
+ * constructors
+ */
+etch_value_factory* new_etch_value_factory();
+ETCH_VALUEFACTORY* new_boxed_value_factory();
+
+
+
+#endif /* #ifndef ETCHVALFACT_H*/
\ No newline at end of file
Added: incubator/etch/trunk/binding-c/runtime/c/inc/etch_valufact.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etch_valufact.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etch_valufact.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etch_valufact.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.
+ */
+
+/*
+ * etch_valufact.h
+ * value factory is an interface defining the value factory which helps the
+ * idl compiler serialize and deserialize messages, convert values, etc.
+ */
+
+#ifndef ETCH_VALUFACT_H
+#define ETCH_VALUFACT_H
+
+#include "etchmsgutl.h"
+#include "etch_arraylist.h"
+#include "etch_structval.h"
+
+struct i_value_factory;
+struct etch_message;
+typedef struct etch_message etch_message;
+struct default_value_factory;
+typedef struct default_value_factory default_value_factory;
+
+
+/**
+ * value_factory
+ * value factory implementation
+ */
+typedef struct etch_value_factory
+{
+ unsigned int hashkey;
+ unsigned short obj_type;
+ unsigned short class_id;
+ struct i_value_factory* 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;
+
+ objmask* impl;
+
+} etch_value_factory;
+
+
+/**
+ * i_value_factory
+ * virtual function table for value factory
+ */
+struct i_value_factory
+{
+ unsigned int hashkey;
+ unsigned short obj_type;
+ unsigned short class_id;
+ struct i_value_factory* 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;
+
+ /* - - - - - - - - - - - -
+ * type
+ * - - - - - - - - - - - -
+ */
+
+ /**
+ * adds a type to the set of types.
+ * @return the argument. If there is a collision with
+ * an id and name, both associated with the same type,
+ * then that type is returned instead of the argument.
+ * @throws IllegalArgumentException (returns NULL) if
+ * bad arg, or if collision in the id or name or both,
+ * when not associated with the same type.
+ */
+ etch_type* (*add_type) (void* vf, etch_type*);
+
+ /**
+ * translates a type id into the associated etch_type object.
+ */
+ etch_type* (*get_type_by_id) (void* vf, const unsigned id);
+
+ /**
+ * translates a name into the associated etch_type object.
+ */
+ etch_type* (*get_type_by_name) (void* vf, const wchar_t* name);
+
+ /**
+ * @return a collection of all the types
+ */
+ etch_arraylist* (*get_types) (void* vf);
+
+
+ /* - - - - - - - - - - - -
+ * encoding
+ * - - - - - - - - - - - -
+ */
+
+ /**
+ * @return the encoding to use for strings.
+ */
+ wchar_t* (*get_string_encoding) (void* vf);
+
+
+ /* - - - - - - - - - - - -
+ * message id
+ * - - - - - - - - - - - -
+ */
+
+ /**
+ * @param msg the message whose well-known id field is to be returned.
+ * @return the value of the well-known message-id field. This is a
+ * unique identifier for this message on a particular transport
+ * during a particular session. If there is no well-known message-id
+ * field defined, or if the message-id field has not been set, then
+ * return null. TODO: determine WHY we can't return an int64 with value
+ * zero equating to null?
+ */
+ etch_int64* (*get_message_id) (void* vf, etch_message*);
+
+ /**
+ * sets the value of the well-known message-id field. this is a unique
+ * identifier for this message on a particular transport during a
+ * particular session. if there is no well-known message-id field
+ * defined then no action is taken. if msgid is null, the field
+ * is cleared.
+ * regardless, the msgid object memory is owned by this method, to be
+ * assigned to the value factory; therefore if the action fails, this
+ * method must destroy the object.
+ */
+ int (*set_message_id) (void* vf, etch_message*, etch_int64* msgid);
+
+
+ /* - - - - - - - - - - - -
+ * reply to
+ * - - - - - - - - - - - -
+ */
+
+ /**
+ * @return the value of the in-reply-to field, or null if there is
+ * none or if there is no such field defined.
+ */
+ etch_int64* (*get_in_reply_to) (void* vf, etch_message*);
+
+ /**
+ * if no well-known in-reply-to field defined then no action is taken.
+ * if msgid is null, the field is cleared.
+ */
+ int (*set_in_reply_to) (void* vf, etch_message*, etch_int64* msgid);
+
+
+ /* - - - - - - - - - - - -
+ * value conversion
+ * - - - - - - - - - - - -
+ */
+
+ /**
+ * Converts a value to a struct value representation to be exported
+ * to a tagged data output.
+ * @param value a custom type defined by a service, or a well-known
+ * standard type (e.g., date).
+ * @return a struct value representing the value.
+ */
+ etch_structvalue* (*export_custom_value) (void* vf, objmask* value);
+
+ /**
+ * Converts a struct value imported from a tagged data input to
+ * a normal type.
+ * @param sv a struct value representation of a custom type, or a
+ * well known standard type.
+ * @return a custom type, or a well known standard type.
+ */
+ objmask* (*import_custom_value) (void* vf, etch_structvalue* sv);
+
+ /**
+ * @param class_id the class of a custom value.
+ * @return the struct type of a custom value class.
+ */
+ etch_type* (*get_custom_struct_type) (void* vf, const unsigned etchclass);
+
+ /**
+ * get well-known message type for exception thrown by oneway message
+ */
+ etch_type* (*get_mt_exception) (void* vf);
+};
+
+typedef struct i_value_factory i_value_factory;
+
+
+
+/**
+ * constructors/destructors
+ */
+etch_value_factory* new_value_factory(const int objlen);
+
+int destroy_valuefactory(etch_value_factory*);
+
+
+#endif /* #ifndef ETCH_VALUFACT_H */
\ No newline at end of file
Added: incubator/etch/trunk/binding-c/runtime/c/inc/etchdefs.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etchdefs.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etchdefs.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etchdefs.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,94 @@
+/* $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.
+ */
+
+/*
+ * etchdefs.h -- type and constant definitions etc
+ */
+
+#ifndef ETCHDEFS_H
+#define ETCHDEFS_H
+#include <io.h>
+
+typedef long long int64;
+typedef unsigned long long uint64;
+typedef unsigned char byte;
+typedef unsigned char boolean;
+#undef NULL
+#define NULL 0
+#undef FALSE
+#define FALSE 0
+#undef TRUE
+#define TRUE 1
+#undef BOOLEAN
+#define BOOLEAN int
+#undef BYTE
+
+
+#ifdef IS_WINDOWS_ETCH
+#define MAXPATHSIZE 260 /* value of MAX_PATH in windef.h */
+#define etch_deletefile _unlink
+#else
+#define MAXPATHSIZE 260 /* TODO max pathsize for linux etc */
+#define etch_deletefile unlink
+#endif
+
+#ifndef _TCHAR
+#define _TCHAR wchar_t
+#endif
+
+#define MAX_ETCHHASHKEY 128 /* arbitrary max byte length of a hashtable key */
+
+#define INITIAL_CACHE_SIZE_ITEMS 32 /* global cache starts out capacity 32 */
+
+#define ETCH_ASSERT(condition) assert(condition)
+
+#define ETCH_ASYNCMODE_NONE 0 /* implies operation is synchronous */
+#define ETCH_ASYNCMODE_QUEUED 1 /* operation is queued to a thread pool */
+#define ETCH_ASYNCMODE_FREE 2 /* operation is executed in a new thread */
+
+#define ETCH_DEFSIZE 0
+#define ETCH_INFWAIT 0
+#define ETCH_NOWAIT (-1)
+#define ETCH_TIMEOUT 1
+#define ETCH_INTERRUPTED 2
+
+#define ETCH_THREADPOOLTYPE_FREE 0
+#define ETCH_THREADPOOLTYPE_QUEUED 1
+
+#define ETCH_TRANSPORT_FORMAT_BINARY 0
+#define ETCH_TRANSPORT_FORMAT_XML 1
+
+#define ETCH_ENCODING_ASCII 1
+#define ETCH_ENCODING_UTF8 2
+#define ETCH_ENCODING_UTF16 3
+#define ETCH_ENCODING_DEFAULT ETCH_ENCODING_UTF8
+#define IS_ETCH_ENCODING_8BIT(n) (n == ETCH_ENCODING_UTF8 || n == ETCH_ENCODING_ASCII)
+
+#define ETCHMAKECLASS(t,c) ((t << 16) | c)
+#define ETCHGETCLASS(n,t,c) do{ c=(short)(n & 0xffff); t=(short)(n>>16); }while(0);
+
+#define ETCH_SHUTDOWNSIGNAL "$ETCHQUIT"
+
+#define ETCH_DEBUG
+#ifdef ETCH_DEBUG
+int g_debugtest;
+#endif
+
+
+
+#endif /* #ifndef ETCHDEFS_H */
\ No newline at end of file
Added: incubator/etch/trunk/binding-c/runtime/c/inc/etchexcp.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etchexcp.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etchexcp.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etchexcp.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,149 @@
+/* $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.
+ */
+
+/*
+ * etchexcp.h -- etch exception
+ */
+
+#ifndef ETCHEXCP_H
+#define ETCHEXCP_H
+
+#include "etchobj.h"
+
+
+/**
+ * etchexception.flags bits
+ */
+#define ETCHEXCP_NONE 0
+#define ETCHEXCP_STATICTEXT 1
+#define ETCHEXCP_COPYTEXT 2
+#define ETCHEXCP_FREETEXT 4
+#define ETCHEXCP_CHECKED 8
+
+
+/**
+ * exception type identifiers
+ */
+typedef enum excptype
+{
+ EXCPTYPE_NONE = 0x0,
+ EXCPTYPE_GENERIC = 0x1,
+ EXCPTYPE_IO = 0x2,
+ EXCPTYPE_ILLEGALARG = 0x3,
+ EXCPTYPE_NULLPTR = 0x4,
+ EXCPTYPE_UNSUPPORTEDOP = 0x5,
+ EXCPTYPE_INTERNALERR = 0x6,
+ EXCPTYPE_ETCHAUTH = 0x10,
+ EXCPTYPE_ETCHRUNTIME = 0x11,
+ EXCPTYPE_NOTFOUND = 0x20,
+ EXCPTYPE_CHECKED_START = 0x40,
+ EXCPTYPE_CHECKED_BOGUS = 0x41,
+} excptype;
+
+
+/**
+ * result codes
+ */
+typedef enum results
+{
+ ETCHRESULT_TRUE = 1,
+ ETCHRESULT_OK = 0,
+ ETCHRESULT_FALSE = 0,
+ ETCHRESULT_ERROR = (-1),
+ ETCHRESULT_NOTFOUND = (-1),
+ ETCHRESULT_EXCPERR_IO = (-1),
+ ETCHRESULT_EXCPERR_BADARG = (-2),
+ ETCHRESULT_EXCPERR_NULLPTR = (-3),
+ ETCHRESULT_EXCPERR_BADOP = (-4),
+ ETCHRESULT_EXCPERR_INTERNAL= (-5),
+} results;
+
+/* exception text */
+const wchar_t* excptext_excp;
+const wchar_t* excptext_io;
+const wchar_t* excptext_nullptr;
+const wchar_t* excptext_arg;
+const wchar_t* excptext_unsupop;
+const wchar_t* excptext_internal;
+const wchar_t* excptext_notfound;
+
+
+/**
+ * etchexception native object
+ */
+struct etchexception
+{
+ excptype excptype;
+ wchar_t* excptext;
+ char* ansitext; /* ansi copy of text for display etc always owned */
+ size_t textlen; /* byte length of unicode text including nullterm */
+ size_t atxtlen; /* byte length of ansi text including nullterm */
+ unsigned flags; /* ETCHEXCP_XXXX */
+};
+
+typedef struct etchexception etchexception;
+
+/**
+ * etch_throw()
+ * "throw" specified exception, meaning instantiate exception and attach to object
+ */
+objmask* etch_throw (void* obj, const excptype t, wchar_t* opttext, unsigned flags);
+
+/**
+ * etch_throwex()
+ * as "throw" but also including result code and reason code
+ */
+objmask* get_excpobj(int objsize, short obj_type, short class_id,
+ excptype xcptype, wchar_t* xcptext, unsigned flags);
+
+/**
+ * native ctors and dtor
+ */
+void destroy_exception(etchexception* excp);
+etchexception* new_exception (const excptype t, wchar_t* x, const unsigned flags);
+etch_exception* new_etch_exception(const excptype t, wchar_t* x, const unsigned flags);
+
+/**
+ * default_excptext()
+ * gets default text for specified exception type.
+ */
+wchar_t* default_excptext(const excptype t);
+
+objmask* get_excpobj(int objsize, short obj_type, short class_id,
+ excptype xcptype, wchar_t* xcptext, unsigned flags);
+
+wchar_t* excp_tostring (etchexception*);
+char* excp_tostringx(etchexception*);
+
+/**
+ * catch, throw
+ */
+boolean is_catch_exception(objmask*j, const int result, objmask** out);
+boolean is_catch(objmask*, const int result, const int objtype, objmask** out);
+objmask* catch_exception(objmask*, const int result);
+objmask* throw_exception(objmask*, const int result);
+objmask* throw_exception_from(const short obj_type, const int result);
+objmask* throw_from(excptype, const short obj_type, wchar_t* text, unsigned flags);
+objmask* etch_rethrow(void* target, void* source);
+
+objmask* verifyx(objmask* obj, const unsigned short, const unsigned short, excptype xtype);
+etch_exception* get_etch_exception_from (objmask*);
+etchexception* get_exception_from (objmask*);
+etch_exception* new_etch_exception_from (objmask*);
+
+#endif /* #ifndef ETCHEXCP_H */
\ No newline at end of file
Added: incubator/etch/trunk/binding-c/runtime/c/inc/etchflexbuf.h
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-c/runtime/c/inc/etchflexbuf.h?rev=767594&view=auto
==============================================================================
--- incubator/etch/trunk/binding-c/runtime/c/inc/etchflexbuf.h (added)
+++ incubator/etch/trunk/binding-c/runtime/c/inc/etchflexbuf.h Wed Apr 22 17:25:43 2009
@@ -0,0 +1,102 @@
+/* $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.
+ */
+
+/*
+ * a flex_buffer wraps a byte array and manages the active region of
+ * it (0..length). it supports dynamically extending the buffer.
+ *
+ * a flexbuffer has an index (read or write cursor). the various get
+ * and put operations always occur at the current index, with the index
+ * adjusted appropriately afterward. get() will not move the index past
+ * length. if put needs to move index past length, length is also
+ * adjusted. this may cause the byte array to be re-allocated.
+ */
+
+#ifndef ETCH_FLEX_BUFFER_H
+#define ETCH_FLEX_BUFFER_H
+
+#include "etchobj.h"
+#define ETCH_FLEXBUF_PUT_ALL (-1)
+
+
+typedef struct etch_flexbuffer
+{
+ 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_littleendian;
+
+ unsigned char *buf;
+ size_t bufsize; /* buffer size */
+ size_t datalen; /* data length */
+ size_t index; /* current position */
+
+} etch_flexbuffer;
+
+etch_flexbuffer *new_flexbuffer(size_t);
+etch_flexbuffer *new_flexwriter_from (void *buf, size_t, size_t);
+etch_flexbuffer *new_flexbuffer_from (void *buf, size_t, size_t, size_t);
+etch_flexbuffer *etch_flexbuf_create_b (void *buf, size_t, size_t);
+etch_flexbuffer *etch_flexbuf_create_bi(void *buf, size_t, size_t, size_t);
+etch_flexbuffer *etch_flexbuf_skip (etch_flexbuffer*, size_t, int);
+
+byte* etch_flexbuf_get_buffer(etch_flexbuffer*);
+int destroy_etch_flexbuffer(etch_flexbuffer*);
+int etch_flexbuf_set_length(etch_flexbuffer*, size_t);
+int etch_flexbuf_set_index (etch_flexbuffer*, size_t);
+void etch_flexbuf_clear (etch_flexbuffer*);
+size_t etch_flexbuf_avail (etch_flexbuffer*);
+int etch_flexbuffer_reset_to (etch_flexbuffer*, size_t);
+etch_flexbuffer *etch_flexbuf_compact(etch_flexbuffer*);
+etch_flexbuffer *etch_flexbuf_reset (etch_flexbuffer*);
+
+size_t etch_flexbuf_get (etch_flexbuffer*, byte*, size_t, size_t);
+
+int etch_flexbuf_get_byte (etch_flexbuffer*, byte* out);
+int etch_flexbuf_get_short (etch_flexbuffer*, short* out);
+int etch_flexbuf_get_int (etch_flexbuffer*, int* out);
+int etch_flexbuf_get_long (etch_flexbuffer*, int64* out);
+int etch_flexbuf_get_float (etch_flexbuffer*, float* out);
+int etch_flexbuf_get_double(etch_flexbuffer*, double* out);
+
+size_t etch_flexbuf_get_fully (etch_flexbuffer*, byte*, size_t);
+byte* etch_flexbuf_get_all (etch_flexbuffer*, size_t* out_count);
+byte* etch_flexbuf_get_allfrom(etch_flexbuffer*, size_t, size_t* out_count);
+
+size_t etch_flexbuf_put (etch_flexbuffer*, byte*, size_t, size_t);
+size_t etch_flexbuf_put_from (etch_flexbuffer*, etch_flexbuffer*, size_t);
+size_t etch_flexbuf_put_byte (etch_flexbuffer*, byte value);
+size_t etch_flexbuf_put_short (etch_flexbuffer*, short value);
+size_t etch_flexbuf_put_int (etch_flexbuffer*, int value);
+size_t etch_flexbuf_put_long (etch_flexbuffer*, int64 value);
+size_t etch_flexbuf_put_float (etch_flexbuffer*, float value);
+size_t etch_flexbuf_put_double (etch_flexbuffer*, double value);
+
+
+#endif /* ETCH_FLEX_BUFFER_H */
\ No newline at end of file