1 /*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) DIGITEO - 2010-2010 - Clément DAVID <clement.david@scilab.org>
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 */
15
16 #include "Palette.hxx"
17 #include "GiwsException.hxx"
18 #include "xcosUtilities.hxx"
19 #include "loadStatus.hxx"
20
21 extern "C"
22 {
23 #include "gw_xcos.h"
24 #include "api_scilab.h"
25 #include "localization.h"
26 #include "Scierror.h"
27 #include "sci_malloc.h"
28 #include "getScilabJavaVM.h"
29 }
30
31 using namespace org_scilab_modules_xcos_palette;
32
sci_xcosPalMove(char * fname,void * pvApiCtx)33 int sci_xcosPalMove(char *fname, void* pvApiCtx)
34 {
35 CheckRhs(2, 2);
36 CheckLhs(0, 1);
37
38 char **source = NULL;
39 int sourceLength = 0;
40
41 char **target = NULL;
42 int targetLength = 0;
43
44 /* source setup */
45 if (readVectorString(pvApiCtx, 1, &source, &sourceLength, fname))
46 {
47 return 0;
48 }
49
50 /* target setup */
51 if (readVectorString(pvApiCtx, 2, &target, &targetLength, fname))
52 {
53 releaseVectorString(source, sourceLength);
54 return 0;
55 }
56
57 /* Call the java implementation */
58 set_loaded_status(XCOS_CALLED);
59 try
60 {
61 Palette::move(getScilabJavaVM(), source, sourceLength, target, targetLength);
62 }
63 catch (const GiwsException::JniCallMethodException& exception)
64 {
65 releaseVectorString(source, sourceLength);
66 releaseVectorString(target, targetLength);
67 Scierror(999, "%s: %s\n", fname, exception.getJavaDescription().c_str());
68 return 0;
69 }
70 catch (const GiwsException::JniException& exception)
71 {
72 releaseVectorString(source, sourceLength);
73 releaseVectorString(target, targetLength);
74 Scierror(999, "%s: %s\n", fname, exception.whatStr().c_str());
75 return 0;
76 }
77
78 releaseVectorString(source, sourceLength);
79 releaseVectorString(target, targetLength);
80 PutLhsVar();
81 return 0;
82 }
83