}
}
+static JSValueRef FunctionAdapter_(JSContextRef context, size_t count, JSValueRef values[], JSObjectRef function);
+
namespace sig {
// XXX: this is somehow not quite a template :/
*reinterpret_cast<void **>(data) = CYCastPointer<void *>(context, value, &guess);
if (!guess || pool == NULL || !JSValueIsObject(context, value))
return;
+
JSObjectRef object(CYCastJSObject(context, value));
- if (CYHasProperty(context, object, length_s)) {
+
+ if (sig::Function *function = dynamic_cast<sig::Function *>(&type)) {
+ _assert(!function->variadic);
+ auto internal(CYMakeFunctor_(context, object, function->signature, &FunctionAdapter_));
+ // XXX: see notes in Library.cpp about needing to leak
+ *reinterpret_cast<void (**)()>(data) = internal->value_;
+ } else if (CYHasProperty(context, object, length_s)) {
size_t length(CYArrayLength(context, object));
ffi_type *element(type.GetFFI(*pool));
size_t size(element->size * length);