Weekly report for 30 July 2011 on Project "dotNET Interaction Mechanism for Scilab + Environment Abstraction Layer"
This week I have been finishing implementation of Managed class ScilabDotNetObjects and ScilabDotNetType and using them from .net environment class in Scilab ScilabDotNetEnvironment.
Getting list of accessible methods and types
Among new implemented methods are GetAccessibleMethodNames and GetAccessibleFieldNames. To get list of accessible methods/fields of a certain type, cached collections of .Net Type's methods, fields and properties are used. These collections are created dyring type load. These collections are also used when getting/setting objects' field value. May be, it is worth to add signature to returning format of accessible method names, because they are often being overloaded. Only names of public methods/fields and properties are includede into resulting array of GetAccessible... methods.
On abstract level in JIMS there's no distinction between 'field' and 'property', which are different notions in .NET. Thus, result of getAccessibleFieldNames includes not only fields, but public properties.
Unwrappable Types
A collection Type objects is created on ScilabDotNetObjects initialization. It consists of the following types: Int16, Int32, Int64, UInt16, UInt32, Float, Double, String, Boolean and Char as well as their 1- and 2- dimensional arrays.
Wrappers
Passed types are wrapped to managed types as follows:
Method |
Native type |
.Net Type |
wrapDouble |
double |
Double |
wrapInt |
int |
Int32 |
wrapUInt |
long longwrapUInt |
UInt32 |
wrapShort |
short |
Int16 |
wrapUShort |
int |
UInt16 |
wrapBoolean |
int |
Bool |
wrapChar |
unsigned short |
UInt16 |
wrapFloat |
float |
Double |
wrapByte |
byte |
Byte |
wrapLong, 64bit |
long long |
Int64 |
Unwrappers
Unwrappers are deinfed by macros, except for String, which is unwrapped to char* using method Marshal::StringToHGlobalAnsi (conversion from native string to managed is done by Marshal::PtrToStringAnsi).
Main difference in implementation of unwrapping in .Net(dNIMS) and Java(JIMS) as Scilab external environments is that in JIMS arrays are allocated on Scilab site and filled by getting every single element from java array. In dNIMS, array is allocated and copied from managed in managed class (ScilabDotNetObjects), so pointer to already allocated array is returned. That's why I used createMatrixOf.. instead of allocateMatrixOf.. in unwrappers.
ScilabDotNetEnvironment
This class inherits from ScilabAbstractEnvironment and almost always redirects calls to managed ScilabDotNetObjects, instead of additionally creating matrix of string for list of accessible fields/methods in corresponding methods.
ScilabDotNetEnvironmentWrapper
Wrapping is also just redirected to ScilabDotNetObjects, but during unwrap there's also Scilab matrix created to put a returned result.
Next week
Test dNIMS and JIMS functionality, add demos, help. Compile abstacted JIMS under Linux.