aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/modules/ObjectModule.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/modules/ObjectModule.h')
-rw-r--r--src/bun.js/modules/ObjectModule.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/bun.js/modules/ObjectModule.h b/src/bun.js/modules/ObjectModule.h
new file mode 100644
index 000000000..42ab4dfa5
--- /dev/null
+++ b/src/bun.js/modules/ObjectModule.h
@@ -0,0 +1,32 @@
+#include "../bindings/ZigGlobalObject.h"
+#include "JavaScriptCore/JSGlobalObject.h"
+
+namespace Zig {
+JSC::SyntheticSourceProvider::SyntheticSourceGenerator
+generateObjectModuleSourceCode(JSC::JSGlobalObject *globalObject,
+ JSC::JSObject *object) {
+ JSC::VM &vm = globalObject->vm();
+
+ return [strongObject = JSC::Strong<JSC::JSObject>(vm, object)](
+ JSC::JSGlobalObject *lexicalGlobalObject,
+ JSC::Identifier moduleKey, Vector<JSC::Identifier, 4> &exportNames,
+ JSC::MarkedArgumentBuffer &exportValues) -> void {
+ JSC::VM &vm = lexicalGlobalObject->vm();
+ GlobalObject *globalObject =
+ reinterpret_cast<GlobalObject *>(lexicalGlobalObject);
+ JSC::JSObject *object = strongObject.get();
+
+ PropertyNameArray properties(vm, PropertyNameMode::Strings,
+ PrivateSymbolMode::Exclude);
+ object->getPropertyNames(globalObject, properties,
+ DontEnumPropertiesMode::Exclude);
+
+ for (auto &entry : properties) {
+ exportNames.append(entry);
+ exportValues.append(object->get(globalObject, entry));
+ }
+ strongObject.clear();
+ };
+}
+
+} // namespace Zig \ No newline at end of file