diff options
author | rupak | 2019-08-09 18:23:51 +0530 |
---|---|---|
committer | rupak | 2019-08-09 18:23:51 +0530 |
commit | 85bde50698bbdfd891ef194cd700d9a659bd50cd (patch) | |
tree | 5b09ea04150f1e11a18022e2145817d84828d563 /sci_gateway/cpp | |
download | fossee-scilab-octave-toolbox-85bde50698bbdfd891ef194cd700d9a659bd50cd.tar.gz fossee-scilab-octave-toolbox-85bde50698bbdfd891ef194cd700d9a659bd50cd.tar.bz2 fossee-scilab-octave-toolbox-85bde50698bbdfd891ef194cd700d9a659bd50cd.zip |
first commit
Diffstat (limited to 'sci_gateway/cpp')
-rw-r--r-- | sci_gateway/cpp/builder_gateway_cpp.sce | 70 | ||||
-rw-r--r-- | sci_gateway/cpp/cleaner.sce | 30 | ||||
-rw-r--r-- | sci_gateway/cpp/libscilab_toolbox.cpp | 16 | ||||
-rw-r--r-- | sci_gateway/cpp/libscilab_toolbox.h | 8 | ||||
-rw-r--r-- | sci_gateway/cpp/libscilab_toolbox.hxx | 18 | ||||
-rwxr-xr-x | sci_gateway/cpp/libscilab_toolbox.so | bin | 0 -> 16448 bytes | |||
-rw-r--r-- | sci_gateway/cpp/loader.sce | 21 | ||||
-rw-r--r-- | sci_gateway/cpp/sci_matrix.cpp | 32 |
8 files changed, 195 insertions, 0 deletions
diff --git a/sci_gateway/cpp/builder_gateway_cpp.sce b/sci_gateway/cpp/builder_gateway_cpp.sce new file mode 100644 index 0000000..fdb5d24 --- /dev/null +++ b/sci_gateway/cpp/builder_gateway_cpp.sce @@ -0,0 +1,70 @@ +// 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 = "scilab_toolbox"; + +Build_64Bits = %t; + +path_builder = get_absolute_file_path('builder_gateway_cpp.sce'); + +Function_Names = [ + + //fun function + "octave_fun","sci_octave_fun", "csci6"; + ]; + +//Name of all the files to be compiled +Files = [ + "sci_matrix.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' + filesep() + 'coin'; + 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+' '+'-I '+threads_dir+' '] + Linker_Flag = [lib_base_dir+"libcoinblas.lib "+lib_base_dir+"libcoinlapack.lib "+lib_base_dir+"libcoinmumps.lib "+lib_base_dir+"libClp.lib "+lib_base_dir+"libipopt.lib "+lib_base_dir+"libOsi.lib "+lib_base_dir+"libOsiClp.lib "+lib_base_dir+"libCoinUtils.lib "+lib_base_dir+"libCgl.lib "+lib_base_dir+"libOsiSym.lib "+lib_base_dir+"libSym.lib "+lib_base_dir+"libCbcSolver.lib "+lib_base_dir+"libCbc.lib "+lib_base_dir+"libbonmin.lib "+lib_base_dir+"pthreadVC2.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 + 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=["-D__USE_DEPRECATED_STACK_FUNCTIONS__ -w -fpermissive -I"+path_builder+" -I"+inc_base_dir+" -Wl,-rpath="+lib_base_dir+" "+"-std=gnu++11"] + + + Linker_Flag = ["-L"+lib_base_dir+"libfun"+" " + "-loctave"+" "+ "-loctinterp"] + +end + +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..74db4be --- /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('libscilab_toolbox.so') <> [] then + mdelete('libscilab_toolbox.so'); +end +// ------------------------------------------------------ +if fileinfo('libscilab_toolbox.cpp') <> [] then + mdelete('libscilab_toolbox.cpp'); +end +// ------------------------------------------------------ +if fileinfo('libscilab_toolbox.hxx') <> [] then + mdelete('libscilab_toolbox.hxx'); +end +// ------------------------------------------------------ +if fileinfo('libscilab_toolbox.h') <> [] then + mdelete('libscilab_toolbox.h'); +end +// ------------------------------------------------------ +chdir(curdir); +// ------------------------------------------------------ diff --git a/sci_gateway/cpp/libscilab_toolbox.cpp b/sci_gateway/cpp/libscilab_toolbox.cpp new file mode 100644 index 0000000..564874c --- /dev/null +++ b/sci_gateway/cpp/libscilab_toolbox.cpp @@ -0,0 +1,16 @@ +#include <wchar.h> +#include "libscilab_toolbox.hxx" +extern "C" +{ +#include "libscilab_toolbox.h" +#include "addfunction.h" +} + +#define MODULE_NAME L"libscilab_toolbox" + +int libscilab_toolbox(wchar_t* _pwstFuncName) +{ + if(wcscmp(_pwstFuncName, L"octave_fun") == 0){ addCFunction(L"octave_fun", &sci_octave_fun, MODULE_NAME); } + + return 1; +} diff --git a/sci_gateway/cpp/libscilab_toolbox.h b/sci_gateway/cpp/libscilab_toolbox.h new file mode 100644 index 0000000..3035e8b --- /dev/null +++ b/sci_gateway/cpp/libscilab_toolbox.h @@ -0,0 +1,8 @@ +#ifndef __LIBSCILAB_TOOLBOX_GW_H__ +#define __LIBSCILAB_TOOLBOX_GW_H__ + +#include "c_gateway_prototype.h" + +C_GATEWAY_PROTOTYPE(sci_octave_fun); + +#endif /* __LIBSCILAB_TOOLBOX_GW_H__ */ diff --git a/sci_gateway/cpp/libscilab_toolbox.hxx b/sci_gateway/cpp/libscilab_toolbox.hxx new file mode 100644 index 0000000..a36a14c --- /dev/null +++ b/sci_gateway/cpp/libscilab_toolbox.hxx @@ -0,0 +1,18 @@ +#ifndef __LIBSCILAB_TOOLBOX_GW_HXX__ +#define __LIBSCILAB_TOOLBOX_GW_HXX__ + +#ifdef _MSC_VER +#ifdef LIBSCILAB_TOOLBOX_GW_EXPORTS +#define LIBSCILAB_TOOLBOX_GW_IMPEXP __declspec(dllexport) +#else +#define LIBSCILAB_TOOLBOX_GW_IMPEXP __declspec(dllimport) +#endif +#else +#define LIBSCILAB_TOOLBOX_GW_IMPEXP +#endif + +extern "C" LIBSCILAB_TOOLBOX_GW_IMPEXP int libscilab_toolbox(wchar_t* _pwstFuncName); + + + +#endif /* __LIBSCILAB_TOOLBOX_GW_HXX__ */ diff --git a/sci_gateway/cpp/libscilab_toolbox.so b/sci_gateway/cpp/libscilab_toolbox.so Binary files differnew file mode 100755 index 0000000..908651c --- /dev/null +++ b/sci_gateway/cpp/libscilab_toolbox.so diff --git a/sci_gateway/cpp/loader.sce b/sci_gateway/cpp/loader.sce new file mode 100644 index 0000000..dd2e723 --- /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 +// ---------------------------------------------------------------------------- +// +libscilab_toolbox_path = get_absolute_file_path('loader.sce'); +// +// ulink previous function with same name +[bOK, ilib] = c_link('libscilab_toolbox'); +if bOK then + ulink(ilib); +end +// +list_functions = [ 'octave_fun'; +]; +addinter(libscilab_toolbox_path + filesep() + 'libscilab_toolbox' + getdynlibext(), 'libscilab_toolbox', list_functions); +// remove temp. variables on stack +clear libscilab_toolbox_path; +clear bOK; +clear ilib; +clear list_functions; +// ---------------------------------------------------------------------------- diff --git a/sci_gateway/cpp/sci_matrix.cpp b/sci_gateway/cpp/sci_matrix.cpp new file mode 100644 index 0000000..071d330 --- /dev/null +++ b/sci_gateway/cpp/sci_matrix.cpp @@ -0,0 +1,32 @@ +extern "C" +{ +#include<Scierror.h> +#include<api_scilab.h> +#include "localization.h" +#include<fun.h> + +static const char fname[] = "octave_fun"; + +int sci_octave_fun(scilabEnv env, int nin, scilabVar* in, int nopt, scilabOpt* opt, int nout, scilabVar* out) + +{ + +if (nin != 0) + { + 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; + } + + double x = fun(); + + out[0] = scilab_createDouble( env, x); + + return 0; +} +} |