Changeset 2162


Ignore:
Timestamp:
Mar 28, 2011 5:55:53 PM (13 years ago)
Author:
mmc
Message:

Fixed the code output for various templates to handle string values
explicitly and output declarations properly. Also fixed matlab/octave
code to handle integers and python to handle boolean values correctly.
Tutorial examples work better now.

Location:
trunk/builder/scripts/templates
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/builder/scripts/templates/clang.tl

    r2153 r2162  
    2222#include "rappture.h"
    2323
     24#include <stdio.h>
    2425#include <stdlib.h>
    25 #include <stdio.h>
     26#include <string.h>
    2627#include <math.h>
    2728#include <unistd.h>
     
    109110    }
    110111  }
     112  input string {
     113    decl "const char* $id;  /* for $path */"
     114    code "\n/* get input value for $path */"
     115    code "rpGetString(io,\"$path.current\", &$id);"
     116  }
    111117  input * {
    112118    code "\n/* get input value for $path */"
     
    149155    code "rpPutString(io, \"$path.current\", line, RPLIB_OVERWRITE);"
    150156  }
     157  output string {
     158    decl "char $id\[1024\];  /* for $path */"
     159    code "\n/* save output value for $path */"
     160    code "rpPutString(io, \"$path.current\", $id, RPLIB_OVERWRITE);"
     161  }
    151162  output * {
    152163    code "\n/* save output value for $path */"
  • trunk/builder/scripts/templates/fortran77.tl

    r2153 r2162  
    2424        integer rp_lib, rp_units_convert_dbl
    2525        integer io, ok
    26         CHARACTER*255 inFile, strVal
     26        character*255 inFile, strVal
    2727
    2828@@DECLARATIONS@@
     
    9999    }
    100100  }
     101  input string {
     102    decl "\nc       for $path"
     103    decl "        character*255 $id"
     104    code "\nc       get input value for $path"
     105    code "        call rp_lib_get(io,\n     +    \"$path.current\", $id)"
     106  }
    101107  input * {
    102108    code "\nc       get input value for $path"
     
    147153    code "        call rp_lib_put_str(io,\n     +    \"$path.current\",strVal,0)"
    148154  }
     155  output string {
     156    decl "\nc       for $path"
     157    decl "        character*255 $id"
     158    code "\nc       save output value for $path"
     159    code "        call rp_lib_put_str(io,\n     +    \"$path.current\",$id,0)"
     160  }
    149161  output * {
    150162    code "\nc       save output value for $path"
  • trunk/builder/scripts/templates/matlab.tl

    r2153 r2162  
    5454    code "$id = rpLibGetString(io,'$path.current');"
    5555  }
     56  input integer {
     57    code "\n% get input value for $path"
     58    code "$id = int32(rpLibGetDouble(io,'$path.current'));"
     59  }
    5660  input number {
    5761    set units [attr get units]
     
    6266    } else {
    6367      code "\n% get input value for $path"
    64       code "str = rpLibGetString(io,'$path.current');"
    65       code "$id = str2num(str);"
     68      code "$id = rpLibGetDouble(io,'$path.current');"
    6669    }
    6770  }
     
    9093    code "rpLibPutString(io,'$path.current',imdata,0);"
    9194  }
     95  output integer {
     96    code "\n% save output value for $path"
     97    code "rpLibPutString(io,'$path.current',num2str($id),0);"
     98  }
     99  output number {
     100    code "\n% save output value for $path"
     101    code "rpLibPutString(io,'$path.current',num2str($id),0);"
     102  }
    92103  output * {
    93104    code "\n% save output value for $path"
  • trunk/builder/scripts/templates/octave.tl

    r2153 r2162  
    5454    code "$id = rpLibGetString(io,'$path.current');"
    5555  }
     56  input integer {
     57    code "\n% get input value for $path"
     58    code "$id = int32(rpLibGetDouble(io,'$path.current'));"
     59  }
    5660  input number {
    5761    set units [attr get units]
     
    6266    } else {
    6367      code "\n% get input value for $path"
    64       code "str = rpLibGetString(io,'$path.current');"
    65       code "$id = str2num(str);"
     68      code "$id = rpLibGetDouble(io,'$path.current');"
    6669    }
    6770  }
     
    9093    code "rpLibPutString(io,'$path.current',imdata,0);"
    9194  }
     95  output integer {
     96    code "\n% save output value for $path"
     97    code "rpLibPutString(io,'$path.current',num2str($id),0);"
     98  }
     99  output number {
     100    code "\n% save output value for $path"
     101    code "rpLibPutString(io,'$path.current',num2str($id),0);"
     102  }
    92103  output * {
    93104    code "\n% save output value for $path"
  • trunk/builder/scripts/templates/python.tl

    r2153 r2162  
    4949    code "\n# get input value for $path"
    5050    code "# returns value as string \"yes\" or \"no\""
    51     code "$id = io.get('$path.current')"
     51    code "$id = io.get('$path.current') == 'yes'"
    5252  }
    5353  input image {
     
    5555    code "# returns base64-encoded image data"
    5656    code "$id = io.get('$path.current')"
     57  }
     58  input integer {
     59    code "\n# get input value for $path"
     60    code "$id = int(io.get('$path.current'))"
    5761  }
    5862  input number {
     
    6468    } else {
    6569      code "\n# get input value for $path"
    66       code "$id = io.get('$path.current')"
     70      code "$id = float(io.get('$path.current'))"
    6771    }
    6872  }
Note: See TracChangeset for help on using the changeset viewer.