scisequencefloat.swg 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. *
  3. * Scilab matrix of float <-> C++ float container
  4. *
  5. */
  6. %include <scifloat.swg>
  7. %fragment(SWIG_AsCheck_Sequence_frag(float), "header") {
  8. SWIGINTERN int
  9. SWIG_AsCheck_Sequence_dec(float)(SwigSciObject obj) {
  10. SciErr sciErr;
  11. int *piAddrVar;
  12. sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piAddrVar);
  13. if (sciErr.iErr) {
  14. printError(&sciErr, 0);
  15. return SWIG_ERROR;
  16. }
  17. if (isDoubleType(pvApiCtx, piAddrVar)) {
  18. return SWIG_OK;
  19. }
  20. else {
  21. Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A double is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
  22. return SWIG_ERROR;
  23. }
  24. }
  25. }
  26. %fragment(SWIG_AsGet_Sequence_frag(float), "header",
  27. fragment="SWIG_SciDouble_AsFloatArrayAndSize") {
  28. SWIGINTERN int
  29. SWIG_AsGet_Sequence_dec(float)(SwigSciObject obj, float **pSequence) {
  30. int iMatrixRowCount;
  31. int iMatrixColCount;
  32. return (SWIG_SciDouble_AsFloatArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, pSequence, SWIG_Scilab_GetFuncName()));
  33. }
  34. }
  35. %fragment(SWIG_AsSize_Sequence_frag(float), "header",
  36. fragment="SWIG_SciDouble_AsFloatArrayAndSize") {
  37. SWIGINTERN int
  38. SWIG_AsSize_Sequence_dec(float)(SwigSciObject obj, int *piSize) {
  39. float *pdblMatrix;
  40. int iMatrixRowCount;
  41. int iMatrixColCount;
  42. if (SWIG_SciDouble_AsFloatArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, &pdblMatrix, SWIG_Scilab_GetFuncName()) == SWIG_OK) {
  43. if ((iMatrixRowCount > 1) && (iMatrixColCount > 1)) {
  44. Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A float vector is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
  45. return SWIG_ERROR;
  46. }
  47. *piSize = iMatrixRowCount * iMatrixColCount;
  48. return SWIG_OK;
  49. }
  50. return SWIG_ERROR;
  51. }
  52. }
  53. %fragment(SWIG_FromCreate_Sequence_frag(float), "header") {
  54. SWIGINTERN int
  55. SWIG_FromCreate_Sequence_dec(float)(int size, float **pSequence) {
  56. *pSequence = new float[size];
  57. return *pSequence != NULL ? SWIG_OK : SWIG_ERROR;
  58. }
  59. }
  60. %fragment(SWIG_FromSet_Sequence_frag(float), "header",
  61. fragment="SWIG_SciDouble_FromFloatArrayAndSize") {
  62. SWIGINTERN SwigSciObject
  63. SWIG_FromSet_Sequence_dec(float)(int size, float *pSequence) {
  64. SwigSciObject obj = SWIG_SciDouble_FromFloatArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, size, pSequence);
  65. delete (float *)pSequence;
  66. return obj;
  67. }
  68. }
  69. %fragment(SWIG_AsVal_SequenceItem_frag(float), "header") {
  70. SWIGINTERN float
  71. SWIG_AsVal_SequenceItem_dec(float)(SwigSciObject obj, float *pSequence, int iItemIndex) {
  72. return pSequence[iItemIndex];
  73. }
  74. }
  75. %fragment(SWIG_From_SequenceItem_frag(float), "header") {
  76. SWIGINTERN int
  77. SWIG_From_SequenceItem_dec(float)(float *pSequence, int iItemIndex, float itemValue) {
  78. pSequence[iItemIndex] = itemValue;
  79. return SWIG_OK;
  80. }
  81. }