AngelScriptはmacに向いてないよ

AngelSciptに関数を登録するときに、呼び出しの種類が選べます。
それは、汎用か?ネイティブか?というものです。

具体的には登録するときにasCALL_GENERIC,asCALL_CDECL,asCALL_STDCALLを指定します。
どうやら、MacではasCALL_GENERICを指定する必要があるようです。
この指定方法によって関数の書き方がかわります。
tutorial/main.cppから抜粋します。


// Function implementation with native calling convention
void PrintString(string &str)
{
cout << str; }

PrintStringはネイティブなので、C++関数そのままです。


// Function implementation with generic script interface
void PrintString_Generic(asIScriptGeneric *gen)
{
string *str = (string*)gen->GetArgAddress(0);
cout << *str; }

PrintString_Genericは引数を取り出すコードが追加してあります。
C++の関数をそのまま登録できるのがAngelScriptの大きな利点です。
そのLuaに勝っている点の一つが台無しでした。

しょうがないので、Macでの検証はここまでにします。

もっと読む

AngelScriptはmacに向いてないよ” への3件のコメント

  1. まだ試せていませんが、情報ありがとうございます!

  2. あれれ…一部がスクリプトで置き換えられたのかな?
    正しくは
    void PrintInt( const int value )
    {
    std::cout
    << value
    << std::endl;
    }
    です。

  3. AS_MAX_PORTABILITY絡みの気がしますけど
    とりあえず2.18.1、OSX(intel機)、AngelScript::asCALL_CDECL、で動いてますよ。
    参考になったらお酒おごってください(ひどい

    //↓色々省いてます
    //テスト用なので適当な関数
    int Print( std::string& value )
    {
    std::cout
    << value
    << std::endl;
    return 999;
    }
    void PrintInt( const int value )
    {
    std::cout
    << value
    <RegisterGlobalFunction(“int Print(string &in)”, AngelScript::asFUNCTION(Print), AngelScript::asCALL_CDECL);
    r = engine->RegisterGlobalFunction(“void PrintInt(const int)”, AngelScript::asFUNCTION(PrintInt), AngelScript::asCALL_CDECL);

    static const char* scriptString =
    “void hellow()”
    “{”
    ” PrintInt(Print( \”hellow world\” ));”
    ” Print( \”UTF8テスト\” );”
    “}”;

にゃおーん へ返信する

メールアドレスが公開されることはありません。 が付いている欄は必須項目です