[asterisk-commits] eliel: branch group/data_api_gsoc2009 r206124 - in /team/group/data_api_gsoc2...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jul 13 09:59:21 CDT 2009
Author: eliel
Date: Mon Jul 13 09:59:17 2009
New Revision: 206124
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=206124
Log:
Add another simplification to the structure members mapping.
Add more documentation.
Modified:
team/group/data_api_gsoc2009/apps/app_queue.c
team/group/data_api_gsoc2009/include/asterisk/data.h
Modified: team/group/data_api_gsoc2009/apps/app_queue.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/apps/app_queue.c?view=diff&rev=206124&r1=206123&r2=206124
==============================================================================
--- team/group/data_api_gsoc2009/apps/app_queue.c (original)
+++ team/group/data_api_gsoc2009/apps/app_queue.c Mon Jul 13 09:59:17 2009
@@ -7390,89 +7390,92 @@
};
/* struct call_queue astdata mapping. */
-#define DATA_EXPORT_CALL_QUEUE(MEMBER) \
- MEMBER(call_queue, name, AST_DATA_STRING, char *) \
- MEMBER(call_queue, moh, AST_DATA_STRING, char *) \
- MEMBER(call_queue, announce, AST_DATA_STRING, char *) \
- MEMBER(call_queue, context, AST_DATA_STRING, char *) \
- MEMBER(call_queue, membermacro, AST_DATA_STRING, char *) \
- MEMBER(call_queue, membergosub, AST_DATA_STRING, char *) \
- MEMBER(call_queue, defaultrule, AST_DATA_STRING, char *) \
- MEMBER(call_queue, sound_next, AST_DATA_STRING, char *) \
- MEMBER(call_queue, sound_thereare, AST_DATA_STRING, char *) \
- MEMBER(call_queue, sound_calls, AST_DATA_STRING, char *) \
- MEMBER(call_queue, queue_quantity1, AST_DATA_STRING, char *) \
- MEMBER(call_queue, queue_quantity2, AST_DATA_STRING, char *) \
- MEMBER(call_queue, sound_holdtime, AST_DATA_STRING, char *) \
- MEMBER(call_queue, sound_minutes, AST_DATA_STRING, char *) \
- MEMBER(call_queue, sound_minute, AST_DATA_STRING, char *) \
- MEMBER(call_queue, sound_seconds, AST_DATA_STRING, char *) \
- MEMBER(call_queue, sound_thanks, AST_DATA_STRING, char *) \
- MEMBER(call_queue, sound_callerannounce, AST_DATA_STRING, char *) \
- MEMBER(call_queue, sound_reporthold, AST_DATA_STRING, char *) \
- MEMBER(call_queue, dead, AST_DATA_BOOLEAN, unsigned int) \
- MEMBER(call_queue, eventwhencalled, AST_DATA_BOOLEAN, unsigned int) \
- MEMBER(call_queue, ringinuse, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, setinterfacevar, AST_DATA_BOOLEAN, unsigned int) \
- MEMBER(call_queue, setqueuevar, AST_DATA_BOOLEAN, unsigned int) \
- MEMBER(call_queue, setqueueentryvar, AST_DATA_BOOLEAN, unsigned int) \
- MEMBER(call_queue, reportholdtime, AST_DATA_BOOLEAN, unsigned int) \
- MEMBER(call_queue, wrapped, AST_DATA_BOOLEAN, unsigned int) \
- MEMBER(call_queue, timeoutrestart, AST_DATA_BOOLEAN, unsigned int) \
- MEMBER(call_queue, announceholdtime, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, announceposition, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, strategy, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, maskmemberstatus, AST_DATA_BOOLEAN, unsigned int) \
- MEMBER(call_queue, realtime, AST_DATA_BOOLEAN, unsigned int) \
- MEMBER(call_queue, found, AST_DATA_BOOLEAN, unsigned int) \
- MEMBER(call_queue, announcepositionlimit, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, announcefrequency, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, minannouncefrequency, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, periodicannouncefrequency, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, numperiodicannounce, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, randomperiodicannounce, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, roundingseconds, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, holdtime, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, talktime, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, callscompleted, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, callsabandoned, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, servicelevel, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, callscompletedinsl, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, monfmt, AST_DATA_STRING, char *) \
- MEMBER(call_queue, montype, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, count, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, maxlen, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, wrapuptime, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, retry, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, timeout, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, weight, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, autopause, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, timeoutpriority, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, rrpos, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, memberdelay, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, autofill, AST_DATA_INTEGER, int) \
- MEMBER(call_queue, membercount, AST_DATA_INTEGER, int)
+#define DATA_EXPORT_CALL_QUEUE(MEMBER) \
+ MEMBER(call_queue, name, AST_DATA_STRING) \
+ MEMBER(call_queue, moh, AST_DATA_STRING) \
+ MEMBER(call_queue, announce, AST_DATA_STRING) \
+ MEMBER(call_queue, context, AST_DATA_STRING) \
+ MEMBER(call_queue, membermacro, AST_DATA_STRING) \
+ MEMBER(call_queue, membergosub, AST_DATA_STRING) \
+ MEMBER(call_queue, defaultrule, AST_DATA_STRING) \
+ MEMBER(call_queue, sound_next, AST_DATA_STRING) \
+ MEMBER(call_queue, sound_thereare, AST_DATA_STRING) \
+ MEMBER(call_queue, sound_calls, AST_DATA_STRING) \
+ MEMBER(call_queue, queue_quantity1, AST_DATA_STRING) \
+ MEMBER(call_queue, queue_quantity2, AST_DATA_STRING) \
+ MEMBER(call_queue, sound_holdtime, AST_DATA_STRING) \
+ MEMBER(call_queue, sound_minutes, AST_DATA_STRING) \
+ MEMBER(call_queue, sound_minute, AST_DATA_STRING) \
+ MEMBER(call_queue, sound_seconds, AST_DATA_STRING) \
+ MEMBER(call_queue, sound_thanks, AST_DATA_STRING) \
+ MEMBER(call_queue, sound_callerannounce, AST_DATA_STRING) \
+ MEMBER(call_queue, sound_reporthold, AST_DATA_STRING) \
+ MEMBER(call_queue, dead, AST_DATA_BOOLEAN) \
+ MEMBER(call_queue, eventwhencalled, AST_DATA_BOOLEAN) \
+ MEMBER(call_queue, ringinuse, AST_DATA_INTEGER) \
+ MEMBER(call_queue, setinterfacevar, AST_DATA_BOOLEAN) \
+ MEMBER(call_queue, setqueuevar, AST_DATA_BOOLEAN) \
+ MEMBER(call_queue, setqueueentryvar, AST_DATA_BOOLEAN) \
+ MEMBER(call_queue, reportholdtime, AST_DATA_BOOLEAN) \
+ MEMBER(call_queue, wrapped, AST_DATA_BOOLEAN) \
+ MEMBER(call_queue, timeoutrestart, AST_DATA_BOOLEAN) \
+ MEMBER(call_queue, announceholdtime, AST_DATA_INTEGER) \
+ MEMBER(call_queue, announceposition, AST_DATA_INTEGER) \
+ MEMBER(call_queue, strategy, AST_DATA_INTEGER) \
+ MEMBER(call_queue, maskmemberstatus, AST_DATA_BOOLEAN) \
+ MEMBER(call_queue, realtime, AST_DATA_BOOLEAN) \
+ MEMBER(call_queue, found, AST_DATA_BOOLEAN) \
+ MEMBER(call_queue, announcepositionlimit, AST_DATA_INTEGER) \
+ MEMBER(call_queue, announcefrequency, AST_DATA_INTEGER) \
+ MEMBER(call_queue, minannouncefrequency, AST_DATA_INTEGER) \
+ MEMBER(call_queue, periodicannouncefrequency, AST_DATA_INTEGER) \
+ MEMBER(call_queue, numperiodicannounce, AST_DATA_INTEGER) \
+ MEMBER(call_queue, randomperiodicannounce, AST_DATA_INTEGER) \
+ MEMBER(call_queue, roundingseconds, AST_DATA_INTEGER) \
+ MEMBER(call_queue, holdtime, AST_DATA_INTEGER) \
+ MEMBER(call_queue, talktime, AST_DATA_INTEGER) \
+ MEMBER(call_queue, callscompleted, AST_DATA_INTEGER) \
+ MEMBER(call_queue, callsabandoned, AST_DATA_INTEGER) \
+ MEMBER(call_queue, servicelevel, AST_DATA_INTEGER) \
+ MEMBER(call_queue, callscompletedinsl, AST_DATA_INTEGER) \
+ MEMBER(call_queue, monfmt, AST_DATA_STRING) \
+ MEMBER(call_queue, montype, AST_DATA_INTEGER) \
+ MEMBER(call_queue, count, AST_DATA_INTEGER) \
+ MEMBER(call_queue, maxlen, AST_DATA_INTEGER) \
+ MEMBER(call_queue, wrapuptime, AST_DATA_INTEGER) \
+ MEMBER(call_queue, retry, AST_DATA_INTEGER) \
+ MEMBER(call_queue, timeout, AST_DATA_INTEGER) \
+ MEMBER(call_queue, weight, AST_DATA_INTEGER) \
+ MEMBER(call_queue, autopause, AST_DATA_INTEGER) \
+ MEMBER(call_queue, timeoutpriority, AST_DATA_INTEGER) \
+ MEMBER(call_queue, rrpos, AST_DATA_INTEGER) \
+ MEMBER(call_queue, memberdelay, AST_DATA_INTEGER) \
+ MEMBER(call_queue, autofill, AST_DATA_INTEGER) \
+ MEMBER(call_queue, membercount, AST_DATA_INTEGER)
AST_DATA_STRUCTURE(call_queue, DATA_EXPORT_CALL_QUEUE);
/* struct member astdata mapping. */
#define DATA_EXPORT_MEMBER(MEMBER) \
- MEMBER(member, interface, AST_DATA_STRING, char *) \
- MEMBER(member, state_interface, AST_DATA_STRING, char *) \
- MEMBER(member, membername, AST_DATA_STRING, char *) \
- MEMBER(member, penalty, AST_DATA_INTEGER, int) \
- MEMBER(member, calls, AST_DATA_INTEGER, int) \
- MEMBER(member, dynamic, AST_DATA_INTEGER, int) \
- MEMBER(member, realtime, AST_DATA_INTEGER, int) \
- MEMBER(member, status, AST_DATA_INTEGER, int) \
- MEMBER(member, paused, AST_DATA_INTEGER, int) \
- MEMBER(member, rt_uniqueid, AST_DATA_STRING, char *)
+ MEMBER(member, interface, AST_DATA_STRING) \
+ MEMBER(member, state_interface, AST_DATA_STRING) \
+ MEMBER(member, membername, AST_DATA_STRING) \
+ MEMBER(member, penalty, AST_DATA_INTEGER) \
+ MEMBER(member, calls, AST_DATA_INTEGER) \
+ MEMBER(member, dynamic, AST_DATA_INTEGER) \
+ MEMBER(member, realtime, AST_DATA_INTEGER) \
+ MEMBER(member, status, AST_DATA_INTEGER) \
+ MEMBER(member, paused, AST_DATA_INTEGER) \
+ MEMBER(member, rt_uniqueid, AST_DATA_STRING)
AST_DATA_STRUCTURE(member, DATA_EXPORT_MEMBER);
/*!
* \internal
- * \brief XXX-document this.
+ * \brief Callback used to generate the queues tree.
+ * \param[in] search The search pattern tree.
+ * \retval NULL on error.
+ * \retval non-NULL The generated tree.
*/
static struct ast_data *queues_data_provider_get(const struct ast_data_search *search)
{
Modified: team/group/data_api_gsoc2009/include/asterisk/data.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/include/asterisk/data.h?view=diff&rev=206124&r1=206123&r2=206124
==============================================================================
--- team/group/data_api_gsoc2009/include/asterisk/data.h (original)
+++ team/group/data_api_gsoc2009/include/asterisk/data.h Mon Jul 13 09:59:17 2009
@@ -145,8 +145,11 @@
/*! \brief Map the members of a structure. */
struct ast_data_mapping_structure {
+ /*! \brief structure member name. */
const char *name;
+ /*! \brief structure member type. */
enum ast_data_type type;
+ /*! \brief member getter. */
union {
char *(*AST_DATA_STRING)(void *ptr);
int (*AST_DATA_INTEGER)(void *ptr);
@@ -158,17 +161,39 @@
} get;
};
-#define AST_DATA_STRUCTURE(__struct, __name) \
- __name(__AST_DATA_MAPPING_FUNCTION); \
- struct ast_data_mapping_structure __data_mapping_structure_##__struct[] = { \
- __name(__AST_DATA_MAPPING_STRUCTURE) \
+/* Generate the structure and the functions to access the members of a structure. */
+#define AST_DATA_STRUCTURE(__struct, __name) \
+ __name(__AST_DATA_MAPPING_FUNCTION); \
+ struct ast_data_mapping_structure __data_mapping_structure_##__struct[] = { \
+ __name(__AST_DATA_MAPPING_STRUCTURE) \
}
-#define __AST_DATA_MAPPING_STRUCTURE(__structure, __member, __type, __real_type) \
+/* Generate the structure to access the members and setup the pointer of the getter. */
+#define __AST_DATA_MAPPING_STRUCTURE(__structure, __member, __type) \
{ .name = #__member, .get.__type = data_mapping_structure_get_##__structure##__member, \
.type = __type },
-#define __AST_DATA_MAPPING_FUNCTION(__structure, __member, __type, __real_type) \
+/* based on the data type, specifify the type of return value for the getter function. */
+#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_STRING(__structure, __member) \
+ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_STRING, char *)
+#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_INTEGER(__structure, __member) \
+ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_INTEGER, int)
+#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_UNSIGNED_INTEGER(__structure, __member) \
+ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_UNSIGNED_INTEGER, unsigned int)
+#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_BOOLEAN(__structure, __member) \
+ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_BOOLEAN, unsigned int)
+#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_POINTER(__structure, __member) \
+ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_POINTER, void *)
+#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_IPADDR(__structure, __member) \
+ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_IPADDR, struct in_addr)
+#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_DOUBLE(__structure, __member) \
+ __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_DBL, double)
+
+#define __AST_DATA_MAPPING_FUNCTION(__structure, __member, __type) \
+ __AST_DATA_MAPPING_FUNCTION_##__type(__structure, __member)
+
+/* Create the function to retrieve a member of the structure. */
+#define __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, __type, __real_type) \
static __real_type data_mapping_structure_get_##__structure##__member(void *ptr) { \
struct __structure *struct_##__member = (struct __structure *) ptr; \
return (__real_type) struct_##__member->__member; \
More information about the asterisk-commits
mailing list