summaryrefslogtreecommitdiffstats
path: root/scilab/modules/api_scilab
diff options
context:
space:
mode:
authorantoine ELIAS <antoine.elias@scilab.org>2010-01-22 17:30:07 +0100
committerantoine ELIAS <antoine.elias@scilab.org>2010-01-22 17:30:07 +0100
commitda2e3f0ae30e5569a5cc6865127c3ecb637e5e9b (patch)
tree32364a78835520ae4303bd595c4bdfd06fb90dd6 /scilab/modules/api_scilab
parent6dfe713da52cb453b1570cb39670c706879e6798 (diff)
downloadscilab-da2e3f0ae30e5569a5cc6865127c3ecb637e5e9b.zip
scilab-da2e3f0ae30e5569a5cc6865127c3ecb637e5e9b.tar.gz
add shortcut functions in API scilab
Diffstat (limited to 'scilab/modules/api_scilab')
-rw-r--r--scilab/modules/api_scilab/includes/api_boolean_sparse.h47
-rw-r--r--scilab/modules/api_scilab/includes/api_common.h7
-rw-r--r--scilab/modules/api_scilab/includes/api_error.h21
-rw-r--r--scilab/modules/api_scilab/includes/api_int.h137
-rw-r--r--scilab/modules/api_scilab/includes/api_pointer.h16
-rw-r--r--scilab/modules/api_scilab/includes/api_poly.h132
-rw-r--r--scilab/modules/api_scilab/includes/api_sparse.h88
-rw-r--r--scilab/modules/api_scilab/includes/api_string.h60
-rw-r--r--scilab/modules/api_scilab/src/cpp/api_boolean_sparse.cpp66
-rw-r--r--scilab/modules/api_scilab/src/cpp/api_common.cpp4
-rw-r--r--scilab/modules/api_scilab/src/cpp/api_double.cpp5
-rw-r--r--scilab/modules/api_scilab/src/cpp/api_int.cpp251
-rw-r--r--scilab/modules/api_scilab/src/cpp/api_internal_poly.h4
-rw-r--r--scilab/modules/api_scilab/src/cpp/api_internal_sparse.h3
-rw-r--r--scilab/modules/api_scilab/src/cpp/api_pointer.cpp10
-rw-r--r--scilab/modules/api_scilab/src/cpp/api_poly.cpp267
-rw-r--r--scilab/modules/api_scilab/src/cpp/api_sparse.cpp111
-rw-r--r--scilab/modules/api_scilab/src/cpp/api_string.cpp100
18 files changed, 1314 insertions, 15 deletions
diff --git a/scilab/modules/api_scilab/includes/api_boolean_sparse.h b/scilab/modules/api_scilab/includes/api_boolean_sparse.h
index 6f436b5..409a279 100644
--- a/scilab/modules/api_scilab/includes/api_boolean_sparse.h
+++ b/scilab/modules/api_scilab/includes/api_boolean_sparse.h
@@ -81,6 +81,53 @@ SciErr createNamedBooleanSparseMatrix(void* _pvCtx, char* _pstName, int _iRows,
81 */ 81 */
82SciErr readNamedBooleanSparseMatrix(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int* _piNbItemRow, int* _piColPos); 82SciErr readNamedBooleanSparseMatrix(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int* _piNbItemRow, int* _piColPos);
83 83
84/* shortcut functions */
85
86/**
87 * check if the variable type is a boolean sparse
88 * @param[in] _piAddress variable address
89 * @return 1 for true and 0 for false
90 */
91int isBooleanSparseType(void* _pvCtx, int* _piAddress);
92
93/**
94 * check if the variable type is a boolean sparse
95 * @param[in] _pstName variable name
96 * @return 1 for true and 0 for false
97 */
98int isNamedBooleanSparseType(void* _pvCtx, char* _pstName);
99
100/**
101 * Get boolean sparse variable data
102 * @param[in] _piAddress variable address
103 * @param[out] _piRows return number of row
104 * @param[out] _piCols return number of column
105 * @param[out] _iNbItem return number of item
106 * @param[out] _piNbItemRow return array of number of item for each row
107 * @param[out] _piColPos return array of item column position ( 1 indexed )
108 * @return if the operation successed (0) or not ( !0 )
109 */
110int getAllocatedBooleanSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos);
111
112/**
113 * Get named boolean sparse variable data
114 * @param[in] _pstName variable name
115 * @param[out] _piRows return number of row
116 * @param[out] _piCols return number of column
117 * @param[out] _iNbItem return number of item
118 * @param[out] _piNbItemRow return array of number of item for each row
119 * @param[out] _piColPos return array of item column position ( 1 indexed )
120 * @return if the operation successed (0) or not ( !0 )
121 */
122int getNamedAllocatedBooleanSparseMatrix(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos);
123
124/**
125 * free data allocated by shortcut functions
126 * @param[in] _piNbItemRow array of number of item for each row
127 * @param[in] _piColPos array of item column position ( 1 indexed )
128 */
129void freeAllocatedBooleanSparse(int* _piNbItemRow, int* _piColPos);
130
84#ifdef __cplusplus 131#ifdef __cplusplus
85} 132}
86#endif 133#endif
diff --git a/scilab/modules/api_scilab/includes/api_common.h b/scilab/modules/api_scilab/includes/api_common.h
index 1458e0c..568ff69 100644
--- a/scilab/modules/api_scilab/includes/api_common.h
+++ b/scilab/modules/api_scilab/includes/api_common.h
@@ -223,6 +223,13 @@ int isEmptyMatrix(void* _pvCtx, int* _piAddress);
223int createEmptyMatrix(void* _pvCtx, int _iVar); 223int createEmptyMatrix(void* _pvCtx, int _iVar);
224 224
225/** 225/**
226* Create a named empty matrix
227* @param[in] _pstName variable name
228* @return if the operation successed (0) or not ( !0 )
229*/
230int createNamedEmptyMatrix(void* _pvCtx, char* _pstName);
231
232/**
226* Check if a named variable exists 233* Check if a named variable exists
227* @param[in] _pstName variable name 234* @param[in] _pstName variable name
228* @return if the operation successed (0) or not ( !0 ) 235* @return if the operation successed (0) or not ( !0 )
diff --git a/scilab/modules/api_scilab/includes/api_error.h b/scilab/modules/api_scilab/includes/api_error.h
index ff42cac..301f544 100644
--- a/scilab/modules/api_scilab/includes/api_error.h
+++ b/scilab/modules/api_scilab/includes/api_error.h
@@ -66,13 +66,18 @@ extern "C" {
66#define API_ERROR_TOO_LONG_VAR 204 66#define API_ERROR_TOO_LONG_VAR 204
67#define API_ERROR_CREATE_NAMED_POLY 207 67#define API_ERROR_CREATE_NAMED_POLY 207
68#define API_ERROR_READ_NAMED_POLY 208 68#define API_ERROR_READ_NAMED_POLY 208
69#define API_ERROR_GET_ALLOC_SINGLE_POLY 209
70#define API_ERROR_GET_ALLOC_NAMED_SINGLE_POLY 210
71#define API_ERROR_GET_ALLOC_MATRIX_POLY 211
72#define API_ERROR_GET_ALLOC_NAMED_MATRIX_POLY 212
69 73
70 /*boolean errors 401 - 499*/ 74 /*boolean errors 401 - 499*/
71#define API_ERROR_GET_BOOLEAN 401 75#define API_ERROR_GET_BOOLEAN 401
72#define API_ERROR_CREATE_BOOLEAN 402 76#define API_ERROR_CREATE_BOOLEAN 402
73#define API_ERROR_CREATE_NAMED_BOOLEAN 403 77#define API_ERROR_CREATE_NAMED_BOOLEAN 403
74 78#define API_ERROR_READ_BOOLEAN 404
75#define API_ERROR_READ_BOOLEAN 451 79#define API_ERROR_CREATE_SCALAR_BOOLEAN 405
80#define API_ERROR_CREATE_NAMED_SCALAR_BOOLEAN 406
76 81
77 /*sparse errors 501 - 599*/ 82 /*sparse errors 501 - 599*/
78#define API_ERROR_GET_SPARSE 501 83#define API_ERROR_GET_SPARSE 501
@@ -80,6 +85,8 @@ extern "C" {
80#define API_ERROR_CREATE_SPARSE 504 85#define API_ERROR_CREATE_SPARSE 504
81#define API_ERROR_CREATE_NAMED_SPARSE 505 86#define API_ERROR_CREATE_NAMED_SPARSE 505
82#define API_ERROR_READ_NAMED_SPARSE 506 87#define API_ERROR_READ_NAMED_SPARSE 506
88#define API_ERROR_GET_ALLOC_SPARSE 507
89#define API_ERROR_GET_NAMED_ALLOC_SPARSE 508
83 90
84 /*boolean sparse errors 601 - 699*/ 91 /*boolean sparse errors 601 - 699*/
85#define API_ERROR_GET_BOOLEAN_SPARSE 601 92#define API_ERROR_GET_BOOLEAN_SPARSE 601
@@ -90,8 +97,8 @@ extern "C" {
90#define API_ERROR_READ_NAMED_BOOLEAN_SPARSE 606 97#define API_ERROR_READ_NAMED_BOOLEAN_SPARSE 606
91#define API_ERROR_GET_SCALAR_BOOLEAN 607 98#define API_ERROR_GET_SCALAR_BOOLEAN 607
92#define API_ERROR_GET_NAMED_SCALAR_BOOLEAN 608 99#define API_ERROR_GET_NAMED_SCALAR_BOOLEAN 608
93#define API_ERROR_CREATE_SCALAR_BOOLEAN 609 100#define API_ERROR_GET_ALLOC_BOOLEAN_SPARSE 611
94#define API_ERROR_CREATE_NAMED_SCALAR_BOOLEAN 610 101#define API_ERROR_GET_NAMED_ALLOC_BOOLEAN_SPARSE 612
95 102
96 /*matlab sparse errors 701 - 799*/ 103 /*matlab sparse errors 701 - 799*/
97 104
@@ -103,6 +110,8 @@ extern "C" {
103#define API_ERROR_READ_NAMED_INT 806 110#define API_ERROR_READ_NAMED_INT 806
104#define API_ERROR_GET_SCALAR_INTEGER 807 111#define API_ERROR_GET_SCALAR_INTEGER 807
105#define API_ERROR_GET_NAMED_SCALAR_INTEGER 808 112#define API_ERROR_GET_NAMED_SCALAR_INTEGER 808
113#define API_ERROR_CREATE_SCALAR_INT 809
114#define API_ERROR_CREATE_NAMED_SCALAR_INT 810
106 115
107 /*strings errors 1001 - 1099*/ 116 /*strings errors 1001 - 1099*/
108#define API_ERROR_GET_STRING 1001 117#define API_ERROR_GET_STRING 1001
@@ -122,6 +131,10 @@ extern "C" {
122#define API_ERROR_GET_ALLOC_NAMED_SINGLE_WIDE_STRING 1016 131#define API_ERROR_GET_ALLOC_NAMED_SINGLE_WIDE_STRING 1016
123#define API_ERROR_GET_ALLOC_NAMED_STRING_MATRIX 1017 132#define API_ERROR_GET_ALLOC_NAMED_STRING_MATRIX 1017
124#define API_ERROR_GET_ALLOC_NAMED_WIDE_STRING_MATRIX 1018 133#define API_ERROR_GET_ALLOC_NAMED_WIDE_STRING_MATRIX 1018
134#define API_ERROR_CREATE_SINGLE_STRING 1019
135#define API_ERROR_CREATE_SINGLE_WIDE_STRING 1020
136#define API_ERROR_CREATE_NAMED_SINGLE_STRING 1021
137#define API_ERROR_CREATE_NAMED_SINGLE_WIDE_STRING 1022
125 138
126 /*list errors 1501 - 1599*/ 139 /*list errors 1501 - 1599*/
127#define API_ERROR_LIST_ITEM_NUMBER 1501 140#define API_ERROR_LIST_ITEM_NUMBER 1501
diff --git a/scilab/modules/api_scilab/includes/api_int.h b/scilab/modules/api_scilab/includes/api_int.h
index 3cee375..843cbee 100644
--- a/scilab/modules/api_scilab/includes/api_int.h
+++ b/scilab/modules/api_scilab/includes/api_int.h
@@ -429,6 +429,143 @@ int getNamedScalarUnsignedInteger32(void* _pvCtx, char* _pstName, unsigned int*
429int getNamedScalarUnsignedInteger64(void* _pvCtx, char* _pstName, unsigned long long* _pullData); 429int getNamedScalarUnsignedInteger64(void* _pvCtx, char* _pstName, unsigned long long* _pullData);
430#endif 430#endif
431 431
432/**
433 * create scalar integer variable data
434 * @param[in] _piAddress variable name
435 * @param[in] _pcData array of integer 8 bits
436 * @return if the operation successed (0) or not ( !0 )
437 */
438int createScalarInteger8(void* _pvCtx, int _iVar, char cData);
439
440/**
441 * create scalar integer variable data
442 * @param[in] _piAddress variable name
443 * @param[in] _psData array of integer 16 bits
444 * @return if the operation successed (0) or not ( !0 )
445 */
446int createScalarInteger16(void* _pvCtx, int _iVar, short sData);
447
448/**
449 * create scalar integer variable data
450 * @param[in] _piAddress variable name
451 * @param[in] _piData array of integer 32 bits
452 * @return if the operation successed (0) or not ( !0 )
453 */
454int createScalarInteger32(void* _pvCtx, int _iVar, int iData);
455
456/**
457 * create scalar integer variable data
458 * @param[in] _piAddress variable name
459 * @param[in] _pllData array of integer 64 bits
460 * @return if the operation successed (0) or not ( !0 )
461 */
462#ifdef __SCILAB_INT64__
463int createScalarInteger64(void* _pvCtx, int _iVar, long long llData);
464#endif
465
466/**
467 * create scalar integer variable data
468 * @param[in] _piAddress variable name
469 * @param[in] _pucData array of unsigned integer 8 bits
470 * @return if the operation successed (0) or not ( !0 )
471 */
472int createScalarUnsignedInteger8(void* _pvCtx, int _iVar, unsigned char ucData);
473
474/**
475 * create scalar integer variable data
476 * @param[in] _piAddress variable name
477 * @param[in] _pusData array of unsigned integer 16 bits
478 * @return if the operation successed (0) or not ( !0 )
479 */
480int createScalarUnsignedInteger16(void* _pvCtx, int _iVar, unsigned short usData);
481
482/**
483 * create scalar integer variable data
484 * @param[in] _piAddress variable name
485 * @param[in] _puiData array of unsigned integer 32 bits
486 * @return if the operation successed (0) or not ( !0 )
487 */
488int createScalarUnsignedInteger32(void* _pvCtx, int _iVar, unsigned int uiData);
489
490/**
491 * create scalar integer variable data
492 * @param[in] _piAddress variable name
493 * @param[in] _pullData array of unsigned integer 64 bits
494 * @return if the operation successed (0) or not ( !0 )
495 */
496#ifdef __SCILAB_INT64__
497int createScalarUnsignedInteger64(void* _pvCtx, int _iVar, unsigned long long ullData);
498#endif
499
500/**
501 * create named scalar integer variable data
502 * @param[in] _pstName variable name
503 * @param[in] _pcData array of integer 8 bits
504 * @return if the operation successed (0) or not ( !0 )
505 */
506int createNamedScalarInteger8(void* _pvCtx, char* _pstName, char cData);
507
508/**
509 * create named scalar integer variable data
510 * @param[in] _pstName variable name
511 * @param[in] _psData array of integer 16 bits
512 * @return if the operation successed (0) or not ( !0 )
513 */
514int createNamedScalarInteger16(void* _pvCtx, char* _pstName, short sData);
515
516/**
517 * create named scalar integer variable data
518 * @param[in] _pstName variable name
519 * @param[in] _piData array of integer 32 bits
520 * @return if the operation successed (0) or not ( !0 )
521 */
522int createNamedScalarInteger32(void* _pvCtx, char* _pstName, int iData);
523
524/**
525 * create named scalar integer variable data
526 * @param[in] _pstName variable name
527 * @param[in] _pllData array of integer 64 bits
528 * @return if the operation successed (0) or not ( !0 )
529 */
530#ifdef __SCILAB_INT64__
531int createNamedScalarInteger64(void* _pvCtx, char* _pstName, long long llData);
532#endif
533
534/**
535 * create named scalar integer variable data
536 * @param[in] _pstName variable name
537 * @param[in] _pucData array of unsigned integer 8 bits
538 * @return if the operation successed (0) or not ( !0 )
539 */
540int createNamedScalarUnsignedInteger8(void* _pvCtx, char* _pstName, unsigned char ucData);
541
542/**
543 * create named scalar integer variable data
544 * @param[in] _pstName variable name
545 * @param[in] _pusData array of unsigned integer 16 bits
546 * @return if the operation successed (0) or not ( !0 )
547 */
548int createNamedScalarUnsignedInteger16(void* _pvCtx, char* _pstName, unsigned short usData);
549
550/**
551 * create named scalar integer variable data
552 * @param[in] _pstName variable name
553 * @param[in] _puiData array of unsigned integer 32 bits
554 * @return if the operation successed (0) or not ( !0 )
555 */
556int createNamedScalarUnsignedInteger32(void* _pvCtx, char* _pstName, unsigned int uiData);
557
558/**
559 * create named scalar integer variable data
560 * @param[in] _pstName variable name
561 * @param[in] _pullData array of unsigned integer 64 bits
562 * @return if the operation successed (0) or not ( !0 )
563 */
564#ifdef __SCILAB_INT64__
565int createNamedScalarUnsignedInteger64(void* _pvCtx, char* _pstName, unsigned long long ullData);
566#endif
567
568
432#ifdef __cplusplus 569#ifdef __cplusplus
433} 570}
434#endif 571#endif
diff --git a/scilab/modules/api_scilab/includes/api_pointer.h b/scilab/modules/api_scilab/includes/api_pointer.h
index ebacacc..50079b4 100644
--- a/scilab/modules/api_scilab/includes/api_pointer.h
+++ b/scilab/modules/api_scilab/includes/api_pointer.h
@@ -57,6 +57,22 @@ SciErr createNamedPointer(void* _pvCtx, char* _pstName, void* _pvPtr);
57 */ 57 */
58SciErr readNamedPointer(void* _pvCtx, char* _pstName, void** _pvPtr); 58SciErr readNamedPointer(void* _pvCtx, char* _pstName, void** _pvPtr);
59 59
60/* shortcut functions */
61
62/**
63 * check if the variable type is a pointer
64 * @param[in] _piAddress variable address
65 * @return 1 for true and 0 for false
66 */
67int isPointerType(void* _pvCtx, int* _piAddress);
68
69/**
70 * check if the variable type is a pointer
71 * @param[in] _pstName variable name
72 * @return 1 for true and 0 for false
73 */
74int isNamedPointerType(void* _pvCtx, char* _pstName);
75
60#ifdef __cplusplus 76#ifdef __cplusplus
61} 77}
62#endif 78#endif
diff --git a/scilab/modules/api_scilab/includes/api_poly.h b/scilab/modules/api_scilab/includes/api_poly.h
index 6824a73..091bb86 100644
--- a/scilab/modules/api_scilab/includes/api_poly.h
+++ b/scilab/modules/api_scilab/includes/api_poly.h
@@ -133,6 +133,138 @@ SciErr readNamedMatrixOfPoly(void* _pvCtx, char* _pstName, int* _piRows, int* _p
133 133
134SciErr readNamedComplexMatrixOfPoly(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg); 134SciErr readNamedComplexMatrixOfPoly(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
135 135
136/* shortcut functions */
137
138/**
139 * check if the variable type is a poly
140 * @param[in] _piAddress variable address
141 * @return 1 for true and 0 for false
142 */
143int isPolyType(void* _pvCtx, int* _piAddress);
144
145/**
146 * check if the variable type is a poly
147 * @param[in] _pstName variable name
148 * @return 1 for true and 0 for false
149 */
150int isNamedPolyType(void* _pvCtx, char* _pstName);
151
152/**
153 * Get single poly variable data
154 * @param[in] _piAddress variable address
155 * @param[out] _piNbCoef return polynomial coefficient number
156 * @param[out] _pdblReal pointer on real data
157 * @return if the operation successed (0) or not ( !0 )
158 */
159int getAllocatedSinglePoly(void* _pvCtx, int* _piAddress, int* _piNbCoef, double** _pdblReal);
160
161/**
162 * Get single complex poly variable data
163 * @param[in] _piAddress variable address
164 * @param[out] _piNbCoef return polynomial coefficient number
165 * @param[out] _pdblReal pointer on real data
166 * @param[out] _pdblImg pointer on imaginary data
167 * @return if the operation successed (0) or not ( !0 )
168 */
169int getAllocatedSingleComplexPoly(void* _pvCtx, int* _piAddress, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
170
171/**
172 * Get named single poly variable data
173 * @param[in] _pstName variable name
174 * @param[out] _piNbCoef return polynomial coefficient number
175 * @param[out] _pdblReal pointer on real data
176 * @return if the operation successed (0) or not ( !0 )
177 */
178int getAllocatedNamedSinglePoly(void* _pvCtx, char* _pstName, int* _piNbCoef, double** _pdblReal);
179
180/**
181 * Get named single complex poly variable data
182 * @param[in] _pstName variable name
183 * @param[out] _piNbCoef return polynomial coefficient number
184 * @param[out] _pdblReal pointer on real data
185 * @param[out] _pdblImg pointer on imaginary data
186 * @return if the operation successed (0) or not ( !0 )
187 */
188int getAllocatedNamedSingleComplexPoly(void* _pvCtx, char* _pstName, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
189
190/**
191 * Get matrix of poly variable data
192 * @param[in] _piAddress variable address
193 * @param[out] _piRows return number of row
194 * @param[out] _piCols return number of col
195 * @param[out] _piNbCoef return polynomials coefficients number
196 * @param[out] _pdblReal pointer on real data
197 * @return if the operation successed (0) or not ( !0 )
198 */
199int getAllocatedMatrixOfPoly(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal);
200
201/**
202 * Get matrix of complex poly variable data
203 * @param[in] _piAddress variable address
204 * @param[out] _piRows return number of row
205 * @param[out] _piCols return number of col
206 * @param[out] _piNbCoef return polynomials coefficients number
207 * @param[out] _pdblReal pointer on real data
208 * @param[out] _pdblImg pointer on imgaginary data
209 * @return if the operation successed (0) or not ( !0 )
210 */
211int getAllocatedMatrixOfComplexPoly(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal, double*** _pdblImg);
212
213/**
214 * Get named matrix of poly variable data
215 * @param[in] _pstName variable name
216 * @param[out] _piRows return number of row
217 * @param[out] _piCols return number of col
218 * @param[out] _piNbCoef return polynomial coefficient number
219 * @param[out] _pdblReal pointer on real data
220 * @return if the operation successed (0) or not ( !0 )
221 */
222int getAllocatedNamedMatrixOfPoly(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal);
223
224/**
225 * Get named matrix of complex poly variable data
226 * @param[in] _pstName variable name
227 * @param[out] _piRows return number of row
228 * @param[out] _piCols return number of col
229 * @param[out] _piNbCoef return polynomial coefficient number
230 * @param[out] _pdblReal pointer on real data
231 * @param[out] _pdblImg pointer on imaginary data
232 * @return if the operation successed (0) or not ( !0 )
233 */
234int getAllocatedNamedMatrixOfComplexPoly(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal, double*** _pdblImg);
235
236/**
237 * free data allocated by shortcut functions ( named or not )
238 * @param[in] _pdblReal single polynom real data
239 */
240void freeAllocatedSinglePoly(double* _pdblReal);
241
242/**
243 * free data allocated by shortcut functions ( named or not )
244 * @param[in] _pdblReal single polynom real data
245 * @param[in] _pdblImg single polynom imaginary data
246 */
247void freeAllocatedSingleComplexPoly(double* _pdblReal, double* _pdblImg);
248
249/**
250 * free data allocated by shortcut functions ( named or not )
251 * @param[in] _iRows row count
252 * @param[in] _iCols column count
253 * @param[in] _piNbCoef polynomial coefficient number
254 * @param[in] _pdblReal matrix of polynom real data
255 */
256void freeAllocatedMatrixOfPoly(int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal);
257
258/**
259 * free data allocated by shortcut functions ( named or not )
260 * @param[in] _iRows row count
261 * @param[in] _iCols column count
262 * @param[in] _piNbCoef polynomial coefficient number
263 * @param[in] _pdblReal matrix of polynom real data
264 * @param[in] _pdblImg matrix of polynom imaginary data
265 */
266void freeAllocatedMatrixOfComplexPoly(int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
267
136#ifdef __cplusplus 268#ifdef __cplusplus
137} 269}
138#endif 270#endif
diff --git a/scilab/modules/api_scilab/includes/api_sparse.h b/scilab/modules/api_scilab/includes/api_sparse.h
index b5a784a..a50eac5 100644
--- a/scilab/modules/api_scilab/includes/api_sparse.h
+++ b/scilab/modules/api_scilab/includes/api_sparse.h
@@ -166,6 +166,94 @@ SciErr readNamedSparseMatrix(void* _pvCtx, char* _pstName, int* _piRows, int* _p
166 166
167SciErr readNamedComplexSparseMatrix(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int* _piNbItemRow, int* _piColPos, double* _pdblReal, double* _pdblImg); 167SciErr readNamedComplexSparseMatrix(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int* _piNbItemRow, int* _piColPos, double* _pdblReal, double* _pdblImg);
168 168
169/* shortcut functions */
170
171/**
172 * check if the variable type is a sparse
173 * @param[in] _piAddress variable address
174 * @return 1 for true and 0 for false
175 */
176int isSparseType(void* _pvCtx, int* _piAddress);
177
178/**
179 * check if the variable type is a sparse
180 * @param[in] _pstName variable name
181 * @return 1 for true and 0 for false
182 */
183int isNamedSparseType(void* _pvCtx, char* _pstName);
184
185/**
186 * Get sparse variable data
187 * @param[in] _piAddress variable address
188 * @param[out] _piRows return number of row
189 * @param[out] _piCols return number of column
190 * @param[out] _iNbItem return number of item
191 * @param[out] _piNbItemRow return array of number of item for each row
192 * @param[out] _piColPos return array of item column position ( 1 indexed )
193 * @param[out] _pdblReal return array of real data
194 * @return if the operation successed (0) or not ( !0 )
195 */
196int getAllocatedSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal);
197
198/**
199 * Get sparse variable data
200 * @param[in] _piAddress variable address
201 * @param[out] _piRows return number of row
202 * @param[out] _piCols return number of column
203 * @param[out] _iNbItem return number of item
204 * @param[out] _piNbItemRow return array of number of item for each row
205 * @param[out] _piColPos return array of item column position ( 1 indexed )
206 * @param[out] _pdblReal return array of real data
207 * @param[out] _pdblImg return array of imaginary data
208 * @return if the operation successed (0) or not ( !0 )
209 */
210int getAllocatedComplexSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg);
211
212/**
213 * Get named sparse variable data
214 * @param[in] _pstName variable name
215 * @param[out] _piRows return number of row
216 * @param[out] _piCols return number of column
217 * @param[out] _iNbItem return number of item
218 * @param[out] _piNbItemRow return array of number of item for each row
219 * @param[out] _piColPos return array of item column position ( 1 indexed )
220 * @param[out] _pdblReal return array of real data
221 * @return if the operation successed (0) or not ( !0 )
222 */
223int getNamedAllocatedSparseMatrix(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal);
224
225/**
226 * Get named sparse variable data
227 * @param[in] _pstName variable name
228 * @param[out] _piRows return number of row
229 * @param[out] _piCols return number of column
230 * @param[out] _iNbItem return number of item
231 * @param[out] _piNbItemRow return array of number of item for each row
232 * @param[out] _piColPos return array of item column position ( 1 indexed )
233 * @param[out] _pdblReal return array of real data
234 * @param[out] _pdblImg return array of imaginary data
235 * @return if the operation successed (0) or not ( !0 )
236 */
237int getNamedAllocatedComplexSparseMatrix(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg);
238
239
240/**
241 * free data allocated by shortcut functions ( named or not )
242 * @param[in] _piNbItemRow array of number of item for each row
243 * @param[in] _piColPos array of item column position ( 1 indexed )
244 * @param[in] _pdblReal sparse real data
245 */
246void freeAllocatedSparseMatrix(int* _piNbItemRows, int* _piColPos, double* _pdblReal);
247
248/**
249 * free data allocated by shortcut functions ( named or not )
250 * @param[in] _piNbItemRow array of number of item for each row
251 * @param[in] _piColPos array of item column position ( 1 indexed )
252 * @param[in] _pdblReal sparse real data
253 * @param[in] _pdblImg sparse imaginary data
254 */
255void freeAllocatedComplexSparseMatrix(int* _piNbItemRows, int* _piColPos, double* _pdblReal, double* _pdblImg);
256
169#ifdef __cplusplus 257#ifdef __cplusplus
170} 258}
171#endif 259#endif
diff --git a/scilab/modules/api_scilab/includes/api_string.h b/scilab/modules/api_scilab/includes/api_string.h
index 15745a1..6dcb815 100644
--- a/scilab/modules/api_scilab/includes/api_string.h
+++ b/scilab/modules/api_scilab/includes/api_string.h
@@ -205,6 +205,66 @@ int getAllocatedNamedMatrixOfString(void* _pvCtx, char* _pstName, int* _piRows,
205 */ 205 */
206int getAllocatedNamedMatrixOfWideString(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, wchar_t*** _pwstData); 206int getAllocatedNamedMatrixOfWideString(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, wchar_t*** _pwstData);
207 207
208/**
209 * Get single string variable data
210 * @param[in] _iVar variable number
211 * @param[in] _pstStrings string ( null terminated )
212 * @return if the operation successed (0) or not ( !0 )
213 */
214int createSingleString(void* _pvCtx, int _iVar, char* _pstStrings);
215
216/**
217 * Get single wide string variable data
218 * @param[in] _iVar variable number
219 * @param[in] _pwstStrings wide string ( null terminated )
220 * @return if the operation successed (0) or not ( !0 )
221 */
222int createSingleWideString(void* _pvCtx, int _iVar, wchar_t* _pwstStrings);
223
224/**
225 * Get named single string variable data
226 * @param[in] _pstName variable name
227 * @param[in] _pstStrings string ( null terminated )
228 * @return if the operation successed (0) or not ( !0 )
229 */
230int createNamedSingleString(void* _pvCtx, char* _pstName, char* _pstStrings);
231
232/**
233 * Get named single wide string variable data
234 * @param[in] _pstName variable name
235 * @param[in] _pwstStrings wide string ( null terminated )
236 * @return if the operation successed (0) or not ( !0 )
237 */
238int createNamedSingleWideString(void* _pvCtx, char* _pstName, wchar_t* _pwstStrings);
239
240/**
241 * free data allocated by shortcut functions ( named or not )
242 * @param[in] _pstData string data
243 */
244void freeAllocatedSingleString(char* _pstData);
245
246/**
247 * free data allocated by shortcut functions ( named or not )
248 * @param[in] _pwstData wide string data
249 */
250void freeAllocatedSingleWideString(wchar_t* _pwstData);
251
252/**
253 * free data allocated by shortcut functions ( named or not )
254 * @param[in] _iRows row number
255 * @param[in] _iCols column number
256 * @param[in] _pstData matrix of string data
257 */
258void freeAllocatedMatrixOfString(int _iRows, int _iCols, char** _pstData);
259
260/**
261 * free data allocated by shortcut functions ( named or not )
262 * @param[in] _iRows row number
263 * @param[in] _iCols column number
264 * @param[in] _pwstData matrix of wide string data
265 */
266void freeAllocatedMatrixOfWideString(int _iRows, int _iCols, wchar_t** _pwstData);
267
208#ifdef __cplusplus 268#ifdef __cplusplus
209} 269}
210#endif 270#endif
diff --git a/scilab/modules/api_scilab/src/cpp/api_boolean_sparse.cpp b/scilab/modules/api_scilab/src/cpp/api_boolean_sparse.cpp
index 9668a9b..6ad70a5 100644
--- a/scilab/modules/api_scilab/src/cpp/api_boolean_sparse.cpp
+++ b/scilab/modules/api_scilab/src/cpp/api_boolean_sparse.cpp
@@ -22,7 +22,7 @@
22 22
23#include "call_scilab.h" 23#include "call_scilab.h"
24#include "stack-c.h" 24#include "stack-c.h"
25 25#include "MALLOC.h"
26 26
27SciErr getBooleanSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos) 27SciErr getBooleanSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos)
28{ 28{
@@ -223,3 +223,67 @@ SciErr readNamedBooleanSparseMatrix(void* _pvCtx, char* _pstName, int* _piRows,
223 return sciErr; 223 return sciErr;
224} 224}
225/*--------------------------------------------------------------------------*/ 225/*--------------------------------------------------------------------------*/
226int isBooleanSparseType(void* _pvCtx, int* _piAddress)
227{
228 return checkVarType(_pvCtx, _piAddress, sci_boolean_sparse);
229}
230/*--------------------------------------------------------------------------*/
231int isNamedBooleanSparseType(void* _pvCtx, char* _pstName)
232{
233 return checkNamedVarType(_pvCtx, _pstName, sci_boolean_sparse);
234}
235/*--------------------------------------------------------------------------*/
236int getAllocatedBooleanSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos)
237{
238 SciErr sciErr;
239 int* piNbItemRow = NULL;
240 int* piColPos = NULL;
241
242 sciErr = getBooleanSparseMatrix(_pvCtx, _piAddress, _piRows, _piCols, _piNbItem, &piNbItemRow, &piColPos);
243 if(sciErr.iErr)
244 {
245 addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_BOOLEAN_SPARSE, _("%s: Unable to get argument #%d"), "getAllocatedBooleanSparseMatrix", getRhsFromAddress(_pvCtx, _piAddress));
246 printError(&sciErr, 0);
247 return sciErr.iErr;
248 }
249
250 *_piNbItemRow = (int*)MALLOC(sizeof(int) * *_piRows);
251 memcpy(*_piNbItemRow, piNbItemRow, sizeof(int) * *_piRows);
252
253 *_piColPos = (int*)MALLOC(sizeof(int) * *_piNbItem);
254 memcpy(*_piColPos, piColPos, sizeof(int) * *_piNbItem);
255
256 return 0;
257}
258/*--------------------------------------------------------------------------*/
259int getNamedAllocatedBooleanSparseMatrix(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos)
260{
261 SciErr sciErr;
262
263 sciErr = readNamedBooleanSparseMatrix(_pvCtx, _pstName, _piRows, _piCols, _piNbItem, NULL, NULL);
264 if(sciErr.iErr)
265 {
266 addErrorMessage(&sciErr, API_ERROR_GET_NAMED_ALLOC_BOOLEAN_SPARSE, _("%s: Unable to get argument \"%s\""), "getNamedAllocatedBooleanSparseMatrix", _pstName);
267 printError(&sciErr, 0);
268 return sciErr.iErr;
269 }
270
271 *_piNbItemRow = (int*)MALLOC(sizeof(int) * *_piRows);
272 *_piColPos = (int*)MALLOC(sizeof(int) * *_piNbItem);
273
274 sciErr = readNamedBooleanSparseMatrix(_pvCtx, _pstName, _piRows, _piCols, _piNbItem, *_piNbItemRow, *_piColPos);
275 if(sciErr.iErr)
276 {
277 addErrorMessage(&sciErr, API_ERROR_GET_NAMED_ALLOC_BOOLEAN_SPARSE, _("%s: Unable to get argument \"%s\""), "getNamedAllocatedBooleanSparseMatrix", _pstName);
278 printError(&sciErr, 0);
279 return sciErr.iErr;
280 }
281
282 return 0;
283}
284/*--------------------------------------------------------------------------*/
285void freeAllocatedBooleanSparse(int* _piNbItemRow, int* _piColPos)
286{
287 FREE(_piNbItemRow);
288 FREE(_piColPos);
289} \ No newline at end of file
diff --git a/scilab/modules/api_scilab/src/cpp/api_common.cpp b/scilab/modules/api_scilab/src/cpp/api_common.cpp
index c5ad559..4200ff7 100644
--- a/scilab/modules/api_scilab/src/cpp/api_common.cpp
+++ b/scilab/modules/api_scilab/src/cpp/api_common.cpp
@@ -26,6 +26,7 @@
26#include "stackinfo.h" 26#include "stackinfo.h"
27#include "Scierror.h" 27#include "Scierror.h"
28#include "localization.h" 28#include "localization.h"
29#include "MALLOC.h"
29 30
30/*Global structure for scilab 5.x*/ 31/*Global structure for scilab 5.x*/
31extern "C" 32extern "C"
@@ -381,7 +382,7 @@ SciErr getProcessMode(void* _pvCtx, int _iPos, int* _piAddRef, int *_piMode)
381 return sciErr; 382 return sciErr;
382 } 383 }
383 384
384 pstMode[1] = (char*)malloc(sizeof(char) * (iLen + 1)); //+1 for null termination 385 pstMode[1] = (char*)MALLOC(sizeof(char) * (iLen + 1)); //+1 for null termination
385 sciErr = getMatrixOfString(_pvCtx, piAddr2, &iRows2, &iCols2, &iLen, pstMode); 386 sciErr = getMatrixOfString(_pvCtx, piAddr2, &iRows2, &iCols2, &iLen, pstMode);
386 if(sciErr.iErr) 387 if(sciErr.iErr)
387 { 388 {
@@ -390,6 +391,7 @@ SciErr getProcessMode(void* _pvCtx, int _iPos, int* _piAddRef, int *_piMode)
390 } 391 }
391 392
392 iMode = (int)pstMode[0][0]; 393 iMode = (int)pstMode[0][0];
394 FREE(pstMode[0]);
393 } 395 }
394 else 396 else
395 { 397 {
diff --git a/scilab/modules/api_scilab/src/cpp/api_double.cpp b/scilab/modules/api_scilab/src/cpp/api_double.cpp
index 3428995..a321f9d 100644
--- a/scilab/modules/api_scilab/src/cpp/api_double.cpp
+++ b/scilab/modules/api_scilab/src/cpp/api_double.cpp
@@ -499,7 +499,10 @@ static int createCommonScalarDouble(void* _pvCtx, int _iVar, int _iComplex, doub
499 } 499 }
500 500
501 pdblReal[0] = _dblReal; 501 pdblReal[0] = _dblReal;
502 pdblImg[0] = _dblImg; 502 if(_iComplex)
503 {
504 pdblImg[0] = _dblImg;
505 }
503 return 0; 506 return 0;
504} 507}
505/*--------------------------------------------------------------------------*/ 508/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/api_scilab/src/cpp/api_int.cpp b/scilab/modules/api_scilab/src/cpp/api_int.cpp
index 4afacf2..10ab849 100644
--- a/scilab/modules/api_scilab/src/cpp/api_int.cpp
+++ b/scilab/modules/api_scilab/src/cpp/api_int.cpp
@@ -354,7 +354,7 @@ SciErr allocMatrixOfUnsignedInteger32(void* _pvCtx, int _iVar, int _iRows, int _
354 354
355 getNewVarAddressFromPosition(_pvCtx, iNewPos, &piAddr); 355 getNewVarAddressFromPosition(_pvCtx, iNewPos, &piAddr);
356 356
357 sciErr = allocCommonMatrixOfInteger(_pvCtx, _iVar, piAddr, SCI_INT32, _iRows, _iCols, (void**)&puiData32); 357 sciErr = allocCommonMatrixOfInteger(_pvCtx, _iVar, piAddr, SCI_UINT32, _iRows, _iCols, (void**)&puiData32);
358 if(sciErr.iErr) 358 if(sciErr.iErr)
359 { 359 {
360 addErrorMessage(&sciErr, API_ERROR_CREATE_INT, _("%s: Unable to create variable in Scilab memory"), "allocMatrixOfUnsignedInteger32"); 360 addErrorMessage(&sciErr, API_ERROR_CREATE_INT, _("%s: Unable to create variable in Scilab memory"), "allocMatrixOfUnsignedInteger32");
@@ -893,3 +893,252 @@ static int getCommandNamedScalarInteger(void* _pvCtx, char* _pstName, int _iPrec
893 return 0; 893 return 0;
894} 894}
895/*--------------------------------------------------------------------------*/ 895/*--------------------------------------------------------------------------*/
896int createScalarInteger8(void* _pvCtx, int _iVar, char cData)
897{
898 SciErr sciErr;
899
900 sciErr = createMatrixOfInteger8(_pvCtx, _iVar, 1, 1, &cData);
901 if(sciErr.iErr)
902 {
903 addErrorMessage(&sciErr, API_ERROR_CREATE_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createScalarInteger8");
904 printError(&sciErr, 0);
905 return sciErr.iErr;
906 }
907
908 return 0;
909}
910/*--------------------------------------------------------------------------*/
911int createScalarInteger16(void* _pvCtx, int _iVar, short sData)
912{
913 SciErr sciErr;
914
915 sciErr = createMatrixOfInteger16(_pvCtx, _iVar, 1, 1, &sData);
916 if(sciErr.iErr)
917 {
918 addErrorMessage(&sciErr, API_ERROR_CREATE_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createScalarInteger16");
919 printError(&sciErr, 0);
920 return sciErr.iErr;
921 }
922
923 return 0;
924}
925/*--------------------------------------------------------------------------*/
926int createScalarInteger32(void* _pvCtx, int _iVar, int iData)
927{
928 SciErr sciErr;
929
930 sciErr = createMatrixOfInteger32(_pvCtx, _iVar, 1, 1, &iData);
931 if(sciErr.iErr)
932 {
933 addErrorMessage(&sciErr, API_ERROR_CREATE_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createScalarInteger32");
934 printError(&sciErr, 0);
935 return sciErr.iErr;
936 }
937
938 return 0;
939}
940/*--------------------------------------------------------------------------*/
941#ifdef __SCILAB_INT64__
942int createScalarInteger64(void* _pvCtx, int _iVar, long long llData)
943{
944 SciErr sciErr;
945
946 sciErr = createMatrixOfInteger64(_pvCtx, _iVar, 1, 1, llData);
947 if(sciErr.iErr)
948 {
949 addErrorMessage(&sciErr, API_ERROR_CREATE_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createScalarInteger64");
950 printError(&sciErr, 0);
951 return sciErr.iErr;
952 }
953
954 return 0;
955}
956#endif
957/*--------------------------------------------------------------------------*/
958int createScalarUnsignedInteger8(void* _pvCtx, int _iVar, unsigned char ucData)
959{
960 SciErr sciErr;
961
962 sciErr = createMatrixOfUnsignedInteger8(_pvCtx, _iVar, 1, 1, &ucData);
963 if(sciErr.iErr)
964 {
965 addErrorMessage(&sciErr, API_ERROR_CREATE_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createScalarUnsignedInteger8");
966 printError(&sciErr, 0);
967 return sciErr.iErr;
968 }
969
970 return 0;
971}
972/*--------------------------------------------------------------------------*/
973int createScalarUnsignedInteger16(void* _pvCtx, int _iVar, unsigned short usData)
974{
975 SciErr sciErr;
976
977 sciErr = createMatrixOfUnsignedInteger16(_pvCtx, _iVar, 1, 1, &usData);
978 if(sciErr.iErr)
979 {
980 addErrorMessage(&sciErr, API_ERROR_CREATE_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createScalarUnsignedInteger16");
981 printError(&sciErr, 0);
982 return sciErr.iErr;
983 }
984
985 return 0;
986}
987/*--------------------------------------------------------------------------*/
988int createScalarUnsignedInteger32(void* _pvCtx, int _iVar, unsigned int uiData)
989{
990 SciErr sciErr;
991 unsigned int* puiData = NULL;
992
993 sciErr = createMatrixOfUnsignedInteger32(_pvCtx, _iVar, 1, 1, &uiData);
994 if(sciErr.iErr)
995 {
996 addErrorMessage(&sciErr, API_ERROR_CREATE_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createScalarUnsignedInteger32");
997 printError(&sciErr, 0);
998 return sciErr.iErr;
999 }
1000
1001 return 0;
1002}
1003/*--------------------------------------------------------------------------*/
1004#ifdef __SCILAB_INT64__
1005int createScalarUnsignedInteger64(void* _pvCtx, int _iVar, unsigned long long ullData)
1006{
1007 SciErr sciErr;
1008
1009 sciErr = createMatrixOfUnsignedInteger64(_pvCtx, _iVar, 1, 1, &ullData);
1010 if(sciErr.iErr)
1011 {
1012 addErrorMessage(&sciErr, API_ERROR_CREATE_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createScalarUnsignedInteger64");
1013 printError(&sciErr, 0);
1014 return sciErr.iErr;
1015 }
1016
1017 return 0;
1018}
1019#endif
1020/*--------------------------------------------------------------------------*/
1021int createNamedScalarInteger8(void* _pvCtx, char* _pstName, char cData)
1022{
1023 SciErr sciErr;
1024
1025 sciErr = createNamedMatrixOfInteger8(_pvCtx, _pstName, 1, 1, &cData);
1026 if(sciErr.iErr)
1027 {
1028 addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createNamedScalarInteger8");
1029 printError(&sciErr, 0);
1030 return sciErr.iErr;
1031 }
1032
1033 return 0;
1034}
1035/*--------------------------------------------------------------------------*/
1036int createNamedScalarInteger16(void* _pvCtx, char* _pstName, short sData)
1037{
1038 SciErr sciErr;
1039
1040 sciErr = createNamedMatrixOfInteger16(_pvCtx, _pstName, 1, 1, &sData);
1041 if(sciErr.iErr)
1042 {
1043 addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createNamedScalarInteger16");
1044 printError(&sciErr, 0);
1045 return sciErr.iErr;
1046 }
1047
1048 return 0;
1049}
1050/*--------------------------------------------------------------------------*/
1051int createNamedScalarInteger32(void* _pvCtx, char* _pstName, int iData)
1052{
1053 SciErr sciErr;
1054
1055 sciErr = createNamedMatrixOfInteger32(_pvCtx, _pstName, 1, 1, &iData);
1056 if(sciErr.iErr)
1057 {
1058 addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createNamedScalarInteger32");
1059 printError(&sciErr, 0);
1060 return sciErr.iErr;
1061 }
1062
1063 return 0;
1064}
1065/*--------------------------------------------------------------------------*/
1066#ifdef __SCILAB_INT64__
1067int createNamedScalarInteger64(void* _pvCtx, char* _pstName, long long llData)
1068{
1069 SciErr sciErr;
1070
1071 sciErr = createNamedMatrixOfInteger64(_pvCtx, _pstName, 1, 1, &llData);
1072 if(sciErr.iErr)
1073 {
1074 addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createNamedScalarInteger64");
1075 printError(&sciErr, 0);
1076 return sciErr.iErr;
1077 }
1078
1079 return 0;
1080}
1081#endif
1082/*--------------------------------------------------------------------------*/
1083int createNamedScalarUnsignedInteger8(void* _pvCtx, char* _pstName, unsigned char ucData)
1084{
1085 SciErr sciErr;
1086
1087 sciErr = createNamedMatrixOfUnsignedInteger8(_pvCtx, _pstName, 1, 1, &ucData);
1088 if(sciErr.iErr)
1089 {
1090 addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createNamedScalarUnsignedInteger8");
1091 printError(&sciErr, 0);
1092 return sciErr.iErr;
1093 }
1094
1095 return 0;
1096}
1097/*--------------------------------------------------------------------------*/
1098int createNamedScalarUnsignedInteger16(void* _pvCtx, char* _pstName, unsigned short usData)
1099{
1100 SciErr sciErr;
1101
1102 sciErr = createNamedMatrixOfUnsignedInteger16(_pvCtx, _pstName, 1, 1, &usData);
1103 if(sciErr.iErr)
1104 {
1105 addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createNamedScalarUnsignedInteger16");
1106 printError(&sciErr, 0);
1107 return sciErr.iErr;
1108 }
1109
1110 return 0;
1111}
1112/*--------------------------------------------------------------------------*/
1113int createNamedScalarUnsignedInteger32(void* _pvCtx, char* _pstName, unsigned int uiData)
1114{
1115 SciErr sciErr;
1116
1117 sciErr = createNamedMatrixOfUnsignedInteger32(_pvCtx, _pstName, 1, 1, &uiData);
1118 if(sciErr.iErr)
1119 {
1120 addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createNamedScalarUnsignedInteger32");
1121 printError(&sciErr, 0);
1122 return sciErr.iErr;
1123 }
1124
1125 return 0;
1126}
1127/*--------------------------------------------------------------------------*/
1128#ifdef __SCILAB_INT64__
1129int createNamedScalarUnsignedInteger64(void* _pvCtx, char* _pstName, unsigned long long ullData)
1130{
1131 SciErr sciErr;
1132
1133 sciErr = createNamedMatrixOfUnsignedInteger64(_pvCtx, _pstName, 1, 1, &ullData);
1134 if(sciErr.iErr)
1135 {
1136 addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createNamedScalarUnsignedInteger64");
1137 printError(&sciErr, 0);
1138 return sciErr.iErr;
1139 }
1140
1141 return 0;
1142}
1143#endif
1144/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/api_scilab/src/cpp/api_internal_poly.h b/scilab/modules/api_scilab/src/cpp/api_internal_poly.h
index be039d2..9420b1e 100644
--- a/scilab/modules/api_scilab/src/cpp/api_internal_poly.h
+++ b/scilab/modules/api_scilab/src/cpp/api_internal_poly.h
@@ -21,6 +21,10 @@ SciErr readCommonNamedMatrixOfPoly(void* _pvCtx, char* _pstName, int _iComplex,
21SciErr createCommonMatrixOfPolyInNamedList(void* _pvCtx, char* _pstName, int* _piParent, int _iItemPos, char* _pstVarName, int _iComplex, int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg); 21SciErr createCommonMatrixOfPolyInNamedList(void* _pvCtx, char* _pstName, int* _piParent, int _iItemPos, char* _pstVarName, int _iComplex, int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
22SciErr readCommonMatrixOfPolyInNamedList(void* _pvCtx, char* _pstName, int* _piParent, int _iItemPos, int _iComplex, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg); 22SciErr readCommonMatrixOfPolyInNamedList(void* _pvCtx, char* _pstName, int* _piParent, int _iItemPos, int _iComplex, int* _piRows, int* _piCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
23 23
24static int getCommonAllocatedSinglePoly(void* _pvCtx, int* _piAddress, int _iComplex, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
25static int getCommonAllocatedNamedSinglePoly(void* _pvCtx, char* _pstName, int _iComplex, int* _piNbCoef, double** _pdblReal, double** _pdblImg);
26static int getCommonAllocatedMatrixOfPoly(void* _pvCtx, int* _piAddress, int _iComplex, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal, double*** _pdblImg);
27static int getCommonAllocatedNamedMatrixOfPoly(void* _pvCtx, char* _pstName, int _iComplex, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal, double*** _pdblImg);
24 28
25#endif /* __INTERNAL_POLY_API__ */ 29#endif /* __INTERNAL_POLY_API__ */
26 30
diff --git a/scilab/modules/api_scilab/src/cpp/api_internal_sparse.h b/scilab/modules/api_scilab/src/cpp/api_internal_sparse.h
index d370e3c..df689d9 100644
--- a/scilab/modules/api_scilab/src/cpp/api_internal_sparse.h
+++ b/scilab/modules/api_scilab/src/cpp/api_internal_sparse.h
@@ -19,5 +19,8 @@ SciErr createCommonSparseMatrix(void* _pvCtx, int _iVar, int _iComplex, int _iRo
19SciErr createCommonNamedSparseMatrix(void* _pvCtx, char* _pstName, int _iComplex, int _iRows, int _iCols, int _iNbItem, int* _piNbItemRow, int* _piColPos, double* _pdblReal, double* _pdblImg); 19SciErr createCommonNamedSparseMatrix(void* _pvCtx, char* _pstName, int _iComplex, int _iRows, int _iCols, int _iNbItem, int* _piNbItemRow, int* _piColPos, double* _pdblReal, double* _pdblImg);
20SciErr readCommonNamedSparseMatrix(void* _pvCtx, char* _pstName, int _iComplex, int* _piRows, int* _piCols, int* _piNbItem, int* _piNbItemRow, int* _piColPos, double* _pdblReal, double* _pdblImg); 20SciErr readCommonNamedSparseMatrix(void* _pvCtx, char* _pstName, int _iComplex, int* _piRows, int* _piCols, int* _piNbItem, int* _piNbItemRow, int* _piColPos, double* _pdblReal, double* _pdblImg);
21 21
22static int getCommonAllocatedSparseMatrix(void* _pvCtx, int* _piAddress, int _iComplex, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg);
23static int getCommonNamedAllocatedSparseMatrix(void* _pvCtx, char* _pstName, int _iComplex, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg);
24
22 25
23#endif /* __INTERNAL_SPARSE_API__ */ 26#endif /* __INTERNAL_SPARSE_API__ */
diff --git a/scilab/modules/api_scilab/src/cpp/api_pointer.cpp b/scilab/modules/api_scilab/src/cpp/api_pointer.cpp
index 6cc09e4..8921974 100644
--- a/scilab/modules/api_scilab/src/cpp/api_pointer.cpp
+++ b/scilab/modules/api_scilab/src/cpp/api_pointer.cpp
@@ -190,4 +190,14 @@ SciErr readNamedPointer(void* _pvCtx, char* _pstName, void** _pvPtr)
190 return sciErr; 190 return sciErr;
191} 191}
192/*--------------------------------------------------------------------------*/ 192/*--------------------------------------------------------------------------*/
193int isPointerType(void* _pvCtx, int* _piAddress)
194{
195 return checkVarType(_pvCtx, _piAddress, sci_pointer);
196}
197/*--------------------------------------------------------------------------*/
198int isNamedPointerType(void* _pvCtx, char* _pstName)
199{
200 return checkNamedVarType(_pvCtx, _pstName, sci_pointer);
201}
202/*--------------------------------------------------------------------------*/
193 203
diff --git a/scilab/modules/api_scilab/src/cpp/api_poly.cpp b/scilab/modules/api_scilab/src/cpp/api_poly.cpp
index 05fbb00..f12e4d8 100644
--- a/scilab/modules/api_scilab/src/cpp/api_poly.cpp
+++ b/scilab/modules/api_scilab/src/cpp/api_poly.cpp
@@ -330,4 +330,271 @@ SciErr readCommonNamedMatrixOfPoly(void* _pvCtx, char* _pstName, int _iComplex,
330 330
331 return sciErr; 331 return sciErr;
332} 332}
333
334/*shortcut functions */
335
336/*--------------------------------------------------------------------------*/
337int isPolyType(void* _pvCtx, int* _piAddress)
338{
339 return checkVarType(_pvCtx, _piAddress, sci_poly);
340}
341/*--------------------------------------------------------------------------*/
342int isNamedPolyType(void* _pvCtx, char* _pstName)
343{
344 return checkNamedVarType(_pvCtx, _pstName, sci_poly);
345}
346/*--------------------------------------------------------------------------*/
347int getAllocatedSinglePoly(void* _pvCtx, int* _piAddress, int* _piNbCoef, double** _pdblReal)
348{
349 return getCommonAllocatedSinglePoly(_pvCtx, _piAddress, 0, _piNbCoef, _pdblReal, NULL);
350}
351/*--------------------------------------------------------------------------*/
352int getAllocatedSingleComplexPoly(void* _pvCtx, int* _piAddress, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
353{
354 return getCommonAllocatedSinglePoly(_pvCtx, _piAddress, 1, _piNbCoef, _pdblReal, _pdblImg);
355}
333/*--------------------------------------------------------------------------*/ 356/*--------------------------------------------------------------------------*/
357static int getCommonAllocatedSinglePoly(void* _pvCtx, int* _piAddress, int _iComplex, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
358{
359 SciErr sciErr;
360 int iRows = 0;
361 int iCols = 0;
362
363 double* pdblReal = NULL;
364 double* pdblImg = NULL;
365
366 if(isScalar(_pvCtx, _piAddress) == 0)
367 {
368 addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_POLY, _("%s: Wrong type for input argument #%d: A scalar expected.\n"), _iComplex ? "getAllocatedSingleComplexPoly" : "getAllocatedSinglePoly", getRhsFromAddress(_pvCtx, _piAddress));
369 printError(&sciErr, 0);
370 return sciErr.iErr;
371 }
372
373 sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, &iRows, &iCols, _piNbCoef, NULL, NULL);
374 if(sciErr.iErr)
375 {
376 addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedSingleComplexPoly" : "getAllocatedSinglePoly", getRhsFromAddress(_pvCtx, _piAddress));
377 printError(&sciErr, 0);
378 return sciErr.iErr;
379 }
380
381 *_pdblReal = (double*)MALLOC(sizeof(double) * *_piNbCoef);
382
383 if(_iComplex)
384 {
385 *_pdblImg = (double*)MALLOC(sizeof(double) * *_piNbCoef);
386 }
387
388 sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, &iRows, &iCols, _piNbCoef, _pdblReal, _pdblImg);
389 if(sciErr.iErr)
390 {
391 addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedSingleComplexPoly" : "getAllocatedSinglePoly", getRhsFromAddress(_pvCtx, _piAddress));
392 printError(&sciErr, 0);
393 return sciErr.iErr;
394 }
395
396 return 0;
397}
398/*--------------------------------------------------------------------------*/
399int getAllocatedNamedSinglePoly(void* _pvCtx, char* _pstName, int* _piNbCoef, double** _pdblReal)
400{
401 return getCommonAllocatedNamedSinglePoly(_pvCtx, _pstName, 0, _piNbCoef, _pdblReal, NULL);
402}
403/*--------------------------------------------------------------------------*/
404int getAllocatedNamedSingleComplexPoly(void* _pvCtx, char* _pstName, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
405{
406 return getCommonAllocatedNamedSinglePoly(_pvCtx, _pstName, 1, _piNbCoef, _pdblReal, _pdblImg);
407}
408/*--------------------------------------------------------------------------*/
409static int getCommonAllocatedNamedSinglePoly(void* _pvCtx, char* _pstName, int _iComplex, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
410{
411 SciErr sciErr;
412 int iRows = 0;
413 int iCols = 0;
414
415 double* pdblReal = NULL;
416 double* pdblImg = NULL;
417
418 if(isNamedScalar(_pvCtx, _pstName) == 0)
419 {
420 addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_SINGLE_POLY, _("%s: Wrong type for input argument \"%s\": A scalar expected.\n"), _iComplex ? "getAllocatedNamedSingleComplexPoly" : "getAllocatedNamedSinglePoly", _pstName);
421 printError(&sciErr, 0);
422 return sciErr.iErr;
423 }
424
425 sciErr = readCommonNamedMatrixOfPoly(_pvCtx, _pstName, _iComplex, &iRows, &iCols, _piNbCoef, &pdblReal, &pdblImg);
426 if(sciErr.iErr)
427 {
428 addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_SINGLE_POLY, _("%s: Unable to get argument \"%s\""), _iComplex ? "getAllocatedNamedSingleComplexPoly" : "getAllocatedNamedSinglePoly", _pstName);
429 printError(&sciErr, 0);
430 return sciErr.iErr;
431 }
432
433 *_pdblReal = (double*)MALLOC(sizeof(double) * *_piNbCoef);
434 memcpy(*_pdblReal, pdblReal, sizeof(double) * *_piNbCoef);
435
436 if(_iComplex)
437 {
438 *_pdblImg = (double*)MALLOC(sizeof(double) * *_piNbCoef);
439 memcpy(*_pdblImg, pdblImg, sizeof(double) * *_piNbCoef);
440 }
441 return 0;
442}
443/*--------------------------------------------------------------------------*/
444int getAllocatedMatrixOfPoly(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal)
445{
446 return getCommonAllocatedMatrixOfPoly(_pvCtx, _piAddress, 0, _piRows, _piCols, _piNbCoef, _pdblReal, NULL);
447}
448/*--------------------------------------------------------------------------*/
449int getAllocatedMatrixOfComplexPoly(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal, double*** _pdblImg)
450{
451 return getCommonAllocatedMatrixOfPoly(_pvCtx, _piAddress, 1, _piRows, _piCols, _piNbCoef, _pdblReal, _pdblImg);
452}
453/*--------------------------------------------------------------------------*/
454static int getCommonAllocatedMatrixOfPoly(void* _pvCtx, int* _piAddress, int _iComplex, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal, double*** _pdblImg)
455{
456 SciErr sciErr;
457
458 double* pdblReal = NULL;
459 double* pdblImg = NULL;
460
461 sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, _piRows, _piCols, NULL, NULL, NULL);
462 if(sciErr.iErr)
463 {
464 addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_MATRIX_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedMatrixOfComplexPoly" : "getAllocatedMatrixOfPoly", getRhsFromAddress(_pvCtx, _piAddress));
465 printError(&sciErr, 0);
466 return sciErr.iErr;
467 }
468
469 *_piNbCoef = (int*)MALLOC(sizeof(int) * *_piRows * *_piCols);
470
471 sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, _piRows, _piCols, *_piNbCoef, NULL, NULL);
472 if(sciErr.iErr)
473 {
474 addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_MATRIX_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedMatrixOfComplexPoly" : "getAllocatedMatrixOfPoly", getRhsFromAddress(_pvCtx, _piAddress));
475 printError(&sciErr, 0);
476 return sciErr.iErr;
477 }
478
479 *_pdblReal = (double**)MALLOC(sizeof(double*) * *_piRows * *_piCols);
480 for(int i = 0 ; i < *_piRows * *_piCols ; i++)
481 {
482 (*_pdblReal)[i] = (double*)MALLOC(sizeof(double) * *_piNbCoef[i]);
483 }
484
485 if(_iComplex)
486 {
487 *_pdblImg = (double**)MALLOC(sizeof(double*) * *_piRows * *_piCols);
488 for(int i = 0 ; i < *_piRows * *_piCols ; i++)
489 {
490 (*_pdblImg)[i] = (double*)MALLOC(sizeof(double) * *_piNbCoef[i]);
491 }
492 }
493
494 sciErr = getCommonMatrixOfPoly(_pvCtx, _piAddress, _iComplex, _piRows, _piCols, *_piNbCoef, *_pdblReal, *_pdblImg);
495 if(sciErr.iErr)
496 {
497 addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_MATRIX_POLY, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedSingleComplexPoly" : "getAllocatedSinglePoly", getRhsFromAddress(_pvCtx, _piAddress));
498 printError(&sciErr, 0);
499 return sciErr.iErr;
500 }
501
502 return 0;
503}
504/*--------------------------------------------------------------------------*/
505int getAllocatedNamedMatrixOfPoly(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal)
506{
507 return getCommonAllocatedNamedMatrixOfPoly(_pvCtx, _pstName, 0, _piRows, _piCols, _piNbCoef, _pdblReal, NULL);
508}
509/*--------------------------------------------------------------------------*/
510int getAllocatedNamedMatrixOfComplexPoly(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal, double*** _pdblImg)
511{
512 return getCommonAllocatedNamedMatrixOfPoly(_pvCtx, _pstName, 1, _piRows, _piCols, _piNbCoef, _pdblReal, _pdblImg);
513}
514/*--------------------------------------------------------------------------*/
515static int getCommonAllocatedNamedMatrixOfPoly(void* _pvCtx, char* _pstName, int _iComplex, int* _piRows, int* _piCols, int** _piNbCoef, double*** _pdblReal, double*** _pdblImg)
516{
517 SciErr sciErr;
518 int iRows = 0;
519 int iCols = 0;
520
521 double* pdblReal = NULL;
522 double* pdblImg = NULL;
523
524
525 sciErr = readCommonNamedMatrixOfPoly(_pvCtx, _pstName, _iComplex, _piRows, _piCols, NULL, NULL, NULL);
526 if(sciErr.iErr)
527 {
528 addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_MATRIX_POLY, _("%s: Unable to get argument \"%s\""), _iComplex ? "getAllocatedNamedMatrixOfComplexPoly" : "getAllocatedNamedMatrixOfPoly", _pstName);
529 printError(&sciErr, 0);
530 return sciErr.iErr;
531 }
532
533 *_piNbCoef = (int*)MALLOC(sizeof(int) * *_piRows * *_piCols);
534
535 sciErr = readCommonNamedMatrixOfPoly(_pvCtx, _pstName, _iComplex, _piRows, _piCols, *_piNbCoef, NULL, NULL);
536 if(sciErr.iErr)
537 {
538 addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_MATRIX_POLY, _("%s: Unable to get argument \"%s\""), _iComplex ? "getAllocatedNamedMatrixOfComplexPoly" : "getAllocatedNamedMatrixOfPoly", _pstName);
539 printError(&sciErr, 0);
540 return sciErr.iErr;
541 }
542
543 *_pdblReal = (double**)MALLOC(sizeof(double*) * *_piRows * *_piCols);
544 for(int i = 0 ; i < *_piRows * *_piCols ; i++)
545 {
546 (*_pdblReal)[i] = (double*)MALLOC(sizeof(double) * *_piNbCoef[i]);
547 }
548
549 if(_iComplex)
550 {
551 *_pdblImg = (double**)MALLOC(sizeof(double*) * *_piRows * *_piCols);
552 for(int i = 0 ; i < *_piRows * *_piCols ; i++)
553 {
554 (*_pdblImg)[i] = (double*)MALLOC(sizeof(double) * *_piNbCoef[i]);
555 }
556 }
557
558 sciErr = readCommonNamedMatrixOfPoly(_pvCtx, _pstName, _iComplex, _piRows, _piCols, *_piNbCoef, *_pdblReal, *_pdblImg);
559 if(sciErr.iErr)
560 {
561 addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_MATRIX_POLY, _("%s: Unable to get argument \"%s\""), _iComplex ? "getAllocatedNamedMatrixOfComplexPoly" : "getAllocatedNamedMatrixOfPoly", _pstName);
562 printError(&sciErr, 0);
563 return sciErr.iErr;
564 }
565
566 return 0;
567}
568/*--------------------------------------------------------------------------*/
569void freeAllocatedSinglePoly(double* _pdblReal)
570{
571 FREE(_pdblReal);
572}
573/*--------------------------------------------------------------------------*/
574void freeAllocatedSingleComplexPoly(double* _pdblReal, double* _pdblImg)
575{
576 freeAllocatedSinglePoly(_pdblReal);
577 FREE(_pdblImg);
578}
579/*--------------------------------------------------------------------------*/
580void freeAllocatedMatrixOfPoly(int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal)
581{
582 FREE(_piNbCoef);
583
584 for(int i = 0 ; i < _iRows * _iCols ; i++)
585 {
586 FREE(_pdblReal[i]);
587 }
588 FREE(_pdblReal);
589}
590/*--------------------------------------------------------------------------*/
591void freeAllocatedMatrixOfComplexPoly(int _iRows, int _iCols, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
592{
593 freeAllocatedMatrixOfPoly(_iRows, _iCols, _piNbCoef, _pdblReal);
594
595 for(int i = 0 ; i < _iRows * _iCols ; i++)
596 {
597 FREE(_pdblImg[i]);
598 }
599 FREE(_pdblImg);
600}
diff --git a/scilab/modules/api_scilab/src/cpp/api_sparse.cpp b/scilab/modules/api_scilab/src/cpp/api_sparse.cpp
index 0de3ef6..374fce9 100644
--- a/scilab/modules/api_scilab/src/cpp/api_sparse.cpp
+++ b/scilab/modules/api_scilab/src/cpp/api_sparse.cpp
@@ -357,5 +357,116 @@ SciErr readCommonNamedSparseMatrix(void* _pvCtx, char* _pstName, int _iComplex,
357 357
358 return sciErr; 358 return sciErr;
359} 359}
360
361/* shortcut functions */
362
363/*--------------------------------------------------------------------------*/
364int isSparseType(void* _pvCtx, int* _piAddress)
365{
366 return checkVarType(_pvCtx, _piAddress, sci_sparse);
367}
368/*--------------------------------------------------------------------------*/
369int isNamedSparseType(void* _pvCtx, char* _pstName)
370{
371 return checkNamedVarType(_pvCtx, _pstName, sci_sparse);
372}
360/*--------------------------------------------------------------------------*/ 373/*--------------------------------------------------------------------------*/
374int getAllocatedSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal)
375{
376 return getCommonAllocatedSparseMatrix(_pvCtx, _piAddress, 0, _piRows, _piCols, _piNbItem, _piNbItemRow, _piColPos, _pdblReal, NULL);
377}
378/*--------------------------------------------------------------------------*/
379int getAllocatedComplexSparseMatrix(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg)
380{
381 return getCommonAllocatedSparseMatrix(_pvCtx, _piAddress, 1, _piRows, _piCols, _piNbItem, _piNbItemRow, _piColPos, _pdblReal, _pdblImg);
382}
383/*--------------------------------------------------------------------------*/
384static int getCommonAllocatedSparseMatrix(void* _pvCtx, int* _piAddress, int _iComplex, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg)
385{
386 SciErr sciErr;
387 int* piNbItemRow = NULL;
388 int* piColPos = NULL;
389 double* pdblReal = NULL;
390 double* pdblImg = NULL;
391
392 sciErr = getCommonSparseMatrix(_pvCtx, _piAddress, _iComplex, _piRows, _piCols, _piNbItem, &piNbItemRow, &piColPos, &pdblReal, &pdblImg);
393 if(sciErr.iErr)
394 {
395 addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SPARSE, _("%s: Unable to get argument #%d"), _iComplex ? "getAllocatedComplexSparseMatrix" : "getAllocatedSparseMatrix", getRhsFromAddress(_pvCtx, _piAddress));
396 printError(&sciErr, 0);
397 return sciErr.iErr;
398 }
399
400 *_piNbItemRow = (int*)MALLOC(sizeof(int) * *_piRows);
401 memcpy(_piNbItemRow, piNbItemRow, sizeof(int) * *_piRows);
361 402
403 *_piColPos = (int*)MALLOC(sizeof(int) * *_piNbItem);
404 memcpy(_piColPos, piColPos, sizeof(int) * *_piNbItem);
405
406 *_pdblReal = (double*)MALLOC(sizeof(double) * *_piNbItem);
407 memcpy(_pdblReal, pdblReal, sizeof(double) * *_piNbItem);
408
409 if(_iComplex)
410 {
411 *_pdblImg = (double*)MALLOC(sizeof(double) * *_piNbItem);
412 memcpy(_pdblImg, pdblImg, sizeof(double) * *_piNbItem);
413 }
414
415 return 0;
416}
417/*--------------------------------------------------------------------------*/
418int getNamedAllocatedSparseMatrix(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal)
419{
420 return getCommonNamedAllocatedSparseMatrix(_pvCtx, _pstName, 0, _piRows, _piCols, _piNbItem, _piNbItemRow, _piColPos, _pdblReal, NULL);
421}
422/*--------------------------------------------------------------------------*/
423int getNamedAllocatedComplexSparseMatrix(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg)
424{
425 return getCommonNamedAllocatedSparseMatrix(_pvCtx, _pstName, 1, _piRows, _piCols, _piNbItem, _piNbItemRow, _piColPos, _pdblReal, _pdblImg);
426}
427/*--------------------------------------------------------------------------*/
428static int getCommonNamedAllocatedSparseMatrix(void* _pvCtx, char* _pstName, int _iComplex, int* _piRows, int* _piCols, int* _piNbItem, int** _piNbItemRow, int** _piColPos, double** _pdblReal, double** _pdblImg)
429{
430 SciErr sciErr;
431
432 sciErr = readCommonNamedSparseMatrix(_pvCtx, _pstName, _iComplex, _piRows, _piCols, _piNbItem, NULL, NULL, NULL, NULL);
433 if(sciErr.iErr)
434 {
435 addErrorMessage(&sciErr, API_ERROR_GET_NAMED_ALLOC_SPARSE, _("%s: Unable to get argument \"%s\""), _iComplex ? "getNamedAllocatedComplexSparseMatrix" : "getNamedAllocatedSparseMatrix", _pstName);
436 printError(&sciErr, 0);
437 return sciErr.iErr;
438 }
439
440 *_piNbItemRow = (int*)MALLOC(sizeof(int) * *_piRows);
441 *_piColPos = (int*)MALLOC(sizeof(int) * *_piNbItem);
442
443 *_pdblReal = (double*)MALLOC(sizeof(double) * *_piNbItem);
444 if(_iComplex)
445 {
446 *_pdblImg = (double*)MALLOC(sizeof(double) * *_piNbItem);
447 }
448
449 sciErr = readCommonNamedSparseMatrix(_pvCtx, _pstName, _iComplex, _piRows, _piCols, _piNbItem, *_piNbItemRow, *_piColPos, *_pdblReal, *_pdblImg);
450 if(sciErr.iErr)
451 {
452 addErrorMessage(&sciErr, API_ERROR_GET_NAMED_ALLOC_SPARSE, _("%s: Unable to get argument \"%s\""), _iComplex ? "getNamedAllocatedComplexSparseMatrix" : "getNamedAllocatedSparseMatrix", _pstName);
453 printError(&sciErr, 0);
454 return sciErr.iErr;
455 }
456
457 return 0;
458}
459/*--------------------------------------------------------------------------*/
460void freeAllocatedSparseMatrix(int* _piNbItemRows, int* _piColPos, double* _pdblReal)
461{
462 FREE(_piNbItemRows);
463 FREE(_piColPos);
464 FREE(_pdblReal);
465}
466/*--------------------------------------------------------------------------*/
467void freeAllocatedComplexSparseMatrix(int* _piNbItemRows, int* _piColPos, double* _pdblReal, double* _pdblImg)
468{
469 freeAllocatedSparseMatrix(_piNbItemRows, _piColPos, _pdblReal);
470 FREE(_pdblImg);
471}
472/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/api_scilab/src/cpp/api_string.cpp b/scilab/modules/api_scilab/src/cpp/api_string.cpp
index 8017501..09083fe 100644
--- a/scilab/modules/api_scilab/src/cpp/api_string.cpp
+++ b/scilab/modules/api_scilab/src/cpp/api_string.cpp
@@ -536,7 +536,7 @@ int getAllocatedMatrixOfString(void* _pvCtx, int* _piAddress, int* _piRows, int*
536 536
537 for(i = 0 ; i < *_piRows * *_piCols ; i++) 537 for(i = 0 ; i < *_piRows * *_piCols ; i++)
538 { 538 {
539 *_pstData[i] = (char*)MALLOC(sizeof(char) * (piLen[i] + 1));//+1 for null termination 539 (*_pstData)[i] = (char*)MALLOC(sizeof(char) * (piLen[i] + 1));//+1 for null termination
540 } 540 }
541 541
542 sciErr = getMatrixOfString(_pvCtx, _piAddress, _piRows, _piCols, piLen, *_pstData); 542 sciErr = getMatrixOfString(_pvCtx, _piAddress, _piRows, _piCols, piLen, *_pstData);
@@ -664,12 +664,10 @@ int getAllocatedNamedSingleWideString(void* _pvCtx, char* _pstName, wchar_t** _p
664int getAllocatedNamedMatrixOfString(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, char*** _pstData) 664int getAllocatedNamedMatrixOfString(void* _pvCtx, char* _pstName, int* _piRows, int* _piCols, char*** _pstData)
665{ 665{
666 SciErr sciErr; 666 SciErr sciErr;
667 int iRows = 0;
668 int iCols = 0;
669 int* piLen = 0; 667 int* piLen = 0;
670 668
671 669
672 sciErr = readNamedMatrixOfString(_pvCtx, _pstName, &iRows, &iCols, NULL, NULL); 670 sciErr = readNamedMatrixOfString(_pvCtx, _pstName, _piRows, _piCols, NULL, NULL);
673 if(sciErr.iErr) 671 if(sciErr.iErr)
674 { 672 {
675 addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_STRING_MATRIX, _("%s: Unable to get argument data"), "getAllocatedNamedMatrixOfString"); 673 addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_STRING_MATRIX, _("%s: Unable to get argument data"), "getAllocatedNamedMatrixOfString");
@@ -679,7 +677,7 @@ int getAllocatedNamedMatrixOfString(void* _pvCtx, char* _pstName, int* _piRows,
679 677
680 piLen = (int*)MALLOC(sizeof(int) * *_piRows * *_piCols); 678 piLen = (int*)MALLOC(sizeof(int) * *_piRows * *_piCols);
681 679
682 sciErr = readNamedMatrixOfString(_pvCtx, _pstName, &iRows, &iCols, piLen, NULL); 680 sciErr = readNamedMatrixOfString(_pvCtx, _pstName, _piRows, _piCols, piLen, NULL);
683 if(sciErr.iErr) 681 if(sciErr.iErr)
684 { 682 {
685 addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_STRING_MATRIX, _("%s: Unable to get argument data"), "getAllocatedNamedMatrixOfString"); 683 addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_STRING_MATRIX, _("%s: Unable to get argument data"), "getAllocatedNamedMatrixOfString");
@@ -690,10 +688,10 @@ int getAllocatedNamedMatrixOfString(void* _pvCtx, char* _pstName, int* _piRows,
690 *_pstData = (char**)MALLOC(sizeof(char*) * *_piRows * *_piCols); 688 *_pstData = (char**)MALLOC(sizeof(char*) * *_piRows * *_piCols);
691 for(int i = 0 ; i < *_piRows * *_piCols ; i++) 689 for(int i = 0 ; i < *_piRows * *_piCols ; i++)
692 { 690 {
693 *_pstData[i] = (char*)MALLOC(sizeof(char) * (piLen[i] + 1));//+1 for null termination 691 (*_pstData)[i] = (char*)MALLOC(sizeof(char) * (piLen[i] + 1));//+1 for null termination
694 } 692 }
695 693
696 sciErr = readNamedMatrixOfString(_pvCtx, _pstName, &iRows, &iCols, piLen, *_pstData); 694 sciErr = readNamedMatrixOfString(_pvCtx, _pstName, _piRows, _piCols, piLen, *_pstData);
697 if(sciErr.iErr) 695 if(sciErr.iErr)
698 { 696 {
699 addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_STRING_MATRIX, _("%s: Unable to get argument data"), "getAllocatedNamedMatrixOfString"); 697 addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_STRING_MATRIX, _("%s: Unable to get argument data"), "getAllocatedNamedMatrixOfString");
@@ -747,3 +745,91 @@ int getAllocatedNamedMatrixOfWideString(void* _pvCtx, char* _pstName, int* _piRo
747 return 0; 745 return 0;
748} 746}
749/*--------------------------------------------------------------------------*/ 747/*--------------------------------------------------------------------------*/
748int createSingleString(void* _pvCtx, int _iVar, char* _pstStrings)
749{
750 SciErr sciErr;
751
752 sciErr = createMatrixOfString(_pvCtx, _iVar, 1, 1, &_pstStrings);
753 if(sciErr.iErr)
754 {
755 addErrorMessage(&sciErr, API_ERROR_CREATE_SINGLE_STRING, _("%s: Unable to get argument data"), "createSingleString");
756 printError(&sciErr, 0);
757 return sciErr.iErr;
758 }
759
760 return 0;
761}
762/*--------------------------------------------------------------------------*/
763int createSingleWideString(void* _pvCtx, int _iVar, wchar_t* _pwstStrings)
764{
765 SciErr sciErr;
766
767 sciErr = createMatrixOfWideString(_pvCtx, _iVar, 1, 1, &_pwstStrings);
768 if(sciErr.iErr)
769 {
770 addErrorMessage(&sciErr, API_ERROR_CREATE_SINGLE_WIDE_STRING, _("%s: Unable to get argument data"), "createSingleWideString");
771 printError(&sciErr, 0);
772 return sciErr.iErr;
773 }
774
775 return 0;
776}
777/*--------------------------------------------------------------------------*/
778int createNamedSingleString(void* _pvCtx, char* _pstName, char* _pstStrings)
779{
780 SciErr sciErr;
781
782 sciErr = createNamedMatrixOfString(_pvCtx, _pstName, 1, 1, &_pstStrings);
783 if(sciErr.iErr)
784 {
785 addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_SINGLE_STRING, _("%s: Unable to get argument data"), "createSingleString");
786 printError(&sciErr, 0);
787 return sciErr.iErr;
788 }
789
790 return 0;
791}
792/*--------------------------------------------------------------------------*/
793int createNamedSingleWideString(void* _pvCtx, char* _pstName, wchar_t* _pwstStrings)
794{
795 SciErr sciErr;
796
797 sciErr = createNamedMatrixOfWideString(_pvCtx, _pstName, 1, 1, &_pwstStrings);
798 if(sciErr.iErr)
799 {
800 addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_SINGLE_WIDE_STRING, _("%s: Unable to get argument data"), "createSingleWideString");
801 printError(&sciErr, 0);
802 return sciErr.iErr;
803 }
804
805 return 0;
806}
807/*--------------------------------------------------------------------------*/
808void freeAllocatedSingleString(char* _pstData)
809{
810 FREE(_pstData);
811}
812/*--------------------------------------------------------------------------*/
813void freeAllocatedSingleWideString(wchar_t* _pwstData)
814{
815 FREE(_pwstData);
816}
817/*--------------------------------------------------------------------------*/
818void freeAllocatedMatrixOfString(int _iRows, int _iCols, char** _pstData)
819{
820 for(int i = 0 ; i < _iRows * _iCols ; i++)
821 {
822 FREE(_pstData[i]);
823 }
824 FREE(_pstData);
825}
826/*--------------------------------------------------------------------------*/
827void freeAllocatedMatrixOfWideString(int _iRows, int _iCols, wchar_t** _pwstData)
828{
829 for(int i = 0 ; i < _iRows * _iCols ; i++)
830 {
831 FREE(_pwstData[i]);
832 }
833 FREE(_pwstData);
834}
835/*--------------------------------------------------------------------------*/