void KPHPArrayObject::AddKrollValueToPHPArray(KValueRef value, zval *phpArray) { if (value->IsNull() || value->IsUndefined()) { add_next_index_null(phpArray); } else if (value->IsBool()) { if (value->ToBool()) add_next_index_bool(phpArray, 1); else add_next_index_bool(phpArray, 0); } else if (value->IsNumber()) { /* No way to check whether the number is an integer or a double here. All Kroll numbers are doubles, so return a double. This could cause some PHP to function incorrectly if it's doing strict type checking. */ add_next_index_double(phpArray, value->ToNumber()); } else if (value->IsString()) { add_next_index_stringl(phpArray, (char *) value->ToString(), strlen(value->ToString()), 1); } else if (value->IsObject()) { /*TODO: Implement*/ } else if (value->IsMethod()) { /*TODO: Implement*/ } else if (value->IsList()) { zval *phpValue; AutoPtr<KPHPArrayObject> pl = value->ToList().cast<KPHPArrayObject>(); if (!pl.isNull()) phpValue = pl->ToPHP(); else phpValue = PHPUtils::ToPHPValue(value); add_next_index_zval(phpArray, phpValue); } }
void PropertiesBinding::GetList(const ValueList& args, KValueRef result) { KValueRef stringValue = Value::Null; GetString(args, stringValue); if (!stringValue->IsNull()) { KListRef list = new StaticBoundList(); std::string string = stringValue->ToString(); Poco::StringTokenizer t(string, ",", Poco::StringTokenizer::TOK_TRIM); for (size_t i = 0; i < t.count(); i++) { KValueRef token = Value::NewString(t[i].c_str()); list->Append(token); } KListRef list2 = list; result->SetList(list2); } }
void convert (Statement &select, KValueRef arg) { if (arg->IsString()) { std::string *s = new std::string(arg->ToString()); select , use(*s); strings.push_back(s); } else if (arg->IsInt()) { int *i = new int(arg->ToInt()); select , use(*i); ints.push_back(i); } else if (arg->IsDouble()) { double *d = new double(arg->ToDouble()); select , use(*d); doubles.push_back(d); } else if (arg->IsBool()) { bool *b = new bool(arg->ToBool()); select , use(*b); bools.push_back(b); } else if (arg->IsNull() || arg->IsUndefined()) { // in this case, we bind a null string (dequoted) std::string *s = new std::string("null"); select , use(s); strings.push_back(s); } else { throw ValueException::FromFormat("Unsupport type for argument: %s", arg->GetType().c_str()); } }