diff options
author | 2022-10-17 22:37:18 -0700 | |
---|---|---|
committer | 2022-10-17 22:37:18 -0700 | |
commit | 8e1b2ba32e1eecb26ec8f21628207890fab34c14 (patch) | |
tree | 1c1c1929c6f034ef9ec203aa65b4ec4fc0b7bb62 /src/bun.js/bindings/ZigGlobalObject.cpp | |
parent | c7fc8fdf96f8a03d95b7adfdb56b639f2ac42582 (diff) | |
download | bun-8e1b2ba32e1eecb26ec8f21628207890fab34c14.tar.gz bun-8e1b2ba32e1eecb26ec8f21628207890fab34c14.tar.zst bun-8e1b2ba32e1eecb26ec8f21628207890fab34c14.zip |
add oniguruma for regex with variable length lookbehinds (#1329)
* added pcre2 submodule
* pcre2 regex boilerplate
* tests for pcre2 regex
* flag validation, getters, construct and compile mostly working
* string escaping for source and toString(), exec, more tests
* flag sorting, match, matchAll, search, split, replace
* remove lib link
* add destructor to PCRE2RegExp
* header include
* removed ternary
* switched to oniguruma for regex library
* revert sql changes
* fix indices flag, add tests
* revert settings
* working error messages
* more tests for lastIndex, fix logic for compile and lastIndex
* move oniguruma lib to deps out dir
Diffstat (limited to 'src/bun.js/bindings/ZigGlobalObject.cpp')
-rw-r--r-- | src/bun.js/bindings/ZigGlobalObject.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 85b3c27ee..e69163043 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -163,6 +163,8 @@ using JSBuffer = WebCore::JSBuffer; #include "DOMJITHelpers.h" #include <JavaScriptCore/DFGAbstractHeap.h> +#include "OnigurumaRegExp.h" + #ifdef __APPLE__ #include <sys/sysctl.h> #else @@ -2076,6 +2078,17 @@ void GlobalObject::finishCreation(VM& vm) init.setConstructor(constructor); }); + m_OnigurumaRegExpClassStructure.initLater( + [](LazyClassStructure::Initializer& init) { + auto* prototype = OnigurumaRegExpConstructor::createPrototype(init.global); + auto* structure = OnigurumaRegExpConstructor::createClassStructure(init.global, prototype); + auto* constructor = OnigurumaRegExpConstructor::create( + init.vm, init.global, OnigurumaRegExpConstructor::createStructure(init.vm, init.global, init.global->functionPrototype()), prototype); + init.setPrototype(prototype); + init.setStructure(structure); + init.setConstructor(constructor); + }); + m_JSStringDecoderClassStructure.initLater( [](LazyClassStructure::Initializer& init) { auto* prototype = JSStringDecoderPrototype::create( @@ -2542,6 +2555,11 @@ void GlobalObject::installAPIGlobals(JSClassRef* globals, int count, JSC::VM& vm } { + JSC::Identifier identifier = JSC::Identifier::fromString(vm, "OnigurumaRegExp"_s); + object->putDirectCustomAccessor(vm, identifier, JSC::CustomGetterSetter::create(vm, jsFunctionGetOnigurumaRegExpConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | 0); + } + + { JSC::Identifier identifier = JSC::Identifier::fromString(vm, "stringHashCode"_s); object->putDirectNativeFunction(vm, this, identifier, 1, functionHashCode, ImplementationVisibility::Public, NoIntrinsic, JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0); @@ -2668,6 +2686,7 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor) thisObject->m_JSHTTPResponseSinkClassStructure.visit(visitor); thisObject->m_JSHTTPSResponseSinkClassStructure.visit(visitor); thisObject->m_JSFileSinkClassStructure.visit(visitor); + thisObject->m_OnigurumaRegExpClassStructure.visit(visitor); visitor.append(thisObject->m_JSBufferSetterValue); visitor.append(thisObject->m_JSTextEncoderSetterValue); |