зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1449861 - Add codegen support for UTF8String. r=bzbarsky
Differential Revision: https://phabricator.services.mozilla.com/D58629 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
b58f2e72e8
Коммит
6bb42bfdf8
|
@ -251,7 +251,7 @@ inline void AssignFromStringBuffer(nsStringBuffer* buffer, size_t len,
|
|||
buffer->ToString(len, dest);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename T, typename std::enable_if_t<std::is_same<typename T::char_type, char16_t>::value>* = nullptr>
|
||||
inline bool AssignJSString(JSContext* cx, T& dest, JSString* s) {
|
||||
size_t len = JS::GetStringLength(s);
|
||||
static_assert(js::MaxStringLength < (1 << 30),
|
||||
|
@ -284,6 +284,49 @@ inline bool AssignJSString(JSContext* cx, T& dest, JSString* s) {
|
|||
return js::CopyStringChars(cx, dest.BeginWriting(), s, len);
|
||||
}
|
||||
|
||||
// Specialization for UTF8String.
|
||||
template <typename T, typename std::enable_if_t<std::is_same<typename T::char_type, char>::value>* = nullptr>
|
||||
inline bool AssignJSString(JSContext* cx, T& dest, JSString* s) {
|
||||
using namespace mozilla;
|
||||
CheckedInt<size_t> bufLen(JS::GetStringLength(s));
|
||||
// From the contract for JS_EncodeStringToUTF8BufferPartial, to guarantee that
|
||||
// the whole string is converted.
|
||||
if (js::StringHasLatin1Chars(s)) {
|
||||
bufLen *= 2;
|
||||
} else {
|
||||
bufLen *= 3;
|
||||
}
|
||||
|
||||
if (MOZ_UNLIKELY(!bufLen.isValid())) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Shouldn't really matter, but worth being safe.
|
||||
const bool kAllowShrinking = true;
|
||||
|
||||
nsresult rv;
|
||||
auto handle = dest.BulkWrite(bufLen.value(), 0, kAllowShrinking, rv);
|
||||
if (MOZ_UNLIKELY(NS_FAILED(rv))) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto maybe = JS_EncodeStringToUTF8BufferPartial(cx, s, handle.AsSpan());
|
||||
if (MOZ_UNLIKELY(!maybe)) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t read;
|
||||
size_t written;
|
||||
Tie(read, written) = *maybe;
|
||||
|
||||
MOZ_ASSERT(read == JS::GetStringLength(s));
|
||||
handle.Finish(written, kAllowShrinking);
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void AssignJSLinearString(nsAString& dest, JSLinearString* s) {
|
||||
size_t len = js::GetLinearStringLength(s);
|
||||
static_assert(js::MaxStringLength < (1 << 30),
|
||||
|
|
|
@ -315,6 +315,30 @@ class Optional<nsAString> {
|
|||
const nsAString* mStr;
|
||||
};
|
||||
|
||||
template <>
|
||||
class Optional<nsACString> {
|
||||
public:
|
||||
Optional() : mStr(nullptr) {}
|
||||
|
||||
bool WasPassed() const { return !!mStr; }
|
||||
|
||||
void operator=(const nsACString* str) {
|
||||
MOZ_ASSERT(str);
|
||||
mStr = str;
|
||||
}
|
||||
const nsACString& Value() const {
|
||||
MOZ_ASSERT(WasPassed());
|
||||
return *mStr;
|
||||
}
|
||||
|
||||
private:
|
||||
// Forbid copy-construction and assignment
|
||||
Optional(const Optional& other) = delete;
|
||||
const Optional& operator=(const Optional& other) = delete;
|
||||
|
||||
const nsACString* mStr;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline void ImplCycleCollectionUnlink(Optional<T>& aField) {
|
||||
if (aField.WasPassed()) {
|
||||
|
|
|
@ -2530,9 +2530,9 @@ bool NonVoidByteStringToJsval(JSContext* cx, const nsACString& str,
|
|||
JS::MutableHandle<JS::Value> rval) {
|
||||
// ByteStrings are not UTF-8 encoded.
|
||||
JSString* jsStr = JS_NewStringCopyN(cx, str.Data(), str.Length());
|
||||
|
||||
if (!jsStr) return false;
|
||||
|
||||
if (!jsStr) {
|
||||
return false;
|
||||
}
|
||||
rval.setString(jsStr);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -2500,6 +2500,29 @@ inline bool ByteStringToJsval(JSContext* cx, const nsACString& str,
|
|||
return NonVoidByteStringToJsval(cx, str, rval);
|
||||
}
|
||||
|
||||
// Convert an utf-8 encoded nsCString to jsval, returning true on success.
|
||||
//
|
||||
// TODO(bug 1606957): This could probably be better.
|
||||
inline bool NonVoidUTF8StringToJsval(JSContext* cx, const nsACString& str,
|
||||
JS::MutableHandle<JS::Value> rval) {
|
||||
JSString* jsStr =
|
||||
JS_NewStringCopyUTF8N(cx, {str.BeginReading(), str.Length()});
|
||||
if (!jsStr) {
|
||||
return false;
|
||||
}
|
||||
rval.setString(jsStr);
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool UTF8StringToJsval(JSContext* cx, const nsACString& str,
|
||||
JS::MutableHandle<JS::Value> rval) {
|
||||
if (str.IsVoid()) {
|
||||
rval.setNull();
|
||||
return true;
|
||||
}
|
||||
return NonVoidUTF8StringToJsval(cx, str, rval);
|
||||
}
|
||||
|
||||
template <class T, bool isISupports = IsBaseOf<nsISupports, T>::value>
|
||||
struct PreserveWrapperHelper {
|
||||
static void PreserveWrapper(T* aObject) {
|
||||
|
|
|
@ -4607,12 +4607,13 @@ def handleDefaultStringValue(defaultValue, method):
|
|||
"""
|
||||
assert (defaultValue.type.isDOMString() or
|
||||
defaultValue.type.isUSVString() or
|
||||
defaultValue.type.isUTF8String() or
|
||||
defaultValue.type.isByteString())
|
||||
# There shouldn't be any non-ASCII or embedded nulls in here; if
|
||||
# it ever sneaks in we will need to think about how to properly
|
||||
# represent that in the C++.
|
||||
assert(all(ord(c) < 128 and ord(c) > 0 for c in defaultValue.value))
|
||||
if defaultValue.type.isByteString():
|
||||
if defaultValue.type.isByteString() or defaultValue.type.isUTF8String():
|
||||
prefix = ""
|
||||
else:
|
||||
prefix = "u"
|
||||
|
@ -4627,7 +4628,7 @@ def handleDefaultStringValue(defaultValue, method):
|
|||
|
||||
def recordKeyType(recordType):
|
||||
assert recordType.keyType.isString()
|
||||
if recordType.keyType.isByteString():
|
||||
if recordType.keyType.isByteString() or recordType.keyType.isUTF8String():
|
||||
return "nsCString"
|
||||
return "nsString"
|
||||
|
||||
|
@ -5099,9 +5100,13 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
|||
keyType = recordKeyType(recordType)
|
||||
if recordType.keyType.isJSString():
|
||||
raise TypeError("Have do deal with JSString record type, but don't know how")
|
||||
elif recordType.keyType.isByteString():
|
||||
keyConversionFunction = "ConvertJSValueToByteString"
|
||||
if recordType.keyType.isByteString() or recordType.keyType.isUTF8String():
|
||||
hashKeyType = "nsCStringHashKey"
|
||||
if recordType.keyType.isByteString():
|
||||
keyConversionFunction = "ConvertJSValueToByteString"
|
||||
else:
|
||||
keyConversionFunction = "ConvertJSValueToString"
|
||||
|
||||
else:
|
||||
hashKeyType = "nsStringHashKey"
|
||||
if recordType.keyType.isDOMString():
|
||||
|
@ -5936,7 +5941,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
|||
declType=CGGeneric(declType),
|
||||
declArgs=declArgs)
|
||||
|
||||
if type.isDOMString() or type.isUSVString():
|
||||
if type.isDOMString() or type.isUSVString() or type.isUTF8String():
|
||||
assert not isEnforceRange and not isClamp
|
||||
|
||||
treatAs = {
|
||||
|
@ -5995,21 +6000,33 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
|||
return handleDefault(conversionCode, defaultCode)
|
||||
|
||||
if isMember:
|
||||
# Convert directly into the nsString member we have.
|
||||
declType = CGGeneric("nsString")
|
||||
# Convert directly into the ns[C]String member we have.
|
||||
if type.isUTF8String():
|
||||
declType = "nsCString"
|
||||
else:
|
||||
declType = "nsString"
|
||||
return JSToNativeConversionInfo(
|
||||
getConversionCode("${declName}"),
|
||||
declType=declType,
|
||||
declType=CGGeneric(declType),
|
||||
dealWithOptional=isOptional)
|
||||
|
||||
if isOptional:
|
||||
declType = "Optional<nsAString>"
|
||||
holderType = CGGeneric("binding_detail::FakeString")
|
||||
if type.isUTF8String():
|
||||
declType = "Optional<nsACString>"
|
||||
holderType = CGGeneric("nsAutoCString")
|
||||
else:
|
||||
declType = "Optional<nsAString>"
|
||||
holderType = CGGeneric("binding_detail::FakeString")
|
||||
conversionCode = ("%s"
|
||||
"${declName} = &${holderName};\n" %
|
||||
getConversionCode("${holderName}"))
|
||||
else:
|
||||
declType = "binding_detail::FakeString"
|
||||
if type.isUTF8String():
|
||||
# TODO(emilio, bug 1606958): We could make FakeString generic
|
||||
# if we deem it worth it, instead of using nsAutoCString.
|
||||
declType = "nsAutoCString"
|
||||
else:
|
||||
declType = "binding_detail::FakeString"
|
||||
holderType = None
|
||||
conversionCode = getConversionCode("${declName}")
|
||||
|
||||
|
@ -6935,6 +6952,11 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
|
|||
# assert anything about the input being ASCII.
|
||||
expandedKeyDecl = "NS_ConvertASCIItoUTF16 expandedKey(entry.mKey);\n"
|
||||
keyName = "expandedKey"
|
||||
elif type.keyType.isUTF8String():
|
||||
# We do the same as above for utf8 strings. We could do better if
|
||||
# we had a DefineProperty API that takes utf-8 property names.
|
||||
expandedKeyDecl = "NS_ConvertUTF8toUTF16 expandedKey(entry.mKey);\n"
|
||||
keyName = "expandedKey"
|
||||
else:
|
||||
expandedKeyDecl = ""
|
||||
keyName = "entry.mKey"
|
||||
|
@ -7049,6 +7071,12 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
|
|||
else:
|
||||
return (wrapAndSetPtr("NonVoidByteStringToJsval(cx, %s, ${jsvalHandle})" % result), False)
|
||||
|
||||
if type.isUTF8String():
|
||||
if type.nullable():
|
||||
return (wrapAndSetPtr("UTF8StringToJsval(cx, %s, ${jsvalHandle})" % result), False)
|
||||
else:
|
||||
return (wrapAndSetPtr("NonVoidUTF8StringToJsval(cx, %s, ${jsvalHandle})" % result), False)
|
||||
|
||||
if type.isEnum():
|
||||
if type.nullable():
|
||||
resultLoc = "%s.Value()" % result
|
||||
|
@ -7322,7 +7350,7 @@ def getRetvalDeclarationForType(returnType, descriptorProvider,
|
|||
if isMember:
|
||||
return CGGeneric("nsString"), "ref", None, None, None
|
||||
return CGGeneric("DOMString"), "ref", None, None, None
|
||||
if returnType.isByteString():
|
||||
if returnType.isByteString() or returnType.isUTF8String():
|
||||
return CGGeneric("nsCString"), "ref", None, None, None
|
||||
if returnType.isEnum():
|
||||
result = CGGeneric(returnType.unroll().inner.identifier.name)
|
||||
|
@ -10316,7 +10344,7 @@ def getUnionAccessorSignatureType(type, descriptorProvider):
|
|||
if type.isDOMString() or type.isUSVString():
|
||||
return CGGeneric("const nsAString&")
|
||||
|
||||
if type.isByteString():
|
||||
if type.isByteString() or type.isUTF8String():
|
||||
return CGGeneric("const nsCString&")
|
||||
|
||||
if type.isEnum():
|
||||
|
@ -10559,7 +10587,7 @@ class CGUnionStruct(CGThing):
|
|||
if vars["setter"]:
|
||||
methods.append(vars["setter"])
|
||||
# Provide a SetStringLiteral() method to support string defaults.
|
||||
if t.isByteString():
|
||||
if t.isByteString() or t.isUTF8String():
|
||||
charType = "const nsCString::char_type"
|
||||
elif t.isString():
|
||||
charType = "const nsString::char_type"
|
||||
|
@ -10835,7 +10863,7 @@ class CGUnionConversionStruct(CGThing):
|
|||
body=body,
|
||||
visibility="private"))
|
||||
# Provide a SetStringLiteral() method to support string defaults.
|
||||
if t.isByteString():
|
||||
if t.isByteString() or t.isUTF8String():
|
||||
charType = "const nsCString::char_type"
|
||||
elif t.isString():
|
||||
charType = "const nsString::char_type"
|
||||
|
@ -15439,7 +15467,7 @@ class CGNativeMember(ClassMethod):
|
|||
return "nsString", None, None
|
||||
# Outparam
|
||||
return "void", "", "aRetVal = ${declName};\n"
|
||||
if type.isByteString():
|
||||
if type.isByteString() or type.isUTF8String():
|
||||
if isMember:
|
||||
# No need for a third element in the isMember case
|
||||
return "nsCString", None, None
|
||||
|
@ -15560,7 +15588,7 @@ class CGNativeMember(ClassMethod):
|
|||
args.append(Argument("JS::MutableHandle<JSString*>", "aRetVal"))
|
||||
elif returnType.isDOMString() or returnType.isUSVString():
|
||||
args.append(Argument("nsString&", "aRetVal"))
|
||||
elif returnType.isByteString():
|
||||
elif returnType.isByteString() or returnType.isUTF8String():
|
||||
args.append(Argument("nsCString&", "aRetVal"))
|
||||
elif returnType.isSequence():
|
||||
nullable = returnType.nullable()
|
||||
|
@ -15721,8 +15749,13 @@ class CGNativeMember(ClassMethod):
|
|||
declType = "nsAString"
|
||||
return declType, True, False
|
||||
|
||||
if type.isByteString():
|
||||
declType = "nsCString"
|
||||
if type.isByteString() or type.isUTF8String():
|
||||
# TODO(emilio): Maybe bytestrings could benefit from nsAutoCString
|
||||
# or such too.
|
||||
if type.isUTF8String() and not isMember:
|
||||
declType = "nsACString"
|
||||
else:
|
||||
declType = "nsCString"
|
||||
return declType, True, False
|
||||
|
||||
if type.isEnum():
|
||||
|
@ -18643,7 +18676,7 @@ class CGEventGetter(CGNativeMember):
|
|||
if type.isJSString():
|
||||
# https://bugzilla.mozilla.org/show_bug.cgi?id=1580167
|
||||
raise TypeError("JSString not supported as member of a generated event")
|
||||
if type.isDOMString() or type.isByteString() or type.isUSVString():
|
||||
if type.isDOMString() or type.isByteString() or type.isUSVString() or type.isUTF8String():
|
||||
return "aRetVal = " + memberName + ";\n"
|
||||
if type.isSpiderMonkeyInterface() or type.isObject():
|
||||
return fill(
|
||||
|
@ -19092,7 +19125,7 @@ class CGEventClass(CGBindingImplClass):
|
|||
nativeType = CGGeneric("JS::Heap<JSString*>")
|
||||
elif type.isDOMString() or type.isUSVString():
|
||||
nativeType = CGGeneric("nsString")
|
||||
elif type.isByteString():
|
||||
elif type.isByteString() or type.isUTF8String():
|
||||
nativeType = CGGeneric("nsCString")
|
||||
elif type.isPromise():
|
||||
nativeType = CGGeneric("RefPtr<Promise>")
|
||||
|
@ -19120,7 +19153,8 @@ class CGEventClass(CGBindingImplClass):
|
|||
innerType = type.inner
|
||||
if (not innerType.isPrimitive() and not innerType.isEnum() and
|
||||
not innerType.isDOMString() and not innerType.isByteString() and
|
||||
not innerType.isPromise() and not innerType.isGeckoInterface()):
|
||||
not innerType.isUTF8String() and not innerType.isPromise() and
|
||||
not innerType.isGeckoInterface()):
|
||||
raise TypeError("Don't know how to properly manage GC/CC for "
|
||||
"event member of type %s" %
|
||||
type)
|
||||
|
|
|
@ -23,6 +23,8 @@ namespace binding_detail {
|
|||
// or point at the buffer of an nsAString whose lifetime is longer than that of
|
||||
// the FakeString.
|
||||
struct FakeString {
|
||||
using char_type = nsString::char_type;
|
||||
|
||||
FakeString()
|
||||
: mDataFlags(nsString::DataFlags::TERMINATED),
|
||||
mClassFlags(nsString::ClassFlags(0)) {}
|
||||
|
@ -57,7 +59,7 @@ struct FakeString {
|
|||
mDataFlags |= nsString::DataFlags::VOIDED;
|
||||
}
|
||||
|
||||
nsString::char_type* BeginWriting() {
|
||||
char_type* BeginWriting() {
|
||||
MOZ_ASSERT(IsMutable());
|
||||
MOZ_ASSERT(mDataInitialized);
|
||||
return mData;
|
||||
|
@ -65,12 +67,12 @@ struct FakeString {
|
|||
|
||||
nsString::size_type Length() const { return mLength; }
|
||||
|
||||
operator mozilla::Span<const nsString::char_type>() const {
|
||||
operator mozilla::Span<const char_type>() const {
|
||||
MOZ_ASSERT(mDataInitialized);
|
||||
return mozilla::MakeSpan(mData, Length());
|
||||
}
|
||||
|
||||
operator mozilla::Span<nsString::char_type>() {
|
||||
operator mozilla::Span<char_type>() {
|
||||
return mozilla::MakeSpan(BeginWriting(), Length());
|
||||
}
|
||||
|
||||
|
@ -82,7 +84,7 @@ struct FakeString {
|
|||
mDataFlags |= nsString::DataFlags::INLINE;
|
||||
} else {
|
||||
RefPtr<nsStringBuffer> buf =
|
||||
nsStringBuffer::Alloc((aLength + 1) * sizeof(nsString::char_type));
|
||||
nsStringBuffer::Alloc((aLength + 1) * sizeof(char_type));
|
||||
if (MOZ_UNLIKELY(!buf)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -109,7 +111,7 @@ struct FakeString {
|
|||
buffer = dont_AddRef(nsStringBuffer::FromData(mData));
|
||||
// And make sure we don't release it twice by accident.
|
||||
}
|
||||
const nsString::char_type* oldChars = mData;
|
||||
const char_type* oldChars = mData;
|
||||
|
||||
mDataFlags = nsString::DataFlags::TERMINATED;
|
||||
#ifdef DEBUG
|
||||
|
@ -126,14 +128,13 @@ struct FakeString {
|
|||
}
|
||||
MOZ_ASSERT(oldChars != mData, "Should have new chars now!");
|
||||
MOZ_ASSERT(IsMutable(), "Why are we still not mutable?");
|
||||
memcpy(mData, oldChars, Length() * sizeof(nsString::char_type));
|
||||
memcpy(mData, oldChars, Length() * sizeof(char_type));
|
||||
return true;
|
||||
}
|
||||
|
||||
void AssignFromStringBuffer(already_AddRefed<nsStringBuffer> aBuffer,
|
||||
size_t aLength) {
|
||||
InitData(static_cast<nsString::char_type*>(aBuffer.take()->Data()),
|
||||
aLength);
|
||||
InitData(static_cast<char_type*>(aBuffer.take()->Data()), aLength);
|
||||
mDataFlags |= nsString::DataFlags::REFCOUNTED;
|
||||
}
|
||||
|
||||
|
@ -141,14 +142,14 @@ struct FakeString {
|
|||
// called with actual C++ literal strings (i.e. u"stuff") or character arrays
|
||||
// that originally come from passing such literal strings.
|
||||
template <int N>
|
||||
void AssignLiteral(const nsString::char_type (&aData)[N]) {
|
||||
void AssignLiteral(const char_type (&aData)[N]) {
|
||||
AssignLiteral(aData, N - 1);
|
||||
}
|
||||
|
||||
// Assign a literal to a FakeString when it's not an actual literal
|
||||
// in the code, but is known to be a literal somehow (e.g. it came
|
||||
// from an nsAString that tested true for IsLiteral()).
|
||||
void AssignLiteral(const nsString::char_type* aData, size_t aLength) {
|
||||
void AssignLiteral(const char_type* aData, size_t aLength) {
|
||||
InitData(aData, aLength);
|
||||
mDataFlags |= nsString::DataFlags::LITERAL;
|
||||
}
|
||||
|
@ -167,14 +168,14 @@ struct FakeString {
|
|||
nsAString* ToAStringPtr() { return reinterpret_cast<nsString*>(this); }
|
||||
|
||||
// mData is left uninitialized for optimization purposes.
|
||||
MOZ_INIT_OUTSIDE_CTOR nsString::char_type* mData;
|
||||
MOZ_INIT_OUTSIDE_CTOR char_type* mData;
|
||||
// mLength is left uninitialized for optimization purposes.
|
||||
MOZ_INIT_OUTSIDE_CTOR nsString::size_type mLength;
|
||||
nsString::DataFlags mDataFlags;
|
||||
nsString::ClassFlags mClassFlags;
|
||||
|
||||
static const size_t sInlineCapacity = 64;
|
||||
nsString::char_type mInlineStorage[sInlineCapacity];
|
||||
char_type mInlineStorage[sInlineCapacity];
|
||||
#ifdef DEBUG
|
||||
bool mDataInitialized = false;
|
||||
#endif // DEBUG
|
||||
|
@ -182,10 +183,10 @@ struct FakeString {
|
|||
FakeString(const FakeString& other) = delete;
|
||||
void operator=(const FakeString& other) = delete;
|
||||
|
||||
void InitData(const nsString::char_type* aData, nsString::size_type aLength) {
|
||||
void InitData(const char_type* aData, nsString::size_type aLength) {
|
||||
MOZ_ASSERT(mDataFlags == nsString::DataFlags::TERMINATED);
|
||||
MOZ_ASSERT(!mDataInitialized);
|
||||
mData = const_cast<nsString::char_type*>(aData);
|
||||
mData = const_cast<char_type*>(aData);
|
||||
mLength = aLength;
|
||||
#ifdef DEBUG
|
||||
mDataInitialized = true;
|
||||
|
|
|
@ -411,6 +411,9 @@ class TestInterface : public nsISupports, public nsWrapperCache {
|
|||
void ReceiveByteStringSequence(nsTArray<nsCString>&);
|
||||
void PassByteStringSequence(const Sequence<nsCString>&);
|
||||
|
||||
void ReceiveUTF8StringSequence(nsTArray<nsCString>&);
|
||||
void PassUTF8StringSequence(const Sequence<nsCString>&);
|
||||
|
||||
void ReceiveAnySequence(JSContext*, nsTArray<JS::Value>&);
|
||||
void ReceiveNullableAnySequence(JSContext*, Nullable<nsTArray<JS::Value>>&);
|
||||
void ReceiveAnySequenceSequence(JSContext*, nsTArray<nsTArray<JS::Value>>&);
|
||||
|
@ -454,6 +457,7 @@ class TestInterface : public nsISupports, public nsWrapperCache {
|
|||
const Record<nsString, RefPtr<TestExternalInterface>>&);
|
||||
void PassStringRecord(const Record<nsString, nsString>&);
|
||||
void PassByteStringRecord(const Record<nsString, nsCString>&);
|
||||
void PassUTF8StringRecord(const Record<nsString, nsCString>&);
|
||||
void PassRecordOfRecords(const Record<nsString, Record<nsString, int32_t>>&);
|
||||
void ReceiveRecord(Record<nsString, int32_t>&);
|
||||
void ReceiveNullableRecord(Nullable<Record<nsString, int32_t>>&);
|
||||
|
@ -513,6 +517,17 @@ class TestInterface : public nsISupports, public nsWrapperCache {
|
|||
void PassOptionalUnionByteString(const Optional<ByteStringOrLong>&);
|
||||
void PassOptionalUnionByteStringWithDefaultValue(const ByteStringOrLong&);
|
||||
|
||||
// UTF8String types
|
||||
void PassUTF8String(const nsACString&);
|
||||
void PassNullableUTF8String(const nsACString&);
|
||||
void PassOptionalUTF8String(const Optional<nsACString>&);
|
||||
void PassOptionalUTF8StringWithDefaultValue(const nsACString&);
|
||||
void PassOptionalNullableUTF8String(const Optional<nsACString>&);
|
||||
void PassOptionalNullableUTF8StringWithDefaultValue(const nsACString&);
|
||||
void PassVariadicUTF8String(const Sequence<nsCString>&);
|
||||
void PassOptionalUnionUTF8String(const Optional<UTF8StringOrLong>&);
|
||||
void PassOptionalUnionUTF8StringWithDefaultValue(const UTF8StringOrLong&);
|
||||
|
||||
// USVString types
|
||||
void PassUSVS(const nsAString&);
|
||||
void PassNullableUSVS(const nsAString&);
|
||||
|
@ -704,6 +719,7 @@ class TestInterface : public nsISupports, public nsWrapperCache {
|
|||
void PassUnion28(const EventInitOrStringSequence&);
|
||||
void PassUnionWithCallback(const EventHandlerNonNullOrNullOrLong& arg);
|
||||
void PassUnionWithByteString(const ByteStringOrLong&);
|
||||
void PassUnionWithUTF8String(const UTF8StringOrLong&);
|
||||
void PassUnionWithRecord(const StringStringRecordOrString&);
|
||||
void PassUnionWithRecordAndSequence(
|
||||
const StringStringRecordOrStringSequence&);
|
||||
|
@ -748,6 +764,9 @@ class TestInterface : public nsISupports, public nsWrapperCache {
|
|||
void PassUnionWithDefaultValue20(const DoubleOrUSVString& arg);
|
||||
void PassUnionWithDefaultValue21(const DoubleOrUSVString& arg);
|
||||
void PassUnionWithDefaultValue22(const DoubleOrUSVString& arg);
|
||||
void PassUnionWithDefaultValue23(const DoubleOrUTF8String& arg);
|
||||
void PassUnionWithDefaultValue24(const DoubleOrUTF8String& arg);
|
||||
void PassUnionWithDefaultValue25(const DoubleOrUTF8String& arg);
|
||||
|
||||
void PassNullableUnionWithDefaultValue1(const Nullable<DoubleOrString>& arg);
|
||||
void PassNullableUnionWithDefaultValue2(const Nullable<DoubleOrString>& arg);
|
||||
|
@ -791,6 +810,14 @@ class TestInterface : public nsISupports, public nsWrapperCache {
|
|||
const Nullable<DoubleOrUSVString>& arg);
|
||||
void PassNullableUnionWithDefaultValue24(
|
||||
const Nullable<DoubleOrUSVString>& arg);
|
||||
void PassNullableUnionWithDefaultValue25(
|
||||
const Nullable<DoubleOrUTF8String>& arg);
|
||||
void PassNullableUnionWithDefaultValue26(
|
||||
const Nullable<DoubleOrUTF8String>& arg);
|
||||
void PassNullableUnionWithDefaultValue27(
|
||||
const Nullable<DoubleOrUTF8String>& arg);
|
||||
void PassNullableUnionWithDefaultValue28(
|
||||
const Nullable<DoubleOrUTF8String>& arg);
|
||||
|
||||
void PassSequenceOfUnions(
|
||||
const Sequence<OwningCanvasPatternOrCanvasGradient>&);
|
||||
|
@ -1226,6 +1253,15 @@ class TestInterface : public nsISupports, public nsWrapperCache {
|
|||
void PassOptionalNullableByteStringWithDefaultValue(nsCString&) = delete;
|
||||
void PassVariadicByteString(Sequence<nsCString>&) = delete;
|
||||
|
||||
// cstrings should be const as well
|
||||
void PassUTF8String(nsACString&) = delete;
|
||||
void PassNullableUTF8String(nsACString&) = delete;
|
||||
void PassOptionalUTF8String(Optional<nsACString>&) = delete;
|
||||
void PassOptionalUTF8StringWithDefaultValue(nsACString&) = delete;
|
||||
void PassOptionalNullableUTF8String(Optional<nsACString>&) = delete;
|
||||
void PassOptionalNullableUTF8StringWithDefaultValue(nsACString&) = delete;
|
||||
void PassVariadicUTF8String(Sequence<nsCString>&) = delete;
|
||||
|
||||
// Make sure dictionary arguments are always const
|
||||
void PassDictionary(JSContext*, Dict&) = delete;
|
||||
void PassOtherDictionary(GrandparentDict&) = delete;
|
||||
|
|
|
@ -407,6 +407,9 @@ interface TestInterface {
|
|||
sequence<ByteString> receiveByteStringSequence();
|
||||
void passByteStringSequence(sequence<ByteString> arg);
|
||||
|
||||
sequence<UTF8String> receiveUTF8StringSequence();
|
||||
void passUTF8StringSequence(sequence<UTF8String> arg);
|
||||
|
||||
sequence<any> receiveAnySequence();
|
||||
sequence<any>? receiveNullableAnySequence();
|
||||
sequence<sequence<any>> receiveAnySequenceSequence();
|
||||
|
@ -437,6 +440,7 @@ interface TestInterface {
|
|||
void passNullableExternalInterfaceRecord(record<DOMString, TestExternalInterface?> arg);
|
||||
void passStringRecord(record<DOMString, DOMString> arg);
|
||||
void passByteStringRecord(record<DOMString, ByteString> arg);
|
||||
void passUTF8StringRecord(record<DOMString, UTF8String> arg);
|
||||
void passRecordOfRecords(record<DOMString, record<DOMString, long>> arg);
|
||||
record<DOMString, long> receiveRecord();
|
||||
record<DOMString, long>? receiveNullableRecord();
|
||||
|
@ -491,6 +495,17 @@ interface TestInterface {
|
|||
void passOptionalUnionByteString(optional (ByteString or long) arg);
|
||||
void passOptionalUnionByteStringWithDefaultValue(optional (ByteString or long) arg = "abc");
|
||||
|
||||
// UTF8String types
|
||||
void passUTF8String(UTF8String arg);
|
||||
void passNullableUTF8String(UTF8String? arg);
|
||||
void passOptionalUTF8String(optional UTF8String arg);
|
||||
void passOptionalUTF8StringWithDefaultValue(optional UTF8String arg = "abc");
|
||||
void passOptionalNullableUTF8String(optional UTF8String? arg);
|
||||
void passOptionalNullableUTF8StringWithDefaultValue(optional UTF8String? arg = null);
|
||||
void passVariadicUTF8String(UTF8String... arg);
|
||||
void passOptionalUnionUTF8String(optional (UTF8String or long) arg);
|
||||
void passOptionalUnionUTF8StringWithDefaultValue(optional (UTF8String or long) arg = "abc");
|
||||
|
||||
// USVString types
|
||||
void passUSVS(USVString arg);
|
||||
void passNullableUSVS(USVString? arg);
|
||||
|
@ -664,6 +679,7 @@ interface TestInterface {
|
|||
void passUnion28(optional (EventInit or sequence<DOMString>) arg = {});
|
||||
void passUnionWithCallback((EventHandler or long) arg);
|
||||
void passUnionWithByteString((ByteString or long) arg);
|
||||
void passUnionWithUTF8String((UTF8String or long) arg);
|
||||
void passUnionWithRecord((record<DOMString, DOMString> or DOMString) arg);
|
||||
void passUnionWithRecordAndSequence((record<DOMString, DOMString> or sequence<DOMString>) arg);
|
||||
void passUnionWithSequenceAndRecord((sequence<DOMString> or record<DOMString, DOMString>) arg);
|
||||
|
@ -713,6 +729,9 @@ interface TestInterface {
|
|||
void passUnionWithDefaultValue20(optional (double or USVString) arg = "abc");
|
||||
void passUnionWithDefaultValue21(optional (double or USVString) arg = 1);
|
||||
void passUnionWithDefaultValue22(optional (double or USVString) arg = 1.5);
|
||||
void passUnionWithDefaultValue23(optional (double or UTF8String) arg = "");
|
||||
void passUnionWithDefaultValue24(optional (double or UTF8String) arg = 1);
|
||||
void passUnionWithDefaultValue25(optional (double or UTF8String) arg = 1.5);
|
||||
|
||||
void passNullableUnionWithDefaultValue1(optional (double or DOMString)? arg = "");
|
||||
void passNullableUnionWithDefaultValue2(optional (double or DOMString)? arg = 1);
|
||||
|
@ -739,6 +758,11 @@ interface TestInterface {
|
|||
void passNullableUnionWithDefaultValue23(optional (double or USVString)? arg = 1.5);
|
||||
void passNullableUnionWithDefaultValue24(optional (double or USVString)? arg = null);
|
||||
|
||||
void passNullableUnionWithDefaultValue25(optional (double or UTF8String)? arg = "abc");
|
||||
void passNullableUnionWithDefaultValue26(optional (double or UTF8String)? arg = 1);
|
||||
void passNullableUnionWithDefaultValue27(optional (double or UTF8String)? arg = 1.5);
|
||||
void passNullableUnionWithDefaultValue28(optional (double or UTF8String)? arg = null);
|
||||
|
||||
void passSequenceOfUnions(sequence<(CanvasPattern or CanvasGradient)> arg);
|
||||
void passSequenceOfUnions2(sequence<(object or long)> arg);
|
||||
void passVariadicUnion((CanvasPattern or CanvasGradient)... arg);
|
||||
|
@ -1143,9 +1167,12 @@ dictionary Dict : ParentDict {
|
|||
record<USVString, long>? nullableUSVStringRecordWithDefault = null;
|
||||
record<ByteString, long> byteStringRecord;
|
||||
record<ByteString, long>? nullableByteStringRecordWithDefault = null;
|
||||
record<UTF8String, long> utf8StringRecord;
|
||||
record<UTF8String, long>? nullableUTF8StringRecordWithDefault = null;
|
||||
required record<DOMString, TestInterface> requiredRecord;
|
||||
required record<USVString, TestInterface> requiredUSVRecord;
|
||||
required record<ByteString, TestInterface> requiredByteRecord;
|
||||
required record<UTF8String, TestInterface> requiredUTF8Record;
|
||||
};
|
||||
|
||||
dictionary ParentDict : GrandparentDict {
|
||||
|
|
|
@ -249,6 +249,9 @@ interface TestExampleInterface {
|
|||
sequence<ByteString> receiveByteStringSequence();
|
||||
void passByteStringSequence(sequence<ByteString> arg);
|
||||
|
||||
sequence<UTF8String> receiveUTF8StringSequence();
|
||||
void passUTF8StringSequence(sequence<UTF8String> arg);
|
||||
|
||||
sequence<any> receiveAnySequence();
|
||||
sequence<any>? receiveNullableAnySequence();
|
||||
//XXXbz No support for sequence of sequence return values yet.
|
||||
|
@ -280,6 +283,7 @@ interface TestExampleInterface {
|
|||
void passNullableExternalInterfaceRecord(record<DOMString, TestExternalInterface?> arg);
|
||||
void passStringRecord(record<DOMString, DOMString> arg);
|
||||
void passByteStringRecord(record<DOMString, ByteString> arg);
|
||||
void passUTF8StringRecord(record<DOMString, UTF8String> arg);
|
||||
void passRecordOfRecords(record<DOMString, record<DOMString, long>> arg);
|
||||
record<DOMString, long> receiveRecord();
|
||||
record<DOMString, long>? receiveNullableRecord();
|
||||
|
@ -335,6 +339,18 @@ interface TestExampleInterface {
|
|||
void passOptionalUnionByteString(optional (ByteString or long) arg);
|
||||
void passOptionalUnionByteStringWithDefaultValue(optional (ByteString or long) arg = "abc");
|
||||
|
||||
// UTF8String types
|
||||
void passUTF8String(UTF8String arg);
|
||||
void passNullableUTF8String(UTF8String? arg);
|
||||
void passOptionalUTF8String(optional UTF8String arg);
|
||||
void passOptionalUTF8StringWithDefaultValue(optional UTF8String arg = "abc");
|
||||
void passOptionalNullableUTF8String(optional UTF8String? arg);
|
||||
void passOptionalNullableUTF8StringWithDefaultValue(optional UTF8String? arg = null);
|
||||
void passVariadicUTF8String(UTF8String... arg);
|
||||
void passUnionUTF8String((UTF8String or long) arg);
|
||||
void passOptionalUnionUTF8String(optional (UTF8String or long) arg);
|
||||
void passOptionalUnionUTF8StringWithDefaultValue(optional (UTF8String or long) arg = "abc");
|
||||
|
||||
// USVString types
|
||||
void passSVS(USVString arg);
|
||||
void passNullableSVS(USVString? arg);
|
||||
|
@ -467,6 +483,7 @@ interface TestExampleInterface {
|
|||
void passUnion28(optional (EventInit or sequence<DOMString>) arg = {});
|
||||
void passUnionWithCallback((EventHandler or long) arg);
|
||||
void passUnionWithByteString((ByteString or long) arg);
|
||||
void passUnionWithUTF8String((UTF8String or long) arg);
|
||||
void passUnionWithRecord((record<DOMString, DOMString> or DOMString) arg);
|
||||
void passUnionWithRecordAndSequence((record<DOMString, DOMString> or sequence<DOMString>) arg);
|
||||
void passUnionWithSequenceAndRecord((sequence<DOMString> or record<DOMString, DOMString>) arg);
|
||||
|
@ -516,6 +533,9 @@ interface TestExampleInterface {
|
|||
void passUnionWithDefaultValue20(optional (double or USVString) arg = "abc");
|
||||
void passUnionWithDefaultValue21(optional (double or USVString) arg = 1);
|
||||
void passUnionWithDefaultValue22(optional (double or USVString) arg = 1.5);
|
||||
void passUnionWithDefaultValue23(optional (double or UTF8String) arg = "");
|
||||
void passUnionWithDefaultValue24(optional (double or UTF8String) arg = 1);
|
||||
void passUnionWithDefaultValue25(optional (double or UTF8String) arg = 1.5);
|
||||
|
||||
void passNullableUnionWithDefaultValue1(optional (double or DOMString)? arg = "");
|
||||
void passNullableUnionWithDefaultValue2(optional (double or DOMString)? arg = 1);
|
||||
|
@ -541,6 +561,10 @@ interface TestExampleInterface {
|
|||
void passNullableUnionWithDefaultValue22(optional (double or USVString)? arg = 1);
|
||||
void passNullableUnionWithDefaultValue23(optional (double or USVString)? arg = 1.5);
|
||||
void passNullableUnionWithDefaultValue24(optional (double or USVString)? arg = null);
|
||||
void passNullableUnionWithDefaultValue25(optional (double or UTF8String)? arg = "");
|
||||
void passNullableUnionWithDefaultValue26(optional (double or UTF8String)? arg = 1);
|
||||
void passNullableUnionWithDefaultValue27(optional (double or UTF8String)? arg = 1.5);
|
||||
void passNullableUnionWithDefaultValue28(optional (double or UTF8String)? arg = null);
|
||||
|
||||
void passSequenceOfUnions(sequence<(CanvasPattern or CanvasGradient)> arg);
|
||||
void passSequenceOfUnions2(sequence<(object or long)> arg);
|
||||
|
|
|
@ -260,6 +260,7 @@ interface TestJSImplInterface {
|
|||
|
||||
sequence<DOMString> receiveStringSequence();
|
||||
sequence<ByteString> receiveByteStringSequence();
|
||||
sequence<UTF8String> receiveUTF8StringSequence();
|
||||
// Callback interface problem. See bug 843261.
|
||||
//void passStringSequence(sequence<DOMString> arg);
|
||||
sequence<any> receiveAnySequence();
|
||||
|
@ -293,6 +294,7 @@ interface TestJSImplInterface {
|
|||
void passNullableExternalInterfaceRecord(record<DOMString, TestExternalInterface?> arg);
|
||||
void passStringRecord(record<DOMString, DOMString> arg);
|
||||
void passByteStringRecord(record<DOMString, ByteString> arg);
|
||||
void passUTF8StringRecord(record<DOMString, UTF8String> arg);
|
||||
void passRecordOfRecords(record<DOMString, record<DOMString, long>> arg);
|
||||
record<DOMString, long> receiveRecord();
|
||||
record<DOMString, long>? receiveNullableRecord();
|
||||
|
@ -348,6 +350,18 @@ interface TestJSImplInterface {
|
|||
void passOptionalUnionByteString(optional (ByteString or long) arg);
|
||||
void passOptionalUnionByteStringWithDefaultValue(optional (ByteString or long) arg = "abc");
|
||||
|
||||
// UTF8String types
|
||||
void passUTF8String(UTF8String arg);
|
||||
void passNullableUTF8String(UTF8String? arg);
|
||||
void passOptionalUTF8String(optional UTF8String arg);
|
||||
void passOptionalUTF8StringWithDefaultValue(optional UTF8String arg = "abc");
|
||||
void passOptionalNullableUTF8String(optional UTF8String? arg);
|
||||
void passOptionalNullableUTF8StringWithDefaultValue(optional UTF8String? arg = null);
|
||||
void passVariadicUTF8String(UTF8String... arg);
|
||||
void passUnionUTF8String((UTF8String or long) arg);
|
||||
void passOptionalUnionUTF8String(optional (UTF8String or long) arg);
|
||||
void passOptionalUnionUTF8StringWithDefaultValue(optional (UTF8String or long) arg = "abc");
|
||||
|
||||
// USVString types
|
||||
void passSVS(USVString arg);
|
||||
void passNullableSVS(USVString? arg);
|
||||
|
@ -480,6 +494,7 @@ interface TestJSImplInterface {
|
|||
void passUnion28(optional (EventInit or sequence<DOMString>) arg = {});
|
||||
void passUnionWithCallback((EventHandler or long) arg);
|
||||
void passUnionWithByteString((ByteString or long) arg);
|
||||
void passUnionWithUTF8String((UTF8String or long) arg);
|
||||
void passUnionWithRecord((record<DOMString, DOMString> or DOMString) arg);
|
||||
void passUnionWithRecordAndSequence((record<DOMString, DOMString> or sequence<DOMString>) arg);
|
||||
void passUnionWithSequenceAndRecord((sequence<DOMString> or record<DOMString, DOMString>) arg);
|
||||
|
@ -529,6 +544,9 @@ interface TestJSImplInterface {
|
|||
void passUnionWithDefaultValue20(optional (double or USVString) arg = "abc");
|
||||
void passUnionWithDefaultValue21(optional (double or USVString) arg = 1);
|
||||
void passUnionWithDefaultValue22(optional (double or USVString) arg = 1.5);
|
||||
void passUnionWithDefaultValue23(optional (double or UTF8String) arg = "");
|
||||
void passUnionWithDefaultValue24(optional (double or UTF8String) arg = 1);
|
||||
void passUnionWithDefaultValue25(optional (double or UTF8String) arg = 1.5);
|
||||
|
||||
void passNullableUnionWithDefaultValue1(optional (double or DOMString)? arg = "");
|
||||
void passNullableUnionWithDefaultValue2(optional (double or DOMString)? arg = 1);
|
||||
|
@ -554,6 +572,10 @@ interface TestJSImplInterface {
|
|||
void passNullableUnionWithDefaultValue22(optional (double or USVString)? arg = 1);
|
||||
void passNullableUnionWithDefaultValue23(optional (double or USVString)? arg = 1.5);
|
||||
void passNullableUnionWithDefaultValue24(optional (double or USVString)? arg = null);
|
||||
void passNullableUnionWithDefaultValue25(optional (double or UTF8String)? arg = "");
|
||||
void passNullableUnionWithDefaultValue26(optional (double or UTF8String)? arg = 1);
|
||||
void passNullableUnionWithDefaultValue27(optional (double or UTF8String)? arg = 1.5);
|
||||
void passNullableUnionWithDefaultValue28(optional (double or UTF8String)? arg = null);
|
||||
|
||||
void passSequenceOfUnions(sequence<(CanvasPattern or CanvasGradient)> arg);
|
||||
void passSequenceOfUnions2(sequence<(object or long)> arg);
|
||||
|
|
Загрузка…
Ссылка в новой задаче