示例#1
0
void* ChttransCreate(FcitxInstance* instance)
{
    FcitxChttrans* transState = fcitx_utils_malloc0(sizeof(FcitxChttrans));
    FcitxAddon* transAddon = FcitxAddonsGetAddonByName(FcitxInstanceGetAddons(instance), FCITX_CHTTRANS_NAME);
    transState->owner = instance;
    if (!LoadChttransConfig(transState)) {
        free(transState);
        return NULL;
    }

    FcitxHotkeyHook hk;
    hk.arg = transState;
    hk.hotkey = transState->hkToggle;
    hk.hotkeyhandle = HotkeyToggleChttransState;

    FcitxStringFilterHook shk;
    shk.arg = transState;
    shk.func = ChttransOutputFilter;

    FcitxInstanceRegisterHotkeyFilter(instance, hk);
    FcitxInstanceRegisterOutputFilter(instance, shk);
    FcitxInstanceRegisterCommitFilter(instance, shk);
    FcitxUIRegisterStatus(instance, transState, "chttrans",
                          transState->enabled ? _("Convert to Traditional Chinese") :  _("Convert to Simplified Chinese"),
                          _("Toggle Simp/Trad Chinese Conversion"),
                          ToggleChttransState,
                          GetChttransEnabled);

    FcitxInstanceWatchContext(instance, CONTEXT_IM_LANGUAGE, ChttransLanguageChanged, transState);

    AddFunction(transAddon, ChttransS2T);
    AddFunction(transAddon, ChttransT2S);

    return transState;
}
示例#2
0
void ReminderGlue::AddFunctions()
{
	AddFunction(boost::bind(&ReminderGlue::AddReminder, this, _1),
			"ReminderAdd");
	AddFunction(boost::bind(&ReminderGlue::FindReminder, this, _1),
			"ReminderFind");
}
示例#3
0
文件: lua.c 项目: dsturnbull/gravit
int luaInit() {

    luaFree();

    state.lua = lua_open();
    if (!state.lua) {
        conAdd(LERR, "Error loading LUA");
        return 0;
    }
    
    luaL_openlibs(state.lua);
    luaopen_base(state.lua);
    luaopen_table(state.lua);
    luaopen_string(state.lua);
    luaopen_math(state.lua);

#define AddFunction(a,b) lua_pushcfunction(state.lua, b); lua_setglobal(state.lua, a);

    AddFunction("particle", luag_spawn)
    AddFunction("log", luag_log)
    AddFunction("load", luag_load);

    return 1;

}
示例#4
0
int plugin_init_proc_stat(void)
{
    hash_create(&Stat);
    AddFunction("proc_stat", -1, my_proc_stat);
    AddFunction("proc_stat::cpu", 2, my_cpu);
    AddFunction("proc_stat::disk", 3, my_disk);
    return 0;
}
示例#5
0
void CServerRPCHandler::Register()
{
	CLogFile::Printf("Registering server RPCs");
	AddFunction(RPC_INITIAL_DATA, InitialData);
	AddFunction(RPC_CHAT_INPUT, ChatInput);
	AddFunction(RPC_VEHICLE_ENTER_EXIT, VehicleEnterExit);
	AddFunction(RPC_PLAYER_SYNC, PlayerSync);
	CLogFile::Printf("Server RPCs registered");
}
示例#6
0
int plugin_init_mysql(void)
{
#ifdef HAVE_MYSQL_MYSQL_H
    AddFunction("MySQL::count", 1, my_MySQLcount);
    AddFunction("MySQL::query", 1, my_MySQLquery);
    AddFunction("MySQL::status", 0, my_MySQLstatus);
#endif
    return 0;
}
示例#7
0
CNssPlayer::CNssPlayer(void) {
	AddFunction("SETQUICKSLOT", L_CAST(&CNssPlayer::SetQuickSlot));
	AddFunction("GETQUICKSLOT", L_CAST(&CNssPlayer::GetQuickSlot));
	AddFunction("UPDATEQUICKBAR", L_CAST(&CNssPlayer::UpdateQuickbar));
	AddFunction("TIMEBARSTART", L_CAST(&CNssPlayer::TimebarStart));
	AddFunction("TIMEBARSTOP", L_CAST(&CNssPlayer::TimebarStop));
	AddFunction("UPDATECHARSHEET", L_CAST(&CNssPlayer::UpdateCharSheet));
	AddFunction("POSSESSCREATURE", L_CAST(&CNssPlayer::PossessCreature));
	AddFunction("BOOTPCWITHMESSAGE", L_CAST(&CNssPlayer::BootPCWithMessage));
	AddFunction("POPUPMESSAGE", L_CAST(&CNssPlayer::PopUpMessage));
}
示例#8
0
/* initialize driver & display */
int drv_st2205_init2(const char *section, const int quiet)
{
    int ret;

    /* real worker functions */
    drv_generic_graphic_real_blit = drv_st2205_blit;

    /* start display */
    if ((ret = drv_st2205_start2(section)) != 0)
	return ret;

    /* initialize generic graphic driver */
    if ((ret = drv_generic_graphic_init(section, Name)) != 0)
	return ret;

    if (!quiet) {
	char buffer[40];
	qprintf(buffer, sizeof(buffer), "%s %dx%d", Name, DCOLS, DROWS);
	if (drv_generic_graphic_greet(buffer, NULL)) {
	    sleep(3);
	    drv_generic_graphic_clear();
	}
    }

    /* register plugins */
    AddFunction("LCD::backlight", 1, plugin_backlight);

    return 0;
}
// Add function to the functions MenuField
void AppWindow::OnAdd() {
	if (CheckFunction()) {
		AddFunction(view->f1);
		view->graph->AppendFunction(view->f1->Clone()); 
	}
	view->Invalidate();
}
示例#10
0
void CDaoNamespace::HandleDeclaration( Decl *D )
{
	if( unsupported ) return;
	if( LinkageSpecDecl *TUD = dyn_cast<LinkageSpecDecl>(D) ){
		DeclContext::decl_iterator it, end;
		for(it=TUD->decls_begin(),end=TUD->decls_end(); it!=end; it++){
			HandleDeclaration( *it );
		}
	}
	if (VarDecl *var = dyn_cast<VarDecl>(D)) {
		variables.push_back( var );
	}else if (EnumDecl *e = dyn_cast<EnumDecl>(D)) {
		enums.push_back( e );
	}else if (FunctionDecl *func = dyn_cast<FunctionDecl>(D)) {
		AddFunction( new CDaoFunction( module, func ) );
	}else if (RecordDecl *record = dyn_cast<RecordDecl>(D)) {
		QualType qtype( record->getTypeForDecl(), 0 );
		AddUserType( module->HandleUserType( qtype, record->getLocation() ) );
	}else if (NamespaceDecl *nsdecl = dyn_cast<NamespaceDecl>(D)) {
		CDaoNamespace *ns = module->AddNamespace( nsdecl );
		if( ns ) namespaces.push_back( ns );
	}else if( TypedefDecl *decl = dyn_cast<TypedefDecl>(D) ){
		module->HandleTypeDefine( decl );
	}
}
示例#11
0
/* initialize driver & display */
int drv_PICGraphic_init2(const char *section, const int quiet)
{
    int ret;

    /* real worker functions */
    drv_generic_graphic_real_blit = drv_PICGraphic_blit;
    drv_generic_gpio_real_set = drv_PICGraphic_GPO;
    drv_generic_gpio_real_get = drv_PICGraphic_GPI;

    /* start display */
    if ((ret = drv_PICGraphic_start2(section)) != 0)
	return ret;

    /* initialize generic graphic driver */
    if ((ret = drv_generic_graphic_init(section, Name)) != 0)
	return ret;

    if (!quiet) {
	char buffer[40];
	qprintf(buffer, sizeof(buffer), "%s %dx%d", Name, DCOLS, DROWS);
	if (drv_generic_graphic_greet(buffer, NULL)) {
	    sleep(3);
	    drv_generic_graphic_clear();	// also clears main framebuffer
	}
    }

    /* register plugins */
    AddFunction("LCD::contrast", 1, plugin_contrast);

    return 0;
}
示例#12
0
void axEventManager::PushEvent(const axID& id,
                               const axEventId& evtId,
                               axMsg* msg)
{
    manager_mutex.lock();
    
    auto it = _event_fct_map.find(id);
    
    if(it != _event_fct_map.end())
    {
        // Pair of the first and last element of this id.
        auto range(it->second.equal_range(evtId));
        
        axCore* core = axApp::GetInstance()->GetCore();
        
        // Add every connected functions from this id to the event queue.
        for (axEventMultimapIterator i = range.first; i != range.second; ++i)
        {
            // Create a Copy of child params.
            axMsg* msg_copy = msg->GetCopy();

            // Add binded function to event queue.bn
            AddFunction(axBindedEvent(i->second, msg_copy));
            
            core->PushEventOnSystemQueue();
        }
    }
    
    manager_mutex.unlock();
    
    delete msg;
}
SCPlotDirector::SCPlotDirector
	(
	istream&			input,
	const JFileVersion	vers,
	SCCircuitDocument*	supervisor
	)
	:
	JXWindowDirector(supervisor)
{
	itsDoc = supervisor;
	itsDoc->PlotCreated(this);

	BuildWindow();
	(GetWindow())->ReadGeometry(input);

	JSize fnCount;
	input >> fnCount;

	for (JIndex i=1; i<=fnCount; i++)
		{
		JFloat xMin, xMax;
		input >> xMin >> xMax;

		JFunction* f = JFunction::StreamIn(input, itsDoc->GetVarList());
		AddFunction(f, "", xMin, xMax);
		}

	itsPlot->PWReadSetup(input);
	itsPlot->PWReadCurveSetup(input);
}
示例#14
0
文件: lua.c 项目: mylxiaoyi/fcitx
void* LuaCreate(FcitxInstance* instance) {
    LuaModule *luamodule = LuaModuleAlloc(instance);
    if (luamodule == NULL) {
        FcitxLog(ERROR, "LuaModule alloc failed");
        goto err;
    }
    LoadLuaConfig(luamodule);

    FcitxIMEventHook hook = {.arg = luamodule,
                             .func = LuaUpdateCandidateWordHookCallback};

    FcitxInstanceRegisterUpdateCandidateWordHook(instance, hook);

    FcitxAddon* luaAddon = FcitxAddonsGetAddonByName(
            FcitxInstanceGetAddons(instance),
            FCITX_LUA_NAME);
    AddFunction(luaAddon, LuaCallCommand);

    return luamodule;
err:
    if (luamodule) {
        LuaModuleFree(luamodule);
    }
    return NULL;
}
示例#15
0
static AstExpression CheckFunctionCall(AstExpression expr)
{
	AstExpression arg;
	Type ty;
	AstNode *tail;
	int argNo, argFull;

	if (expr->kids[0]->op == OP_ID && LookupID(expr->kids[0]->val.p) == NULL)
	{
		expr->kids[0]->ty = DefaultFunctionType;
		expr->kids[0]->val.p = AddFunction(expr->kids[0]->val.p, DefaultFunctionType, TK_EXTERN);
	}
	else
	{
		expr->kids[0] = CheckExpression(expr->kids[0]);
	}
	expr->kids[0] = Adjust(expr->kids[0], 1);
	ty = expr->kids[0]->ty;

	if (! (IsPtrType(ty) && IsFunctionType(ty->bty)))
	{
		Error(&expr->coord, "The left operand must be function or function pointer");
	    ty = DefaultFunctionType;
	}
	else
	{
		ty = ty->bty;
	}

	tail = (AstNode *)&expr->kids[1];
	arg = expr->kids[1];
	argNo = 1;
	argFull = 0;
	while (arg != NULL && ! argFull)
	{
		*tail = (AstNode)CheckArgument((FunctionType)ty, arg, argNo, &argFull);
		tail = &(*tail)->next;
		arg = (AstExpression)arg->next;
		argNo++;
	}
	*tail = NULL;

	if (arg != NULL)
	{
		while (arg != NULL)
		{
			CheckExpression(arg);
			arg = (AstExpression)arg->next;
		}
		Error(&expr->coord, "Too many arguments");
	}
	else if (argNo < LEN(((FunctionType)ty)->sig->params))
	{
		Error(&expr->coord, "Too few arguments");
	}
	expr->ty = ty->bty;

	return expr;
}
示例#16
0
int plugin_init_apm(void)
{
    hash_create(&APM);

    AddFunction("apm", 1, my_apm);

    return 0;
}
示例#17
0
bool Register_Siren(IEventArg& e)
{
	LuaState& state = *((UserDataEventArg<LuaState*>&)e).Data();
	auto module = state.BeginModule("ml");
	auto sirenModule = module.BeginModule("Siren");

	auto serializePtr = [](const ISirenType& type, ScriptObject obj)->HeapString {return Siren::SerializeScript(obj, type, SirenCoderType::Compact); };
	auto deserializePtr = [](const ISirenType& type, HeapString data)->ScriptObject {return Siren::DeserializeScript(*ScriptEngine::State(),data,type,SirenCoderType::Compact); };
	auto deserializeToPtr = [](ScriptObject& obj,const ISirenType& type, HeapString data)->bool {return Siren::DeserializeScriptTo(obj, data, type, SirenCoderType::Compact); };

	sirenModule.AddFunction("Serialize", serializePtr);
	sirenModule.AddFunction("Deserialize", deserializePtr);
	sirenModule.AddFunction("DeserializeTo", deserializePtr);


	return true;
}
示例#18
0
int plugin_init_wireless(void)
{
    hash_create(&wireless);

    AddFunction("wifi::level", 1, wireless_level);
    AddFunction("wifi::noise", 1, wireless_noise);
    AddFunction("wifi::quality", 1, wireless_quality);
    AddFunction("wifi::protocol", 1, wireless_protocol);
    AddFunction("wifi::frequency", 1, wireless_frequency);
    AddFunction("wifi::bitrate", 1, wireless_bitrate);
    AddFunction("wifi::essid", 1, wireless_essid);
    AddFunction("wifi::op_mode", 1, wireless_op_mode);
    AddFunction("wifi::sensitivity", 1, wireless_sensitivity);
    AddFunction("wifi::sec_mode", 1, wireless_sec_mode);

    return 0;
}
	void UpdatesNotificationManager::notify ()
	{
		NotifyScheduled_ = false;

		auto em = Proxy_->GetEntityManager ();

		const auto upgradableCount = UpgradablePackages_.size ();
		QString bodyText;
		if (!upgradableCount)
		{
			auto cancel = Util::MakeANCancel ("org.LeechCraft.LackMan", "org.LeechCraft.LackMan");
			em->HandleEntity (cancel);

			return;
		}
		else if (upgradableCount <= 3)
		{
			QStringList names;
			for (auto id : UpgradablePackages_)
				names << Core::Instance ().GetListPackageInfo (id).Name_;
			names.sort ();

			if (upgradableCount == 1)
				bodyText = tr ("A new version of %1 is available.")
						.arg ("<em>" + names.value (0) + "</em>");
			else
			{
				const auto& lastName = names.takeLast ();
				bodyText = tr ("New versions of %1 and %2 are available.")
						.arg ("<em>" + names.join ("</em>, <em>") + "</em>")
						.arg ("<em>" + lastName + "</em>");
			}
		}
		else
			bodyText = tr ("New versions are available for %n package(s).",
					0, upgradableCount);

		auto entity = Util::MakeAN ("Lackman",
				bodyText,
				PInfo_,
				"org.LeechCraft.LackMan",
				AN::CatPackageManager,
				AN::TypePackageUpdated,
				"org.LeechCraft.LackMan",
				{ "Lackman" },
				0,
				upgradableCount);

		auto nah = new Util::NotificationActionHandler (entity, this);
		nah->AddFunction (tr ("Open LackMan"),
				[this, entity, em] () -> void
				{
					emit openLackmanRequested ();
					em->HandleEntity (Util::MakeANCancel (entity));
				});

		em->HandleEntity (entity);
	}
示例#20
0
bool SymbolMap::LoadNocashSym(const char *filename)
{
	lock_guard guard(lock_);
	FILE *f = File::OpenCFile(filename, "r");
	if (!f)
		return false;

	while (!feof(f)) {
		char line[256], value[256] = {0};
		char *p = fgets(line, 256, f);
		if (p == NULL)
			break;

		u32 address;
		if (sscanf(line, "%08X %s", &address, value) != 2)
			continue;
		if (address == 0 && strcmp(value, "0") == 0)
			continue;

		if (value[0] == '.') {
			// data directives
			char* s = strchr(value, ':');
			if (s != NULL) {
				*s = 0;

				u32 size = 0;
				if (sscanf(s + 1, "%04X", &size) != 1)
					continue;

				if (strcasecmp(value, ".byt") == 0) {
					AddData(address, size, DATATYPE_BYTE);
				} else if (strcasecmp(value, ".wrd") == 0) {
					AddData(address, size, DATATYPE_HALFWORD);
				} else if (strcasecmp(value, ".dbl") == 0) {
					AddData(address, size, DATATYPE_WORD);
				} else if (strcasecmp(value, ".asc") == 0) {
					AddData(address, size, DATATYPE_ASCII);
				}
			}
		} else {				// labels
			int size = 1;
			char* seperator = strchr(value,',');
			if (seperator != NULL) {
				*seperator = 0;
				sscanf(seperator+1,"%08X",&size);
			}

			if (size != 1) {
				AddFunction(value,address,size);
			} else {
				AddLabel(value,address);
			}
		}
	}

	fclose(f);
	return true;
}
示例#21
0
int plugin_init_xmms(void)
{
    hash_create(&xmms);

    /* register xmms info */
    AddFunction("xmms", 1, my_xmms);

    return 0;
}
示例#22
0
int plugin_init_python(void)
{
    if (!Py_IsInitialized()) {
        Py_Initialize();
        python_cleanup_responsibility = 1;
    }
    AddFunction("python::exec", 3, my_exec);
    return 0;
}
示例#23
0
CNssCreature::CNssCreature(void) {
	AddFunction("SETCREATURESIZE", L_CAST(&CNssCreature::SetCreatureSize));
	AddFunction("GETEQUIPPEDWEIGHT", L_CAST(&CNssCreature::GetEquippedWeight));
	AddFunction("SETGOLD", L_CAST(&CNssCreature::SetGold));
	AddFunction("SETSOUNDSETID", L_CAST(&CNssCreature::SetSoundSetID));
	AddFunction("GETSOUNDSETID", L_CAST(&CNssCreature::GetSoundSetID));
	AddFunction("JUMPTOLIMBO", L_CAST(&CNssCreature::JumpToLimbo));
	AddFunction("SUMMONASSOCIATE", L_CAST(&CNssCreature::SummonAssociate)); //not implemented in nwnx_funcs.nss yet
	AddFunction("GETATTACKMODIFIERVERSUS", L_CAST(&CNssCreature::GetAttackModifierVs));

}
示例#24
0
/* MUST NOT be declared 'static'! */
int plugin_init_raspi(void)
{
    /* Check if raspi plugin section exists in config file */
    if (cfg_number(Section, "enabled", 0, 0, 1, &plugin_enabled) < 1) {
	plugin_enabled = 0;
    }

    /* Disable plugin unless it is explicitly enabled */
    if (plugin_enabled != 1) {
	info("[raspi] WARNING: Plugin is not enabled! (set 'enabled 1' to enable this plugin)");
	return 0;
    }

    char checkFile[128];

    snprintf(checkFile, sizeof(checkFile), "%s%s", RASPI_TEMP_PATH, RASPI_TEMP_IDFILE);
    if (strncmp(readStr(checkFile), RASPI_TEMP_ID, strlen(RASPI_TEMP_ID)) != 0) {
	error("Warning: no raspberry pi thermal sensor found: value of '%s' is '%s', should be '%s'",
	      checkFile, readStr(checkFile), RASPI_TEMP_IDFILE);
    }

    snprintf(checkFile, sizeof(checkFile), "%s%s", RASPI_TEMP_PATH, RASPI_TEMP_VALUE);
    if (0 == access(checkFile, R_OK)) {
	AddFunction("raspi::cputemp", 0, my_cputemp);
    } else {
	error("Error: File '%s' not readable, no temperature sensor found", checkFile);
    }

    snprintf(checkFile, sizeof(checkFile), "%s%s", RASPI_FREQ_PATH, RASPI_FREQ_IDFILE);
    if (strncmp(readStr(checkFile), RASPI_FREQ_ID, strlen(RASPI_FREQ_ID)) != 0) {
	error("Warning: no raspberry pi frequence sensor found: value of '%s' is '%s', should be '%s'",
	      checkFile, readStr(checkFile), RASPI_FREQ_IDFILE);
    }

    snprintf(checkFile, sizeof(checkFile), "%s%s", RASPI_FREQ_PATH, RASPI_FREQ_VALUE);
    if (0 == access(checkFile, R_OK)) {
	AddFunction("raspi::cpufreq", 0, my_cpufreq);
    } else {
	error("Error: File '%s' not readable, no frequency sensor found", checkFile);
    }

    return 0;
}
void
SCPlotDirector::AddFunction
	(
	const JFunction&	f,
	const JCharacter*	name,
	const JFloat		xMin,
	const JFloat		xMax
	)
{
	AddFunction(f.Copy(), name, xMin, xMax);
}
示例#26
0
BOOL
CED6AsDecompiler::
AddFunction(
    ULONG               Offset,
    ULONG               RefCount            /* = 1 */,
    ULONG               InstructionIndex    /* = 0 */,
    ED6_AS_CRAFT_INFO  *pCraftInfo          /* = NULL */
)
{
    ED6_INSTRUCTION_RECORD Function = { Offset, RefCount, InstructionIndex, pCraftInfo };
    return AddFunction(Function);
}
示例#27
0
void AddRNOVELTYPLUS() {

  ALGORITHM *pCurAlg;

  pCurAlg = AddAlg("rnovelty+","",0,
    "WALKSAT-RNOVELTY+: Hoos [AAAI 99]",
    "Defaults,PickRNOVELTYPLUS,FlipFalseInfo");
    
  CopyParameters(pCurAlg,"novelty+","",0);

  AddFunction("PickRNOVELTYPLUS",ChooseCandidate,PickRNOVELTYPLUS,"FalseInfo,VarLastChange","");

}
示例#28
0
void AddWALKSATTABU() {

  ALGORITHM *pCurAlg;

  pCurAlg = AddAlg("walksat-tabu","",0,
    "WALKSAT-TABU: McAllester, Selmen, Kautz [AAAI 97]",
    "Defaults,PickWALKSATTABU,FlipFalseInfo");
  
  AddParmInt(&pCurAlg->parmList,"-tabu","tabu tenure","variables flipped within the last N steps are tabu","",&iTabuTenure,10);

  AddFunction("PickWALKSATTABU",ChooseCandidate,PickWALKSATTABU,"FalseInfo,VarLastChange","");
  
}
示例#29
0
void AddGWSAT() {

  ALGORITHM *pCurAlg;

  pCurAlg = AddAlg("gwsat","",0,
    "GWSAT: Selmen, Kautz, Cohen [AAAI 94]",
    "Defaults,PickGWSAT,FlipMakeBreakVarInFalse");

  AddParmRatio(&pCurAlg->parmList,"-wp","walk probability","Choose random variable from an unsat clause with prob N/[M]","",&iWpNum,&iWpDen,50,100);

  AddFunction("PickGWSAT",ChooseCandidate,PickGWSAT,"MakeBreak,CandidateInfo,VarInFalseClause","");

}
示例#30
0
int drv_generic_gpio_init(const char *section, const char *driver)
{
    WIDGET_CLASS wc;

    Section = (char *) section;
    Driver = (char *) driver;

    info("%s: using %d GPI's and %d GPO's", Driver, GPIS, GPOS);

    /* reset all GPO's */
    drv_generic_gpio_clear();

    /* register gpo widget */
    wc = Widget_GPO;
    wc.draw = drv_generic_gpio_draw;
    widget_register(&wc);

    /* register plugins */
    AddFunction("LCD::GPI", 1, drv_generic_gpio_plugin_gpi);
    AddFunction("LCD::GPO", -1, drv_generic_gpio_plugin_gpo);

    return 0;
}