Esempio n. 1
0
static unsigned char
get_previous_byte (gf_font_t *font)
{
	unsigned char b;

	move_relative (font, -1);
	b = get_byte (font);
	move_relative (font, -1);
	return b;
}
Esempio n. 2
0
static unsigned long
get_previous_four (gf_font_t *font)
{
	unsigned long b;

	move_relative (font, -4);
	b = get_four (font);
	move_relative (font, -4);
	return b;
}
Esempio n. 3
0
/*
 * Skip all specials, leaving the file pointer at the first non-special.
 * We do not save the specials, though.
 */
static void
skip_specials (gf_font_t *font)
{
	for (;;) {
		switch (get_byte (font)) {
		case XXX1:
			move_relative (font, get_byte (font));
			continue;
		case XXX2:
			move_relative (font, get_two (font));
			continue;
		case XXX3:
			move_relative (font, get_three (font));
			continue;
		case YYY:
			(void) get_four (font);
			continue;
		default:
			move_relative (font, -1);
			return;
		}
	}
}
Esempio n. 4
0
// Moves the motor to an absolute step position. This function blocks.
// If the motor was previously off, this function will turn it on.
void Stepper::move_absolute(int step_number)
{
  move_relative(step_number - _count);
  _count = step_number;
}
Esempio n. 5
0
	void param_tree::generate_from_schema(schema::schema_node s, tree_t::node_descriptor node, param_accessor acc, schema::schema_provider_map_handle sch_mp)
	{
/*		if(acc.m_pt == this)
		{
			throw std::runtime_error{ "shouldn't happen!" };
		}
*/
		//acc.set_lock_on_failed_move(true);

		auto name = s["name"].as< std::string >();
/*		if(acc && !acc.move_relative(name)) // todo: Maybe allow to push a non-valid state onto the location stack,
									// so we can put an accessor into invalid state and then revert later
		{
			// This node does not exist in the existing param tree, so for this subtree, use a null param_accessor
			// so that everything will be generated from defaults
			acc = param_accessor{};
		}
*/
		auto type = s["type"].as< ParamType >();

		m_tree[node].type = type;
		m_tree[node].name = name;

		if(is_leaf_type(type))
		{
			// For leaf types, if a node with matching name and type is found in the given accessor, just
			// copy across its value
			if(acc && acc.where().leaf().name() == name && acc.param_here().type == type)
			{
				m_tree[node].value = acc.value_here();
			}
			else
			{
				// Not found, so use default value
				m_tree[node].value = generate_default_terminal(s);
			}
		}
		else switch(type)	// Non-leaf types
		{
			case ParamType::List:
			{
				YAML::Node children = s["children"];
				for(YAML::Node c : children)
				{
					auto child_acc = acc;
					// TODO: This test (and also the one below for repeats) is supposed to ensure that the 
					// accessor is valid for the current location. It's not ideal, since nothing to stop
					// the same name occurring at multiple nodes in the tree.
					if(child_acc && child_acc.where().leaf().name() == name)
					{
						// Attempt to move the accessor to the newly created node.
						// Failure will lock the accessor ensuring that any copies of it in recursive calls
						// will not move it from its current position (which is the position furthest down the
						// existing param tree towards the current node which actually exists).
						child_acc.move_relative(c["name"].as< std::string >());
					}
					auto c_node = m_tree.add_node(node).second;
					generate_from_schema(c, c_node, child_acc, sch_mp);
				}
			}
			break;

			case ParamType::Repeat:
			{
				auto contents_string = s["contents"].as< std::string >();
				m_tree[node].extra = repeat_extra{ contents_string };

				if(acc && acc.where().leaf().name() == name)
				{
					// Maintain any existing instances
					auto existing_instances = acc.children();
					for(auto const& p : existing_instances)
					{
						add_repeat_instance(node, acc, sch_mp);
					}
				}

				// TODO: respect repeat min instance count
			}
			break;
		}
	}