Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.ExternalEvaluation Scientific/DotNetScilab/dotnetsci/Scilab_cs_wrapper.cs @ 10125

Last change on this file since 10125 was 10125, checked in by mkommend, 10 years ago

#2082: Updated scilab mono connector with latest source and corrected marshalling of sci_err.

File size: 12.8 KB
Line 
1/*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2009 - DIGITEO - Allan CORNET
4 *
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution.  The terms
8 * are also available at   
9 * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
10 *
11 */
12//=============================================================================
13using System;
14using System.Runtime.InteropServices;
15//=============================================================================
16namespace DotNetScilab {
17  class Scilab_cs_wrapper {
18    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
19    public unsafe struct api_Ctx {
20      public String pstName; /**< Function name */
21    }
22
23    //=============================================================================
24    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
25    public unsafe struct api_Err {
26      public int iErr;
27      public int iMsgCount;
28      public fixed char pstructMsg[5];
29    }
30    //=============================================================================
31    private const string CALL_SCILAB_DLL = "call_scilab.dll";
32    private const string API_SCILAB_DLL = "api_scilab.dll";
33    private const string GRAPHICS_DLL = "graphics.dll";
34    private const string OUTPUT_STREAM_DLL = "scioutput_stream.dll";
35    //=============================================================================
36    /// <summary>
37    /// import SendScilabJob from C (see call_scilab.h)
38    /// </summary>
39    [DllImport(CALL_SCILAB_DLL, CharSet = CharSet.Ansi)]
40    public static extern int SendScilabJob([In]String job);
41    //=============================================================================
42    /// <summary>
43    /// import StartScilab from C (see call_scilab.h)
44    /// </summary>
45    [DllImport(CALL_SCILAB_DLL, CharSet = CharSet.Ansi)]
46    public static extern int StartScilab([In] String SCIpath,
47                                          [In] String ScilabStartup,
48                                          [In] Int32[] Stacksize);
49    //=============================================================================
50    /// <summary>
51    /// import TerminateScilab from C (see call_scilab.h)
52    /// </summary>
53    [DllImport(CALL_SCILAB_DLL, CharSet = CharSet.Ansi)]
54    public static extern int TerminateScilab([In] String ScilabQuit);
55    //=============================================================================
56    /// <summary>
57    /// import DisableInteractiveMode from C (see call_scilab.h)
58    /// </summary>
59    [DllImport(CALL_SCILAB_DLL, CharSet = CharSet.Ansi)]
60    public static extern void DisableInteractiveMode();
61    //=============================================================================
62    /// <summary>
63    /// import createNamedMatrixOfString from C (see api_string.h)
64    /// </summary>
65    [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
66    public static extern api_Err createNamedMatrixOfString([In]IntPtr pvApiCtx, [In] String _pstName,
67                                                        [In] int _iRows, [In] int _iCols,
68                                                        [In] String[] _pstStrings);
69    //=============================================================================
70    /// <summary>
71    /// import createNamedMatrixOfWideString from C (see api_string.h)
72    /// </summary>
73    [DllImport(API_SCILAB_DLL, CharSet = CharSet.Unicode)]
74    public static extern api_Err createNamedMatrixOfWideString([In]IntPtr pvApiCtx,
75                                                        [In] String _pstName,
76                                                        [In] int _iRows, [In] int _iCols,
77                                                        [In] String[] _pstStrings);
78    //=============================================================================
79    /// <summary>
80    /// import createNamedMatrixOfDouble from C (see api_double.h)
81    /// </summary>
82    [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
83    [return: MarshalAs(UnmanagedType.Struct)]
84    public static extern api_Err createNamedMatrixOfDouble([In]IntPtr pvApiCtx, [In] String _pstName,
85                                                        [In] int _iRows, [In] int _iCols,
86                                                        [In] double[] _pdblReal);
87
88
89    //=============================================================================
90    /// <summary>
91    /// import createNamedMatrixOfBoolean from C (see api_boolean.h)
92    /// </summary>
93    [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
94    public static extern api_Err createNamedMatrixOfBoolean([In]IntPtr pvApiCtx, [In] String _pstName,
95                                                        [In] int _iRows, [In] int _iCols,
96                                                        [In] int[] _piBool);
97    //=============================================================================
98    /// <summary>
99    /// import createNamedMatrixOfInteger32 from C (see api_int.h)
100    /// </summary>
101    [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
102    public unsafe static extern api_Err createNamedMatrixOfInteger32([In]IntPtr pvApiCtx, [In] String _pstName,
103                                                       [In] int _iRows, [In] int _iCols,
104                                                       [In] int[] _piData);
105    //=============================================================================
106    /// <summary>
107    /// import createNamedComplexMatrixOfDouble from C (see api_double.h)
108    /// </summary>
109    [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
110    public unsafe static extern api_Err createNamedComplexMatrixOfDouble([In]IntPtr pvApiCtx, [In] String _pstName,
111                                                        [In] int _iRows, [In] int _iCols,
112                                                        [In] double[] _pdblReal,
113                                                        [In] double[] _pdblImg);
114    //=============================================================================
115    /// <summary>
116    /// import readNamedMatrixOfString from C (see api_string.h)
117    /// </summary>
118    [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
119    public unsafe static extern api_Err readNamedMatrixOfString([In]IntPtr pvApiCtx, [In] String _pstName,
120                                                      [Out]  Int32* _piRows, [Out]  Int32* _piCols,
121                                                      [In, Out] int[] _piLength,
122                                                      [In, Out] String[] _pstStrings);
123    //=============================================================================
124    /// <summary>
125    /// import readNamedMatrixOfWideString from C (see api_string.h)
126    /// </summary>
127    [DllImport(API_SCILAB_DLL, CharSet = CharSet.Unicode)]
128    public unsafe static extern api_Err readNamedMatrixOfWideString([In]IntPtr pvApiCtx, [In] String _pstName,
129                                                      [Out]  Int32* _piRows, [Out]  Int32* _piCols,
130                                                      [In, Out] int[] _piLength,
131                                                      [In, Out] String[] _pstStrings);
132    //=============================================================================
133    /// <summary>
134    /// import readNamedMatrixOfDouble from C (see api_double.h)
135    /// </summary>
136    [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
137    public unsafe static extern api_Err readNamedMatrixOfDouble([In]IntPtr pvApiCtx, [In] String _pstName,
138                                                      [Out] Int32* _piRows, [Out] Int32* _piCols,
139                                                      [In, Out] Double[] _pdblReal);
140    //=============================================================================
141    /// <summary>
142    /// import readNamedMatrixOfBoolean from C (see api_boolean.h)
143    /// </summary>
144    [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
145    public unsafe static extern api_Err readNamedMatrixOfBoolean([In]IntPtr pvApiCtx, [In] String _pstName,
146                                                      [Out] Int32* _piRows, [Out] Int32* _piCols,
147                                                      [In, Out] int[] _piBool);
148    //=============================================================================
149    /// <summary>
150    /// import readNamedMatrixOfInteger32 from C (see api_int.h)
151    /// </summary>
152    [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
153    public unsafe static extern api_Err readNamedMatrixOfInteger32([In]IntPtr pvApiCtx, [In] String _pstName,
154                                                      [Out] Int32* _piRows, [Out] Int32* _piCols,
155                                                      [In, Out] int[] _piData);
156
157    //=============================================================================
158    /// <summary>
159    /// import readNamedComplexMatrixOfDouble from C (see api_double.h)
160    /// </summary>
161    [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
162    public unsafe static extern api_Err readNamedComplexMatrixOfDouble([In]IntPtr pvApiCtx, [In] String _pstName,
163                                                    [Out] Int32* _piRows, [Out] Int32* _piCols,
164                                                    [In, Out] double[] _pdblReal,
165                                                    [In, Out] double[] _pdblImg);
166    //=============================================================================
167    /// <summary>
168    /// get Variable Adress in scilab stack from name
169    /// used for getNamedMatrixType (internal)
170    /// </summary>
171    /// <param name="_pstName">variable name</param>
172    /// <param name="_piAddress"> stack address</param>
173    /// <returns>1 if ok</returns>
174    [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
175    public unsafe static extern api_Err getVarAddressFromName([In]IntPtr pvApiCtx, [In] String _pstName,
176                                                           [Out] Int32** _piAddress);
177    //=============================================================================
178    /// <summary>
179    /// get Variable type in scilab stack from name
180    /// </summary>
181    /// <param name="_pstName">variable name</param>
182    /// <returns>type or -1</returns>
183    [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
184    public unsafe static extern api_Err getNamedVarType([In]IntPtr pvApiCtx, [In] String _pstName, [Out]Int32* _piType);
185    //=============================================================================
186    /// <summary>
187    /// get variable type with adress in scilab stack
188    /// used for getNamedMatrixType (internal)
189    /// </summary>
190    /// <param name="_piAddress"> stack address</param>
191    /// <returns>scilab type, 0 fails</returns>
192    [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
193    public unsafe static extern api_Err getVarType([In]IntPtr pvApiCtx, [In] Int32* _piAddress, [Out]Int32* _piType);
194    //=============================================================================
195    /// <summary>
196    ///  Detect if a Scilab graphic window is opened
197    /// </summary>
198    /// <returns>0 (FALSE) or 1 (TRUE)</returns>
199    [DllImport(GRAPHICS_DLL, CharSet = CharSet.Ansi)]
200    public unsafe static extern int sciHasFigures();
201    //=============================================================================
202    /// <summary>
203    ///  get last error code
204    /// </summary>
205    /// <returns>last error code</returns>
206    [DllImport(OUTPUT_STREAM_DLL, CharSet = CharSet.Ansi)]
207    public unsafe static extern int GetLastErrorCode();
208    //=============================================================================
209    /// <summary>
210    ///  Get variable dimension
211    /// </summary>
212    /// import getNamedVarDimension from C (see api_common.h)
213    /// <returns>int last error code</returns>
214    [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
215    public unsafe static extern api_Err getNamedVarDimension([In]IntPtr pvApiCtx, [In] String _pstName,
216                               [Out] Int32* _piRows, [Out] Int32* _piCols);
217    //=============================================================================
218    /// <summary>
219    ///  Get named complex information
220    /// </summary>
221    /// import isNamedVarComplex from C (see api_common.h)
222    /// <returns>int if complex 1 otherwise 0</returns>
223    [DllImport(API_SCILAB_DLL, CharSet = CharSet.Ansi)]
224    public unsafe static extern int isNamedVarComplex([In]IntPtr pvApiCtx, [In] String _pstName);
225    //=============================================================================
226
227  }
228}
229//=============================================================================
Note: See TracBrowser for help on using the repository browser.