return $ CYBlock(statements);
}
-static CYTypedIdentifier *CYDecodeType(CXType type);
-static void CYParseType(CXType type, CYTypedIdentifier *typed);
+static CYType *CYDecodeType(CXType type);
+static void CYParseType(CXType type, CYType *typed);
-static CYTypedIdentifier *CYDecodeType(CXType type, const CYCXString &identifier) {
- CYTypedIdentifier *typed(CYDecodeType(type));
- typed->identifier_ = $ CYIdentifier(identifier.Pool($pool));
- return typed;
-}
-
-static void CYParseEnumeration(CXCursor cursor, CYTypedIdentifier *typed) {
+static void CYParseEnumeration(CXCursor cursor, CYType *typed) {
CYList<CYEnumConstant> constants;
CYForChild(cursor, fun([&](CXCursor child) {
constants->*$ CYEnumConstant($I($pool.strdup(CYCXString(child))), $D(clang_getEnumConstantDeclValue(child)));
}));
- CYTypedIdentifier *integer(CYDecodeType(clang_getEnumDeclIntegerType(cursor)));
+ CYType *integer(CYDecodeType(clang_getEnumDeclIntegerType(cursor)));
typed->specifier_ = $ CYTypeEnum(NULL, integer->specifier_, constants);
}
-static void CYParseStructure(CXCursor cursor, CYTypedIdentifier *typed) {
+static void CYParseStructure(CXCursor cursor, CYType *typed) {
CYList<CYTypeStructField> fields;
CYForChild(cursor, fun([&](CXCursor child) {
- if (clang_getCursorKind(child) == CXCursor_FieldDecl) {
- CYTypedIdentifier *field(CYDecodeType(clang_getCursorType(child), child));
- fields->*$ CYTypeStructField(field);
- }
+ if (clang_getCursorKind(child) == CXCursor_FieldDecl)
+ fields->*$ CYTypeStructField(CYDecodeType(clang_getCursorType(child)), $I(CYCXString(child).Pool($pool)));
}));
typed->specifier_ = $ CYTypeStruct(NULL, $ CYStructTail(fields));
}
-static void CYParseCursor(CXType type, CXCursor cursor, CYTypedIdentifier *typed) {
+static void CYParseCursor(CXType type, CXCursor cursor, CYType *typed) {
CYCXString spelling(cursor);
switch (CXCursorKind kind = clang_getCursorKind(cursor)) {
}
}
-static CYTypedParameter *CYParseSignature(CXType type, CYTypedIdentifier *typed) {
+static CYTypedParameter *CYParseSignature(CXType type, CYType *typed) {
CYParseType(clang_getResultType(type), typed);
CYList<CYTypedParameter> parameters;
for (int i(0), e(clang_getNumArgTypes(type)); i != e; ++i)
- parameters->*$ CYTypedParameter(CYDecodeType(clang_getArgType(type, i)));
+ parameters->*$ CYTypedParameter(CYDecodeType(clang_getArgType(type, i)), NULL);
return parameters;
}
-static void CYParseFunction(CXType type, CYTypedIdentifier *typed) {
+static void CYParseFunction(CXType type, CYType *typed) {
typed = typed->Modify($ CYTypeFunctionWith(clang_isFunctionTypeVariadic(type), CYParseSignature(type, typed)));
}
-static void CYParseType(CXType type, CYTypedIdentifier *typed) {
+static void CYParseType(CXType type, CYType *typed) {
switch (CXTypeKind kind = type.kind) {
case CXType_Unexposed: {
CXType result(clang_getResultType(type));
} break;
case CXType_Bool: typed->specifier_ = $ CYTypeVariable("bool"); break;
- case CXType_Float: typed->specifier_ = $ CYTypeVariable("float"); break;
- case CXType_Double: typed->specifier_ = $ CYTypeVariable("double"); break;
+ case CXType_WChar: typed->specifier_ = $ CYTypeVariable("wchar_t"); break;
+ case CXType_Float: typed->specifier_ = $ CYTypeFloating(0); break;
+ case CXType_Double: typed->specifier_ = $ CYTypeFloating(1); break;
+ case CXType_LongDouble: typed->specifier_ = $ CYTypeFloating(2); break;
case CXType_Char_U: typed->specifier_ = $ CYTypeCharacter(CYTypeNeutral); break;
case CXType_Char_S: typed->specifier_ = $ CYTypeCharacter(CYTypeNeutral); break;
typed = typed->Modify($ CYTypeConstant());
}
-static CYTypedIdentifier *CYDecodeType(CXType type) {
- CYTypedIdentifier *typed($ CYTypedIdentifier(NULL));
+static CYType *CYDecodeType(CXType type) {
+ CYType *typed($ CYType(NULL));
CYParseType(type, typed);
return typed;
}
CYLocalPool pool;
- CYTypedIdentifier typed(NULL);
+ CYType typed;
CYParseEnumeration(cursor, &typed);
CYOptions options;
CYLocalPool pool;
- CYTypedIdentifier typed(NULL);
+ CYType typed;
CYParseStructure(cursor, &typed);
CYOptions options;
case CXCursor_TypedefDecl: {
CYLocalPool local;
- CYTypedIdentifier *typed(CYDecodeType(clang_getTypedefDeclUnderlyingType(cursor)));
+ CYType *typed(CYDecodeType(clang_getTypedefDeclUnderlyingType(cursor)));
if (typed->specifier_ == NULL)
value << "(typedef " << CYCXString(clang_getTypeSpelling(clang_getTypedefDeclUnderlyingType(cursor))) << ")";
else {
goto skip;
if (code == NULL) {
+ value << "*";
CXType type(clang_getCursorType(cursor));
- value << "*(typedef " << CYCXString(clang_getTypeSpelling(type)) << ").pointerTo()(dlsym(RTLD_DEFAULT,'" << label.substr(1) << "'))";
+ CYType *typed(CYDecodeType(type));
+ CYOptions options;
+ CYOutput out(*value.rdbuf(), options);
+ CYTypeExpression(typed).Output(out, CYNoBFC);
+ value << ".pointerTo()(dlsym(RTLD_DEFAULT,'" << label.substr(1) << "'))";
} else {
CYOptions options;
CYOutput out(*value.rdbuf(), options);