通过swig作中转的
我看使用手册上介绍如果传数组的话要先转成 lvalue,
用typedef 定义了了一个数组。
typedef double vec2d[2];/***************************
33.8.5 Lvalues
When generating wrapper code, it is necessary to emit datatypes that can be used on the left-hand side of an assignment operator
(an lvalue). However, not all C datatypes can be used in this way---especially arrays and const-qualified types. To generate a
type that can be used as an lvalue, use the following function:
SwigType *SwigType_ltype(SwigType *ty)
Converts type ty to a type that can be used as an lvalue in assignment. The resulting type is stripped of qualifiers and arrays
are converted to a pointers.
The creation of lvalues is fully aware of typedef and other aspects of the type system. Therefore, the creation of an lvalue may
result in unexpected results. Here are a few examples:
typedef double Matrix4[4][4];
Matrix4 x;    // type = 'Matrix4', ltype='p.a(4).double'
***************************/
但是不知道为什么,转出来都是SWIGTYPE_P*.cs的类,无法使用的。
但是typedef struct/double 都可以。在.i文件里面都补完还是不行, 有谁能够提供一个成功的例子么?

解决方案 »

  1.   

    intPtr
    public static IntPtr UnsafeAddrOfPinnedArrayElement (
    Array arr,
    int index
    )
      

  2.   


    / * this was automatically generated by swig */using System;
    using System.Runtime.InteropServices;public class SWIGTYPE_p_a_3__float {
      private HandleRef swigCPtr;  internal SWIGTYPE_p_a_3__float(IntPtr cPtr, bool futureUse) {
        swigCPtr = new HandleRef(this, cPtr);
      }  protected SWIGTYPE_p_a_3__float() {
        swigCPtr = new HandleRef(null, IntPtr.Zero);
      }  internal static HandleRef getCPtr(SWIGTYPE_p_a_3__float obj) {
        return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
      }
    }請問如何將他封裝成一個偽類掉用呢? 
    或者使用swig 轉換的時候 能夠直接生成一個類型方法