Mercurial > hg > octave-lyh
changeset 5879:4f1112bfafce
[project @ 2006-07-05 23:50:44 by jwe]
author | jwe |
---|---|
date | Wed, 05 Jul 2006 23:51:24 +0000 |
parents | 27771d9cd4f4 |
children | 84ca47e311b3 |
files | src/ChangeLog src/mex.cc src/mex.h src/mexproto.h |
diffstat | 4 files changed, 162 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2006-07-05 John W. Eaton <jwe@octave.org> + + * mex.cc (mexGetVariable): Rename from mexGetArray, swap arguments. + (mexGetVariablePtr): Rename from mexGetArrayPtr, swap arguments. + (mexErrMsgIdAndTxt, mexWarnMsgIdAndTxt): New functions. + * mexproto.h: Provide decls. + Include decls for as yet unsupported functions. + * mex.h: Add enum for class ids. + (mexGetArray): Define using mexGetVariable. + (mexGetArrayPtr): Define using mexGetVariablePtr. + 2006-07-02 John W. Eaton <jwe@octave.org> * ov-str-mat.cc (CHAR_MATRIX_CONV): Omit "warn-" from label.
--- a/src/mex.cc +++ b/src/mex.cc @@ -22,7 +22,7 @@ */ // This code was originally distributed as part of Octave Forge under -// the follwoing terms: +// the following terms: // // Author: Paul Kienzle // I grant this code to the public domain. @@ -77,7 +77,7 @@ // the mex function invocation. class mxArray; -// Prototypes for external funcitons. Must declare mxArray as a class +// Prototypes for external functions. Must declare mxArray as a class // before including this file. #include "mexproto.h" @@ -759,7 +759,7 @@ mexErrMsgTxt (const char *s) { if (s && strlen (s) > 0) - error("%s: %s", mexFunctionName (), s); + error ("%s: %s", mexFunctionName (), s); else // Just set the error state; don't print msg. error (""); @@ -767,7 +767,29 @@ __mex->abort(); } -void mexWarnMsgTxt (const char *s) { warning("%s", s); } +void +mexErrMsgIdAndTxt (const char *id, const char *s) +{ + if (s && strlen (s) > 0) + error_with_id (id, "%s: %s", mexFunctionName (), s); + else + // Just set the error state; don't print msg. + error (""); + + __mex->abort(); +} + +void +mexWarnMsgTxt (const char *s) +{ + warning ("%s", s); +} + +void +mexWarnMsgIdAndTxt (const char *id, const char *s) +{ + warning_with_id (id, "%s", s); +} void mexPrintf (const char *fmt, ...) @@ -780,9 +802,9 @@ // Floating point representation. -int mxIsNaN (const double v) { return lo_ieee_isnan (v) != 0; } int mxIsFinite (const double v) { return lo_ieee_finite (v) != 0; } int mxIsInf (const double v) { return lo_ieee_isinf (v) != 0; } +int mxIsNaN (const double v) { return lo_ieee_isnan (v) != 0; } double mxGetEps (void) { return DBL_EPSILON; } double mxGetInf (void) { return lo_ieee_inf_value (); } @@ -1055,7 +1077,7 @@ } mxArray * -mexGetArray (const char *name, const char *space) +mexGetVariable (const char *space, const char *name) { mxArray *retval = 0; @@ -1070,9 +1092,9 @@ else if (! strcmp (space, "caller")) sr = curr_sym_tab->lookup (name); else if (! strcmp (space, "base")) - mexErrMsgTxt ("mexGetArray: 'base' symbol table not implemented"); + mexErrMsgTxt ("mexGetVariable: 'base' symbol table not implemented"); else - mexErrMsgTxt ("mexGetArray: symbol table does not exist"); + mexErrMsgTxt ("mexGetVariable: symbol table does not exist"); if (sr) { @@ -1088,10 +1110,10 @@ return retval; } -mxArray * -mexGetArrayPtr (const char *name, const char *space) +const mxArray * +mexGetVariablePtr (const char *space, const char *name) { - return mexGetArray (name, space); + return mexGetVariable (space, name); } const char *mxGetName (const mxArray *ptr) { return ptr->name (); } @@ -1132,11 +1154,13 @@ { return ptr->key (key); } + mxArray * mxGetFieldByNumber (const mxArray *ptr, int index, int key_num) { return ptr->field (key_num, index); } + void mxSetFieldByNumber (mxArray *ptr, int index, int key_num, mxArray *val) { @@ -1169,12 +1193,13 @@ mexPrintf ("%.*s\n", slen, s); } +int F77_FUNC (mexisfinite, MEXISFINITE) (double v) { return mxIsFinite (v); } +int F77_FUNC (mexisinf, MEXISINF) (double v) { return mxIsInf (v); } +int F77_FUNC (mexisnan, MEXISNAN) (double v) { return mxIsNaN (v); } + double F77_FUNC (mexgeteps, MEXGETEPS) (void) { return mxGetEps (); } double F77_FUNC (mexgetinf, MEXGETINF) (void) { return mxGetInf (); } double F77_FUNC (mexgetnan, MEXGETNAN) (void) { return mxGetNaN (); } -int F77_FUNC (mexisfinite, MEXISFINITE) (double v) { return mxIsFinite (v); } -int F77_FUNC (mexisinf, MEXISINF) (double v) { return mxIsInf (v); } -int F77_FUNC (mexisnan, MEXISNAN) (double v) { return mxIsNaN (v); } // Array access:
--- a/src/mex.h +++ b/src/mex.h @@ -52,8 +52,38 @@ #define HAVE_OCTAVE typedef void mxArray; + +enum mxComplexity + { + mxREAL = 0, + mxCOMPLEX = 1 + }; + +typedef enum + { + mxUNKNOWN_CLASS = 0, + mxCELL_CLASS, + mxSTRUCT_CLASS, + mxLOGICAL_CLASS, + mxCHAR_CLASS, + mxUNUSED_CLASS, + mxDOUBLE_CLASS, + mxSINGLE_CLASS, + mxINT8_CLASS, + mxUINT8_CLASS, + mxINT16_CLASS, + mxUINT16_CLASS, + mxINT32_CLASS, + mxUINT32_CLASS, + mxINT64_CLASS, + mxUINT64_CLASS, + mxFUNCTION_CLASS, + } mxClassID; + +#if 0 +/* typedef Uint16 mxChar; */ typedef unsigned short mxChar; -enum mxComplexity { mxREAL = 0, mxCOMPLEX = 1 }; +#endif #if ! defined (__cplusplus) typedef int bool; @@ -74,9 +104,9 @@ #endif #if defined (V4) -void mexFunction (int nlhs, mxArray* plhs[], int nrhs, mxArray* prhs[]); +void mexFunction (int nlhs, mxArray* plhs[], int nrhs, mxArray *prhs[]); #else -void mexFunction (int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]); +void mexFunction (int nlhs, mxArray* plhs[], int nrhs, const mxArray *prhs[]); #endif #include "mexproto.h" @@ -93,6 +123,9 @@ #define mexGetMatrix(nm) mexGetArray (nm, "caller") #define mexGetMatrixPtr(nm) mexGetArrayPtr (nm, "caller") +#define mexGetArray(nm, space) mexGetVariable (space, nm) +#define mexGetArrayPtr(nm, space) mexGetVariablePtr (space, nm) + #define mexPutMatrix(ptr) mexPutVariable ("caller", "", ptr) #define mexPutArray(ptr, space) mexPutVariable (space, "", ptr)
--- a/src/mexproto.h +++ b/src/mexproto.h @@ -54,9 +54,9 @@ #endif /* Floating point representation. */ -extern int mxIsNaN (double v); extern int mxIsFinite (double v); extern int mxIsInf (double v); +extern int mxIsNaN (double v); extern double mxGetEps (void); extern double mxGetInf (void); extern double mxGetNaN (void); @@ -70,11 +70,13 @@ extern void mexSetTrapFlag (int flag); extern int mexEvalString (const char *s); extern void mexErrMsgTxt (const char *s); +extern void mexErrMsgIdAndTxt (const char *id, const char *s); extern void mexWarnMsgTxt (const char *s); +extern void mexWarnMsgIdAndTxt (const char *id, const char *s); extern void mexPrintf (const char *fmt, ...); -extern mxArray *mexGetArray (const char *name, const char *space); -extern mxArray *mexGetArrayPtr (const char *name, const char *space); +extern mxArray *mexGetVariable (const char *space, const char *name); +extern const mxArray *mexGetVariablePtr (const char *space, const char *name); extern int mexPutVariable (const char *space, const char *name, mxArray *ptr); @@ -95,23 +97,24 @@ extern mxArray *mxDuplicateArray (const mxArray *v); extern int mxIsChar (const mxArray *ptr); - +extern int mxIsComplex (const mxArray *ptr); +extern int mxIsDouble (const mxArray *ptr); +extern int mxIsEmpty (const mxArray *ptr); +extern int mxIsFull (const mxArray *ptr); +extern int mxIsLogicalScalar (const mxArray *ptr); +extern int mxIsNumeric (const mxArray *ptr); extern int mxIsSparse (const mxArray *ptr); extern int mxIsStruct (const mxArray *ptr); -extern int mxIsFull (const mxArray *ptr); -extern int mxIsDouble (const mxArray *ptr); -extern int mxIsNumeric (const mxArray *ptr); -extern int mxIsComplex (const mxArray *ptr); -extern int mxIsEmpty (const mxArray *ptr); -extern int mxIsLogicalScalar (const mxArray *ptr); + extern int mxGetM (const mxArray *ptr); extern int mxGetN (const mxArray *ptr); extern int mxGetNumberOfDimensions (const mxArray *ptr); extern int mxGetNumberOfElements (const mxArray *ptr); + extern double *mxGetPr (const mxArray *ptr); +extern double *mxGetPi (const mxArray *ptr); /* Structure support. */ -extern int mxIsStruct (const mxArray *ptr); extern mxArray *mxGetField (const mxArray *ptr, int index, const char *key); extern void mxSetField (mxArray *ptr, int index, const char *key, mxArray *val); extern int mxGetNumberOfFields (const mxArray *ptr); @@ -122,12 +125,7 @@ mxArray *val); extern mxArray *mxCreateStructMatrix (int rows, int cols, int num_keys, const char **keys); -#if 0 -extern mxArray *mxCreateStructArray (int num_dims, const int *dims, - int numkeys, const char **keys); -#endif -extern double *mxGetPi (const mxArray *ptr); extern void mxSetM (mxArray *ptr, int M); extern void mxSetN (mxArray *ptr, int N); extern void mxSetPr (mxArray *ptr, double *pr); @@ -139,6 +137,68 @@ extern double mxGetScalar (const mxArray *ptr); +#if 0 +/* Not implemented. */ +extern int mxAddField (mxArray *ptr, const char *field_name); +extern void mxAssert (int expr, char *msg); +extern void mxAssertS (int expr, char *msg); +extern int mxCalcSingleSubscript (const mxArray *ptr, int nsubs, int *subs); +extern void *mxCalloc (size_t n, size_t size); +extern mxArray *mxCreateCellArray (int ndim, const int *dims); +extern mxArray *mxCreateCellMatrix (int m, int n); +extern mxArray *mxCreateCharArray (int ndim, const int *dims); +extern mxArray *mxCreateCharMatrixFromStrings (int m, const char **str); +extern mxArray *mxCreateLogicalArray (int ndim, const int *dims); +extern mxArray *mxCreateLogicalMatrix (int m, int n); +extern mxArray *mxCreateNumericArray (int ndim, const int *dims, mxClassID class, mxComplexity flag); +extern mxArray *mxCreateNumericMatrix (int m, int n, mxClassID class, mxComplexity flag); +extern mxArray *mxCreateSparse (int m, int n, int nzmax, mxComplexity flag); +extern mxArray *mxCreateSparseLogicalMatrix (int m, int n, int nzmax); +extern mxArray *mxGetCell (const mxArray *ptr, int idx); +extern mxChar *mxGetChars (const mxArray *ptr); +extern mxClassID mxGetClassID (const mxArray *ptr); +extern const char *mxGetClassName (const mxArray *ptr); +extern void mxGetData (const mxArray *ptr); +extern int *mxGetDimensions (const mxArray *ptr); +extern int mxGetElementSize (const mxArray *ptr); +extern void *mxGetImagData (const mxArray *ptr); +extern int *mxGetIr (const mxArray *ptr); +extern int *mxGetJc (const mxArray *ptr); +extern mxLogical *mxGetLogicals (const mxArray *ptr); +extern int mxGetNzmax (const mxArray *ptr); +extern int mxIsCell (const mxArray *ptr); +extern int mxIsClass (const mxArray *ptr, const char *name); +extern int mxIsFromGlobalWS (const mxArray *ptr); +extern int mxIsInt16 (const mxArray *ptr); +extern int mxIsInt32 (const mxArray *ptr); +extern int mxIsInt64 (const mxArray *ptr); +extern int mxIsInt8 (const mxArray *ptr); +extern int mxIsLogical (const mxArray *ptr); +extern int mxIsLogicalScalarTrue (const mxArray *ptr); +extern int mxIsSingle (const mxArray *ptr); +extern int mxIsUint16 (const mxArray *ptr); +extern int mxIsUint32 (const mxArray *ptr); +extern int mxIsUint64 (const mxArray *ptr); +extern int mxIsUint8 (const mxArray *ptr); +extern void mxRemoveField (mxArray *ptr, int num); +extern void mxSetCell (mxArray *ptr, int idx, mxArray *val); +extern void mxSetClassName (mxArray *ptr, const char *name); +extern void mxSetData (mxArray *ptr, void *data); +extern void mxSetDimensions (mxArray *ptr, int *dims, int ndim); +extern void mxSetImagData (mxArray *ptr, void *pi); +extern void mxSetIr (mxArray *ptr, int *ir); +extern void mxSetJc (mxArray *ptr, int *ir); +extern void mxSetNzmax (mxArray *ptr, int nzmax); + +extern int mexAtExit (void (*f) (void)); +extern const mxArray *mexGet (double handle, const char *property); +extern int mexIsGlobal (const mxArray *ptr); +extern int mexIsLocked (void); +extern void mexLock (void); +extern int mexSet (double handle, const char *property, mxArray *val); +extern void mexUnlock (void); +#endif + #if defined (__cplusplus) } #endif