Adobe Flex プロジェクト用に C++ で記述されたネイティブ拡張機能を構築しようとしています。すべてを100回再確認しましたが、何をしても、「拡張コンテキストにはgetHelloWorldという名前のメソッドがありません」というエラーが常に表示されます。
これは私のコードです:
Flash ビルダー アクションスクリプト クラス:
package
{
import flash.events.EventDispatcher;
import flash.external.ExtensionContext;
public class QCARBridge extends EventDispatcher
{
private var extContext:ExtensionContext;
public function QCARBridge()
{
extContext = ExtensionContext.createExtensionContext("NativeQCAR", null);
if(!extContext) {
throw new Error("Extension context couldn't be created :(");
}
}
// Native methods
public function getTestString():String {
return extContext.call("getTestString") as String;
}
public function isSupported():int {
return extContext.call("isSupported") as int;
}
public function getHelloWorld():String {
return extContext.call("getHelloWorld") as String;
}
}
}
Flash ビルダーの extension.xml:
<?xml version="1.0" encoding="UTF-8"?>
<extension xmlns="http://ns.adobe.com/air/extension/3.1">
<id>NativeQCAR</id>
<versionNumber>1</versionNumber>
<platforms>
<platform name="Windows-x86">
<applicationDeployment>
<nativeLibrary>libNativeQCAR.dll</nativeLibrary>
<initializer>initializer</initializer>
<finalizer>finalizer</finalizer>
</applicationDeployment>
</platform>
</platforms>
</extension>
および C++ コード:
#include "main.h"
#include "Stdlib.h"
#include "String.h"
FREObject isSupported(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[])
{
FREObject result;
uint32_t isSupportedInThisOS = 1;
FRENewObjectFromBool( isSupportedInThisOS, &result);
return result;
}
FREObject getTestString(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[])
{
FREObject result;
const char *str = "De android library zegt ook eens hallo...";
FRENewObjectFromUTF8(strlen(str)+1, (const uint8_t *)str, &result);
return result;
}
FREObject getHelloWorld(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[])
{
FREObject result;
const char *str = "Hello World!! This is your DLL talking!";
FRENewObjectFromUTF8(strlen(str)+1, (const uint8_t *)str, &result);
return result;
}
void contextInitializer(void* extData, const uint8_t* ctxType, FREContext ctx, uint32_t* numFunctions, const FRENamedFunction** functions)
{
*numFunctions = 3;
FRENamedFunction* func = (FRENamedFunction*) malloc(sizeof(FRENamedFunction) * (*numFunctions));
func[0].name = (const uint8_t*) "getTestString";
func[0].functionData = NULL;
func[0].function = &getTestString;
func[1].name = (const uint8_t*) "isSupported";
func[1].functionData = NULL;
func[1].function = &isSupported;
func[2].name = (const uint8_t*) "getHelloWorld";
func[2].functionData = NULL;
func[2].function = &getHelloWorld;
*functions = func;
}
void contextFinalizer(FREContext ctx)
{
return;
}
void initializer(void** extData, FREContextInitializer* ctxInitializer, FREContextFinalizer* ctxFinalizer)
{
*ctxInitializer = &contextInitializer;
*ctxFinalizer = &contextFinalizer;
}
void finalizer(void* extData)
{
return;
}
すべての点を正しい方法で接続したように見えますが、なぜ機能しないのですか?