diff libpurple/plugins/perl/common/Status.xs @ 16739:39c7bb133a9f

Remove the const-c and const-xs stuff and replace it with real constants exposed to perl.
author Etan Reisner <pidgin@unreliablesource.net>
date Tue, 01 May 2007 02:34:22 +0000
parents 2f8274ce570a
children 08b9f27cf219
line wrap: on
line diff
--- a/libpurple/plugins/perl/common/Status.xs	Mon Apr 30 05:06:29 2007 +0000
+++ b/libpurple/plugins/perl/common/Status.xs	Tue May 01 02:34:22 2007 +0000
@@ -42,6 +42,38 @@
 MODULE = Purple::Status  PACKAGE = Purple::Presence  PREFIX = purple_presence_
 PROTOTYPES: ENABLE
 
+BOOT:
+{
+	HV *context_stash = gv_stashpv("Purple::Presence::Context", 1);
+	HV *primitive_stash = gv_stashpv("Purple::Status::Primitive", 1);
+
+	static const constiv *civ, context_const_iv[] = {
+#define const_iv(name) {#name, (IV)PURPLE_PRESENCE_CONTEXT_##name}
+		const_iv(UNSET),
+		const_iv(ACCOUNT),
+		const_iv(CONV),
+		const_iv(BUDDY),
+	};
+	static const constiv primitive_const_iv[] = {
+#undef const_iv
+#define const_iv(name) {#name, (IV)PURPLE_STATUS_##name}
+		const_iv(UNSET),
+		const_iv(OFFLINE),
+		const_iv(AVAILABLE),
+		const_iv(UNAVAILABLE),
+		const_iv(INVISIBLE),
+		const_iv(AWAY),
+		const_iv(EXTENDED_AWAY),
+		const_iv(MOBILE),
+	};
+
+	for (civ = context_const_iv + sizeof(context_const_iv) / sizeof(context_const_iv[0]); civ-- > context_const_iv; )
+		newCONSTSUB(context_stash, (char *)civ->name, newSViv(civ->iv));
+
+	for (civ = primitive_const_iv + sizeof(primitive_const_iv) / sizeof(primitive_const_iv[0]); civ-- > primitive_const_iv; )
+		newCONSTSUB(primitive_stash, (char *)civ->name, newSViv(civ->iv));
+}
+
 void
 purple_presence_add_list(presence, source_list)
 	Purple::Presence presence