diff libpurple/plugins/perl/common/Cmds.xs @ 16750: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/Cmds.xs	Mon Apr 30 05:06:29 2007 +0000
+++ b/libpurple/plugins/perl/common/Cmds.xs	Tue May 01 02:34:22 2007 +0000
@@ -4,6 +4,63 @@
 MODULE = Purple::Cmd  PACKAGE = Purple::Cmd  PREFIX = purple_cmd_
 PROTOTYPES: ENABLE
 
+BOOT:
+{
+	HV *status_stash = gv_stashpv("Purple::Cmd::Status", 1);
+	HV *ret_stash = gv_stashpv("Purple::Cmd::Return", 1);
+	HV *p_stash = gv_stashpv("Purple::Cmd::Priority", 1);
+	HV *flag_stash = gv_stashpv("Purple::Cmd::Flag", 1);
+
+	static const constiv *civ, status_const_iv[] = {
+#define const_iv(name) {#name, (IV)PURPLE_CMD_STATUS_##name}
+		const_iv(OK),
+		const_iv(FAILED),
+		const_iv(NOT_FOUND),
+		const_iv(WRONG_ARGS),
+		const_iv(WRONG_PRPL),
+		const_iv(WRONG_TYPE),
+	};
+	static const constiv ret_const_iv[] = {
+#undef const_iv
+#define const_iv(name) {#name, (IV)PURPLE_CMD_RET_##name}
+		const_iv(OK),
+		const_iv(FAILED),
+		const_iv(CONTINUE),
+	};
+	static const constiv p_const_iv[] = {
+#undef const_iv
+#define const_iv(name) {#name, (IV)PURPLE_CMD_P_##name}
+		const_iv(VERY_LOW),
+		const_iv(LOW),
+		const_iv(DEFAULT),
+		const_iv(PRPL),
+		const_iv(PLUGIN),
+		const_iv(ALIAS),
+		const_iv(HIGH),
+		const_iv(VERY_HIGH),
+	};
+	static const constiv flag_const_iv[] = {
+#undef const_iv
+#define const_iv(name) {#name, (IV)PURPLE_CMD_FLAG_##name}
+		const_iv(IM),
+		const_iv(CHAT),
+		const_iv(PRPL_ONLY),
+		const_iv(ALLOW_WRONG_ARGS),
+	};
+
+	for (civ = status_const_iv + sizeof(status_const_iv) / sizeof(status_const_iv[0]); civ-- > status_const_iv;)
+		newCONSTSUB(status_stash, (char *)civ->name, newSViv(civ->iv));
+
+	for (civ = ret_const_iv + sizeof(ret_const_iv) / sizeof(ret_const_iv[0]); civ-- > ret_const_iv;)
+		newCONSTSUB(ret_stash, (char *)civ->name, newSViv(civ->iv));
+
+	for (civ = p_const_iv + sizeof(p_const_iv) / sizeof(p_const_iv[0]); civ-- > p_const_iv;)
+		newCONSTSUB(p_stash, (char *)civ->name, newSViv(civ->iv));
+
+	for (civ = flag_const_iv + sizeof(flag_const_iv) / sizeof(flag_const_iv[0]); civ-- > flag_const_iv;)
+		newCONSTSUB(flag_stash, (char *)civ->name, newSViv(civ->iv));
+}
+
 void
 purple_cmd_help(conv, command)
 	Purple::Conversation conv