-/* }}} */
-
-static JSGlobalContextRef Context_;
-static JSObjectRef System_;
-
-static JSClassRef Functor_;
-static JSClassRef Pointer_;
-static JSClassRef Runtime_;
-static JSClassRef Struct_;
-
-static JSStringRef Result_;
-
-JSObjectRef Array_;
-JSObjectRef Error_;
-JSObjectRef Function_;
-JSObjectRef String_;
-
-JSStringRef length_;
-JSStringRef message_;
-JSStringRef name_;
-JSStringRef prototype_;
-JSStringRef toCYON_;
-JSStringRef toJSON_;
-
-JSObjectRef Object_prototype_;
-JSObjectRef Function_prototype_;
-
-JSObjectRef Array_prototype_;
-JSObjectRef Array_pop_;
-JSObjectRef Array_push_;
-JSObjectRef Array_splice_;
-
-sqlite3 *Bridge_;
-
-void CYFinalize(JSObjectRef object) {
- delete reinterpret_cast<CYData *>(JSObjectGetPrivate(object));
-}
-
-struct CStringMapLess :
- std::binary_function<const char *, const char *, bool>
-{
- _finline bool operator ()(const char *lhs, const char *rhs) const {
- return strcmp(lhs, rhs) < 0;
- }
-};
-
-void Structor_(apr_pool_t *pool, sig::Type *&type) {
- if (
- type->primitive == sig::pointer_P &&
- type->data.data.type != NULL &&
- type->data.data.type->primitive == sig::struct_P &&
- strcmp(type->data.data.type->name, "_objc_class") == 0
- ) {
- type->primitive = sig::typename_P;
- type->data.data.type = NULL;
- return;
- }
-
- if (type->primitive != sig::struct_P || type->name == NULL)
- return;
-
- sqlite3_stmt *statement;
-
- _sqlcall(sqlite3_prepare(Bridge_,
- "select "
- "\"bridge\".\"mode\", "
- "\"bridge\".\"value\" "
- "from \"bridge\" "
- "where"
- " \"bridge\".\"mode\" in (3, 4) and"
- " \"bridge\".\"name\" = ?"
- " limit 1"
- , -1, &statement, NULL));
-
- _sqlcall(sqlite3_bind_text(statement, 1, type->name, -1, SQLITE_STATIC));
-
- int mode;
- const char *value;
-
- if (_sqlcall(sqlite3_step(statement)) == SQLITE_DONE) {
- mode = -1;
- value = NULL;
- } else {
- mode = sqlite3_column_int(statement, 0);
- value = sqlite3_column_pooled(pool, statement, 1);
- }
-
- _sqlcall(sqlite3_finalize(statement));
-
- switch (mode) {
- default:
- _assert(false);
- case -1:
- break;
-
- case 3: {
- sig::Parse(pool, &type->data.signature, value, &Structor_);
- } break;
-
- case 4: {
- sig::Signature signature;
- sig::Parse(pool, &signature, value, &Structor_);
- type = signature.elements[0].type;
- } break;
- }
-}
-
-JSClassRef Type_privateData::Class_;
-
-struct Pointer :
- CYOwned
-{
- Type_privateData *type_;
-
- Pointer(void *value, JSContextRef context, JSObjectRef owner, sig::Type *type) :
- CYOwned(value, context, owner),
- type_(new(pool_) Type_privateData(type))
- {
- }
-};
-
-struct Struct_privateData :
- CYOwned
-{
- Type_privateData *type_;
-
- Struct_privateData(JSContextRef context, JSObjectRef owner) :
- CYOwned(NULL, context, owner)
- {
- }
-};
-
-typedef std::map<const char *, Type_privateData *, CStringMapLess> TypeMap;
-static TypeMap Types_;
-
-JSObjectRef CYMakeStruct(JSContextRef context, void *data, sig::Type *type, ffi_type *ffi, JSObjectRef owner) {
- Struct_privateData *internal(new Struct_privateData(context, owner));
- apr_pool_t *pool(internal->pool_);
- Type_privateData *typical(new(pool) Type_privateData(type, ffi));
- internal->type_ = typical;
-
- if (owner != NULL)
- internal->value_ = data;
- else {
- size_t size(typical->GetFFI()->size);
- void *copy(apr_palloc(internal->pool_, size));
- memcpy(copy, data, size);
- internal->value_ = copy;
- }
-
- return JSObjectMake(context, Struct_, internal);
-}
-
-JSValueRef CYCastJSValue(JSContextRef context, bool value) {
- return JSValueMakeBoolean(context, value);
-}
-
-JSValueRef CYCastJSValue(JSContextRef context, double value) {
- return JSValueMakeNumber(context, value);
-}
-
-#define CYCastJSValue_(Type_) \
- JSValueRef CYCastJSValue(JSContextRef context, Type_ value) { \
- return JSValueMakeNumber(context, static_cast<double>(value)); \
- }
-
-CYCastJSValue_(int)
-CYCastJSValue_(unsigned int)
-CYCastJSValue_(long int)
-CYCastJSValue_(long unsigned int)
-CYCastJSValue_(long long int)
-CYCastJSValue_(long long unsigned int)
-
-JSValueRef CYJSUndefined(JSContextRef context) {
- return JSValueMakeUndefined(context);
-}
-
-double CYCastDouble(const char *value, size_t size) {
- char *end;
- double number(strtod(value, &end));
- if (end != value + size)
- return NAN;
- return number;
-}
-
-double CYCastDouble(const char *value) {
- return CYCastDouble(value, strlen(value));
-}
-
-double CYCastDouble(JSContextRef context, JSValueRef value) {
- JSValueRef exception(NULL);
- double number(JSValueToNumber(context, value, &exception));
- CYThrow(context, exception);
- return number;
-}
-
-bool CYCastBool(JSContextRef context, JSValueRef value) {
- return JSValueToBoolean(context, value);
-}
-
-JSValueRef CYJSNull(JSContextRef context) {
- return JSValueMakeNull(context);
-}
-
-JSValueRef CYCastJSValue(JSContextRef context, JSStringRef value) {
- return value == NULL ? CYJSNull(context) : JSValueMakeString(context, value);
-}
-
-JSValueRef CYCastJSValue(JSContextRef context, const char *value) {
- return CYCastJSValue(context, CYJSString(value));
-}
-
-JSObjectRef CYCastJSObject(JSContextRef context, JSValueRef value) {
- JSValueRef exception(NULL);
- JSObjectRef object(JSValueToObject(context, value, &exception));
- CYThrow(context, exception);
- return object;
-}
-
-JSValueRef CYCallAsFunction(JSContextRef context, JSObjectRef function, JSObjectRef _this, size_t count, JSValueRef arguments[]) {
- JSValueRef exception(NULL);
- JSValueRef value(JSObjectCallAsFunction(context, function, _this, count, arguments, &exception));
- CYThrow(context, exception);
- return value;
-}
-
-bool CYIsCallable(JSContextRef context, JSValueRef value) {
- return value != NULL && JSValueIsObject(context, value) && JSObjectIsFunction(context, (JSObjectRef) value);
-}
-
-static JSValueRef System_print(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
- if (count == 0)
- printf("\n");
- else {
- CYPool pool;
- printf("%s\n", CYPoolCString(pool, context, arguments[0]));
- }
-
- return CYJSUndefined(context);
-} CYCatch }
-
-static size_t Nonce_(0);
-
-static JSValueRef $cyq(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) {
- CYPool pool;
- const char *name(apr_psprintf(pool, "%s%"APR_SIZE_T_FMT"", CYPoolCString(pool, context, arguments[0]), Nonce_++));
- return CYCastJSValue(context, name);
-}
-
-static JSValueRef Cycript_gc_callAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) {
- JSGarbageCollect(context);
- return CYJSUndefined(context);
-}
-
-const char *CYPoolCCYON(apr_pool_t *pool, JSContextRef context, JSValueRef value, JSValueRef *exception) { CYTry {
- switch (JSType type = JSValueGetType(context, value)) {
- case kJSTypeUndefined:
- return "undefined";
- case kJSTypeNull:
- return "null";
- case kJSTypeBoolean:
- return CYCastBool(context, value) ? "true" : "false";
-
- case kJSTypeNumber: {
- std::ostringstream str;
- CYNumerify(str, CYCastDouble(context, value));
- std::string value(str.str());
- return apr_pstrmemdup(pool, value.c_str(), value.size());
- } break;
-
- case kJSTypeString: {
- std::ostringstream str;
- CYUTF8String string(CYPoolUTF8String(pool, context, CYJSString(context, value)));
- CYStringify(str, string.data, string.size);
- std::string value(str.str());
- return apr_pstrmemdup(pool, value.c_str(), value.size());
- } break;
-
- case kJSTypeObject:
- return CYPoolCCYON(pool, context, (JSObjectRef) value);
- default:
- throw CYJSError(context, "JSValueGetType() == 0x%x", type);
- }
-} CYCatch }
-
-const char *CYPoolCCYON(apr_pool_t *pool, JSContextRef context, JSValueRef value) {
- JSValueRef exception(NULL);
- const char *cyon(CYPoolCCYON(pool, context, value, &exception));
- CYThrow(context, exception);
- return cyon;
-}
-
-const char *CYPoolCCYON(apr_pool_t *pool, JSContextRef context, JSObjectRef object) {
- JSValueRef toCYON(CYGetProperty(context, object, toCYON_));
- if (CYIsCallable(context, toCYON)) {
- JSValueRef value(CYCallAsFunction(context, (JSObjectRef) toCYON, object, 0, NULL));
- return CYPoolCString(pool, context, value);
- }
-
- JSValueRef toJSON(CYGetProperty(context, object, toJSON_));
- if (CYIsCallable(context, toJSON)) {
- JSValueRef arguments[1] = {CYCastJSValue(context, CYJSString(""))};
- JSValueRef exception(NULL);
- const char *cyon(CYPoolCCYON(pool, context, CYCallAsFunction(context, (JSObjectRef) toJSON, object, 1, arguments), &exception));
- CYThrow(context, exception);
- return cyon;
- }
-
- std::ostringstream str;
-
- str << '{';
-
- // XXX: this is, sadly, going to leak
- JSPropertyNameArrayRef names(JSObjectCopyPropertyNames(context, object));
-
- bool comma(false);
-
- for (size_t index(0), count(JSPropertyNameArrayGetCount(names)); index != count; ++index) {
- JSStringRef name(JSPropertyNameArrayGetNameAtIndex(names, index));
- JSValueRef value(CYGetProperty(context, object, name));
-
- if (comma)
- str << ',';
- else
- comma = true;
-
- CYUTF8String string(CYPoolUTF8String(pool, context, name));
- if (CYIsKey(string))
- str << string.data;
- else
- CYStringify(str, string.data, string.size);
-
- str << ':' << CYPoolCCYON(pool, context, value);
- }
-
- str << '}';
-
- JSPropertyNameArrayRelease(names);
-
- std::string string(str.str());
- return apr_pstrmemdup(pool, string.c_str(), string.size());
-}
-
-static JSValueRef Array_callAsFunction_toCYON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
- CYPool pool;
- std::ostringstream str;
-
- str << '[';
-
- JSValueRef length(CYGetProperty(context, _this, length_));
- bool comma(false);
-
- for (size_t index(0), count(CYCastDouble(context, length)); index != count; ++index) {
- JSValueRef value(CYGetProperty(context, _this, index));
-
- if (comma)
- str << ',';
- else
- comma = true;
-
- if (!JSValueIsUndefined(context, value))
- str << CYPoolCCYON(pool, context, value);
- else {
- str << ',';
- comma = false;
- }
- }
-
- str << ']';
-
- std::string value(str.str());
- return CYCastJSValue(context, CYJSString(CYUTF8String(value.c_str(), value.size())));
-} CYCatch }
-
-JSObjectRef CYMakePointer(JSContextRef context, void *pointer, sig::Type *type, ffi_type *ffi, JSObjectRef owner) {
- Pointer *internal(new Pointer(pointer, context, owner, type));
- return JSObjectMake(context, Pointer_, internal);
-}
-
-static JSObjectRef CYMakeFunctor(JSContextRef context, void (*function)(), const char *type) {
- cy::Functor *internal(new cy::Functor(type, function));
- return JSObjectMake(context, Functor_, internal);
-}
-
-static bool CYGetOffset(apr_pool_t *pool, JSContextRef context, JSStringRef value, ssize_t &index) {
- return CYGetOffset(CYPoolCString(pool, context, value), index);
-}
-
-void *CYCastPointer_(JSContextRef context, JSValueRef value) {
- switch (JSValueGetType(context, value)) {
- case kJSTypeNull:
- return NULL;
- /*case kJSTypeObject:
- if (JSValueIsObjectOfClass(context, value, Pointer_)) {
- Pointer *internal(reinterpret_cast<Pointer *>(JSObjectGetPrivate((JSObjectRef) value)));
- return internal->value_;
- }*/
- default:
- double number(CYCastDouble(context, value));
- if (std::isnan(number))
- throw CYJSError(context, "cannot convert value to pointer");
- return reinterpret_cast<void *>(static_cast<uintptr_t>(static_cast<long long>(number)));
- }
-}
-
-void CYPoolFFI(apr_pool_t *pool, JSContextRef context, sig::Type *type, ffi_type *ffi, void *data, JSValueRef value) {
- switch (type->primitive) {
- case sig::boolean_P:
- *reinterpret_cast<bool *>(data) = JSValueToBoolean(context, value);
- break;
-
-#define CYPoolFFI_(primitive, native) \
- case sig::primitive ## _P: \
- *reinterpret_cast<native *>(data) = CYCastDouble(context, value); \
- break;
-
- CYPoolFFI_(uchar, unsigned char)
- CYPoolFFI_(char, char)
- CYPoolFFI_(ushort, unsigned short)
- CYPoolFFI_(short, short)
- CYPoolFFI_(ulong, unsigned long)
- CYPoolFFI_(long, long)
- CYPoolFFI_(uint, unsigned int)
- CYPoolFFI_(int, int)
- CYPoolFFI_(ulonglong, unsigned long long)
- CYPoolFFI_(longlong, long long)
- CYPoolFFI_(float, float)
- CYPoolFFI_(double, double)
-
- case sig::pointer_P:
- *reinterpret_cast<void **>(data) = CYCastPointer<void *>(context, value);
- break;
-
- case sig::string_P:
- *reinterpret_cast<const char **>(data) = CYPoolCString(pool, context, value);
- break;
-
- case sig::struct_P: {
- uint8_t *base(reinterpret_cast<uint8_t *>(data));
- JSObjectRef aggregate(JSValueIsObject(context, value) ? (JSObjectRef) value : NULL);
- for (size_t index(0); index != type->data.signature.count; ++index) {
- sig::Element *element(&type->data.signature.elements[index]);
- ffi_type *field(ffi->elements[index]);
-
- JSValueRef rhs;
- if (aggregate == NULL)
- rhs = value;
- else {
- rhs = CYGetProperty(context, aggregate, index);
- if (JSValueIsUndefined(context, rhs)) {
- if (element->name != NULL)
- rhs = CYGetProperty(context, aggregate, CYJSString(element->name));
- else
- goto undefined;
- if (JSValueIsUndefined(context, rhs)) undefined:
- throw CYJSError(context, "unable to extract structure value");
- }
- }
-
- CYPoolFFI(pool, context, element->type, field, base, rhs);
- // XXX: alignment?
- base += field->size;
- }
- } break;
-
- case sig::void_P:
- break;
-
- default:
- if (hooks_ != NULL && hooks_->PoolFFI != NULL)
- if ((*hooks_->PoolFFI)(pool, context, type, ffi, data, value))
- return;
-
- fprintf(stderr, "CYPoolFFI(%c)\n", type->primitive);
- _assert(false);
- }
-}
-
-JSValueRef CYFromFFI(JSContextRef context, sig::Type *type, ffi_type *ffi, void *data, bool initialize, JSObjectRef owner) {
- switch (type->primitive) {
- case sig::boolean_P:
- return CYCastJSValue(context, *reinterpret_cast<bool *>(data));
-
-#define CYFromFFI_(primitive, native) \
- case sig::primitive ## _P: \
- return CYCastJSValue(context, *reinterpret_cast<native *>(data)); \
-
- CYFromFFI_(uchar, unsigned char)
- CYFromFFI_(char, char)
- CYFromFFI_(ushort, unsigned short)
- CYFromFFI_(short, short)
- CYFromFFI_(ulong, unsigned long)
- CYFromFFI_(long, long)
- CYFromFFI_(uint, unsigned int)
- CYFromFFI_(int, int)
- CYFromFFI_(ulonglong, unsigned long long)
- CYFromFFI_(longlong, long long)
- CYFromFFI_(float, float)
- CYFromFFI_(double, double)
-
- case sig::pointer_P:
- if (void *pointer = *reinterpret_cast<void **>(data))
- return CYMakePointer(context, pointer, type->data.data.type, ffi, owner);
- else goto null;
-
- case sig::string_P:
- if (char *utf8 = *reinterpret_cast<char **>(data))
- return CYCastJSValue(context, utf8);
- else goto null;
-
- case sig::struct_P:
- return CYMakeStruct(context, data, type, ffi, owner);
- case sig::void_P:
- return CYJSUndefined(context);
-
- null:
- return CYJSNull(context);
- default:
- if (hooks_ != NULL && hooks_->FromFFI != NULL)
- if (JSValueRef value = (*hooks_->FromFFI)(context, type, ffi, data, initialize, owner))
- return value;
-
- CYThrow("failed conversion from FFI format: '%c'\n", type->primitive);
- }
-}
-
-static void FunctionClosure_(ffi_cif *cif, void *result, void **arguments, void *arg) {
- Closure_privateData *internal(reinterpret_cast<Closure_privateData *>(arg));
-
- JSContextRef context(internal->context_);
-
- size_t count(internal->cif_.nargs);
- JSValueRef values[count];
-
- for (size_t index(0); index != count; ++index)
- values[index] = CYFromFFI(context, internal->signature_.elements[1 + index].type, internal->cif_.arg_types[index], arguments[index]);
-
- JSValueRef value(CYCallAsFunction(context, internal->function_, NULL, count, values));
- CYPoolFFI(NULL, context, internal->signature_.elements[0].type, internal->cif_.rtype, result, value);
-}
-
-Closure_privateData *CYMakeFunctor_(JSContextRef context, JSObjectRef function, const char *type, void (*callback)(ffi_cif *, void *, void **, void *)) {
- // XXX: in case of exceptions this will leak
- // XXX: in point of fact, this may /need/ to leak :(
- Closure_privateData *internal(new Closure_privateData(CYGetJSContext(), function, type));
-
- ffi_closure *closure((ffi_closure *) _syscall(mmap(
- NULL, sizeof(ffi_closure),
- PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE,
- -1, 0
- )));
-
- ffi_status status(ffi_prep_closure(closure, &internal->cif_, callback, internal));
- _assert(status == FFI_OK);
-
- _syscall(mprotect(closure, sizeof(*closure), PROT_READ | PROT_EXEC));
-
- internal->value_ = closure;
-
- return internal;
-}
-
-static JSObjectRef CYMakeFunctor(JSContextRef context, JSObjectRef function, const char *type) {
- Closure_privateData *internal(CYMakeFunctor_(context, function, type, &FunctionClosure_));
- return JSObjectMake(context, Functor_, internal);
-}
-
-static JSObjectRef CYMakeFunctor(JSContextRef context, JSValueRef value, const char *type) {
- JSValueRef exception(NULL);
- bool function(JSValueIsInstanceOfConstructor(context, value, Function_, &exception));
- CYThrow(context, exception);
-
- if (function) {
- JSObjectRef function(CYCastJSObject(context, value));
- return CYMakeFunctor(context, function, type);
- } else {
- void (*function)()(CYCastPointer<void (*)()>(context, value));
- return CYMakeFunctor(context, function, type);
- }
-}
-
-static bool Index_(apr_pool_t *pool, JSContextRef context, Struct_privateData *internal, JSStringRef property, ssize_t &index, uint8_t *&base) {
- Type_privateData *typical(internal->type_);
- sig::Type *type(typical->type_);
- if (type == NULL)
- return false;
-
- const char *name(CYPoolCString(pool, context, property));
- size_t length(strlen(name));
- double number(CYCastDouble(name, length));
-
- size_t count(type->data.signature.count);
-
- if (std::isnan(number)) {
- if (property == NULL)
- return false;
-
- sig::Element *elements(type->data.signature.elements);
-
- for (size_t local(0); local != count; ++local) {
- sig::Element *element(&elements[local]);
- if (element->name != NULL && strcmp(name, element->name) == 0) {
- index = local;
- goto base;
- }
- }
-
- return false;
- } else {
- index = static_cast<ssize_t>(number);
- if (index != number || index < 0 || static_cast<size_t>(index) >= count)
- return false;
- }
-
- base:
- ffi_type **elements(typical->GetFFI()->elements);
-
- base = reinterpret_cast<uint8_t *>(internal->value_);
- for (ssize_t local(0); local != index; ++local)
- base += elements[local]->size;
-
- return true;
-}
-
-static JSValueRef Pointer_getIndex(JSContextRef context, JSObjectRef object, size_t index, JSValueRef *exception) { CYTry {
- Pointer *internal(reinterpret_cast<Pointer *>(JSObjectGetPrivate(object)));
- Type_privateData *typical(internal->type_);
-
- ffi_type *ffi(typical->GetFFI());
-
- uint8_t *base(reinterpret_cast<uint8_t *>(internal->value_));
- base += ffi->size * index;
-
- JSObjectRef owner(internal->GetOwner() ?: object);
- return CYFromFFI(context, typical->type_, ffi, base, false, owner);
-} CYCatch }
-
-static JSValueRef Pointer_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) {
- CYPool pool;
- Pointer *internal(reinterpret_cast<Pointer *>(JSObjectGetPrivate(object)));
- Type_privateData *typical(internal->type_);
-
- if (typical->type_ == NULL)
- return NULL;
-
- ssize_t offset;
- if (!CYGetOffset(pool, context, property, offset))
- return NULL;
-
- return Pointer_getIndex(context, object, offset, exception);
-}
-
-static JSValueRef Pointer_getProperty_$cyi(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) {
- return Pointer_getIndex(context, object, 0, exception);
-}
-
-static bool Pointer_setIndex(JSContextRef context, JSObjectRef object, size_t index, JSValueRef value, JSValueRef *exception) { CYTry {
- Pointer *internal(reinterpret_cast<Pointer *>(JSObjectGetPrivate(object)));
- Type_privateData *typical(internal->type_);
-
- ffi_type *ffi(typical->GetFFI());
-
- uint8_t *base(reinterpret_cast<uint8_t *>(internal->value_));
- base += ffi->size * index;
-
- CYPoolFFI(NULL, context, typical->type_, ffi, base, value);
- return true;
-} CYCatch }
-
-static bool Pointer_setProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef value, JSValueRef *exception) {
- CYPool pool;
- Pointer *internal(reinterpret_cast<Pointer *>(JSObjectGetPrivate(object)));
- Type_privateData *typical(internal->type_);
-
- if (typical->type_ == NULL)
- return NULL;
-
- ssize_t offset;
- if (!CYGetOffset(pool, context, property, offset))
- return NULL;
-
- return Pointer_setIndex(context, object, offset, value, exception);
-}
-
-static bool Pointer_setProperty_$cyi(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef value, JSValueRef *exception) {
- return Pointer_setIndex(context, object, 0, value, exception);
-}
-
-static JSValueRef Struct_callAsFunction_$cya(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) {
- Struct_privateData *internal(reinterpret_cast<Struct_privateData *>(JSObjectGetPrivate(_this)));
- Type_privateData *typical(internal->type_);
- return CYMakePointer(context, internal->value_, typical->type_, typical->ffi_, _this);
-}
-
-static JSValueRef Struct_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
- CYPool pool;
- Struct_privateData *internal(reinterpret_cast<Struct_privateData *>(JSObjectGetPrivate(object)));
- Type_privateData *typical(internal->type_);
-
- ssize_t index;
- uint8_t *base;
-
- if (!Index_(pool, context, internal, property, index, base))
- return NULL;
-
- JSObjectRef owner(internal->GetOwner() ?: object);
-
- return CYFromFFI(context, typical->type_->data.signature.elements[index].type, typical->GetFFI()->elements[index], base, false, owner);
-} CYCatch }
-
-static bool Struct_setProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef value, JSValueRef *exception) { CYTry {
- CYPool pool;
- Struct_privateData *internal(reinterpret_cast<Struct_privateData *>(JSObjectGetPrivate(object)));
- Type_privateData *typical(internal->type_);