scisequenceint.swg 2.8 KB

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