/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 2009 - 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
*
*/
//=============================================================================
using System;
using System.Runtime.InteropServices;
//=============================================================================
namespace DotNetScilab {
class Scilab_cs_wrapper {
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public unsafe struct api_Ctx {
public String pstName; /**< Function name */
}
//=============================================================================
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public unsafe struct api_Err {
public int iErr;
public int iMsgCount;
public fixed char pstructMsg[5];
}
//=============================================================================
private const string CALL_SCILAB_DLL = "call_scilab.dll";
private const string API_SCILAB_DLL = "api_scilab.dll";
private const string GRAPHICS_DLL = "graphics.dll";
private const string OUTPUT_STREAM_DLL = "scioutput_stream.dll";
//=============================================================================
///
/// import SendScilabJob from C (see call_scilab.h)
///
[DllImport(CALL_SCILAB_DLL, CharSet = CharSet.Ansi)]
public static extern int SendScilabJob([In]String job);
//=============================================================================
///
/// import StartScilab from C (see call_scilab.h)
///
[DllImport(CALL_SCILAB_DLL, CharSet = CharSet.Ansi)]
public static extern int StartScilab([In] String SCIpath,
[In] String ScilabStartup,
[In] Int32[] Stacksize);
//=============================================================================
///
/// import TerminateScilab from C (see call_scilab.h)
///
[DllImport(CALL_SCILAB_DLL, CharSet = CharSet.Ansi)]
public static extern int TerminateScilab([In] String ScilabQuit);
//=============================================================================
///
/// import DisableInteractiveMode from C (see call_scilab.h)
///
[DllImport(CALL_SCILAB_DLL, CharSet = CharSet.Ansi)]
public static extern void DisableInteractiveMode();
//=============================================================================
///
/// import createNamedMatrixOfString from C (see api_string.h)
///
[DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
public static extern api_Err createNamedMatrixOfString([In]IntPtr pvApiCtx, [In] String _pstName,
[In] int _iRows, [In] int _iCols,
[In] String[] _pstStrings);
//=============================================================================
///
/// import createNamedMatrixOfWideString from C (see api_string.h)
///
[DllImport(API_SCILAB_DLL, CharSet = CharSet.Unicode)]
public static extern api_Err createNamedMatrixOfWideString([In]IntPtr pvApiCtx,
[In] String _pstName,
[In] int _iRows, [In] int _iCols,
[In] String[] _pstStrings);
//=============================================================================
///
/// import createNamedMatrixOfDouble from C (see api_double.h)
///
[DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
[return: MarshalAs(UnmanagedType.Struct)]
public static extern api_Err createNamedMatrixOfDouble([In]IntPtr pvApiCtx, [In] String _pstName,
[In] int _iRows, [In] int _iCols,
[In] double[] _pdblReal);
//=============================================================================
///
/// import createNamedMatrixOfBoolean from C (see api_boolean.h)
///
[DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
public static extern api_Err createNamedMatrixOfBoolean([In]IntPtr pvApiCtx, [In] String _pstName,
[In] int _iRows, [In] int _iCols,
[In] int[] _piBool);
//=============================================================================
///
/// import createNamedMatrixOfInteger32 from C (see api_int.h)
///
[DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
public unsafe static extern api_Err createNamedMatrixOfInteger32([In]IntPtr pvApiCtx, [In] String _pstName,
[In] int _iRows, [In] int _iCols,
[In] int[] _piData);
//=============================================================================
///
/// import createNamedComplexMatrixOfDouble from C (see api_double.h)
///
[DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
public unsafe static extern api_Err createNamedComplexMatrixOfDouble([In]IntPtr pvApiCtx, [In] String _pstName,
[In] int _iRows, [In] int _iCols,
[In] double[] _pdblReal,
[In] double[] _pdblImg);
//=============================================================================
///
/// import readNamedMatrixOfString from C (see api_string.h)
///
[DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
public unsafe static extern api_Err readNamedMatrixOfString([In]IntPtr pvApiCtx, [In] String _pstName,
[Out] Int32* _piRows, [Out] Int32* _piCols,
[In, Out] int[] _piLength,
[In, Out] String[] _pstStrings);
//=============================================================================
///
/// import readNamedMatrixOfWideString from C (see api_string.h)
///
[DllImport(API_SCILAB_DLL, CharSet = CharSet.Unicode)]
public unsafe static extern api_Err readNamedMatrixOfWideString([In]IntPtr pvApiCtx, [In] String _pstName,
[Out] Int32* _piRows, [Out] Int32* _piCols,
[In, Out] int[] _piLength,
[In, Out] String[] _pstStrings);
//=============================================================================
///
/// import readNamedMatrixOfDouble from C (see api_double.h)
///
[DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
public unsafe static extern api_Err readNamedMatrixOfDouble([In]IntPtr pvApiCtx, [In] String _pstName,
[Out] Int32* _piRows, [Out] Int32* _piCols,
[In, Out] Double[] _pdblReal);
//=============================================================================
///
/// import readNamedMatrixOfBoolean from C (see api_boolean.h)
///
[DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
public unsafe static extern api_Err readNamedMatrixOfBoolean([In]IntPtr pvApiCtx, [In] String _pstName,
[Out] Int32* _piRows, [Out] Int32* _piCols,
[In, Out] int[] _piBool);
//=============================================================================
///
/// import readNamedMatrixOfInteger32 from C (see api_int.h)
///
[DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
public unsafe static extern api_Err readNamedMatrixOfInteger32([In]IntPtr pvApiCtx, [In] String _pstName,
[Out] Int32* _piRows, [Out] Int32* _piCols,
[In, Out] int[] _piData);
//=============================================================================
///
/// import readNamedComplexMatrixOfDouble from C (see api_double.h)
///
[DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
public unsafe static extern api_Err readNamedComplexMatrixOfDouble([In]IntPtr pvApiCtx, [In] String _pstName,
[Out] Int32* _piRows, [Out] Int32* _piCols,
[In, Out] double[] _pdblReal,
[In, Out] double[] _pdblImg);
//=============================================================================
///
/// get Variable Adress in scilab stack from name
/// used for getNamedMatrixType (internal)
///
/// variable name
/// stack address
/// 1 if ok
[DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
public unsafe static extern api_Err getVarAddressFromName([In]IntPtr pvApiCtx, [In] String _pstName,
[Out] Int32** _piAddress);
//=============================================================================
///
/// get Variable type in scilab stack from name
///
/// variable name
/// type or -1
[DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
public unsafe static extern api_Err getNamedVarType([In]IntPtr pvApiCtx, [In] String _pstName, [Out]Int32* _piType);
//=============================================================================
///
/// get variable type with adress in scilab stack
/// used for getNamedMatrixType (internal)
///
/// stack address
/// scilab type, 0 fails
[DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
public unsafe static extern api_Err getVarType([In]IntPtr pvApiCtx, [In] Int32* _piAddress, [Out]Int32* _piType);
//=============================================================================
///
/// Detect if a Scilab graphic window is opened
///
/// 0 (FALSE) or 1 (TRUE)
[DllImport(GRAPHICS_DLL, CharSet = CharSet.Ansi)]
public unsafe static extern int sciHasFigures();
//=============================================================================
///
/// get last error code
///
/// last error code
[DllImport(OUTPUT_STREAM_DLL, CharSet = CharSet.Ansi)]
public unsafe static extern int GetLastErrorCode();
//=============================================================================
///
/// Get variable dimension
///
/// import getNamedVarDimension from C (see api_common.h)
/// int last error code
[DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
public unsafe static extern api_Err getNamedVarDimension([In]IntPtr pvApiCtx, [In] String _pstName,
[Out] Int32* _piRows, [Out] Int32* _piCols);
//=============================================================================
///
/// Get named complex information
///
/// import isNamedVarComplex from C (see api_common.h)
/// int if complex 1 otherwise 0
[DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
public unsafe static extern int isNamedVarComplex([In]IntPtr pvApiCtx, [In] String _pstName);
//=============================================================================
}
}
//=============================================================================