static void hrefByteStringAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) { v8::Handle<v8::Object> holder = info.Holder(); ExceptionState exceptionState(ExceptionState::SetterContext, "hrefByteString", "TestNode", holder, info.GetIsolate()); TestNode* impl = V8TestNode::toImpl(holder); TONATIVE_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, toByteString(v8Value, exceptionState), exceptionState); impl->setHrefByteString(cppValue); }
static void hrefByteStringAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Local<v8::Object> holder = info.Holder(); ExceptionState exceptionState(ExceptionState::SetterContext, "hrefByteString", "TestNode", holder, info.GetIsolate()); TestNode* impl = V8TestNode::toImpl(holder); V8StringResource<> cppValue = toByteString(info.GetIsolate(), v8Value, exceptionState); if (exceptionState.throwIfNeeded()) return; impl->setHrefByteString(cppValue); }
std::string CborValue::inspect() const { if( isNull() ) { static std::string null = "(null)"; return null; } else if( isUndefined() ) { static std::string undefined = "(undefined)"; return undefined; } else if( isBool() ) { return boost::lexical_cast<std::string>(toBool()); } else if( isPositiveInteger() ) { return boost::lexical_cast<std::string>(toPositiveInteger()); } else if( isNegativeInteger() ) { std::string result = "-"; const char specialValue[] = "18446744073709551616"; // 0x10000000000000000 uint64_t value = toNegativeInteger(); if( value == 0 ) result += specialValue; else result += boost::lexical_cast<std::string>(value); return result; } else if( isDouble() ) { return boost::lexical_cast<std::string>(toDouble()); } else if( isString() ) { return toString(); } else if( isByteString() ) { std::vector<char> byteString = toByteString(); std::string result = "(0x"; static const char hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; for(size_t i = 0; i < byteString.size(); ++i) { unsigned char c = static_cast<unsigned char>(byteString[i]); result += hex[c / sizeof(hex)]; result += hex[c % sizeof(hex)]; } result += ')'; return result; } else if( isArray() ) { std::vector<CborValue> values = toArray(); std::string result = "["; if( values.empty() == false ) { for(size_t i = 0; i < values.size(); ++i) { result += values[i].inspect(); result += ", "; } result.resize(result.size() - 1); result[result.size() - 1] = ']'; } else { result += ']'; } return result; } else if( isMap() ) { std::map<CborValue, CborValue> values = toMap(); std::string result = "{"; if( values.empty() == false ) { std::map<CborValue, CborValue>::iterator it = values.begin(); std::map<CborValue, CborValue>::iterator end = values.end(); for(; it != end; ++it) { result += it->first.inspect(); result += ": "; result += it->second.inspect(); result += ", "; } result.resize(result.size() - 1); result[result.size() - 1] = '}'; } else { result += '}'; } return result; } else if( isBigInteger() ) { BigInteger bigInteger = toBigInteger(); std::string result; if( bigInteger.positive ) result = "(big integer: 0x"; else result = "(negative big integer: 0x"; static const char hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; if( bigInteger.bigint.empty() == false ) { for(size_t i = 0; i < bigInteger.bigint.size(); ++i) { unsigned char c = static_cast<unsigned char >(bigInteger.bigint[i]); result += hex[c / sizeof(hex)]; result += hex[c % sizeof(hex)]; } result.resize(result.size() - 1); result[result.size() - 1] = ')'; } else { result += ')'; } return result; } assert(false); std::string invalidType = "(invalid type)"; return invalidType; }