Be more explicit in casts of generated bindings

This commit is contained in:
Sankha Narayan Guria 2014-02-23 03:03:48 +05:30
parent 061269f963
commit 47e6e6ec8f

View file

@ -250,7 +250,7 @@ class CGMethodCall(CGThing):
# Doesn't matter which of the possible signatures we use, since # Doesn't matter which of the possible signatures we use, since
# they all have the same types up to that point; just use # they all have the same types up to that point; just use
# possibleSignatures[0] # possibleSignatures[0]
caseBody = [CGGeneric("let argv_start = JS_ARGV(cx, cast::transmute(vp));")] caseBody = [CGGeneric("let argv_start = JS_ARGV(cx, vp as *JSVal);")]
caseBody.extend([ CGArgumentConverter(possibleSignatures[0][1][i], caseBody.extend([ CGArgumentConverter(possibleSignatures[0][1][i],
i, "argv_start", "argc", i, "argv_start", "argc",
descriptor) for i in descriptor) for i in
@ -1481,7 +1481,7 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
"}\n" + "}\n" +
successCode) successCode)
else: else:
tail = "return JS_WrapValue(cx, cast::transmute(${jsvalPtr}));" tail = "return JS_WrapValue(cx, ${jsvalPtr} as *JSVal);"
return ("${jsvalRef} = %s;\n" + return ("${jsvalRef} = %s;\n" +
tail) % (value) tail) % (value)
@ -2802,7 +2802,7 @@ class CGGetPerInterfaceObject(CGAbstractMethod):
return ptr::null(); return ptr::null();
}*/ }*/
/* Check to see whether the interface objects are already installed */ /* Check to see whether the interface objects are already installed */
let protoOrIfaceArray: *mut *JSObject = cast::transmute(GetProtoOrIfaceArray(aGlobal)); let protoOrIfaceArray: *mut *JSObject = GetProtoOrIfaceArray(aGlobal) as *mut *JSObject;
let cachedObject: *JSObject = *protoOrIfaceArray.offset(%s as int); let cachedObject: *JSObject = *protoOrIfaceArray.offset(%s as int);
if cachedObject.is_null() { if cachedObject.is_null() {
let tmp: *JSObject = CreateInterfaceObjects(aCx, aGlobal, aReceiver); let tmp: *JSObject = CreateInterfaceObjects(aCx, aGlobal, aReceiver);
@ -3072,7 +3072,7 @@ class CGPerSignatureCall(CGThing):
def getArgv(self): def getArgv(self):
return "argv" if self.argCount > 0 else "" return "argv" if self.argCount > 0 else ""
def getArgvDecl(self): def getArgvDecl(self):
return "\nlet argv = JS_ARGV(cx, cast::transmute(vp));\n" return "\nlet argv = JS_ARGV(cx, vp as *JSVal);\n"
def getArgc(self): def getArgc(self):
return "argc" return "argc"
def getArguments(self): def getArguments(self):
@ -3232,7 +3232,7 @@ class CGAbstractBindingMethod(CGAbstractExternMethod):
def getThis(self): def getThis(self):
return CGIndenter( return CGIndenter(
CGGeneric("let obj: *JSObject = JS_THIS_OBJECT(cx, cast::transmute(vp));\n" CGGeneric("let obj: *JSObject = JS_THIS_OBJECT(cx, vp as *mut JSVal);\n"
"if obj.is_null() {\n" "if obj.is_null() {\n"
" return false as JSBool;\n" " return false as JSBool;\n"
"}\n" "}\n"
@ -3379,8 +3379,8 @@ class CGGenericSetter(CGAbstractBindingMethod):
def generate_code(self): def generate_code(self):
return CGIndenter(CGGeneric( return CGIndenter(CGGeneric(
"let undef = JSVAL_VOID;\n" "let undef = JSVAL_VOID;\n"
"let argv: *JSVal = if argc != 0 { JS_ARGV(cx, cast::transmute(vp)) } else { &undef as *JSVal };\n" "let argv: *JSVal = if argc != 0 { JS_ARGV(cx, vp as *JSVal) } else { &undef as *JSVal };\n"
"let info: *JSJitInfo = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, cast::transmute(vp)));\n" "let info: *JSJitInfo = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, vp as *JSVal));\n"
"if CallJitPropertyOp(info, cx, obj, this as *libc::c_void, argv) == 0 {" "if CallJitPropertyOp(info, cx, obj, this as *libc::c_void, argv) == 0 {"
" return 0;\n" " return 0;\n"
"}\n" "}\n"
@ -4364,7 +4364,7 @@ if expando.is_not_null() {
} }
if hasProp != 0 { if hasProp != 0 {
return JS_GetPropertyById(cx, expando, id, cast::transmute(vp)); return JS_GetPropertyById(cx, expando, id, vp as *JSVal);
} }
}""" }"""
@ -4402,7 +4402,7 @@ if expando.is_not_null() {
%s %s
let mut found = false; let mut found = false;
if !GetPropertyOnPrototype(cx, proxy, id, &mut found, cast::transmute(vp)) { if !GetPropertyOnPrototype(cx, proxy, id, &mut found, vp as *JSVal) {
return 0; return 0;
} }