Ejemplo n.º 1
0
nsDiskCacheBinding *
nsDiskCacheBindery::CreateBinding(nsCacheEntry *       entry,
                                  nsDiskCacheRecord *  record)
{
    NS_ASSERTION(initialized, "nsDiskCacheBindery not initialized");
    nsCOMPtr<nsISupports> data = entry->Data();
    if (data) {
        NS_ERROR("cache entry already has bind data");
        return nsnull;
    }
    
    nsDiskCacheBinding * binding = new nsDiskCacheBinding(entry, record);
    if (!binding)  return nsnull;
        
    // give ownership of the binding to the entry
    entry->SetData(binding);
    
    // add binding to collision detection system
    nsresult rv = AddBinding(binding);
    if (NS_FAILED(rv)) {
        entry->SetData(nsnull);
        return nsnull;
    }

    return binding;
}
void
JFSBindingList::SetCommand
	(
	const JCharacter*				pattern,
	const JCharacter*				cmd,
	const JFSBinding::CommandType	type,
	const JBoolean					singleFile
	)
{
	JFSBinding* b = new JFSBinding(pattern, cmd, type, singleFile, kJFalse);
	assert( b != NULL );

	JIndex index;
	if (itsBindingList->SearchSorted(b, JOrderedSetT::kLastMatch, &index) &&
		!(itsBindingList->NthElement(index))->IsSystemBinding())
		{
		delete b;
		b = itsBindingList->NthElement(index);
		b->SetCommand(cmd, type, singleFile);
		}
	else
		{
		AddBinding(b);
		}
}
JBoolean
JFSBindingList::SetSingleFile
	(
	const JIndex	index,
	const JBoolean	singleFile
	)
{
	JFSBinding* b = itsBindingList->NthElement(index);
	if (b->IsSingleFileCommand() == singleFile)
		{
		return kJFalse;
		}

	if (b->IsSystemBinding())
		{
		JFSBinding::CommandType type;
		JBoolean origSingle;
		const JString pattern = b->GetPattern();					// in case b is deleted
		const JString cmd     = b->GetCommand(&type, &origSingle);	// in case b is deleted
		AddBinding(pattern, cmd, type, singleFile);					// move b to itsOverriddenList
		}
	else
		{
		b->SetSingleFileCommand(singleFile);
		}

	return kJTrue;
}
		void Synchronize(Command *serverVariable, Command *clientVariable)
		{
			if (serverVariable->Type != clientVariable->Type)
				throw std::runtime_error("Server and client variable types do not match");
			SynchronizationBinding binding;
			binding.ServerVariable = serverVariable;
			binding.ClientVariable = clientVariable;
			binding.ID = GenerateID(binding);
			binding.SynchronizedPeers.reset();
			AddBinding(binding);
		}
Ejemplo n.º 5
0
void DefineDefaultBinding(SourceLoc *loc, int pname, int aname, int count, float *fval)
{
    BindingTree *lTree;

    lTree = LookupBinding(pname, aname);
    if (lTree) {
        SemanticError(loc, ERROR_SSSD_DUPLICATE_BINDING,
            GetAtomString(atable, pname), GetAtomString(atable, aname),
            GetAtomString(atable, lTree->loc.file), lTree->loc.line);
        return;
    }
    lTree = NewConstDefaultBindingTree(loc, BK_DEFAULT, pname, aname, count, fval);
    AddBinding(lTree);
} // DefineDefaultBinding
Ejemplo n.º 6
0
void DefineTexunitBinding(SourceLoc *loc, int pname, int aname, int unitno)
{
    BindingTree *lTree;

    lTree = LookupBinding(pname, aname);
    if (lTree) {
        SemanticError(loc, ERROR_SSSD_DUPLICATE_BINDING,
            GetAtomString(atable, pname), GetAtomString(atable, aname),
            GetAtomString(atable, lTree->loc.file), lTree->loc.line);
        return;
    }
    lTree = NewTexunitBindingTree(loc, pname, aname, unitno);
    AddBinding(lTree);
} // DefineTexunitBinding
Ejemplo n.º 7
0
void DefineConnectorBinding(SourceLoc *loc, int cname, int mname, int rname)
{
    BindingTree *lTree;

    lTree = LookupBinding(cname, mname);
    if (lTree) {
        SemanticError(loc, ERROR_SSSD_DUPLICATE_BINDING,
            GetAtomString(atable, cname), GetAtomString(atable, mname),
            GetAtomString(atable, lTree->loc.file), lTree->loc.line);
        return;
    }
    lTree = NewConnectorBindingTree(loc, cname, mname, rname);
    AddBinding(lTree);
} // DefineConnectorBinding
JIndex
JFSBindingList::AddBinding
	(
	const JCharacter*				pattern,
	const JCharacter*				cmd,
	const JFSBinding::CommandType	type,
	const JBoolean					singleFile,
	const JBoolean					isSystem
	)
{
	JFSBinding* b = new JFSBinding(pattern, cmd, type, singleFile, isSystem);
	assert( b != NULL );
	return AddBinding(b);
}
Ejemplo n.º 9
0
void DefineRegArrayBinding(SourceLoc *loc, int pname, int aname, int rname, int index,
                           int count)
{
    BindingTree *lTree;

    lTree = LookupBinding(pname, aname);
    if (lTree) {
        SemanticError(loc, ERROR_SSSD_DUPLICATE_BINDING,
            GetAtomString(atable, pname), GetAtomString(atable, aname),
            GetAtomString(atable, lTree->loc.file), lTree->loc.line);
        return;
    }
    lTree = NewRegArrayBindingTree(loc, pname, aname, rname, index, count);
    AddBinding(lTree);
} // DefineRegArrayBinding
JBoolean
JFSBindingList::SetPattern
	(
	const JIndex		index,
	const JCharacter*	pattern,
	JIndex*				newIndex
	)
{
	*newIndex = index;

	JFSBinding* b = itsBindingList->NthElement(index);
	if (b->GetPattern() == pattern)
		{
		return kJTrue;
		}

	JFSBinding temp(pattern, "", JFSBinding::kRunPlain, kJFalse, kJFalse);
	JIndex fIndex;
	if (itsBindingList->SearchSorted(&temp, JOrderedSetT::kAnyMatch, &fIndex))
		{
		return kJFalse;
		}

	if (b->IsSystemBinding())
		{
		JFSBinding::CommandType type;
		JBoolean singleFile;
		const JString cmd = b->GetCommand(&type, &singleFile);	// in case b is deleted
		AddBinding(pattern, cmd, type, singleFile);				// move b to itsOverriddenList
		b = &temp;
		}
	else
		{
		b->SetPattern(pattern);
		itsBindingList->Sort();
		}

	const JBoolean found =
		itsBindingList->SearchSorted(b, JOrderedSetT::kAnyMatch, newIndex);
	assert( found );

	return kJTrue;
}
Ejemplo n.º 11
0
 void onAddBindingButton(wxCommandEvent& event) {
     AddBinding(KeyList, selectedActivationKey());
     onKeyListSelChange(event);
 }
Ejemplo n.º 12
0
int menu_binding(
	Display *dpy, binding_t type, int button, KeySym keysym,
	int context, int modifier, char *action, char *menu_style)
{
	Binding *rmlist;
	int rc;
	Bool dummy;

	if (menu_bindings == NULL)
	{
		menu_bindings = &menu_bindings_fallback;
	}
	rmlist = NULL;
	if (~(~context | C_MENU | C_TITLE | C_MENU_ITEM | C_SIDEBAR) != 0)
	{
		mvwm_msg(
			ERR, "menu_binding",
			"invalid context in combination with menu context.");

		return 1;
	}
	if (menu_style != NULL)
	{
		/*!!! fixme - make either match a menu style or a menu name */
		mvwm_msg(
			ERR, "menu_binding", "a window name may not be"
			" specified without a menu context.");

		return 1;
	}
	/*
	 * Remove the "old" bindings if any
	 */
	/* BEGIN remove */
	CollectBindingList(
		dpy, menu_bindings, &rmlist, &dummy, type,
		button, keysym, modifier, context, menu_style);
	if (rmlist != NULL)
	{
		FreeBindingList(rmlist);
	}
	else if (
		keysym == 0 && button != 0 && modifier == 0 &&
		strcmp(action,"-") == 0 && context == C_MENU)
	{
		/* Warn if Mouse n M N - occurs without removing any binding.
		 The user most likely want Mouse n MT A - instead. */
		mvwm_msg(
			WARN, "menu_binding",
			"The syntax for disabling the tear off button has "
			"changed.");
	}
	if (strcmp(action,"-") == 0)
	{
		return 0;
	}
	/* END remove */
	if ((modifier & AnyModifier) && (modifier & (~AnyModifier)))
	{
		mvwm_msg(
			WARN, "menu_binding", "Binding specified AnyModifier"
			" and other modifers too. Excess modifiers are"
			" ignored.");
		modifier = AnyModifier;
	}
	/* Warn about Mouse n M N TearOff. */
	if (
		keysym == 0 && button != 0 && modifier == 0 &&
		strcasecmp(action,"tearoff") == 0 && context == C_MENU)
	{
		mvwm_msg(OLD, "menu_binding",
			 "The syntax for disabling the tear off button has "
			 "changed. The TearOff action is no longer possible "
			 "in menu bindings.");
	}
	rc = AddBinding(
		dpy, menu_bindings, type, button, keysym,
		NULL, modifier, context, (void *)action, NULL, menu_style);

	return rc;
}