+template <size_t Size_>
+class CYArrayBuilder {
+ private:
+ JSContextRef context_;
+ JSObjectRef &array_;
+ size_t size_;
+ JSValueRef values_[Size_];
+
+ void flush() {
+ if (array_ == NULL)
+ array_ = CYObjectMakeArray(context_, size_, values_);
+ else
+ CYArrayPush(context_, array_, size_, values_);
+ }
+
+ public:
+ CYArrayBuilder(JSContextRef context, JSObjectRef &array) :
+ context_(context),
+ array_(array),
+ size_(0)
+ {
+ }
+
+ ~CYArrayBuilder() {
+ flush();
+ }
+
+ void operator ()(JSValueRef value) {
+ if (size_ == Size_) {
+ flush();
+ size_ = 0;
+ }
+
+ values_[size_++] = value;
+ }
+};
+
+#ifdef __APPLE__
+#define _weak __attribute__((__weak_import__));
+#else
+#define _weak
+#endif
+
+typedef struct OpaqueJSWeakObjectMap *JSWeakObjectMapRef;
+typedef void (*JSWeakMapDestroyedCallback)(JSWeakObjectMapRef map, void *data);
+
+extern "C" JSWeakObjectMapRef JSWeakObjectMapCreate(JSContextRef ctx, void *data, JSWeakMapDestroyedCallback destructor) _weak;
+extern "C" void JSWeakObjectMapSet(JSContextRef ctx, JSWeakObjectMapRef map, void *key, JSObjectRef) _weak;
+extern "C" JSObjectRef JSWeakObjectMapGet(JSContextRef ctx, JSWeakObjectMapRef map, void *key) _weak;
+extern "C" bool JSWeakObjectMapClear(JSContextRef ctx, JSWeakObjectMapRef map, void *key, JSObjectRef object) _weak;
+extern "C" void JSWeakObjectMapRemove(JSContextRef ctx, JSWeakObjectMapRef map, void* key) _weak;
+
+typedef bool (*JSShouldTerminateCallback)(JSContextRef ctx, void *context);
+extern "C" void JSContextGroupSetExecutionTimeLimit(JSContextGroupRef, double limit, JSShouldTerminateCallback, void *context) _weak;
+