Changeset 93


Ignore:
Timestamp:
Oct 6, 2005 3:33:41 PM (19 years ago)
Author:
dkearney
Message:
  1. corrected c interface language binding function names so they are

consistant with previous c interface function names

  1. separated object dictionaries from fortran code, placed them in

the RpBindings.[h,cc] files so matlab bindings can use them too.

  1. adjusted makefile to compile RpBindings code
Location:
trunk
Files:
2 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/c-example/plotc.c

    r92 r93  
    22
    33//#include <stdlib.h>
    4 #include <time.h>
    54#include <string.h>
    65#include <stdio.h>
     
    3332
    3433    // create a rappture library from the file filePath
    35     lib = library(argv[1]);
     34    lib = rpLibrary(argv[1]);
    3635
    3736    if (lib) {
     
    4746
    4847    // get the xml that is stored in the rappture library lib
    49     if( (xmltext = xml(lib)) ) {
     48    if( (xmltext = rpXml(lib)) ) {
    5049        if(DEBUG) {
    5150        //printf("XML file content:\n");
     
    5958
    6059    // get the min
    61     xmltext = getString (lib, "input.number(min).current");
     60    xmltext = rpGetString (lib, "input.number(min).current");
    6261
    6362    if (! (xmltext) ) {
     
    8180
    8281    // get the max
    83     fmax = getDouble(lib,"input.(max).current");
     82    fmax = rpGetDouble(lib,"input.(max).current");
    8483    if(DEBUG) {
    8584        printf("max: %f\n", fmax);
     
    9190        fy = sin(fx);
    9291        sprintf(str, "%f %f\n", fx, fy);
    93         put(lib, "output.curve.component.xy", str, "result", 1);
     92        rpPut(lib, "output.curve.component.xy", str, "result", 1);
    9493    }
    9594
    9695
    9796    // write output to run file and signal
    98     result(lib);
     97    rpResult(lib);
    9998
     99    // free the rappture library
     100    rpFreeLibrary(lib);
     101
     102    // exit program
    100103    return 0;
    101104}
  • trunk/include/cee/RpLibraryCInterface.h

    r83 r93  
    1818
    1919    // unit definition functions
    20     RpLibrary*  library             (const char* path);
    21     void freeLibrary                (RpLibrary* lib);
     20    RpLibrary*  rpLibrary             (const char* path);
     21    void rpFreeLibrary                (RpLibrary* lib);
    2222
    2323    // RpLibrary member functions
    24     RpLibrary*  element             (RpLibrary* lib, const char* path);
    25     RpLibrary*  elementAsObject     (RpLibrary* lib, const char* path);
    26     const char* elementAsType       (RpLibrary* lib, const char* path);
    27     const char* elementAsComp       (RpLibrary* lib, const char* path);
    28     const char* elementAsId         (RpLibrary* lib, const char* path);
     24    RpLibrary*  rpElement             (RpLibrary* lib, const char* path);
     25    RpLibrary*  rpElementAsObject     (RpLibrary* lib, const char* path);
     26    const char* rpElementAsType       (RpLibrary* lib, const char* path);
     27    const char* rpElementAsComp       (RpLibrary* lib, const char* path);
     28    const char* rpElementAsId         (RpLibrary* lib, const char* path);
    2929
    30     RpLibrary* children             (RpLibrary* lib,
    31                                      const char* path, 
     30    RpLibrary* rpChildren             (RpLibrary* lib,
     31                                     const char* path,
    3232                                     RpLibrary* childEle);
    33     RpLibrary* childrenByType       (RpLibrary* lib,
    34                                      const char* path, 
    35                                      RpLibrary* childEle, 
     33    RpLibrary* rpChildrenByType       (RpLibrary* lib,
     34                                     const char* path,
     35                                     RpLibrary* childEle,
    3636                                     const char* type   );
    37     RpLibrary* childrenAsObject     (RpLibrary* lib,
    38                                      const char* path, 
     37    RpLibrary* rpChildrenAsObject     (RpLibrary* lib,
     38                                     const char* path,
    3939                                     const char* type   );
    40     const char* childrenAsType      (RpLibrary* lib,
    41                                      const char* path, 
     40    const char* rpChildrenAsType      (RpLibrary* lib,
     41                                     const char* path,
    4242                                     const char* type   );
    43     const char* childrenAsComp      (RpLibrary* lib,
    44                                      const char* path, 
     43    const char* rpChildrenAsComp      (RpLibrary* lib,
     44                                     const char* path,
    4545                                     const char* type   );
    46     const char* childrenAsId        (RpLibrary* lib,
    47                                      const char* path, 
     46    const char* rpChildrenAsId        (RpLibrary* lib,
     47                                     const char* path,
    4848                                     const char* type   );
    4949
    50     RpLibrary*  get                 (RpLibrary* lib, const char* path);
    51     const char* getString           (RpLibrary* lib, const char* path);
    52     double      getDouble           (RpLibrary* lib, const char* path);
     50    RpLibrary*  rpGet                 (RpLibrary* lib, const char* path);
     51    const char* rpGetString           (RpLibrary* lib, const char* path);
     52    double      rpGetDouble           (RpLibrary* lib, const char* path);
    5353
    54     void        put                 (RpLibrary* lib,
    55                                      const char* path, 
     54    void        rpPut                 (RpLibrary* lib,
     55                                     const char* path,
    5656                                     const char* value,
    5757                                     const char* id,
    5858                                     int append         );
    59     void        putStringId         (RpLibrary* lib,
    60                                      const char* path, 
     59    void        rpPutStringId         (RpLibrary* lib,
     60                                     const char* path,
    6161                                     const char* value,
    6262                                     const char* id,
    6363                                     int append         );
    64     void        putString           (RpLibrary* lib,
    65                                      const char* path, 
     64    void        rpPutString           (RpLibrary* lib,
     65                                     const char* path,
    6666                                     const char* value,
    6767                                     int append         );
    68     void        putDoubleId         (RpLibrary* lib,
    69                                      const char* path, 
     68    void        rpPutDoubleId         (RpLibrary* lib,
     69                                     const char* path,
    7070                                     double value,
    7171                                     const char* id,
    7272                                     int append         );
    73     void        putDouble           (RpLibrary* lib,
    74                                      const char* path, 
     73    void        rpPutDouble           (RpLibrary* lib,
     74                                     const char* path,
    7575                                     double value,
    7676                                     int append         );
    7777
    78     const char* xml                 (RpLibrary* lib);
     78    const char* rpXml                 (RpLibrary* lib);
    7979
    80     const char* nodeComp            (RpLibrary* node);
    81     const char* nodeType            (RpLibrary* node);
    82     const char* nodeId              (RpLibrary* node);
     80    const char* rpNodeComp            (RpLibrary* node);
     81    const char* rpNodeType            (RpLibrary* node);
     82    const char* rpNodeId              (RpLibrary* node);
    8383
    84     void        result              (RpLibrary* lib);
     84    void        rpResult              (RpLibrary* lib);
    8585
    8686#ifdef __cplusplus
  • trunk/include/cee/RpUnitsCInterface.h

    r83 r93  
    1212#ifdef __cplusplus
    1313extern "C" {
    14 #endif 
     14#endif
    1515
    1616    typedef struct RpUnits RpUnits;
    1717
    1818    // unit definition functions
    19     RpUnits* defineUnit(const char* unitSymbol, RpUnits* basis);
     19    RpUnits* rpDefineUnit        ( const char* unitSymbol, RpUnits* basis );
    2020
    2121    // conversion definition functions
    22     RpUnits* defineConv(    RpUnits* fromUnit,
    23                             RpUnits* toUnit,
    24                             double (*convForwFxnPtr)(double),
    25                             double (*convBackFxnPtr)(double)    );
     22    RpUnits* rpDefineConv        ( RpUnits* fromUnit,
     23                                   RpUnits* toUnit,
     24                                   double (*convForwFxnPtr)(double),
     25                                   double (*convBackFxnPtr)(double)    );
    2626
    2727    // unit attribute access functions
    28     const char* getUnits(RpUnits* unit);
     28    const char* rpGetUnits       ( RpUnits* unit );
    2929
    30     const char* getUnitsName(RpUnits* unit);
     30    const char* rpGetUnitsName   ( RpUnits* unit );
    3131
    32     double getExponent(RpUnits* unit);
     32    double rpGetExponent         ( RpUnits* unit );
    3333
    34     RpUnits* getBasis(RpUnits* unit);
     34    RpUnits* rpGetBasis          ( RpUnits* unit);
    3535
    36     RpUnits* find(const char* unitSymbol);
     36    RpUnits* rpFind              ( const char* unitSymbol);
    3737
    38     int makeMetric(RpUnits* basis);
     38    int rpMakeMetric             ( RpUnits* basis );
    3939
    40     // convert functions 
     40    // convert functions
    4141
    42     const char* convert (  const char* fromVal,
    43                             const char* toUnitsName,
    44                             int showUnits,
    45                             int* result );
     42    const char* rpConvert        ( const char* fromVal,
     43                                   const char* toUnitsName,
     44                                   int showUnits,
     45                                   int* result );
    4646
    47     const char* convert_str (  const char* fromVal,
    48                                 const char* toUnitsName,
    49                                 int showUnits,
    50                                 int* result );
     47    const char* rpConvertStr     ( const char* fromVal,
     48                                   const char* toUnitsName,
     49                                   int showUnits,
     50                                   int* result );
    5151
    52     const char* convert_obj_str (   RpUnits* fromUnits,
    53                                     RpUnits* toUnits,
    54                                     double val,
    55                                     int showUnits   );
     52    const char* rpConvert_ObjStr ( RpUnits* fromUnits,
     53                                   RpUnits* toUnits,
     54                                   double val,
     55                                   int showUnits,
     56                                   int* result );
    5657
    57     const char* convert_obj_str_result( RpUnits* fromUnits,
    58                                         RpUnits* toUnits,
    59                                         double val,
    60                                         int showUnits,
    61                                         int* result );
     58    double rpConvertDbl          ( const char* fromVal,
     59                                   const char* toUnitsName,
     60                                   int* result );
    6261
    63     double convert_dbl (    const char* fromVal,
    64                             const char* toUnitsName,
    65                             int* result );
     62    double rpConvert_ObjDbl      ( RpUnits* fromUnits,
     63                                   RpUnits* toUnits,
     64                                   double val,
     65                                   int* result );
    6666
    67     double convert_obj_double ( RpUnits* fromUnits,
    68                                 RpUnits* toUnits,
    69                                 double val  );
    70 
    71     double convert_obj_double_result (  RpUnits* fromUnits,
    72                                         RpUnits* toUnits,
    73                                         double val,
    74                                         int* result );
    75 
    76     int add_presets(const char* presetName);
     67    int rpAddPresets ( const char* presetName );
    7768
    7869#ifdef __cplusplus
  • trunk/include/fortran/RpLibraryFInterface.h

    r84 r93  
    44 *
    55 * ======================================================================
    6  *  AUTHOR:  Derrick Kearney, Purdue University
     6 *  AUTHOR:  Derrick S. Kearney, Purdue University
    77 *  Copyright (c) 2005
    88 *  Purdue Research Foundation, West Lafayette, IN
     
    1111
    1212#include "RpLibrary.h"
    13 #include "RpDict.h"
    1413#include <string.h>
    1514#include <fstream>
     
    150149/**********************************************************/
    151150
    152 /**********************************************************/
    153 
    154 // private member functions
    155 int objType( char* flavor);
    156 
    157 int storeObject_Lib(RpLibrary* objectName);
    158 RpLibrary* getObject_Lib(int objKey);
    159 
    160 // global vars
    161 // dictionary to hold the python objects that
    162 // cannot be sent to fortran
    163 
    164 #define DICT_TEMPLATE <int,RpLibrary*>
    165 RpDict DICT_TEMPLATE fortObjDict_Lib;
    166 
    167151#ifdef __cplusplus
    168152    }
  • trunk/src/Makefile

    r90 r93  
    7373                  scew_extras.o
    7474RP_UNITS_DEPS   = RpUnitsStd.o RpUnits.o RpUnitsCInterface.o RpUnitsFInterface.o
    75 RP_OTHER_DEPS   = RpFortranCommon.o # RpBindingsDict.o
     75RP_OTHER_DEPS   = RpFortranCommon.o RpBindingsDict.o
    7676RP_OBJS_DEP     = RpVariable.o RpAbout.o RpNumber.o RpString.o RpBoolean.o \
    7777                  RpChoice.o RpOption.o RpUnitsStd.o RpUnits.o
  • trunk/src/cee/RpLibraryCInterface.cc

    r83 r93  
    1818
    1919    RpLibrary*
    20     library (const char* path)
     20    rpLibrary (const char* path)
    2121    {
    2222        return new RpLibrary(path);
     
    2424
    2525    void
    26     freeLibrary (RpLibrary* lib)
     26    rpFreeLibrary (RpLibrary* lib)
    2727    {
    2828        delete lib;
     
    3131
    3232    RpLibrary*
    33     element (RpLibrary* lib, const char* path)
     33    rpElement (RpLibrary* lib, const char* path)
    3434    {
    3535        return lib->element(path);
     
    3737
    3838    RpLibrary*
    39     elementAsObject (RpLibrary* lib, const char* path)
    40     {
    41         return element(lib,path);
    42     }
    43 
    44     const char*
    45     elementAsType (RpLibrary* lib, const char* path)
     39    rpElementAsObject (RpLibrary* lib, const char* path)
     40    {
     41        return rpElement(lib,path);
     42    }
     43
     44    const char*
     45    rpElementAsType (RpLibrary* lib, const char* path)
    4646    {
    4747        static std::string retStr = "";
     
    5656
    5757    const char*
    58     elementAsComp (RpLibrary* lib, const char* path)
     58    rpElementAsComp (RpLibrary* lib, const char* path)
    5959    {
    6060        static std::string retStr = "";
     
    6969
    7070    const char*
    71     elementAsId (RpLibrary* lib, const char* path)
     71    rpElementAsId (RpLibrary* lib, const char* path)
    7272    {
    7373        static std::string retStr = "";
     
    8383
    8484    RpLibrary*
    85     children (RpLibrary* lib, const char* path, RpLibrary* childEle   )
     85    rpChildren (RpLibrary* lib, const char* path, RpLibrary* childEle   )
    8686    {
    8787        return lib->children(path,childEle);
     
    8989
    9090    RpLibrary*
    91     childrenByType( RpLibrary* lib,
     91    rpChildrenByType( RpLibrary* lib,
    9292                    const char* path,
    9393                    RpLibrary* childEle,
     
    9898
    9999    RpLibrary*
    100     get (RpLibrary* lib, const char* path)
     100    rpGet (RpLibrary* lib, const char* path)
    101101    {
    102102        return lib->get(path);
     
    104104
    105105    const char*
    106     getString (RpLibrary* lib, const char* path)
     106    rpGetString (RpLibrary* lib, const char* path)
    107107    {
    108108        static std::string retStr = "";
     
    112112
    113113    double
    114     getDouble (RpLibrary* lib, const char* path)
     114    rpGetDouble (RpLibrary* lib, const char* path)
    115115    {
    116116        return lib->getDouble(path);
     
    118118
    119119    void
    120     put         (RpLibrary* lib,
     120    rpPut         (RpLibrary* lib,
    121121                 const char* path,
    122122                 const char* value,
     
    128128
    129129    void
    130     putStringId (RpLibrary* lib,
     130    rpPutStringId (RpLibrary* lib,
    131131                 const char* path,
    132132                 const char* value,
     
    138138
    139139    void
    140     putString ( RpLibrary* lib,
     140    rpPutString ( RpLibrary* lib,
    141141                const char* path,
    142142                const char* value,
     
    147147
    148148    void
    149     putDoubleId (RpLibrary* lib,
     149    rpPutDoubleId (RpLibrary* lib,
    150150                 const char* path,
    151151                 double value,
     
    157157
    158158    void
    159     putDouble   (RpLibrary* lib,
     159    rpPutDouble   (RpLibrary* lib,
    160160                 const char* path,
    161161                 double value,
     
    166166
    167167    const char*
    168     xml (RpLibrary* lib)
     168    rpXml (RpLibrary* lib)
    169169    {
    170170        static std::string retStr = "";
     
    174174
    175175    const char*
    176     nodeComp (RpLibrary* node)
     176    rpNodeComp (RpLibrary* node)
    177177    {
    178178        static std::string retStr = "";
     
    182182
    183183    const char*
    184     nodeType (RpLibrary* node)
     184    rpNodeType (RpLibrary* node)
    185185    {
    186186        static std::string retStr = "";
     
    190190
    191191    const char*
    192     nodeId (RpLibrary* node)
     192    rpNodeId (RpLibrary* node)
    193193    {
    194194        static std::string retStr = "";
     
    198198
    199199    void
    200     result (RpLibrary* lib)
     200    rpResult (RpLibrary* lib)
    201201    {
    202202        lib->result();
  • trunk/src/cee/RpUnitsCInterface.cc

    r83 r93  
    1717#endif
    1818
    19     RpUnits* defineUnit(const char* unitSymbol, RpUnits* basis) {
     19RpUnits*
     20rpDefineUnit(const char* unitSymbol, RpUnits* basis) {
    2021
    21         return RpUnits::define(unitSymbol, basis);
     22    return RpUnits::define(unitSymbol, basis);
     23}
     24
     25RpUnits*
     26rpDefineConv(    RpUnits* fromUnit,
     27               RpUnits* toUnit,
     28               double (*convForwFxnPtr)(double),
     29               double (*convBackFxnPtr)(double)    ) {
     30
     31    return RpUnits::define(fromUnit,toUnit,convForwFxnPtr,convBackFxnPtr);
     32}
     33
     34RpUnits*
     35rpFind ( const char* key ) {
     36
     37    return RpUnits::find(key);
     38}
     39
     40const char*
     41rpGetUnits ( RpUnits* unit ) {
     42
     43    static std::string retVal;
     44    retVal = unit->getUnits();
     45    return retVal.c_str();
     46}
     47
     48const char*
     49rpGetUnitsName ( RpUnits* unit ) {
     50
     51    static std::string retVal;
     52    retVal = unit->getUnitsName();
     53    return retVal.c_str();
     54}
     55
     56double
     57rpGetExponent ( RpUnits* unit ) {
     58
     59    return unit->getExponent();
     60}
     61
     62RpUnits*
     63rpGetBasis ( RpUnits* unit ) {
     64
     65    return unit->getBasis();
     66}
     67
     68int
     69rpMakeMetric(RpUnits* basis) {
     70
     71    return RpUnits::makeMetric(basis);
     72}
     73
     74const char*
     75rpConvert (   const char* fromVal,
     76               const char* toUnitsName,
     77               int showUnits,
     78               int* result ) {
     79
     80    static std::string retVal;
     81    retVal = RpUnits::convert(fromVal,toUnitsName,showUnits,result);
     82    return retVal.c_str();
     83}
     84
     85const char*
     86rpConvertStr (   const char* fromVal,
     87                  const char* toUnitsName,
     88                  int showUnits,
     89                  int* result ) {
     90
     91    static std::string retVal;
     92    retVal = RpUnits::convert(fromVal,toUnitsName,showUnits,result);
     93    return retVal.c_str();
     94}
     95
     96const char*
     97rpConvert_ObjStr ( RpUnits* fromUnits,
     98                   RpUnits* toUnits,
     99                   double val,
     100                   int showUnits,
     101                   int* result ) {
     102
     103    static std::string retVal;
     104    retVal = fromUnits->convert(toUnits,val,showUnits,result);
     105    return retVal.c_str();
     106}
     107
     108double
     109rpConvertDbl (    const char* fromVal,
     110                  const char* toUnitsName,
     111                  int* result ) {
     112
     113    std::string convStr;
     114    double retVal = 0.0;
     115
     116    convStr = RpUnits::convert(fromVal,toUnitsName,0,result);
     117
     118    if (!convStr.empty()) {
     119        retVal = atof(convStr.c_str());
    22120    }
    23121
    24     RpUnits* defineConv(    RpUnits* fromUnit,
    25                             RpUnits* toUnit,
    26                             double (*convForwFxnPtr)(double),
    27                             double (*convBackFxnPtr)(double)    ) {
     122    return retVal;
     123}
    28124
    29         return RpUnits::define(fromUnit,toUnit,convForwFxnPtr,convBackFxnPtr);
    30     }
     125double
     126rpConvert_ObjDbl (   RpUnits* fromUnits,
     127                     RpUnits* toUnits,
     128                     double val,
     129                     int* result ) {
    31130
    32     RpUnits* find(const char* key) {
     131    return fromUnits->convert(toUnits,val,result);
     132}
    33133
    34         return RpUnits::find(key);
    35     }
     134int rpAddPresets ( const char* presetName ) {
    36135
    37     const char* getUnits(RpUnits* unit) {
    38 
    39         static std::string retVal;
    40         retVal = unit->getUnits();
    41         return retVal.c_str();
    42     }
    43 
    44     const char* getUnitsName(RpUnits* unit) {
    45 
    46         static std::string retVal;
    47         retVal = unit->getUnitsName();
    48         return retVal.c_str();
    49     }
    50 
    51     double getExponent(RpUnits* unit) {
    52 
    53         return unit->getExponent();
    54     }
    55 
    56     RpUnits* getBasis(RpUnits* unit) {
    57 
    58         return unit->getBasis();
    59     }
    60 
    61     int makeMetric(RpUnits* basis) {
    62 
    63         return RpUnits::makeMetric(basis);
    64     }
    65 
    66     const char* convert (   const char* fromVal,
    67                             const char* toUnitsName,
    68                             int showUnits,
    69                             int* result ) {
    70 
    71         static std::string retVal;
    72         retVal = RpUnits::convert(fromVal,toUnitsName,showUnits,result);
    73         return retVal.c_str();
    74     }
    75 
    76     const char* convert_str (   const char* fromVal,
    77                                 const char* toUnitsName,
    78                                 int showUnits,
    79                                 int* result ) {
    80 
    81         static std::string retVal;
    82         retVal = RpUnits::convert(fromVal,toUnitsName,showUnits,result);
    83         return retVal.c_str();
    84     }
    85 
    86     const char* convert_obj_str(    RpUnits* fromUnits,
    87                                     RpUnits* toUnits,
    88                                     double val,
    89                                     int showUnits   ) {
    90 
    91         return convert_obj_str_result(fromUnits,toUnits,val,showUnits,NULL);
    92     }
    93 
    94     const char* convert_obj_str_result( RpUnits* fromUnits,
    95                                         RpUnits* toUnits,
    96                                         double val,
    97                                         int showUnits,
    98                                         int* result ) {
    99 
    100         static std::string retVal;
    101         retVal = fromUnits->convert(toUnits,val,showUnits,result);
    102         return retVal.c_str();
    103     }
    104 
    105     double convert_dbl (    const char* fromVal,
    106                             const char* toUnitsName,
    107                             int* result ) {
    108 
    109         std::string convStr;
    110         double retVal = 0.0;
    111 
    112         convStr = RpUnits::convert(fromVal,toUnitsName,0,result);
    113 
    114         if (!convStr.empty()) {
    115             retVal = atof(convStr.c_str());
    116         }
    117 
    118         return retVal;
    119     }
    120 
    121     double convert_obj_double(  RpUnits* fromUnits,
    122                                 RpUnits* toUnits,
    123                                 double val  ) {
    124 
    125         return convert_obj_double_result(fromUnits,toUnits,val,NULL);
    126     }
    127 
    128     double convert_obj_double_result(   RpUnits* fromUnits,
    129                                         RpUnits* toUnits,
    130                                         double val,
    131                                         int* result ) {
    132 
    133         return fromUnits->convert(toUnits,val,result);
    134     }
    135 
    136     int add_presets ( const char* presetName ) {
    137 
    138         return RpUnits::addPresets(presetName);
    139     }
     136    return RpUnits::addPresets(presetName);
     137}
    140138
    141139#ifdef __cplusplus
  • trunk/src/fortran/RpLibraryFInterface.cc

    r84 r93  
    1111
    1212#include "RpLibraryFInterface.h"
     13#include "RpBindingsDict.h"
    1314#include "RpLibraryFStubs.c"
    1415
     
    403404    PyObject* lib = NULL;
    404405    PyObject* list = NULL;
    405    
     406
    406407    char* inPath = NULL;
    407408    char* inType = NULL;
     
    413414        if ((handle) && (*handle != 0)) {
    414415            lib = getObject_Lib(*handle);
    415            
     416
    416417            if (lib) {
    417418                list = rpChildren_f(lib, inPath, "object");
     
    423424                }
    424425                else {
    425                    
     426
    426427                }
    427428            }
     
    606607    PyObject* lib = NULL;
    607608    PyObject* value = NULL;
    608    
     609
    609610    char* inPath = NULL;
    610611    char* inId = NULL;
     
    617618            lib = getObject_Lib(*handle);
    618619            value = getObject_Lib(*valHandle);
    619            
     620
    620621            if (lib && value) {
    621622                // retObj is a borrowed object
     
    811812    // clean up the dictionary
    812813
    813     RpDictEntry DICT_TEMPLATE *hPtr;
    814     // RpDictIterator DICT_TEMPLATE iter((RpDict&)*this);
    815     RpDictIterator DICT_TEMPLATE iter(fortObjDict_Lib);
     814    RpDictEntry DICT_TEMPLATE_L *hPtr;
     815    // RpDictIterator DICT_TEMPLATE iter(fortObjDict_Lib);
     816    // should rp_quit clean up the dict or some function in RpBindingsCommon.h
     817    RpDictIterator DICT_TEMPLATE_L iter(ObjDict_Lib);
    816818
    817819    hPtr = iter.first();
     
    823825    }
    824826
    825     if (fortObjDict_Lib.size()) {
     827    // if (fortObjDict_Lib.size()) {
     828    if (ObjDict_Lib.size()) {
    826829        // probably want to change the warning sometime
    827830        // printf("\nWARNING: internal dictionary is not empty..deleting\n");
     
    841844}
    842845
    843 int objType( char* flavor)
    844 {
    845     if (flavor == NULL) {
    846         // return a PyObject*
    847         return 0;
    848     }
    849     else if((*flavor == 'o')&&(strncmp(flavor,"object", 6)==0)){
    850         // return a PyObject*
    851         return 0;
    852     }
    853     else if (
    854       ((*flavor == 't')&&(strncmp(flavor,"type", 4) == 0))
    855     ||((*flavor == 'i')&&(strncmp(flavor,"id", 2) == 0))
    856     ||((*flavor == 'c')&&(strncmp(flavor,"component", 9) == 0)))
    857     {
    858         // return a char*
    859         // convert the result to c style strings
    860         return 1;
    861     }
    862     else {
    863         // unrecognized format
    864         return -1;
    865     }
    866 }
    867 
    868 int storeObject_Lib(RpLibrary* objectName) {
    869 
    870     int retVal = -1;
    871     int dictKey = fortObjDict_Lib.size() + 1;
    872     int newEntry = 0;
    873 
    874     if (objectName) {
    875         // dictionary returns a reference to the inserted value
    876         // no error checking to make sure it was successful in entering
    877         // the new entry.
    878         fortObjDict_Lib.set(dictKey,objectName, &newEntry);
    879     }
    880 
    881     retVal = dictKey;
    882     return retVal;
    883 }
    884 
    885 RpLibrary* getObject_Lib(int objKey) {
    886 
    887     RpLibrary* retVal = *(fortObjDict_Lib.find(objKey).getValue());
    888 
    889     if (retVal == *(fortObjDict_Lib.getNullEntry().getValue())) {
    890         retVal = NULL;
    891     }
    892 
    893    return retVal;
    894 
    895 }
  • trunk/src/fortran/RpUnitsFInterface.cc

    r84 r93  
    1111
    1212#include "RpUnits.h"
    13 #include "RpDict.h"
    1413#include "string.h"
    1514#include "RpUnitsFInterface.h"
    1615#include "RpUnitsFStubs.c"
    17 
    18 #define DICT_TEMPLATE <int,std::string>
    19 RpDict DICT_TEMPLATE fortObjDictUnits;
    20 
    21 int storeObject_UnitsStr(std::string objectName);
    22 RpUnits* getObject_UnitsInt(int objKey);
     16#include "RpBindingsDict.h"
    2317
    2418int
     
    3731
    3832    if (basisName && *basisName) {
    39         basisStrName = fortObjDictUnits.find(*basisName);
     33        // basisStrName = fortObjDictUnits.find(*basisName);
     34        basisStrName = ObjDictUnits.find(*basisName);
    4035
    4136        if (basisStrName != "") {
     
    8984
    9085    if (basis && *basis) {
    91         newBasis = getObject_UnitsInt(*basis);
     86        newBasis = getObject_UnitsStr(*basis);
    9287
    9388        if (newBasis) {
     
    107102
    108103    if (unitRefVal && *unitRefVal) {
    109         unitObj = getObject_UnitsInt(*unitRefVal);
     104        unitObj = getObject_UnitsStr(*unitRefVal);
    110105        if (unitObj) {
    111106            unitNameText = unitObj->getUnits();
     
    125120
    126121    if (unitRefVal && *unitRefVal) {
    127         unitObj = getObject_UnitsInt(*unitRefVal);
     122        unitObj = getObject_UnitsStr(*unitRefVal);
    128123        if (unitObj) {
    129124            unitNameText = unitObj->getUnitsName();
     
    142137
    143138    if (unitRefVal && *unitRefVal) {
    144         unitObj = getObject_UnitsInt(*unitRefVal);
     139        unitObj = getObject_UnitsStr(*unitRefVal);
    145140        if (unitObj) {
    146141            *retExponent = unitObj->getExponent();
     
    159154
    160155    if (unitRefVal && *unitRefVal) {
    161         unitObj = getObject_UnitsInt(*unitRefVal);
     156        unitObj = getObject_UnitsStr(*unitRefVal);
    162157
    163158        if (unitObj) {
     
    275270}
    276271
    277 
    278 
    279 
    280 //**********************************************************************//
    281 
    282 
    283 int
    284 storeObject_UnitsStr(std::string objectName) {
    285 
    286     int retVal = -1;
    287     int dictNextKey = fortObjDictUnits.size() + 1;
    288     int newEntry = 0;
    289 
    290     if (objectName != "") {
    291         // dictionary returns a reference to the inserted value
    292         // no error checking to make sure it was successful in entering
    293         // the new entry.
    294         fortObjDictUnits.set(dictNextKey,objectName, &newEntry);
    295     }
    296 
    297     retVal = dictNextKey;
    298     return retVal;
    299 }
    300 
    301 RpUnits*
    302 getObject_UnitsInt(int objKey) {
    303 
    304     std::string basisName = *(fortObjDictUnits.find(objKey).getValue());
    305 
    306     if (basisName == *(fortObjDictUnits.getNullEntry().getValue())) {
    307         // basisName = "";
    308         return NULL;
    309     }
    310 
    311    return RpUnits::find(basisName);
    312 
    313 }
  • trunk/test/src/RpLibraryC_test.c

    r83 r93  
    2828    printf("TESTING ELEMENT: path = %s\n", path);
    2929
    30     searchEle = element(lib,path);
    31     type = elementAsType(lib,path);
    32     comp = elementAsComp(lib,path);
    33     id = elementAsId(lib,path);
     30    searchEle = rpElement(lib,path);
     31    type = rpElementAsType(lib,path);
     32    comp = rpElementAsComp(lib,path);
     33    id = rpElementAsId(lib,path);
    3434
    3535    if (!searchEle) {
     
    4242        printf("searchEle type = :%s:\n", type);
    4343
    44         comp = nodeComp(searchEle);
    45         id   = nodeId(searchEle);
    46         type = nodeType(searchEle);
    47        
     44        comp = rpNodeComp(searchEle);
     45        id   = rpNodeId(searchEle);
     46        type = rpNodeType(searchEle);
     47
    4848        printf("searchEle comp = :%s:\n", comp);
    4949        printf("searchEle   id = :%s:\n", id);
     
    6363    printf("TESTING GET String: path = %s\n", path);
    6464
    65     searchVal = getString(lib,path);
     65    searchVal = rpGetString(lib,path);
    6666
    6767    if (!searchVal || *searchVal == '\0') {
     
    8484    printf("TESTING GET Double: path = %s\n", path);
    8585
    86     searchVal = getDouble(lib,path);
     86    searchVal = rpGetDouble(lib,path);
    8787
    8888    printf("searchVal = :%f:\n", searchVal);
     
    102102    printf("TESTING CHILDREN: path = %s\n", path);
    103103
    104     while ( (childEle = children(lib,path,childEle)) ) {
    105         comp = nodeComp(childEle);
    106         id   = nodeId(childEle);
    107         type = nodeType(childEle);
     104    while ( (childEle = rpChildren(lib,path,childEle)) ) {
     105        comp = rpNodeComp(childEle);
     106        id   = rpNodeId(childEle);
     107        type = rpNodeType(childEle);
    108108
    109109        printf("childEle comp = :%s:\n",comp);
     
    128128    printf("TESTING CHILDREN: path = %s\n", path);
    129129
    130     while ( (childEle = childrenByType(lib,path,childEle,searchType)) ) {
    131         comp = nodeComp(childEle);
    132         id   = nodeId(childEle);
    133         type = nodeType(childEle);
     130    while ( (childEle = rpChildrenByType(lib,path,childEle,searchType)) ) {
     131        comp = rpNodeComp(childEle);
     132        id   = rpNodeId(childEle);
     133        type = rpNodeType(childEle);
    134134
    135135        printf("childEle comp = :%s:\n",comp);
     
    151151    printf("TESTING PUT String: path = %s\n", path);
    152152
    153     putString(lib,path,value,append);
    154     searchVal = getString(lib, path);
     153    rpPutString(lib,path,value,append);
     154    searchVal = rpGetString(lib, path);
    155155
    156156    if (!searchVal || *searchVal == '\0') {
     
    173173    printf("TESTING PUT String: path = %s\n", path);
    174174
    175     putDouble(lib,path,value,append);
    176     searchVal = getDouble(lib, path);
     175    rpPutDouble(lib,path,value,append);
     176    searchVal = rpGetDouble(lib, path);
    177177    printf("searchVal = :%f:\n", searchVal);
    178178    retVal = 0;
     
    186186    RpLibrary* lib = NULL;
    187187
    188     if (argc < 3)
     188    if (argc < 2)
    189189    {
    190         printf("usage: RpLibrary_test infile.xml outfile.xml\n");
     190        printf("usage: %s driver.xml\n", argv[0]);
    191191        return -1;
    192192    }
    193193
    194     lib = library(argv[1]);
     194    lib = rpLibrary(argv[1]);
    195195
    196196    test_element(lib,"input.number(min)");
     
    217217    test_childrenByType(lib,"input.number(test)","preset");
    218218
    219     printf("XML = \n%s\n",xml(lib));
     219    printf("XML = \n%s\n",rpXml(lib));
    220220   
    221     freeLibrary(lib);
     221    rpFreeLibrary(lib);
    222222
    223223    return 0;
  • trunk/test/src/RpLibraryF_test.f

    r84 r93  
    55c
    66c ======================================================================
    7 c  AUTHOR:  Derrick Kearney, Purdue University
     7c  AUTHOR:  Derrick S. Kearney, Purdue University
    88c  Copyright (c) 2005
    99c  Purdue Research Foundation, West Lafayette, IN
  • trunk/test/src/RpUnitsC_test.c

    r76 r93  
    4848}
    4949
    50 int main() 
     50int main()
    5151{
    5252
    53     RpUnits* meters = defineUnit("m",NULL);
     53    RpUnits* meters = rpDefineUnit("m",NULL);
    5454
    5555    RpUnits* centimeters = NULL;
     
    5757    RpUnits* cm_basis = NULL;
    5858
    59     RpUnits* angstrom = defineUnit("A",NULL);
    60     RpUnits* fahrenheit = defineUnit("F",NULL);
    61     RpUnits* celcius = defineUnit("C",NULL);
    62     RpUnits* kelvin = defineUnit("K",NULL);
     59    RpUnits* angstrom = rpDefineUnit("A",NULL);
     60    RpUnits* fahrenheit = rpDefineUnit("F",NULL);
     61    RpUnits* celcius = rpDefineUnit("C",NULL);
     62    RpUnits* kelvin = rpDefineUnit("K",NULL);
    6363
    64     defineConv(angstrom, meters, angstrom2meter, meter2angstrom);
    65     defineConv(fahrenheit, celcius, fahrenheit2centigrade, centigrade2fahrenheit);
    66     defineConv(celcius, kelvin, centigrade2kelvin, kelvin2centigrade);
    67    
    68    
     64    rpDefineConv(angstrom, meters, angstrom2meter, meter2angstrom);
     65    rpDefineConv(fahrenheit, celcius, fahrenheit2centigrade, centigrade2fahrenheit);
     66    rpDefineConv(celcius, kelvin, centigrade2kelvin, kelvin2centigrade);
     67
     68
    6969    double cm_exp = 0;
    7070    double nm_conv = 0;
    7171    double value = 0;
    72    
     72
    7373    int result = 0;
    7474    int showUnits = 0;
     
    7676    const char* nm_conv_str = NULL;
    7777    const char* retStr = NULL;
    78    
    79     makeMetric(meters);
    80     centimeters = find("cm");
    81    
     78
     79    rpMakeMetric(meters);
     80    centimeters = rpFind("cm");
     81
    8282    if (meters) {
    83         printf("meters sign is :%s:\n",getUnitsName(meters));
     83        printf("meters sign is :%s:\n",rpGetUnitsName(meters));
    8484    }
    8585
    8686    if (centimeters) {
    87         cm_exp = getExponent(centimeters);
    88         cm_basis = getBasis(centimeters);
     87        cm_exp = rpGetExponent(centimeters);
     88        cm_basis = rpGetBasis(centimeters);
    8989
    90         printf("centimeters sign is :%s:\n",getUnits(centimeters));
     90        printf("centimeters sign is :%s:\n",rpGetUnits(centimeters));
    9191        printf("cm_exp is :%f:\n",cm_exp);
    9292
    9393        if (cm_basis) {
    94             printf("cm_basis sign is :%s:\n",getUnitsName(cm_basis));
     94            printf("cm_basis sign is :%s:\n",rpGetUnitsName(cm_basis));
    9595        }
    9696        else {
     
    100100    }
    101101
    102     nanometers = find("nm");
     102    nanometers = rpFind("nm");
    103103
    104104    if (nanometers) {
    105105
    106         nm_conv = convert_obj_double_result(nanometers,meters,1.0e9,&result);
     106        nm_conv = rpConvert_ObjDbl(nanometers,meters,1.0e9,&result);
    107107        printf("1.0e9 nm = %f m\tresult = %d\n",nm_conv,result);
    108108
    109         nm_conv = convert_obj_double(nanometers,meters,1.0e9);
     109        nm_conv = rpConvert_ObjDbl(nanometers,meters,1.0e9, NULL);
    110110        printf("1.0e9 nm = %f m\n",nm_conv);
    111111
    112112        showUnits = 1;
    113         nm_conv_str = convert_obj_str(nanometers,meters,1.588e9,showUnits);
     113        nm_conv_str = rpConvert_ObjStr(nanometers,meters,1.588e9,showUnits,NULL);
    114114        printf("1.588e9 nm = %s\n",nm_conv_str);
    115115
    116116        showUnits = 0;
    117         nm_conv_str = convert_obj_str(nanometers,meters,1.588e9,showUnits);
     117        nm_conv_str = rpConvert_ObjStr(nanometers,meters,1.588e9,showUnits,NULL);
    118118        printf("1.588e9 nm = %s\n",nm_conv_str);
    119119    }
     
    123123
    124124    if (meters && angstrom && centimeters) {
    125         value = convert_obj_double_result(angstrom,meters,1.0,&result);
     125        value = rpConvert_ObjDbl(angstrom,meters,1.0,&result);
    126126        printf("1 angstrom = %e meters\n",value);
    127127
    128         value = convert_obj_double_result(centimeters,angstrom,1e-8,&result);
     128        value = rpConvert_ObjDbl(centimeters,angstrom,1e-8,&result);
    129129        printf("1.0e-8 centimeter = %f angstroms\n",value);
    130130    }
     
    135135
    136136    if (fahrenheit && celcius) {
    137         value = convert_obj_double_result(fahrenheit,celcius,72,&result);
     137        value = rpConvert_ObjDbl(fahrenheit,celcius,72,&result);
    138138        printf("72 degrees fahrenheit = %f degrees celcius\n",value);
    139    
    140         value = convert_obj_double_result(celcius,fahrenheit,value,&result);
     139
     140        value = rpConvert_ObjDbl(celcius,fahrenheit,value,&result);
    141141        printf("22.222 degrees celcius = %f degrees fahrenheit\n",value);
    142142    }
     
    144144        printf("fahrenheit or celcius is NULL\n");
    145145    }
    146        
     146
    147147    if (celcius && kelvin) {
    148         value = convert_obj_double_result(celcius,kelvin,20,&result);
     148        value = rpConvert_ObjDbl(celcius,kelvin,20,&result);
    149149        printf("20 degrees celcius = %f kelvin\n",value);
    150150
    151         value = convert_obj_double_result(kelvin,celcius,300,&result);
     151        value = rpConvert_ObjDbl(kelvin,celcius,300,&result);
    152152        printf("300 kelvin = %f degrees celcius\n", value);
    153153    }
     
    157157
    158158    printf("====== adding all preset units ======\n");
    159     add_presets("all");
     159    rpAddPresets("all");
    160160
    161161    printf("====== TESTING STATIC CONVERT FXNS ======\n");
    162162
    163     retStr = convert("72F","C",1,&result);
     163    retStr = rpConvert("72F","C",1,&result);
    164164    printf("72F = %s\tresult = %d\n", retStr,result);
    165165
    166     retStr = convert("300K","F",1,&result);
     166    retStr = rpConvert("300K","F",1,&result);
    167167    printf("300K = %s\tresult = %d\n", retStr,result);
    168168
    169     retStr = convert("1eV","J",0,&result);
     169    retStr = rpConvert("1eV","J",0,&result);
    170170    printf("1eV = %s (no units)\tresult = %d\n", retStr,result);
    171171
    172     retStr = convert_str("300K","R",1,&result);
     172    retStr = rpConvertStr("300K","R",1,&result);
    173173    printf("300K = %s\tresult = %d\n", retStr,result);
    174174
    175     retStr = convert_str("5m","ft",1,&result);
     175    retStr = rpConvertStr("5m","ft",1,&result);
    176176    printf("5m = %s\tresult = %d\n", retStr,result);
    177177
    178     value = convert_dbl("5000mV","V",&result);
     178    value = rpConvertDbl("5000mV","V",&result);
    179179    printf("5V = %f (double value)\n", value);
    180180
    181    
     181
    182182    return 0;
    183183}
Note: See TracChangeset for help on using the changeset viewer.