src/cpp/types/struct.cpp \
src/cpp/types/macrofile.cpp \
src/cpp/types/callable.cpp \
+ src/cpp/types/addfunction.cpp \
src/cpp/system_env/dynamic_module.cpp \
src/cpp/system_env/setenvvar.cpp \
src/cpp/system_env/sci_home.cpp \
src/cpp/types/listundefined.cpp src/cpp/types/string.cpp \
src/cpp/types/implicitlist.cpp src/cpp/types/macro.cpp \
src/cpp/types/struct.cpp src/cpp/types/macrofile.cpp \
- src/cpp/types/callable.cpp \
+ src/cpp/types/callable.cpp src/cpp/types/addfunction.cpp \
src/cpp/system_env/dynamic_module.cpp \
src/cpp/system_env/setenvvar.cpp \
src/cpp/system_env/sci_home.cpp \
src/cpp/types/libsciast_la-struct.lo \
src/cpp/types/libsciast_la-macrofile.lo \
src/cpp/types/libsciast_la-callable.lo \
+ src/cpp/types/libsciast_la-addfunction.lo \
src/cpp/system_env/libsciast_la-dynamic_module.lo \
src/cpp/system_env/libsciast_la-setenvvar.lo \
src/cpp/system_env/libsciast_la-sci_home.lo \
src/cpp/types/listundefined.cpp src/cpp/types/string.cpp \
src/cpp/types/implicitlist.cpp src/cpp/types/macro.cpp \
src/cpp/types/struct.cpp src/cpp/types/macrofile.cpp \
- src/cpp/types/callable.cpp \
+ src/cpp/types/callable.cpp src/cpp/types/addfunction.cpp \
src/cpp/system_env/dynamic_module.cpp \
src/cpp/system_env/setenvvar.cpp \
src/cpp/system_env/sci_home.cpp \
src/cpp/types/$(DEPDIR)/$(am__dirstamp)
src/cpp/types/libsciast_la-callable.lo: src/cpp/types/$(am__dirstamp) \
src/cpp/types/$(DEPDIR)/$(am__dirstamp)
+src/cpp/types/libsciast_la-addfunction.lo: \
+ src/cpp/types/$(am__dirstamp) \
+ src/cpp/types/$(DEPDIR)/$(am__dirstamp)
src/cpp/system_env/$(am__dirstamp):
@$(MKDIR_P) src/cpp/system_env
@: > src/cpp/system_env/$(am__dirstamp)
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/system_env/$(DEPDIR)/libsciast_la-sci_path.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/system_env/$(DEPDIR)/libsciast_la-sci_tmpdir.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/system_env/$(DEPDIR)/libsciast_la-setenvvar.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/types/$(DEPDIR)/libsciast_la-addfunction.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/types/$(DEPDIR)/libsciast_la-arrayof.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/types/$(DEPDIR)/libsciast_la-bool.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/cpp/types/$(DEPDIR)/libsciast_la-callable.Plo@am__quote@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/types/libsciast_la-callable.lo `test -f 'src/cpp/types/callable.cpp' || echo '$(srcdir)/'`src/cpp/types/callable.cpp
+src/cpp/types/libsciast_la-addfunction.lo: src/cpp/types/addfunction.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/types/libsciast_la-addfunction.lo -MD -MP -MF src/cpp/types/$(DEPDIR)/libsciast_la-addfunction.Tpo -c -o src/cpp/types/libsciast_la-addfunction.lo `test -f 'src/cpp/types/addfunction.cpp' || echo '$(srcdir)/'`src/cpp/types/addfunction.cpp
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/cpp/types/$(DEPDIR)/libsciast_la-addfunction.Tpo src/cpp/types/$(DEPDIR)/libsciast_la-addfunction.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/cpp/types/addfunction.cpp' object='src/cpp/types/libsciast_la-addfunction.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o src/cpp/types/libsciast_la-addfunction.lo `test -f 'src/cpp/types/addfunction.cpp' || echo '$(srcdir)/'`src/cpp/types/addfunction.cpp
+
src/cpp/system_env/libsciast_la-dynamic_module.lo: src/cpp/system_env/dynamic_module.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsciast_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT src/cpp/system_env/libsciast_la-dynamic_module.lo -MD -MP -MF src/cpp/system_env/$(DEPDIR)/libsciast_la-dynamic_module.Tpo -c -o src/cpp/system_env/libsciast_la-dynamic_module.lo `test -f 'src/cpp/system_env/dynamic_module.cpp' || echo '$(srcdir)/'`src/cpp/system_env/dynamic_module.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/cpp/system_env/$(DEPDIR)/libsciast_la-dynamic_module.Tpo src/cpp/system_env/$(DEPDIR)/libsciast_la-dynamic_module.Plo
<ClCompile Include="src\cpp\system_env\sci_path.cpp" />
<ClCompile Include="src\cpp\system_env\sci_tmpdir.cpp" />
<ClCompile Include="src\cpp\system_env\setenvvar.cpp" />
+ <ClCompile Include="src\cpp\types\addfunction.cpp" />
<ClCompile Include="src\cpp\types\arrayof.cpp" />
<ClCompile Include="src\cpp\types\bool.cpp" />
<ClCompile Include="src\cpp\types\callable.cpp" />
<ClCompile Include="src\cpp\system_env\configvariable_interface.cpp">
<Filter>Source Files\system_env</Filter>
</ClCompile>
+ <ClCompile Include="src\cpp\types\addfunction.cpp">
+ <Filter>Source Files\types</Filter>
+ </ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
--- /dev/null
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
+* Copyright (C) 2014 - Scilab Enterprises - Cedric Delamarre
+*
+* 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
+*
+*/
+
+#ifndef __ADDFUNCTION_H__
+#define __ADDFUNCTION_H__
+
+#include "dynlib_ast.h"
+
+EXTERN_AST void addCFunction(wchar_t* _wstName, OLDGW_FUNC _pFunc, wchar_t* _wstModule);
+
+#endif // __ADDFUNCTION_H__
--- /dev/null
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
+* Copyright (C) 2014 - Scilab Enterprises - Cedric Delamarre
+*
+* 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
+*
+*/
+
+#include "context.hxx"
+#include "function.hxx"
+
+extern "C"
+{
+#include "addfunction.h"
+}
+
+void addCFunction(wchar_t* _wstName, OLDGW_FUNC _pFunc, wchar_t* _wstModule)
+{
+ symbol::Context::getInstance()->addFunction(types::Function::createFunction(_wstName, _pFunc, _wstModule));
+}
// Headers are dispatched in the source tree
if isdir(SCI+"/modules/core/includes/") then
defaultModulesCHeader=[ "core", "mexlib","api_scilab","output_stream","localization", "dynamic_link", "threads", "string", "console"];
- defaultKernelCHeader=[ "ast" "exps" "operations" "parse" "symbol" "system_env" "types"];
+ defaultKernelCHeader=[ "analysis" "ast" "exps" "operations" "parse" "symbol" "system_env" "types"];
defaultModulesFHeader=[ "core" ];
ScilabTreeFound=%t
ScilabTreeFound=%t
end
+ global cppCompilation;
+ if cppCompilation then
+ cflags = cflags + " --std=c++11";
+ end
+ clearglobal cppCompilation;
+
if ( ilib_verbose() <> 0 & ScilabTreeFound <> %t) then
mprintf(gettext("%s: Warning: Scilab has not been able to find where the Scilab sources are. Please submit a bug report on http://bugzilla.scilab.org/\n"),"ilib_compile");
end
if ( nt <> 3 ) then
error(msprintf(gettext("%s: Wrong size for input argument #%d: %d expected.\n"),"ilib_gen_gateway",2,3));
end
- [gate,names] = new_names(table);
-
+ [gate,names,cppCompilation] = new_names(table);
+ global cppCompilation;
//generate cpp interface file
- t = [
- "#include ""context.hxx""";
- "#include """ + tname + ".hxx""";
- "extern ""C""";
- "{";
- "#include """ + tname + ".h""";
- "}";
- "";
- "#define MODULE_NAME L""" + tname + """";
- "";
- "int " + tname + "(wchar_t* _pwstFuncName)";
- "{";
- " if(wcscmp(_pwstFuncName, L""" + table(:,1) + """) == 0){ " + "symbol::Context::getInstance()->addFunction(types::Function::createFunction(L""" + table(:,1) + """, &" + names(:) + ", MODULE_NAME)); }";
- "";
- " return 1;";
- "}"];
+ if cppCompilation then
+ t = [
+ "#include ""context.hxx""";
+ "#include ""cpp_gateway_prototype.hxx""";
+ "#include """ + tname + ".hxx""";
+ "extern ""C""";
+ "{";
+ "#include """ + tname + ".h""";
+ "}";
+ "";
+ "#define MODULE_NAME L""" + tname + """";
+ "";
+ "int " + tname + "(wchar_t* _pwstFuncName)";
+ "{";
+ " if(wcscmp(_pwstFuncName, L""" + table(:,1) + """) == 0){ " + "symbol::Context::getInstance()->addFunction(types::Function::createFunction(L""" + table(:,1) + """, &" + names(:) + ", MODULE_NAME)); }";
+ "";
+ " return 1;";
+ "}"];
+ else
+ t = [
+ "#include <wchar.h>";
+ "#include """ + tname + ".hxx""";
+ "extern ""C""";
+ "{";
+ "#include """ + tname + ".h""";
+ "#include ""addfunction.h""";
+ "}";
+ "";
+ "#define MODULE_NAME L""" + tname + """";
+ "";
+ "int " + tname + "(wchar_t* _pwstFuncName)";
+ "{";
+ " if(wcscmp(_pwstFuncName, L""" + table(:,1) + """) == 0){ " + "addCFunction(L""" + table(:,1) + """, &" + names(:) + ", MODULE_NAME); }";
+ "";
+ " return 1;";
+ "}"];
+ end
gateway_filename(1) = path + tname + ".cpp";
// first check if we have already a gateway
"#ifndef __" + TNAME + "_GW_HXX__";
"#define __" + TNAME + "_GW_HXX__";
"";
- "#include ""c_gateway_prototype.h""";
- "#include ""cpp_gateway_prototype.hxx""";
- "";
"#ifdef _MSC_VER";
"#ifdef " + TNAME + "_GW_EXPORTS";
"#define " + TNAME + "_GW_IMPEXP __declspec(dllexport)";
//=============================================================================
// new_names only used by ilib_gen_gateway
//=============================================================================
-function [gate,names] = new_names(table)
+function [gate,names,cppCompilation] = new_names(table)
// change names according to types
+ cppCompilation = %f;
[mt,nt] = size(table);
gate = [""];
gate = gate(ones(mt, 2));
names(i) = "C2F(" + table(i,2) + ")";
gate(i, 1) = "C_GATEWAY_PROTOTYPE(" + names(i) + ");";
case "cppsci" then
+ cppCompilation = %t;
names(i) = table(i,2);
gate(i, 2) = "CPP_GATEWAY_PROTOTYPE(" + names(i) + ");";
case "direct" then