diff options
author | Emmanuel Raviart <eraviart@entrouvert.com> | 2005-01-17 23:37:36 +0000 |
---|---|---|
committer | Emmanuel Raviart <eraviart@entrouvert.com> | 2005-01-17 23:37:36 +0000 |
commit | 02464ae3147f8df3c8d57665669b52008eb25821 (patch) | |
tree | 3fcbf24766af75846a6fac40a77077f4ade49628 /swig | |
parent | 89e3b547cea3685aa4b5452331b0fa3d5e89bd90 (diff) | |
download | lasso-02464ae3147f8df3c8d57665669b52008eb25821.tar.gz lasso-02464ae3147f8df3c8d57665669b52008eb25821.tar.xz lasso-02464ae3147f8df3c8d57665669b52008eb25821.zip |
Extracted the inheritance of nodes from SWIG in a separate file, to remove
its duplication in Lasso.i.
Reorganized Lasso.i.
Diffstat (limited to 'swig')
-rw-r--r-- | swig/Lasso.i | 341 | ||||
-rw-r--r-- | swig/Makefile.am | 2 | ||||
-rw-r--r-- | swig/inheritance.h | 112 |
3 files changed, 211 insertions, 244 deletions
diff --git a/swig/Lasso.i b/swig/Lasso.i index 7fc795a0..6c91d034 100644 --- a/swig/Lasso.i +++ b/swig/Lasso.i @@ -51,6 +51,31 @@ #include <lasso/lasso.h> #include <lasso/xml/lib_assertion.h> +%} + +/* GLib types */ + +#define gboolean bool +%{ +#define bool int +#define false 0 +#define true 1 +%} +#define gchar char +#define gint int +#define gpointer void* +#define GPtrArray void + + + +/*********************************************************************** + *********************************************************************** + * SWIG Tuning + *********************************************************************** + ***********************************************************************/ + + +%{ /* * Thanks to the patch in this Debian bug for the solution @@ -72,95 +97,23 @@ %} -#ifdef SWIGJAVA -#if SWIG_VERSION >= 0x010322 - %include "enumsimple.swg" -#endif -%pragma(java) jniclasscode=%{ - static { - try { - // Load a library whose "core" name is "jlasso". - // Operating system specific stuff will be added to make an - // actual filename from this: Under Unix this will become - // libjlasso.so while under Windows it will likely become - // something like jlasso.dll. - System.loadLibrary("jlasso"); - } - catch (UnsatisfiedLinkError e) { - System.err.println("Native code library failed to load. \n" + e); - System.exit(1); - } - // Initialize Lasso. - init(); - } -%} -#else - -#ifdef SWIGPYTHON -%{ - PyObject *lassoError; - PyObject *LASSO_WARNING; -%} - -%init %{ - lassoError = PyErr_NewException("_lasso.Error", NULL, NULL); - Py_INCREF(lassoError); - PyModule_AddObject(m, "Error", lassoError); - - LASSO_WARNING = PyErr_NewException("_lasso.Warning", lassoError, NULL); - Py_INCREF(LASSO_WARNING); - PyModule_AddObject(m, "Warning", LASSO_WARNING); - - lasso_init(); -%} - -%pythoncode %{ -Error = _lasso.Error -Warning = _lasso.Warning -%} - -#else -/* Apache fails when lasso_init is called too early in PHP binding. */ -/* FIXME: To investigate. */ -#ifndef SWIGPHP4 -%init %{ - lasso_init(); -%} -#endif -#endif -#endif +#define %nonewobject %feature("new","") /*********************************************************************** - *********************************************************************** - * Common - *********************************************************************** + * Python Tuning ***********************************************************************/ -/* GLib types */ - -#define gboolean bool -%{ -#define bool int -#define false 0 -#define true 1 -%} -#define gchar char -#define gint int -#define gpointer void* -#define GPtrArray void +#if defined(SWIGPYTHON) +%typemap(in,parse="z") char * ""; +#endif /*********************************************************************** - * Swig Tuning + * PHP Tuning ***********************************************************************/ -#define %nonewobject %feature("new","") - -#if defined(SWIGPYTHON) -%typemap(in,parse="z") char * ""; -#endif #if defined(SWIGPHP4) @@ -222,6 +175,9 @@ Warning = _lasso.Warning %{ +PyObject *lassoError; +PyObject *LASSO_WARNING; + static void lasso_exception(int errorCode) { PyObject *errorTuple; @@ -239,6 +195,21 @@ static void lasso_exception(int errorCode) { %} +%init %{ + lassoError = PyErr_NewException("_lasso.Error", NULL, NULL); + Py_INCREF(lassoError); + PyModule_AddObject(m, "Error", lassoError); + + LASSO_WARNING = PyErr_NewException("_lasso.Warning", lassoError, NULL); + Py_INCREF(LASSO_WARNING); + PyModule_AddObject(m, "Warning", LASSO_WARNING); +%} + +%pythoncode %{ +Error = _lasso.Error +Warning = _lasso.Warning +%} + %define THROW_ERROR %exception { int errorCode; @@ -521,85 +492,7 @@ DYNAMIC_CAST(SWIGTYPE_p_LassoSamlpResponseAbstract, dynamic_cast_node); %typemap(javabase) LassoNode "DowncastableNode"; -/* saml prefix */ - -SET_NODE_INFO(SamlAdvice, Node) -SET_NODE_INFO(SamlAssertion, Node) -SET_NODE_INFO(SamlAttributeDesignator, Node) -SET_NODE_INFO(SamlAuthorityBinding, Node) -SET_NODE_INFO(SamlConditionAbstract, Node) -SET_NODE_INFO(SamlConditions, Node) -SET_NODE_INFO(SamlNameIdentifier, Node) -SET_NODE_INFO(SamlStatementAbstract, Node) -SET_NODE_INFO(SamlSubject, Node) -SET_NODE_INFO(SamlSubjectConfirmation, Node) -SET_NODE_INFO(SamlSubjectLocality, Node) - -SET_NODE_INFO(SamlAttribute, SamlAttributeDesignator) -SET_NODE_INFO(SamlAudienceRestrictionCondition, SamlConditionAbstract) -SET_NODE_INFO(SamlSubjectStatementAbstract, SamlStatementAbstract) - -SET_NODE_INFO(SamlAttributeStatement, SamlSubjectStatementAbstract) -SET_NODE_INFO(SamlAuthenticationStatement, SamlSubjectStatementAbstract) -SET_NODE_INFO(SamlSubjectStatement, SamlSubjectStatementAbstract) - -/* samlp prefix */ - -SET_NODE_INFO(SamlpRequestAbstract, Node) -SET_NODE_INFO(SamlpResponseAbstract, Node) -SET_NODE_INFO(SamlpStatus, Node) -SET_NODE_INFO(SamlpStatusCode, Node) - -SET_NODE_INFO(SamlpRequest, SamlpRequestAbstract) -SET_NODE_INFO(SamlpResponse, SamlpResponseAbstract) - -/* lib prefix */ - -SET_NODE_INFO(LibAssertion, SamlAssertion) -SET_NODE_INFO(LibAuthnRequest, SamlpRequestAbstract) -SET_NODE_INFO(LibAuthnResponse, SamlpResponse) -SET_NODE_INFO(LibFederationTerminationNotification, SamlpRequestAbstract) -SET_NODE_INFO(LibLogoutRequest, SamlpRequestAbstract) -SET_NODE_INFO(LibRegisterNameIdentifierRequest, SamlpRequestAbstract) -SET_NODE_INFO(LibRequestAuthnContext, Node) -SET_NODE_INFO(LibStatusResponse, SamlpResponseAbstract) - -SET_NODE_INFO(LibLogoutResponse, LibStatusResponse) -SET_NODE_INFO(LibRegisterNameIdentifierResponse, LibStatusResponse) - -/* ID-WSF FIXME: Check inheritance */ -#if 0 -/* disco prefix */ - -SET_NODE_INFO(DiscoCredentials, Node) -SET_NODE_INFO(DiscoDescription, Node) -SET_NODE_INFO(DiscoEncryptedResourceID, Node) -SET_NODE_INFO(DiscoInsertEntry, Node) -SET_NODE_INFO(DiscoModify, Node) -SET_NODE_INFO(DiscoModifyResponse, Node) -SET_NODE_INFO(DiscoOptions, Node) -SET_NODE_INFO(DiscoQuery, Node) -SET_NODE_INFO(DiscoQueryResponse, Node) -SET_NODE_INFO(DiscoRemoveEntry, Node) -SET_NODE_INFO(DiscoRequestedServiceType, Node) -SET_NODE_INFO(DiscoResourceID, Node) -SET_NODE_INFO(DiscoResourceOffering, Node) -SET_NODE_INFO(DiscoServiceInstance, Node) - -/* dst prefix */ - -SET_NODE_INFO(DstModification, Node) -SET_NODE_INFO(DstModify, Node) -SET_NODE_INFO(DstModifyResponse, Node) -SET_NODE_INFO(DstNewData, Node) -SET_NODE_INFO(DstQuery, Node) -SET_NODE_INFO(DstQueryItem, Node) -SET_NODE_INFO(DstQueryResponse, Node) - -/* pp prefix */ - -SET_NODE_INFO(PPMsgContact, Node) -#endif +%include inheritance.h #else /* if !defined(SWIGCSHARP) && !defined(SWIGJAVA) */ @@ -610,99 +503,17 @@ SET_NODE_INFO(PPMsgContact, Node) info = node_infos; #ifdef PHP_VERSION set_node_info(info++, "LassoNode", NULL, SWIGTYPE_p_LassoNode, &ce_swig_LassoNode); -#else - set_node_info(info++, "LassoNode", NULL, SWIGTYPE_p_LassoNode); -#endif - -#ifdef PHP_VERSION #define SET_NODE_INFO(className, superClassName)\ set_node_info(info++, "Lasso"#className, "Lasso"#superClassName,\ SWIGTYPE_p_Lasso##className, &ce_swig_Lasso##className); #else + set_node_info(info++, "LassoNode", NULL, SWIGTYPE_p_LassoNode); #define SET_NODE_INFO(className, superClassName)\ set_node_info(info++, "Lasso"#className, "Lasso"#superClassName,\ SWIGTYPE_p_Lasso##className); #endif -/* saml prefix */ - -SET_NODE_INFO(SamlAdvice, Node) -SET_NODE_INFO(SamlAssertion, Node) -SET_NODE_INFO(SamlAttributeDesignator, Node) -SET_NODE_INFO(SamlAuthorityBinding, Node) -SET_NODE_INFO(SamlConditionAbstract, Node) -SET_NODE_INFO(SamlConditions, Node) -SET_NODE_INFO(SamlNameIdentifier, Node) -SET_NODE_INFO(SamlStatementAbstract, Node) -SET_NODE_INFO(SamlSubject, Node) -SET_NODE_INFO(SamlSubjectConfirmation, Node) -SET_NODE_INFO(SamlSubjectLocality, Node) - -SET_NODE_INFO(SamlAttribute, SamlAttributeDesignator) -SET_NODE_INFO(SamlAudienceRestrictionCondition, SamlConditionAbstract) -SET_NODE_INFO(SamlSubjectStatementAbstract, SamlStatementAbstract) - -SET_NODE_INFO(SamlAttributeStatement, SamlSubjectStatementAbstract) -SET_NODE_INFO(SamlAuthenticationStatement, SamlSubjectStatementAbstract) -SET_NODE_INFO(SamlSubjectStatement, SamlSubjectStatementAbstract) - -/* samlp prefix */ - -SET_NODE_INFO(SamlpRequestAbstract, Node) -SET_NODE_INFO(SamlpResponseAbstract, Node) -SET_NODE_INFO(SamlpStatus, Node) -SET_NODE_INFO(SamlpStatusCode, Node) - -SET_NODE_INFO(SamlpRequest, SamlpRequestAbstract) -SET_NODE_INFO(SamlpResponse, SamlpResponseAbstract) - -/* lib prefix */ - -SET_NODE_INFO(LibAssertion, SamlAssertion) -SET_NODE_INFO(LibAuthnRequest, SamlpRequestAbstract) -SET_NODE_INFO(LibAuthnResponse, SamlpResponse) -SET_NODE_INFO(LibFederationTerminationNotification, SamlpRequestAbstract) -SET_NODE_INFO(LibLogoutRequest, SamlpRequestAbstract) -SET_NODE_INFO(LibRegisterNameIdentifierRequest, SamlpRequestAbstract) -SET_NODE_INFO(LibRequestAuthnContext, Node) -SET_NODE_INFO(LibStatusResponse, SamlpResponseAbstract) - -SET_NODE_INFO(LibLogoutResponse, LibStatusResponse) -SET_NODE_INFO(LibRegisterNameIdentifierResponse, LibStatusResponse) - -/* ID-WSF FIXME: Check inheritance */ -#if 0 -/* disco prefix */ - -SET_NODE_INFO(DiscoCredentials, Node) -SET_NODE_INFO(DiscoDescription, Node) -SET_NODE_INFO(DiscoEncryptedResourceID, Node) -SET_NODE_INFO(DiscoInsertEntry, Node) -SET_NODE_INFO(DiscoModify, Node) -SET_NODE_INFO(DiscoModifyResponse, Node) -SET_NODE_INFO(DiscoOptions, Node) -SET_NODE_INFO(DiscoQuery, Node) -SET_NODE_INFO(DiscoQueryResponse, Node) -SET_NODE_INFO(DiscoRemoveEntry, Node) -SET_NODE_INFO(DiscoRequestedServiceType, Node) -SET_NODE_INFO(DiscoResourceID, Node) -SET_NODE_INFO(DiscoResourceOffering, Node) -SET_NODE_INFO(DiscoServiceInstance, Node) - -/* dst prefix */ - -SET_NODE_INFO(DstModification, Node) -SET_NODE_INFO(DstModify, Node) -SET_NODE_INFO(DstModifyResponse, Node) -SET_NODE_INFO(DstNewData, Node) -SET_NODE_INFO(DstQuery, Node) -SET_NODE_INFO(DstQueryItem, Node) -SET_NODE_INFO(DstQueryResponse, Node) - -/* pp prefix */ - -SET_NODE_INFO(PPMsgContact, Node) -#endif +#include <swig/inheritance.h> info->name = NULL; info->swig = NULL; @@ -1020,6 +831,11 @@ typedef enum { ***********************************************************************/ +/*********************************************************************** + * Public Functions + ***********************************************************************/ + + #ifndef SWIGPHP4 %rename(init) lasso_init; #endif @@ -1032,9 +848,7 @@ int lasso_shutdown(void); /*********************************************************************** - *********************************************************************** * Utility functions to handle nodes, strings, lists... - *********************************************************************** ***********************************************************************/ @@ -1241,6 +1055,47 @@ static void set_xml_list(GList **xmlListPointer, GPtrArray *xmlArray) { /*********************************************************************** *********************************************************************** + * Initialization + *********************************************************************** + ***********************************************************************/ + + +#ifdef SWIGJAVA +#if SWIG_VERSION >= 0x010322 + %include "enumsimple.swg" +#endif +%pragma(java) jniclasscode=%{ + static { + try { + // Load a library whose "core" name is "jlasso". + // Operating system specific stuff will be added to make an + // actual filename from this: Under Unix this will become + // libjlasso.so while under Windows it will likely become + // something like jlasso.dll. + System.loadLibrary("jlasso"); + } + catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. \n" + e); + System.exit(1); + } + // Initialize Lasso. + init(); + } +%} +#else + +/* Apache fails when lasso_init is called too early in PHP binding. */ +/* FIXME: To investigate. */ +#ifndef SWIGPHP4 +%init %{ + lasso_init(); +%} +#endif +#endif + + +/*********************************************************************** + *********************************************************************** * Core Structures *********************************************************************** ***********************************************************************/ diff --git a/swig/Makefile.am b/swig/Makefile.am index a0a7e0bc..65ca6902 100644 --- a/swig/Makefile.am +++ b/swig/Makefile.am @@ -1,2 +1,2 @@ -EXTRA_DIST = Lasso.i Lasso-wsf.i +EXTRA_DIST = Lasso.i Lasso-wsf.i inheritance.h diff --git a/swig/inheritance.h b/swig/inheritance.h new file mode 100644 index 00000000..58ff9925 --- /dev/null +++ b/swig/inheritance.h @@ -0,0 +1,112 @@ +/* -*- Mode: c; c-basic-offset: 8 -*- + * + * $Id$ + * + * SWIG bindings for Lasso Library + * + * Copyright (C) 2004, 2005 Entr'ouvert + * http://lasso.entrouvert.org + * + * Authors: See AUTHORS file. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +/*********************************************************************** + * Declaration of LassoNode Derivated Classes + ***********************************************************************/ + +/* FIXME: May be this file should be automatically generated by a script? */ + +/* saml prefix */ + +SET_NODE_INFO(SamlAdvice, Node) +SET_NODE_INFO(SamlAssertion, Node) +SET_NODE_INFO(SamlAttributeDesignator, Node) +SET_NODE_INFO(SamlAuthorityBinding, Node) +SET_NODE_INFO(SamlConditionAbstract, Node) +SET_NODE_INFO(SamlConditions, Node) +SET_NODE_INFO(SamlNameIdentifier, Node) +SET_NODE_INFO(SamlStatementAbstract, Node) +SET_NODE_INFO(SamlSubject, Node) +SET_NODE_INFO(SamlSubjectConfirmation, Node) +SET_NODE_INFO(SamlSubjectLocality, Node) + +SET_NODE_INFO(SamlAttribute, SamlAttributeDesignator) +SET_NODE_INFO(SamlAudienceRestrictionCondition, SamlConditionAbstract) +SET_NODE_INFO(SamlSubjectStatementAbstract, SamlStatementAbstract) + +SET_NODE_INFO(SamlAttributeStatement, SamlSubjectStatementAbstract) +SET_NODE_INFO(SamlAuthenticationStatement, SamlSubjectStatementAbstract) +SET_NODE_INFO(SamlSubjectStatement, SamlSubjectStatementAbstract) + +/* samlp prefix */ + +SET_NODE_INFO(SamlpRequestAbstract, Node) +SET_NODE_INFO(SamlpResponseAbstract, Node) +SET_NODE_INFO(SamlpStatus, Node) +SET_NODE_INFO(SamlpStatusCode, Node) + +SET_NODE_INFO(SamlpRequest, SamlpRequestAbstract) +SET_NODE_INFO(SamlpResponse, SamlpResponseAbstract) + +/* lib prefix */ + +SET_NODE_INFO(LibAssertion, SamlAssertion) +SET_NODE_INFO(LibAuthnRequest, SamlpRequestAbstract) +SET_NODE_INFO(LibAuthnResponse, SamlpResponse) +SET_NODE_INFO(LibFederationTerminationNotification, SamlpRequestAbstract) +SET_NODE_INFO(LibLogoutRequest, SamlpRequestAbstract) +SET_NODE_INFO(LibRegisterNameIdentifierRequest, SamlpRequestAbstract) +SET_NODE_INFO(LibRequestAuthnContext, Node) +SET_NODE_INFO(LibStatusResponse, SamlpResponseAbstract) + +SET_NODE_INFO(LibLogoutResponse, LibStatusResponse) +SET_NODE_INFO(LibRegisterNameIdentifierResponse, LibStatusResponse) + +/* ID-WSF FIXME: Check inheritance */ +#if 0 +/* disco prefix */ + +SET_NODE_INFO(DiscoCredentials, Node) +SET_NODE_INFO(DiscoDescription, Node) +SET_NODE_INFO(DiscoEncryptedResourceID, Node) +SET_NODE_INFO(DiscoInsertEntry, Node) +SET_NODE_INFO(DiscoModify, Node) +SET_NODE_INFO(DiscoModifyResponse, Node) +SET_NODE_INFO(DiscoOptions, Node) +SET_NODE_INFO(DiscoQuery, Node) +SET_NODE_INFO(DiscoQueryResponse, Node) +SET_NODE_INFO(DiscoRemoveEntry, Node) +SET_NODE_INFO(DiscoRequestedServiceType, Node) +SET_NODE_INFO(DiscoResourceID, Node) +SET_NODE_INFO(DiscoResourceOffering, Node) +SET_NODE_INFO(DiscoServiceInstance, Node) + +/* dst prefix */ + +SET_NODE_INFO(DstModification, Node) +SET_NODE_INFO(DstModify, Node) +SET_NODE_INFO(DstModifyResponse, Node) +SET_NODE_INFO(DstNewData, Node) +SET_NODE_INFO(DstQuery, Node) +SET_NODE_INFO(DstQueryItem, Node) +SET_NODE_INFO(DstQueryResponse, Node) + +/* pp prefix */ + +SET_NODE_INFO(PPMsgContact, Node) +#endif |