зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1455217 - Part 1: Add an explicit Promise type to xpidl, r=mccr8
This type is fairly simple on the idl parsing side of things. I handle it in the same way that special types such as ns[C]String, nsid, and jsval are handled, by using a special native type. The logic for converting the value between C++ and JS follows the existing logic from the nsISupports <=> JS Promise conversions.
This commit is contained in:
Родитель
e5e1512c1e
Коммит
c9d0fe3dd2
|
@ -17,7 +17,16 @@ typedef int64_t PRTime;
|
|||
*/
|
||||
#include "nsStringFwd.h"
|
||||
|
||||
/*
|
||||
/*
|
||||
* Forward declaration of mozilla::dom::Promise
|
||||
*/
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class Promise;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
/*
|
||||
* Start commenting out the C++ versions of the below in the output header
|
||||
*/
|
||||
#if 0
|
||||
|
@ -88,6 +97,8 @@ typedef unsigned long size_t;
|
|||
[ref, jsval] native jsval(jsval);
|
||||
native jsid(jsid);
|
||||
|
||||
[ptr, promise] native Promise(ignored);
|
||||
|
||||
%{C++
|
||||
/*
|
||||
* End commenting out the C++ versions of the above in the output header
|
||||
|
|
|
@ -45,6 +45,7 @@ TypeMap = {
|
|||
'utf8string': 'TD_UTF8STRING',
|
||||
'cstring': 'TD_CSTRING',
|
||||
'jsval': 'TD_JSVAL',
|
||||
'promise': 'TD_PROMISE',
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -455,8 +455,9 @@ class Native(object):
|
|||
'utf8string': 'nsACString',
|
||||
'cstring': 'nsACString',
|
||||
'astring': 'nsAString',
|
||||
'jsval': 'JS::Value'
|
||||
}
|
||||
'jsval': 'JS::Value',
|
||||
'promise': '::mozilla::dom::Promise',
|
||||
}
|
||||
|
||||
# Mappings from C++ native name types to rust native names. Types which
|
||||
# aren't listed here are incompatible with rust code.
|
||||
|
@ -505,6 +506,9 @@ class Native(object):
|
|||
if self.specialtype is None:
|
||||
return False
|
||||
|
||||
if self.specialtype == 'promise':
|
||||
return self.modifier == 'ptr'
|
||||
|
||||
if self.specialtype == 'nsid':
|
||||
return self.modifier is not None
|
||||
|
||||
|
@ -522,7 +526,7 @@ class Native(object):
|
|||
raise IDLError("[shared] only applies to out parameters.")
|
||||
const = True
|
||||
|
||||
if self.specialtype is not None and calltype == 'in':
|
||||
if self.specialtype not in [None, 'promise'] and calltype == 'in':
|
||||
const = True
|
||||
|
||||
if self.specialtype == 'jsval':
|
||||
|
|
|
@ -134,6 +134,7 @@ struct nsXPTCVariant : public nsXPTCMiniVariant
|
|||
case nsXPTType::T_INTERFACE: /* fall through */
|
||||
case nsXPTType::T_INTERFACE_IS: /* fall through */
|
||||
case nsXPTType::T_DOMOBJECT: /* fall through */
|
||||
case nsXPTType::T_PROMISE: /* fall through */
|
||||
case nsXPTType::T_ARRAY: /* fall through */
|
||||
case nsXPTType::T_PSTRING_SIZE_IS: /* fall through */
|
||||
case nsXPTType::T_PWSTRING_SIZE_IS: /* fall through */
|
||||
|
|
|
@ -190,7 +190,8 @@ enum nsXPTTypeTag : uint8_t
|
|||
TD_CSTRING = 24,
|
||||
TD_ASTRING = 25,
|
||||
TD_JSVAL = 26,
|
||||
TD_DOMOBJECT = 27
|
||||
TD_DOMOBJECT = 27,
|
||||
TD_PROMISE = 28
|
||||
};
|
||||
|
||||
|
||||
|
@ -306,7 +307,8 @@ public:
|
|||
T_CSTRING = TD_CSTRING ,
|
||||
T_ASTRING = TD_ASTRING ,
|
||||
T_JSVAL = TD_JSVAL ,
|
||||
T_DOMOBJECT = TD_DOMOBJECT
|
||||
T_DOMOBJECT = TD_DOMOBJECT ,
|
||||
T_PROMISE = TD_PROMISE
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
|
Загрузка…
Ссылка в новой задаче