source: trunk/src/octave/RpMatlabInterface.cc @ 122

Last change on this file since 122 was 122, checked in by dkearney, 17 years ago

added initial version of octave language bindings.
1) no claiming language bindings work, but will happily take credit if they do.
2) bindings are untested
3) bindings happen to work with mystery example that happens to be located in examples/app-fermi/matlab/fermi_rp.m and happens to be invokable with examples/app-fermi/matlab/tool_rp.xml
4) bindings need octave2.1-headers installed (in debian: apt-get install octave2.1-headers) to get the mkoctfile program
5) binding function names might be changing to be more discriptive and more tightly bound to either the lib or units module.
6) adjusted Makefile to add octave bindings compilation.

File size: 1.8 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  INTERFACE: Matlab Rappture Library Interface Helper Functions
4 *
5 * ======================================================================
6 *  AUTHOR:  Derrick Kearney, Purdue University
7 *  Copyright (c) 2005
8 *  Purdue Research Foundation, West Lafayette, IN
9 * ======================================================================
10 */
11#include "RpMatlabInterface.h"
12
13int
14getIntInput ( const mxArray* prhs ) {
15
16    int retVal = -1;
17    retVal = (int) getDoubleInput(prhs);
18    return retVal;
19}
20
21double
22getDoubleInput ( const mxArray* prhs ) {
23
24    double retVal = -1;
25
26    /* Input must be a double. */
27    if (mxIsDouble(prhs) != 1) {
28        mexErrMsgTxt("Input must be a double.");
29        return retVal;
30    }
31
32    /* Input must be a scalar. */
33    if ( (mxGetN(prhs)*mxGetM(prhs)) != 1) {
34        mexErrMsgTxt("Input must be a scalar.");
35        return retVal;
36    }
37
38    retVal = *mxGetPr(prhs);
39
40    return retVal;
41}
42
43char*
44getStringInput ( const mxArray* prhs ) {
45
46    int         buflen = 0;
47    int         status = 0;
48    char*       path = NULL;
49
50    /* Input must be a string. */
51    if (mxIsChar(prhs) != 1)
52        mexErrMsgTxt("Input must be a string.");
53
54    /* Input must be a row vector. */
55    if ( (mxGetM(prhs)) != 1)
56        mexErrMsgTxt("Input must be a row vector.");
57
58    /* Get the length of the input string. */
59    buflen = (mxGetM(prhs) * mxGetN(prhs)) + 1;
60
61    /* Allocate memory for input and output strings. */
62    path = (char*) mxCalloc(buflen, sizeof(char));
63
64    /* Copy the string data from prhs[0] into a C string
65     * path. */
66    status = mxGetString(prhs, path, buflen);
67    if (status != 0)
68        mexWarnMsgTxt("Not enough space. String is truncated.");
69
70    return path;
71}
Note: See TracBrowser for help on using the repository browser.