diff libpurple/plugins/perl/common/Pounce.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 4dc66862203f
line wrap: on
line diff
--- a/libpurple/plugins/perl/common/Pounce.xs	Mon Apr 30 05:06:29 2007 +0000
+++ b/libpurple/plugins/perl/common/Pounce.xs	Tue May 01 02:34:22 2007 +0000
@@ -3,6 +3,39 @@
 MODULE = Purple::Pounce  PACKAGE = Purple::Pounce  PREFIX = purple_pounce_
 PROTOTYPES: ENABLE
 
+BOOT:
+{
+	HV *event_stash = gv_stashpv("Purple::Pounce::Event", 1);
+	HV *option_stash = gv_stashpv("Purple::Pounce::Option", 1);
+
+	static const constiv *civ, event_const_iv[] = {
+#define const_iv(name) {#name, (IV)PURPLE_POUNCE_##name}
+		const_iv(NONE),
+		const_iv(SIGNON),
+		const_iv(SIGNOFF),
+		const_iv(AWAY),
+		const_iv(AWAY_RETURN),
+		const_iv(IDLE),
+		const_iv(IDLE_RETURN),
+		const_iv(TYPING),
+		const_iv(TYPED),
+		const_iv(TYPING_STOPPED),
+		const_iv(MESSAGE_RECEIVED),
+	};
+	static const constiv option_const_iv[] = {
+#undef const_iv
+#define const_iv(name) {#name, (IV)PURPLE_POUNCE_OPTION_##name}
+		const_iv(NONE),
+		const_iv(AWAY),
+	};
+
+	for (civ = event_const_iv + sizeof(event_const_iv) / sizeof(event_const_iv[0]); civ-- > event_const_iv; )
+		newCONSTSUB(event_stash, (char *)civ->name, newSViv(civ->iv));
+
+	for (civ = option_const_iv + sizeof(option_const_iv) / sizeof(option_const_iv[0]); civ-- > option_const_iv; )
+		newCONSTSUB(option_stash, (char *)civ->name, newSViv(civ->iv));
+}
+
 void
 purple_pounce_action_register(pounce, name)
 	Purple::Pounce pounce