summaryrefslogtreecommitdiffstats
path: root/xpcom/reflect/xptinfo/xptcodegen.py
diff options
context:
space:
mode:
Diffstat (limited to 'xpcom/reflect/xptinfo/xptcodegen.py')
-rw-r--r--xpcom/reflect/xptinfo/xptcodegen.py30
1 files changed, 20 insertions, 10 deletions
diff --git a/xpcom/reflect/xptinfo/xptcodegen.py b/xpcom/reflect/xptinfo/xptcodegen.py
index d2859703b8..9dd54a6f07 100644
--- a/xpcom/reflect/xptinfo/xptcodegen.py
+++ b/xpcom/reflect/xptinfo/xptcodegen.py
@@ -9,6 +9,7 @@ import json
from collections import OrderedDict
import buildconfig
+from mozbuild.util import memoize
from perfecthash import PerfectHash
# Pick a nice power-of-two size for our intermediate PHF tables.
@@ -135,6 +136,7 @@ def split_iid(iid): # Get the individual components out of an IID string.
return tuple(split_at_idxs(iid, (8, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2)))
+@memoize
def iid_bytes(iid): # Get the byte representation of the IID for hashing.
bs = bytearray()
for num in split_iid(iid):
@@ -283,10 +285,6 @@ def link_to_cpp(interfaces, fd, header_fd):
tag = type["tag"]
d1 = d2 = 0
- # TD_VOID is used for types that can't be represented in JS, so they
- # should not be represented in the XPT info.
- assert tag != "TD_VOID"
-
if tag == "TD_LEGACY_ARRAY":
d1 = type["size_is"]
d2 = lower_extra_type(type["element"])
@@ -351,15 +349,15 @@ def link_to_cpp(interfaces, fd, header_fd):
return True
- def lower_method(method, ifacename):
+ def lower_method(method, ifacename, builtinclass):
methodname = "%s::%s" % (ifacename, method["name"])
isSymbol = "symbol" in method["flags"]
reflectable = is_method_reflectable(method)
- if not reflectable:
- # Hide the parameters of methods that can't be called from JS to
- # reduce the size of the file.
+ if not reflectable and builtinclass:
+ # Hide the parameters of methods that can't be called from JS and
+ # are on builtinclass interfaces to reduce the size of the file.
paramidx = name = numparams = 0
else:
if isSymbol:
@@ -440,6 +438,8 @@ def link_to_cpp(interfaces, fd, header_fd):
assert method_cnt < 250, "%s has too many methods" % iface["name"]
assert const_cnt < 256, "%s has too many constants" % iface["name"]
+ builtinclass = "builtinclass" in iface["flags"]
+
# Store the lowered interface as 'cxx' on the iface object.
iface["cxx"] = nsXPTInterfaceInfo(
"%d = %s" % (iface["idx"], iface["name"]),
@@ -451,14 +451,14 @@ def link_to_cpp(interfaces, fd, header_fd):
mConsts=len(consts),
mNumConsts=const_cnt,
# Flags
- mBuiltinClass="builtinclass" in iface["flags"],
+ mBuiltinClass=builtinclass,
mMainProcessScriptableOnly="main_process_only" in iface["flags"],
mFunction="function" in iface["flags"],
)
# Lower methods and constants used by this interface
for method in iface["methods"]:
- lower_method(method, iface["name"])
+ lower_method(method, iface["name"], builtinclass)
for const in iface["consts"]:
lower_const(const, iface["name"])
@@ -625,6 +625,16 @@ def link_and_write(files, outfile, outheader):
iids.add(interface["uuid"])
names.add(interface["name"])
+ # All forwards referenced from scriptable members must be known (as scriptable).
+ for iface in interfaces:
+ for ref in iface["needs_scriptable"]:
+ if not ref in names:
+ raise Exception(
+ f"Scriptable member in {iface['name']} references unknown {ref}. "
+ "Forward must be a known and [scriptable] interface, "
+ "or the referencing member marked with [noscript]."
+ )
+
link_to_cpp(interfaces, outfile, outheader)