}
}));
+ value << "new Type([" << types.str() << "],[" << names.str() << "]).withName(\"" << name << "\")";
name += "$cy";
- value << "new Type([" << types.str() << "],[" << names.str() << "])";
} break;
case CXCursor_TypedefDecl: {
static JSValueRef Functor_callAsFunction_toCYON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
cy::Functor *internal(reinterpret_cast<cy::Functor *>(JSObjectGetPrivate(_this)));
uint8_t *value(reinterpret_cast<uint8_t *>(internal->value_));
- std::ostringstream str;
- Dl_info info;
- if (internal->value_ == NULL)
- str << "NULL";
- else if (dladdr(value, &info) == 0)
- str << internal->value_;
- else {
- str << info.dli_sname;
- off_t offset(value - reinterpret_cast<uint8_t *>(info.dli_saddr));
- if (offset != 0)
- str << "+0x" << std::hex << offset;
+
+ CYLocalPool pool;
+
+ sig::Function function(internal->variadic_);
+ sig::Copy(pool, function.signature, internal->signature_);
+
+ auto typed(CYDecodeType(pool, &function)); {
+ std::ostringstream str;
+ Dl_info info;
+ if (internal->value_ == NULL)
+ str << "NULL";
+ else if (dladdr(value, &info) == 0)
+ str << internal->value_;
+ else {
+ str << info.dli_sname;
+ off_t offset(value - reinterpret_cast<uint8_t *>(info.dli_saddr));
+ if (offset != 0)
+ str << "+0x" << std::hex << offset;
+ }
+
+ typed->identifier_ = new(pool) CYIdentifier(pool.strdup(str.str().c_str()));
}
+
+ std::ostringstream str;
+ CYOptions options;
+ CYOutput output(*str.rdbuf(), options);
+ output.pretty_ = true;
+ (new(pool) CYExternal(new(pool) CYString("C"), typed))->Output(output, CYNoFlags);
return CYCastJSValue(context, CYJSString(str.str()));
} CYCatch(NULL) }
std::stringbuf out;
CYOptions options;
CYOutput output(out, options);
- (new(pool) CYTypeExpression(CYDecodeType(pool, internal->type_)))->Output(output, CYNoFlags);
+ (new(pool) CYTypeExpression(CYDecodeType(pool, internal->type_->Copy(pool, ""))))->Output(output, CYNoFlags);
return CYCastJSValue(context, CYJSString(out.str().c_str()));
} CYCatch(NULL) }
}
void CYExternal::Output(CYOutput &out, CYFlags flags) const {
- out << "extern" << abi_ << typed_;
+ out << "extern" << ' ' << abi_ << ' ' << typed_;
out.Terminate();
}
}
void CYTypeArrayOf::Output(CYOutput &out, CYIdentifier *identifier) const {
- next_->Output(out, Precedence(), identifier);
+ next_->Output(out, Precedence(), identifier, false);
out << '[';
out << size_;
out << ']';
void CYTypeBlockWith::Output(CYOutput &out, CYIdentifier *identifier) const {
out << '(' << '^';
- next_->Output(out, Precedence(), identifier);
+ next_->Output(out, Precedence(), identifier, false);
out << ')' << '(' << parameters_ << ')';
}
void CYTypeConstant::Output(CYOutput &out, CYIdentifier *identifier) const {
- out << "const" << ' ';
- next_->Output(out, Precedence(), identifier);
+ out << "const";
+ next_->Output(out, Precedence(), identifier, false);
}
void CYTypeFunctionWith::Output(CYOutput &out, CYIdentifier *identifier) const {
- next_->Output(out, Precedence(), identifier);
+ next_->Output(out, Precedence(), identifier, false);
out << '(' << parameters_;
if (variadic_) {
if (parameters_ != NULL)
void CYTypePointerTo::Output(CYOutput &out, CYIdentifier *identifier) const {
out << '*';
- next_->Output(out, Precedence(), identifier);
+ next_->Output(out, Precedence(), identifier, false);
}
void CYTypeVolatile::Output(CYOutput &out, CYIdentifier *identifier) const {
out << "volatile";
- next_->Output(out, Precedence(), identifier);
+ next_->Output(out, Precedence(), identifier, true);
}
-void CYTypeModifier::Output(CYOutput &out, int precedence, CYIdentifier *identifier) const {
+void CYTypeModifier::Output(CYOutput &out, int precedence, CYIdentifier *identifier, bool space) const {
+ if (this == NULL && identifier == NULL)
+ return;
+ else if (space)
+ out << ' ';
+
if (this == NULL) {
out << identifier;
return;
void CYTypedIdentifier::Output(CYOutput &out) const {
specifier_->Output(out);
- modifier_->Output(out, 0, identifier_);
+ modifier_->Output(out, 0, identifier_, true);
}
void CYEncodedType::Output(CYOutput &out, CYFlags flags) const {
out << '\n';
}
--out.indent_;
- out << '}';
+ out << '\t' << '}';
}
void CYSuperAccess::Output(CYOutput &out, CYFlags flags) const {
CYTarget *Replace(CYContext &context, CYTarget *type);
virtual void Output(CYOutput &out, CYIdentifier *identifier) const = 0;
- void Output(CYOutput &out, int precedence, CYIdentifier *identifier) const;
+ void Output(CYOutput &out, int precedence, CYIdentifier *identifier, bool space) const;
virtual CYTypeFunctionWith *Function() { return NULL; }
};
#endif
Aggregate *Aggregate::Copy(CYPool &pool, const char *rename) const {
- Aggregate *copy(new(pool) Aggregate(overlap, rename ?: pool.strdup(name)));
+ if (rename == NULL)
+ rename = pool.strdup(name);
+ else if (rename[0] == '\0')
+ rename = NULL;
+ Aggregate *copy(new(pool) Aggregate(overlap, rename));
sig::Copy(pool, copy->signature, signature);
return copy;
}