From: Jay Freeman (saurik) Date: Sun, 3 Jun 2012 20:59:32 +0000 (-0700) Subject: Support variadic messages (bridge extras as object). X-Git-Tag: v0.9.455~13 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/0add079d639fd70cf3e1934963a9e47fcab4e9b8 Support variadic messages (bridge extras as object). --- diff --git a/ObjectiveC/Library.mm b/ObjectiveC/Library.mm index 81f182b..10ce9cd 100644 --- a/ObjectiveC/Library.mm +++ b/ObjectiveC/Library.mm @@ -2091,6 +2091,26 @@ JSValueRef CYSendMessage(apr_pool_t *pool, JSContextRef context, id self, Class sig::Signature signature; sig::Parse(pool, &signature, type, &Structor_); + size_t used(count + 3); + if (used > signature.count) { + sig::Element *elements(new (pool) sig::Element[used]); + memcpy(elements, signature.elements, used * sizeof(sig::Element)); + + for (size_t index(signature.count); index != used; ++index) { + sig::Element *element(&elements[index]); + element->name = NULL; + element->offset = _not(size_t); + + sig::Type *type(new (pool) sig::Type); + memset(type, 0, sizeof(*type)); + type->primitive = sig::object_P; + element->type = type; + } + + signature.elements = elements; + signature.count = used; + } + ffi_cif cif; sig::sig_ffi_cif(pool, &sig::ObjectiveC, &signature, &cif);