1
使用Swig包裝C++代碼時,可能使用使用%extend
。有可能0123'使用%typemap(cscode)
。使用Swig爲C++代碼構建C#包裝時,是否可以將代碼添加到現有方法?
如果包裝類中已經存在一個方法,有沒有辦法添加額外的代碼行?
例如,我的C#包裝方法是這樣的:
public void ItemChanged(CollectionObject collectionObject, string propertyName) {
mynamespacePINVOKE.mynamespace_DataObjectCollection_ItemChanged(swigCPtr, CollectionObject.getCPtr(collectionObject), propertyName);
if (mynamespacePINVOKE.SWIGPendingException.Pending) throw mynamespacePINVOKE.SWIGPendingException.Retrieve();
}
我想添加一行代碼:
public void ItemChanged(CollectionObject collectionObject, string propertyName) {
mynamespacePINVOKE.mynamespace_DataObjectCollection_ItemChanged(swigCPtr, CollectionObject.getCPtr(collectionObject), propertyName);
if (mynamespacePINVOKE.SWIGPendingException.Pending) throw mynamespacePINVOKE.SWIGPendingException.Retrieve();
**insert my line of code here**
}