mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Merge pull request #2678 from Ms2ger/CreateInterfaceObjects2-protoClass
Stop pretending that CreateInterfaceObjects2 can return the interface object.
This commit is contained in:
commit
f852fc7d86
2 changed files with 12 additions and 21 deletions
|
@ -1902,14 +1902,13 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
|
||||||
return "Some(%s.as_slice())" % val
|
return "Some(%s.as_slice())" % val
|
||||||
|
|
||||||
call = """return CreateInterfaceObjects2(aCx, aGlobal, aReceiver, parentProto,
|
call = """return CreateInterfaceObjects2(aCx, aGlobal, aReceiver, parentProto,
|
||||||
%s, %s, %d,
|
&PrototypeClass, %s, %d,
|
||||||
%s,
|
%s,
|
||||||
%s,
|
%s,
|
||||||
%s,
|
%s,
|
||||||
%s,
|
%s,
|
||||||
%s,
|
%s,
|
||||||
%s);""" % (
|
%s);""" % (
|
||||||
"&PrototypeClass" if needInterfacePrototypeObject else "ptr::null()",
|
|
||||||
"Some(%s)" % constructHook if needInterfaceObject else "None",
|
"Some(%s)" % constructHook if needInterfaceObject else "None",
|
||||||
constructArgs,
|
constructArgs,
|
||||||
domClass,
|
domClass,
|
||||||
|
|
|
@ -216,7 +216,8 @@ pub fn GetProtoOrIfaceArray(global: *mut JSObject) -> *mut *mut JSObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn CreateInterfaceObjects2(cx: *mut JSContext, global: *mut JSObject, receiver: *mut JSObject,
|
pub fn CreateInterfaceObjects2(cx: *mut JSContext, global: *mut JSObject, receiver: *mut JSObject,
|
||||||
protoProto: *mut JSObject, protoClass: *JSClass,
|
protoProto: *mut JSObject,
|
||||||
|
protoClass: &'static JSClass,
|
||||||
constructor: JSNative,
|
constructor: JSNative,
|
||||||
ctorNargs: u32,
|
ctorNargs: u32,
|
||||||
domClass: *DOMClass,
|
domClass: *DOMClass,
|
||||||
|
@ -225,32 +226,24 @@ pub fn CreateInterfaceObjects2(cx: *mut JSContext, global: *mut JSObject, receiv
|
||||||
constants: Option<&'static [ConstantSpec]>,
|
constants: Option<&'static [ConstantSpec]>,
|
||||||
staticMethods: Option<&'static [JSFunctionSpec]>,
|
staticMethods: Option<&'static [JSFunctionSpec]>,
|
||||||
name: &str) -> *mut JSObject {
|
name: &str) -> *mut JSObject {
|
||||||
let mut proto = ptr::mut_null();
|
let proto = CreateInterfacePrototypeObject(cx, global, protoProto,
|
||||||
if protoClass.is_not_null() {
|
|
||||||
proto = CreateInterfacePrototypeObject(cx, global, protoProto,
|
|
||||||
protoClass, methods,
|
protoClass, methods,
|
||||||
properties, constants);
|
properties, constants);
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
JS_SetReservedSlot(proto, DOM_PROTO_INSTANCE_CLASS_SLOT,
|
JS_SetReservedSlot(proto, DOM_PROTO_INSTANCE_CLASS_SLOT,
|
||||||
PrivateValue(domClass as *libc::c_void));
|
PrivateValue(domClass as *libc::c_void));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut interface = ptr::mut_null();
|
|
||||||
if constructor.is_some() {
|
if constructor.is_some() {
|
||||||
interface = name.to_c_str().with_ref(|s| {
|
name.to_c_str().with_ref(|s| {
|
||||||
CreateInterfaceObject(cx, global, receiver,
|
CreateInterfaceObject(cx, global, receiver,
|
||||||
constructor, ctorNargs, proto,
|
constructor, ctorNargs, proto,
|
||||||
staticMethods, constants, s)
|
staticMethods, constants, s)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if protoClass.is_not_null() {
|
proto
|
||||||
proto
|
|
||||||
} else {
|
|
||||||
interface
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn CreateInterfaceObject(cx: *mut JSContext, global: *mut JSObject, receiver: *mut JSObject,
|
fn CreateInterfaceObject(cx: *mut JSContext, global: *mut JSObject, receiver: *mut JSObject,
|
||||||
|
@ -258,7 +251,7 @@ fn CreateInterfaceObject(cx: *mut JSContext, global: *mut JSObject, receiver: *m
|
||||||
ctorNargs: u32, proto: *mut JSObject,
|
ctorNargs: u32, proto: *mut JSObject,
|
||||||
staticMethods: Option<&'static [JSFunctionSpec]>,
|
staticMethods: Option<&'static [JSFunctionSpec]>,
|
||||||
constants: Option<&'static [ConstantSpec]>,
|
constants: Option<&'static [ConstantSpec]>,
|
||||||
name: *libc::c_char) -> *mut JSObject {
|
name: *libc::c_char) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let fun = JS_NewFunction(cx, constructorNative, ctorNargs,
|
let fun = JS_NewFunction(cx, constructorNative, ctorNargs,
|
||||||
JSFUN_CONSTRUCTOR, global, name);
|
JSFUN_CONSTRUCTOR, global, name);
|
||||||
|
@ -289,8 +282,6 @@ fn CreateInterfaceObject(cx: *mut JSContext, global: *mut JSObject, receiver: *m
|
||||||
ObjectValue(&*constructor),
|
ObjectValue(&*constructor),
|
||||||
None, None, 0) != 0);
|
None, None, 0) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return constructor;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +317,8 @@ fn DefineProperties(cx: *mut JSContext, obj: *mut JSObject, properties: &'static
|
||||||
}
|
}
|
||||||
|
|
||||||
fn CreateInterfacePrototypeObject(cx: *mut JSContext, global: *mut JSObject,
|
fn CreateInterfacePrototypeObject(cx: *mut JSContext, global: *mut JSObject,
|
||||||
parentProto: *mut JSObject, protoClass: *JSClass,
|
parentProto: *mut JSObject,
|
||||||
|
protoClass: &'static JSClass,
|
||||||
methods: Option<&'static [JSFunctionSpec]>,
|
methods: Option<&'static [JSFunctionSpec]>,
|
||||||
properties: Option<&'static [JSPropertySpec]>,
|
properties: Option<&'static [JSPropertySpec]>,
|
||||||
constants: Option<&'static [ConstantSpec]>) -> *mut JSObject {
|
constants: Option<&'static [ConstantSpec]>) -> *mut JSObject {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue