Skip to content

Commit 6fb1bdb

Browse files
authored
Added Glue for GetRegExpFlags (#423)
* Added Glue for RegExpFlags Updated Comment on MSVC Non-POD Return Values * Regenerated Glue Wrappers Renamed GetRegExpFlags Glue Function * Removed Debug Wrappers * Fixed Comment on MSVC Non-POD Return Values
1 parent f452fb2 commit 6fb1bdb

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

mozjs/src/glue_wrappers.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ wrap!(glue: pub fn AppendToIdVector(v: MutableHandleIdVector, id: HandleId) -> b
1818
wrap!(glue: pub fn JS_GetPromiseResult(promise: HandleObject, dest: MutableHandleValue));
1919
wrap!(glue: pub fn JS_GetScriptPrivate(script: *mut JSScript, dest: MutableHandleValue));
2020
wrap!(glue: pub fn JS_GetModulePrivate(module: *mut JSObject, dest: MutableHandleValue));
21+
wrap!(glue: pub fn JS_GetRegExpFlags(cx: *mut JSContext, obj: HandleObject, flags: *mut RegExpFlags));
2122
wrap!(glue: pub fn EncodeStringToUTF8(cx: *mut JSContext, str_: HandleString, cb: EncodedStringCallback));
2223
wrap!(glue: pub fn SetDataPropertyDescriptor(desc: MutableHandle<PropertyDescriptor>, value: HandleValue, attrs: u32));
2324
wrap!(glue: pub fn SetAccessorPropertyDescriptor(desc: MutableHandle<PropertyDescriptor>, getter: HandleObject, setter: HandleObject, attrs: u32));

mozjs/src/jsglue.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "js/Principals.h"
2424
#include "js/Promise.h"
2525
#include "js/Proxy.h"
26+
#include "js/RegExp.h"
2627
#include "js/ScalarType.h"
2728
#include "js/Stream.h"
2829
#include "js/StructuredClone.h"
@@ -985,13 +986,12 @@ bool WriteBytesToJSStructuredCloneData(const uint8_t* src, size_t len,
985986
return dest->AppendBytes(reinterpret_cast<const char*>(src), len);
986987
}
987988

988-
// MSVC uses a different calling conventions for functions
989+
// MSVC uses a different calling convention for functions
989990
// that return non-POD values. Unfortunately, this includes anything
990-
// with a constructor, such as JS::Value, so we can't call these
991-
// from Rust. These wrapper functions are only here to
992-
// ensure the calling convention is right.
993-
// https://docs.microsoft.com/en-us/cpp/build/return-values-cpp
994-
// https://mozilla.logbot.info/jsapi/20180622#c14918658
991+
// with a constructor, such as JS::Value and JS::RegExpFlags, so we
992+
// can't call these from Rust. These wrapper functions are only here
993+
// to ensure the calling convention is right.
994+
// https://web.archive.org/web/20180929193700/https://mozilla.logbot.info/jsapi/20180622#c14918658
995995

996996
void JS_GetPromiseResult(JS::HandleObject promise,
997997
JS::MutableHandleValue dest) {
@@ -1020,6 +1020,10 @@ void JS_GetReservedSlot(JSObject* obj, uint32_t index, JS::Value* dest) {
10201020
*dest = JS::GetReservedSlot(obj, index);
10211021
}
10221022

1023+
void JS_GetRegExpFlags(JSContext* cx, JS::HandleObject obj, JS::RegExpFlags* flags) {
1024+
*flags = JS::GetRegExpFlags(cx, obj);
1025+
}
1026+
10231027
// keep this in sync with EncodedStringCallback in glue.rs
10241028
typedef void (*EncodedStringCallback)(const char*);
10251029

0 commit comments

Comments
 (0)