示例#1
0
bool operator<(const SortElem &o1, const SortElem &o2)
{
	PHP_VALUE_NODE result;

	value_value_assign(&SortElem::callback->params[0].si_var->var->value, &o1.obj->value);
	value_value_assign(&SortElem::callback->params[1].si_var->var->value, &o2.obj->value);

	switch_push_scope_table((PHP_SCOPE_TABLE_TYPE *)SortElem::callback->scope);

	//
	// params passed by-value, all & notations ignored
	//
	result.type = PHP_VAL_NONE;
	php_execute(SortElem::callback->code, &result);
	cast_value_dnum(&result);
	//
	// restore stack, free arg list
	//
	switch_pop_scope_table(0);

	value_value_free(&SortElem::callback->params[0].si_var->var->value);
	value_value_free(&SortElem::callback->params[1].si_var->var->value);

	return result.int_val != 0;
}
示例#2
0
void set_array_int_val(PHP_VALUE_NODE *array, std::string arrkey, int value)
{
	PHP_VAR_NODE *key = array_get_by_str_key(array, arrkey);
	PHP_VALUE_NODE intval;
	intval.type = PHP_VAL_INT;
	intval.int_val = value;
	value_value_assign(&key->value, &intval);
}
示例#3
0
void load_session_vars(const char *target, std::map<std::string, std::string> &varmap)
{
	PHP_EXP_NODE *sess_vars_exp_node = get_var_node(target);
	PHP_VAR_NODE *sess_vars = sess_vars_exp_node->var_si_node->var;
	// i'm not building exp tree, node not needed
	delete sess_vars_exp_node;
	cast_value_array(&sess_vars->value);
	for(std::map<std::string, std::string>::iterator i = varmap.begin(); i != varmap.end(); i++) {
		PHP_VAR_NODE *curr_var = array_get_by_str_key(&sess_vars->value, i->first);
		PHP_VALUE_NODE val;
		val.type = PHP_VAL_STRING;
		val.str_val = const_cast<char *>(i->second.c_str());
		value_value_assign(&curr_var->value, &val);
	}
}