本文整理汇总了C++中JSValue::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ JSValue::toString方法的具体用法?C++ JSValue::toString怎么用?C++ JSValue::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSValue
的用法示例。
在下文中一共展示了JSValue::toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: append
JSValue JSDOMFormData::append(ExecState* exec)
{
if (exec->argumentCount() >= 2) {
String name = exec->argument(0).toString(exec)->value(exec);
JSValue value = exec->argument(1);
if (value.inherits(&JSBlob::s_info)) {
String filename;
if (exec->argumentCount() >= 3 && !exec->argument(2).isUndefinedOrNull())
filename = exec->argument(2).toString(exec)->value(exec);
impl()->append(name, toBlob(value), filename);
} else
impl()->append(name, value.toString(exec)->value(exec));
}
return jsUndefined();
}
示例2: setPort
void JSLocation::setPort(ExecState* exec, JSValue value)
{
Frame* frame = impl()->frame();
ASSERT(frame);
KURL url = frame->loader()->url();
// FIXME: Could make this a little less ugly if String provided a toUnsignedShort function.
const UString& portString = value.toString(exec);
int port = charactersToInt(portString.data(), portString.size());
if (port < 0 || port > 0xFFFF)
url.removePort();
else
url.setPort(port);
navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false);
}
示例3: JSValueToStringCopy
EXPORT
JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception)
{
JSLock lock;
JSValue* jsValue = toJS(value);
ExecState* exec = toJS(ctx);
JSStringRef stringRef = toRef(jsValue->toString(exec).rep()->ref());
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
exec->clearException();
stringRef = 0;
}
return stringRef;
}
示例4: adoptPtr
PassOwnPtr<ScheduledAction> ScheduledAction::create(ExecState* exec, DOMWrapperWorld* isolatedWorld, ContentSecurityPolicy* policy)
{
JSValue v = exec->argument(0);
CallData callData;
if (getCallData(v, callData) == CallTypeNone) {
RefPtr<ScriptCallStack> callStack(createScriptCallStackForInspector(exec));
if (policy && !policy->allowEval(callStack.release()))
return nullptr;
String string = v.toString(exec)->value(exec);
if (exec->hadException())
return nullptr;
return adoptPtr(new ScheduledAction(string, isolatedWorld));
}
return adoptPtr(new ScheduledAction(exec, v, isolatedWorld));
}
示例5: setHash
void JSLocation::setHash(ExecState* exec, JSValue value)
{
Frame* frame = impl()->frame();
ASSERT(frame);
KURL url = frame->loader()->url();
String oldFragmentIdentifier = url.fragmentIdentifier();
String str = value.toString(exec);
if (str.startsWith("#"))
str = str.substring(1);
if (equalIgnoringNullity(oldFragmentIdentifier, str))
return;
url.setFragmentIdentifier(str);
navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false);
}
示例6: JSValueToStringCopy
JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception)
{
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
JSValue jsValue = toJS(exec, value);
RefPtr<OpaqueJSString> stringRef(OpaqueJSString::create(jsValue.toString(exec)->value(exec)));
if (exec->hadException()) {
if (exception)
*exception = toRef(exec, exec->exception());
exec->clearException();
stringRef.clear();
}
return stringRef.release().leakRef();
}
示例7: setJSAudioNodeChannelInterpretation
void setJSAudioNodeChannelInterpretation(ExecState* exec, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
JSValue value = JSValue::decode(encodedValue);
UNUSED_PARAM(exec);
JSAudioNode* castedThis = jsDynamicCast<JSAudioNode*>(JSValue::decode(thisValue));
if (!castedThis) {
throwVMTypeError(exec);
return;
}
AudioNode& impl = castedThis->impl();
ExceptionCode ec = 0;
const String& nativeValue(value.isEmpty() ? String() : value.toString(exec)->value(exec));
if (exec->hadException())
return;
impl.setChannelInterpretation(nativeValue, ec);
setDOMException(exec, ec);
}
示例8: toFlags
inline RegExpFlags toFlags(ExecState* exec, JSValue flags)
{
if (flags.isUndefined())
return NoFlags;
JSString* flagsString = flags.toString(exec);
if (!flagsString) {
ASSERT(exec->hadException());
return InvalidFlags;
}
RegExpFlags result = regExpFlags(flagsString->value(exec));
if (exec->hadException())
return InvalidFlags;
if (result == InvalidFlags)
throwSyntaxError(exec, ASCIILiteral("Invalid flags supplied to RegExp constructor."));
return result;
}
示例9: setLocation
void JSDocument::setLocation(ExecState* exec, JSValue value)
{
Frame* frame = static_cast<Document*>(impl())->frame();
if (!frame)
return;
String str = value.toString(exec);
// IE and Mozilla both resolve the URL relative to the source frame,
// not the target frame.
Frame* activeFrame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame();
if (activeFrame)
str = activeFrame->document()->completeURL(str).string();
bool userGesture = activeFrame->script()->processingUserGesture(currentWorld(exec));
frame->redirectScheduler()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !activeFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture);
}
示例10: convertValue
void JSDictionary::convertValue(ExecState* exec, JSValue value, Vector<String>& result)
{
if (value.isUndefinedOrNull())
return;
unsigned length = 0;
JSObject* object = toJSSequence(exec, value, length);
if (exec->hadException())
return;
for (unsigned i = 0 ; i < length; ++i) {
JSValue itemValue = object->get(exec, i);
if (exec->hadException())
return;
result.append(itemValue.toString(exec)->value(exec));
}
}
示例11: JSValueToStringCopy
JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception)
{
ExecState* exec = toJS(ctx);
exec->globalData().heap.registerThread();
JSLock lock(exec);
JSValue jsValue = toJS(exec, value);
RefPtr<OpaqueJSString> stringRef(OpaqueJSString::create(jsValue.toString(exec)));
if (exec->hadException()) {
if (exception)
*exception = toRef(exec, exec->exception());
exec->clearException();
stringRef.clear();
}
return stringRef.release().releaseRef();
}
示例12: setJSTestTypedefsStringAttrWithSetterException
void setJSTestTypedefsStringAttrWithSetterException(ExecState* exec, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
JSValue value = JSValue::decode(encodedValue);
UNUSED_PARAM(exec);
JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
if (!castedThis) {
throwVMTypeError(exec);
return;
}
TestTypedefs& impl = castedThis->impl();
ExceptionCode ec = 0;
const String& nativeValue(value.isEmpty() ? String() : value.toString(exec)->value(exec));
if (exec->hadException())
return;
impl.setStringAttrWithSetterException(nativeValue, ec);
setDOMException(exec, ec);
}
示例13: setJSTestNondeterministicNondeterministicSetterExceptionAttr
bool setJSTestNondeterministicNondeterministicSetterExceptionAttr(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
JSValue value = JSValue::decode(encodedValue);
UNUSED_PARAM(thisValue);
JSTestNondeterministic* castedThis = jsDynamicCast<JSTestNondeterministic*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, "TestNondeterministic", "nondeterministicSetterExceptionAttr");
}
auto& impl = castedThis->wrapped();
ExceptionCode ec = 0;
String nativeValue = value.toString(state)->value(state);
if (UNLIKELY(state->hadException()))
return false;
impl.setNondeterministicSetterExceptionAttr(nativeValue, ec);
setDOMException(state, ec);
return true;
}
示例14:
Stringifier::Stringifier(ExecState* exec, const Local<Unknown>& replacer, const Local<Unknown>& space)
: m_exec(exec)
, m_replacer(replacer)
, m_usingArrayReplacer(false)
, m_arrayReplacerPropertyNames(exec)
, m_replacerCallType(CallTypeNone)
, m_gap(gap(exec, space.get()))
{
if (!m_replacer.isObject())
return;
if (m_replacer.asObject()->inherits(&JSArray::s_info)) {
m_usingArrayReplacer = true;
Handle<JSObject> array = m_replacer.asObject();
unsigned length = array->get(exec, exec->globalData().propertyNames->length).toUInt32(exec);
for (unsigned i = 0; i < length; ++i) {
JSValue name = array->get(exec, i);
if (exec->hadException())
break;
UString propertyName;
if (name.getString(exec, propertyName)) {
m_arrayReplacerPropertyNames.add(Identifier(exec, propertyName));
continue;
}
double value = 0;
if (name.getNumber(value)) {
m_arrayReplacerPropertyNames.add(Identifier::from(exec, value));
continue;
}
if (name.isObject()) {
if (!asObject(name)->inherits(&NumberObject::s_info) && !asObject(name)->inherits(&StringObject::s_info))
continue;
propertyName = name.toString(exec);
if (exec->hadException())
break;
m_arrayReplacerPropertyNames.add(Identifier(exec, propertyName));
}
}
return;
}
m_replacerCallType = m_replacer.asObject()->getCallData(m_replacerCallData);
}
示例15: convertJSValueToNPVariant
void NPRuntimeObjectMap::convertJSValueToNPVariant(ExecState* exec, JSValue value, NPVariant& variant)
{
JSLock lock(SilenceAssertionsOnly);
VOID_TO_NPVARIANT(variant);
if (value.isNull()) {
NULL_TO_NPVARIANT(variant);
return;
}
if (value.isUndefined()) {
VOID_TO_NPVARIANT(variant);
return;
}
if (value.isBoolean()) {
BOOLEAN_TO_NPVARIANT(value.toBoolean(exec), variant);
return;
}
if (value.isNumber()) {
DOUBLE_TO_NPVARIANT(value.toNumber(exec), variant);
return;
}
if (value.isString()) {
CString utf8String = value.toString(exec).utf8();
// This should use NPN_MemAlloc, but we know that it uses malloc under the hood.
char* utf8Characters = static_cast<char*>(malloc(utf8String.length()));
memcpy(utf8Characters, utf8String.data(), utf8String.length());
STRINGN_TO_NPVARIANT(utf8Characters, utf8String.length(), variant);
return;
}
if (value.isObject()) {
NPObject* npObject = getOrCreateNPObject(asObject(value));
OBJECT_TO_NPVARIANT(npObject, variant);
return;
}
ASSERT_NOT_REACHED();
}