[seed] [modules] DEFINE_ENUM_MEMBER macro
- From: Tim Horton <hortont src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed] [modules] DEFINE_ENUM_MEMBER macro
- Date: Sat, 4 Jul 2009 07:53:47 +0000 (UTC)
commit 15e99ed21d8833d0663062ae137eb59d5fb2bd3c
Author: Tim Horton <hortont svn gnome org>
Date: Sat Jul 4 03:28:55 2009 -0400
[modules] DEFINE_ENUM_MEMBER macro
modules/seed-module.h | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/modules/seed-module.h b/modules/seed-module.h
index 1055d5d..42f2402 100644
--- a/modules/seed-module.h
+++ b/modules/seed-module.h
@@ -3,9 +3,14 @@
#include <seed.h>
+// Pluralize an argument count ("1 argument", "2 arguments", etc), given an int
#define PLURALIZE_ARG_COUNT(c) \
((c == 1) ? #c " argument" : #c " arguments")
+// Check that the required number of arguments were passed into a seed callback.
+// If this is not true, raise an exception and return null.
+// This requires the callback to use "argument_count", "ctx", and "exception"
+// as the names of the various function arguments.
#define CHECK_ARG_COUNT(name, argnum) \
if ( argument_count != argnum ) \
{ \
@@ -13,7 +18,13 @@
asprintf(&msg, "%s expected %s got %Zd", name, \
PLURALIZE_ARG_COUNT(argnum), argument_count); \
seed_make_exception (ctx, exception, "ArgumentError", "%s", msg); \
+ g_free(msg); \
return seed_make_undefined (ctx); \
}
+// Defines a property on holder for the given enum member, with the given name
+#define DEFINE_ENUM_MEMBER(holder, name, val) \
+ seed_object_set_property(ctx, holder, name, \
+ seed_value_from_long(ctx, val, NULL))
+
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]