我在C以下代碼++(cocos2d的):轉換一個C++回調到Java
typedef void (CCObject::*SEL_CallFunc)();
CCCallFunc * CCCallFunc::actionWithTarget(CCObject* pSelectorTarget,
SEL_CallFunc selector) {
CCCallFunc *pRet = new CCCallFunc();
if (pRet && pRet->initWithTarget(pSelectorTarget)) {
pRet->m_pCallFunc = selector;
pRet->autorelease();
return pRet;
}
CC_SAFE_DELETE(pRet);
return NULL;
}
當痛飲轉換爲Java,我得到以下幾點:
public static CCCallFunc actionWithTarget(CCObject pSelectorTarget, SWIGTYPE_m_CCObject__f___void selector) {
long cPtr = cocos2dxMappingJNI.CCCallFunc_actionWithTarget(CCObject.getCPtr(pSelectorTarget), pSelectorTarget,
SWIGTYPE_m_CCObject__f___void.getCMemberPtr(selector));
return (cPtr == 0) ? null : new CCCallFunc(cPtr, false);
}
哪裏SWIGTYPE_m_CCObject__f___void
只是一個我無法使用的指針。
我該如何在SWIG界面中實現這個功能? 我已經研究過這個解決方案stackoverflow,但無法爲我的情況實現它。
可能用JavaCPP完成它... – issamux 2014-10-20 22:13:03