diff options
Diffstat (limited to 'sci_gateway')
-rwxr-xr-x | sci_gateway/builder_gateway.sce | 15 | ||||
-rw-r--r-- | sci_gateway/cleaner_gateway.sce | 15 | ||||
-rwxr-xr-x | sci_gateway/cpp/builder_gateway_cpp.sce | 69 | ||||
-rw-r--r-- | sci_gateway/cpp/cleaner.sce | 30 | ||||
-rw-r--r-- | sci_gateway/cpp/libtest_toolbox.cpp | 16 | ||||
-rw-r--r-- | sci_gateway/cpp/libtest_toolbox.h | 8 | ||||
-rw-r--r-- | sci_gateway/cpp/libtest_toolbox.hxx | 18 | ||||
-rwxr-xr-x | sci_gateway/cpp/libtest_toolbox.so | bin | 0 -> 16712 bytes | |||
-rw-r--r-- | sci_gateway/cpp/loader.sce | 21 | ||||
-rwxr-xr-x | sci_gateway/cpp/sci_multiply.cpp | 55 | ||||
-rwxr-xr-x | sci_gateway/cpp/test_toolbox.cpp | 16 | ||||
-rwxr-xr-x | sci_gateway/cpp/test_toolbox.h | 8 | ||||
-rwxr-xr-x | sci_gateway/cpp/test_toolbox.hxx | 18 | ||||
-rwxr-xr-x | sci_gateway/loader_gateway.sce | 24 |
14 files changed, 313 insertions, 0 deletions
diff --git a/sci_gateway/builder_gateway.sce b/sci_gateway/builder_gateway.sce new file mode 100755 index 0000000..103597c --- /dev/null +++ b/sci_gateway/builder_gateway.sce @@ -0,0 +1,15 @@ +// This file is released under the 3-clause BSD license. See COPYING-BSD. + +function builder_gateway() + + sci_gateway_dir = get_absolute_file_path("builder_gateway.sce"); + languages = ["cpp"]; + + tbx_builder_gateway_lang(languages,sci_gateway_dir); + tbx_build_gateway_loader(languages,sci_gateway_dir); + tbx_build_gateway_clean(languages,sci_gateway_dir); + +endfunction + +builder_gateway() +clear builder_gateway; // remove builder_gateway on stack diff --git a/sci_gateway/cleaner_gateway.sce b/sci_gateway/cleaner_gateway.sce new file mode 100644 index 0000000..03aedaf --- /dev/null +++ b/sci_gateway/cleaner_gateway.sce @@ -0,0 +1,15 @@ +// This file is released under the 3-clause BSD license. See COPYING-BSD. +// Generated by builder_gateway.sce: Please, do not edit this file + +sci_gateway_dir = get_absolute_file_path("cleaner_gateway.sce"); +current_dir = pwd(); + +chdir(sci_gateway_dir); +if ( isdir("cpp") ) then + chdir("cpp"); + exec("cleaner.sce"); + mdelete("cleaner.sce"); +end + +chdir(current_dir); +clear sci_gateway_dir current_dir; diff --git a/sci_gateway/cpp/builder_gateway_cpp.sce b/sci_gateway/cpp/builder_gateway_cpp.sce new file mode 100755 index 0000000..79b7d18 --- /dev/null +++ b/sci_gateway/cpp/builder_gateway_cpp.sce @@ -0,0 +1,69 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Author: Harpreet Singh, Yash Kataria, Adarsh Shah +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +mode(-1) +lines(0) + +toolbox_title = "test_toolbox"; + +Build_64Bits = %t; + +path_builder = get_absolute_file_path('builder_gateway_cpp.sce'); + +Function_Names = [ + + //fun function + "multiply","sci_multiply", "csci6"; + ]; + +//Name of all the files to be compiled +Files = "sci_multiply.cpp"; + + + +[a, opt] = getversion(); +Version = opt(2); + +//Build_64Bits = %f; + +if getos()=="Windows" then + third_dir = path_builder+filesep()+'..'+filesep()+'..'+filesep()+'thirdparty'; + lib_base_dir = third_dir + filesep() + 'windows' + filesep() + 'lib' + filesep() + Version + filesep(); + inc_base_dir = third_dir + filesep() + 'windows' + filesep() + 'include'; + //inc_base_dir = third_dir + filesep() + 'linux' + filesep() + 'include' + filesep() + 'coin'; + //threads_dir=third_dir + filesep() + 'linux' + filesep() + 'include' + filesep() + 'pthreads-win32'; + C_Flags=['-D__USE_DEPRECATED_STACK_FUNCTIONS__ -I -w '+path_builder+' '+ '-I '+inc_base_dir+' '] + Linker_Flag = [lib_base_dir+"libcoinblas.lib "] + +elseif getos()=="Darwin" then + third_dir = path_builder+filesep()+'..'+filesep()+'..'+filesep()+'thirdparty'; + lib_base_dir = third_dir + filesep() + 'Mac' + filesep() + 'lib' + filesep() + Version + filesep(); + inc_base_dir = third_dir + filesep() + 'Mac' + filesep() + 'include' + filesep() + 'coin'; + C_Flags=["-D__USE_DEPRECATED_STACK_FUNCTIONS__ -w -fpermissive -I"+path_builder+" -I"+inc_base_dir+" -Wl,-rpath "+lib_base_dir+" "] + Linker_Flag = ["-L"+lib_base_dir+"libSym"+" "+"-L"+lib_base_dir+"libipopt"+" "+"-L"+lib_base_dir+"libClp"+" "+"-L"+lib_base_dir+"libOsiClp"+" "+"-L"+lib_base_dir+"libCoinUtils" + " "+"-L"+lib_base_dir+"libbonmin" ] + +else//LINUX + + third_dir = path_builder+filesep()+'..'+filesep()+'..'+filesep()+'thirdparty'; + lib_base_dir = third_dir + filesep() + 'linux' + filesep() + 'lib' + filesep() + Version + filesep(); + + inc_base_dir = third_dir + filesep() + 'linux' + filesep() + 'include'; + + C_Flags = ["-I"+inc_base_dir]; + + Linker_Flag = ["-L" + lib_base_dir + " -ladd -Wl,-rpath="+lib_base_dir] + +end + +//disp("printing ?????") +tbx_build_gateway(toolbox_title,Function_Names,Files,get_absolute_file_path("builder_gateway_cpp.sce"), [], Linker_Flag, C_Flags,[]); + +clear toolbox_title Function_Names Files Linker_Flag C_Flags; diff --git a/sci_gateway/cpp/cleaner.sce b/sci_gateway/cpp/cleaner.sce new file mode 100644 index 0000000..d2f9e0c --- /dev/null +++ b/sci_gateway/cpp/cleaner.sce @@ -0,0 +1,30 @@ +// This file is released under the 3-clause BSD license. See COPYING-BSD. +// Generated by builder.sce : Please, do not edit this file +// cleaner.sce +// ------------------------------------------------------ +curdir = pwd(); +cleaner_path = get_file_path('cleaner.sce'); +chdir(cleaner_path); +// ------------------------------------------------------ +if fileinfo('loader.sce') <> [] then + mdelete('loader.sce'); +end +// ------------------------------------------------------ +if fileinfo('libtest_toolbox.so') <> [] then + mdelete('libtest_toolbox.so'); +end +// ------------------------------------------------------ +if fileinfo('libtest_toolbox.cpp') <> [] then + mdelete('libtest_toolbox.cpp'); +end +// ------------------------------------------------------ +if fileinfo('libtest_toolbox.hxx') <> [] then + mdelete('libtest_toolbox.hxx'); +end +// ------------------------------------------------------ +if fileinfo('libtest_toolbox.h') <> [] then + mdelete('libtest_toolbox.h'); +end +// ------------------------------------------------------ +chdir(curdir); +// ------------------------------------------------------ diff --git a/sci_gateway/cpp/libtest_toolbox.cpp b/sci_gateway/cpp/libtest_toolbox.cpp new file mode 100644 index 0000000..a2cd82a --- /dev/null +++ b/sci_gateway/cpp/libtest_toolbox.cpp @@ -0,0 +1,16 @@ +#include <wchar.h> +#include "libtest_toolbox.hxx" +extern "C" +{ +#include "libtest_toolbox.h" +#include "addfunction.h" +} + +#define MODULE_NAME L"libtest_toolbox" + +int libtest_toolbox(wchar_t* _pwstFuncName) +{ + if(wcscmp(_pwstFuncName, L"multiply") == 0){ addCFunction(L"multiply", &sci_multiply, MODULE_NAME); } + + return 1; +} diff --git a/sci_gateway/cpp/libtest_toolbox.h b/sci_gateway/cpp/libtest_toolbox.h new file mode 100644 index 0000000..f9c4895 --- /dev/null +++ b/sci_gateway/cpp/libtest_toolbox.h @@ -0,0 +1,8 @@ +#ifndef __LIBTEST_TOOLBOX_GW_H__ +#define __LIBTEST_TOOLBOX_GW_H__ + +#include "c_gateway_prototype.h" + +C_GATEWAY_PROTOTYPE(sci_multiply); + +#endif /* __LIBTEST_TOOLBOX_GW_H__ */ diff --git a/sci_gateway/cpp/libtest_toolbox.hxx b/sci_gateway/cpp/libtest_toolbox.hxx new file mode 100644 index 0000000..be782b9 --- /dev/null +++ b/sci_gateway/cpp/libtest_toolbox.hxx @@ -0,0 +1,18 @@ +#ifndef __LIBTEST_TOOLBOX_GW_HXX__ +#define __LIBTEST_TOOLBOX_GW_HXX__ + +#ifdef _MSC_VER +#ifdef LIBTEST_TOOLBOX_GW_EXPORTS +#define LIBTEST_TOOLBOX_GW_IMPEXP __declspec(dllexport) +#else +#define LIBTEST_TOOLBOX_GW_IMPEXP __declspec(dllimport) +#endif +#else +#define LIBTEST_TOOLBOX_GW_IMPEXP +#endif + +extern "C" LIBTEST_TOOLBOX_GW_IMPEXP int libtest_toolbox(wchar_t* _pwstFuncName); + + + +#endif /* __LIBTEST_TOOLBOX_GW_HXX__ */ diff --git a/sci_gateway/cpp/libtest_toolbox.so b/sci_gateway/cpp/libtest_toolbox.so Binary files differnew file mode 100755 index 0000000..582de0f --- /dev/null +++ b/sci_gateway/cpp/libtest_toolbox.so diff --git a/sci_gateway/cpp/loader.sce b/sci_gateway/cpp/loader.sce new file mode 100644 index 0000000..8747504 --- /dev/null +++ b/sci_gateway/cpp/loader.sce @@ -0,0 +1,21 @@ +// This file is released under the 3-clause BSD license. See COPYING-BSD. +// Generated by builder.sce : Please, do not edit this file +// ---------------------------------------------------------------------------- +// +libtest_toolbox_path = get_absolute_file_path('loader.sce'); +// +// ulink previous function with same name +[bOK, ilib] = c_link('libtest_toolbox'); +if bOK then + ulink(ilib); +end +// +list_functions = [ 'multiply'; +]; +addinter(libtest_toolbox_path + filesep() + 'libtest_toolbox' + getdynlibext(), 'libtest_toolbox', list_functions); +// remove temp. variables on stack +clear libtest_toolbox_path; +clear bOK; +clear ilib; +clear list_functions; +// ---------------------------------------------------------------------------- diff --git a/sci_gateway/cpp/sci_multiply.cpp b/sci_gateway/cpp/sci_multiply.cpp new file mode 100755 index 0000000..4aece25 --- /dev/null +++ b/sci_gateway/cpp/sci_multiply.cpp @@ -0,0 +1,55 @@ +// Copyright (C) 2019 - IIT Bombay - FOSSEE +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Author: Rupak Rokade +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in +extern "C" +{ +#include<Scierror.h> +#include<api_scilab.h> +#include <stdio.h> +#include "localization.h" +#include "add.h" + + + + +static const char fname[] = "multiply"; +int sci_multiply(scilabEnv env, int nin, scilabVar* in, int nopt, scilabOpt* opt, int nout, scilabVar* out) + +{ + double* in1 = NULL; + double* in2 = NULL; + double* out1 = NULL; + double ar[1]; + +if (nin < 2) + { + Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), fname, 2); + return 1; + } + +if (nout != 1) + { + Scierror(77, _("%s: Wrong number of output argument(s): %d expected.\n"), fname, 1); + return 1; + } + + scilab_getDoubleArray(env, in[0], &in1); + scilab_getDoubleArray(env, in[1], &in2); + + add(ar, in1[0],in2[0]); + + out[0] = scilab_createDoubleMatrix2d(env, 1, 1, 0); + scilab_getDoubleArray(env, out[0], &out1); + + + out1[0] = ar[0]; + return 0; +} +} diff --git a/sci_gateway/cpp/test_toolbox.cpp b/sci_gateway/cpp/test_toolbox.cpp new file mode 100755 index 0000000..df05be7 --- /dev/null +++ b/sci_gateway/cpp/test_toolbox.cpp @@ -0,0 +1,16 @@ +#include <wchar.h>
+#include "test_toolbox.hxx"
+extern "C"
+{
+#include "test_toolbox.h"
+#include "addfunction.h"
+}
+
+#define MODULE_NAME L"test_toolbox"
+
+int test_toolbox(wchar_t* _pwstFuncName)
+{
+ if(wcscmp(_pwstFuncName, L"multiply") == 0){ addCFunction(L"multiply", &sci_multiply, MODULE_NAME); }
+
+ return 1;
+}
diff --git a/sci_gateway/cpp/test_toolbox.h b/sci_gateway/cpp/test_toolbox.h new file mode 100755 index 0000000..a2a257c --- /dev/null +++ b/sci_gateway/cpp/test_toolbox.h @@ -0,0 +1,8 @@ +#ifndef __TEST_TOOLBOX_GW_H__
+#define __TEST_TOOLBOX_GW_H__
+
+#include "c_gateway_prototype.h"
+
+C_GATEWAY_PROTOTYPE(sci_multiply);
+
+#endif /* __TEST_TOOLBOX_GW_H__ */
diff --git a/sci_gateway/cpp/test_toolbox.hxx b/sci_gateway/cpp/test_toolbox.hxx new file mode 100755 index 0000000..b689e70 --- /dev/null +++ b/sci_gateway/cpp/test_toolbox.hxx @@ -0,0 +1,18 @@ +#ifndef __TEST_TOOLBOX_GW_HXX__
+#define __TEST_TOOLBOX_GW_HXX__
+
+#ifdef _MSC_VER
+#ifdef TEST_TOOLBOX_GW_EXPORTS
+#define TEST_TOOLBOX_GW_IMPEXP __declspec(dllexport)
+#else
+#define TEST_TOOLBOX_GW_IMPEXP __declspec(dllimport)
+#endif
+#else
+#define TEST_TOOLBOX_GW_IMPEXP
+#endif
+
+extern "C" TEST_TOOLBOX_GW_IMPEXP int test_toolbox(wchar_t* _pwstFuncName);
+
+
+
+#endif /* __TEST_TOOLBOX_GW_HXX__ */
diff --git a/sci_gateway/loader_gateway.sce b/sci_gateway/loader_gateway.sce new file mode 100755 index 0000000..6809d99 --- /dev/null +++ b/sci_gateway/loader_gateway.sce @@ -0,0 +1,24 @@ +// This file is released under the 3-clause BSD license. See COPYING-BSD. +// Generated by builder_gateway.sce: Please, do not edit this file + +try + v = getversion("scilab"); +catch + v = [ 5 0 ]; // or older +end +if (v(1) <= 5) & (v(2) < 3) then + // new API in scilab 5.3 + error(gettext("Scilab 5.3 or more is required.")); +end + +sci_gateway_dir = get_absolute_file_path("loader_gateway.sce"); +current_dir = pwd(); + +chdir(sci_gateway_dir); +if ( isdir("cpp") ) then + chdir("cpp"); + exec("loader.sce"); +end + +chdir(current_dir); +clear sci_gateway_dir current_dir v; |