• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ call_function函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中call_function函数的典型用法代码示例。如果您正苦于以下问题:C++ call_function函数的具体用法?C++ call_function怎么用?C++ call_function使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: simpsons_approx

double simpsons_approx(int fun,double lo,double hi){//do a simpson's approximation on the appropriate function over the specified interval
	double p1=(hi-lo)/6.0;
	double pLo=call_function(fun,lo);
	double pAv=4.0 * call_function(fun,(lo+hi)/2 );
	double pHi=call_function(fun,hi);
	return p1*( pLo+pAv+pHi );
}
开发者ID:wtmcneill,项目名称:HPC,代码行数:7,代码来源:simpsons_serial.c


示例2: create_object

void 
create_object(struct object *ob)
{
    int i;

    if (!(ob->flags & O_CREATED))
    {
	ob->flags |= O_CREATED;
	ob->created = current_time;
	for (i = 0; i < (int)ob->prog->num_inherited; i++)
	    if (!(ob->prog->inherit[i].type & TYPE_MOD_SECOND))
	    {
		if (ob->prog->inherit[i].prog->ctor_index !=
		    (unsigned short) -1)
		{
		    call_function(ob, i,
				  (unsigned int)ob->prog->inherit[i].prog->ctor_index, 0);
		    pop_stack();
		}
	    }
	if (search_for_function("create", ob->prog))
	{
	    call_function(ob, function_inherit_found,
			  (unsigned int)function_index_found, 0);
	    pop_stack();
	}
    }
}
开发者ID:carriercomm,项目名称:cd-gamedriver,代码行数:28,代码来源:object.c


示例3: func_name

const SpObject *SpVM::eval(const SpExpr *expr, SpEnv *env) {
   // check whether this expression is an atom or a function call
   if (expr->head()->type() == TOKEN_FUNCTION_CALL) {
      // this is a function call expression
      std::string func_name(expr->head()->value());

      // we find the function associated with this name in the given environment
      const SpObject *obj = resolve(func_name, env);
      if (obj == NULL || obj->type() != T_FUNCTION) RUNTIME_ERROR_F("'%s' is not a function", func_name.c_str());

      // now call the function
      return call_function(func_name, 
         static_cast<const SpFunction *>(obj->self()), expr, env);
   } else {
      // evaluate this atom
      std::string val = expr->head()->value();
      switch (expr->head()->type()) {
         case TOKEN_NAME: {
            const SpObject *obj = resolve(val, env); 
            if (obj == NULL)
               RUNTIME_ERROR_F("Undeclared variable '%s'", val.c_str());
            return obj->shallow_copy();
         }
         case TOKEN_NUMERIC:
            return new SpIntValue(atoi(val.c_str()));
         case TOKEN_CLOSURE:
            // the closure expression is stored in the first argument of the
            // object expression
            return new SpRefObject(new SpClosure(ArgList(), NULL, *expr->cbegin()));
         default:
            RUNTIME_ERROR("Unsupported operation");
      }
   }
}
开发者ID:evilncrazy,项目名称:spooner,代码行数:34,代码来源:vm.cpp


示例4: get_type

int	get_type(char *format, va_list args)
{
  int	id;
  int	count[1];

  count[0] = 0;
  count[1] = 0;
  while (format[count[1]] != '\0')
    {
      id = -1;
      if (format[count[1]] == '%')
	{
	  id = get_id(count[1], format, "csdioxXbpSuf");
	  if (id >= 0)
	    {
	      count[0] += call_function(id, args);
	      count[1]++;
	    }
	  count[1]++;
	}
      else
	get_type_next(format, count);
    }
  return (count[0]);
}
开发者ID:guillaumetran,项目名称:EPITECH,代码行数:25,代码来源:my_printf.c


示例5: call_function

/**
* \brief Calls the on_closed() method of the object on top of the stack.
*/
void LuaContext::on_closed() 
{
  if (find_method("on_closed")) 
  {
    call_function(1, 0, "on_closed");
  }
}
开发者ID:woodenToaster,项目名称:kirpsquest,代码行数:10,代码来源:LuaContext.cpp


示例6: get_function_value

int32 interpreter::get_function_value(int32 f, uint32 param_count) {
	int32 result;
	if(!f) {
		params.clear();
		return 0;
	}
	no_action++;
	call_depth++;
	if (call_function(f, param_count, 1)) {
		if (lua_isboolean(current_state, -1))
			result = lua_toboolean(current_state, -1);
		else
			result = lua_tointeger(current_state, -1);
		lua_pop(current_state, 1);
		no_action--;
		call_depth--;
		if(call_depth == 0) {
			pduel->release_script_group();
			pduel->restore_assumes();
		}
		return result;
	}
	no_action--;
	call_depth--;
	if(call_depth == 0) {
		pduel->release_script_group();
		pduel->restore_assumes();
	}
	return OPERATION_FAIL;
}
开发者ID:AthosVinicius,项目名称:ygopro,代码行数:30,代码来源:interpreter.cpp


示例7: check_condition

int32 interpreter::check_condition(int32 f, uint32 param_count) {
	int32 result;
	if(!f) {
		params.clear();
		return TRUE;
	}
	no_action++;
	call_depth++;
	if (call_function(f, param_count, 1)) {
		result = lua_toboolean(current_state, -1);
		lua_pop(current_state, 1);
		no_action--;
		call_depth--;
		if(call_depth == 0) {
			pduel->release_script_group();
			pduel->restore_assumes();
		}
		return result;
	}
	no_action--;
	call_depth--;
	if(call_depth == 0) {
		pduel->release_script_group();
		pduel->restore_assumes();
	}
	return OPERATION_FAIL;
}
开发者ID:AthosVinicius,项目名称:ygopro,代码行数:27,代码来源:interpreter.cpp


示例8: evaluate_variable

bool evaluate_variable(const object& variable_name)
{
    object result;

//    std::cout << "GET VARIABLE" << std::endl;
    if(get_variable(variable_name.data.variable, &result) == OK)
    {
//        std::cout << "GET VARIABLE" << std::endl;

        // Auto call zero argument functions when they are found.
        if(result.type == FUNCTION)
        {
            if(result.data.function->arguments.size() == 1)
            {
                object arguments; // empty, won't be used by call_function so no need to initialize
                call_function(result, result, arguments);
            }
        }

        optic_stack.push_back(result); // result is already a copy, no need to copy again
        return true;
    }

    else
    {
        out() << "Variable " << reverse_variable_name_lookup[variable_name.data.variable] << " not found." << std::endl;
        clear_stack();
        return false;
    }
}
开发者ID:GlitchLich,项目名称:Panopticon,代码行数:30,代码来源:stack.cpp


示例9: push_callback

/**
 * \brief Executes the callback of a timer.
 *
 * Then, if the callback returns \c true, the timer is rescheduled,
 * otherwise it is discarded.
 *
 * Does nothing if the timer is already finished.
 *
 * \param timer The timer to execute.
 */
void LuaContext::do_timer_callback(Timer& timer) {

  Debug::check_assertion(timer.is_finished(), "This timer is still running");

  const std::map<Timer*, LuaTimerData>::iterator it = timers.find(&timer);
  if (it != timers.end() && it->second.callback_ref != LUA_REFNIL) {
    const int callback_ref = it->second.callback_ref;
    push_callback(callback_ref);
    const bool success = call_function(0, 1, "timer callback");

    bool repeat = false;
    if (success) {
      repeat = lua_isboolean(l, -1) && lua_toboolean(l, -1);
      lua_pop(l, 1);
    }

    if (repeat) {
      // The callback returned true: reschedule the timer.
      timer.set_expiration_date(timer.get_expiration_date() + timer.get_initial_duration());
      if (timer.is_finished()) {
        // Already finished: this is possible if the duration is smaller than
        // the main loop stepsize.
        do_timer_callback(timer);
      }
    }
    else {
      cancel_callback(callback_ref);
      it->second.callback_ref = LUA_REFNIL;
      timers_to_remove.push_back(&timer);
    }
  }
}
开发者ID:kenygia,项目名称:solarus,代码行数:42,代码来源:TimerApi.cpp


示例10: main

int
main() {
	lua_State *L = luaL_newstate();
	call_function(L);
	lua_close(L);
	return 0;
}
开发者ID:andycai,项目名称:kodeclua,代码行数:7,代码来源:cCallLuaFunction.c


示例11: Function_call

static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
        jsval_t *r)
{
    FunctionInstance *function;
    IDispatch *this_obj = NULL;
    unsigned cnt = 0;
    HRESULT hres;

    TRACE("\n");

    if(!(function = function_this(jsthis)))
        return throw_type_error(ctx, JS_E_FUNCTION_EXPECTED, NULL);

    if(argc) {
        if(!is_undefined(argv[0]) && !is_null(argv[0])) {
            hres = to_object(ctx, argv[0], &this_obj);
            if(FAILED(hres))
                return hres;
        }

        cnt = argc-1;
    }

    hres = call_function(ctx, function, this_obj, cnt, argv+1, r);

    if(this_obj)
        IDispatch_Release(this_obj);
    return hres;
}
开发者ID:340211173,项目名称:wine,代码行数:29,代码来源:function.c


示例12: push_ref

/**
 * \brief Executes the callback of a timer.
 *
 * Then, if the callback returns \c true, the timer is rescheduled,
 * otherwise it is discarded.
 *
 * Does nothing if the timer is already finished.
 *
 * \param timer The timer to execute.
 */
void LuaContext::do_timer_callback(const TimerPtr& timer) {

  Debug::check_assertion(timer->is_finished(), "This timer is still running");

  auto it = timers.find(timer);
  if (it != timers.end() &&
      !it->second.callback_ref.is_empty()) {
    ScopedLuaRef& callback_ref = it->second.callback_ref;
    push_ref(l, callback_ref);
    const bool success = call_function(0, 1, "timer callback");

    bool repeat = false;
    if (success) {
      repeat = lua_isboolean(l, -1) && lua_toboolean(l, -1);
      lua_pop(l, 1);
    }

    if (repeat) {
      // The callback returned true: reschedule the timer.
      timer->set_expiration_date(timer->get_expiration_date() + timer->get_initial_duration());
      if (timer->is_finished()) {
        // Already finished: this is possible if the duration is smaller than
        // the main loop stepsize.
        do_timer_callback(timer);
      }
    }
    else {
      callback_ref.clear();
      timers_to_remove.push_back(timer);
    }
  }
}
开发者ID:benoitschneider,项目名称:solarus,代码行数:42,代码来源:TimerApi.cpp


示例13: epic_call

static VALUE epic_call (VALUE module, VALUE string)
{
	char *funcval;
	RUBY_STARTUP

	funcval = call_function(my_string, "");
	return rb_str_new(funcval, strlen(funcval));
}
开发者ID:Cloudxtreme,项目名称:epic5,代码行数:8,代码来源:ruby.c


示例14: do_test_run

static void do_test_run(struct code_chunks *chunk)
{
	/* type-1 function */
	char df1[] = {
		0x64, 0x00, 0x00, 0x00,   /* 100 */
		'x', 0x00, 0x00, 0x00,    /* 'x' */
		0xC8, 0x00, 0x00, 0x00,   /* 200 */
	};

	/* type-2 function */
	char *name = "mygirl";
	char df2[] = {
		0x00, 0x00, 0x00, 0x00,   /* name */
		0x04, 0x00, 0x00, 0x00    /* 4 */
	};

	/* type-3 function */
	int fibo;
	char df3[] = {
		0x0f, 0x00, 0x00, 0x00,   /* 15 */
		0x00, 0x00, 0x00, 0x00    /* fibo */
	};

	char number[15];
	char df4[] = {
		0xde, 0xad, 0xbe, 0xef,
		0x00, 0x00, 0x00, 0x00   /* number */
	};

	char df5[] = { };

	ptr2char(df2, name);
	ptr2char((char *)df3 + 4, &fibo);
	ptr2char((char *)df4 + 4, number);

	call_function(chunk, FUNC_TYPE1, df1);
	call_function(chunk, FUNC_TYPE2, df2);

	call_function(chunk, FUNC_TYPE3, df3);
	printf("%s: fibo value returned: %d\n", __func__, fibo);

	call_function(chunk, FUNC_TYPE5, df5);

	call_function(chunk, FUNC_TYPE4, df4);
	printf("%s: original: %d, reversed: %s\n", __func__, *(int *)df4, number);
}
开发者ID:rchandramouli,项目名称:misc-scripts,代码行数:46,代码来源:tests.c


示例15: query

 uint64_t query(factor Factor) const
 {
     const auto Diff = call_function(QueryPerformanceCounter) - m_StartTime;
     const auto Frequency = get_frequency();
     const auto Whole = Diff / Frequency;
     const auto Fraction = Diff % Frequency;
     return Whole * Factor + (Fraction * Factor) / Frequency;
 }
开发者ID:modulexcite,项目名称:Far3bis-googlecode,代码行数:8,代码来源:farwinapi.hpp


示例16: tm_load_module

/**
 * @since 2016-11-20
 */
Object tm_load_module(Object file, Object code, Object name) {
    Object mod = module_new(file, name, code);
    Object fnc = func_new(mod, NONE_OBJECT, NULL);
    GET_FUNCTION(fnc)->code = (unsigned char*) GET_STR(code);
    GET_FUNCTION(fnc)->name = string_new("#main");
    call_function(fnc);
    return GET_MODULE(mod)->globals;
}
开发者ID:xupingmao,项目名称:minipy,代码行数:11,代码来源:interp.c


示例17: push_surface

/**
* @brief Calls the on_draw() method of the object on top of the stack.
* @param dst_surface The destination surface.
*/
void LuaContext::on_draw(Surface& dst_surface) 
{
  if (find_method("on_draw")) 
  {
    push_surface(l, dst_surface);
    call_function(2, 0, "on_draw");
  }
}
开发者ID:woodenToaster,项目名称:kirpsquest,代码行数:12,代码来源:LuaContext.cpp


示例18: push_callback

/**
* @brief Calls a function stored in the registry with a reference and
* releases this reference.
* @param callback_ref Reference of the function to call (if LUA_REFNIL,
* nothing is done).
*/
void LuaContext::do_callback(int callback_ref) 
{
  if (callback_ref != LUA_REFNIL) 
  {
    push_callback(callback_ref);
    call_function(0, 0, "callback");
    destroy_ref(callback_ref);
  }
}
开发者ID:woodenToaster,项目名称:kirpsquest,代码行数:15,代码来源:LuaContext.cpp


示例19: Function_apply

static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp,
        VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
{
    FunctionInstance *function;
    DISPPARAMS args = {NULL,NULL,0,0};
    DWORD argc, i;
    IDispatch *this_obj = NULL;
    HRESULT hres = S_OK;

    TRACE("\n");

    if(!(function = function_this(jsthis)))
        return throw_type_error(ctx, ei, JS_E_FUNCTION_EXPECTED, NULL);

    argc = arg_cnt(dp);
    if(argc) {
        VARIANT *v = get_arg(dp,0);

        if(V_VT(v) != VT_EMPTY && V_VT(v) != VT_NULL) {
            hres = to_object(ctx, v, &this_obj);
            if(FAILED(hres))
                return hres;
        }
    }

    if(argc >= 2) {
        jsdisp_t *arg_array = NULL;

        if(V_VT(get_arg(dp,1)) == VT_DISPATCH) {
            arg_array = iface_to_jsdisp((IUnknown*)V_DISPATCH(get_arg(dp,1)));
            if(arg_array &&
               (!is_class(arg_array, JSCLASS_ARRAY) && !is_class(arg_array, JSCLASS_ARGUMENTS) )) {
                jsdisp_release(arg_array);
                arg_array = NULL;
            }
        }

        if(arg_array) {
            hres = array_to_args(ctx, arg_array, ei, caller, &args);
            jsdisp_release(arg_array);
        }else {
            FIXME("throw TypeError\n");
            hres = E_FAIL;
        }
    }

    if(SUCCEEDED(hres))
       hres = call_function(ctx, function, this_obj, &args, retv, ei, caller);

    if(this_obj)
        IDispatch_Release(this_obj);
    for(i=0; i<args.cArgs; i++)
        VariantClear(args.rgvarg+i);
    heap_free(args.rgvarg);
    return hres;
}
开发者ID:MichaelMcDonnell,项目名称:wine,代码行数:56,代码来源:function.c


示例20: lock

void ApplicationWindow::onCheckForNewVersionResult(VersionInfo::VersionInfo _versioninfo)
{        
    if (_versioninfo.appVersionBuild == 0)
    {
        // no connect to update server...
        std::unique_lock<std::mutex> lock(lockGuiUpdate);
        call_function("Application.newVersionCheckFailed");
    }
    else if (_versioninfo.appVersionBuild > versionInfoApp.appVersionBuild)
    {        
        // new version is ready for download
        std::unique_lock<std::mutex> lock(lockGuiUpdate);
        call_function("Application.newVersionAvailable", sciter::value(currentVersionBinarySource), sciter::value(_versioninfo.appVersion), sciter::value(std::to_string(_versioninfo.appVersionBuild)));
    }
    else
    {
        call_function("Application.versionIsUpToDate", sciter::value(_versioninfo.appVersion), sciter::value(std::to_string(_versioninfo.appVersionBuild)));
    }
}
开发者ID:mfuxxschick,项目名称:Raumserver,代码行数:19,代码来源:raumserverInstallerView.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ call_method函数代码示例发布时间:2022-05-30
下一篇:
C++ call_dissector函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap