Skip to content
This repository was archived by the owner on Nov 12, 2022. It is now read-only.

Commit ca5da66

Browse files
author
Alan Jeffrey
committed
Merge branch 'smup' of github.com:asajeffrey/rust-mozjs into smup
2 parents a26fe0c + 14cfbea commit ca5da66

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

src/glue.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,4 +339,12 @@ extern "C" {
339339
pub fn GetLengthOfJSStructuredCloneData(data: *mut JSStructuredCloneData) -> usize;
340340
pub fn CopyJSStructuredCloneData(src: *const JSStructuredCloneData, dest: *mut u8);
341341
pub fn WriteBytesToJSStructuredCloneData(src: *const u8, len: usize, dest: *mut JSStructuredCloneData);
342+
pub fn JS_ComputeThis (cx: *mut JSContext , vp: *mut JS::Value, dest: *mut JS::Value);
343+
pub fn JS_GetModuleHostDefinedField (module: *mut JSObject, dest: *mut JS::Value);
344+
pub fn JS_GetPromiseResult (promise: JS::HandleObject, dest: *mut JS::Value);
345+
pub fn JS_THIS (cx: *mut JSContext , vp: *mut JS::Value, dest: *mut JS::Value);
346+
pub fn JS_GetNaNValue (cx: *mut JSContext, dest: *mut JS::Value);
347+
pub fn JS_GetPositiveInfinityValue (cx: *mut JSContext, dest: *mut JS::Value);
348+
pub fn JS_GetEmptyStringValue (cx: *mut JSContext, dest: *mut JS::Value);
349+
pub fn JS_GetReservedSlot (obj: *mut JSObject , index: u32, dest: *mut JS::Value);
342350
}

src/jsglue.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,4 +952,52 @@ WriteBytesToJSStructuredCloneData(const uint8_t* src, size_t len, JSStructuredCl
952952
return dest->WriteBytes(reinterpret_cast<const char*>(src), len);
953953
}
954954

955+
// MSVC uses a different calling conventions for functions
956+
// that return non-POD values. Unfortunately, this includes anything
957+
// with a constructor, such as JS::Value, so we can't call these
958+
// from Rust. These wrapper functions are only here to
959+
// ensure the calling convention is right.
960+
// https://docs.microsoft.com/en-us/cpp/build/return-values-cpp
961+
// https://mozilla.logbot.info/jsapi/20180622#c14918658
962+
963+
void
964+
JS_ComputeThis(JSContext* cx, JS::Value* vp, JS::Value* dest) {
965+
*dest = JS::detail::ComputeThis(cx, vp);
966+
}
967+
968+
void
969+
JS_GetModuleHostDefinedField(JSObject* module, JS::Value* dest) {
970+
*dest = JS::GetModuleHostDefinedField(module);
971+
}
972+
973+
void
974+
JS_GetPromiseResult(JS::HandleObject promise, JS::Value* dest) {
975+
*dest = JS::GetPromiseResult(promise);
976+
}
977+
978+
void
979+
JS_THIS(JSContext* cx, JS::Value* vp, JS::Value* dest) {
980+
*dest = JS_THIS(cx, vp);
981+
}
982+
983+
void
984+
JS_GetNaNValue(JSContext* cx, JS::Value* dest) {
985+
*dest = JS_GetNaNValue(cx);
986+
}
987+
988+
void
989+
JS_GetPositiveInfinityValue(JSContext* cx, JS::Value* dest) {
990+
*dest = JS_GetPositiveInfinityValue(cx);
991+
}
992+
993+
void
994+
JS_GetEmptyStringValue(JSContext* cx, JS::Value* dest) {
995+
*dest = JS_GetEmptyStringValue(cx);
996+
}
997+
998+
void
999+
JS_GetReservedSlot(JSObject* obj, uint32_t index, JS::Value* dest) {
1000+
*dest = JS_GetReservedSlot(obj, index);
1001+
}
1002+
9551003
} // extern "C"

0 commit comments

Comments
 (0)