Esempio n. 1
0
EPtr Rewriter::rewrite_pair(EPtr pair, Creator &creator) {
	if (pair) {
		EPtr new_car = rewrite(EPtr(Pair::car(pair), creator.collector()), creator);
		EPtr new_cdr = rewrite(EPtr(Pair::cdr(pair), creator.collector()), creator);
		if (Pair::car(pair) != new_car || Pair::cdr(pair) != new_cdr) {
			return creator.new_pair(new_car, new_cdr);
		}
	}
	return pair;
}
Esempio n. 2
0
EPtr Rewriter::rewrite_dictionary(EPtr dictionary, Creator &creator) {
	Dictionary *old_dict = dictionary->as_dictionary();
	bool was_modified = false;
	Dictionary *parent = old_dict->parent();
	if (parent) {
		Dictionary *new_parent = Element::as_dictionary(rewrite_dictionary(EPtr(parent, creator.collector()), creator));
		if (new_parent != parent) {
			parent = new_parent;
			was_modified = true;
		}
	}
	EPtr new_dict = creator.new_dictionary(parent);
	auto cur = old_dict->begin();
	auto end = old_dict->end();
	for (; cur != end; ++cur) {
		EPtr old_value = EPtr(cur->second, creator.collector());
		EPtr new_value = rewrite(old_value, creator);
		if (!was_modified && old_value != new_value) {
			was_modified = true;
		}
		new_dict->as_dictionary()->put(cur->first, new_value);
	}
	return was_modified ? new_dict : dictionary;
}
/// <summary>
/// Vibrates the device for the specified milliseconds.
/// </summary>
/// <param name="milliseconds">The length to vibrate the device in milliseconds.</param>
/// <returns>int.</returns>
int Vibrate::vibrate(int milliseconds) {
	EPtr eptrs[] = { EPtr(MS, milliseconds) };
	return writeAll(SERVICE_VIBRATE, eptrs, 1);
}
Esempio n. 4
0
EPtr FunctionList::apply_evaled(EPtr arguments, State &state) {
	return EPtr(arguments, state.collector());
}
/// <summary>
/// Captures a picture and optionally saves/sends it to the specified URL.
/// </summary>
/// <param name="url">The URL.</param>
/// <returns>int.</returns>
int Camera::capture(String url)
{
	EPtr eptrs[] = { EPtr(url ? MemPtr : None, URL, url.c_str()) };
	return shield.block(writeAll(SERVICE_CAMERA, eptrs, 1), onEvent == 0);
}
/// <summary>
/// Enables the camera preview.
/// </summary>
/// <param name="enable">true to enable, false to disable.</param>
/// <returns>int.</returns>
int Camera::enablePreview(bool enable)
{
	EPtr eptrs[] = { EPtr(ACTION, enable ? ENABLE : DISABLE), EPtr(MESSAGE, PREVIEW) };
	return writeAll(SERVICE_CAMERA, eptrs, 2);
}