1 /*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2009 - DIGITEO - Antoine ELIAS
4 *
5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
6 *
7 * This file is hereby licensed under the terms of the GNU GPL v2.0,
8 * pursuant to article 5.3.4 of the CeCILL v.2.1.
9 * This file was originally licensed under the terms of the CeCILL v2.1,
10 * and continues to be available under such terms.
11 * For more information, see the COPYING file which you should have received
12 * along with this program.
13 *
14 * Please note that piece of code will be rewrited for the Scilab 6 family
15 * However, the API (profile of the functions in the header files) will be
16 * still available and supported in Scilab 6.
17 */
18
19 #include "gatewaystruct.hxx"
20 #include "int.hxx"
21 #include "context.hxx"
22
23 extern "C"
24 {
25 #include <string.h>
26 #include <stdlib.h>
27 #include "localization.h"
28 #include "api_scilab.h"
29 #include "api_internal_int.h"
30 #include "api_internal_common.h"
31 }
32
33 static int getCommonScalarInteger(void* _pvCtx, int* _piAddress, int _iPrec, void** _pvData);
34 static int getCommonNamedScalarInteger(void* _pvCtx, const char* _pstName, int _iPrec, void** _pvData);
35
36
getMatrixOfIntegerPrecision(void * _pvCtx,int * _piAddress,int * _piPrecision)37 SciErr getMatrixOfIntegerPrecision(void* _pvCtx, int* _piAddress, int* _piPrecision)
38 {
39 SciErr sciErr = sciErrInit();
40 if (_piAddress == NULL)
41 {
42 addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getMatrixOfIntegerPrecision");
43 return sciErr;
44 }
45
46 if (!((types::InternalType*)_piAddress)->isInt())
47 {
48 addErrorMessage(&sciErr, API_ERROR_INVALID_TYPE, _("%s: Invalid argument type, %s expected"), "getMatrixOfIntegerPrecision", _("int matrix"));
49 return sciErr;
50 }
51
52 switch (((types::InternalType*)_piAddress)->getType())
53 {
54 case types::InternalType::ScilabInt8 :
55 *_piPrecision = SCI_INT8;
56 break;
57 case types::InternalType::ScilabUInt8 :
58 *_piPrecision = SCI_UINT8;
59 break;
60 case types::InternalType::ScilabInt16 :
61 *_piPrecision = SCI_INT16;
62 break;
63 case types::InternalType::ScilabUInt16 :
64 *_piPrecision = SCI_UINT16;
65 break;
66 case types::InternalType::ScilabInt32 :
67 *_piPrecision = SCI_INT32;
68 break;
69 case types::InternalType::ScilabUInt32 :
70 *_piPrecision = SCI_UINT32;
71 break;
72 case types::InternalType::ScilabInt64 :
73 *_piPrecision = SCI_INT64;
74 break;
75 case types::InternalType::ScilabUInt64 :
76 *_piPrecision = SCI_UINT64;
77 break;
78 default:
79 return sciErr;
80 }
81 return sciErr;
82 }
83
getMatrixOfUnsignedInteger8(void * _pvCtx,int * _piAddress,int * _piRows,int * _piCols,unsigned char ** _pucData8)84 SciErr getMatrixOfUnsignedInteger8(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, unsigned char** _pucData8)
85 {
86 return getCommonMatrixOfInteger(_pvCtx, _piAddress, SCI_UINT8, _piRows, _piCols, (void**)_pucData8);
87 }
88
getMatrixOfUnsignedInteger16(void * _pvCtx,int * _piAddress,int * _piRows,int * _piCols,unsigned short ** _pusData16)89 SciErr getMatrixOfUnsignedInteger16(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, unsigned short** _pusData16)
90 {
91 return getCommonMatrixOfInteger(_pvCtx, _piAddress, SCI_UINT16, _piRows, _piCols, (void**)_pusData16);
92 }
93
getMatrixOfUnsignedInteger32(void * _pvCtx,int * _piAddress,int * _piRows,int * _piCols,unsigned int ** _puiData32)94 SciErr getMatrixOfUnsignedInteger32(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, unsigned int** _puiData32)
95 {
96 return getCommonMatrixOfInteger(_pvCtx, _piAddress, SCI_UINT32, _piRows, _piCols, (void**)_puiData32);
97 }
98
99 #ifdef __SCILAB_INT64__
getMatrixOfUnsignedInteger64(void * _pvCtx,int * _piAddress,int * _piRows,int * _piCols,unsigned long long ** _pullData64)100 SciErr getMatrixOfUnsignedInteger64(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, unsigned long long** _pullData64)
101 {
102 return getCommonMatrixOfInteger(_pvCtx, _piAddress, SCI_UINT64, _piRows, _piCols, (void**)_pullData64);
103 }
104 #endif
105
getMatrixOfInteger8(void * _pvCtx,int * _piAddress,int * _piRows,int * _piCols,char ** _pcData8)106 SciErr getMatrixOfInteger8(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, char** _pcData8)
107 {
108 return getCommonMatrixOfInteger(_pvCtx, _piAddress, SCI_INT8, _piRows, _piCols, (void**)_pcData8);
109 }
110
getMatrixOfInteger16(void * _pvCtx,int * _piAddress,int * _piRows,int * _piCols,short ** _psData16)111 SciErr getMatrixOfInteger16(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, short** _psData16)
112 {
113 return getCommonMatrixOfInteger(_pvCtx, _piAddress, SCI_INT16, _piRows, _piCols, (void**)_psData16);
114 }
115
getMatrixOfInteger32(void * _pvCtx,int * _piAddress,int * _piRows,int * _piCols,int ** _piData32)116 SciErr getMatrixOfInteger32(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, int** _piData32)
117 {
118 return getCommonMatrixOfInteger(_pvCtx, _piAddress, SCI_INT32, _piRows, _piCols, (void**)_piData32);
119 }
120
121 #ifdef __SCILAB_INT64__
getMatrixOfInteger64(void * _pvCtx,int * _piAddress,int * _piRows,int * _piCols,long long ** _pllData64)122 SciErr getMatrixOfInteger64(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCols, long long** _pllData64)
123 {
124 return getCommonMatrixOfInteger(_pvCtx, _piAddress, SCI_INT64, _piRows, _piCols, (void**)_pllData64);
125 }
126 #endif
127
getCommonMatrixOfInteger(void * _pvCtx,int * _piAddress,int _iPrecision,int * _piRows,int * _piCols,void ** _piData)128 SciErr getCommonMatrixOfInteger(void* _pvCtx, int* _piAddress, int _iPrecision, int* _piRows, int* _piCols, void** _piData)
129 {
130 SciErr sciErr = sciErrInit();
131 int iPrec = 0;
132
133 if (_piAddress == NULL)
134 {
135 addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getMatrixOfInteger");
136 return sciErr;
137 }
138
139 sciErr = getMatrixOfIntegerPrecision(_pvCtx, _piAddress, &iPrec);
140 if (sciErr.iErr)
141 {
142 addErrorMessage(&sciErr, API_ERROR_GET_INT, _("%s: Unable to get argument #%d"), "getMatrixOfInteger", getRhsFromAddress(_pvCtx, _piAddress));
143 return sciErr;
144 }
145
146 if (iPrec != _iPrecision)
147 {
148 addErrorMessage(&sciErr, API_ERROR_GET_INT, _("%s: Unable to get argument #%d"), "getMatrixOfInteger", getRhsFromAddress(_pvCtx, _piAddress));
149 return sciErr;
150 }
151
152 sciErr = getVarDimension(_pvCtx, _piAddress, _piRows, _piCols);
153 if (sciErr.iErr)
154 {
155 addErrorMessage(&sciErr, API_ERROR_GET_INT, _("%s: Unable to get argument #%d"), "getMatrixOfInteger", getRhsFromAddress(_pvCtx, _piAddress));
156 return sciErr;
157 }
158
159 switch (((types::InternalType*)_piAddress)->getType())
160 {
161 case types::InternalType::ScilabInt8 :
162 *_piData = (void*)((types::InternalType*)_piAddress)->getAs<types::Int8>()->get();
163 break;
164 case types::InternalType::ScilabUInt8 :
165 *_piData = (void*)((types::InternalType*)_piAddress)->getAs<types::UInt8>()->get();
166 break;
167 case types::InternalType::ScilabInt16 :
168 *_piData = (void*)((types::InternalType*)_piAddress)->getAs<types::Int16>()->get();
169 break;
170 case types::InternalType::ScilabUInt16 :
171 *_piData = (void*)((types::InternalType*)_piAddress)->getAs<types::UInt16>()->get();
172 break;
173 case types::InternalType::ScilabInt32 :
174 *_piData = (void*)((types::InternalType*)_piAddress)->getAs<types::Int32>()->get();
175 break;
176 case types::InternalType::ScilabUInt32 :
177 *_piData = (void*)((types::InternalType*)_piAddress)->getAs<types::UInt32>()->get();
178 break;
179 case types::InternalType::ScilabInt64 :
180 *_piData = (void*)((types::InternalType*)_piAddress)->getAs<types::Int64>()->get();
181 break;
182 case types::InternalType::ScilabUInt64 :
183 *_piData = (void*)((types::InternalType*)_piAddress)->getAs<types::UInt64>()->get();
184 break;
185 default:
186 return sciErr;
187 }
188 if (*_piData == NULL)
189 {
190 addErrorMessage(&sciErr, API_ERROR_GET_INT, _("%s: Unable to get argument #%d"), "getMatrixOfInteger", getRhsFromAddress(_pvCtx, _piAddress));
191 return sciErr;
192 }
193
194 return sciErr;
195 }
196
createMatrixOfUnsignedInteger8(void * _pvCtx,int _iVar,int _iRows,int _iCols,const unsigned char * _pucData8)197 SciErr createMatrixOfUnsignedInteger8(void* _pvCtx, int _iVar, int _iRows, int _iCols, const unsigned char* _pucData8)
198 {
199 unsigned char *pucData8 = NULL;
200 int iSize = _iRows * _iCols;
201
202 if (_iRows == 0 && _iCols == 0)
203 {
204 double dblReal = 0;
205 SciErr sciErr = createMatrixOfDouble(_pvCtx, _iVar, 0, 0, &dblReal);
206 if (sciErr.iErr)
207 {
208 addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Unable to create variable in Scilab memory"), "createEmptyMatrix");
209 }
210 return sciErr;
211 }
212
213 SciErr sciErr = allocMatrixOfUnsignedInteger8(_pvCtx, _iVar, _iRows, _iCols, &pucData8);
214 if (sciErr.iErr)
215 {
216 addErrorMessage(&sciErr, API_ERROR_CREATE_INT, _("%s: Unable to create variable in Scilab memory"), "createMatrixOfUnsignedInteger8");
217 return sciErr;
218 }
219
220 memcpy(pucData8, _pucData8, sizeof(unsigned char) * iSize);
221 return sciErr;
222 }
223
createMatrixOfUnsignedInteger16(void * _pvCtx,int _iVar,int _iRows,int _iCols,const unsigned short * _pusData16)224 SciErr createMatrixOfUnsignedInteger16(void* _pvCtx, int _iVar, int _iRows, int _iCols, const unsigned short* _pusData16)
225 {
226 unsigned short *psData16 = NULL;
227 int iSize = _iRows * _iCols;
228
229 if (_iRows == 0 && _iCols == 0)
230 {
231 double dblReal = 0;
232 SciErr sciErr = createMatrixOfDouble(_pvCtx, _iVar, 0, 0, &dblReal);
233 if (sciErr.iErr)
234 {
235 addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Unable to create variable in Scilab memory"), "createEmptyMatrix");
236 }
237 return sciErr;
238 }
239
240 SciErr sciErr = allocMatrixOfUnsignedInteger16(_pvCtx, _iVar, _iRows, _iCols, &psData16);
241 if (sciErr.iErr)
242 {
243 addErrorMessage(&sciErr, API_ERROR_CREATE_INT, _("%s: Unable to create variable in Scilab memory"), "createMatrixOfUnsignedInteger16");
244 return sciErr;
245 }
246
247 memcpy(psData16, _pusData16, sizeof(unsigned short) * iSize);
248 return sciErr;
249 }
250
createMatrixOfUnsignedInteger32(void * _pvCtx,int _iVar,int _iRows,int _iCols,const unsigned int * _puiData32)251 SciErr createMatrixOfUnsignedInteger32(void* _pvCtx, int _iVar, int _iRows, int _iCols, const unsigned int* _puiData32)
252 {
253 unsigned int *piData32 = NULL;
254 int iSize = _iRows * _iCols;
255
256 if (_iRows == 0 && _iCols == 0)
257 {
258 double dblReal = 0;
259 SciErr sciErr = createMatrixOfDouble(_pvCtx, _iVar, 0, 0, &dblReal);
260 if (sciErr.iErr)
261 {
262 addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Unable to create variable in Scilab memory"), "createEmptyMatrix");
263 }
264 return sciErr;
265 }
266
267 SciErr sciErr = allocMatrixOfUnsignedInteger32(_pvCtx, _iVar, _iRows, _iCols, &piData32);
268 if (sciErr.iErr)
269 {
270 addErrorMessage(&sciErr, API_ERROR_CREATE_INT, _("%s: Unable to create variable in Scilab memory"), "createMatrixOfUnsignedInteger32");
271 return sciErr;
272 }
273
274 memcpy(piData32, _puiData32, sizeof(unsigned int) * iSize);
275 return sciErr;
276 }
277
278 #ifdef __SCILAB_INT64__
createMatrixOfUnsignedInteger64(void * _pvCtx,int _iVar,int _iRows,int _iCols,const unsigned long long * _pullData64)279 SciErr createMatrixOfUnsignedInteger64(void* _pvCtx, int _iVar, int _iRows, int _iCols, const unsigned long long* _pullData64)
280 {
281 SciErr sciErr = sciErrInit();
282 unsigned long long *pullData64 = NULL;
283 int iSize = _iRows * _iCols;
284
285 sciErr = allocMatrixOfUnsignedInteger64(_pvCtx, _iVar, _iRows, _iCols, &pullData64);
286 if (sciErr.iErr)
287 {
288 addErrorMessage(&sciErr, API_ERROR_CREATE_INT, _("%s: Unable to create variable in Scilab memory"), "createMatrixOfUnsignedInteger64");
289 return sciErr;
290 }
291
292 memcpy(pullData64, _pullData64, sizeof(unsigned long long) * iSize);
293 return sciErr;
294 }
295 #endif
296
createMatrixOfInteger8(void * _pvCtx,int _iVar,int _iRows,int _iCols,const char * _pcData8)297 SciErr createMatrixOfInteger8(void* _pvCtx, int _iVar, int _iRows, int _iCols, const char* _pcData8)
298 {
299 char *pcData8 = NULL;
300 int iSize = _iRows * _iCols;
301
302 if (_iRows == 0 && _iCols == 0)
303 {
304 double dblReal = 0;
305 SciErr sciErr = createMatrixOfDouble(_pvCtx, _iVar, 0, 0, &dblReal);
306 if (sciErr.iErr)
307 {
308 addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Unable to create variable in Scilab memory"), "createEmptyMatrix");
309 }
310 return sciErr;
311 }
312
313 SciErr sciErr = allocMatrixOfInteger8(_pvCtx, _iVar, _iRows, _iCols, &pcData8);
314 if (sciErr.iErr)
315 {
316 addErrorMessage(&sciErr, API_ERROR_CREATE_INT, _("%s: Unable to create variable in Scilab memory"), "createMatrixOfInteger8");
317 return sciErr;
318 }
319
320 memcpy(pcData8, _pcData8, sizeof(char) * iSize);
321 return sciErr;
322 }
323
createMatrixOfInteger16(void * _pvCtx,int _iVar,int _iRows,int _iCols,const short * _psData16)324 SciErr createMatrixOfInteger16(void* _pvCtx, int _iVar, int _iRows, int _iCols, const short* _psData16)
325 {
326 short *psData16 = NULL;
327 int iSize = _iRows * _iCols;
328
329 if (_iRows == 0 && _iCols == 0)
330 {
331 double dblReal = 0;
332 SciErr sciErr = createMatrixOfDouble(_pvCtx, _iVar, 0, 0, &dblReal);
333 if (sciErr.iErr)
334 {
335 addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Unable to create variable in Scilab memory"), "createEmptyMatrix");
336 }
337 return sciErr;
338 }
339
340 SciErr sciErr = allocMatrixOfInteger16(_pvCtx, _iVar, _iRows, _iCols, &psData16);
341 if (sciErr.iErr)
342 {
343 addErrorMessage(&sciErr, API_ERROR_CREATE_INT, _("%s: Unable to create variable in Scilab memory"), "createMatrixOfInteger16");
344 return sciErr;
345 }
346
347 memcpy(psData16, _psData16, sizeof(short) * iSize);
348 return sciErr;
349 }
350
createMatrixOfInteger32(void * _pvCtx,int _iVar,int _iRows,int _iCols,const int * _piData32)351 SciErr createMatrixOfInteger32(void* _pvCtx, int _iVar, int _iRows, int _iCols, const int* _piData32)
352 {
353 int *piData32 = NULL;
354 int iSize = _iRows * _iCols;
355
356 if (_iRows == 0 && _iCols == 0)
357 {
358 double dblReal = 0;
359 SciErr sciErr = createMatrixOfDouble(_pvCtx, _iVar, 0, 0, &dblReal);
360 if (sciErr.iErr)
361 {
362 addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Unable to create variable in Scilab memory"), "createEmptyMatrix");
363 }
364 return sciErr;
365 }
366
367 SciErr sciErr = allocMatrixOfInteger32(_pvCtx, _iVar, _iRows, _iCols, &piData32);
368 if (sciErr.iErr)
369 {
370 addErrorMessage(&sciErr, API_ERROR_CREATE_INT, _("%s: Unable to create variable in Scilab memory"), "createMatrixOfInteger32");
371 return sciErr;
372 }
373
374 memcpy(piData32, _piData32, sizeof(int) * iSize);
375 return sciErr;
376 }
377
378 #ifdef __SCILAB_INT64__
createMatrixOfInteger64(void * _pvCtx,int _iVar,int _iRows,int _iCols,const long long * _pllData64)379 SciErr createMatrixOfInteger64(void* _pvCtx, int _iVar, int _iRows, int _iCols, const long long* _pllData64)
380 {
381 SciErr sciErr = sciErrInit();
382 long long *pllData64 = NULL;
383 int iSize = _iRows * _iCols;
384
385 if (_iRows == 0 && _iCols == 0)
386 {
387 double dblReal = 0;
388 sciErr = createMatrixOfDouble(_pvCtx, _iVar, 0, 0, &dblReal);
389 if (sciErr.iErr)
390 {
391 addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Unable to create variable in Scilab memory"), "createEmptyMatrix");
392 }
393 return sciErr;
394 }
395
396 sciErr = allocMatrixOfInteger64(_pvCtx, _iVar, _iRows, _iCols, &pllData64);
397 if (sciErr.iErr)
398 {
399 addErrorMessage(&sciErr, API_ERROR_CREATE_INT, _("%s: Unable to create variable in Scilab memory"), "createMatrixOfInteger64");
400 return sciErr;
401 }
402
403 memcpy(pllData64, _pllData64, sizeof(long long) * iSize);
404 return sciErr;
405 }
406 #endif
407
allocMatrixOfInteger8(void * _pvCtx,int _iVar,int _iRows,int _iCols,char ** _pcData8)408 SciErr allocMatrixOfInteger8(void* _pvCtx, int _iVar, int _iRows, int _iCols, char** _pcData8)
409 {
410 SciErr sciErr = sciErrInit();
411 int *piAddr = NULL;
412 char *pcData8 = NULL;
413
414 if (_iRows == 0 && _iCols == 0)
415 {
416 double dblReal = 0;
417 sciErr = createMatrixOfDouble(_pvCtx, _iVar, 0, 0, &dblReal);
418 if (sciErr.iErr)
419 {
420 addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Unable to create variable in Scilab memory"), "createEmptyMatrix");
421 }
422 return sciErr;
423 }
424
425 getNewVarAddressFromPosition(_pvCtx, _iVar/*iNewPos*/, &piAddr);
426
427 sciErr = allocCommonMatrixOfInteger(_pvCtx, _iVar, piAddr, SCI_INT8, _iRows, _iCols, (void**)&pcData8);
428 if (sciErr.iErr)
429 {
430 addErrorMessage(&sciErr, API_ERROR_CREATE_INT, _("%s: Unable to create variable in Scilab memory"), "allocMatrixOfInteger8");
431 return sciErr;
432 }
433
434 *_pcData8 = pcData8;
435 return sciErr;
436 }
437
allocMatrixOfInteger16(void * _pvCtx,int _iVar,int _iRows,int _iCols,short ** _psData16)438 SciErr allocMatrixOfInteger16(void* _pvCtx, int _iVar, int _iRows, int _iCols, short** _psData16)
439 {
440 SciErr sciErr = sciErrInit();
441 int *piAddr = NULL;
442 short *psData16 = NULL;
443
444 if (_iRows == 0 && _iCols == 0)
445 {
446 double dblReal = 0;
447 sciErr = createMatrixOfDouble(_pvCtx, _iVar, 0, 0, &dblReal);
448 if (sciErr.iErr)
449 {
450 addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Unable to create variable in Scilab memory"), "createEmptyMatrix");
451 }
452 return sciErr;
453 }
454
455 getNewVarAddressFromPosition(_pvCtx, _iVar/*iNewPos*/, &piAddr);
456
457 sciErr = allocCommonMatrixOfInteger(_pvCtx, _iVar, piAddr, SCI_INT16, _iRows, _iCols, (void**)&psData16);
458 if (sciErr.iErr)
459 {
460 addErrorMessage(&sciErr, API_ERROR_CREATE_INT, _("%s: Unable to create variable in Scilab memory"), "allocMatrixOfInteger16");
461 return sciErr;
462 }
463
464 *_psData16 = psData16;
465 return sciErr;
466 }
467
allocMatrixOfInteger32(void * _pvCtx,int _iVar,int _iRows,int _iCols,int ** _piData32)468 SciErr allocMatrixOfInteger32(void* _pvCtx, int _iVar, int _iRows, int _iCols, int** _piData32)
469 {
470 SciErr sciErr = sciErrInit();
471 int *piAddr = NULL;
472 int *piData32 = NULL;
473 // int iNewPos = api_Top((int*)_pvCtx) - *getInputArgument(_pvCtx) + _iVar;
474
475 if (_iRows == 0 && _iCols == 0)
476 {
477 double dblReal = 0;
478 sciErr = createMatrixOfDouble(_pvCtx, _iVar, 0, 0, &dblReal);
479 if (sciErr.iErr)
480 {
481 addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Unable to create variable in Scilab memory"), "createEmptyMatrix");
482 }
483 return sciErr;
484 }
485
486 getNewVarAddressFromPosition(_pvCtx, _iVar/*iNewPos*/, &piAddr);
487
488 sciErr = allocCommonMatrixOfInteger(_pvCtx, _iVar, piAddr, SCI_INT32, _iRows, _iCols, (void**)&piData32);
489 if (sciErr.iErr)
490 {
491 addErrorMessage(&sciErr, API_ERROR_CREATE_INT, _("%s: Unable to create variable in Scilab memory"), "allocMatrixOfInteger32");
492 return sciErr;
493 }
494
495 *_piData32 = piData32;
496 return sciErr;
497 }
498
499 #ifdef __SCILAB_INT64__
allocMatrixOfInteger64(void * _pvCtx,int _iVar,int _iRows,int _iCols,long long ** _pllData64)500 SciErr allocMatrixOfInteger64(void* _pvCtx, int _iVar, int _iRows, int _iCols, long long** _pllData64)
501 {
502 SciErr sciErr = sciErrInit();
503 int *piAddr = NULL;
504 long long *pllData64 = NULL;
505 // int iNewPos = api_Top((int*)_pvCtx) - *getInputArgument(_pvCtx) + _iVar;
506
507 if (_iRows == 0 && _iCols == 0)
508 {
509 double dblReal = 0;
510 sciErr = createMatrixOfDouble(_pvCtx, _iVar, 0, 0, &dblReal);
511 if (sciErr.iErr)
512 {
513 addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Unable to create variable in Scilab memory"), "createEmptyMatrix");
514 }
515 return sciErr;
516 }
517
518 getNewVarAddressFromPosition(_pvCtx, _iVar/*iNewPos*/, &piAddr);
519
520 sciErr = allocCommonMatrixOfInteger(_pvCtx, _iVar, piAddr, SCI_INT64, _iRows, _iCols, (void**)&pllData64);
521 if (sciErr.iErr)
522 {
523 addErrorMessage(&sciErr, API_ERROR_CREATE_INT, _("%s: Unable to create variable in Scilab memory"), "allocMatrixOfInteger64");
524 return sciErr;
525 }
526
527 *_pllData64 = pllData64;
528 return sciErr;
529 }
530 #endif
531
allocMatrixOfUnsignedInteger8(void * _pvCtx,int _iVar,int _iRows,int _iCols,unsigned char ** _pucData8)532 SciErr allocMatrixOfUnsignedInteger8(void* _pvCtx, int _iVar, int _iRows, int _iCols, unsigned char** _pucData8)
533 {
534 SciErr sciErr = sciErrInit();
535 int *piAddr = NULL;
536 unsigned char *pucData8 = NULL;
537
538 if (_iRows == 0 && _iCols == 0)
539 {
540 double dblReal = 0;
541 sciErr = createMatrixOfDouble(_pvCtx, _iVar, 0, 0, &dblReal);
542 if (sciErr.iErr)
543 {
544 addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Unable to create variable in Scilab memory"), "createEmptyMatrix");
545 }
546 return sciErr;
547 }
548
549 getNewVarAddressFromPosition(_pvCtx, _iVar/*iNewPos*/, &piAddr);
550
551 sciErr = allocCommonMatrixOfInteger(_pvCtx, _iVar, piAddr, SCI_UINT8, _iRows, _iCols, (void**)&pucData8);
552 if (sciErr.iErr)
553 {
554 addErrorMessage(&sciErr, API_ERROR_CREATE_INT, _("%s: Unable to create variable in Scilab memory"), "allocMatrixOfUnsignedInteger8");
555 return sciErr;
556 }
557
558 *_pucData8 = pucData8;
559 return sciErr;
560 }
561
allocMatrixOfUnsignedInteger16(void * _pvCtx,int _iVar,int _iRows,int _iCols,unsigned short ** _pusData16)562 SciErr allocMatrixOfUnsignedInteger16(void* _pvCtx, int _iVar, int _iRows, int _iCols, unsigned short** _pusData16)
563 {
564 SciErr sciErr = sciErrInit();
565 int *piAddr = NULL;
566 unsigned short *pusData16 = NULL;
567
568 if (_iRows == 0 && _iCols == 0)
569 {
570 double dblReal = 0;
571 sciErr = createMatrixOfDouble(_pvCtx, _iVar, 0, 0, &dblReal);
572 if (sciErr.iErr)
573 {
574 addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Unable to create variable in Scilab memory"), "createEmptyMatrix");
575 }
576 return sciErr;
577 }
578
579 getNewVarAddressFromPosition(_pvCtx, _iVar/*iNewPos*/, &piAddr);
580
581 sciErr = allocCommonMatrixOfInteger(_pvCtx, _iVar, piAddr, SCI_UINT16, _iRows, _iCols, (void**)&pusData16);
582 if (sciErr.iErr)
583 {
584 addErrorMessage(&sciErr, API_ERROR_CREATE_INT, _("%s: Unable to create variable in Scilab memory"), "allocMatrixOfUnsignedInteger16");
585 return sciErr;
586 }
587
588 *_pusData16 = pusData16;
589 return sciErr;
590 }
591
allocMatrixOfUnsignedInteger32(void * _pvCtx,int _iVar,int _iRows,int _iCols,unsigned int ** _puiData32)592 SciErr allocMatrixOfUnsignedInteger32(void* _pvCtx, int _iVar, int _iRows, int _iCols, unsigned int** _puiData32)
593 {
594 SciErr sciErr = sciErrInit();
595 int *piAddr = NULL;
596 unsigned int *puiData32 = NULL;
597
598 if (_iRows == 0 && _iCols == 0)
599 {
600 double dblReal = 0;
601 sciErr = createMatrixOfDouble(_pvCtx, _iVar, 0, 0, &dblReal);
602 if (sciErr.iErr)
603 {
604 addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Unable to create variable in Scilab memory"), "createEmptyMatrix");
605 }
606 return sciErr;
607 }
608
609 getNewVarAddressFromPosition(_pvCtx, _iVar/*iNewPos*/, &piAddr);
610
611 sciErr = allocCommonMatrixOfInteger(_pvCtx, _iVar, piAddr, SCI_UINT32, _iRows, _iCols, (void**)&puiData32);
612 if (sciErr.iErr)
613 {
614 addErrorMessage(&sciErr, API_ERROR_CREATE_INT, _("%s: Unable to create variable in Scilab memory"), "allocMatrixOfUnsignedInteger32");
615 return sciErr;
616 }
617
618 *_puiData32 = puiData32;
619 return sciErr;
620 }
621
622 #ifdef __SCILAB_INT64__
allocMatrixOfUnsignedInteger64(void * _pvCtx,int _iVar,int _iRows,int _iCols,unsigned long long ** _pullData64)623 SciErr allocMatrixOfUnsignedInteger64(void* _pvCtx, int _iVar, int _iRows, int _iCols, unsigned long long** _pullData64)
624 {
625 SciErr sciErr = sciErrInit();
626 int *piAddr = NULL;
627 unsigned long long *pullData64 = NULL;
628
629 if (_iRows == 0 && _iCols == 0)
630 {
631 double dblReal = 0;
632 sciErr = createMatrixOfDouble(_pvCtx, _iVar, 0, 0, &dblReal);
633 if (sciErr.iErr)
634 {
635 addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Unable to create variable in Scilab memory"), "createEmptyMatrix");
636 }
637 return sciErr;
638 }
639
640 getNewVarAddressFromPosition(_pvCtx, _iVar/*iNewPos*/, &piAddr);
641
642 sciErr = allocCommonMatrixOfInteger(_pvCtx, _iVar, piAddr, SCI_UINT64, _iRows, _iCols, (void**)&pullData64);
643 if (sciErr.iErr)
644 {
645 addErrorMessage(&sciErr, API_ERROR_CREATE_INT, _("%s: Unable to create variable in Scilab memory"), "allocMatrixOfUnsignedInteger64");
646 return sciErr;
647 }
648
649 *_pullData64 = pullData64;
650 return sciErr;
651 }
652 #endif
653
allocCommonMatrixOfInteger(void * _pvCtx,int _iVar,int * _piAddress,int _iPrecision,int _iRows,int _iCols,void ** _pvData)654 SciErr allocCommonMatrixOfInteger(void* _pvCtx, int _iVar, int *_piAddress, int _iPrecision, int _iRows, int _iCols, void** _pvData)
655 {
656 SciErr sciErr = sciErrInit();
657
658 //return empty matrix
659 if (_iRows == 0 && _iCols == 0)
660 {
661 double dblReal = 0;
662 sciErr = createMatrixOfDouble(_pvCtx, _iVar, 0, 0, &dblReal);
663 if (sciErr.iErr)
664 {
665 addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Unable to create variable in Scilab memory"), "createEmptyMatrix");
666 }
667 return sciErr;
668 }
669
670 if (_pvCtx == NULL)
671 {
672 addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "allocMatrixOfInteger");
673 return sciErr;
674 }
675
676 types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
677 types::InternalType** out = pStr->m_pOut;
678
679 types::InternalType *pIT = nullptr;
680 switch (_iPrecision)
681 {
682 case SCI_INT8 :
683 pIT = new types::Int8(_iRows, _iCols, (char**)_pvData);
684 break;
685 case SCI_UINT8 :
686 pIT = new types::UInt8(_iRows, _iCols, (unsigned char**)_pvData);
687 break;
688 case SCI_INT16 :
689 pIT = new types::Int16(_iRows, _iCols, (short**)_pvData);
690 break;
691 case SCI_UINT16 :
692 pIT = new types::UInt16(_iRows, _iCols, (unsigned short**)_pvData);
693 break;
694 case SCI_INT32 :
695 pIT = new types::Int32(_iRows, _iCols, (int**)_pvData);
696 break;
697 case SCI_UINT32 :
698 pIT = new types::UInt32(_iRows, _iCols, (unsigned int**)_pvData);
699 break;
700 case SCI_INT64 :
701 pIT = new types::Int64(_iRows, _iCols, (long long**)_pvData);
702 break;
703 case SCI_UINT64 :
704 pIT = new types::UInt64(_iRows, _iCols, (unsigned long long**)_pvData);
705 break;
706 }
707
708 if (pIT == NULL)
709 {
710 addErrorMessage(&sciErr, API_ERROR_NO_MORE_MEMORY, _("%s: No more memory to allocated variable"), "allocMatrixOfInteger");
711 return sciErr;
712 }
713
714 int rhs = _iVar - *getNbInputArgument(_pvCtx);
715 out[rhs - 1] = pIT;
716 return sciErr;
717 }
718
createNamedMatrixOfUnsignedInteger8(void * _pvCtx,const char * _pstName,int _iRows,int _iCols,const unsigned char * _pucData8)719 SciErr createNamedMatrixOfUnsignedInteger8(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, const unsigned char* _pucData8)
720 {
721 return createCommonNamedMatrixOfInteger(_pvCtx, _pstName, SCI_UINT8, _iRows, _iCols, _pucData8);
722 }
723
createNamedMatrixOfUnsignedInteger16(void * _pvCtx,const char * _pstName,int _iRows,int _iCols,const unsigned short * _pusData16)724 SciErr createNamedMatrixOfUnsignedInteger16(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, const unsigned short* _pusData16)
725 {
726 return createCommonNamedMatrixOfInteger(_pvCtx, _pstName, SCI_UINT16, _iRows, _iCols, _pusData16);
727 }
728
createNamedMatrixOfUnsignedInteger32(void * _pvCtx,const char * _pstName,int _iRows,int _iCols,const unsigned int * _puiData32)729 SciErr createNamedMatrixOfUnsignedInteger32(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, const unsigned int* _puiData32)
730 {
731 return createCommonNamedMatrixOfInteger(_pvCtx, _pstName, SCI_UINT32, _iRows, _iCols, _puiData32);
732 }
733
734 #ifdef __SCILAB_INT64__
createNamedMatrixOfUnsignedInteger64(void * _pvCtx,const char * _pstName,int _iRows,int _iCols,const unsigned long long * _pullData64)735 SciErr createNamedMatrixOfUnsignedInteger64(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, const unsigned long long* _pullData64)
736 {
737 return createCommonNamedMatrixOfInteger(_pvCtx, _pstName, SCI_UINT64, _iRows, _iCols, _pullData64);
738 }
739 #endif
740
createNamedMatrixOfInteger8(void * _pvCtx,const char * _pstName,int _iRows,int _iCols,const char * _pcData8)741 SciErr createNamedMatrixOfInteger8(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, const char* _pcData8)
742 {
743 return createCommonNamedMatrixOfInteger(_pvCtx, _pstName, SCI_INT8, _iRows, _iCols, _pcData8);
744 }
745
createNamedMatrixOfInteger16(void * _pvCtx,const char * _pstName,int _iRows,int _iCols,const short * _psData16)746 SciErr createNamedMatrixOfInteger16(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, const short* _psData16)
747 {
748 return createCommonNamedMatrixOfInteger(_pvCtx, _pstName, SCI_INT16, _iRows, _iCols, _psData16);
749 }
750
createNamedMatrixOfInteger32(void * _pvCtx,const char * _pstName,int _iRows,int _iCols,const int * _piData32)751 SciErr createNamedMatrixOfInteger32(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, const int* _piData32)
752 {
753 return createCommonNamedMatrixOfInteger(_pvCtx, _pstName, SCI_INT32, _iRows, _iCols, _piData32);
754 }
755
756 #ifdef __SCILAB_INT64__
createNamedMatrixOfInteger64(void * _pvCtx,const char * _pstName,int _iRows,int _iCols,const long long * _pllData64)757 SciErr createNamedMatrixOfInteger64(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, const long long* _pllData64)
758 {
759 return createCommonNamedMatrixOfInteger(_pvCtx, _pstName, SCI_INT64, _iRows, _iCols, _pllData64);
760 }
761 #endif
762
createCommonNamedMatrixOfInteger(void * _pvCtx,const char * _pstName,int _iPrecision,int _iRows,int _iCols,const void * _pvData)763 SciErr createCommonNamedMatrixOfInteger(void* _pvCtx, const char* _pstName, int _iPrecision, int _iRows, int _iCols, const void* _pvData)
764 {
765 SciErr sciErr = sciErrInit();
766
767 // check variable name
768 if (checkNamedVarFormat(_pvCtx, _pstName) == 0)
769 {
770 addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Invalid variable name: %s."), "createCommonNamedMatrixOfInteger", _pstName);
771 return sciErr;
772 }
773
774 //return empty matrix
775 if (_iRows == 0 && _iCols == 0)
776 {
777 if (createNamedEmptyMatrix(_pvCtx, _pstName))
778 {
779 addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_EMPTY_MATRIX, _("%s: Unable to create variable in Scilab memory"), "createNamedEmptyMatrix");
780 }
781
782 return sciErr;
783 }
784
785 types::InternalType *pIT = nullptr;
786 switch (_iPrecision)
787 {
788 case SCI_INT8 :
789 {
790 types::Int8 *pInt8 = new types::Int8(_iRows, _iCols);
791 pInt8->set((char*)_pvData);
792 pIT = pInt8;
793 break;
794 }
795 case SCI_UINT8:
796 {
797 types::UInt8 *pUInt8 = new types::UInt8(_iRows, _iCols);
798 pUInt8->set((unsigned char*)_pvData);
799 pIT = pUInt8;
800 break;
801 }
802 case SCI_INT16 :
803 {
804 types::Int16 *pInt16 = new types::Int16(_iRows, _iCols);
805 pInt16->set((short*)_pvData);
806 pIT = pInt16;
807 break;
808 }
809 case SCI_UINT16:
810 {
811 types::UInt16 *pUInt16 = new types::UInt16(_iRows, _iCols);
812 pUInt16->set((unsigned short*)_pvData);
813 pIT = pUInt16;
814 break;
815 }
816 case SCI_INT32:
817 {
818 types::Int32 *pInt32 = new types::Int32(_iRows, _iCols);
819 pInt32->set((int*)_pvData);
820 pIT = pInt32;
821 break;
822 }
823 case SCI_UINT32:
824 {
825 types::UInt32 *pUInt32 = new types::UInt32(_iRows, _iCols);
826 pUInt32->set((unsigned int*)_pvData);
827 pIT = pUInt32;
828 break;
829 }
830 case SCI_INT64:
831 {
832 types::Int64 *pInt64 = new types::Int64(_iRows, _iCols);
833 pInt64->set((long long*)_pvData);
834 pIT = pInt64;
835 break;
836 }
837 case SCI_UINT64:
838 {
839 types::UInt64 *pUInt64 = new types::UInt64(_iRows, _iCols);
840 pUInt64->set((unsigned long long*)_pvData);
841 pIT = pUInt64;
842 break;
843 }
844 }
845
846 if (pIT == NULL)
847 {
848 addErrorMessage(&sciErr, API_ERROR_NO_MORE_MEMORY, _("%s: No more memory to allocated variable"), "allocMatrixOfInteger");
849 return sciErr;
850 }
851
852 wchar_t* pwstName = to_wide_string(_pstName);
853 symbol::Context* ctx = symbol::Context::getInstance();
854 symbol::Symbol sym = symbol::Symbol(pwstName);
855 FREE(pwstName);
856 if (ctx->isprotected(sym) == false)
857 {
858 ctx->put(sym, pIT);
859 }
860 else
861 {
862 delete pIT;
863 addErrorMessage(&sciErr, API_ERROR_REDEFINE_PERMANENT_VAR, _("Redefining permanent variable.\n"));
864 }
865 return sciErr;
866 }
867
getNamedMatrixOfIntegerPrecision(void * _pvCtx,const char * _pstName,int * _piPrecision)868 SciErr getNamedMatrixOfIntegerPrecision(void* _pvCtx, const char* _pstName, int* _piPrecision)
869 {
870 int* piAddr = NULL;
871
872 SciErr sciErr = getVarAddressFromName(_pvCtx, _pstName, &piAddr);
873 if (sciErr.iErr)
874 {
875 addErrorMessage(&sciErr, API_ERROR_GET_NAMED_INT_PRECISION, _("%s: Unable to get precision of variable \"%s\""), "getNamedMatrixOfIntegerPrecision", _pstName);
876 return sciErr;
877 }
878
879 types::InternalType* pIT = (types::InternalType*)piAddr;
880
881 //check variable type
882 if (pIT->isInt() == false)
883 {
884 addErrorMessage(&sciErr, API_ERROR_INVALID_TYPE, _("%s: Invalid argument type, %s expected"), "getNamedMatrixOfIntegerPrecision", _("int matrix"));
885 return sciErr;
886 }
887
888 switch (pIT->getType())
889 {
890 case types::InternalType::ScilabInt8 :
891 *_piPrecision = sci_int8;
892 break;
893 case types::InternalType::ScilabUInt8 :
894 *_piPrecision = sci_uint8;
895 break;
896 case types::InternalType::ScilabInt16 :
897 *_piPrecision = sci_int16;
898 break;
899 case types::InternalType::ScilabUInt16 :
900 *_piPrecision = sci_uint16;
901 break;
902 case types::InternalType::ScilabInt32 :
903 *_piPrecision = sci_int32;
904 break;
905 case types::InternalType::ScilabUInt32 :
906 *_piPrecision = sci_uint32;
907 break;
908 case types::InternalType::ScilabInt64 :
909 *_piPrecision = sci_int64;
910 break;
911 case types::InternalType::ScilabUInt64 :
912 *_piPrecision = sci_uint64;
913 break;
914 default :
915 // That never occurs, the previous test prevents that.
916 *_piPrecision = -1;
917 break;
918 }
919
920 return sciErr;
921 }
922
readNamedMatrixOfUnsignedInteger8(void * _pvCtx,const char * _pstName,int * _piRows,int * _piCols,unsigned char * _pucData8)923 SciErr readNamedMatrixOfUnsignedInteger8(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, unsigned char* _pucData8)
924 {
925 return readCommonNamedMatrixOfInteger(_pvCtx, _pstName, SCI_UINT8, _piRows, _piCols, _pucData8);
926 }
927
readNamedMatrixOfUnsignedInteger16(void * _pvCtx,const char * _pstName,int * _piRows,int * _piCols,unsigned short * _pusData16)928 SciErr readNamedMatrixOfUnsignedInteger16(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, unsigned short* _pusData16)
929 {
930 return readCommonNamedMatrixOfInteger(_pvCtx, _pstName, SCI_UINT16, _piRows, _piCols, _pusData16);
931 }
932
readNamedMatrixOfUnsignedInteger32(void * _pvCtx,const char * _pstName,int * _piRows,int * _piCols,unsigned int * _puiData32)933 SciErr readNamedMatrixOfUnsignedInteger32(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, unsigned int* _puiData32)
934 {
935 return readCommonNamedMatrixOfInteger(_pvCtx, _pstName, SCI_UINT32, _piRows, _piCols, _puiData32);
936 }
937
938 #ifdef __SCILAB_INT64__
readNamedMatrixOfUnsignedInteger64(void * _pvCtx,const char * _pstName,int * _piRows,int * _piCols,unsigned long long * _pullData64)939 SciErr readNamedMatrixOfUnsignedInteger64(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, unsigned long long* _pullData64)
940 {
941 return readCommonNamedMatrixOfInteger(_pvCtx, _pstName, SCI_UINT64, _piRows, _piCols, _pullData64);
942 }
943 #endif
944
readNamedMatrixOfInteger8(void * _pvCtx,const char * _pstName,int * _piRows,int * _piCols,char * _pcData8)945 SciErr readNamedMatrixOfInteger8(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, char* _pcData8)
946 {
947 return readCommonNamedMatrixOfInteger(_pvCtx, _pstName, SCI_INT8, _piRows, _piCols, _pcData8);
948 }
949
readNamedMatrixOfInteger16(void * _pvCtx,const char * _pstName,int * _piRows,int * _piCols,short * _psData16)950 SciErr readNamedMatrixOfInteger16(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, short* _psData16)
951 {
952 return readCommonNamedMatrixOfInteger(_pvCtx, _pstName, SCI_INT16, _piRows, _piCols, _psData16);
953 }
954
readNamedMatrixOfInteger32(void * _pvCtx,const char * _pstName,int * _piRows,int * _piCols,int * _piData32)955 SciErr readNamedMatrixOfInteger32(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, int* _piData32)
956 {
957 return readCommonNamedMatrixOfInteger(_pvCtx, _pstName, SCI_INT32, _piRows, _piCols, _piData32);
958 }
959
960 #ifdef __SCILAB_INT64__
readNamedMatrixOfInteger64(void * _pvCtx,const char * _pstName,int * _piRows,int * _piCols,long long * _pllData64)961 SciErr readNamedMatrixOfInteger64(void* _pvCtx, const char* _pstName, int* _piRows, int* _piCols, long long* _pllData64)
962 {
963 return readCommonNamedMatrixOfInteger(_pvCtx, _pstName, SCI_INT64, _piRows, _piCols, _pllData64);
964 }
965 #endif
966
readCommonNamedMatrixOfInteger(void * _pvCtx,const char * _pstName,int _iPrecision,int * _piRows,int * _piCols,void * _pvData)967 SciErr readCommonNamedMatrixOfInteger(void* _pvCtx, const char* _pstName, int _iPrecision, int* _piRows, int* _piCols, void* _pvData)
968 {
969 int* piAddr = NULL;
970 int iSize = 0;
971 void* pvData = NULL;
972
973 SciErr sciErr = getVarAddressFromName(_pvCtx, _pstName, &piAddr);
974 if (sciErr.iErr)
975 {
976 addErrorMessage(&sciErr, API_ERROR_READ_NAMED_INT, _("%s: Unable to get variable \"%s\""), "readNamedMatrixOfInteger", _pstName);
977 return sciErr;
978 }
979
980 sciErr = getCommonMatrixOfInteger(_pvCtx, piAddr, _iPrecision, _piRows, _piCols, &pvData);
981 if (sciErr.iErr)
982 {
983 addErrorMessage(&sciErr, API_ERROR_READ_NAMED_INT, _("%s: Unable to get variable \"%s\""), "readNamedMatrixOfInteger", _pstName);
984 return sciErr;
985 }
986 iSize = *_piRows **_piCols;
987
988 if (pvData == NULL || _pvData == NULL)
989 {
990 return sciErr;
991 }
992
993 memcpy(_pvData, pvData, (_iPrecision % 10) * iSize);
994 return sciErr;
995 }
996
997 /* shortcut functions */
998
isIntegerType(void * _pvCtx,int * _piAddress)999 int isIntegerType(void* _pvCtx, int* _piAddress)
1000 {
1001 return checkVarType(_pvCtx, _piAddress, sci_ints);
1002 }
1003 /*--------------------------------------------------------------------------*/
isNamedIntegerType(void * _pvCtx,const char * _pstName)1004 int isNamedIntegerType(void* _pvCtx, const char* _pstName)
1005 {
1006 return checkNamedVarType(_pvCtx, _pstName, sci_ints);
1007 }
1008 /*--------------------------------------------------------------------------*/
getScalarInteger8(void * _pvCtx,int * _piAddress,char * _pcData)1009 int getScalarInteger8(void* _pvCtx, int* _piAddress, char* _pcData)
1010 {
1011 char* pcData = NULL;
1012
1013 int iRet = getCommonScalarInteger(_pvCtx, _piAddress, SCI_INT8, (void**)&pcData);
1014 if (iRet)
1015 {
1016 return iRet;
1017 }
1018
1019 *_pcData = pcData[0];
1020 return 0;
1021 }
1022 /*--------------------------------------------------------------------------*/
getScalarInteger16(void * _pvCtx,int * _piAddress,short * _psData)1023 int getScalarInteger16(void* _pvCtx, int* _piAddress, short* _psData)
1024 {
1025 short* psData = NULL;
1026
1027 int iRet = getCommonScalarInteger(_pvCtx, _piAddress, SCI_INT16, (void**)&psData);
1028 if (iRet)
1029 {
1030 return iRet;
1031 }
1032
1033 *_psData = psData[0];
1034 return 0;
1035 }
1036 /*--------------------------------------------------------------------------*/
getScalarInteger32(void * _pvCtx,int * _piAddress,int * _piData)1037 int getScalarInteger32(void* _pvCtx, int* _piAddress, int* _piData)
1038 {
1039 int* piData = NULL;
1040
1041 int iRet = getCommonScalarInteger(_pvCtx, _piAddress, SCI_INT32, (void**)&piData);
1042 if (iRet)
1043 {
1044 return iRet;
1045 }
1046
1047 *_piData = piData[0];
1048 return 0;
1049 }
1050 /*--------------------------------------------------------------------------*/
1051 #ifdef __SCILAB_INT64__
getScalarInteger64(void * _pvCtx,int * _piAddress,long long * _pllData)1052 int getScalarInteger64(void* _pvCtx, int* _piAddress, long long* _pllData)
1053 {
1054 long long* pllData = NULL;
1055
1056 int iRet = getCommonScalarInteger(_pvCtx, _piAddress, SCI_INT64, (void**)&pllData);
1057 if (iRet)
1058 {
1059 return iRet;
1060 }
1061
1062 *_pllData = pllData[0];
1063 return 0;
1064 }
1065 #endif
1066 /*--------------------------------------------------------------------------*/
getScalarUnsignedInteger8(void * _pvCtx,int * _piAddress,unsigned char * _pucData)1067 int getScalarUnsignedInteger8(void* _pvCtx, int* _piAddress, unsigned char* _pucData)
1068 {
1069 unsigned char* pucData = NULL;
1070
1071 int iRet = getCommonScalarInteger(_pvCtx, _piAddress, SCI_UINT8, (void**)&pucData);
1072 if (iRet)
1073 {
1074 return iRet;
1075 }
1076
1077 *_pucData = pucData[0];
1078 return 0;
1079 }
1080 /*--------------------------------------------------------------------------*/
getScalarUnsignedInteger16(void * _pvCtx,int * _piAddress,unsigned short * _pusData)1081 int getScalarUnsignedInteger16(void* _pvCtx, int* _piAddress, unsigned short* _pusData)
1082 {
1083 unsigned short* pusData = NULL;
1084
1085 int iRet = getCommonScalarInteger(_pvCtx, _piAddress, SCI_UINT16, (void**)&pusData);
1086 if (iRet)
1087 {
1088 return iRet;
1089 }
1090
1091 *_pusData = pusData[0];
1092 return 0;
1093 }
1094 /*--------------------------------------------------------------------------*/
getScalarUnsignedInteger32(void * _pvCtx,int * _piAddress,unsigned int * _puiData)1095 int getScalarUnsignedInteger32(void* _pvCtx, int* _piAddress, unsigned int* _puiData)
1096 {
1097 unsigned int* puiData = NULL;
1098
1099 int iRet = getCommonScalarInteger(_pvCtx, _piAddress, SCI_UINT32, (void**)&puiData);
1100 if (iRet)
1101 {
1102 return iRet;
1103 }
1104
1105 *_puiData = puiData[0];
1106 return 0;
1107 }
1108 /*--------------------------------------------------------------------------*/
1109 #ifdef __SCILAB_INT64__
getScalarUnsignedInteger64(void * _pvCtx,int * _piAddress,unsigned long long * _pullData)1110 int getScalarUnsignedInteger64(void* _pvCtx, int* _piAddress, unsigned long long* _pullData)
1111 {
1112 unsigned long long* pullData = NULL;
1113
1114 int iRet = getCommonScalarInteger(_pvCtx, _piAddress, SCI_UINT64, (void**)&pullData);
1115 if (iRet)
1116 {
1117 return iRet;
1118 }
1119
1120 *_pullData = pullData[0];
1121 return 0;
1122 }
1123 #endif
1124 /*--------------------------------------------------------------------------*/
getCommonScalarInteger(void * _pvCtx,int * _piAddress,int _iPrec,void ** _pvData)1125 static int getCommonScalarInteger(void* _pvCtx, int* _piAddress, int _iPrec, void** _pvData)
1126 {
1127 SciErr sciErr = sciErrInit();
1128 int iRows = 0;
1129 int iCols = 0;
1130
1131 if (isScalar(_pvCtx, _piAddress) == 0)
1132 {
1133 addErrorMessage(&sciErr, API_ERROR_GET_SCALAR_INTEGER, _("%s: Wrong type for input argument #%d: A scalar expected.\n"), "getScalarInteger", getRhsFromAddress(_pvCtx, _piAddress));
1134 printError(&sciErr, 0);
1135 return sciErr.iErr;
1136 }
1137
1138 sciErr = getCommonMatrixOfInteger(_pvCtx, _piAddress, _iPrec, &iRows, &iCols, _pvData);
1139 if (sciErr.iErr)
1140 {
1141 addErrorMessage(&sciErr, API_ERROR_GET_SCALAR_INTEGER, _("%s: Unable to get argument #%d"), "getScalarInteger", getRhsFromAddress(_pvCtx, _piAddress));
1142 printError(&sciErr, 0);
1143 return sciErr.iErr;
1144 }
1145
1146 return 0;
1147 }
1148 /*--------------------------------------------------------------------------*/
getNamedScalarInteger8(void * _pvCtx,const char * _pstName,char * _pcData)1149 int getNamedScalarInteger8(void* _pvCtx, const char* _pstName, char* _pcData)
1150 {
1151 char* pcData = NULL;
1152
1153 int iRet = getCommonNamedScalarInteger(_pvCtx, _pstName, SCI_INT8, (void**)&pcData);
1154 if (iRet)
1155 {
1156 return iRet;
1157 }
1158
1159 *_pcData = pcData[0];
1160 return 0;
1161 }
1162 /*--------------------------------------------------------------------------*/
getNamedScalarInteger16(void * _pvCtx,const char * _pstName,short * _psData)1163 int getNamedScalarInteger16(void* _pvCtx, const char* _pstName, short* _psData)
1164 {
1165 short* psData = NULL;
1166
1167 int iRet = getCommonNamedScalarInteger(_pvCtx, _pstName, SCI_INT16, (void**)&psData);
1168 if (iRet)
1169 {
1170 return iRet;
1171 }
1172
1173 *_psData = psData[0];
1174 return 0;
1175 }
1176 /*--------------------------------------------------------------------------*/
getNamedScalarInteger32(void * _pvCtx,const char * _pstName,int * _piData)1177 int getNamedScalarInteger32(void* _pvCtx, const char* _pstName, int* _piData)
1178 {
1179 int* piData = NULL;
1180
1181 int iRet = getCommonNamedScalarInteger(_pvCtx, _pstName, SCI_INT32, (void**)&piData);
1182 if (iRet)
1183 {
1184 return iRet;
1185 }
1186
1187 *_piData = piData[0];
1188 return 0;
1189 }
1190 /*--------------------------------------------------------------------------*/
1191 #ifdef __SCILAB_INT64__
getNamedScalarInteger64(void * _pvCtx,const char * _pstName,long long * _pllData)1192 int getNamedScalarInteger64(void* _pvCtx, const char* _pstName, long long* _pllData)
1193 {
1194 long long* pllData = NULL;
1195
1196 int iRet = getCommonNamedScalarInteger(_pvCtx, _pstName, SCI_INT64, (void**)&pllData);
1197 if (iRet)
1198 {
1199 return iRet;
1200 }
1201
1202 *_pllData = pllData[0];
1203 return 0;
1204 }
1205 #endif
1206 /*--------------------------------------------------------------------------*/
getNamedScalarUnsignedInteger8(void * _pvCtx,const char * _pstName,unsigned char * _pucData)1207 int getNamedScalarUnsignedInteger8(void* _pvCtx, const char* _pstName, unsigned char* _pucData)
1208 {
1209 unsigned char* pucData = NULL;
1210
1211 int iRet = getCommonNamedScalarInteger(_pvCtx, _pstName, SCI_UINT8, (void**)&pucData);
1212 if (iRet)
1213 {
1214 return iRet;
1215 }
1216
1217 *_pucData = pucData[0];
1218 return 0;
1219 }
1220 /*--------------------------------------------------------------------------*/
getNamedScalarUnsignedInteger16(void * _pvCtx,const char * _pstName,unsigned short * _pusData)1221 int getNamedScalarUnsignedInteger16(void* _pvCtx, const char* _pstName, unsigned short* _pusData)
1222 {
1223 unsigned short* pusData = NULL;
1224
1225 int iRet = getCommonNamedScalarInteger(_pvCtx, _pstName, SCI_UINT16, (void**)&pusData);
1226 if (iRet)
1227 {
1228 return iRet;
1229 }
1230
1231 *_pusData = pusData[0];
1232 return 0;
1233 }
1234 /*--------------------------------------------------------------------------*/
getNamedScalarUnsignedInteger32(void * _pvCtx,const char * _pstName,unsigned int * _puiData)1235 int getNamedScalarUnsignedInteger32(void* _pvCtx, const char* _pstName, unsigned int* _puiData)
1236 {
1237 unsigned int* puiData = NULL;
1238
1239 int iRet = getCommonNamedScalarInteger(_pvCtx, _pstName, SCI_UINT32, (void**)&puiData);
1240 if (iRet)
1241 {
1242 return iRet;
1243 }
1244
1245 *_puiData = puiData[0];
1246 return 0;
1247 }
1248 /*--------------------------------------------------------------------------*/
1249 #ifdef __SCILAB_INT64__
getNamedScalarUnsignedInteger64(void * _pvCtx,const char * _pstName,unsigned long long * _pullData)1250 int getNamedScalarUnsignedInteger64(void* _pvCtx, const char* _pstName, unsigned long long* _pullData)
1251 {
1252 unsigned long long* pullData = NULL;
1253
1254 int iRet = getCommonNamedScalarInteger(_pvCtx, _pstName, SCI_UINT64, (void**)&pullData);
1255 if (iRet)
1256 {
1257 return iRet;
1258 }
1259
1260 *_pullData = pullData[0];
1261 return 0;
1262 }
1263 #endif
1264 /*--------------------------------------------------------------------------*/
getCommonNamedScalarInteger(void * _pvCtx,const char * _pstName,int _iPrec,void ** _pvData)1265 static int getCommonNamedScalarInteger(void* _pvCtx, const char* _pstName, int _iPrec, void** _pvData)
1266 {
1267 SciErr sciErr = sciErrInit();
1268 int iRows = 0;
1269 int iCols = 0;
1270
1271 if (isNamedScalar(_pvCtx, _pstName) == 0)
1272 {
1273 addErrorMessage(&sciErr, API_ERROR_GET_NAMED_SCALAR_INTEGER, _("%s: Wrong type for input argument \"%s\": A scalar expected.\n"), "getNamedScalarInteger", _pstName);
1274 printError(&sciErr, 0);
1275 return sciErr.iErr;
1276 }
1277
1278 sciErr = readCommonNamedMatrixOfInteger(_pvCtx, _pstName, _iPrec, &iRows, &iCols, _pvData);
1279 if (sciErr.iErr)
1280 {
1281 addErrorMessage(&sciErr, API_ERROR_GET_NAMED_SCALAR_INTEGER, _("%s: Unable to get argument \"%s\""), "getNamedScalarInteger", _pstName);
1282 printError(&sciErr, 0);
1283 return sciErr.iErr;
1284 }
1285
1286 return 0;
1287 }
1288 /*--------------------------------------------------------------------------*/
createScalarInteger8(void * _pvCtx,int _iVar,char _cData)1289 int createScalarInteger8(void* _pvCtx, int _iVar, char _cData)
1290 {
1291 SciErr sciErr = createMatrixOfInteger8(_pvCtx, _iVar, 1, 1, &_cData);
1292 if (sciErr.iErr)
1293 {
1294 addErrorMessage(&sciErr, API_ERROR_CREATE_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createScalarInteger8");
1295 printError(&sciErr, 0);
1296 return sciErr.iErr;
1297 }
1298
1299 return 0;
1300 }
1301 /*--------------------------------------------------------------------------*/
createScalarInteger16(void * _pvCtx,int _iVar,short _sData)1302 int createScalarInteger16(void* _pvCtx, int _iVar, short _sData)
1303 {
1304 SciErr sciErr = createMatrixOfInteger16(_pvCtx, _iVar, 1, 1, &_sData);
1305 if (sciErr.iErr)
1306 {
1307 addErrorMessage(&sciErr, API_ERROR_CREATE_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createScalarInteger16");
1308 printError(&sciErr, 0);
1309 return sciErr.iErr;
1310 }
1311
1312 return 0;
1313 }
1314 /*--------------------------------------------------------------------------*/
createScalarInteger32(void * _pvCtx,int _iVar,int _iData)1315 int createScalarInteger32(void* _pvCtx, int _iVar, int _iData)
1316 {
1317 SciErr sciErr = createMatrixOfInteger32(_pvCtx, _iVar, 1, 1, &_iData);
1318 if (sciErr.iErr)
1319 {
1320 addErrorMessage(&sciErr, API_ERROR_CREATE_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createScalarInteger32");
1321 printError(&sciErr, 0);
1322 return sciErr.iErr;
1323 }
1324
1325 return 0;
1326 }
1327 /*--------------------------------------------------------------------------*/
1328 #ifdef __SCILAB_INT64__
createScalarInteger64(void * _pvCtx,int _iVar,long long _llData)1329 int createScalarInteger64(void* _pvCtx, int _iVar, long long _llData)
1330 {
1331 SciErr sciErr = sciErrInit();
1332 sciErr = createMatrixOfInteger64(_pvCtx, _iVar, 1, 1, &_llData);
1333 if (sciErr.iErr)
1334 {
1335 addErrorMessage(&sciErr, API_ERROR_CREATE_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createScalarInteger64");
1336 printError(&sciErr, 0);
1337 return sciErr.iErr;
1338 }
1339
1340 return 0;
1341 }
1342 #endif
1343 /*--------------------------------------------------------------------------*/
createScalarUnsignedInteger8(void * _pvCtx,int _iVar,unsigned char _ucData)1344 int createScalarUnsignedInteger8(void* _pvCtx, int _iVar, unsigned char _ucData)
1345 {
1346 SciErr sciErr = createMatrixOfUnsignedInteger8(_pvCtx, _iVar, 1, 1, &_ucData);
1347 if (sciErr.iErr)
1348 {
1349 addErrorMessage(&sciErr, API_ERROR_CREATE_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createScalarUnsignedInteger8");
1350 printError(&sciErr, 0);
1351 return sciErr.iErr;
1352 }
1353
1354 return 0;
1355 }
1356 /*--------------------------------------------------------------------------*/
createScalarUnsignedInteger16(void * _pvCtx,int _iVar,unsigned short _usData)1357 int createScalarUnsignedInteger16(void* _pvCtx, int _iVar, unsigned short _usData)
1358 {
1359 SciErr sciErr = createMatrixOfUnsignedInteger16(_pvCtx, _iVar, 1, 1, &_usData);
1360 if (sciErr.iErr)
1361 {
1362 addErrorMessage(&sciErr, API_ERROR_CREATE_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createScalarUnsignedInteger16");
1363 printError(&sciErr, 0);
1364 return sciErr.iErr;
1365 }
1366
1367 return 0;
1368 }
1369 /*--------------------------------------------------------------------------*/
createScalarUnsignedInteger32(void * _pvCtx,int _iVar,unsigned int _uiData)1370 int createScalarUnsignedInteger32(void* _pvCtx, int _iVar, unsigned int _uiData)
1371 {
1372 SciErr sciErr = createMatrixOfUnsignedInteger32(_pvCtx, _iVar, 1, 1, &_uiData);
1373 if (sciErr.iErr)
1374 {
1375 addErrorMessage(&sciErr, API_ERROR_CREATE_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createScalarUnsignedInteger32");
1376 printError(&sciErr, 0);
1377 return sciErr.iErr;
1378 }
1379
1380 return 0;
1381 }
1382 /*--------------------------------------------------------------------------*/
1383 #ifdef __SCILAB_INT64__
createScalarUnsignedInteger64(void * _pvCtx,int _iVar,unsigned long long _ullData)1384 int createScalarUnsignedInteger64(void* _pvCtx, int _iVar, unsigned long long _ullData)
1385 {
1386 SciErr sciErr = createMatrixOfUnsignedInteger64(_pvCtx, _iVar, 1, 1, &_ullData);
1387 if (sciErr.iErr)
1388 {
1389 addErrorMessage(&sciErr, API_ERROR_CREATE_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createScalarUnsignedInteger64");
1390 printError(&sciErr, 0);
1391 return sciErr.iErr;
1392 }
1393
1394 return 0;
1395 }
1396 #endif
1397 /*--------------------------------------------------------------------------*/
createNamedScalarInteger8(void * _pvCtx,const char * _pstName,char _cData)1398 int createNamedScalarInteger8(void* _pvCtx, const char* _pstName, char _cData)
1399 {
1400 SciErr sciErr = createNamedMatrixOfInteger8(_pvCtx, _pstName, 1, 1, &_cData);
1401 if (sciErr.iErr)
1402 {
1403 addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createNamedScalarInteger8");
1404 printError(&sciErr, 0);
1405 return sciErr.iErr;
1406 }
1407
1408 return 0;
1409 }
1410 /*--------------------------------------------------------------------------*/
createNamedScalarInteger16(void * _pvCtx,const char * _pstName,short _sData)1411 int createNamedScalarInteger16(void* _pvCtx, const char* _pstName, short _sData)
1412 {
1413 SciErr sciErr = createNamedMatrixOfInteger16(_pvCtx, _pstName, 1, 1, &_sData);
1414 if (sciErr.iErr)
1415 {
1416 addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createNamedScalarInteger16");
1417 printError(&sciErr, 0);
1418 return sciErr.iErr;
1419 }
1420
1421 return 0;
1422 }
1423 /*--------------------------------------------------------------------------*/
createNamedScalarInteger32(void * _pvCtx,const char * _pstName,int _iData)1424 int createNamedScalarInteger32(void* _pvCtx, const char* _pstName, int _iData)
1425 {
1426 SciErr sciErr = createNamedMatrixOfInteger32(_pvCtx, _pstName, 1, 1, &_iData);
1427 if (sciErr.iErr)
1428 {
1429 addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createNamedScalarInteger32");
1430 printError(&sciErr, 0);
1431 return sciErr.iErr;
1432 }
1433
1434 return 0;
1435 }
1436 /*--------------------------------------------------------------------------*/
1437 #ifdef __SCILAB_INT64__
createNamedScalarInteger64(void * _pvCtx,const char * _pstName,long long _llData)1438 int createNamedScalarInteger64(void* _pvCtx, const char* _pstName, long long _llData)
1439 {
1440 SciErr sciErr = createNamedMatrixOfInteger64(_pvCtx, _pstName, 1, 1, &_llData);
1441 if (sciErr.iErr)
1442 {
1443 addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createNamedScalarInteger64");
1444 printError(&sciErr, 0);
1445 return sciErr.iErr;
1446 }
1447
1448 return 0;
1449 }
1450 #endif
1451 /*--------------------------------------------------------------------------*/
createNamedScalarUnsignedInteger8(void * _pvCtx,const char * _pstName,unsigned char _ucData)1452 int createNamedScalarUnsignedInteger8(void* _pvCtx, const char* _pstName, unsigned char _ucData)
1453 {
1454 SciErr sciErr = createNamedMatrixOfUnsignedInteger8(_pvCtx, _pstName, 1, 1, &_ucData);
1455 if (sciErr.iErr)
1456 {
1457 addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createNamedScalarUnsignedInteger8");
1458 printError(&sciErr, 0);
1459 return sciErr.iErr;
1460 }
1461
1462 return 0;
1463 }
1464 /*--------------------------------------------------------------------------*/
createNamedScalarUnsignedInteger16(void * _pvCtx,const char * _pstName,unsigned short _usData)1465 int createNamedScalarUnsignedInteger16(void* _pvCtx, const char* _pstName, unsigned short _usData)
1466 {
1467 SciErr sciErr = createNamedMatrixOfUnsignedInteger16(_pvCtx, _pstName, 1, 1, &_usData);
1468 if (sciErr.iErr)
1469 {
1470 addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createNamedScalarUnsignedInteger16");
1471 printError(&sciErr, 0);
1472 return sciErr.iErr;
1473 }
1474
1475 return 0;
1476 }
1477 /*--------------------------------------------------------------------------*/
createNamedScalarUnsignedInteger32(void * _pvCtx,const char * _pstName,unsigned int _uiData)1478 int createNamedScalarUnsignedInteger32(void* _pvCtx, const char* _pstName, unsigned int _uiData)
1479 {
1480 SciErr sciErr = createNamedMatrixOfUnsignedInteger32(_pvCtx, _pstName, 1, 1, &_uiData);
1481 if (sciErr.iErr)
1482 {
1483 addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createNamedScalarUnsignedInteger32");
1484 printError(&sciErr, 0);
1485 return sciErr.iErr;
1486 }
1487
1488 return 0;
1489 }
1490 /*--------------------------------------------------------------------------*/
1491 #ifdef __SCILAB_INT64__
createNamedScalarUnsignedInteger64(void * _pvCtx,const char * _pstName,unsigned long long _ullData)1492 int createNamedScalarUnsignedInteger64(void* _pvCtx, const char* _pstName, unsigned long long _ullData)
1493 {
1494 SciErr sciErr = createNamedMatrixOfUnsignedInteger64(_pvCtx, _pstName, 1, 1, &_ullData);
1495 if (sciErr.iErr)
1496 {
1497 addErrorMessage(&sciErr, API_ERROR_CREATE_NAMED_SCALAR_INT, _("%s: Unable to create variable in Scilab memory"), "createNamedScalarUnsignedInteger64");
1498 printError(&sciErr, 0);
1499 return sciErr.iErr;
1500 }
1501
1502 return 0;
1503 }
1504 #endif
1505 /*--------------------------------------------------------------------------*/
1506