Changeset 13034


Ignore:
Timestamp:
08/14/12 16:02:21 (13 years ago)
Author:
jschierm
Message:

NEW: Python versions of EnumToString and StringToEnum (along with necessary io).

Location:
issm/trunk-jpl/src/modules
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/modules/EnumToString/EnumToString.cpp

    r12518 r13034  
    55#include "./EnumToString.h"
    66
    7 void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
     7WRAPPER(EnumToString){
    88
    99        char    *name    = NULL;
    1010        int      enum_in;
    1111
    12         /*checks on arguments on the matlab side: */
    13         if(nrhs!=NRHS){
    14                 EnumToStringUsage(); _error2_("usage. See above");
    15         }
     12        /*Boot module: */
     13        MODULEBOOT();
     14
     15        /*checks on arguments: */
     16        CHECKARGUMENTS(NLHS,NRHS,&EnumToStringUsage);
    1617
    1718        /*Fetch inputs: */
     
    2324        /* output: */
    2425        WriteData(NAME,name);
     26
     27        /*end module: */
     28        MODULEEND();
    2529}
    2630
  • issm/trunk-jpl/src/modules/EnumToString/EnumToString.h

    r12013 r13034  
    66#define _ENUMTOSTRING_H
    77
    8 /* local prototypes: */
    9 void EnumToStringUsage(void);
     8#ifdef HAVE_CONFIG_H
     9#include <config.h>
     10#else
     11#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
     12#endif
    1013
     14/*Very important definition in case we are compiling a python module!: needs to come before header files inclusion*/
     15#ifdef _HAVE_PYTHON_
     16#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
     17#endif
     18
     19/*Header files: */
    1120#include "../../c/include/globals.h"
    1221#include "../../c/modules/modules.h"
     
    1524#include "../../c/issm-binding.h"
    1625   
     26#ifdef _HAVE_MATLAB_MODULES_
    1727/* serial input macros: */
    1828#define ENUMIN (mxArray*)prhs[0]
    19 
    2029/* serial output macros: */
    2130#define NAME (mxArray**)&plhs[0]
     31#endif
     32
     33#ifdef _HAVE_PYTHON_MODULES_
     34/* serial input macros: */
     35#define ENUMIN PyTuple_GetItem(args,0)
     36/* serial output macros: */
     37#define NAME output,0
     38#endif
    2239
    2340/* serial arg counts: */
     
    3047#define __FUNCT__  "EnumToString"
    3148
     49/* local prototypes: */
     50void EnumToStringUsage(void);
     51
    3252#endif  /* _TEST_H */
  • issm/trunk-jpl/src/modules/StringToEnum/StringToEnum.cpp

    r12518 r13034  
    55#include "./StringToEnum.h"
    66
    7 void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
     7WRAPPER(StringToEnum){
    88
    99        char    *name    = NULL;
    1010        int      enum_out;
    1111
    12         /*checks on arguments on the matlab side: */
    13         if(nrhs!=NRHS){
    14                 StringToEnumUsage(); _error2_("usage. See above");
    15         }
     12        /*Boot module: */
     13        MODULEBOOT();
     14
     15        /*checks on arguments: */
     16        CHECKARGUMENTS(NLHS,NRHS,&StringToEnumUsage);
    1617
    1718        /*Fetch inputs: */
     
    2324        /* output: */
    2425        WriteData(ENUMOUT,enum_out);
     26
     27        /*end module: */
     28        MODULEEND();
    2529}
    2630
  • issm/trunk-jpl/src/modules/StringToEnum/StringToEnum.h

    r12013 r13034  
    66#define _STRINGTOENUM_H
    77
    8 /* local prototypes: */
    9 void StringToEnumUsage(void);
     8#ifdef HAVE_CONFIG_H
     9#include <config.h>
     10#else
     11#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
     12#endif
    1013
     14/*Very important definition in case we are compiling a python module!: needs to come before header files inclusion*/
     15#ifdef _HAVE_PYTHON_
     16#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
     17#endif
     18
     19/*Header files: */
    1120#include "../../c/include/globals.h"
    1221#include "../../c/modules/modules.h"
     
    1524#include "../../c/issm-binding.h"
    1625   
     26#ifdef _HAVE_MATLAB_MODULES_
    1727/* serial input macros: */
    1828#define NAME (mxArray*)prhs[0]
    19 
    2029/* serial output macros: */
    2130#define ENUMOUT (mxArray**)&plhs[0]
     31#endif
     32
     33#ifdef _HAVE_PYTHON_MODULES_
     34/* serial input macros: */
     35#define NAME PyTuple_GetItem(args,0)
     36/* serial output macros: */
     37#define ENUMOUT output,0
     38#endif
    2239
    2340/* serial arg counts: */
     
    3047#define __FUNCT__  "StringToEnum"
    3148
     49/* local prototypes: */
     50void StringToEnumUsage(void);
     51
    3252#endif  /* _TEST_H */
Note: See TracChangeset for help on using the changeset viewer.