当前位置: 首页>>代码示例>>C++>>正文


C++ Environment::callFunction方法代码示例

本文整理汇总了C++中Environment::callFunction方法的典型用法代码示例。如果您正苦于以下问题:C++ Environment::callFunction方法的具体用法?C++ Environment::callFunction怎么用?C++ Environment::callFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Environment的用法示例。


在下文中一共展示了Environment::callFunction方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testEvaluateCallRegFunction

void EnvironmentTestCase::testEvaluateCallRegFunction() {
    Environment engine;

    engine.registerFunction( "arg", QtScriptFunctions::arg );

    ASSERT_EQUAL( engine.callFunction( "arg" ).isUndefined(), true );
    ASSERT_EQUAL( engine.callFunction( "arg", 5 ).toNumber(), 5 );
    ASSERT_EXCEPTION( engine.callFunction( "arg", 5, engine.newArray() ), ScriptException );
};
开发者ID:sunepoulsen,项目名称:toolkit,代码行数:9,代码来源:environmenttestcase.cpp

示例2: testRegisterStaticMethods

void RegistrationClassTestCase::testRegisterStaticMethods() {
    Environment engine;

    QSharedPointer<RegistrationClass> f( RegistrationClass::newClass<QtScriptObject>() );
    f->getStaticFunctions().push_back( RegistrationFunction( "arg", QtScriptFunctions::arg ) );
    f->registerObject( engine.globalObject(), &engine );

    ASSERT_EQUAL( engine.callFunction( engine.globalObject().property( "QtScriptObject" ), "arg", 5 ).toInt32(), 5 );
};
开发者ID:sunepoulsen,项目名称:toolkit,代码行数:9,代码来源:registrationclasstestcase.cpp

示例3: testRegisterExtendStaticMethods

void RegistrationClassTestCase::testRegisterExtendStaticMethods() {
    Environment engine;

    RegistrationClass f( "String" );
    f.getStaticFunctions().push_back( RegistrationFunction( "arg", QtScriptFunctions::arg ) );
    f.registerObject( engine.globalObject(), &engine );

    ASSERT_EQUAL( engine.callFunction( engine.globalObject().property( "String" ), "arg", 5 ).toInt32(), 5 );
};
开发者ID:sunepoulsen,项目名称:toolkit,代码行数:9,代码来源:registrationclasstestcase.cpp

示例4: testRegisterExtendDynamicMethods

void RegistrationClassTestCase::testRegisterExtendDynamicMethods() {
    Environment engine;

    RegistrationClass f( "String" );
    f.getDynamicFunctions().push_back( RegistrationFunction( "arg", QtScriptFunctions::arg ) );
    f.registerObject( engine.globalObject(), &engine );

    QScriptValue v = engine.evaluate( "new String();" );
    ASSERT_REQUIRE_EQUAL( v.isObject(), true );

    ASSERT_EQUAL( engine.callFunction( v, "arg", 5 ).toInt32(), 5 );
};
开发者ID:sunepoulsen,项目名称:toolkit,代码行数:12,代码来源:registrationclasstestcase.cpp

示例5: testRegisterDynamicMethods

void RegistrationClassTestCase::testRegisterDynamicMethods() {
    Environment engine;

    QSharedPointer<RegistrationClass> f( RegistrationClass::newClass<QtScriptObject>() );
    f->getDynamicFunctions().push_back( RegistrationFunction( "arg", QtScriptFunctions::arg ) );
    f->registerObject( engine.globalObject(), &engine );

    QScriptValue v = engine.evaluate( "new QtScriptObject();" );
    ASSERT_REQUIRE_EQUAL( v.isObject(), true );

    ASSERT_EQUAL( engine.callFunction( v, "arg", 5 ).toInt32(), 5 );
};
开发者ID:sunepoulsen,项目名称:toolkit,代码行数:12,代码来源:registrationclasstestcase.cpp

示例6: testEvaluateCallScriptFunction

void EnvironmentTestCase::testEvaluateCallScriptFunction() {
    Environment engine;

    QString script = "function fun() { return arguments.length; }";

    ASSERT_EQUAL( engine.evaluate( script ).isValid(), true );
    ASSERT_EQUAL( engine.callFunction( "fun" ).toInteger(), 0 );
    ASSERT_EQUAL( engine.callFunction( "fun", 1 ).toInteger(), 1 );
    ASSERT_EQUAL( engine.callFunction( "fun", 1, 2 ).toInteger(), 2 );
    ASSERT_EQUAL( engine.callFunction( "fun", 1, 2, 3 ).toInteger(), 3 );
    ASSERT_EQUAL( engine.callFunction( "fun", 1, 2, 3, 4 ).toInteger(), 4 );
    ASSERT_EQUAL( engine.callFunction( "fun", 1, 2, 3, 4, 5 ).toInteger(), 5 );
    ASSERT_EQUAL( engine.callFunction( "fun", 1, 2, 3, 4, 5, 6 ).toInteger(), 6 );
    ASSERT_EQUAL( engine.callFunction( "fun", 1, 2, 3, 4, 5, 6, 7 ).toInteger(), 7 );
    ASSERT_EQUAL( engine.callFunction( "fun", 1, 2, 3, 4, 5, 6, 7, 8 ).toInteger(), 8 );
    ASSERT_EQUAL( engine.callFunction( "fun", 1, 2, 3, 4, 5, 6, 7, 8, 9 ).toInteger(), 9 );
    ASSERT_EQUAL( engine.callFunction( "fun", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ).toInteger(), 10 );
};
开发者ID:sunepoulsen,项目名称:toolkit,代码行数:18,代码来源:environmenttestcase.cpp


注:本文中的Environment::callFunction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。