1 /** 2 * @file local.i 3 * @brief PHP-specific SWIG directives for wrapping libSBML API 4 * 5 * <!-------------------------------------------------------------------------- 6 * This file is part of libSBML. Please visit http://sbml.org for more 7 * information about SBML, and the latest version of libSBML. 8 * 9 * Copyright (C) 2020 jointly by the following organizations: 10 * 1. California Institute of Technology, Pasadena, CA, USA 11 * 2. University of Heidelberg, Heidelberg, Germany 12 * 3. University College London, London, UK 13 * 14 * Copyright (C) 2019 jointly by the following organizations: 15 * 1. California Institute of Technology, Pasadena, CA, USA 16 * 2. University of Heidelberg, Heidelberg, Germany 17 * 18 * Copyright (C) 2013-2018 jointly by the following organizations: 19 * 1. California Institute of Technology, Pasadena, CA, USA 20 * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK 21 * 3. University of Heidelberg, Heidelberg, Germany 22 * 23 * Copyright (C) 2009-2013 jointly by the following organizations: 24 * 1. California Institute of Technology, Pasadena, CA, USA 25 * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK 26 * 27 * Copyright (C) 2006-2008 by the California Institute of Technology, 28 * Pasadena, CA, USA 29 * 30 * Copyright (C) 2002-2005 jointly by the following organizations: 31 * 1. California Institute of Technology, Pasadena, CA, USA 32 * 2. Japan Science and Technology Agency, Japan 33 * 34 * This library is free software; you can redistribute it and/or modify it 35 * under the terms of the GNU Lesser General Public License as published by 36 * the Free Software Foundation. A copy of the license agreement is provided 37 * in the file named "LICENSE.txt" included with this software distribution 38 * and also available online as http://sbml.org/software/libsbml/license.html 39 * ---------------------------------------------------------------------- -->*/ 40 41 #pragma SWIG nowarn=509 42 %warnfilter(365) operator+=; 43 %warnfilter(401) basic_ios<char>; 44 %warnfilter(801) basic_string<char>; 45 46 // ignores C++ specific methods in std::string. 47 %ignore std::basic_string<char>::begin; 48 %ignore std::basic_string<char>::end; 49 %ignore std::basic_string<char>::rbegin; 50 %ignore std::basic_string<char>::rend; 51 %ignore std::basic_string<char>::get_allocator; 52 %ignore std::basic_string<char>::capacity; 53 %ignore std::basic_string<char>::reserve; 54 55 %rename(sbmlClone) *::clone; 56 57 %include <std_string.i> 58 59 /** 60 * Convert SBase, SimpleSpeciesReference, and Rule objects into the most specific type possible. 61 */ 62 %typemap(out) SBase*, SimpleSpeciesReference*, Rule*, SBasePlugin*, SBMLExtension*, SBMLNamespaces*, SBMLConverter*, Reaction* 63 { 64 SWIG_SetPointerZval(return_value, SWIG_as_voidptr($1),GetDowncastSwigType($1), $owner); 65 } 66 67 %typemap(out) ASTBasePlugin* 68 { 69 SWIG_SetPointerZval(return_value, SWIG_as_voidptr($1),GetDowncastSwigType($1), $owner); 70 } 71 72 73 74 /* 75 * SWIG-generated wrapper code for Ruby binding wrongly invokes 76 * XMLOutputStream::writeAttribute(.., const unsigned int& value) instead of 77 * XMLOutputStream::writeAttribute(.., const bool& value) even if the writeAttribute 78 * function properly invoked with a bool value (true or false) in Ruby code. 79 * It seems that a bool value could be casted to unsigned int, int, or long value 80 * in SWIG-generated internal type check code when these types are overloaded in the 81 * wrapped function. 82 * 83 * To avoid this problem, XMLOutputStream::writeAttributeBool(.., const bool&) 84 * functions, which internally invoke XMLOutputStream::writeAttribute(.., const bool& value) 85 * functions properly, are additionally wrapped as aliases. 86 */ 87 %extend XMLOutputStream 88 { writeAttributeBool(const std::string & name,const bool & value)89 void writeAttributeBool(const std::string& name, const bool& value) 90 { 91 $self->writeAttribute(name, value); 92 } 93 writeAttributeBool(const XMLTriple & name,const bool & value)94 void writeAttributeBool(const XMLTriple& name, const bool& value) 95 { 96 $self->writeAttribute(name, value); 97 } 98 } 99 100 101 /** 102 * Wraps the SBMLConstructorException 103 * 104 */ 105 106 %exceptionclass SBMLConstructorException; 107 108 %define SBMLCONSTRUCTOR_EXCEPTION(SBASE_CLASS_NAME) 109 %exception SBASE_CLASS_NAME{ 110 try { 111 $action 112 } catch(const SBMLConstructorException & e)113 catch (const SBMLConstructorException &e){ 114 SWIG_PHP_Error(E_ERROR, e.what()); 115 } catch(const SBMLExtensionException & e)116 catch (const SBMLExtensionException &e){ 117 SWIG_PHP_Error(E_ERROR, e.what()); 118 } 119 } 120 %enddef 121 122 SBMLCONSTRUCTOR_EXCEPTION(Compartment) 123 SBMLCONSTRUCTOR_EXCEPTION(CompartmentType) 124 SBMLCONSTRUCTOR_EXCEPTION(Constraint) 125 SBMLCONSTRUCTOR_EXCEPTION(Delay) 126 SBMLCONSTRUCTOR_EXCEPTION(Event) 127 SBMLCONSTRUCTOR_EXCEPTION(EventAssignment) 128 SBMLCONSTRUCTOR_EXCEPTION(FunctionDefinition) 129 SBMLCONSTRUCTOR_EXCEPTION(InitialAssignment) 130 SBMLCONSTRUCTOR_EXCEPTION(KineticLaw) 131 SBMLCONSTRUCTOR_EXCEPTION(Model) 132 SBMLCONSTRUCTOR_EXCEPTION(Parameter) 133 SBMLCONSTRUCTOR_EXCEPTION(Priority) 134 SBMLCONSTRUCTOR_EXCEPTION(LocalParameter) 135 SBMLCONSTRUCTOR_EXCEPTION(Reaction) 136 SBMLCONSTRUCTOR_EXCEPTION(AssignmentRule) 137 SBMLCONSTRUCTOR_EXCEPTION(AlgebraicRule) 138 SBMLCONSTRUCTOR_EXCEPTION(RateRule) 139 SBMLCONSTRUCTOR_EXCEPTION(Species) 140 SBMLCONSTRUCTOR_EXCEPTION(SpeciesReference) 141 SBMLCONSTRUCTOR_EXCEPTION(ModifierSpeciesReference) 142 SBMLCONSTRUCTOR_EXCEPTION(SpeciesType) 143 SBMLCONSTRUCTOR_EXCEPTION(StoichiometryMath) 144 SBMLCONSTRUCTOR_EXCEPTION(Trigger) 145 SBMLCONSTRUCTOR_EXCEPTION(Unit) 146 SBMLCONSTRUCTOR_EXCEPTION(UnitDefinition) 147 SBMLCONSTRUCTOR_EXCEPTION(SBMLDocument) 148 SBMLCONSTRUCTOR_EXCEPTION(SBMLNamespaces) 149 SBMLCONSTRUCTOR_EXCEPTION(SBMLExtensionNamespaces) 150 151 SBMLCONSTRUCTOR_EXCEPTION(ListOf) 152 SBMLCONSTRUCTOR_EXCEPTION(ListOfCompartments) 153 SBMLCONSTRUCTOR_EXCEPTION(ListOfCompartmentTypes) 154 SBMLCONSTRUCTOR_EXCEPTION(ListOfConstraints) 155 SBMLCONSTRUCTOR_EXCEPTION(ListOfEventAssignments) 156 SBMLCONSTRUCTOR_EXCEPTION(ListOfEvents) 157 SBMLCONSTRUCTOR_EXCEPTION(ListOfFunctionDefinitions) 158 SBMLCONSTRUCTOR_EXCEPTION(ListOfInitialAssignments) 159 SBMLCONSTRUCTOR_EXCEPTION(ListOfParameters) 160 SBMLCONSTRUCTOR_EXCEPTION(ListOfLocalParameters) 161 SBMLCONSTRUCTOR_EXCEPTION(ListOfReactions) 162 SBMLCONSTRUCTOR_EXCEPTION(ListOfRules) 163 SBMLCONSTRUCTOR_EXCEPTION(ListOfSpecies) 164 SBMLCONSTRUCTOR_EXCEPTION(ListOfSpeciesReferences) 165 SBMLCONSTRUCTOR_EXCEPTION(ListOfSpeciesTypes) 166 SBMLCONSTRUCTOR_EXCEPTION(ListOfUnitDefinitions) 167 SBMLCONSTRUCTOR_EXCEPTION(ListOfUnits) 168 169 /** 170 * Wraps the XMLConstructorException 171 * 172 */ 173 174 %exceptionclass XMLConstructorException; 175 176 %define XMLCONSTRUCTOR_EXCEPTION(SBASE_CLASS_NAME) 177 %exception SBASE_CLASS_NAME{ 178 try { 179 $action 180 } catch(const XMLConstructorException & e)181 catch (const XMLConstructorException &e){ 182 SWIG_PHP_Error(E_ERROR, e.what()); 183 } 184 } 185 %enddef 186 187 188 XMLCONSTRUCTOR_EXCEPTION(XMLAttributes) 189 XMLCONSTRUCTOR_EXCEPTION(XMLError) 190 XMLCONSTRUCTOR_EXCEPTION(XMLNamespaces) 191 XMLCONSTRUCTOR_EXCEPTION(XMLNode) 192 XMLCONSTRUCTOR_EXCEPTION(XMLOutputStream) 193 XMLCONSTRUCTOR_EXCEPTION(XMLToken) 194 XMLCONSTRUCTOR_EXCEPTION(XMLTripple) 195 196 /** 197 * Wraps the following functions by using the corresponding 198 * ListWrapper<TYPENAME> class. 199 * 200 * - List* ModelHistory::getListCreators() 201 * - List* ModelHistory::getListModifiedDates() 202 * - List* SBase::getCVTerms() 203 * - List* SBMLNamespaces::getSupportedNamespaces() 204 * 205 * ListWrapper<TYPENAME> class is wrapped as ListTYPENAMEs class. 206 * So, the above functions are wrapped as follows: 207 * 208 * - ModelCreatorList ModelHistory.getListCreators() 209 * - DateList ModelHistory.getListModifiedDates() 210 * - CVTermList SBase.getCVTerms() 211 * - SBMLNamespacesList SBMLNamespaces::getSupportedNamespaces() 212 * 213 */ 214 215 %typemap(out) List* SBMLNamespaces::getSupportedNamespaces 216 { 217 ListWrapper<SBMLNamespaces> *listw = ($1 != 0) ? new ListWrapper<SBMLNamespaces>($1) : 0; 218 SWIG_SetPointerZval(return_value, SWIG_as_voidptr(listw), 219 #if SWIG_VERSION > 0x010333 220 SWIGTYPE_p_ListWrapperT_SBMLNamespaces_t, 221 #else 222 SWIGTYPE_p_ListWrapperTSBMLNamespaces_t, 223 #endif 224 SWIG_POINTER_OWN | 0 ); 225 } 226 227 228 %typemap(out) List* ModelHistory::getListCreators 229 { 230 ListWrapper<ModelCreator> *listw = ($1 != 0) ? new ListWrapper<ModelCreator>($1) : 0; 231 SWIG_SetPointerZval(return_value, SWIG_as_voidptr(listw), 232 #if SWIG_VERSION > 0x010333 233 SWIGTYPE_p_ListWrapperT_ModelCreator_t, 234 #else 235 SWIGTYPE_p_ListWrapperTModelCreator_t, 236 #endif 237 SWIG_POINTER_OWN | 0 ); 238 } 239 240 %typemap(out) List* ModelHistory::getListModifiedDates 241 { 242 ListWrapper<Date> *listw = ($1 != 0) ? new ListWrapper<Date>($1) : 0; 243 SWIG_SetPointerZval(return_value, SWIG_as_voidptr(listw), 244 #if SWIG_VERSION > 0x010333 245 SWIGTYPE_p_ListWrapperT_Date_t, 246 #else 247 SWIGTYPE_p_ListWrapperTDate_t, 248 #endif 249 SWIG_POINTER_OWN | 0 ); 250 } 251 252 253 254 %define LIST_WRAPPER(_FNAME_,_TYPENAME_) 255 %typemap(out) List* _FNAME_ 256 { 257 ListWrapper<_TYPENAME_> *listw = ($1 != 0)? new ListWrapper<_TYPENAME_>($1) : 0; 258 SWIG_SetPointerZval(return_value, SWIG_as_voidptr(listw), 259 #if SWIG_VERSION > 0x010333 260 SWIGTYPE_p_ListWrapperT_ ## _TYPENAME_ ## _t, 261 #else 262 SWIGTYPE_p_ListWrapperT ## _TYPENAME_ ## _t, 263 #endif 264 SWIG_POINTER_OWN | 0 ); 265 } 266 %enddef 267 268 LIST_WRAPPER(SBase::getCVTerms,CVTerm) 269 LIST_WRAPPER(SBase::getListOfAllElements,SBase) 270 LIST_WRAPPER(SBasePlugin::getListOfAllElements,SBase) 271 LIST_WRAPPER(SBase::getListOfAllElementsFromPlugins,SBase) 272 273 %include "local-packages.i" 274 275