diff options
author | Shashank | 2017-05-29 12:40:26 +0530 |
---|---|---|
committer | Shashank | 2017-05-29 12:40:26 +0530 |
commit | 0345245e860375a32c9a437c4a9d9cae807134e9 (patch) | |
tree | ad51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/commons/src | |
download | scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.gz scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.bz2 scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.zip |
CMSCOPE changed
Diffstat (limited to 'modules/commons/src')
67 files changed, 7293 insertions, 0 deletions
diff --git a/modules/commons/src/c/.deps/.dirstamp b/modules/commons/src/c/.deps/.dirstamp new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/modules/commons/src/c/.deps/.dirstamp diff --git a/modules/commons/src/c/.deps/libscicommons_la-fileutils.Plo b/modules/commons/src/c/.deps/libscicommons_la-fileutils.Plo new file mode 100755 index 000000000..c21e9a33e --- /dev/null +++ b/modules/commons/src/c/.deps/libscicommons_la-fileutils.Plo @@ -0,0 +1,148 @@ +src/c/libscicommons_la-fileutils.lo: src/c/fileutils.c \ + /usr/include/stdc-predef.h /usr/include/string.h /usr/include/features.h \ + /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h /usr/include/xlocale.h \ + /usr/include/x86_64-linux-gnu/bits/string.h \ + /usr/include/x86_64-linux-gnu/bits/string2.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h /usr/include/stdlib.h \ + /usr/include/x86_64-linux-gnu/bits/string3.h \ + /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/dirent.h \ + /usr/include/x86_64-linux-gnu/bits/dirent.h \ + /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h ../../modules/core/includes/MALLOC.h \ + ../../modules/core/includes/sci_mem_alloc.h \ + /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h \ + ../../modules/core/includes/PATH_MAX.h \ + ../../modules/fileio/includes/scicurdir.h /usr/include/wchar.h \ + /usr/include/stdio.h /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/wchar.h \ + /usr/include/x86_64-linux-gnu/bits/wchar2.h \ + ../../modules/fileio/includes/dynlib_fileio.h \ + ../../modules/core/includes/warningmode.h \ + ../../modules/core/includes/BOOL.h ../../modules/core/includes/machine.h \ + includes/fileutils.h + +/usr/include/stdc-predef.h: + +/usr/include/string.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h: + +/usr/include/xlocale.h: + +/usr/include/x86_64-linux-gnu/bits/string.h: + +/usr/include/x86_64-linux-gnu/bits/string2.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/string3.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/time.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/sigset.h: + +/usr/include/x86_64-linux-gnu/bits/time.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/dirent.h: + +/usr/include/x86_64-linux-gnu/bits/dirent.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +../../modules/core/includes/MALLOC.h: + +../../modules/core/includes/sci_mem_alloc.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/alloca.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +../../modules/core/includes/PATH_MAX.h: + +../../modules/fileio/includes/scicurdir.h: + +/usr/include/wchar.h: + +/usr/include/stdio.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/wchar.h: + +/usr/include/x86_64-linux-gnu/bits/wchar2.h: + +../../modules/fileio/includes/dynlib_fileio.h: + +../../modules/core/includes/warningmode.h: + +../../modules/core/includes/BOOL.h: + +../../modules/core/includes/machine.h: + +includes/fileutils.h: diff --git a/modules/commons/src/c/.dirstamp b/modules/commons/src/c/.dirstamp new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/modules/commons/src/c/.dirstamp diff --git a/modules/commons/src/c/.libs/libscicommons_la-fileutils.o b/modules/commons/src/c/.libs/libscicommons_la-fileutils.o Binary files differnew file mode 100755 index 000000000..30852875a --- /dev/null +++ b/modules/commons/src/c/.libs/libscicommons_la-fileutils.o diff --git a/modules/commons/src/c/DllmainCommons.c b/modules/commons/src/c/DllmainCommons.c new file mode 100755 index 000000000..d15e7f02b --- /dev/null +++ b/modules/commons/src/c/DllmainCommons.c @@ -0,0 +1,34 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan CORNET + * + * 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.1-en.txt + * + */ + +#include <windows.h> +#include "dynlib_commons.h" +/*--------------------------------------------------------------------------*/ +#pragma comment(lib,"../../../../bin/libintl.lib") +/*--------------------------------------------------------------------------*/ +COMMONS_IMPEXP int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved) +{ + switch (reason) + { + case DLL_PROCESS_ATTACH: + break; + case DLL_PROCESS_DETACH: + break; + case DLL_THREAD_ATTACH: + break; + case DLL_THREAD_DETACH: + break; + } + return 1; +} +/*--------------------------------------------------------------------------*/ + diff --git a/modules/commons/src/c/commons.rc b/modules/commons/src/c/commons.rc new file mode 100755 index 000000000..1c1e8a806 --- /dev/null +++ b/modules/commons/src/c/commons.rc @@ -0,0 +1,95 @@ +// Microsoft Visual C++ generated resource script. +// + + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// French (France) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA) +#ifdef _WIN32 +LANGUAGE LANG_FRENCH, SUBLANG_FRENCH +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 5,5,2,0 + PRODUCTVERSION 5,5,2,0 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040c04b0" + BEGIN + VALUE "FileDescription", "commons module" + VALUE "FileVersion", "5, 5, 2, 0" + VALUE "InternalName", "commons module" + VALUE "LegalCopyright", "Copyright (C) 2017" + VALUE "OriginalFilename", "commons.dll" + VALUE "ProductName", "commons module" + VALUE "ProductVersion", "5, 5, 2, 0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x40c, 1200 + END +END + +#endif // French (France) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/modules/commons/src/c/commons.vcxproj b/modules/commons/src/c/commons.vcxproj new file mode 100755 index 000000000..30b836e09 --- /dev/null +++ b/modules/commons/src/c/commons.vcxproj @@ -0,0 +1,288 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{ECA09A1E-6D12-4A47-92E1-A671C181DF77}</ProjectGuid> + <RootNamespace>commons</RootNamespace> + <Keyword>Win32Proj</Keyword> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + <WholeProgramOptimization>false</WholeProgramOptimization> + <PlatformToolset>v110</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + <PlatformToolset>v110</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + <WholeProgramOptimization>false</WholeProgramOptimization> + <PlatformToolset>v110</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>MultiByte</CharacterSet> + <PlatformToolset>v110</PlatformToolset> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)bin\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)bin\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)bin\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)bin\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">sci$(ProjectName)</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">sci$(ProjectName)</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">sci$(ProjectName)</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">sci$(ProjectName)</TargetName> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <AdditionalOptions>%(AdditionalOptions)</AdditionalOptions> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>.;../../includes;../../../core/includes;../../../output_stream/includes;../../../dynamic_link/includes;../../../dynamic_link/src/c;../../../localization/includes;../../../core/src/c;../../../../libs/intl;../../../commons/includes;../../../api_scilab/includes;../../../fileio/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;COMMONS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>true</MinimalRebuild> + <BasicRuntimeChecks>Default</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <CompileAs>Default</CompileAs> + <DisableSpecificWarnings>4251</DisableSpecificWarnings> + </ClCompile> + <PreLinkEvent> + <Message>Make dependencies</Message> + <Command>lib /DEF:"$(ProjectDir)core_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core.lib" 1>NUL 2>NUL +</Command> + </PreLinkEvent> + <Link> + <AdditionalDependencies>core.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(SolutionDir)bin\sci$(ProjectName).dll</OutputFile> + <ModuleDefinitionFile> + </ModuleDefinitionFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + <ImportLibrary>$(SolutionDir)bin\$(ProjectName).lib</ImportLibrary> + <TargetMachine>MachineX86</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>.;../../includes;../../../core/includes;../../../output_stream/includes;../../../dynamic_link/includes;../../../dynamic_link/src/c;../../../localization/includes;../../../core/src/c;../../../../libs/intl;../../../commons/includes;../../../api_scilab/includes;../../../fileio/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;_DEBUG;_WINDOWS;_USRDLL;COMMONS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>true</MinimalRebuild> + <BasicRuntimeChecks>Default</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <CompileAs>Default</CompileAs> + <DisableSpecificWarnings>4251</DisableSpecificWarnings> + </ClCompile> + <PreLinkEvent> + <Message>Make dependencies</Message> + <Command>lib /DEF:"$(ProjectDir)core_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core.lib" 1>NUL 2>NUL +</Command> + </PreLinkEvent> + <Link> + <AdditionalDependencies>core.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(SolutionDir)bin\sci$(ProjectName).dll</OutputFile> + <ModuleDefinitionFile> + </ModuleDefinitionFile> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + <ImportLibrary>$(SolutionDir)bin\$(ProjectName).lib</ImportLibrary> + <TargetMachine>MachineX64</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <AdditionalOptions>%(AdditionalOptions)</AdditionalOptions> + <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + <WholeProgramOptimization>false</WholeProgramOptimization> + <AdditionalIncludeDirectories>.;../../includes;../../../core/includes;../../../output_stream/includes;../../../dynamic_link/includes;../../../dynamic_link/src/c;../../../localization/includes;../../../core/src/c;../../../../libs/intl;../../../commons/includes;../../../api_scilab/includes;../../../fileio/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;COMMONS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <CompileAs>Default</CompileAs> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + <DisableSpecificWarnings>4251</DisableSpecificWarnings> + </ClCompile> + <PreLinkEvent> + <Message>Make dependencies</Message> + <Command>lib /DEF:"$(ProjectDir)core_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core.lib" 1>NUL 2>NUL +</Command> + </PreLinkEvent> + <Link> + <AdditionalDependencies>core.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(SolutionDir)bin\sci$(ProjectName).dll</OutputFile> + <ModuleDefinitionFile> + </ModuleDefinitionFile> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <LinkTimeCodeGeneration> + </LinkTimeCodeGeneration> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + <ImportLibrary>$(SolutionDir)bin\$(ProjectName).lib</ImportLibrary> + <TargetMachine>MachineX86</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + <WholeProgramOptimization>false</WholeProgramOptimization> + <AdditionalIncludeDirectories>.;../../includes;../../../core/includes;../../../output_stream/includes;../../../dynamic_link/includes;../../../dynamic_link/src/c;../../../localization/includes;../../../core/src/c;../../../../libs/intl;../../../commons/includes;../../../api_scilab/includes;../../../fileio/includes;../../../../java/jdk/include;../../../../java/jdk/include/win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;FORDLL;NDEBUG;_WINDOWS;_USRDLL;COMMONS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <CompileAs>Default</CompileAs> + <MultiProcessorCompilation>true</MultiProcessorCompilation> + <DisableSpecificWarnings>4251</DisableSpecificWarnings> + </ClCompile> + <PreLinkEvent> + <Message>Make dependencies</Message> + <Command>lib /DEF:"$(ProjectDir)core_import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /OUT:"$(ProjectDir)core.lib" 1>NUL 2>NUL +</Command> + </PreLinkEvent> + <Link> + <AdditionalDependencies>core.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(SolutionDir)bin\sci$(ProjectName).dll</OutputFile> + <ModuleDefinitionFile> + </ModuleDefinitionFile> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <LinkTimeCodeGeneration> + </LinkTimeCodeGeneration> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + <ImportLibrary>$(SolutionDir)bin\$(ProjectName).lib</ImportLibrary> + <TargetMachine>MachineX64</TargetMachine> + <CLRUnmanagedCodeCheck>true</CLRUnmanagedCodeCheck> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\jni\CommonFileUtils_wrap.c" /> + <ClCompile Include="..\jni\FindIconHelper.cpp" /> + <ClCompile Include="..\jni\GiwsException.cpp" /> + <ClCompile Include="DllmainCommons.c" /> + <ClCompile Include="..\jni\ScilabCommons_wrap.c" /> + <ClCompile Include="fileutils.c" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\..\includes\dynlib_commons.h" /> + <ClInclude Include="..\..\includes\fileutils.h" /> + <ClInclude Include="..\jni\FindIconHelper.hxx" /> + <ClInclude Include="..\jni\GiwsException.hxx" /> + </ItemGroup> + <ItemGroup> + <None Include="..\..\locales\commons.pot" /> + <None Include="core_import.def" /> + <None Include="..\..\commons.iss" /> + <None Include="..\..\Makefile.am" /> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="commons.rc" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\..\..\Visual-Studio-settings\rename-vc-files\rename-vc-files.vcxproj"> + <Project>{dd8a0506-8d31-4cf8-856a-c10ece9c13a4}</Project> + <ReferenceOutputAssembly>false</ReferenceOutputAssembly> + </ProjectReference> + <ProjectReference Include="..\..\..\fileio\fileio.vcxproj"> + <Project>{4fc72d4a-80ee-4b1a-8724-0201c1a35621}</Project> + </ProjectReference> + <ProjectReference Include="..\..\..\localization\src\localization.vcxproj"> + <Project>{ecffeb0c-1eda-45ee-9a10-b18143852e17}</Project> + </ProjectReference> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/modules/commons/src/c/commons.vcxproj.filters b/modules/commons/src/c/commons.vcxproj.filters new file mode 100755 index 000000000..fef01a270 --- /dev/null +++ b/modules/commons/src/c/commons.vcxproj.filters @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{5849332e-4973-499d-862f-7a39742056fa}</UniqueIdentifier> + <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{5be8576b-880f-404a-88e9-cef1ec43fc27}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl</Extensions> + </Filter> + <Filter Include="localization"> + <UniqueIdentifier>{0a1ff52e-6ad2-4cc6-836f-4a83515837a6}</UniqueIdentifier> + </Filter> + <Filter Include="Libraries Dependencies"> + <UniqueIdentifier>{4fceabb3-16e6-4b09-b030-2fa8a88333c5}</UniqueIdentifier> + </Filter> + <Filter Include="Libraries Dependencies\Imports"> + <UniqueIdentifier>{74ee55e7-359a-4343-a41b-2f9465ad02eb}</UniqueIdentifier> + </Filter> + <Filter Include="Resource File"> + <UniqueIdentifier>{8d469228-8f88-42ba-8476-e9e09a737537}</UniqueIdentifier> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="DllmainCommons.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\jni\ScilabCommons_wrap.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="fileutils.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\jni\CommonFileUtils_wrap.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\jni\GiwsException.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\jni\FindIconHelper.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\..\includes\dynlib_commons.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\..\includes\fileutils.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\jni\GiwsException.hxx"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\jni\FindIconHelper.hxx"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> + <ItemGroup> + <None Include="core_import.def"> + <Filter>Libraries Dependencies\Imports</Filter> + </None> + <None Include="..\..\commons.iss" /> + <None Include="..\..\Makefile.am" /> + <None Include="..\..\locales\commons.pot"> + <Filter>localization</Filter> + </None> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="commons.rc"> + <Filter>Resource File</Filter> + </ResourceCompile> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/modules/commons/src/c/commons_f_Import.def b/modules/commons/src/c/commons_f_Import.def new file mode 100755 index 000000000..9b2c29707 --- /dev/null +++ b/modules/commons/src/c/commons_f_Import.def @@ -0,0 +1,7 @@ +LIBRARY commons_f.dll + + +EXPORTS +; --------------------------------------- +; commons_f +; --------------------------------------- diff --git a/modules/commons/src/c/core_Import.def b/modules/commons/src/c/core_Import.def new file mode 100755 index 000000000..d8d687c14 --- /dev/null +++ b/modules/commons/src/c/core_Import.def @@ -0,0 +1,21 @@ + LIBRARY core.dll + + +EXPORTS +; +;core +; +getSCIHOME +getTMPDIR +setieee +setformat +getieee +getformat +getformatwidth +getScilabVersionMajor +getScilabVersionMinor +getScilabVersionMaintenance +getScilabVersionTimestamp +getScilabVersionAsString +MyHeapAlloc +MyHeapFree diff --git a/modules/commons/src/c/fileutils.c b/modules/commons/src/c/fileutils.c new file mode 100755 index 000000000..e24f28cd0 --- /dev/null +++ b/modules/commons/src/c/fileutils.c @@ -0,0 +1,142 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - DIGITEO - Calixte DENIZET + * + * 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.1-en.txt + * + */ + +#include <string.h> + +#ifdef _MSC_VER +#include <Windows.h> +#include <stdio.h> +#include "charEncoding.h" +#else +#include <sys/types.h> +#include <dirent.h> +#endif + +#include "MALLOC.h" + +#include "PATH_MAX.h" +#include "scicurdir.h" +#include "warningmode.h" + +#include "fileutils.h" + +/*--------------------------------------------------------------------------*/ +#ifdef _MSC_VER +int isEmptyDirectory(char *dirName) +{ + wchar_t *wcpath = NULL; + wchar_t wdirpath[PATH_MAX + FILENAME_MAX + 1]; + HANDLE hFile; + WIN32_FIND_DATAW FileInformation; + int ret = 1; + + wcpath = to_wide_string(dirName); + swprintf(wdirpath, wcslen(wcpath) + 2 + 1, L"%s\\*", wcpath); + FREE(wcpath); + + hFile = FindFirstFileW(wdirpath, &FileInformation); + + if (hFile == INVALID_HANDLE_VALUE) + { + return 0; + } + + do + { + if (!wcscmp(FileInformation.cFileName, L".") || !wcscmp(FileInformation.cFileName, L"..")) + { + continue; + } + + ret = 0; + break; + } + while (FindNextFileW(hFile, &FileInformation) == TRUE); + + FindClose(hFile); + + return ret; +} + +/*--------------------------------------------------------------------------*/ +#else +/*--------------------------------------------------------------------------*/ +int isEmptyDirectory(char *dirName) +{ + DIR *dir = NULL; + +#ifdef __USE_LARGEFILE64 + struct dirent64 *ptr; + struct dirent64 *result; +#else + struct dirent *ptr; + struct dirent *result; +#endif + int ret = 1; + + dir = opendir(dirName); + if (dir == NULL) + { + return 0; + } + +#ifdef __USE_LARGEFILE64 + ptr = MALLOC(sizeof(struct dirent64) + (PATH_MAX + 1)); +#else + ptr = MALLOC(sizeof(struct dirent) + (PATH_MAX + 1)); +#endif + if (ptr == NULL) + { + closedir(dir); + return 0; + } + +#ifdef __USE_LARGEFILE64 + while ((readdir64_r(dir, ptr, &result) == 0) && (result != NULL)) +#else + while ((readdir_r(dir, ptr, &result) == 0) && (result != NULL)) +#endif + { + if (!strcmp(ptr->d_name, ".") || !strcmp(ptr->d_name, "..")) + { + continue; + } + + ret = 0; + break; + } + + FREE(ptr); + closedir(dir); + + return ret; +} +#endif +/*--------------------------------------------------------------------------*/ +char *getCWD() +{ + int err = 0; + char *str; + + str = scigetcwd(&err); + + if (err) + { + return NULL; + } + else + { + return str; + } +} + +/*--------------------------------------------------------------------------*/ diff --git a/modules/commons/src/c/libscicommons_la-fileutils.lo b/modules/commons/src/c/libscicommons_la-fileutils.lo new file mode 100755 index 000000000..ec3a49094 --- /dev/null +++ b/modules/commons/src/c/libscicommons_la-fileutils.lo @@ -0,0 +1,12 @@ +# src/c/libscicommons_la-fileutils.lo - a libtool object file +# Generated by libtool (GNU libtool) 2.4.2 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/libscicommons_la-fileutils.o' + +# Name of the non-PIC object +non_pic_object=none + diff --git a/modules/commons/src/fortran/.deps/.dirstamp b/modules/commons/src/fortran/.deps/.dirstamp new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/modules/commons/src/fortran/.deps/.dirstamp diff --git a/modules/commons/src/fortran/.dirstamp b/modules/commons/src/fortran/.dirstamp new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/modules/commons/src/fortran/.dirstamp diff --git a/modules/commons/src/fortran/.libs/empty.o b/modules/commons/src/fortran/.libs/empty.o Binary files differnew file mode 100755 index 000000000..9089a3379 --- /dev/null +++ b/modules/commons/src/fortran/.libs/empty.o diff --git a/modules/commons/src/fortran/commons_Import.def b/modules/commons/src/fortran/commons_Import.def new file mode 100755 index 000000000..b4085ee2a --- /dev/null +++ b/modules/commons/src/fortran/commons_Import.def @@ -0,0 +1,4 @@ +LIBRARY commons.dll + + +EXPORTS diff --git a/modules/commons/src/fortran/commons_f.def b/modules/commons/src/fortran/commons_f.def new file mode 100755 index 000000000..f794e656e --- /dev/null +++ b/modules/commons/src/fortran/commons_f.def @@ -0,0 +1,9 @@ +LIBRARY commons_f.dll + + +EXPORTS +; --------------------------------------- +; commons_f +; --------------------------------------- + empty_ +
\ No newline at end of file diff --git a/modules/commons/src/fortran/commons_f.rc b/modules/commons/src/fortran/commons_f.rc new file mode 100755 index 000000000..86fabecd7 --- /dev/null +++ b/modules/commons/src/fortran/commons_f.rc @@ -0,0 +1,95 @@ +// Microsoft Visual C++ generated resource script. +// + + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// French (France) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA) +#ifdef _WIN32 +LANGUAGE LANG_FRENCH, SUBLANG_FRENCH +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 5,5,2,0 + PRODUCTVERSION 5,5,2,0 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040c04b0" + BEGIN + VALUE "FileDescription", "commons_f module" + VALUE "FileVersion", "5, 5, 2, 0" + VALUE "InternalName", "commons_f module" + VALUE "LegalCopyright", "Copyright (C) 2017" + VALUE "OriginalFilename", "commons_f.dll" + VALUE "ProductName", "commons_f module" + VALUE "ProductVersion", "5, 5, 2, 0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x40c, 1200 + END +END + +#endif // French (France) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/modules/commons/src/fortran/commons_f.vfproj b/modules/commons/src/fortran/commons_f.vfproj new file mode 100755 index 000000000..8c31b3646 --- /dev/null +++ b/modules/commons/src/fortran/commons_f.vfproj @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8"?> +<VisualStudioProject ProjectType="typeDynamicLibrary" ProjectCreator="Intel Fortran" Keyword="Dll" Version="11.0" ProjectIdGuid="{F4C4DE36-43F4-4E44-AE82-BA757CFF4970}"> + <Platforms> + <Platform Name="Win32"/> + <Platform Name="x64"/></Platforms> + <Configurations> + <Configuration Name="Debug|Win32" OutputDirectory="$(SolutionDir)bin\" IntermediateDirectory="$(ProjectDir)$(ConfigurationName)" DeleteExtensionsOnClean="*.obj;*.mod;*.pdb;*.asm;*.map;*.dyn;*.dpi;*.tmp;*.log;*.ilk;*.dll;$(TargetPath)" ConfigurationType="typeDynamicLibrary"> + <Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" Optimization="optimizeDisabled" AdditionalIncludeDirectories="../../../core/includes" PreprocessorDefinitions="WIN32;FORDLL" AlternateParameterSyntax="false" F77RuntimeCompatibility="true" FPS4Libs="false" CallingConvention="callConventionCRef" ExternalNameUnderscore="true" ModulePath="$(INTDIR)/" ObjectFile="$(INTDIR)/" RuntimeLibrary="rtMultiThreadedDebugDLL"/> + <Tool Name="VFLinkerTool" OutputFile="$(SolutionDir)bin\$(ProjectName).dll" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" ModuleDefinitionFile="commons_f.def" GenerateDebugInformation="true" SubSystem="subSystemWindows" ImportLibrary="$(SolutionDir)bin\$(ProjectName).lib" LinkDLL="true" AdditionalDependencies="core.lib commons.lib"/> + <Tool Name="VFResourceCompilerTool"/> + <Tool Name="VFMidlTool" SuppressStartupBanner="true" HeaderFileName="$(InputName).h" TypeLibraryName="$(IntDir)/$(InputName).tlb"/> + <Tool Name="VFCustomBuildTool"/> + <Tool Name="VFPreLinkEventTool" CommandLine="cd $(IntDir) +for %%f in (*.obj) do ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n commons_f.dll %%f >nul +copy *.def commons_f.def >nul +copy commons_f.def ..\commons_f.vcdef >nul +del *.def >nul +cd .. +copy commons_f_header.def+commons_f.vcdef commons_f.def >nul" Description="Build commons.def"/> + <Tool Name="VFPreBuildEventTool" CommandLine="lib /DEF:"$(InputDir)core_import.def" /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:"$(InputDir)core.lib" 1>NUL 2>NUL +lib /DEF:"$(InputDir)commons_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:"$(InputDir)commons.lib" 1>NUL 2>NUL" Description="Build Dependencies"/> + <Tool Name="VFPostBuildEventTool"/> + <Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration> + <Configuration Name="Release|Win32" OutputDirectory="$(SolutionDir)bin\" IntermediateDirectory="$(ProjectDir)$(ConfigurationName)" DeleteExtensionsOnClean="*.obj;*.mod;*.pdb;*.asm;*.map;*.dyn;*.dpi;*.tmp;*.log;*.ilk;*.dll;$(TargetPath)" ConfigurationType="typeDynamicLibrary"> + <Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" Parallelization="true" AdditionalIncludeDirectories="../../../core/includes" PreprocessorDefinitions="WIN32;FORDLL" AlternateParameterSyntax="false" F77RuntimeCompatibility="true" FPS4Libs="false" CallingConvention="callConventionCRef" ExternalNameUnderscore="true" ModulePath="$(INTDIR)/" ObjectFile="$(INTDIR)/" RuntimeLibrary="rtMultiThreadedDLL"/> + <Tool Name="VFLinkerTool" OutputFile="$(SolutionDir)bin\$(ProjectName).dll" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" ModuleDefinitionFile="commons_f.def" SubSystem="subSystemWindows" ImportLibrary="$(SolutionDir)bin\$(ProjectName).lib" LinkDLL="true" AdditionalDependencies="core.lib commons.lib"/> + <Tool Name="VFResourceCompilerTool"/> + <Tool Name="VFMidlTool" SuppressStartupBanner="true" HeaderFileName="$(InputName).h" TypeLibraryName="$(IntDir)/$(InputName).tlb"/> + <Tool Name="VFCustomBuildTool"/> + <Tool Name="VFPreLinkEventTool" CommandLine="cd $(IntDir) +for %%f in (*.obj) do ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n commons_f.dll %%f >nul +copy *.def commons_f.def >nul +copy commons_f.def ..\commons_f.vcdef >nul +del *.def >nul +cd .. +copy commons_f_header.def+commons_f.vcdef commons_f.def >nul" Description="Build commons.def"/> + <Tool Name="VFPreBuildEventTool" CommandLine="lib /DEF:"$(InputDir)core_import.def" /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:"$(InputDir)core.lib" 1>NUL 2>NUL +lib /DEF:"$(InputDir)commons_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:"$(InputDir)commons.lib" 1>NUL 2>NUL" Description="Build Dependencies"/> + <Tool Name="VFPostBuildEventTool"/> + <Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration> + <Configuration Name="Debug|x64" OutputDirectory="$(SolutionDir)bin\" IntermediateDirectory="$(ProjectDir)$(ConfigurationName)" DeleteExtensionsOnClean="*.obj;*.mod;*.pdb;*.asm;*.map;*.dyn;*.dpi;*.tmp;*.log;*.ilk;*.dll;$(TargetPath)" ConfigurationType="typeDynamicLibrary"> + <Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" Optimization="optimizeDisabled" AdditionalIncludeDirectories="../../../core/includes" PreprocessorDefinitions="WIN32;FORDLL" AlternateParameterSyntax="false" F77RuntimeCompatibility="true" FPS4Libs="false" CallingConvention="callConventionCRef" ExternalNameUnderscore="true" ModulePath="$(INTDIR)/" ObjectFile="$(INTDIR)/" RuntimeLibrary="rtMultiThreadedDebugDLL"/> + <Tool Name="VFLinkerTool" OutputFile="$(SolutionDir)bin\$(ProjectName).dll" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" ModuleDefinitionFile="commons_f.def" GenerateDebugInformation="true" SubSystem="subSystemWindows" ImportLibrary="$(SolutionDir)bin\$(ProjectName).lib" LinkDLL="true" AdditionalDependencies="core.lib commons.lib"/> + <Tool Name="VFResourceCompilerTool"/> + <Tool Name="VFMidlTool" SuppressStartupBanner="true" HeaderFileName="$(InputName).h" TypeLibraryName="$(IntDir)/$(InputName).tlb"/> + <Tool Name="VFCustomBuildTool"/> + <Tool Name="VFPreLinkEventTool" CommandLine="cd $(IntDir) +for %%f in (*.obj) do ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n commons_f.dll %%f >nul +copy *.def commons_f.def >nul +copy commons_f.def ..\commons_f.vcdef >nul +del *.def >nul +cd .. +copy commons_f_header.def+commons_f.vcdef commons_f.def >nul" Description="Build commons.def"/> + <Tool Name="VFPreBuildEventTool" CommandLine="lib /DEF:"$(InputDir)core_import.def" /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:"$(InputDir)core.lib" 1>NUL 2>NUL +lib /DEF:"$(InputDir)commons_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:"$(InputDir)commons.lib" 1>NUL 2>NUL" Description="Build Dependencies"/> + <Tool Name="VFPostBuildEventTool"/> + <Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration> + <Configuration Name="Release|x64" OutputDirectory="$(SolutionDir)bin\" IntermediateDirectory="$(ProjectDir)$(ConfigurationName)" DeleteExtensionsOnClean="*.obj;*.mod;*.pdb;*.asm;*.map;*.dyn;*.dpi;*.tmp;*.log;*.ilk;*.dll;$(TargetPath)" ConfigurationType="typeDynamicLibrary"> + <Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" Parallelization="true" AdditionalIncludeDirectories="../../../core/includes" PreprocessorDefinitions="WIN32;FORDLL" AlternateParameterSyntax="false" F77RuntimeCompatibility="true" FPS4Libs="false" CallingConvention="callConventionCRef" ExternalNameUnderscore="true" ModulePath="$(INTDIR)/" ObjectFile="$(INTDIR)/" RuntimeLibrary="rtMultiThreadedDLL"/> + <Tool Name="VFLinkerTool" OutputFile="$(SolutionDir)bin\$(ProjectName).dll" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" ModuleDefinitionFile="commons_f.def" SubSystem="subSystemWindows" ImportLibrary="$(SolutionDir)bin\$(ProjectName).lib" LinkDLL="true" AdditionalDependencies="core.lib commons.lib"/> + <Tool Name="VFResourceCompilerTool"/> + <Tool Name="VFMidlTool" SuppressStartupBanner="true" HeaderFileName="$(InputName).h" TypeLibraryName="$(IntDir)/$(InputName).tlb"/> + <Tool Name="VFCustomBuildTool"/> + <Tool Name="VFPreLinkEventTool" CommandLine="cd $(IntDir) +for %%f in (*.obj) do ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n commons_f.dll %%f >nul +copy *.def commons_f.def >nul +copy commons_f.def ..\commons_f.vcdef >nul +del *.def >nul +cd .. +copy commons_f_header.def+commons_f.vcdef commons_f.def >nul" Description="Build commons.def"/> + <Tool Name="VFPreBuildEventTool" CommandLine="lib /DEF:"$(InputDir)core_import.def" /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:"$(InputDir)core.lib" 1>NUL 2>NUL +lib /DEF:"$(InputDir)commons_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:"$(InputDir)commons.lib" 1>NUL 2>NUL" Description="Build Dependencies"/> + <Tool Name="VFPostBuildEventTool"/> + <Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration></Configurations> + <Files> + <Filter Name="Header Files" Filter="fi;fd"/> + <Filter Name="Library Dependencies"> + <File RelativePath=".\commons_Import.def"/> + <File RelativePath=".\core_import.def"/></Filter> + <Filter Name="Resource Files" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"> + <File RelativePath=".\commons_f.rc"/></Filter> + <Filter Name="Source Files" Filter="f90;for;f;fpp;ftn;def;odl;idl"> + <File RelativePath=".\empty.f"/></Filter> + <File RelativePath="..\..\..\..\bin\blasplus.lib"/> + <File RelativePath="..\..\sci_gateway\commons_gateway.xml"/> + <File RelativePath="..\..\..\..\bin\lapack.lib"/> + <File RelativePath="..\..\Makefile.am"/></Files> + <Globals/></VisualStudioProject> diff --git a/modules/commons/src/fortran/core_Import.def b/modules/commons/src/fortran/core_Import.def new file mode 100755 index 000000000..a7eb8597c --- /dev/null +++ b/modules/commons/src/fortran/core_Import.def @@ -0,0 +1,7 @@ + LIBRARY core.dll + + +EXPORTS +; +;core +; diff --git a/modules/commons/src/fortran/empty.f b/modules/commons/src/fortran/empty.f new file mode 100755 index 000000000..86c84a66e --- /dev/null +++ b/modules/commons/src/fortran/empty.f @@ -0,0 +1,12 @@ +c Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +c Copyright (C) DIGITEO - 2010 - Allan CORNET +c +c This file must be used under the terms of the CeCILL. +c This source file is licensed as described in the file COPYING, which +c you should have received as part of this distribution. The terms +c are also available at +c http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + subroutine empty() + end + diff --git a/modules/commons/src/fortran/empty.lo b/modules/commons/src/fortran/empty.lo new file mode 100755 index 000000000..71b28f276 --- /dev/null +++ b/modules/commons/src/fortran/empty.lo @@ -0,0 +1,12 @@ +# src/fortran/empty.lo - a libtool object file +# Generated by libtool (GNU libtool) 2.4.2 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/empty.o' + +# Name of the non-PIC object +non_pic_object=none + diff --git a/modules/commons/src/java/org/scilab/modules/commons/CommonFileUtils.java b/modules/commons/src/java/org/scilab/modules/commons/CommonFileUtils.java new file mode 100755 index 000000000..6fd850641 --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/CommonFileUtils.java @@ -0,0 +1,38 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.7 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.scilab.modules.commons; + + +/** + * Some file utils + * @author Calixte DENIZET + * @copyright DIGITEO 2011 + */ +public class CommonFileUtils { + + /** + * Constructor + */ + protected CommonFileUtils() { + throw new UnsupportedOperationException(); + } + public static int isEmptyDirectory(String dirName) { + return CommonFileUtilsJNI.isEmptyDirectory(dirName); + } + + + /** + * Get the current working directory + * @return the Scilab CWD + */ + public static String getCWD() { + return CommonFileUtilsJNI.getCWD(); + } + +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/CommonFileUtilsJNI.java b/modules/commons/src/java/org/scilab/modules/commons/CommonFileUtilsJNI.java new file mode 100755 index 000000000..bebe7c277 --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/CommonFileUtilsJNI.java @@ -0,0 +1,49 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.7 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.scilab.modules.commons; + + +/* It is generated code. Disable checkstyle */ +//CHECKSTYLE:OFF +/** + * Some file utils + * @author Calixte DENIZET + * @copyright DIGITEO 2011 + */ +public class CommonFileUtilsJNI { + + /** + * Constructor + */ + protected CommonFileUtilsJNI() { + throw new UnsupportedOperationException(); + } + + static { + try { + System.loadLibrary("scicommons"); + } catch (SecurityException e) { + System.err.println("A security manager exists and does not allow the loading of the specified dynamic library."); + System.err.println(e.getLocalizedMessage()); + System.exit(-1); + } catch (UnsatisfiedLinkError e) { + System.err.println("The native library scicommons does not exist or cannot be found."); + if (System.getenv("CONTINUE_ON_JNI_ERROR") == null) { + System.err.println(e.getLocalizedMessage()); + System.err.println("Current java.library.path is : " + System.getProperty("java.library.path")); + System.exit(-1); + } else { + System.err.println("Continuing anyway because of CONTINUE_ON_JNI_ERROR"); + } + } + } + + public final static native int isEmptyDirectory(String jarg1); + public final static native String getCWD(); +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/OS.java b/modules/commons/src/java/org/scilab/modules/commons/OS.java new file mode 100755 index 000000000..1b584b82d --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/OS.java @@ -0,0 +1,79 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Allan CORNET + * Copyright (C) 2011 - DIGITEO - Clement DAVID + * + * 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.1-en.txt + * + */ + +package org.scilab.modules.commons; + +/** + * Operating Systems utility class + */ +public enum OS { + WINDOWS { + /** + * {@inheritDoc} + */ + @Override + public Object getVersion() { + return Double.valueOf(System.getProperty("os.version")); + } + }, + MAC { + /** + * {@inheritDoc} + */ + @Override + public Object getVersion() { + final String[] numbers = System.getProperty("os.version").split( + "\\."); + + int[] ret = new int[numbers.length]; + for (int i = 0; i < numbers.length; i++) { + ret[i] = Integer.parseInt(numbers[i]); + } + return ret; + } + }, + UNIX; + + /** + * @return the OS type + */ + public static OS get() { + final String name = System.getProperty("os.name").toLowerCase(); + + if (name.contains("windows")) { + return OS.WINDOWS; + } else if (name.contains("mac")) { + return MAC; + } else { + return UNIX; + } + } + + /** + * @return the OS version + */ + public Object getVersion() { + return null; + } + + public static String getVersionName() { + switch (get()) { + case WINDOWS: + return "Windows"; + case MAC: + return "Mac"; + default: + return "Linux"; + } + } +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/ScilabCommons.java b/modules/commons/src/java/org/scilab/modules/commons/ScilabCommons.java new file mode 100755 index 000000000..44b8d810a --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/ScilabCommons.java @@ -0,0 +1,125 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.7 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.scilab.modules.commons; + + +/** + * Some commons values from Scilab engine to Java + * @author Sylvestre LEDRU + * @copyright DIGITEO 2010 + */ +public class ScilabCommons { + + /** + * Constructor + */ + protected ScilabCommons() { + throw new UnsupportedOperationException(); + } + + /** + * Get SCIHOME variable from Scilab + * @return SCIHOME value + */ + public static String getSCIHOME() { + return ScilabCommonsJNI.getSCIHOME(); + } + + public static String getTMPDIR() { + return ScilabCommonsJNI.getTMPDIR(); + } + + public static String getlanguage() { + return ScilabCommonsJNI.getlanguage(); + } + + public static String createtempfilename(String prefix, int bShortFormat) { + return ScilabCommonsJNI.createtempfilename(prefix, bShortFormat); + } + + public static int getieee() { + return ScilabCommonsJNI.getieee(); + } + + public static void setieee(int arg0) { + ScilabCommonsJNI.setieee(arg0); + } + + + /** + * Set the Scilab ieee mode + */ + public static void setformat(String format, int width) { + ScilabCommonsJNI.setformat(format, width); + } + + + /** + * returns the Scilab format ("v" or "e") + * @return format + */ + public static String getformat() { + return ScilabCommonsJNI.getformat(); + } + + + /** + * returns the Scilab format width + * @return format + */ + public static int getformatwidth() { + return ScilabCommonsJNI.getformatwidth(); + } + + + /** + * returns the Scilab version major number + * @return version major + */ + public static int getScilabVersionMajor() { + return ScilabCommonsJNI.getScilabVersionMajor(); + } + + + /** + * returns the Scilab version minor number + * @return version minor + */ + public static int getScilabVersionMinor() { + return ScilabCommonsJNI.getScilabVersionMinor(); + } + + + /** + * returns the Scilab version maintenance number + * @return version maintenance + */ + public static int getScilabVersionMaintenance() { + return ScilabCommonsJNI.getScilabVersionMaintenance(); + } + + + /** + * returns the Scilab version timestamp number + * @return version timestamp + */ + public static int getScilabVersionTimestamp() { + return ScilabCommonsJNI.getScilabVersionTimestamp(); + } + + + /** + * returns the Scilab version as string + * @return version Scilab version as a string + */ + public static String getScilabVersionAsString() { + return ScilabCommonsJNI.getScilabVersionAsString(); + } + +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/ScilabCommonsJNI.java b/modules/commons/src/java/org/scilab/modules/commons/ScilabCommonsJNI.java new file mode 100755 index 000000000..5e49a18ba --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/ScilabCommonsJNI.java @@ -0,0 +1,61 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.7 + * + * Do not make changes to this file unless you know what you are doing--modify + * the SWIG interface file instead. + * ----------------------------------------------------------------------------- */ + +package org.scilab.modules.commons; + + +/* It is generated code. Disable checkstyle */ +//CHECKSTYLE:OFF +/** + * Some commons values from Scilab engine to Java + * @author Sylvestre LEDRU + * @copyright DIGITEO 2010 + */ +public class ScilabCommonsJNI { + + /** + * Constructor + */ + protected ScilabCommonsJNI() { + throw new UnsupportedOperationException(); + } + + static { + try { + System.loadLibrary("scicommons"); + } catch (SecurityException e) { + System.err.println("A security manager exists and does not allow the loading of the specified dynamic library."); + System.err.println(e.getLocalizedMessage()); + System.exit(-1); + } catch (UnsatisfiedLinkError e) { + System.err.println("The native library scicommons does not exist or cannot be found."); + if (System.getenv("CONTINUE_ON_JNI_ERROR") == null) { + System.err.println(e.getLocalizedMessage()); + System.err.println("Current java.library.path is : " + System.getProperty("java.library.path")); + System.exit(-1); + } else { + System.err.println("Continuing anyway because of CONTINUE_ON_JNI_ERROR"); + } + } + } + + public final static native String getSCIHOME(); + public final static native String getTMPDIR(); + public final static native String getlanguage(); + public final static native String createtempfilename(String jarg1, int jarg2); + public final static native int getieee(); + public final static native void setieee(int jarg1); + public final static native void setformat(String jarg1, int jarg2); + public final static native String getformat(); + public final static native int getformatwidth(); + public final static native int getScilabVersionMajor(); + public final static native int getScilabVersionMinor(); + public final static native int getScilabVersionMaintenance(); + public final static native int getScilabVersionTimestamp(); + public final static native String getScilabVersionAsString(); +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/ScilabCommonsUtils.java b/modules/commons/src/java/org/scilab/modules/commons/ScilabCommonsUtils.java new file mode 100755 index 000000000..917df11e9 --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/ScilabCommonsUtils.java @@ -0,0 +1,187 @@ +/* + * Scilab (http://www.scilab.org/) - This file is part of Scilab + * Copyright (C) 2011 - Calixte DENIZET + * + * 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.1-en.txt + * + */ + +package org.scilab.modules.commons; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.lang.reflect.Method; +import java.math.BigInteger; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + * Basic utils + * @author Calixte DENIZET + */ +public final class ScilabCommonsUtils { + + private static final int BUFFERSIZE = 8192; + private static Thread scilabThread; + + private static MessageDigest MD5; + static { + try { + MD5 = MessageDigest.getInstance("MD5"); + } catch (NoSuchAlgorithmException e) { + System.err.println(e); + MD5 = null; + } + } + + public static int[] getScilabVersions() { + return new int[] {ScilabCommons.getScilabVersionMajor(), ScilabCommons.getScilabVersionMinor(), ScilabCommons.getScilabVersionMaintenance(), ScilabCommons.getScilabVersionTimestamp()}; + } + + public static String getScilabVersion() { + return ScilabCommons.getScilabVersionMajor() + "." + ScilabCommons.getScilabVersionMinor() + "." + ScilabCommons.getScilabVersionMaintenance(); + } + + public static String getScilabVersionAsString() { + return ScilabCommons.getScilabVersionAsString().replaceFirst("scilab-", ""); + } + + + + /** + * Get a MD5 string of the input string + * @param str the string to convert + * @return the MD5 representation of str + */ + public static String getMD5(String str) { + if (MD5 == null) { + return null; + } + + try { + byte[] bytes = MD5.digest(str.getBytes("UTF-8")); + return new BigInteger(1, bytes).toString(16); + } catch (Exception e) { + return null; + } + } + + /** + * Copy a file + * @param inFile src file + * @param outFile dest file + * @return true if the operation succeeded + */ + public static boolean copyFile(File inFile, File outFile) { + FileInputStream in = null; + FileOutputStream out = null; + boolean success = false; + + try { + in = new FileInputStream(inFile); + out = new FileOutputStream(outFile); + byte[] buffer = new byte[BUFFERSIZE]; + int n; + + while ((n = in.read(buffer)) != -1) { + out.write(buffer, 0, n); + } + out.flush(); + success = true; + } catch (IOException e) { + System.err.println("Error in copying file " + inFile.getAbsolutePath() + " to " + outFile.getAbsolutePath()); + System.err.println(e); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + System.err.println(e); + } + } + if (out != null) { + try { + out.close(); + } catch (IOException e) { + System.err.println(e); + } + } + } + + return success; + } + + /** + * Replace ~ by user home, SCI by Scilab main directory, ... + * @param baseDir the base directory + * @return correct base directory + */ + public static String getCorrectedPath(String path) { + String sciUnixStyle = ""; + path = path.trim(); + String pathLinux = path.replace("\\", "/"); + if (path != null && !path.isEmpty()) { + if (path.startsWith("~" + "/") || path.equals("~")) { + sciUnixStyle = ScilabConstants.USERHOME.replace("\\", "/"); + return path.replaceFirst("~", sciUnixStyle); + } else if (path.startsWith("SCI/") || path.equals("SCI")) { + try { + sciUnixStyle = ScilabConstants.SCI.getCanonicalPath().replace("\\", "/"); + } catch (IOException e) { + sciUnixStyle = ScilabConstants.SCI.getAbsolutePath().replace("\\", "/"); + } + return pathLinux.replaceFirst("SCI", sciUnixStyle).replace("/", File.separator); + } else if (path.startsWith("SCIHOME/") || path.equals("SCIHOME")) { + sciUnixStyle = ScilabConstants.SCIHOME.toString().replace("\\", "/"); + return path.replaceFirst("SCIHOME", sciUnixStyle).replace("/", File.separator); + } else if (path.startsWith("TMPDIR/") || path.equals("TMPDIR")) { + sciUnixStyle = ScilabCommons.getTMPDIR().replace("\\", "/"); + return path.replaceFirst("TMPDIR", sciUnixStyle).replace("/", File.separator); + } + } + + return path; + } + + /** + * Load on use + * @param str the action + */ + public static void loadOnUse(String str) { + try { + Class jvmLoadClassPathClass = Class.forName("org.scilab.modules.jvm.LoadClassPath"); + Method loadOnUseMethod = jvmLoadClassPathClass.getDeclaredMethod("loadOnUse", new Class[] { String.class }); + loadOnUseMethod.invoke(null, str); + } catch (java.lang.ClassNotFoundException ex) { + System.err.println("Could not find the Scilab class to load dependency: " + ex); + } catch (java.lang.NoSuchMethodException ex) { + System.err.println("Could not find the Scilab method to load dependency: " + ex); + } catch (java.lang.IllegalAccessException ex) { + System.err.println("Could not access to the Scilab method to load dependency: " + ex); + } catch (java.lang.reflect.InvocationTargetException ex) { + System.err.println("Could not invoke the Scilab method to load dependency: " + ex); + } + } + + /** + * Set the scilab thread as the current thread + * Called from org.scilab.modules.core.Scilab::executeInitialHooks called itself + * in GetCommandLine.c just after the first display of the prompt. + */ + public static void registerScilabThread() { + scilabThread = Thread.currentThread(); + } + + /** + * @return true if Thread.currentThread() is the main Scilab thread + */ + public static boolean isScilabThread() { + return scilabThread != null && scilabThread == Thread.currentThread(); + } +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/ScilabConstants.java b/modules/commons/src/java/org/scilab/modules/commons/ScilabConstants.java new file mode 100755 index 000000000..aeac7e097 --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/ScilabConstants.java @@ -0,0 +1,93 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Clement DAVID + * Copyright (C) 2010 - DIGITEO - Sylvestre LEDRU + * + * 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.1-en.txt + * + */ + +package org.scilab.modules.commons; + +import java.io.File; + +/** + * Define all the constants used on a Scilab + */ +public class ScilabConstants { + + /* Scilab */ + + /** + * The tmp directory + * This code used to be System.getenv("TMPDIR"). + * However, this was failing with Javasci to due architecture constraints + * Javasci (Java) => Call_scilab (C) => Scilab engine (C) + * => Java VM (graphics, xcos, etc). + * In this case, the Java VM is started by Javasci. + * Since, the TMPDIR env variable is set by Call_Scilab (the second step), + * the environnement in the Java world has not TMPDIR + */ + public static final File TMPDIR; + + /** + * The SCI directory (Scilab root directory) + */ + public static final File SCI; + + /** + * The SCI configuration directory (Scilab home directory) + */ + public static final File SCIHOME; + + /** + * The user home directory + */ + public static final String USERHOME = System.getProperty("user.home"); + + /** Escape double quote symbol */ + public static final char QUOTE = '\"'; + + /** 2 is for GUI **/ + public static int mode; + + /* + * Static constructor + */ + static { + String value; + + value = ScilabCommons.getTMPDIR(); + if (value == null || value.isEmpty()) { + value = System.getProperty("java.io.tmpdir"); + } + TMPDIR = new File(value); + + value = System.getenv("SCI"); + SCI = new File(value).getAbsoluteFile(); + + value = ScilabCommons.getSCIHOME(); + if (value == null || "".equals(value) || "empty_SCIHOME".equals(value)) { + // Empty java value is TMPDIR + SCIHOME = TMPDIR; + } else { + SCIHOME = new File(value); + } + } + + /** This class is a static singleton, thus it must not be instantiated */ + protected ScilabConstants() { } + + public static void setMode(int mode) { + ScilabConstants.mode = mode; + } + + public static boolean isGUI() { + return ScilabConstants.mode == 2; + } + +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/ScilabGeneralPrefs.java b/modules/commons/src/java/org/scilab/modules/commons/ScilabGeneralPrefs.java new file mode 100755 index 000000000..2da76cab8 --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/ScilabGeneralPrefs.java @@ -0,0 +1,137 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET + * + * 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.1-en.txt + * + */ + +package org.scilab.modules.commons; + +import java.awt.Font; +import java.lang.reflect.Method; + +import org.w3c.dom.Document; + +import org.scilab.modules.commons.xml.XConfiguration; +import org.scilab.modules.commons.xml.XConfigurationEvent; +import org.scilab.modules.commons.xml.XConfigurationListener; +import static org.scilab.modules.commons.xml.XConfiguration.XConfAttribute; +import org.scilab.modules.localization.WindowsDefaultLanguage; + +public class ScilabGeneralPrefs implements XConfigurationListener { + + private static final String ENV_PATH = "//general/body/environment"; + private static final String FONT_PATH = "//fonts/body/fonts"; + private static final String LANG_PATH = "//general/body/languages"; + private static final ScilabGeneralPrefs instance = new ScilabGeneralPrefs(); + private static Font desktopFont; + + private ScilabGeneralPrefs() { } + + public static ScilabGeneralPrefs getInstance() { + return instance; + } + + public static void openPreferences(String path) { + try { + Class prefs = ClassLoader.getSystemClassLoader().loadClass("org.scilab.modules.preferences.ScilabPreferences"); + Method open = prefs.getDeclaredMethod("openPreferences", String.class); + open.invoke(null, path); + } catch (ClassNotFoundException e) { + // Nothing displayed (always occurs in MN mode) + } catch (Exception e) { + System.err.println(e); + } + } + + public void configurationChanged(XConfigurationEvent e) { + boolean all = e.getModifiedPaths().contains("ALL"); + if (all || e.getModifiedPaths().contains(ENV_PATH)) { + Document doc = XConfiguration.getXConfigurationDocument(); + GeneralEnvironment ge = XConfiguration.get(GeneralEnvironment.class, doc, ENV_PATH)[0]; + ScilabCommons.setieee(ge.code); + ScilabCommons.setformat(ge.format, ge.width); + } + + if (e.getModifiedPaths().contains(LANG_PATH)) { + Document doc = XConfiguration.getXConfigurationDocument(); + Language language = XConfiguration.get(Language.class, doc, LANG_PATH)[0]; + WindowsDefaultLanguage.setdefaultlanguage(language.lang); + } + + if (all || e.getModifiedPaths().contains(FONT_PATH)) { + desktopFont = null; + } + } + + public static Font getDesktopFont() { + if (desktopFont == null) { + Document doc = XConfiguration.getXConfigurationDocument(); + DesktopFont df = XConfiguration.get(DesktopFont.class, doc, FONT_PATH)[0]; + desktopFont = df.font; + } + + return desktopFont; + } + + @XConfAttribute + private static class DesktopFont { + + public Font font; + + private DesktopFont() { } + + @XConfAttribute(tag = "fonts", attributes = {"font-face", "font-name", "font-size", "system"}) + private void set(String fontFace, String fontName, int fontSize, boolean useSystemFont) { + if (useSystemFont) { + this.font = new Font("monospaced", Font.PLAIN, 13); + } else { + this.font = new Font(fontName, Font.PLAIN, fontSize); + int style = Font.PLAIN; + if (fontFace.contains("bold")) { + style = style | Font.BOLD; + } else if (fontFace.contains("italic")) { + style = style | Font.ITALIC; + } + if (style != Font.PLAIN) { + this.font = this.font.deriveFont(style); + } + } + } + } + + @XConfAttribute + private static class GeneralEnvironment { + + public int code; + public String format; + public int width; + + private GeneralEnvironment() { } + + @XConfAttribute(attributes = {"fpe", "printing-format", "width"}) + private void set(int fpe, String format, int width) { + this.code = fpe; + this.format = format; + this.width = Math.min(Math.max(0, width), 25); + } + } + + @XConfAttribute + private static class Language { + + public String lang; + + private Language() { } + + @XConfAttribute(attributes = {"lang"}) + private void set(String lang) { + this.lang = lang; + } + } +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/gui/FindIconHelper.java b/modules/commons/src/java/org/scilab/modules/commons/gui/FindIconHelper.java new file mode 100755 index 000000000..cb0ed05d2 --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/gui/FindIconHelper.java @@ -0,0 +1,320 @@ +package org.scilab.modules.commons.gui; + +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.TreeSet; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.imageio.ImageIO; +import javax.swing.Icon; +import javax.swing.ImageIcon; + +import org.scilab.modules.commons.OS; +import org.scilab.modules.commons.ScilabCommonsUtils; + +public final class FindIconHelper { + /** + * Look for the icon associated with the name. + * + * @param icon + * the name to look for + * @return the image icon path + */ + public static String findIcon(final String icon) { + return findIcon(icon, "16x16", true); + } + + public static String findIcon(final String icon, boolean defaultValue) { + return findIcon(icon, "16x16", defaultValue); + } + + /** + * Look for the icon associated with the name for a specific module. + * + * @param name + * the name to look for + * @param size + * the size to look for + * @return the loaded image icon + */ + public static String findIcon(final String icon, final String size) { + return findIcon(icon, size, true); + } + + public static String findIcon(final String icon, final String size, boolean defaultValue) { + if (icon == null || icon.isEmpty()) { + return null; + } + + final String filename = findIconHelper(icon, size, "Tango"); + if (filename != null) { + if (LOG.isLoggable(Level.FINER)) { + LOG.finer(icon + '[' + size + ']' + " i " + filename); + } + return filename; + } + + final String fallback = lookupFallbackIcon(icon); + if (defaultValue && fallback == null) { + LOG.warning("Unable to found icon: " + icon + '[' + size + ']'); + return System.getenv("SCI") + "/modules/gui/images/icons/16x16/status/error.png"; + } + + if (LOG.isLoggable(Level.FINER)) { + LOG.finer(icon + '[' + size + ']' + " f " + fallback); + } + return fallback; + } + + private static String findIconHelper(final String icon, final String size, final String theme) { + try { + final String filename = lookupIcon(icon, size, theme); + if (filename != null) { + return filename; + } + } catch (IOException e) { + } + + /* + * always look for hicolor and then empty theme in case of invalid + * theme. + */ + if (!theme.isEmpty() && theme != HICOLOR) { + return findIconHelper(icon, size, HICOLOR); + } else if (!theme.isEmpty()) { + return findIconHelper(icon, size, ""); + } else { + return null; + } + } + + private static final Logger LOG = Logger.getLogger(FindIconHelper.class.getName()); + + private static final String SCI = System.getenv("SCI"); + private static final String SEP = System.getProperty("file.separator"); + private static final String DOT = "."; + private static final String HICOLOR = "hicolor"; + private static final List<String> ICONS_EXTENSIONS = Arrays.asList("png", "svg", "xpm"); + private static final HashMap<File, TreeSet<String>> THEME_SUBDIR_CACHE = new HashMap<File, TreeSet<String>>(); + + private static final FileFilter DIR_FILTER; + private static final List<String> THEME_BASENAME; + static { + DIR_FILTER = new FileFilter() { + @Override + public boolean accept(File pathname) { + return pathname.isDirectory(); + } + }; + THEME_BASENAME = new ArrayList<String>(); + + /* + * Linux specific path + */ + switch (OS.get()) { + case UNIX: + THEME_BASENAME.add("~/.icons"); + THEME_BASENAME.add("/usr/share/icons"); + THEME_BASENAME.add("/usr/share/pixmaps"); + + THEME_BASENAME.add(SCI + "/../icons"); + break; + + case MAC: + THEME_BASENAME.add(SCI + "/../icons"); + break; + + default: + break; + } + + /* + * Scilab embedded icons + */ + + final ArrayList<File> dirs = new ArrayList<File>(); + + // Append SCI/desktop and SCI/modules/xxx to the dirs + dirs.add(new File(SCI + SEP + "desktop")); + dirs.addAll(Arrays.asList(new File(SCI + SEP + "modules").listFiles(DIR_FILTER))); + for (File m : dirs) { + final File icons = new File(m, "images" + SEP + "icons"); + final boolean iconsIsDir = icons.isDirectory(); + + // add dirs/images/icons/ to the base name + if (iconsIsDir) { + THEME_BASENAME.add(icons.getAbsolutePath()); + } + + // add dirs/images/icons/*/* to the base name + if (iconsIsDir) { + for (File s : icons.listFiles(DIR_FILTER)) { + for (File category : s.listFiles(DIR_FILTER)) { + THEME_BASENAME.add(category.getAbsolutePath()); + } + } + } + } + } + + private static String lookupIcon(final String iconname, final String size, final String theme) throws IOException { + if(iconname.contains("<html>")) { + return null; + } + + for (String directory : THEME_BASENAME) { + final File themeDir = new File(directory + SEP + theme); + if (!themeDir.exists() || !themeDir.isDirectory()) { + continue; + } + + /* + * FIXME: implement an index.theme reader, for now we are parsing + * the file path to get the information + */ + for (String extension : ICONS_EXTENSIONS) { + final File f = new File(themeDir, iconname + DOT + extension); + + if (f.exists()) { + return f.getCanonicalPath(); + } + } + /* + * Create the theme subdirs + */ + final int themeDirLen = themeDir.getCanonicalPath().length(); + final TreeSet<String> themeSubdirs = findThemeSubdir(themeDir, themeDirLen); + + /* + * Create a theme subdirs for a specific size + */ + final TreeSet<String> sizedSubDirs = findSizedSubdirs(size, themeSubdirs); + + /* + * Look for the icon + */ + for (final String s : sizedSubDirs) { + for (String extension : ICONS_EXTENSIONS) { + final File f = new File(themeDir, s + SEP + iconname + DOT + extension); + + if (f.exists()) { + return f.getCanonicalPath(); + } + } + } + } + + return null; + } + + private static TreeSet<String> findSizedSubdirs(final String size, final TreeSet<String> themeSubdirs) { + final TreeSet<String> sizedSubDirs = new TreeSet<String>(); + for (String subdir : themeSubdirs) { + if (subdir.startsWith(size)) { + sizedSubDirs.add(subdir); + } + } + return sizedSubDirs; + } + + private static TreeSet<String> findThemeSubdir(final File themeDir, final int themeDirLen) throws IOException { + final TreeSet<String> cache = THEME_SUBDIR_CACHE.get(themeDir); + if (cache != null) { + return cache; + } + + final TreeSet<String> themeSubdirs = new TreeSet<String>(); + + final LinkedList<File> dirs = new LinkedList<File>(Arrays.asList(themeDir.listFiles(DIR_FILTER))); + while (!dirs.isEmpty()) { + final File d = dirs.poll(); + + File[] allDirs = d.listFiles(DIR_FILTER); + if (allDirs == null) { + continue; + } + + final List<File> sub = Arrays.asList(allDirs); + if (sub.isEmpty()) { + final String s = d.getCanonicalPath(); + + themeSubdirs.add(s.substring(themeDirLen + 1)); + } else { + dirs.addAll(sub); + } + } + + THEME_SUBDIR_CACHE.put(themeDir, themeSubdirs); + return themeSubdirs; + } + + public static String findImage(final String image) { + return findImage(image, true); + } + + public static String findImage(final String image, boolean defaulValue) { + + File file = new File(ScilabCommonsUtils.getCorrectedPath(image)); + if (file.exists()) { + return file.getAbsolutePath(); + } + + for (String directory : THEME_BASENAME) { + final File f = new File(directory + SEP + image); + if (f.exists()) { + return f.getAbsolutePath(); + } + } + + return findIcon(image, defaulValue); + } + + private static String lookupFallbackIcon(final String icon) { + for (String directory : THEME_BASENAME) { + for (String extension : ICONS_EXTENSIONS) { + final File f = new File(directory + SEP + icon + DOT + extension); + if (f.exists()) { + return f.getAbsolutePath(); + } + } + } + + return null; + } + + public static void addThemePath(String path) { + if (THEME_BASENAME.contains(path)) { + return; + } + + THEME_BASENAME.add(path); + } + + + public static Icon loadIcon(String icon) throws IOException { + String iconFile = findIcon(icon, false); + if (iconFile == null) { + iconFile = ""; + } + + //add item in listbox + File file = new File(iconFile); + if (file.exists() == false) { + String filename = findImage(iconFile, false); + if (filename == null) { + filename = ""; + } + + file = new File(filename); + } + + return new ImageIcon(ImageIO.read(file)); + } +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/gui/ScilabCaret.java b/modules/commons/src/java/org/scilab/modules/commons/gui/ScilabCaret.java new file mode 100755 index 000000000..d31f2f219 --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/gui/ScilabCaret.java @@ -0,0 +1,183 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * 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.1-en.txt + * + */ + +package org.scilab.modules.commons.gui; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Rectangle; +import java.awt.event.FocusEvent; +import java.awt.event.MouseEvent; + +import javax.swing.UIManager; +import javax.swing.text.BadLocationException; +import javax.swing.text.DefaultCaret; +import javax.swing.text.JTextComponent; + +/** + * This class handles the tabulation + * @author Calixte DENIZET + */ +public class ScilabCaret extends DefaultCaret { + + private static final long serialVersionUID = 8230195712653828841L; + + private static Color selectionColor; + private static Color inactiveSelectionColor; + + private JTextComponent editor; + + private boolean overwriteMode; + private boolean mustAdjustVisibility = true; + + /** + * Constructor + * @param editor the editor where the caret lives + */ + public ScilabCaret(JTextComponent editor) { + super(); + this.editor = editor; + setSelectionColor(editor.getSelectionColor(), UIManager.getColor("TextComponent.selectionBackgroundInactive")); + } + + /** + * {@inheritDoc} + */ + protected void adjustVisibility(Rectangle nloc) { + if (mustAdjustVisibility) { + super.adjustVisibility(nloc); + } + } + + public void setMustAdjustVisibility(boolean mustAdjustVisibility) { + this.mustAdjustVisibility = mustAdjustVisibility; + } + + public boolean getMustAdjustVisibility() { + return this.mustAdjustVisibility; + } + + /** + * @param active the color of the selection when it is active + * @param inactive the color of the selection when it is inactive + */ + public void setSelectionColor(Color active, Color inactive) { + selectionColor = active; + inactiveSelectionColor = inactive; + if (inactiveSelectionColor == null) { + float r = 0.6f * selectionColor.getRed() / 255f + 0.4f * Color.LIGHT_GRAY.getRed() / 255f; + float g = 0.6f * selectionColor.getGreen() / 255f + 0.4f * Color.LIGHT_GRAY.getGreen() / 255f; + float b = 0.6f * selectionColor.getBlue() / 255f + 0.4f * Color.LIGHT_GRAY.getBlue() / 255f; + inactiveSelectionColor = new Color(r, g, b); + } + } + + /** + * @return the color of the selection + */ + public Color getSelectionColor() { + return selectionColor; + } + + /** + * @return the color of the inactive selection + */ + public Color getInactiveSelectionColor() { + return inactiveSelectionColor; + } + + /** + * {@inheritDoc} + */ + public void setSelectionVisible(boolean vis) { + super.setSelectionVisible(true); + } + + /** + * {@inheritDoc} + */ + public void focusGained(FocusEvent e) { + editor.setSelectionColor(selectionColor); + editor.repaint(); + super.focusGained(e); + } + + /** + * {@inheritDoc} + */ + public void focusLost(FocusEvent e) { + editor.setSelectionColor(inactiveSelectionColor); + editor.repaint(); + super.focusLost(e); + } + + /** + * {@inheritDoc} + */ + public void mouseDragged(MouseEvent e) { + editor.setSelectionColor(selectionColor); + super.mouseDragged(e); + } + + /** + * @param overwriteMode if true, the caret will be drawn as solid rectangle + */ + public void setOverwriteMode(boolean overwriteMode) { + this.overwriteMode = overwriteMode; + } + + /** + * {@inheritDoc} + */ + public void paint(Graphics g) { + if (isVisible() && overwriteMode) { + Rectangle r = null; + int pos = editor.getCaretPosition(); + try { + r = editor.modelToView(pos); + } catch (BadLocationException e) { } + if (r != null && (r.width != 0 || r.height != 0)) { + if ( (x != r.x) || (y != r.y) ) { + repaint(); + x = r.x; + y = r.y; + height = r.height; + width = editor.getFontMetrics(editor.getFont()).charWidth('W') + 1; + } else { + g.setColor(editor.getCaretColor()); + g.setXORMode(editor.getBackground()); + g.fillRect(x, y, width, height); + } + } + } else { + super.paint(g); + } + } + + /** + * {@inheritDoc} + */ + protected synchronized void damage(Rectangle r) { + if (overwriteMode) { + if (r == null) { + return; + } + + x = r.x; + y = r.y; + height = r.height; + repaint(); + } else { + super.damage(r); + } + } +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/gui/ScilabGUIUtilities.java b/modules/commons/src/java/org/scilab/modules/commons/gui/ScilabGUIUtilities.java new file mode 100755 index 000000000..4de02d283 --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/gui/ScilabGUIUtilities.java @@ -0,0 +1,51 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - Calixte DENIZET + * + * 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.1-en.txt + * + */ + +package org.scilab.modules.commons.gui; + +import java.awt.event.WindowEvent; +import java.awt.event.WindowFocusListener; + +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +/** + * GUI utilities + * @author Calixte DENIZET + */ +public class ScilabGUIUtilities { + + /** + * Bring a window to the front + * @param window the window to bring to the front + */ + public static void toFront(final JFrame window) { + WindowFocusListener listener = new WindowFocusListener() { + + public void windowGainedFocus(WindowEvent e) { + window.setAlwaysOnTop(true); + } + + public void windowLostFocus(WindowEvent e) { + window.setAlwaysOnTop(false); + window.removeWindowFocusListener(this); + } + }; + window.addWindowFocusListener(listener); + window.toFront(); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + window.requestFocus(); + } + }); + } +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/gui/ScilabKeyStroke.java b/modules/commons/src/java/org/scilab/modules/commons/gui/ScilabKeyStroke.java new file mode 100755 index 000000000..cd94e66be --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/gui/ScilabKeyStroke.java @@ -0,0 +1,87 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * 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.1-en.txt + * + */ + +package org.scilab.modules.commons.gui; + +import java.awt.GraphicsEnvironment; +import java.awt.Toolkit; +import java.awt.event.KeyEvent; + +import javax.swing.KeyStroke; + +import org.scilab.modules.commons.OS; + +/** + * Class to handle the keystroke and the default menu shortcut key. + */ +public final class ScilabKeyStroke { + + private static final String oSKey; + + static { + String key = ""; + int mask; + if (!GraphicsEnvironment.isHeadless()) { + mask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); + } else { + switch (OS.get()) { + case MAC: + mask = KeyEvent.META_MASK; + break; + default: + mask = KeyEvent.CTRL_MASK; + } + } + + if ((mask & KeyEvent.CTRL_MASK) != 0) { + key += " Ctrl"; + } + if ((mask & KeyEvent.META_MASK) != 0) { + key += " Meta"; + } + if ((mask & KeyEvent.SHIFT_MASK) != 0) { + key += " Shift"; + } + if ((mask & KeyEvent.ALT_MASK) != 0) { + key += " Alt"; + } + if ((mask & KeyEvent.ALT_GRAPH_MASK) != 0) { + key += " AltGraph"; + } + + if (key.length() > 0 && key.startsWith(" ")) { + key = key.substring(1); + } + + oSKey = key; + } + + /** + * Get the OS meta key: usually Ctrl for Linux or Windows OS, and Meta (Apple) for Mac OS + * @return the OS special meta key + */ + public static final String getOSMetaKey() { + return oSKey; + } + + /** + * @param key String representation of the key "control A" or + * "OSSCKEY A" where OSSCKEY is replaced by the default meta key of + * the OS. + * @return the corresponding key + */ + public static KeyStroke getKeyStroke(String key) { + String str = key.replaceAll("OSSCKEY", oSKey.toLowerCase()); + + return KeyStroke.getKeyStroke(str); + } +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/gui/ScilabLAF.java b/modules/commons/src/java/org/scilab/modules/commons/gui/ScilabLAF.java new file mode 100755 index 000000000..c6127fc21 --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/gui/ScilabLAF.java @@ -0,0 +1,26 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2014 - Scialb Enterprises - Calixte DENIZET + * + * 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.1-en.txt + * + */ + +package org.scilab.modules.commons.gui; + +import javax.swing.AbstractButton; + +public final class ScilabLAF { + + public static void setDefaultProperties(AbstractButton button) { + if (button != null) { + button.setFocusable(false); + button.setContentAreaFilled(true); + button.setOpaque(false); + } + } +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/jarsci/Handler.java b/modules/commons/src/java/org/scilab/modules/commons/jarsci/Handler.java new file mode 100755 index 000000000..1154b7c5c --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/jarsci/Handler.java @@ -0,0 +1,46 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET + * + * 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.1-en.txt + * + */ + +package org.scilab.modules.commons.jarsci; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLStreamHandler; + +import org.scilab.modules.commons.ScilabConstants; + +/** + * A {@link URLStreamHandler} that handles images resource. + */ +public class Handler extends URLStreamHandler { + + private static String JARPATH = new File(ScilabConstants.SCI, "/modules/helptools/jar/scilab_images.jar").getAbsoluteFile().toURI().toString(); + + public Handler() { + + } + + @Override + protected URLConnection openConnection(URL u) throws IOException { + String path = u.getPath(); + if (path.startsWith("./")) { + path = path.substring(1); + } else { + path = "/" + path; + } + + URL jar = new URL("jar:" + JARPATH + "!" + path); + return jar.openConnection(); + } +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/utils/BlockingResult.java b/modules/commons/src/java/org/scilab/modules/commons/utils/BlockingResult.java new file mode 100755 index 000000000..73e2e4b7c --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/utils/BlockingResult.java @@ -0,0 +1,55 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008 - INRIA - Bruno JOFRET + * Copyright (C) 2012 - Scilab Enterprises - Bruno JOFRET + * + * 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.1-en.txt + * + */ + +package org.scilab.modules.commons.utils; + +/** + * Class use for dialogs that wait for a user input + * + * @author Bruno JOFRET + */ +public class BlockingResult<BlockingResultType> { + + private BlockingResultType theResult = null; + private final Object lock = new Object(); + + /** + * Get the user input (wait until it) + * + * @return the user input + */ + public BlockingResultType getResult() { + synchronized (lock) { + try { + lock.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + return theResult; + } + + /** + * Set the result for this BlockingResult and notify + * + * @param theResult + * the user input to set + */ + public void setResult(BlockingResultType theResult) { + this.theResult = theResult; + synchronized (lock) { + lock.notify(); + } + } + +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/utils/StringBlockingResult.java b/modules/commons/src/java/org/scilab/modules/commons/utils/StringBlockingResult.java new file mode 100755 index 000000000..8322fd53f --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/utils/StringBlockingResult.java @@ -0,0 +1,35 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008 - INRIA - Bruno JOFRET + * Copyright (C) 2012 - Scilab Enterprises - Bruno JOFRET + * + * 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.1-en.txt + * + */ + +package org.scilab.modules.commons.utils; + +/** + * Class use for dialogs that wait for a user input + * + * @author Bruno JOFRET + */ +public final class StringBlockingResult extends BlockingResult<String> { + + private static StringBlockingResult me; + + /** + * Get the current instance of BlockingResult + * @return this instance + */ + public static StringBlockingResult getInstance() { + if (me == null) { + me = new StringBlockingResult(); + } + return me; + } +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/xml/ScilabDocumentBuilderFactory.java b/modules/commons/src/java/org/scilab/modules/commons/xml/ScilabDocumentBuilderFactory.java new file mode 100755 index 000000000..1ab26de11 --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/xml/ScilabDocumentBuilderFactory.java @@ -0,0 +1,59 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2011 - Calixte DENIZET + * + * 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.1-en.txt + * + */ + +package org.scilab.modules.commons.xml; + +import javax.xml.parsers.DocumentBuilderFactory; + +/** + * Class to provide a way to be sure that the default DocumentBuilderFactory provided by Java framework will be used. + * @author Calixte DENIZET + */ +public class ScilabDocumentBuilderFactory { + + private static final String DOCUMENTBUILDERFACTORYPROPERTY = "javax.xml.parsers.DocumentBuilderFactory"; + private static final String DOCUMENTBUILDERFACTORYIMPL = "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"; + + /** + * Use default internal DocumentBuilderFactoryImpl + * @return the key corresponding to the currently used implementation + */ + public static String useDefaultDocumentBuilderFactoryImpl() { + String factory = System.getProperty(DOCUMENTBUILDERFACTORYPROPERTY); + System.setProperty(DOCUMENTBUILDERFACTORYPROPERTY, DOCUMENTBUILDERFACTORYIMPL); + + return factory; + } + + /** + * Restore the previous factory + * @param factory the key as returned by useDefaultDocumentBuilderFactoryImpl + */ + public static void restoreDocumentBuilderFactoryImpl(String factory) { + if (factory == null) { + System.clearProperty(DOCUMENTBUILDERFACTORYPROPERTY); + } else { + System.setProperty(DOCUMENTBUILDERFACTORYPROPERTY, factory); + } + } + + /** + * @return a new instance using the default DocumentBuilderFactory implementation + */ + public static DocumentBuilderFactory newInstance() { + String factory = useDefaultDocumentBuilderFactoryImpl(); + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + restoreDocumentBuilderFactoryImpl(factory); + + return dbf; + } +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/xml/ScilabTransformerFactory.java b/modules/commons/src/java/org/scilab/modules/commons/xml/ScilabTransformerFactory.java new file mode 100755 index 000000000..a0ac6c0f9 --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/xml/ScilabTransformerFactory.java @@ -0,0 +1,59 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * 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.1-en.txt + * + */ + +package org.scilab.modules.commons.xml; + +import javax.xml.transform.TransformerFactory; + +/** + * Class to provide a way to be sure that the default TransformerFactory provided by Java framework will be used. + * @author Calixte DENIZET + */ +public class ScilabTransformerFactory { + + private static final String TRANSFORMERFACTORYPROPERTY = "javax.xml.transform.TransformerFactory"; + private static final String TRANSFORMERFACTORYIMPL = "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"; + + /** + * Use default internal TransformerFactoryImpl + * @return the key corresponding to the currently used implementation + */ + public static String useDefaultTransformerFactoryImpl() { + String factory = System.getProperty(TRANSFORMERFACTORYPROPERTY); + System.setProperty(TRANSFORMERFACTORYPROPERTY, TRANSFORMERFACTORYIMPL); + + return factory; + } + + /** + * Restore the previous factory + * @param factory the key as returned by useDefaultTransformerFactoryImpl + */ + public static void restoreTransformerFactoryImpl(String factory) { + if (factory == null) { + System.clearProperty(TRANSFORMERFACTORYPROPERTY); + } else { + System.setProperty(TRANSFORMERFACTORYPROPERTY, factory); + } + } + + /** + * @return a new instance using the default TransforferFactory implementation + */ + public static TransformerFactory newInstance() { + String factory = useDefaultTransformerFactoryImpl(); + TransformerFactory tf = TransformerFactory.newInstance(); + restoreTransformerFactoryImpl(factory); + + return tf; + } +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/xml/ScilabXMLUtilities.java b/modules/commons/src/java/org/scilab/modules/commons/xml/ScilabXMLUtilities.java new file mode 100755 index 000000000..a6d07603a --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/xml/ScilabXMLUtilities.java @@ -0,0 +1,537 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - Calixte DENIZET + * + * 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.1-en.txt + * + */ + +package org.scilab.modules.commons.xml; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.StringTokenizer; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.TransformerFactoryConfigurationError; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import org.xml.sax.SAXException; + +import org.scilab.modules.localization.Messages; + +/** + * Class to provide different tools to manage xml. + * + * @author Calixte DENIZET + */ +public class ScilabXMLUtilities { + + private static final String ENCODING = "UTF-8"; + private static final String ERROR_WRITE = Messages.gettext("Could not save file: "); + private static final String ERROR_READ = Messages.gettext("Could not load file: "); + private static final Integer INDENTATION = new Integer(4); + + private static Transformer transformer; + + /** + * Read a xml file and parse it + * @param fileToRead the file to read + * @return the corresponding document + */ + public static Document readDocument(String fileToRead) { + Document doc = null; + try { + DocumentBuilderFactory factory = ScilabDocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = factory.newDocumentBuilder(); + doc = docBuilder.parse(new File(fileToRead)); + } catch (ParserConfigurationException e) { + System.err.println(ERROR_READ + fileToRead); + } catch (SAXException e) { + System.err.println(ERROR_READ + fileToRead); + } catch (IOException e) { + System.err.println(ERROR_READ + fileToRead); + } + + return doc; + } + + /** + * Write a Document in a file. The empty lines are removed and the xml code is indented + * @param doc the document to write + * @param fileName the file name + */ + public static void writeDocument(Document doc, String fileName) { + if (doc != null && fileName != null) { + if (transformer == null) { + initTransformer(); + } + + if (transformer != null) { + removeEmptyLines(doc.getDocumentElement()); + + FileOutputStream fos = null; + OutputStreamWriter osw = null; + + try { + /* FileOutputStream & OutputStreamWriter are needed to be sure that + the indentation will be correct (known Java bug) */ + + fos = new FileOutputStream(fileName, false); + osw = new OutputStreamWriter(fos, ENCODING); + transformer.transform(new DOMSource(doc), new StreamResult(osw)); + } catch (FileNotFoundException e) { + System.err.println(ERROR_WRITE + fileName); + System.err.println(e); + } catch (UnsupportedEncodingException e) { + System.err.println(ERROR_WRITE + fileName); + System.err.println(e); + } catch (TransformerException e) { + System.err.println(ERROR_WRITE + fileName); + System.err.println(e); + } finally { + if (osw != null) { + try { + osw.close(); + } catch (IOException ex) { + System.err.println(ex); + } + } + } + } + } + } + + /** + * Remove empty lines which are a descendant of node + * @param node the initial node + */ + public static void removeEmptyLines(Node node) { + Set<Node> nodesToRemove = new HashSet<Node>(); + collectEmptyLines(node, nodesToRemove); + for (Node n : nodesToRemove) { + n.getParentNode().removeChild(n); + } + } + + /** + * Collect the empty lines to remove + * @param node the parent node + * @param nodesToRemove the set containing the nodes to remove + */ + private static void collectEmptyLines(Node node, Set<Node> nodesToRemove) { + if (node != null) { + NodeList list = node.getChildNodes(); + int length = getNodeListLength(list); + for (int i = 0; i < length; i++) { + Node n = list.item(i); + if (n != null) { + if (n.getNodeType() == Node.TEXT_NODE) { + nodesToRemove.add(n); + } else { + collectEmptyLines(n, nodesToRemove); + } + } + } + } + } + + /** + * Replace or create a named node with parent element + * @param doc the document + * @param parent the parent element + * @param nodeName the node name + * @param attr an array containing attribute name followed by its value: "attr1", 1, "attr2", true, ... + * @return the created element + */ + public static Element replaceNamedNode(Document doc, Element parent, String nodeName, Object[] attr) { + NodeList children = parent.getElementsByTagName(nodeName); + Element elem; + if (getNodeListLength(children) > 0) { + elem = (Element) children.item(0); + } else { + elem = doc.createElement(nodeName); + parent.appendChild(elem); + } + + for (int i = 0; i < attr.length; i += 2) { + elem.setAttribute(attr[i].toString(), attr[i + 1].toString()); + } + + return elem; + } + + /** + * Replace or create a named node with parent element + * @param doc the document + * @param parent the name of the parent element + * @param nodeName the node name + * @param attr an array containing attribute name followed by its value: "attr1", 1, "attr2", true, ... + * @return the created element + */ + public static Element replaceNamedNode(Document doc, String parent, String nodeName, Object[] attr) { + NodeList parents = doc.getDocumentElement().getElementsByTagName(parent); + if (getNodeListLength(parents) > 0) { + return replaceNamedNode(doc, (Element) parents.item(0), nodeName, attr); + } + + return null; + } + + /** + * Replace or create a named node with parent element + * @param doc the document + * @param parent the parent element + * @param nodeName the node name + * @param map a map containing {attributes -> value}, the method value.toString() will be used. + * @return the created element + */ + public static Element replaceNamedNode(Document doc, Element parent, String nodeName, Map<String, Object> map) { + NodeList children = parent.getElementsByTagName(nodeName); + Element elem; + if (getNodeListLength(children) > 0) { + elem = (Element) children.item(0); + } else { + elem = doc.createElement(nodeName); + parent.appendChild(elem); + } + + for (String name : map.keySet()) { + elem.setAttribute(name, map.get(name).toString()); + } + + return elem; + } + + /** + * Replace or create a named node with parent element + * @param doc the document + * @param parent the name of the parent element + * @param nodeName the node name + * @param map a map containing {attributes -> value}, the method value.toString() will be used. + * @return the created element + */ + public static Element replaceNamedNode(Document doc, String parent, String nodeName, Map<String, Object> map) { + NodeList parents = doc.getDocumentElement().getElementsByTagName(parent); + if (getNodeListLength(parents) > 0) { + return replaceNamedNode(doc, (Element) parents.item(0), nodeName, map); + } + + return null; + } + + /** + * Create a new node with parent element + * @param doc the document + * @param parent the parent element + * @param nodeName the node name + * @param attr an array containing attribute name followed by its value: "attr1", 1, "attr2", true, ... + * @return the created element + */ + public static Element createNode(Document doc, Element parent, String nodeName, Object[] attr) { + Element elem = doc.createElement(nodeName); + for (int i = 0; i < attr.length; i += 2) { + elem.setAttribute(attr[i].toString(), attr[i + 1].toString()); + } + parent.appendChild(elem); + + return elem; + } + + /** + * Create a new node with parent element + * @param doc the document + * @param parent the parent element + * @param nodeName the node name + * @param map a map containing {attributes -> value}, the method value.toString() will be used. + * @return the created element + */ + public static Element createNode(Document doc, Element parent, String nodeName, Map<String, Object> map) { + Element elem = doc.createElement(nodeName); + for (String name : map.keySet()) { + elem.setAttribute(name, map.get(name).toString()); + } + parent.appendChild(elem); + + return elem; + } + + /** + * Read the attributes of elem. + * Map must be like this: "attr1" -> integer.class, "attr2" -> boolean.class, ... + * Map will be filled with the value (as Object) of the different attributes + * @param elem the element to analyze + * @param map the map containing the attributes type. + */ + public static void readNodeAttributes(Element elem, Map<String, Object> map) { + NamedNodeMap attrMap = elem.getAttributes(); + for (int i = 0; i < attrMap.getLength(); i++) { + Attr attr = (Attr) attrMap.item(i); + String key = attr.getName(); + if (map.containsKey(key)) { + map.put(key, convert(attr.getValue(), (Class) map.get(key))); + } + } + } + + /** + * Read the attributes of elem. + * Map must be like this: Object[]{"attr1", integer.class, "attr2", boolean.class, ...} + * Map will be filled with the value (as Object) of the different attributes + * @param elem the element to analyze + * @param map the map containing the attributes type. + */ + public static void readNodeAttributes(Element elem, Object[] map) { + NamedNodeMap attrMap = elem.getAttributes(); + for (int i = 0; i < attrMap.getLength(); i++) { + Attr attr = (Attr) attrMap.item(i); + String key = attr.getName(); + for (int j = 0; j < map.length; j += 2) { + if (map[j].equals(key)) { + map[j + 1] = convert(attr.getValue(), (Class) map[j + 1]); + } + } + } + } + + /** + * Read the attributes of first element named nodeName in the document. + * Map must be like this: "attr1" -> integer.class, "attr2" -> boolean.class, ... + * Map will be filled with the value (as Object) of the different attributes + * @param doc the document + * @param nodeName the node name + * @param map the map containing the attributes type. + * @return the corresponding element or null if it doesn't exist + */ + public static Element readNodeAttributes(Document doc, String nodeName, Map<String, Object> map) { + NodeList list = doc.getDocumentElement().getElementsByTagName(nodeName); + if (getNodeListLength(list) > 0) { + Node n = list.item(0); + if (n instanceof Element) { + readNodeAttributes((Element) n, map); + return (Element) n; + } + } + + return null; + } + + /** + * Read the attributes of first element named nodeName in the document. + * Map must be like this: Object[]{"attr1", integer.class, "attr2", boolean.class, ...} + * Map will be filled with the value (as Object) of the different attributes + * @param doc the document + * @param nodeName the node name + * @param map the map containing the attributes type. + * @return the corresponding element or null if it doesn't exist + */ + public static Element readNodeAttributes(Document doc, String nodeName, Object[] map) { + NodeList list = doc.getDocumentElement().getElementsByTagName(nodeName); + if (getNodeListLength(list) > 0) { + Node n = list.item(0); + if (n instanceof Element) { + readNodeAttributes((Element) n, map); + return (Element) n; + } + } + + return null; + } + + /** + * Retrieve the list of the elements which have an attribute equal to the given value. + * @param root the root element + * @param attribute the attribute name + * @param value the value + * @return the list + */ + public static List<Element> getElementsWithAttributeEquals(Element root, String attribute, String value) { + List<Element> list = new ArrayList<Element>(); + getElementsWithAttributeEquals(root, attribute, value, list); + + return list; + } + + /** + * Retrieve the list of the elements which have an attribute equal to the given value (recursive function). + * @param root the root element + * @param attribute the attribute name + * @param value the value + * @param list the list to fill + */ + private static final void getElementsWithAttributeEquals(Element root, String attribute, String value, List<Element> list) { + if (root.getAttribute(attribute).equals(value)) { + list.add(root); + } + if (root.hasChildNodes()) { + NodeList nodes = root.getChildNodes(); + int length = nodes.getLength(); + for (int i = 0; i < length; i++) { + Node node = nodes.item(i); + if (node instanceof Element) { + Element elem = (Element) nodes.item(i); + getElementsWithAttributeEquals(elem, attribute, value, list); + } + } + } + } + + /** + * Convert a value (as String) into an object according to its class type giving in clazz + * @param value the value to convert + * @param clazz the class type of the value + * @return the converted object + */ + private static final Object convert(String value, Class clazz) { + if (clazz == int.class) { + return Integer.parseInt(value); + } else if (clazz == float.class) { + return Float.parseFloat(value); + } else if (clazz == boolean.class) { + return Boolean.parseBoolean(value); + } else if (clazz == double.class) { + return Double.parseDouble(value); + } else if (clazz == short.class) { + return Short.parseShort(value); + } else if (clazz == long.class) { + return Long.parseLong(value); + } else if (clazz == byte.class) { + return Byte.parseByte(value); + } else if (clazz == char.class) { + return value.length() == 0 ? '\0' : value.charAt(0); + } else if (clazz == String[].class) { + return getArray(value, ";"); + } + + return value; + } + + /** + * Get an array from a string containing strings separated with a delimitor + * @param value the string to parse + * @param delimitor the delimitor + * @return an array of String + */ + private static final String[] getArray(String value, String delimitor) { + StringTokenizer tokens = new StringTokenizer(value, delimitor); + String[] arr = new String[tokens.countTokens()]; + for (int i = 0; i < arr.length; i++) { + arr[i] = tokens.nextToken(); + } + + return arr; + } + + /** + * Init the transformer + */ + private static final void initTransformer() { + try { + TransformerFactory factory = ScilabTransformerFactory.newInstance(); + factory.setAttribute("indent-number", INDENTATION); + transformer = factory.newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); + transformer.setOutputProperty(OutputKeys.ENCODING, ENCODING); + } catch (TransformerConfigurationException e) { + System.err.println("Problem to init the Transformer to write xml files"); + System.err.println(e); + } catch (TransformerFactoryConfigurationError e) { + System.err.println("Problem to init the Transformer to write xml files"); + System.err.println(e); + } + } + + /** + * @param list a node list + * @return the length + */ + private static int getNodeListLength(NodeList list) { + int length = 0; + try { + length = list.getLength(); + } catch (NullPointerException e) { + /* Avoid Java bug */ + } + return length; + } + + /** + * Replace classical XML reserved chars by their XML equivalent entities + * @param str the String to parse and transform + * @return a String with the XML entities. + */ + public static String getXMLString(String str) { + if (str != null && !str.isEmpty()) { + StringBuilder buf = new StringBuilder(); + char[] chars = str.toCharArray(); + int last = 0; + for (int i = 0; i < chars.length; i++) { + switch (chars[i]) { + case '\'' : + buf.append(chars, last, i - last).append("'"); + last = i + 1; + break; + case '\"' : + buf.append(chars, last, i - last).append("""); + last = i + 1; + break; + case '<' : + buf.append(chars, last, i - last).append("<"); + last = i + 1; + break; + case '>' : + buf.append(chars, last, i - last).append(">"); + last = i + 1; + break; + case '&' : + buf.append(chars, last, i - last).append("&"); + last = i + 1; + break; + default : + break; + } + } + + if (last == 0) { + return str; + } + + if (last < chars.length) { + buf.append(chars, last, chars.length - last); + } + + return buf.toString(); + } + + return str; + } +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/xml/XConfiguration.java b/modules/commons/src/java/org/scilab/modules/commons/xml/XConfiguration.java new file mode 100755 index 000000000..1c6c8f01d --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/xml/XConfiguration.java @@ -0,0 +1,902 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET + * + * 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.1-en.txt + * + */ + +package org.scilab.modules.commons.xml; + +import java.awt.Color; +import java.io.BufferedOutputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FilenameFilter; +import java.io.FileFilter; +import java.io.IOException; +import java.lang.annotation.Annotation; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Array; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.HashSet; +import java.util.Set; + +import javax.swing.KeyStroke; +import javax.swing.event.EventListenerList; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactoryConfigurationError; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; + +import org.xml.sax.SAXException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import org.scilab.modules.commons.ScilabConstants; +import org.scilab.modules.commons.ScilabGeneralPrefs; +import org.scilab.modules.commons.gui.ScilabKeyStroke; +import org.scilab.modules.localization.Messages; + +/** + * Class to retrieve object from the xml configuration file + * + * @author Calixte DENIZET + * + */ +public class XConfiguration { + + // User configuration file + private static final String SCI = System.getenv("SCI"); + private static final String SCILAB_CONFIG_FILE = SCI + "/modules/preferences/etc/XConfiguration.xml"; + + private static final String ERROR_READ = Messages.gettext("Could not load file: "); + private static final String ERROR_WRITE = Messages.gettext("Could not write the file: "); + private static final String SEVERE_ERROR = Messages.gettext("A severe error occurred: cannot load the preferences file."); + private static final String PARSING_ERROR = Messages.gettext("An error occurred when loading the preferences file, try to reload the default one."); + + private static final XPathFactory xpathFactory = XPathFactory.newInstance(); + private static final Map < Class<?>, StringParser > conv = new HashMap < Class<?>, StringParser > (); + + private static final EventListenerList listenerList = new EventListenerList(); + private static final Set<String> modifiedPaths = new HashSet<String>(); + + private static Document doc; + private static boolean hasBeenRead; + private static boolean mustSave = true;; + private static String USER_CONFIG_FILE = ScilabConstants.SCIHOME.toString() + "/XConfiguration.xml"; + + static { + if (ScilabConstants.SCIHOME != null && ScilabConstants.SCIHOME.canRead() && ScilabConstants.SCIHOME.canWrite()) { + USER_CONFIG_FILE = ScilabConstants.SCIHOME.toString() + "/XConfiguration.xml"; + } else { + USER_CONFIG_FILE = SCILAB_CONFIG_FILE; + mustSave = false; + } + + addXConfigurationListener(ScilabGeneralPrefs.getInstance()); + + try { + Class histoprefs = ClassLoader.getSystemClassLoader().loadClass("org.scilab.modules.history_manager.HistoryPrefs"); + Method getinstance = histoprefs.getDeclaredMethod("getInstance"); + addXConfigurationListener((XConfigurationListener)getinstance.invoke(null)); + } catch (ClassNotFoundException e) { + // Nothing displayed (always occurs in MN mode) + } catch (Exception e) { + System.err.println(e); + } + } + + /** + * Get the document in SCIHOME corresponding to the configuration file. + * @return the configuration document. + */ + public static Document getXConfigurationDocument() { + if (doc == null) { + boolean error = false; + File xml = new File(USER_CONFIG_FILE); + if (!xml.exists() && mustSave) { + ScilabXMLUtilities.writeDocument(createDocument(), USER_CONFIG_FILE); + } + + DocumentBuilder docBuilder = null; + + if (mustSave) { + try { + DocumentBuilderFactory factory = ScilabDocumentBuilderFactory.newInstance(); + docBuilder = factory.newDocumentBuilder(); + doc = docBuilder.parse(xml); + float version = getDocumentVersion(doc); + float defaultVersion = getDocumentVersion(getDefaultDocument()); + if (defaultVersion != version) { + xml.delete(); + doc = null; + return getXConfigurationDocument(); + } else { + return doc; + } + } catch (ParserConfigurationException pce) { + error = true; + } catch (SAXException se) { + error = true; + } catch (IOException ioe) { + error = true; + } + + if (error) { + if (hasBeenRead) { + System.err.println(SEVERE_ERROR); + doc = null; + xml.delete(); + return docBuilder.newDocument(); + } + + hasBeenRead = true; + doc = null; + xml.delete(); + System.err.println(PARSING_ERROR); + return getXConfigurationDocument(); + } + + return docBuilder.newDocument(); + } else { + doc = createDocument(); + } + } + + return doc; + } + + /** + * Save the modifications + */ + public static void writeDocument(String filename, Node written) { + if (mustSave) { + Transformer transformer = null; + try { + transformer = ScilabTransformerFactory.newInstance().newTransformer(); + } catch (TransformerConfigurationException e1) { + System.err.println(ERROR_WRITE + filename); + return; + } catch (TransformerFactoryConfigurationError e1) { + System.err.println(ERROR_WRITE + filename); + return; + } + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + + StreamResult result = new StreamResult(new File(filename)); + DOMSource source = new DOMSource(written); + try { + transformer.transform(source, result); + } catch (TransformerException e) { + System.err.println(ERROR_WRITE + filename); + return; + } + + // Invalidate the current document + if (filename.equals(USER_CONFIG_FILE)) { + doc = null; + } + } + } + + /** + * Save the modifications + */ + public static String dumpNode(Node written) { + Transformer transformer = null; + try { + transformer = ScilabTransformerFactory.newInstance().newTransformer(); + } catch (TransformerConfigurationException e1) { + System.err.println("Cannot dump xml"); + return ""; + } catch (TransformerFactoryConfigurationError e1) { + System.err.println("Cannot dump xml"); + return ""; + } + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + StreamResult result = new StreamResult(new BufferedOutputStream(stream)); + DOMSource source = new DOMSource(written); + String str = ""; + try { + transformer.transform(source, result); + str = stream.toString(); + } catch (TransformerException e) { + System.err.println("Cannot dump xml"); + return str; + } finally { + try { + stream.close(); + } catch (Exception e) { } + } + + return str; + } + + /** + * Get the document version + * @param doc the document + * @return the version + */ + private static float getDocumentVersion(Document doc) { + if (doc != null) { + Element root = doc.getDocumentElement(); + String version = root.getAttribute("version"); + + try { + return Float.parseFloat(version); + } catch (NumberFormatException e) { } + } + + return 0.0f; + } + + /** + * Get the default document + * @return the document + */ + private static Document getDefaultDocument() { + DocumentBuilder docBuilder; + DocumentBuilderFactory factory; + Document mainDoc = null; + + try { + factory = ScilabDocumentBuilderFactory.newInstance(); + docBuilder = factory.newDocumentBuilder(); + mainDoc = docBuilder.parse(SCILAB_CONFIG_FILE); + } catch (ParserConfigurationException pce) { + System.err.println("Cannot create a XML DocumentBuilder:\n" + pce); + return null; + } catch (SAXException se) { + System.err.println("Weird... Cannot parse basic file:\n" + se); + return null; + } catch (IOException ioe) { + System.err.println("Weird... Cannot parse basic file:\n" + ioe); + return null; + } + + return mainDoc; + } + + /** + * Create a document in using the XConfiguration-*.xml found in SCI/modules/MODULE_NAME/etc/ + * @return the built document + */ + public static Document createDocument() { + DocumentBuilder docBuilder; + DocumentBuilderFactory factory; + Document mainDoc = getDefaultDocument(); + if (mainDoc == null) { + return null; + } + + Element root = mainDoc.getDocumentElement(); + + factory = ScilabDocumentBuilderFactory.newInstance(); + + try { + docBuilder = factory.newDocumentBuilder(); + } catch (ParserConfigurationException pce) { + System.err.println("Cannot create a XML DocumentBuilder:\n" + pce); + return null; + } + + List<File> etcs = getEtcDir(); + for (File etc : etcs) { + File[] xmls = etc.listFiles(new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.endsWith(".xml") && name.startsWith("XConfiguration-"); + } + }); + for (File xml : xmls) { + try { + Document doc = docBuilder.parse(xml); + if (xml.getName().equals("XConfiguration-general.xml")) { + try { + XPath xp = xpathFactory.newXPath(); + NodeList nodes = (NodeList) xp.compile("//shortcuts/body/actions/action-folder/action[contains(@key, 'OSSCKEY')]").evaluate(doc, XPathConstants.NODESET); + for (int i = 0; i < nodes.getLength(); i++) { + Element e = (Element) nodes.item(i); + e.setAttribute("key", e.getAttribute("key").replace("OSSCKEY", ScilabKeyStroke.getOSMetaKey())); + } + } catch (XPathExpressionException e) { + System.err.println(e); + } + } + Node node = mainDoc.importNode(doc.getDocumentElement(), true); + NodeList list = root.getElementsByTagName(node.getNodeName()); + if (list.getLength() != 0) { + root.replaceChild(node, list.item(0)); + } + } catch (SAXException se) { + System.err.println(ERROR_READ + xml.getName()); + } catch (IOException ioe) { + System.err.println(ERROR_READ + xml.getName()); + } + } + } + + return mainDoc; + } + + /** + * Get the list of the etc dirs in modules dirs + * @return the lit of etc dirs + */ + public static List<File> getEtcDir() { + List<File> list = new ArrayList<File>(); + File modulesDir = new File(SCI + "/modules/"); + File[] modules = modulesDir.listFiles(new FileFilter() { + public boolean accept(File f) { + return f.isDirectory(); + } + }); + + for (File module : modules) { + File etc = new File(module, "/etc/"); + if (etc.exists() && etc.isDirectory()) { + list.add(etc); + } + } + + return list; + } + + public static void addModifiedPath(String path) { + if (path != null && !path.isEmpty()) { + modifiedPaths.add(path); + } + } + + public static void invalidate() { + modifiedPaths.clear(); + doc = null; + } + + public static void addXConfigurationListener(XConfigurationListener listener) { + listenerList.add(XConfigurationListener.class, listener); + } + + public static void removeXConfigurationListener(XConfigurationListener listener) { + listenerList.remove(XConfigurationListener.class, listener); + } + + public static XConfigurationListener[] getXConfigurationListeners() { + return listenerList.getListeners(XConfigurationListener.class); + } + + public static void fireXConfigurationEvent() { + if (!modifiedPaths.isEmpty()) { + XConfigurationEvent event = null; + Object[] listeners = listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == XConfigurationListener.class) { + if (event == null) { + event = new XConfigurationEvent(modifiedPaths); + } + ((XConfigurationListener) listeners[i + 1]).configurationChanged(event); + } + } + + modifiedPaths.clear(); + } + } + + /** + * Register a StringParser for a given Class + * @param type the class type + * @param parser the StringParser + */ + public static void registerStringParser(Class<?> type, StringParser parser) { + conv.put(type, parser); + } + + /** + * Get a StringParser for a given Class + * @param type the class type + * @return the corresponding parser + */ + public static StringParser getStringParser(Class<?> type) { + return conv.get(type); + } + + public static void set(final Document doc, final String path, String value) { + XPath xp = xpathFactory.newXPath(); + NodeList nodes; + try { + nodes = (NodeList) xp.compile(path).evaluate(doc, XPathConstants.NODESET); + } catch (XPathExpressionException e) { + System.err.println(e); + return; + } + + for (int i = 0; i < nodes.getLength() ; i++) { + Node n = nodes.item(i); + if (n != null && n.getNodeType() == Node.ATTRIBUTE_NODE) { + n.setNodeValue(value); + } + } + + writeDocument(USER_CONFIG_FILE, doc); + } + + /** + * Save the current file + */ + public static void save() { + if (doc != null) { + writeDocument(USER_CONFIG_FILE, doc); + } + } + + /** + * Get all the nodes with the given path. + * All the get nodes are serialized into an object (generic paramater) which must have + * a constructor without argument and with methods named set<Attribute Name> with + * one argument and no returned value. + * For example a node <foo aaa="1" bbb="true" ccc-ddd="#001122"/> could be retrieved with something like + * XConfiguration.get(MyObject.class, doc, "//path/to/node") where MyObject should be something like + * <code> + * public class MyObject { + * + * public MyObject() { + * // ... + * } + * + * public void setAaa(int a) { + * // ... + * } + * + * public void setBbb(boolean b) { + * // ... + * } + * + * public void setCccDdd(Color c) { + * // ... + * } + * } + * </code> + * If an attribute must not be retrieved, just remove the setter. + * + * It is possible to use the annotation @XConfAttribute to make easier the retrievement. + * For example + * <code> + * @XConfAttribute + * public class MyObject { + * + * public MyObject() { + * // ... + * } + * + * @XConfAttribute(attributes={"aaa", "bbb", "ccc-ddd"}) + * // the contents of aaa will be converted into int and passed as first argument + * // the contents of bbb will be converted into boolean and passed as second argument + * // the contents of ccc-ddd will be converted into Color and passed as third argument + * public void set(int n, boolean b, Color c) { + * // ... + * } + * } + * </code> + * + * @param type the Class type to retrieve + * @param doc the document to explore + * @param path the xpath query to retrieve the corresponding nodeset. + * @return an array of instance of class type. + */ + public static final <T> T[] get(final Class<T> type, final Document doc, final String path) { + XPath xp = xpathFactory.newXPath(); + NodeList nodes; + try { + nodes = (NodeList) xp.compile(path).evaluate(doc, XPathConstants.NODESET); + } catch (XPathExpressionException e) { + System.err.println(e); + return (T[]) Array.newInstance(type, 0); + } + + if (type.getAnnotation(XConfAttribute.class) != null) { + T[] arr = get(type, nodes); + if (arr != null) { + return arr; + } + } + + Method[] meths = type.getDeclaredMethods(); + Map<String, Method> mapMethods = new HashMap<String, Method>(); + for (Method m : meths) { + String name = m.getName(); + if (name.startsWith("set") && m.getParameterTypes().length == 1 && m.getReturnType().equals(Void.TYPE)) { + mapMethods.put(m.getName(), m); + m.setAccessible(true); + } + } + + Map<String, String> names = new HashMap<String, String>(); + + T[] values = (T[]) Array.newInstance(type, nodes.getLength()); + for (int i = 0; i < values.length; i++) { + NamedNodeMap map = nodes.item(i).getAttributes(); + try { + Constructor<T> constructor = type.getDeclaredConstructor(new Class[] {}); + constructor.setAccessible(true); + values[i] = constructor.newInstance(); + } catch (InstantiationException e) { + System.err.println(e); + break; + } catch (IllegalAccessException e) { + System.err.println(e); + break; + } catch (NoSuchMethodException e) { + System.err.println(e); + break; + } catch (InvocationTargetException e) { + System.err.println(e.getTargetException()); + } + + for (int j = 0; j < map.getLength(); j++) { + Node n = map.item(j); + String name = n.getNodeName(); + String methName = names.get(name); + if (methName == null) { + StringBuilder buffer = new StringBuilder("set"); + String[] parts = name.split("-"); + for (String part : parts) { + if (part != null && part.length() > 0) { + buffer.append(part.substring(0, 1).toUpperCase()); + buffer.append(part.substring(1).toLowerCase()); + } + } + methName = buffer.toString(); + names.put(name, methName); + } + String value = n.getNodeValue(); + Method method = mapMethods.get(methName); + if (method != null) { + Class[] paramsClass = method.getParameterTypes(); + StringParser parser = conv.get(paramsClass[0]); + if (parser != null) { + Object[] params = new Object[] {parser.parse(value)}; + try { + method.invoke(values[i], params); + } catch (IllegalAccessException e) { + System.err.println(e); + } catch (IllegalArgumentException e) { + System.err.println(e); + } catch (InvocationTargetException e) { + System.err.println(e.getTargetException()); + } + } + } + } + } + + return values; + } + + /** + * Get a Map with where the key is the converted value (according to keyType) of the attribute named key + * and the value is given in the same way. + * @param doc the document to read + * @param key the attribute name where its value will be converted and used as a key in the map + * @param keyType the Class of the key + * @param value the attribute name where its value will be converted and used as a value in the map + * @param valueType the Class of the value + * @return the corresponding map. + */ + public static final <T, U> Map<T, U> get(final Document doc, final String key, final Class<T> keyType, final String value, final Class<U> valueType, final String path) { + XPath xp = xpathFactory.newXPath(); + Map<T, U> map = new HashMap<T, U>(); + NodeList nodes; + try { + nodes = (NodeList) xp.compile(path).evaluate(doc, XPathConstants.NODESET); + } catch (XPathExpressionException e) { + System.err.println(e); + return map; + } + + int len = nodes.getLength(); + for (int i = 0; i < len; i++) { + NamedNodeMap nmap = nodes.item(i).getAttributes(); + Node k = nmap.getNamedItem(key); + Node v = nmap.getNamedItem(value); + if (k == null || v == null) { + return map; + } + + String kk = k.getNodeValue(); + String vv = v.getNodeValue(); + + StringParser convK = conv.get(keyType); + StringParser convV = conv.get(valueType); + if (convK == null || convV == null) { + return map; + } + + map.put((T) convK.parse(kk), (U) convV.parse(vv)); + } + + return map; + } + + /** + * Getter for annoted class (with @XConfAttribute) + * @param type the class type + * @param nodes the nodes to read + * @return an array of instances of type, if the class is annoted with @XConfAttribute(isStatic=true), + * the returned array is empty. + */ + private static final <T> T[] get(final Class<T> type, NodeList nodes) { + Method[] meths = type.getDeclaredMethods(); + List<String[]> attrs = new ArrayList<String[]>(); + List<Method> methods = new ArrayList<Method>(); + Map<String[], Method> mapMethods = new HashMap<String[], Method>(); + for (Method m : meths) { + String name = m.getName(); + Annotation ann = m.getAnnotation(XConfAttribute.class); + if (ann != null) { + String[] attributes = ((XConfAttribute) ann).attributes(); + if (attributes.length == m.getParameterTypes().length) { + m.setAccessible(true); + attrs.add(attributes); + methods.add(m); + } else { + return null; + } + } + } + + Annotation ann = type.getAnnotation(XConfAttribute.class); + boolean mustInstantiate = !((XConfAttribute) ann).isStatic(); + + T[] values = null; + int len = nodes.getLength(); + if (mustInstantiate) { + values = (T[]) Array.newInstance(type, len); + } + + for (int i = 0; i < len; i++) { + NamedNodeMap map = nodes.item(i).getAttributes(); + String nodeName = nodes.item(i).getNodeName(); + + if (mustInstantiate) { + try { + Constructor<T> constructor = type.getDeclaredConstructor(new Class[] {}); + constructor.setAccessible(true); + values[i] = constructor.newInstance(); + } catch (InstantiationException e) { + System.err.println(e); + break; + } catch (IllegalAccessException e) { + System.err.println(e); + break; + } catch (NoSuchMethodException e) { + System.err.println(e); + break; + } catch (InvocationTargetException e) { + System.err.println(e.getTargetException()); + } + } + + for (int j = 0; j < methods.size(); j++) { + Method method = methods.get(j); + ann = method.getAnnotation(XConfAttribute.class); + String tag = ((XConfAttribute) ann).tag(); + if (tag.isEmpty() || tag.equals(nodeName)) { + String[] attributes = attrs.get(j); + Object[] params = new Object[attributes.length]; + Class[] paramsClass = method.getParameterTypes(); + for (int k = 0; k < attributes.length; k++) { + String p = ""; + Node node = null; + if (map != null) { + node = map.getNamedItem(attributes[k]); + } + if (node != null) { + p = node.getNodeValue(); + } + + StringParser parser = conv.get(paramsClass[k]); + if (parser != null) { + params[k] = parser.parse(p); + } + } + + try { + if (mustInstantiate) { + method.invoke(values[i], params); + } else { + method.invoke(null, params); + } + } catch (IllegalAccessException e) { + System.err.println(e); + } catch (IllegalArgumentException e) { + System.err.println(e); + } catch (InvocationTargetException e) { + System.err.println(e.getTargetException()); + } + } + } + } + + if (mustInstantiate) { + return values; + } else { + return (T[]) Array.newInstance(type, 0); + } + } + + /** + * Interface to implement to parse an attribute String into a Java object + */ + public static interface StringParser { + + /** + * Parse a string + * @param str the string to parse + * @return the corresponding Object + */ + public Object parse(String str); + } + + static { + conv.put(int.class, new StringParser() { + public Integer parse(String str) { + try { + return Integer.parseInt(str); + } catch (NumberFormatException e) { + try { + return (int) Double.parseDouble(str); + } catch (NumberFormatException ee) { + return new Integer(0); + } + } + } + }); + conv.put(char.class, new StringParser() { + public Object parse(String str) { + if (str.length() > 0) { + return str.charAt(0); + } else { + return new Character((char) 0); + } + } + }); + conv.put(byte.class, new StringParser() { + public Object parse(String str) { + try { + return Byte.parseByte(str); + } catch (NumberFormatException e) { + try { + return (byte) Double.parseDouble(str); + } catch (NumberFormatException ee) { + return new Byte((byte) 0); + } + } + } + }); + conv.put(short.class, new StringParser() { + public Object parse(String str) { + try { + return Short.parseShort(str); + } catch (NumberFormatException e) { + try { + return (short) Double.parseDouble(str); + } catch (NumberFormatException ee) { + return new Short((short) 0); + } + } + } + }); + conv.put(double.class, new StringParser() { + public Object parse(String str) { + try { + return Double.parseDouble(str); + } catch (NumberFormatException ee) { + return new Double((double) 0); + } + } + }); + conv.put(float.class, new StringParser() { + public Object parse(String str) { + try { + return Float.parseFloat(str); + } catch (NumberFormatException ee) { + return new Float((float) 0); + } + } + }); + conv.put(boolean.class, new StringParser() { + public Object parse(String str) { + return Boolean.parseBoolean(str); + } + }); + conv.put(long.class, new StringParser() { + public Object parse(String str) { + try { + return Long.parseLong(str); + } catch (NumberFormatException e) { + try { + return (long) Double.parseDouble(str); + } catch (NumberFormatException ee) { + return new Long((long) 0); + } + } + } + }); + conv.put(String.class, new StringParser() { + public Object parse(String str) { + return str; + } + }); + conv.put(Color.class, new StringParser() { + public Object parse(String str) { + try { + return Color.decode(str); + } catch (NumberFormatException e) { + return Color.BLACK; + } + } + }); + conv.put(KeyStroke.class, new StringParser() { + public Object parse(String str) { + String[] toks = str.split(" +"); + StringBuilder buffer = new StringBuilder(); + for (int i = 0; i < toks.length - 1; i++) { + buffer.append(toks[i].toLowerCase()); + buffer.append(" "); + } + buffer.append(toks[toks.length - 1].toUpperCase()); + return KeyStroke.getKeyStroke(buffer.toString()); + } + }); + } + + @Retention(RetentionPolicy.RUNTIME) + public @interface XConfAttribute { + + /** + * Map method arguments with attributes name + * For example, + * <code> + * @XConfAttribute(tag="mytag", attributes={"a", "b"}) + * void foo(String one, int tow) { ... } + * </code> + * The value of attribute "a" is converted into a String and passed as "one" argument,... + */ + public String[] attributes() default { + "" + }; + + public String tag() default ""; + + /** + * Used to avoid object instanciation so the differents annotated methods must be static. + */ + public boolean isStatic() default false; + } +} diff --git a/modules/commons/src/java/org/scilab/modules/commons/xml/XConfigurationEvent.java b/modules/commons/src/java/org/scilab/modules/commons/xml/XConfigurationEvent.java new file mode 100755 index 000000000..68aa8808b --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/xml/XConfigurationEvent.java @@ -0,0 +1,36 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET + * + * 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.1-en.txt + * + */ + +package org.scilab.modules.commons.xml; + +import java.util.Set; + +public class XConfigurationEvent { + + private Set<String> changedPaths; + + /** + * Default constructor + * @param changedPaths a set containing all the paths which have been modified + */ + public XConfigurationEvent(Set<String> changedPaths) { + this.changedPaths = changedPaths; + } + + /** + * Get the modified paths + * @return the modified paths as a set + */ + public Set<String> getModifiedPaths() { + return changedPaths; + } +}
\ No newline at end of file diff --git a/modules/commons/src/java/org/scilab/modules/commons/xml/XConfigurationListener.java b/modules/commons/src/java/org/scilab/modules/commons/xml/XConfigurationListener.java new file mode 100755 index 000000000..06c41e219 --- /dev/null +++ b/modules/commons/src/java/org/scilab/modules/commons/xml/XConfigurationListener.java @@ -0,0 +1,26 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET + * + * 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.1-en.txt + * + */ + +package org.scilab.modules.commons.xml; + +import java.util.EventListener; + +public interface XConfigurationListener extends EventListener { + + /** + * Prevent the listener that configuration has changed + * + * @param e the event + */ + public void configurationChanged(XConfigurationEvent e); + +} diff --git a/modules/commons/src/jni/.deps/.dirstamp b/modules/commons/src/jni/.deps/.dirstamp new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/modules/commons/src/jni/.deps/.dirstamp diff --git a/modules/commons/src/jni/.deps/libscicommons_la-CommonFileUtils_wrap.Plo b/modules/commons/src/jni/.deps/libscicommons_la-CommonFileUtils_wrap.Plo new file mode 100755 index 000000000..acc5311b9 --- /dev/null +++ b/modules/commons/src/jni/.deps/libscicommons_la-CommonFileUtils_wrap.Plo @@ -0,0 +1,134 @@ +src/jni/libscicommons_la-CommonFileUtils_wrap.lo: \ + src/jni/CommonFileUtils_wrap.c /usr/include/stdc-predef.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/jni.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/string.h \ + /usr/include/xlocale.h /usr/include/x86_64-linux-gnu/bits/string.h \ + /usr/include/x86_64-linux-gnu/bits/string2.h \ + /usr/include/x86_64-linux-gnu/bits/string3.h \ + src/jni/../../includes/fileutils.h ../../modules/core/includes/MALLOC.h \ + ../../modules/core/includes/sci_mem_alloc.h + +/usr/include/stdc-predef.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/jni.h: + +/usr/include/stdio.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/wchar.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/time.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/sigset.h: + +/usr/include/x86_64-linux-gnu/bits/time.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/alloca.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/string.h: + +/usr/include/xlocale.h: + +/usr/include/x86_64-linux-gnu/bits/string.h: + +/usr/include/x86_64-linux-gnu/bits/string2.h: + +/usr/include/x86_64-linux-gnu/bits/string3.h: + +src/jni/../../includes/fileutils.h: + +../../modules/core/includes/MALLOC.h: + +../../modules/core/includes/sci_mem_alloc.h: diff --git a/modules/commons/src/jni/.deps/libscicommons_la-FindIconHelper.Plo b/modules/commons/src/jni/.deps/libscicommons_la-FindIconHelper.Plo new file mode 100755 index 000000000..7953ced00 --- /dev/null +++ b/modules/commons/src/jni/.deps/libscicommons_la-FindIconHelper.Plo @@ -0,0 +1,341 @@ +src/jni/libscicommons_la-FindIconHelper.lo: src/jni/FindIconHelper.cpp \ + /usr/include/stdc-predef.h src/jni/FindIconHelper.hxx \ + /usr/include/c++/5/iostream \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/cpu_defines.h \ + /usr/include/c++/5/ostream /usr/include/c++/5/ios \ + /usr/include/c++/5/iosfwd /usr/include/c++/5/bits/stringfwd.h \ + /usr/include/c++/5/bits/memoryfwd.h /usr/include/c++/5/bits/postypes.h \ + /usr/include/c++/5/cwchar /usr/include/wchar.h /usr/include/stdio.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h /usr/include/xlocale.h \ + /usr/include/x86_64-linux-gnu/bits/wchar2.h /usr/include/c++/5/exception \ + /usr/include/c++/5/bits/atomic_lockfree_defines.h \ + /usr/include/c++/5/bits/char_traits.h \ + /usr/include/c++/5/bits/stl_algobase.h \ + /usr/include/c++/5/bits/functexcept.h \ + /usr/include/c++/5/bits/exception_defines.h \ + /usr/include/c++/5/bits/cpp_type_traits.h \ + /usr/include/c++/5/ext/type_traits.h \ + /usr/include/c++/5/ext/numeric_traits.h \ + /usr/include/c++/5/bits/stl_pair.h /usr/include/c++/5/bits/move.h \ + /usr/include/c++/5/bits/concept_check.h \ + /usr/include/c++/5/bits/stl_iterator_base_types.h \ + /usr/include/c++/5/bits/stl_iterator_base_funcs.h \ + /usr/include/c++/5/debug/debug.h /usr/include/c++/5/bits/stl_iterator.h \ + /usr/include/c++/5/bits/ptr_traits.h \ + /usr/include/c++/5/bits/predefined_ops.h \ + /usr/include/c++/5/bits/localefwd.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++locale.h \ + /usr/include/c++/5/clocale /usr/include/locale.h \ + /usr/include/x86_64-linux-gnu/bits/locale.h /usr/include/c++/5/cctype \ + /usr/include/ctype.h /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/c++/5/bits/ios_base.h /usr/include/c++/5/ext/atomicity.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/gthr.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/gthr-default.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/bits/sched.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/bits/timex.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/setjmp.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/atomic_word.h \ + /usr/include/c++/5/bits/locale_classes.h /usr/include/c++/5/string \ + /usr/include/c++/5/bits/allocator.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++allocator.h \ + /usr/include/c++/5/ext/new_allocator.h /usr/include/c++/5/new \ + /usr/include/c++/5/bits/ostream_insert.h \ + /usr/include/c++/5/bits/cxxabi_forced.h \ + /usr/include/c++/5/bits/stl_function.h \ + /usr/include/c++/5/backward/binders.h \ + /usr/include/c++/5/bits/range_access.h \ + /usr/include/c++/5/bits/basic_string.h \ + /usr/include/c++/5/ext/alloc_traits.h \ + /usr/include/c++/5/bits/basic_string.tcc \ + /usr/include/c++/5/bits/locale_classes.tcc /usr/include/c++/5/stdexcept \ + /usr/include/c++/5/streambuf /usr/include/c++/5/bits/streambuf.tcc \ + /usr/include/c++/5/bits/basic_ios.h \ + /usr/include/c++/5/bits/locale_facets.h /usr/include/c++/5/cwctype \ + /usr/include/wctype.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/ctype_base.h \ + /usr/include/c++/5/bits/streambuf_iterator.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/ctype_inline.h \ + /usr/include/c++/5/bits/locale_facets.tcc \ + /usr/include/c++/5/bits/basic_ios.tcc \ + /usr/include/c++/5/bits/ostream.tcc /usr/include/c++/5/istream \ + /usr/include/c++/5/bits/istream.tcc /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/string3.h /usr/include/stdlib.h \ + /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/jni.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h \ + src/jni/GiwsException.hxx + +/usr/include/stdc-predef.h: + +src/jni/FindIconHelper.hxx: + +/usr/include/c++/5/iostream: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/cpu_defines.h: + +/usr/include/c++/5/ostream: + +/usr/include/c++/5/ios: + +/usr/include/c++/5/iosfwd: + +/usr/include/c++/5/bits/stringfwd.h: + +/usr/include/c++/5/bits/memoryfwd.h: + +/usr/include/c++/5/bits/postypes.h: + +/usr/include/c++/5/cwchar: + +/usr/include/wchar.h: + +/usr/include/stdio.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/wchar.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h: + +/usr/include/xlocale.h: + +/usr/include/x86_64-linux-gnu/bits/wchar2.h: + +/usr/include/c++/5/exception: + +/usr/include/c++/5/bits/atomic_lockfree_defines.h: + +/usr/include/c++/5/bits/char_traits.h: + +/usr/include/c++/5/bits/stl_algobase.h: + +/usr/include/c++/5/bits/functexcept.h: + +/usr/include/c++/5/bits/exception_defines.h: + +/usr/include/c++/5/bits/cpp_type_traits.h: + +/usr/include/c++/5/ext/type_traits.h: + +/usr/include/c++/5/ext/numeric_traits.h: + +/usr/include/c++/5/bits/stl_pair.h: + +/usr/include/c++/5/bits/move.h: + +/usr/include/c++/5/bits/concept_check.h: + +/usr/include/c++/5/bits/stl_iterator_base_types.h: + +/usr/include/c++/5/bits/stl_iterator_base_funcs.h: + +/usr/include/c++/5/debug/debug.h: + +/usr/include/c++/5/bits/stl_iterator.h: + +/usr/include/c++/5/bits/ptr_traits.h: + +/usr/include/c++/5/bits/predefined_ops.h: + +/usr/include/c++/5/bits/localefwd.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++locale.h: + +/usr/include/c++/5/clocale: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/include/c++/5/cctype: + +/usr/include/ctype.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/c++/5/bits/ios_base.h: + +/usr/include/c++/5/ext/atomicity.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/gthr.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/gthr-default.h: + +/usr/include/pthread.h: + +/usr/include/sched.h: + +/usr/include/time.h: + +/usr/include/x86_64-linux-gnu/bits/sched.h: + +/usr/include/x86_64-linux-gnu/bits/time.h: + +/usr/include/x86_64-linux-gnu/bits/timex.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/setjmp.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/atomic_word.h: + +/usr/include/c++/5/bits/locale_classes.h: + +/usr/include/c++/5/string: + +/usr/include/c++/5/bits/allocator.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++allocator.h: + +/usr/include/c++/5/ext/new_allocator.h: + +/usr/include/c++/5/new: + +/usr/include/c++/5/bits/ostream_insert.h: + +/usr/include/c++/5/bits/cxxabi_forced.h: + +/usr/include/c++/5/bits/stl_function.h: + +/usr/include/c++/5/backward/binders.h: + +/usr/include/c++/5/bits/range_access.h: + +/usr/include/c++/5/bits/basic_string.h: + +/usr/include/c++/5/ext/alloc_traits.h: + +/usr/include/c++/5/bits/basic_string.tcc: + +/usr/include/c++/5/bits/locale_classes.tcc: + +/usr/include/c++/5/stdexcept: + +/usr/include/c++/5/streambuf: + +/usr/include/c++/5/bits/streambuf.tcc: + +/usr/include/c++/5/bits/basic_ios.h: + +/usr/include/c++/5/bits/locale_facets.h: + +/usr/include/c++/5/cwctype: + +/usr/include/wctype.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/ctype_base.h: + +/usr/include/c++/5/bits/streambuf_iterator.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/ctype_inline.h: + +/usr/include/c++/5/bits/locale_facets.tcc: + +/usr/include/c++/5/bits/basic_ios.tcc: + +/usr/include/c++/5/bits/ostream.tcc: + +/usr/include/c++/5/istream: + +/usr/include/c++/5/bits/istream.tcc: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/string3.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/sigset.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/alloca.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/jni.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h: + +src/jni/GiwsException.hxx: diff --git a/modules/commons/src/jni/.deps/libscicommons_la-GiwsException.Plo b/modules/commons/src/jni/.deps/libscicommons_la-GiwsException.Plo new file mode 100755 index 000000000..1c54004c8 --- /dev/null +++ b/modules/commons/src/jni/.deps/libscicommons_la-GiwsException.Plo @@ -0,0 +1,338 @@ +src/jni/libscicommons_la-GiwsException.lo: src/jni/GiwsException.cpp \ + /usr/include/stdc-predef.h src/jni/GiwsException.hxx \ + /usr/include/c++/5/iostream \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/cpu_defines.h \ + /usr/include/c++/5/ostream /usr/include/c++/5/ios \ + /usr/include/c++/5/iosfwd /usr/include/c++/5/bits/stringfwd.h \ + /usr/include/c++/5/bits/memoryfwd.h /usr/include/c++/5/bits/postypes.h \ + /usr/include/c++/5/cwchar /usr/include/wchar.h /usr/include/stdio.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h /usr/include/xlocale.h \ + /usr/include/x86_64-linux-gnu/bits/wchar2.h /usr/include/c++/5/exception \ + /usr/include/c++/5/bits/atomic_lockfree_defines.h \ + /usr/include/c++/5/bits/char_traits.h \ + /usr/include/c++/5/bits/stl_algobase.h \ + /usr/include/c++/5/bits/functexcept.h \ + /usr/include/c++/5/bits/exception_defines.h \ + /usr/include/c++/5/bits/cpp_type_traits.h \ + /usr/include/c++/5/ext/type_traits.h \ + /usr/include/c++/5/ext/numeric_traits.h \ + /usr/include/c++/5/bits/stl_pair.h /usr/include/c++/5/bits/move.h \ + /usr/include/c++/5/bits/concept_check.h \ + /usr/include/c++/5/bits/stl_iterator_base_types.h \ + /usr/include/c++/5/bits/stl_iterator_base_funcs.h \ + /usr/include/c++/5/debug/debug.h /usr/include/c++/5/bits/stl_iterator.h \ + /usr/include/c++/5/bits/ptr_traits.h \ + /usr/include/c++/5/bits/predefined_ops.h \ + /usr/include/c++/5/bits/localefwd.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++locale.h \ + /usr/include/c++/5/clocale /usr/include/locale.h \ + /usr/include/x86_64-linux-gnu/bits/locale.h /usr/include/c++/5/cctype \ + /usr/include/ctype.h /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/c++/5/bits/ios_base.h /usr/include/c++/5/ext/atomicity.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/gthr.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/gthr-default.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/bits/sched.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/bits/timex.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \ + /usr/include/x86_64-linux-gnu/bits/setjmp.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/atomic_word.h \ + /usr/include/c++/5/bits/locale_classes.h /usr/include/c++/5/string \ + /usr/include/c++/5/bits/allocator.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/c++allocator.h \ + /usr/include/c++/5/ext/new_allocator.h /usr/include/c++/5/new \ + /usr/include/c++/5/bits/ostream_insert.h \ + /usr/include/c++/5/bits/cxxabi_forced.h \ + /usr/include/c++/5/bits/stl_function.h \ + /usr/include/c++/5/backward/binders.h \ + /usr/include/c++/5/bits/range_access.h \ + /usr/include/c++/5/bits/basic_string.h \ + /usr/include/c++/5/ext/alloc_traits.h \ + /usr/include/c++/5/bits/basic_string.tcc \ + /usr/include/c++/5/bits/locale_classes.tcc /usr/include/c++/5/stdexcept \ + /usr/include/c++/5/streambuf /usr/include/c++/5/bits/streambuf.tcc \ + /usr/include/c++/5/bits/basic_ios.h \ + /usr/include/c++/5/bits/locale_facets.h /usr/include/c++/5/cwctype \ + /usr/include/wctype.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/ctype_base.h \ + /usr/include/c++/5/bits/streambuf_iterator.h \ + /usr/include/x86_64-linux-gnu/c++/5/bits/ctype_inline.h \ + /usr/include/c++/5/bits/locale_facets.tcc \ + /usr/include/c++/5/bits/basic_ios.tcc \ + /usr/include/c++/5/bits/ostream.tcc /usr/include/c++/5/istream \ + /usr/include/c++/5/bits/istream.tcc /usr/include/string.h \ + /usr/include/x86_64-linux-gnu/bits/string3.h /usr/include/stdlib.h \ + /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/jni.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h + +/usr/include/stdc-predef.h: + +src/jni/GiwsException.hxx: + +/usr/include/c++/5/iostream: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/cpu_defines.h: + +/usr/include/c++/5/ostream: + +/usr/include/c++/5/ios: + +/usr/include/c++/5/iosfwd: + +/usr/include/c++/5/bits/stringfwd.h: + +/usr/include/c++/5/bits/memoryfwd.h: + +/usr/include/c++/5/bits/postypes.h: + +/usr/include/c++/5/cwchar: + +/usr/include/wchar.h: + +/usr/include/stdio.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/wchar.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h: + +/usr/include/xlocale.h: + +/usr/include/x86_64-linux-gnu/bits/wchar2.h: + +/usr/include/c++/5/exception: + +/usr/include/c++/5/bits/atomic_lockfree_defines.h: + +/usr/include/c++/5/bits/char_traits.h: + +/usr/include/c++/5/bits/stl_algobase.h: + +/usr/include/c++/5/bits/functexcept.h: + +/usr/include/c++/5/bits/exception_defines.h: + +/usr/include/c++/5/bits/cpp_type_traits.h: + +/usr/include/c++/5/ext/type_traits.h: + +/usr/include/c++/5/ext/numeric_traits.h: + +/usr/include/c++/5/bits/stl_pair.h: + +/usr/include/c++/5/bits/move.h: + +/usr/include/c++/5/bits/concept_check.h: + +/usr/include/c++/5/bits/stl_iterator_base_types.h: + +/usr/include/c++/5/bits/stl_iterator_base_funcs.h: + +/usr/include/c++/5/debug/debug.h: + +/usr/include/c++/5/bits/stl_iterator.h: + +/usr/include/c++/5/bits/ptr_traits.h: + +/usr/include/c++/5/bits/predefined_ops.h: + +/usr/include/c++/5/bits/localefwd.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++locale.h: + +/usr/include/c++/5/clocale: + +/usr/include/locale.h: + +/usr/include/x86_64-linux-gnu/bits/locale.h: + +/usr/include/c++/5/cctype: + +/usr/include/ctype.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/c++/5/bits/ios_base.h: + +/usr/include/c++/5/ext/atomicity.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/gthr.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/gthr-default.h: + +/usr/include/pthread.h: + +/usr/include/sched.h: + +/usr/include/time.h: + +/usr/include/x86_64-linux-gnu/bits/sched.h: + +/usr/include/x86_64-linux-gnu/bits/time.h: + +/usr/include/x86_64-linux-gnu/bits/timex.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/x86_64-linux-gnu/bits/setjmp.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/atomic_word.h: + +/usr/include/c++/5/bits/locale_classes.h: + +/usr/include/c++/5/string: + +/usr/include/c++/5/bits/allocator.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/c++allocator.h: + +/usr/include/c++/5/ext/new_allocator.h: + +/usr/include/c++/5/new: + +/usr/include/c++/5/bits/ostream_insert.h: + +/usr/include/c++/5/bits/cxxabi_forced.h: + +/usr/include/c++/5/bits/stl_function.h: + +/usr/include/c++/5/backward/binders.h: + +/usr/include/c++/5/bits/range_access.h: + +/usr/include/c++/5/bits/basic_string.h: + +/usr/include/c++/5/ext/alloc_traits.h: + +/usr/include/c++/5/bits/basic_string.tcc: + +/usr/include/c++/5/bits/locale_classes.tcc: + +/usr/include/c++/5/stdexcept: + +/usr/include/c++/5/streambuf: + +/usr/include/c++/5/bits/streambuf.tcc: + +/usr/include/c++/5/bits/basic_ios.h: + +/usr/include/c++/5/bits/locale_facets.h: + +/usr/include/c++/5/cwctype: + +/usr/include/wctype.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/ctype_base.h: + +/usr/include/c++/5/bits/streambuf_iterator.h: + +/usr/include/x86_64-linux-gnu/c++/5/bits/ctype_inline.h: + +/usr/include/c++/5/bits/locale_facets.tcc: + +/usr/include/c++/5/bits/basic_ios.tcc: + +/usr/include/c++/5/bits/ostream.tcc: + +/usr/include/c++/5/istream: + +/usr/include/c++/5/bits/istream.tcc: + +/usr/include/string.h: + +/usr/include/x86_64-linux-gnu/bits/string3.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/sigset.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/alloca.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/jni.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h: diff --git a/modules/commons/src/jni/.deps/libscicommons_la-ScilabCommons_wrap.Plo b/modules/commons/src/jni/.deps/libscicommons_la-ScilabCommons_wrap.Plo new file mode 100755 index 000000000..e7b97426e --- /dev/null +++ b/modules/commons/src/jni/.deps/libscicommons_la-ScilabCommons_wrap.Plo @@ -0,0 +1,180 @@ +src/jni/libscicommons_la-ScilabCommons_wrap.lo: \ + src/jni/ScilabCommons_wrap.c /usr/include/stdc-predef.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/jni.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h \ + /usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h \ + /usr/include/stdlib.h /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/string.h \ + /usr/include/xlocale.h /usr/include/x86_64-linux-gnu/bits/string.h \ + /usr/include/x86_64-linux-gnu/bits/string2.h \ + /usr/include/x86_64-linux-gnu/bits/string3.h \ + src/jni/../../../core/includes/SCIHOME.h \ + src/jni/../../../core/includes/BOOL.h \ + src/jni/../../../core/includes/tmpdir.h \ + /usr/include/x86_64-linux-gnu/bits/wchar.h \ + /usr/include/x86_64-linux-gnu/bits/wchar2.h \ + src/jni/../../../core/includes/machine.h \ + src/jni/../../../fileio/includes/createtempfilename.h \ + src/jni/../../../fileio/includes/dynlib_fileio.h \ + ../../modules/localization/includes/charEncoding.h \ + /usr/include/x86_64-linux-gnu/sys/stat.h \ + /usr/include/x86_64-linux-gnu/bits/stat.h \ + ../../modules/core/includes/MALLOC.h \ + ../../modules/core/includes/sci_mem_alloc.h \ + ../../modules/core/includes/BOOL.h \ + src/jni/../../../localization/includes/setgetlanguage.h \ + src/jni/../../../core/includes/getversion.h \ + src/jni/../../../core/includes/setieee.h \ + src/jni/../../../core/includes/setformat.h + +/usr/include/stdc-predef.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/jni.h: + +/usr/include/stdio.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/wchar.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/lib/jvm/java-8-openjdk-amd64/include/linux/jni_md.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/time.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/sigset.h: + +/usr/include/x86_64-linux-gnu/bits/time.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/alloca.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/string.h: + +/usr/include/xlocale.h: + +/usr/include/x86_64-linux-gnu/bits/string.h: + +/usr/include/x86_64-linux-gnu/bits/string2.h: + +/usr/include/x86_64-linux-gnu/bits/string3.h: + +src/jni/../../../core/includes/SCIHOME.h: + +src/jni/../../../core/includes/BOOL.h: + +src/jni/../../../core/includes/tmpdir.h: + +/usr/include/x86_64-linux-gnu/bits/wchar.h: + +/usr/include/x86_64-linux-gnu/bits/wchar2.h: + +src/jni/../../../core/includes/machine.h: + +src/jni/../../../fileio/includes/createtempfilename.h: + +src/jni/../../../fileio/includes/dynlib_fileio.h: + +../../modules/localization/includes/charEncoding.h: + +/usr/include/x86_64-linux-gnu/sys/stat.h: + +/usr/include/x86_64-linux-gnu/bits/stat.h: + +../../modules/core/includes/MALLOC.h: + +../../modules/core/includes/sci_mem_alloc.h: + +../../modules/core/includes/BOOL.h: + +src/jni/../../../localization/includes/setgetlanguage.h: + +src/jni/../../../core/includes/getversion.h: + +src/jni/../../../core/includes/setieee.h: + +src/jni/../../../core/includes/setformat.h: diff --git a/modules/commons/src/jni/.dirstamp b/modules/commons/src/jni/.dirstamp new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/modules/commons/src/jni/.dirstamp diff --git a/modules/commons/src/jni/.libs/libscicommons_la-CommonFileUtils_wrap.o b/modules/commons/src/jni/.libs/libscicommons_la-CommonFileUtils_wrap.o Binary files differnew file mode 100755 index 000000000..c72d54b37 --- /dev/null +++ b/modules/commons/src/jni/.libs/libscicommons_la-CommonFileUtils_wrap.o diff --git a/modules/commons/src/jni/.libs/libscicommons_la-FindIconHelper.o b/modules/commons/src/jni/.libs/libscicommons_la-FindIconHelper.o Binary files differnew file mode 100755 index 000000000..5204e75ca --- /dev/null +++ b/modules/commons/src/jni/.libs/libscicommons_la-FindIconHelper.o diff --git a/modules/commons/src/jni/.libs/libscicommons_la-GiwsException.o b/modules/commons/src/jni/.libs/libscicommons_la-GiwsException.o Binary files differnew file mode 100755 index 000000000..d0c5f49d8 --- /dev/null +++ b/modules/commons/src/jni/.libs/libscicommons_la-GiwsException.o diff --git a/modules/commons/src/jni/.libs/libscicommons_la-ScilabCommons_wrap.o b/modules/commons/src/jni/.libs/libscicommons_la-ScilabCommons_wrap.o Binary files differnew file mode 100755 index 000000000..7f12479d5 --- /dev/null +++ b/modules/commons/src/jni/.libs/libscicommons_la-ScilabCommons_wrap.o diff --git a/modules/commons/src/jni/CommonFileUtils.i b/modules/commons/src/jni/CommonFileUtils.i new file mode 100755 index 000000000..2d64b3dce --- /dev/null +++ b/modules/commons/src/jni/CommonFileUtils.i @@ -0,0 +1,106 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) DIGITEO - 2011 - Calixte DENIZET + * + * 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.1-en.txt + * + */ + + +/* CommonFileUtils.i */ +/** + * Windows: swig -java -package org.scilab.modules.commons -outdir ../java/org/scilab/modules/commons/ CommonFileUtils.i + * Other: Use the option --enable-build-swig to the configure +*/ +%module CommonFileUtils +%{ +#include "../../includes/fileutils.h" +#include "MALLOC.h" +%} + +%include "../../../jvm/src/jni/scilab_typemaps.i" + +/* JavaDoc for CommonFileUtilsJNI class */ +%pragma(java) jniclassclassmodifiers=%{ +/* It is generated code. Disable checkstyle */ +//CHECKSTYLE:OFF + /** + * Some file utils + * @author Calixte DENIZET + * @copyright DIGITEO 2011 + */ +public class%} + +/* Constructor for CommonFileUtilsJNI class */ +%pragma(java) jniclasscode=" + /** + * Constructor + */ + protected CommonFileUtilsJNI() { + throw new UnsupportedOperationException(); + }"; + +/* static load of library */ +%pragma(java) jniclasscode=%{ + static { + try { + System.loadLibrary("scicommons"); + } catch (SecurityException e) { + System.err.println("A security manager exists and does not allow the loading of the specified dynamic library."); + System.err.println(e.getLocalizedMessage()); + System.exit(-1); + } catch (UnsatisfiedLinkError e) { + System.err.println("The native library scicommons does not exist or cannot be found."); + if (System.getenv("CONTINUE_ON_JNI_ERROR") == null) { + System.err.println(e.getLocalizedMessage()); + System.err.println("Current java.library.path is : "+System.getProperty("java.library.path")); + System.exit(-1); + }else{ + System.err.println("Continuing anyway because of CONTINUE_ON_JNI_ERROR"); + } + } + } +%} + + +/* JavaDoc for CommonFileUtils class */ +%pragma(java) moduleclassmodifiers=" + /** + * Some file utils + * @author Calixte DENIZET + * @copyright DIGITEO 2011 + */ +public class"; + +/* Constructor for CommonFileUtils class */ +%pragma(java) modulecode=" + /** + * Constructor + */ + protected CommonFileUtils() { + throw new UnsupportedOperationException(); + }"; + +/* JavaDoc */ +%javamethodmodifiers isEmptyDirectory(String dirName) " + /** + * Test if a directory is empty or not + * @param dirName the directory name + * @return true if it is a directory + */ +public"; +int isEmptyDirectory(char * dirName); + +/* JavaDoc */ +%javamethodmodifiers getCWD() " + /** + * Get the current working directory + * @return the Scilab CWD + */ +public"; +char * getCWD(); + diff --git a/modules/commons/src/jni/CommonFileUtils_wrap.c b/modules/commons/src/jni/CommonFileUtils_wrap.c new file mode 100755 index 000000000..0e518381e --- /dev/null +++ b/modules/commons/src/jni/CommonFileUtils_wrap.c @@ -0,0 +1,239 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.7 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGJAVA + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + + + +/* Fix for jlong on some versions of gcc on Windows */ +#if defined(__GNUC__) && !defined(__INTEL_COMPILER) + typedef long long __int64; +#endif + +/* Fix for jlong on 64-bit x86 Solaris */ +#if defined(__x86_64) +# ifdef _LP64 +# undef _LP64 +# endif +#endif + +#include <jni.h> +#include <stdlib.h> +#include <string.h> + + +/* Support for throwing Java exceptions */ +typedef enum { + SWIG_JavaOutOfMemoryError = 1, + SWIG_JavaIOException, + SWIG_JavaRuntimeException, + SWIG_JavaIndexOutOfBoundsException, + SWIG_JavaArithmeticException, + SWIG_JavaIllegalArgumentException, + SWIG_JavaNullPointerException, + SWIG_JavaDirectorPureVirtual, + SWIG_JavaUnknownError +} SWIG_JavaExceptionCodes; + +typedef struct { + SWIG_JavaExceptionCodes code; + const char *java_exception; +} SWIG_JavaExceptions_t; + + +static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) { + jclass excep; + static const SWIG_JavaExceptions_t java_exceptions[] = { + { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" }, + { SWIG_JavaIOException, "java/io/IOException" }, + { SWIG_JavaRuntimeException, "java/lang/RuntimeException" }, + { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" }, + { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" }, + { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" }, + { SWIG_JavaNullPointerException, "java/lang/NullPointerException" }, + { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" }, + { SWIG_JavaUnknownError, "java/lang/UnknownError" }, + { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } + }; + const SWIG_JavaExceptions_t *except_ptr = java_exceptions; + + while (except_ptr->code != code && except_ptr->code) + except_ptr++; + + (*jenv)->ExceptionClear(jenv); + excep = (*jenv)->FindClass(jenv, except_ptr->java_exception); + if (excep) + (*jenv)->ThrowNew(jenv, excep, msg); +} + + +/* Contract support */ + +#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else + + +#include "../../includes/fileutils.h" +#include "MALLOC.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGEXPORT jint JNICALL Java_org_scilab_modules_commons_CommonFileUtilsJNI_isEmptyDirectory(JNIEnv *jenv, jclass jcls, jstring jarg1) { + jint jresult = 0 ; + char *arg1 = (char *) 0 ; + int result; + + (void)jenv; + (void)jcls; + arg1 = 0; + if (jarg1) { + arg1 = (char *)(*jenv)->GetStringUTFChars(jenv, jarg1, 0); + if (!arg1) return 0; + } + result = (int)isEmptyDirectory(arg1); + jresult = (jint)result; + if (arg1) (*jenv)->ReleaseStringUTFChars(jenv, jarg1, (const char *)arg1); + return jresult; +} + + +SWIGEXPORT jstring JNICALL Java_org_scilab_modules_commons_CommonFileUtilsJNI_getCWD(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result = 0 ; + + (void)jenv; + (void)jcls; + result = (char *)getCWD(); + { + if (result != NULL) + { + jresult = (*jenv)->NewStringUTF(jenv, (const char *)result); + FREE(result); + result = NULL; + } + } + return jresult; +} + + +#ifdef __cplusplus +} +#endif + diff --git a/modules/commons/src/jni/FindIconHelper.cpp b/modules/commons/src/jni/FindIconHelper.cpp new file mode 100755 index 000000000..8fedec0c2 --- /dev/null +++ b/modules/commons/src/jni/FindIconHelper.cpp @@ -0,0 +1,224 @@ +#include "FindIconHelper.hxx" +/* Generated by GIWS (version 2.0.2) with command: +giws --disable-return-size-array --output-dir src/jni --throws-exception-on-error --description-file src\jni\FindIconHelper.xml +*/ +/* + +This is generated code. + +This software is a computer program whose purpose is to hide the complexity +of accessing Java objects/methods from C++ code. + +This software is governed by the CeCILL-B license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL-B +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL-B license and that you accept its terms. +*/ + +namespace org_scilab_modules_commons_gui { + + // Static declarations (if any) + +// Returns the current env + +JNIEnv * FindIconHelper::getCurrentEnv() { +JNIEnv * curEnv = NULL; +jint res=this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +if (res != JNI_OK) { +throw GiwsException::JniException(getCurrentEnv()); +} +return curEnv; +} +// Destructor + +FindIconHelper::~FindIconHelper() { +JNIEnv * curEnv = NULL; +this->jvm->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +curEnv->DeleteGlobalRef(this->instance); +curEnv->DeleteGlobalRef(this->instanceClass); +} +// Constructors +FindIconHelper::FindIconHelper(JavaVM * jvm_) { +jmethodID constructObject = NULL ; +jobject localInstance ; +jclass localClass ; + +const std::string construct="<init>"; +const std::string param="()V"; +jvm=jvm_; + +JNIEnv * curEnv = getCurrentEnv(); + +localClass = curEnv->FindClass( this->className().c_str() ) ; +if (localClass == NULL) { + throw GiwsException::JniClassNotFoundException(curEnv, this->className()); +} + +this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass)); + +/* localClass is not needed anymore */ +curEnv->DeleteLocalRef(localClass); + +if (this->instanceClass == NULL) { +throw GiwsException::JniObjectCreationException(curEnv, this->className()); +} + + +constructObject = curEnv->GetMethodID( this->instanceClass, construct.c_str() , param.c_str() ) ; +if(constructObject == NULL){ +throw GiwsException::JniObjectCreationException(curEnv, this->className()); +} + +localInstance = curEnv->NewObject( this->instanceClass, constructObject ) ; +if(localInstance == NULL){ +throw GiwsException::JniObjectCreationException(curEnv, this->className()); +} + +this->instance = curEnv->NewGlobalRef(localInstance) ; +if(this->instance == NULL){ +throw GiwsException::JniObjectCreationException(curEnv, this->className()); +} +/* localInstance not needed anymore */ +curEnv->DeleteLocalRef(localInstance); + + /* Methods ID set to NULL */ +voidaddThemePathjstringjava_lang_StringID=NULL; +jstringfindIconjstringjava_lang_StringjbooleanbooleanID=NULL; + + +} + +FindIconHelper::FindIconHelper(JavaVM * jvm_, jobject JObj) { + jvm=jvm_; + + JNIEnv * curEnv = getCurrentEnv(); + +jclass localClass = curEnv->GetObjectClass(JObj); + this->instanceClass = static_cast<jclass>(curEnv->NewGlobalRef(localClass)); + curEnv->DeleteLocalRef(localClass); + + if (this->instanceClass == NULL) { +throw GiwsException::JniObjectCreationException(curEnv, this->className()); + } + + this->instance = curEnv->NewGlobalRef(JObj) ; + if(this->instance == NULL){ +throw GiwsException::JniObjectCreationException(curEnv, this->className()); + } + /* Methods ID set to NULL */ + voidaddThemePathjstringjava_lang_StringID=NULL; +jstringfindIconjstringjava_lang_StringjbooleanbooleanID=NULL; + + +} + +// Generic methods + +void FindIconHelper::synchronize() { +if (getCurrentEnv()->MonitorEnter(instance) != JNI_OK) { +throw GiwsException::JniMonitorException(getCurrentEnv(), "FindIconHelper"); +} +} + +void FindIconHelper::endSynchronize() { +if ( getCurrentEnv()->MonitorExit(instance) != JNI_OK) { +throw GiwsException::JniMonitorException(getCurrentEnv(), "FindIconHelper"); +} +} +// Method(s) + +void FindIconHelper::addThemePath (JavaVM * jvm_, char const* path){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID voidaddThemePathjstringjava_lang_StringID = curEnv->GetStaticMethodID(cls, "addThemePath", "(Ljava/lang/String;)V" ) ; +if (voidaddThemePathjstringjava_lang_StringID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "addThemePath"); +} + +jstring path_ = curEnv->NewStringUTF( path ); +if (path != NULL && path_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + + curEnv->CallStaticVoidMethod(cls, voidaddThemePathjstringjava_lang_StringID ,path_); + curEnv->DeleteLocalRef(path_); +if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +} +} + +char* FindIconHelper::findIcon (JavaVM * jvm_, char const* path, bool defaultValue){ + +JNIEnv * curEnv = NULL; +jvm_->AttachCurrentThread(reinterpret_cast<void **>(&curEnv), NULL); +jclass cls = initClass(curEnv); +if ( cls == NULL) { +throw GiwsException::JniCallMethodException(curEnv); +} + +static jmethodID jstringfindIconjstringjava_lang_StringjbooleanbooleanID = curEnv->GetStaticMethodID(cls, "findIcon", "(Ljava/lang/String;Z)Ljava/lang/String;" ) ; +if (jstringfindIconjstringjava_lang_StringjbooleanbooleanID == NULL) { +throw GiwsException::JniMethodNotFoundException(curEnv, "findIcon"); +} + +jstring path_ = curEnv->NewStringUTF( path ); +if (path != NULL && path_ == NULL) +{ +throw GiwsException::JniBadAllocException(curEnv); +} + + +jboolean defaultValue_ = (static_cast<bool>(defaultValue) ? JNI_TRUE : JNI_FALSE); + + jstring res = static_cast<jstring>( curEnv->CallStaticObjectMethod(cls, jstringfindIconjstringjava_lang_StringjbooleanbooleanID ,path_, defaultValue_)); + if (curEnv->ExceptionCheck()) { +throw GiwsException::JniCallMethodException(curEnv); +}if (res != NULL) { + +const char *tempString = curEnv->GetStringUTFChars(res, 0); +char * myStringBuffer = new char[strlen(tempString) + 1]; +strcpy(myStringBuffer, tempString); +curEnv->ReleaseStringUTFChars(res, tempString); +curEnv->DeleteLocalRef(res); +curEnv->DeleteLocalRef(path_); +if (curEnv->ExceptionCheck()) { +delete[] myStringBuffer; + throw GiwsException::JniCallMethodException(curEnv); +} +return myStringBuffer; + } else { +curEnv->DeleteLocalRef(res); +return NULL; +} +} + +} diff --git a/modules/commons/src/jni/FindIconHelper.hxx b/modules/commons/src/jni/FindIconHelper.hxx new file mode 100755 index 000000000..04e71b3b2 --- /dev/null +++ b/modules/commons/src/jni/FindIconHelper.hxx @@ -0,0 +1,181 @@ +/* Generated by GIWS (version 2.0.2) with command: +giws --disable-return-size-array --output-dir src/jni --throws-exception-on-error --description-file src\jni\FindIconHelper.xml +*/ +/* + +This is generated code. + +This software is a computer program whose purpose is to hide the complexity +of accessing Java objects/methods from C++ code. + +This software is governed by the CeCILL-B license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL-B +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL-B license and that you accept its terms. +*/ + + +#ifndef __ORG_SCILAB_MODULES_COMMONS_GUI_FINDICONHELPER__ +#define __ORG_SCILAB_MODULES_COMMONS_GUI_FINDICONHELPER__ +#include <iostream> +#include <string> +#include <string.h> +#include <stdlib.h> +#include <jni.h> + +#include "GiwsException.hxx" + + #if defined(_MSC_VER) /* Defined anyway with Visual */ + #include <Windows.h> + #else + typedef signed char byte; + #endif + + +#ifndef GIWSEXPORT +# if defined(_MSC_VER) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define GIWSEXPORT +# else +# define GIWSEXPORT __declspec(dllexport) +# endif +# else +# if __GNUC__ >= 4 +# define GIWSEXPORT __attribute__ ((visibility ("default"))) +# else +# define GIWSEXPORT +# endif +# endif +#endif + +namespace org_scilab_modules_commons_gui { +class GIWSEXPORT FindIconHelper { + +private: +JavaVM * jvm; + +protected: +jmethodID voidaddThemePathjstringjava_lang_StringID; // cache method id +jmethodID jstringfindIconjstringjava_lang_StringjbooleanbooleanID; // cache method id + + + +jobject instance; +jclass instanceClass; // cache class + + +// Caching (if any) + + +/** +* Get the environment matching to the current thread. +*/ +virtual JNIEnv * getCurrentEnv(); + +public: +// Constructor +/** +* Create a wrapping of the object from a JNIEnv. +* It will call the default constructor +* @param JEnv_ the Java Env +*/ +FindIconHelper(JavaVM * jvm_); + +/** +* Create a wrapping of an already existing object from a JNIEnv. +* The object must have already been instantiated +* @param JEnv_ the Java Env +* @param JObj the object +*/ +FindIconHelper(JavaVM * jvm_, jobject JObj); + + +/** +* This is a fake constructor to avoid the constructor +* chaining when dealing with extended giws classes +*/ +#ifdef FAKEGIWSDATATYPE +FindIconHelper(fakeGiwsDataType::fakeGiwsDataType /* unused */) {} +#endif + +// Destructor +~FindIconHelper(); + +// Generic method +// Synchronization methods +/** +* Enter monitor associated with the object. +* Equivalent of creating a "synchronized(obj)" scope in Java. +*/ +void synchronize(); + +/** +* Exit monitor associated with the object. +* Equivalent of ending a "synchronized(obj)" scope. +*/ +void endSynchronize(); + +// Methods +static void addThemePath(JavaVM * jvm_, char const* path); + +static char* findIcon(JavaVM * jvm_, char const* path, bool defaultValue); + + + /** + * Get class name to use for static methods + * @return class name to use for static methods + */ + + static const std::string className() + { + return "org/scilab/modules/commons/gui/FindIconHelper"; + } + + + /** + * Get class to use for static methods + * @return class to use for static methods + */ + + static jclass initClass(JNIEnv * curEnv) + { + static jclass cls = 0; + + if (cls == 0) + { + jclass _cls = curEnv->FindClass(className().c_str()); + if (_cls) + { + cls = static_cast<jclass>(curEnv->NewGlobalRef(_cls)); + } + } + + return cls; + } + +}; + + +} +#endif diff --git a/modules/commons/src/jni/FindIconHelper.xml b/modules/commons/src/jni/FindIconHelper.xml new file mode 100755 index 000000000..a9b225661 --- /dev/null +++ b/modules/commons/src/jni/FindIconHelper.xml @@ -0,0 +1,23 @@ +<!-- + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS + * + * 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.1-en.txt + * + --> + +<package name="org.scilab.modules.commons.gui"> + <object name="FindIconHelper"> + <method name="addThemePath" returnType="void" modifier="static"> + <parameter name="path" type="String"/> + </method> + <method name="findIcon" returnType="String" modifier="static"> + <parameter name="path" type="String"/> + <parameter name="defaultValue" type="boolean"/> + </method> + </object> +</package> diff --git a/modules/commons/src/jni/GiwsException.cpp b/modules/commons/src/jni/GiwsException.cpp new file mode 100755 index 000000000..4706533df --- /dev/null +++ b/modules/commons/src/jni/GiwsException.cpp @@ -0,0 +1,361 @@ +/* Generated by GIWS (version 2.0.2) */ +/* + +This is generated code. + +This software is a computer program whose purpose is to hide the complexity +of accessing Java objects/methods from C++ code. + +This software is governed by the CeCILL-B license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL-B +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL-B license and that you accept its terms. +*/ + +#include "GiwsException.hxx" +namespace GiwsException { + + + +/** +* Each subclass of JniExcpetion should call the super constructor +* and the setErrorMessage function to set the message. +* @param curEnv java envirnonment where the exception occurred. +*/ +JniException::JniException(JNIEnv * curEnv) throw() : exception() +{ +// retrieve information about the exception +javaException = curEnv->ExceptionOccurred(); +/* Clear the Java Exception to avoid calling it again & again */ +curEnv->ExceptionClear(); +m_oJavaMessage = this->retrieveExceptionMessage(curEnv); +m_oJavaStackTrace = this->retrieveStackTrace(curEnv); +m_oJavaExceptionName = this->retrieveExceptionName(curEnv); + +// by default JniExceptions display teh stack trace +setErrorMessage(m_oJavaMessage + "\n" + m_oJavaStackTrace); +curEnv->DeleteLocalRef(javaException); +closeException(curEnv); +} + +JniException::~JniException(void) throw() +{ +m_oErrorMessage.clear(); +} + +/** +* @return a description of the exception +* @deprecated This function could lead to side effect error. Please use whatStr +*/ +const char * JniException::what(void) const throw() +{ +return m_oErrorMessage.c_str(); +} + +/** +* @return a description of the exception +*/ +std::string JniException::whatStr(void) const throw() +{ +return m_oErrorMessage; +} + +/** +* @return Java description of the exception. +*/ +std::string JniException::getJavaDescription(void) const throw() +{ +return m_oJavaMessage; +} + +/** +* @return Java stack trace where the exception occurred. +*/ +std::string JniException::getJavaStackTrace(void) const throw() +{ +return m_oJavaStackTrace; +} + +/** +* Get the name of the exception (ie its class name). +*/ +std::string JniException::getJavaExceptionName(void) const throw() +{ +return m_oJavaExceptionName; +} + + +/** +* Set the error message that the exception should print. +*/ +void JniException::setErrorMessage(const std::string & errorMessage) +{ +m_oErrorMessage = errorMessage; +} + +/** +* Get the message that the exception will print. +*/ +std::string JniException::getErrorMessage(void) const +{ +return m_oErrorMessage; +} + +/** +* @return error message of the exception. +*/ +std::string JniException::retrieveExceptionMessage(JNIEnv * curEnv) +{ +// return the result of the getLocalizedMessage method + +// retrieve information from the exception. +// get method id +jmethodID getLocalizedMessageId = curEnv->GetMethodID(curEnv->GetObjectClass(javaException), + "getLocalizedMessage", + "()Ljava/lang/String;"); + +// call getLocalizedMessage +jstring description = (jstring) curEnv->CallObjectMethod(javaException, getLocalizedMessageId); + +if (description == NULL) +{ + return ""; +} + +std::string res = convertJavaString(curEnv, description); + +// release java resources +curEnv->DeleteLocalRef(description); + +return res; + } + + /** + * @return full stack trace when the exception occurred. + */ + std::string JniException::retrieveStackTrace(JNIEnv * curEnv) + { + + +// return the result of the getStackTrace method + +// retrieve information from the exception. +// get method id +// getStackTrace returns an array of StackTraceElement +jmethodID getStackTraceId = curEnv->GetMethodID(curEnv->GetObjectClass(javaException), +"getStackTrace", +"()[Ljava/lang/StackTraceElement;"); + +// call getStackTrace +jobjectArray stackTrace = (jobjectArray) curEnv->CallObjectMethod(javaException, getStackTraceId); + +if (stackTrace == NULL) +{ + return ""; +} + +// get length of the array +jsize stackTraceLength = curEnv->GetArrayLength(stackTrace); +std::string res = ""; + +// get toString methodId of StackTraceElement class +jclass stackTraceElementClass = curEnv->FindClass("java/lang/StackTraceElement"); +jmethodID toStringId = curEnv->GetMethodID(stackTraceElementClass, "toString", "()Ljava/lang/String;"); + +for (jsize i = 0; i < stackTraceLength; i++) +{ + // add the result of toString method of each element in the result + jobject curStackTraceElement = curEnv->GetObjectArrayElement(stackTrace, i); + + // call to string on the object + jstring stackElementString = (jstring) curEnv->CallObjectMethod(curStackTraceElement, toStringId); + + if (stackElementString == NULL) + { +curEnv->DeleteLocalRef(stackTraceElementClass); +curEnv->DeleteLocalRef(stackTrace); +curEnv->DeleteLocalRef(curStackTraceElement); +return res; + } + + // add a line to res + res += " at " + convertJavaString(curEnv, stackElementString) + "\n"; + + curEnv->DeleteLocalRef(curStackTraceElement); + curEnv->DeleteLocalRef(stackElementString); +} + +// release java resources +curEnv->DeleteLocalRef(stackTraceElementClass); +curEnv->DeleteLocalRef(stackTrace); + + +return res; + } + + /** + * @return string containing the name of the exception (ie its class name). + */ + std::string JniException::retrieveExceptionName(JNIEnv * curEnv) + { + +// then get its class +jclass exceptionClass = curEnv->GetObjectClass(javaException); + +// get the Class class +// we could also use curEnv->FindClass("Class"); +jclass classClass = curEnv->GetObjectClass(exceptionClass); + +// get the getName method +jmethodID getNameId = curEnv->GetMethodID(classClass, "getName", "()Ljava/lang/String;"); + +// call the getName function +jstring javaName = (jstring) curEnv->CallObjectMethod(exceptionClass, getNameId); + +if (javaName == NULL) +{ + return ""; +} + +std::string res = convertJavaString(curEnv, javaName); + +// release java resources +curEnv->DeleteLocalRef(exceptionClass); +curEnv->DeleteLocalRef(classClass); +curEnv->DeleteLocalRef(javaName); + +return res; + } + + /** + * To be called when all the information about the exceptions have been + * retrived. + * Remove the exception from the environment. + */ + void JniException::closeException(JNIEnv * curEnv) + { +// remove the exception from the environment +// Beware, the exception is no longer reachable +curEnv->ExceptionClear(); + } + + /** + * Convert a Java string (jstring) into a C++ string + */ + std::string JniException::convertJavaString(JNIEnv * curEnv, jstring javaString) + { +// get a pointer on a C string +const char * tempString = curEnv->GetStringUTFChars(javaString, 0); + +// convert the C string into a C++ string +std::string res(tempString); + +// release pointer +curEnv->ReleaseStringUTFChars(javaString, tempString); + +return res; + } + + + /** + * Exception that should be thrown when allocation of Java resources from C++ + * code fails (sur as NewDoubleArray or NewStringUTF). + */ + + JniBadAllocException::JniBadAllocException(JNIEnv * curEnv) throw() : JniException() + { + std::string message = "Error no more memory."; + setErrorMessage(message); + } + + JniBadAllocException::~JniBadAllocException(void) throw() {} + + + /** + * Exception that should be thrown when a call to a Java method + * using Jni throw an exception. + * If possible, user should try to avoid this sitution because of the loss + * of information. + */ + + /** + * @param curEnv java environment where the exception occurred. + */ + JniCallMethodException::JniCallMethodException(JNIEnv * curEnv) throw() : JniException(curEnv) + { + std::string errorMessage = "Exception when calling Java method : "; + errorMessage += getJavaDescription() + "\n" + getJavaStackTrace(); + errorMessage += what(); + setErrorMessage(errorMessage); + } + + JniCallMethodException::~JniCallMethodException(void) throw() {} + /** + * @param className name of the class which haven't been found + */ + JniClassNotFoundException::JniClassNotFoundException(JNIEnv * curEnv, const std::string & className) throw() : JniException(curEnv) + { +std::string errorMessage = "Could not get the Class " + className + "."; +setErrorMessage(errorMessage); + } + + JniClassNotFoundException::~JniClassNotFoundException(void) throw() {} + + /** + * @param className name of the method which haven't been found + */ + JniMethodNotFoundException::JniMethodNotFoundException(JNIEnv * curEnv, const std::string & methodName) throw() : JniException(curEnv) + { +std::string errorMessage = "Could not access to the method " + methodName + "."; +setErrorMessage(errorMessage); + } + + JniMethodNotFoundException::~JniMethodNotFoundException(void) throw() {} + + /** + * @param curEnv java envirnonment where the exception occurred. + */ + JniObjectCreationException::JniObjectCreationException(JNIEnv * curEnv, const std::string & className) throw() : JniException(curEnv) + { +std::string errorMessage = "Could not instantiate the object " + className + "."; +setErrorMessage(errorMessage); + } + + JniObjectCreationException::~JniObjectCreationException(void) throw() {} + + /** + * @param curEnv java envirnonment where the exception occurred. + */ + JniMonitorException::JniMonitorException(JNIEnv * curEnv, const std::string & className) throw() : JniException(curEnv) + { +std::string errorMessage = "Error in the access (Enter or exit) or a Java env monitor of class " + className + "."; +setErrorMessage(errorMessage); + } + + JniMonitorException::~JniMonitorException(void) throw() {} + + + +} + diff --git a/modules/commons/src/jni/GiwsException.hxx b/modules/commons/src/jni/GiwsException.hxx new file mode 100755 index 000000000..4a8c1b422 --- /dev/null +++ b/modules/commons/src/jni/GiwsException.hxx @@ -0,0 +1,274 @@ +/* Generated by GIWS (version 2.0.2) */ +/* + +This is generated code. + +This software is a computer program whose purpose is to hide the complexity +of accessing Java objects/methods from C++ code. + +This software is governed by the CeCILL-B license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL-B +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL-B license and that you accept its terms. +*/ + + +#ifndef __GIWSEXCEPTION__ +#define __GIWSEXCEPTION__ +#include <iostream> +#include <string> +#include <string.h> +#include <stdlib.h> +#include <jni.h> + + #if defined(_MSC_VER) /* Defined anyway with Visual */ + #include <Windows.h> + #else + typedef signed char byte; + #endif +#include <exception> + + +#ifndef GIWSEXPORT +# if defined(_MSC_VER) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define GIWSEXPORT +# else +# define GIWSEXPORT __declspec(dllexport) +# endif +# else +# if __GNUC__ >= 4 +# define GIWSEXPORT __attribute__ ((visibility ("default"))) +# else +# define GIWSEXPORT +# endif +# endif +#endif + + +namespace GiwsException { + + + +/** +* Parent class for exceptions which may occure in JNI code. +*/ +class GIWSEXPORT JniException : public std::exception +{ + +/** Error message to display */ +std::string m_oErrorMessage; + +/** Java description of the exception*/ +std::string m_oJavaMessage; + +/** Java stackTrace when the exception occurred */ +std::string m_oJavaStackTrace; + +/** Name of the exception (ie class name).*/ +std::string m_oJavaExceptionName; + +/** The exception itself ... we store as a member otherwise JNI +complains about 'WARNING in native method: JNI call made with +exception pending' */ +jthrowable javaException; + +public: + +/** +* Each subclass of JniExcpetion should call the super constructor +* and the setErrorMessage function to set the message. +* @param curEnv java environment where the exception occurred. +*/ +JniException(JNIEnv * curEnv) throw() ; +JniException() throw() : exception() { }; + + +virtual ~JniException(void) throw(); + +/** +* @return a description of the exception +* @deprecated This function could lead to side effect error. Please use whatStr +*/ +virtual const char * what(void) const throw(); + +/** +* @return a description of the exception +*/ +virtual std::string whatStr(void) const throw(); + +/** +* @return Java description of the exception. +*/ +std::string getJavaDescription(void) const throw(); + +/** +* @return Java stack trace where the exception occurred. +*/ +std::string getJavaStackTrace(void) const throw(); + +/** +* Get the name of the exception (ie its class name). +*/ +std::string getJavaExceptionName(void) const throw(); + +protected: + +/** +* Set the error message that the exception should print. +*/ +void setErrorMessage(const std::string & errorMessage); + +/** +* Get the message that the exception will print. +*/ +std::string getErrorMessage(void) const; + +private: + /** +* @return error message of the exception. +*/ +std::string retrieveExceptionMessage(JNIEnv * curEnv); +/** +* @return full stack trace when the exception occurred. +*/ +std::string retrieveStackTrace(JNIEnv * curEnv); + +/** +* @return string containing the name of the exception (ie its class name). +*/ +std::string retrieveExceptionName(JNIEnv * curEnv); +/** +* To be called when all the information about the exceptions have been +* retrived. +* Remove the exception from the environment. +*/ +void closeException(JNIEnv * curEnv); + +/** +* Convert a Java string (jstring) into a C++ string +*/ +std::string convertJavaString(JNIEnv * curEnv, jstring javaString); +}; + +/** +* Exception that should be thrown when allocation of Java resources from C++ +* code fails (sur as NewDoubleArray or NewStringUTF). +*/ +class GIWSEXPORT JniBadAllocException : public JniException +{ +public: + +JniBadAllocException(JNIEnv * curEnv) throw(); +virtual ~JniBadAllocException(void) throw(); +}; + +/** +* Exception that should be thrown when a call to a Java method +* using Jni throw an exception. +* If possible, user should try to avoid this sitution because of the loss +* of information. +*/ +class GIWSEXPORT JniCallMethodException : public JniException +{ +public: + + /** + * @param curEnv java envirnonment where the exception occurred. + */ + JniCallMethodException(JNIEnv * curEnv) throw(); + + virtual ~JniCallMethodException(void) throw(); +}; + +/** +* Exception that should be thrown when Jni code could not find a Java class +*/ +class GIWSEXPORT JniClassNotFoundException : public JniException +{ +public: + +/** +* @param className name of the class which haven't been found +*/ +JniClassNotFoundException(JNIEnv * curEnv, const std::string & className) throw(); + +virtual ~JniClassNotFoundException(void) throw(); + +}; + +/** +* Exception that should be thrown when Jni code could not find a Java method +*/ +class GIWSEXPORT JniMethodNotFoundException : public JniException +{ +public: + +/** +* @param className name of the method which haven't been found +*/ +JniMethodNotFoundException(JNIEnv * curEnv, const std::string & methodName) throw(); +virtual ~JniMethodNotFoundException(void) throw(); + +}; + +/** +* Exception that should be thrown when a call to a Java method +* using Jni throw an exception. +* If possible, user should try to avoid this sitution because of the loss +* of information. +*/ +class GIWSEXPORT JniObjectCreationException : public JniException +{ +public: + +/** +* @param curEnv java envirnonment where the exception occurred. +*/ +JniObjectCreationException(JNIEnv * curEnv, const std::string & className) throw(); +virtual ~JniObjectCreationException(void) throw(); + +}; + + +/** +* Exception that should be thrown when a call to the Java monitor +* failed +*/ +class GIWSEXPORT JniMonitorException : public JniException +{ +public: + +/** +* @param curEnv java envirnonment where the exception occurred. +*/ +JniMonitorException(JNIEnv * curEnv, const std::string & className) throw(); +virtual ~JniMonitorException(void) throw(); + +}; + + +} +#endif + diff --git a/modules/commons/src/jni/ScilabCommons.i b/modules/commons/src/jni/ScilabCommons.i new file mode 100755 index 000000000..71632af07 --- /dev/null +++ b/modules/commons/src/jni/ScilabCommons.i @@ -0,0 +1,219 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) INRIA - 2010 - Sylvestre Ledru + * + * 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.1-en.txt + * + */ + + +/* ScilabCommons.i */ +/** + * Windows: swig -java -package org.scilab.modules.commons -outdir ../java/org/scilab/modules/commons/ ScilabCommons.i + * Other: Use the option --enable-build-swig to the configure +*/ +%module ScilabCommons +%{ +#include "../../../core/includes/SCIHOME.h" +#include "../../../core/includes/tmpdir.h" +#include "../../../fileio/includes/createtempfilename.h" +#include "../../../localization/includes/setgetlanguage.h" +#include "../../../core/includes/getversion.h" +#include "../../../core/includes/setieee.h" +#include "../../../core/includes/setformat.h" +%} + +/* JavaDoc for ScilabCommonsJNI class */ +%pragma(java) jniclassclassmodifiers=%{ +/* It is generated code. Disable checkstyle */ +//CHECKSTYLE:OFF + /** + * Some commons values from Scilab engine to Java + * @author Sylvestre LEDRU + * @copyright DIGITEO 2010 + */ +public class%} + +/* Constructor for ScilabCommonsJNI class */ +%pragma(java) jniclasscode=" + /** + * Constructor + */ + protected ScilabCommonsJNI() { + throw new UnsupportedOperationException(); + }"; + +/* static load of library */ +%pragma(java) jniclasscode=%{ + static { + try { + System.loadLibrary("scicommons"); + } catch (SecurityException e) { + System.err.println("A security manager exists and does not allow the loading of the specified dynamic library."); + System.err.println(e.getLocalizedMessage()); + System.exit(-1); + } catch (UnsatisfiedLinkError e) { + System.err.println("The native library scicommons does not exist or cannot be found."); + if (System.getenv("CONTINUE_ON_JNI_ERROR") == null) { + System.err.println(e.getLocalizedMessage()); + System.err.println("Current java.library.path is : "+System.getProperty("java.library.path")); + System.exit(-1); + }else{ + System.err.println("Continuing anyway because of CONTINUE_ON_JNI_ERROR"); + } + } + } +%} + + +/* JavaDoc for ScilabCommons class */ +%pragma(java) moduleclassmodifiers=" + /** + * Some commons values from Scilab engine to Java + * @author Sylvestre LEDRU + * @copyright DIGITEO 2010 + */ +public class"; + +/* Constructor for ScilabCommons class */ +%pragma(java) modulecode=" + /** + * Constructor + */ + protected ScilabCommons() { + throw new UnsupportedOperationException(); + }"; + +/* JavaDoc */ +%javamethodmodifiers getSCIHOME() " + /** + * Get SCIHOME variable from Scilab + * @return SCIHOME value + */ +public"; +char* getSCIHOME(); + + +/* JavaDoc */ +%javamethodmodifiers getTMPDIR() " + /** + * returns TMPDIR directory value + * @return TMPDIR value + */ +public"; +char *getTMPDIR(void); + + +/* JavaDoc */ +%javamethodmodifiers getScilabLanguage() " + /** + * returns Scilab current language + * @return language + */ +public"; +char *getlanguage(void); + + +/* JavaDoc */ +%javamethodmodifiers createTempFileName() " + /** + * Create file with unique file name in TMPDIR + * TMPDIR/PREFIX[XXXXXXX] + * @param prefix the file prefix + * @param bShortFormat set 1 for a 8.5 filename, 0 otherwise + * @return a unique filename + */ +public"; +char *createtempfilename(const char* prefix, int bShortFormat); + +/* JavaDoc */ +%javamethodmodifiers getScilabIeeeMode() " + /** + * returns the Scilab ieee mode + * @return ieee mode + */ +public"; +int getieee(void); + +/* JavaDoc */ +%javamethodmodifiers setScilabIeeeMode(int) " + /** + * Set the Scilab ieee mode + */ +public"; +void setieee(int); + +/* JavaDoc */ +%javamethodmodifiers setformat(const char *, int) " + /** + * Set the Scilab ieee mode + */ +public"; +void setformat(const char * format, int width); + +/* JavaDoc */ +%javamethodmodifiers getformat() " + /** + * returns the Scilab format (\"v\" or \"e\") + * @return format + */ +public"; +char * getformat(); + +/* JavaDoc */ +%javamethodmodifiers getformatwidth() " + /** + * returns the Scilab format width + * @return format + */ +public"; +int getformatwidth(); + +/* JavaDoc */ +%javamethodmodifiers getScilabVersionMajor() " + /** + * returns the Scilab version major number + * @return version major + */ +public"; +int getScilabVersionMajor(); + +/* JavaDoc */ +%javamethodmodifiers getScilabVersionMinor() " + /** + * returns the Scilab version minor number + * @return version minor + */ +public"; +int getScilabVersionMinor(); + +/* JavaDoc */ +%javamethodmodifiers getScilabVersionMaintenance() " + /** + * returns the Scilab version maintenance number + * @return version maintenance + */ +public"; +int getScilabVersionMaintenance(); + +/* JavaDoc */ +%javamethodmodifiers getScilabVersionTimestamp() " + /** + * returns the Scilab version timestamp number + * @return version timestamp + */ +public"; +int getScilabVersionTimestamp(); + +/* JavaDoc */ +%javamethodmodifiers getScilabVersionAsString() " + /** + * returns the Scilab version as string + * @return version Scilab version as a string + */ +public"; +char* getScilabVersionAsString(); diff --git a/modules/commons/src/jni/ScilabCommons_wrap.c b/modules/commons/src/jni/ScilabCommons_wrap.c new file mode 100755 index 000000000..b65a5bf2b --- /dev/null +++ b/modules/commons/src/jni/ScilabCommons_wrap.c @@ -0,0 +1,386 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.7 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGJAVA + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + + + +/* Fix for jlong on some versions of gcc on Windows */ +#if defined(__GNUC__) && !defined(__INTEL_COMPILER) + typedef long long __int64; +#endif + +/* Fix for jlong on 64-bit x86 Solaris */ +#if defined(__x86_64) +# ifdef _LP64 +# undef _LP64 +# endif +#endif + +#include <jni.h> +#include <stdlib.h> +#include <string.h> + + +/* Support for throwing Java exceptions */ +typedef enum { + SWIG_JavaOutOfMemoryError = 1, + SWIG_JavaIOException, + SWIG_JavaRuntimeException, + SWIG_JavaIndexOutOfBoundsException, + SWIG_JavaArithmeticException, + SWIG_JavaIllegalArgumentException, + SWIG_JavaNullPointerException, + SWIG_JavaDirectorPureVirtual, + SWIG_JavaUnknownError +} SWIG_JavaExceptionCodes; + +typedef struct { + SWIG_JavaExceptionCodes code; + const char *java_exception; +} SWIG_JavaExceptions_t; + + +static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) { + jclass excep; + static const SWIG_JavaExceptions_t java_exceptions[] = { + { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" }, + { SWIG_JavaIOException, "java/io/IOException" }, + { SWIG_JavaRuntimeException, "java/lang/RuntimeException" }, + { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" }, + { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" }, + { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" }, + { SWIG_JavaNullPointerException, "java/lang/NullPointerException" }, + { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" }, + { SWIG_JavaUnknownError, "java/lang/UnknownError" }, + { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } + }; + const SWIG_JavaExceptions_t *except_ptr = java_exceptions; + + while (except_ptr->code != code && except_ptr->code) + except_ptr++; + + (*jenv)->ExceptionClear(jenv); + excep = (*jenv)->FindClass(jenv, except_ptr->java_exception); + if (excep) + (*jenv)->ThrowNew(jenv, excep, msg); +} + + +/* Contract support */ + +#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else + + +#include "../../../core/includes/SCIHOME.h" +#include "../../../core/includes/tmpdir.h" +#include "../../../fileio/includes/createtempfilename.h" +#include "../../../localization/includes/setgetlanguage.h" +#include "../../../core/includes/getversion.h" +#include "../../../core/includes/setieee.h" +#include "../../../core/includes/setformat.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGEXPORT jstring JNICALL Java_org_scilab_modules_commons_ScilabCommonsJNI_getSCIHOME(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result = 0 ; + + (void)jenv; + (void)jcls; + result = (char *)getSCIHOME(); + if (result) jresult = (*jenv)->NewStringUTF(jenv, (const char *)result); + return jresult; +} + + +SWIGEXPORT jstring JNICALL Java_org_scilab_modules_commons_ScilabCommonsJNI_getTMPDIR(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result = 0 ; + + (void)jenv; + (void)jcls; + result = (char *)getTMPDIR(); + if (result) jresult = (*jenv)->NewStringUTF(jenv, (const char *)result); + return jresult; +} + + +SWIGEXPORT jstring JNICALL Java_org_scilab_modules_commons_ScilabCommonsJNI_getlanguage(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result = 0 ; + + (void)jenv; + (void)jcls; + result = (char *)getlanguage(); + if (result) jresult = (*jenv)->NewStringUTF(jenv, (const char *)result); + return jresult; +} + + +SWIGEXPORT jstring JNICALL Java_org_scilab_modules_commons_ScilabCommonsJNI_createtempfilename(JNIEnv *jenv, jclass jcls, jstring jarg1, jint jarg2) { + jstring jresult = 0 ; + char *arg1 = (char *) 0 ; + int arg2 ; + char *result = 0 ; + + (void)jenv; + (void)jcls; + arg1 = 0; + if (jarg1) { + arg1 = (char *)(*jenv)->GetStringUTFChars(jenv, jarg1, 0); + if (!arg1) return 0; + } + arg2 = (int)jarg2; + result = (char *)createtempfilename((char const *)arg1,arg2); + if (result) jresult = (*jenv)->NewStringUTF(jenv, (const char *)result); + if (arg1) (*jenv)->ReleaseStringUTFChars(jenv, jarg1, (const char *)arg1); + return jresult; +} + + +SWIGEXPORT jint JNICALL Java_org_scilab_modules_commons_ScilabCommonsJNI_getieee(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int)getieee(); + jresult = (jint)result; + return jresult; +} + + +SWIGEXPORT void JNICALL Java_org_scilab_modules_commons_ScilabCommonsJNI_setieee(JNIEnv *jenv, jclass jcls, jint jarg1) { + int arg1 ; + + (void)jenv; + (void)jcls; + arg1 = (int)jarg1; + setieee(arg1); +} + + +SWIGEXPORT void JNICALL Java_org_scilab_modules_commons_ScilabCommonsJNI_setformat(JNIEnv *jenv, jclass jcls, jstring jarg1, jint jarg2) { + char *arg1 = (char *) 0 ; + int arg2 ; + + (void)jenv; + (void)jcls; + arg1 = 0; + if (jarg1) { + arg1 = (char *)(*jenv)->GetStringUTFChars(jenv, jarg1, 0); + if (!arg1) return ; + } + arg2 = (int)jarg2; + setformat((char const *)arg1,arg2); + if (arg1) (*jenv)->ReleaseStringUTFChars(jenv, jarg1, (const char *)arg1); +} + + +SWIGEXPORT jstring JNICALL Java_org_scilab_modules_commons_ScilabCommonsJNI_getformat(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result = 0 ; + + (void)jenv; + (void)jcls; + result = (char *)getformat(); + if (result) jresult = (*jenv)->NewStringUTF(jenv, (const char *)result); + return jresult; +} + + +SWIGEXPORT jint JNICALL Java_org_scilab_modules_commons_ScilabCommonsJNI_getformatwidth(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int)getformatwidth(); + jresult = (jint)result; + return jresult; +} + + +SWIGEXPORT jint JNICALL Java_org_scilab_modules_commons_ScilabCommonsJNI_getScilabVersionMajor(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int)getScilabVersionMajor(); + jresult = (jint)result; + return jresult; +} + + +SWIGEXPORT jint JNICALL Java_org_scilab_modules_commons_ScilabCommonsJNI_getScilabVersionMinor(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int)getScilabVersionMinor(); + jresult = (jint)result; + return jresult; +} + + +SWIGEXPORT jint JNICALL Java_org_scilab_modules_commons_ScilabCommonsJNI_getScilabVersionMaintenance(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int)getScilabVersionMaintenance(); + jresult = (jint)result; + return jresult; +} + + +SWIGEXPORT jint JNICALL Java_org_scilab_modules_commons_ScilabCommonsJNI_getScilabVersionTimestamp(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int)getScilabVersionTimestamp(); + jresult = (jint)result; + return jresult; +} + + +SWIGEXPORT jstring JNICALL Java_org_scilab_modules_commons_ScilabCommonsJNI_getScilabVersionAsString(JNIEnv *jenv, jclass jcls) { + jstring jresult = 0 ; + char *result = 0 ; + + (void)jenv; + (void)jcls; + result = (char *)getScilabVersionAsString(); + if (result) jresult = (*jenv)->NewStringUTF(jenv, (const char *)result); + return jresult; +} + + +#ifdef __cplusplus +} +#endif + diff --git a/modules/commons/src/jni/libscicommons_la-CommonFileUtils_wrap.lo b/modules/commons/src/jni/libscicommons_la-CommonFileUtils_wrap.lo new file mode 100755 index 000000000..6f8fa6205 --- /dev/null +++ b/modules/commons/src/jni/libscicommons_la-CommonFileUtils_wrap.lo @@ -0,0 +1,12 @@ +# src/jni/libscicommons_la-CommonFileUtils_wrap.lo - a libtool object file +# Generated by libtool (GNU libtool) 2.4.2 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/libscicommons_la-CommonFileUtils_wrap.o' + +# Name of the non-PIC object +non_pic_object=none + diff --git a/modules/commons/src/jni/libscicommons_la-FindIconHelper.lo b/modules/commons/src/jni/libscicommons_la-FindIconHelper.lo new file mode 100755 index 000000000..37f478d2e --- /dev/null +++ b/modules/commons/src/jni/libscicommons_la-FindIconHelper.lo @@ -0,0 +1,12 @@ +# src/jni/libscicommons_la-FindIconHelper.lo - a libtool object file +# Generated by libtool (GNU libtool) 2.4.2 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/libscicommons_la-FindIconHelper.o' + +# Name of the non-PIC object +non_pic_object=none + diff --git a/modules/commons/src/jni/libscicommons_la-GiwsException.lo b/modules/commons/src/jni/libscicommons_la-GiwsException.lo new file mode 100755 index 000000000..547f0ab05 --- /dev/null +++ b/modules/commons/src/jni/libscicommons_la-GiwsException.lo @@ -0,0 +1,12 @@ +# src/jni/libscicommons_la-GiwsException.lo - a libtool object file +# Generated by libtool (GNU libtool) 2.4.2 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/libscicommons_la-GiwsException.o' + +# Name of the non-PIC object +non_pic_object=none + diff --git a/modules/commons/src/jni/libscicommons_la-ScilabCommons_wrap.lo b/modules/commons/src/jni/libscicommons_la-ScilabCommons_wrap.lo new file mode 100755 index 000000000..50d622cf3 --- /dev/null +++ b/modules/commons/src/jni/libscicommons_la-ScilabCommons_wrap.lo @@ -0,0 +1,12 @@ +# src/jni/libscicommons_la-ScilabCommons_wrap.lo - a libtool object file +# Generated by libtool (GNU libtool) 2.4.2 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/libscicommons_la-ScilabCommons_wrap.o' + +# Name of the non-PIC object +non_pic_object=none + |