apr_pool_t *pool_;
ffi_type *ffi_;
- sig::Type type_;
+ sig::Type *type_;
Type_privateData(apr_pool_t *pool, sig::Type *type) :
pool_(pool),
ffi_(NULL)
{
- sig::Copy(pool, type_, *type);
+ if (type != NULL) {
+ type_ = new(pool) sig::Type;
+ sig::Copy(pool, *type_, *type);
+ }
}
Type_privateData(apr_pool_t *pool, sig::Type *type, ffi_type *ffi) :
{
ffi_ = new(pool) ffi_type;
sig::Copy(pool, *ffi_, *ffi);
- sig::Copy(pool, type_, *type);
+ type_ = new(pool) sig::Type;
+ sig::Copy(pool, *type_, *type);
}
ffi_type *GetFFI() {
sig::Element element;
element.name = NULL;
- element.type = &type_;
+ element.type = type_;
element.offset = 0;
sig::Signature signature;
bool Index_(apr_pool_t *pool, 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;
size_t length;
const char *name(CYPoolCString(pool, property, &length));
double number(CYCastDouble(name, length));
- size_t count(typical->type_.data.signature.count);
+ size_t count(type->data.signature.count);
if (std::isnan(number)) {
if (property == NULL)
return false;
- sig::Element *elements(typical->type_.data.signature.elements);
+ sig::Element *elements(type->data.signature.elements);
for (size_t local(0); local != count; ++local) {
sig::Element *element(&elements[local]);
Pointer *internal(reinterpret_cast<Pointer *>(JSObjectGetPrivate(object)));
Type_privateData *typical(internal->type_);
+ if (typical->type_ == NULL)
+ return NULL;
+
ssize_t index;
if (!CYGetIndex(pool, property, index))
return NULL;
JSObjectRef owner(internal->owner_ ?: object);
CYTry {
- return CYFromFFI(context, &typical->type_, ffi, base, false, owner);
+ return CYFromFFI(context, typical->type_, ffi, base, false, owner);
} CYCatch
}
Pointer *internal(reinterpret_cast<Pointer *>(JSObjectGetPrivate(object)));
Type_privateData *typical(internal->type_);
+ if (typical->type_ == NULL)
+ return NULL;
+
ssize_t index;
if (!CYGetIndex(pool, property, index))
return NULL;
base += ffi->size * index;
CYTry {
- CYPoolFFI(NULL, context, &typical->type_, ffi, base, value);
+ CYPoolFFI(NULL, context, typical->type_, ffi, base, value);
return true;
} CYCatch
}
JSObjectRef owner(internal->owner_ ?: object);
CYTry {
- return CYFromFFI(context, typical->type_.data.signature.elements[index].type, typical->GetFFI()->elements[index], base, false, owner);
+ return CYFromFFI(context, typical->type_->data.signature.elements[index].type, typical->GetFFI()->elements[index], base, false, owner);
} CYCatch
}
return false;
CYTry {
- CYPoolFFI(NULL, context, typical->type_.data.signature.elements[index].type, typical->GetFFI()->elements[index], base, value);
+ CYPoolFFI(NULL, context, typical->type_->data.signature.elements[index].type, typical->GetFFI()->elements[index], base, value);
return true;
} CYCatch
}
static void Struct_getPropertyNames(JSContextRef context, JSObjectRef object, JSPropertyNameAccumulatorRef names) {
Struct_privateData *internal(reinterpret_cast<Struct_privateData *>(JSObjectGetPrivate(object)));
Type_privateData *typical(internal->type_);
+ sig::Type *type(typical->type_);
+
+ if (type == NULL)
+ return;
- size_t count(typical->type_.data.signature.count);
- sig::Element *elements(typical->type_.data.signature.elements);
+ size_t count(type->data.signature.count);
+ sig::Element *elements(type->data.signature.elements);
char number[32];