void CL_DomElement::set_child_string_ns(const CL_DomString &namespace_uri, const CL_DomString &qualified_name, const CL_DomString &value)
{
	CL_DomString local_name;
	CL_DomString::size_type pos = qualified_name.find(L':');
	if (pos != CL_DomString::npos)
		local_name = qualified_name.substr(pos+1);
	else
		local_name = qualified_name;

	CL_DomElement element = named_item_ns(namespace_uri, local_name).to_element();
	if (element.is_null())
	{
		element = get_owner_document().create_element_ns(namespace_uri, qualified_name);
		append_child(element);
	}

	CL_DomText dom_text = get_owner_document().create_text_node(value);
	if (element.get_first_child().is_text())
	{
		CL_DomNode temp_domnode = element.get_first_child();
		replace_child(dom_text, temp_domnode);
	}
	else
	{
		element.append_child(dom_text);
	}
}
Exemple #2
0
void replace_node(BST* t, Node* nd, Node* nd_parent) {
  if (nd->left == NULL) {
    replace_child(t, nd_parent, nd, nd->right);
    return;
  }
  if (nd->right == NULL) {
    replace_child(t, nd_parent, nd, nd->left);
    return;
  }

  Node* curr = nd->right;
  Node* curr_parent = nd;
  while (curr->left != NULL) {
    curr_parent = curr;
    curr = curr->left;
  }

  replace_child(t, curr_parent, curr, curr->right);

  curr->left = nd->left;
  curr->right = nd->right;

  replace_child(t, nd_parent, nd, curr);
}
Exemple #3
0
swayc_t *new_container(swayc_t *child, enum swayc_layouts layout) {
	if (!ASSERT_NONNULL(child)) {
		return NULL;
	}
	swayc_t *cont = new_swayc(C_CONTAINER);

	sway_log(L_DEBUG, "creating container %p around %p", cont, child);

	cont->layout = layout;
	cont->width = child->width;
	cont->height = child->height;
	cont->x = child->x;
	cont->y = child->y;
	cont->visible = child->visible;

	/* Container inherits all of workspaces children, layout and whatnot */
	if (child->type == C_WORKSPACE) {
		swayc_t *workspace = child;
		// reorder focus
		cont->focused = workspace->focused;
		workspace->focused = cont;
		// set all children focu to container
		int i;
		for (i = 0; i < workspace->children->length; ++i) {
			((swayc_t *)workspace->children->items[i])->parent = cont;
		}
		// Swap children
		list_t  *tmp_list  = workspace->children;
		workspace->children = cont->children;
		cont->children = tmp_list;
		// add container to workspace chidren
		add_child(workspace, cont);
		// give them proper layouts
		cont->layout = workspace->layout;
		workspace->layout = layout;
		set_focused_container_for(workspace, get_focused_view(workspace));
	} else { // Or is built around container
		swayc_t *parent = replace_child(child, cont);
		if (parent) {
			add_child(cont, child);
		}
	}
	return cont;
}
Exemple #4
0
void qArrayAccess::subupdateType()
{
	neu_type = 0;

	qneu_PointerType * ptype = dynamic_cast<qneu_PointerType*>(L()->neu_type);

	if (!ptype)
	{
		fireError(true, ERROR_TYPE_NO_POINTER, "Type `" + L()->neu_type->name() + "`is not a pointer type");
		return;
	}

	if (!R()->neu_type->is_integer())
	{
		qValue * cc = new qConvert(qneu_PrimitiveType::type_uint32(), R(), "Array index: ");
		replace_child(R(), cc);
	}
	
	neu_type = ptype->base;
}
Exemple #5
0
swayc_t *new_container(swayc_t *child, enum swayc_layouts layout) {
    swayc_t *cont = new_swayc(C_CONTAINER);

    sway_log(L_DEBUG, "creating container %p around %p", cont, child);

    cont->layout = layout;
    cont->width = child->width;
    cont->height = child->height;
    cont->x	= child->x;
    cont->y = child->y;
    cont->visible = child->visible;

    /* Container inherits all of workspaces children, layout and whatnot */
    if (child->type == C_WORKSPACE) {
        swayc_t *workspace = child;
        //reorder focus
        cont->focused = workspace->focused;
        workspace->focused = cont;
        //Swap children
        list_t  *tmp_list  = workspace->children;
        workspace->children = cont->children;
        cont->children = tmp_list;
        //add container to workspace chidren
        add_child(workspace, cont);
        //give them proper layouts
        cont->layout = workspace->layout;
        workspace->layout = layout;
    }
    //Or is built around container
    else {
        swayc_t *parent = replace_child(child, cont);
        if (parent) {
            add_child(cont, child);
        }
    }
    return cont;
}
Exemple #6
0
void ACPI::add_child(const acpi_sdt *replacement, acpi_sdt *const parent, const unsigned ptrsize)
{
	// if insufficient space, replace unimportant tables
	if (slack(parent) < ptrsize) {
		const char *expendable[] = {"FPDT", "EINJ", "TCPA", "BERT", "ERST", "HEST"};
		for (unsigned i = 0; i < (sizeof expendable / sizeof expendable[0]); i++) {
			if (replace_child(expendable[i], replacement, parent, ptrsize)) {
				printf("Replaced %s table\n", expendable[i]);
				return;
			}
		}

		fatal("Out of space when adding entry for ACPI table %s to %s", replacement->sig.s, parent->sig.s);
	}

	assert_checksum(replacement, replacement->len);
	uint64_t newp = 0;
	memcpy(&newp, &replacement, sizeof replacement);
	unsigned i = parent->len - sizeof(*parent);
	memcpy(&parent->data[i], &newp, ptrsize);
	if (memcmp(&parent->data[i], &newp, ptrsize))
		goto again;

	parent->len += ptrsize;
	xassert(parent->len < RSDT_MAX);
	parent->checksum += checksum((const char *)parent, parent->len);
	return;

again:
	if (!bios_shadowed) {
		shadow_bios();
		add_child(replacement, parent, ptrsize);
		return;
	}

	fatal("ACPI tables immutable when adding child at 0x%p", &parent->data[i]);
}
Exemple #7
0
bool ACPI::replace_child(const char *sig, const acpi_sdt *replacement, acpi_sdt *const parent, const unsigned ptrsize)
{
	uint64_t newp = 0, childp;

	assert_checksum(replacement, replacement->len);
	memcpy(&newp, &replacement, sizeof(replacement));
	unsigned i;

	for (i = 0; i + sizeof(*parent) < parent->len; i += ptrsize) {
		childp = 0;
		memcpy(&childp, &parent->data[i], ptrsize);

		if (childp > 0xffffffffULL) {
			printf("Error: Child pointer at %d (%p) outside 32-bit range (0x%" PRIx64 ")",
			       i, &parent->data[i], childp);
			continue;
		}

		acpi_sdt *table;
		memcpy(&table, &childp, sizeof(table));
		assert_checksum(table, table->len);

		// DSDT is special-cased
		if (table->sig.l == STR_DW_H("FACP") && !strncmp(sig, "DSDT", 4)) {
			struct acpi_fadt *fadt = (struct acpi_fadt *)&table->data;
			fadt->Dsdt = (uint32_t)replacement;
			if (ptrsize == 8)
				fadt->X_Dsdt = (uint64_t)replacement;
			table->checksum = 0;
			table->checksum = checksum((const char *)table, table->len);
			return 1;
		}

		if (table->sig.l == STR_DW_H(sig)) {
			memcpy(&parent->data[i], &newp, ptrsize);
			// check if writing succeeded
			if (memcmp(&parent->data[i], &newp, ptrsize))
				goto again;

			parent->checksum += checksum((const char *)parent, parent->len);
			return 1;
		}
	}

	// handled by caller
	if (slack(parent) < ptrsize)
		return 0;

	// append entry to end of table
	memcpy(&parent->data[i], &newp, ptrsize);

	// check if writing succeeded
	if (memcmp(&parent->data[i], &newp, ptrsize))
		goto again;

	parent->len += ptrsize;
	xassert(parent->len < RSDT_MAX);
	parent->checksum += checksum((const char *)parent, parent->len);
	return 1;

again:
	if (!bios_shadowed) {
		shadow_bios();
		return replace_child(sig, replacement, parent, ptrsize);
	}

	fatal("ACPI tables immutable when replacing child at 0x%p", &parent->data[i]);
}