} 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;
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);
template <>
CYType *Primitive<double>::Decode(CYPool &pool) const {
- return $ CYType($ CYTypeVariable("double"));
+ return $ CYType($ CYTypeFloating(1));
}
template <>
CYType *Primitive<float>::Decode(CYPool &pool) const {
- return $ CYType($ CYTypeVariable("float"));
+ return $ CYType($ CYTypeFloating(0));
+}
+
+template <>
+CYType *Primitive<long double>::Decode(CYPool &pool) const {
+ return $ CYType($ CYTypeFloating(2));
}
template <>
return JSValueMakeNumber(context, static_cast<double>(value)); \
}
+CYCastJSValue_(long double)
CYCastJSValue_(signed short int)
CYCastJSValue_(unsigned short int)
CYCastJSValue_(signed int)
*reinterpret_cast<Type_ *>(data) = CYCastDouble(context, value); \
}
-CYPoolFFI_(double)
+CYPoolFFI_(wchar_t)
CYPoolFFI_(float)
+CYPoolFFI_(double)
+CYPoolFFI_(long double)
+
CYPoolFFI_(signed char)
CYPoolFFI_(signed int)
CYPoolFFI_(signed long int)
CYPoolFFI_(signed long long int)
CYPoolFFI_(signed short int)
+
CYPoolFFI_(unsigned char)
CYPoolFFI_(unsigned int)
CYPoolFFI_(unsigned long int)
}
CYFromFFI_(bool)
-CYFromFFI_(double)
+CYFromFFI_(wchar_t)
CYFromFFI_(float)
+CYFromFFI_(double)
+CYFromFFI_(long double)
+
CYFromFFI_(signed char)
CYFromFFI_(signed int)
CYFromFFI_(signed long int)
CYFromFFI_(signed long long int)
CYFromFFI_(signed short int)
+
CYFromFFI_(unsigned char)
CYFromFFI_(unsigned int)
CYFromFFI_(unsigned long int)
CYSetProperty(context, cache, CYJSString("float"), CYMakeType(context, sig::Primitive<float>()), kJSPropertyAttributeDontEnum);
CYSetProperty(context, cache, CYJSString("double"), CYMakeType(context, sig::Primitive<double>()), kJSPropertyAttributeDontEnum);
+ CYSetProperty(context, cache, CYJSString("longdouble"), CYMakeType(context, sig::Primitive<long double>()), kJSPropertyAttributeDontEnum);
CYSetProperty(context, global, CYJSString("require"), &require_callAsFunction, kJSPropertyAttributeDontEnum);
out << "@error";
}
+void CYTypeFloating::Output(CYOutput &out) const {
+ switch (length_) {
+ case 0: out << "float"; break;
+ case 1: out << "double"; break;
+ case 2: out << "long" << ' ' << "double"; break;
+ default: _assert(false);
+ }
+}
+
void CYTypeInt128::Output(CYOutput &out) const {
switch (signing_) {
case CYTypeNeutral: break;
| "boolean" { $$ = CYNew CYIdentifier("boolean"); }
| "byte" { $$ = CYNew CYIdentifier("byte"); }
| "constructor" { $$ = CYNew CYIdentifier("constructor"); }
- | "double" { $$ = CYNew CYIdentifier("double"); }
| "each" { $$ = CYNew CYIdentifier("each"); }
| "eval" { $$ = CYNew CYIdentifier("eval"); }
| "final" { $$ = CYNew CYIdentifier("final"); }
- | "float" { $$ = CYNew CYIdentifier("float"); }
| "from" { $$ = CYNew CYIdentifier("from"); }
| "get" { $$ = CYNew CYIdentifier("get"); }
| "goto" { $$ = CYNew CYIdentifier("goto"); }
IdentifierNoOf
: IdentifierTypeNoOf
| "char" { $$ = CYNew CYIdentifier("char"); }
+ | "double" { $$ = CYNew CYIdentifier("double"); }
+ | "float" { $$ = CYNew CYIdentifier("float"); }
| "int" { $$ = CYNew CYIdentifier("int"); }
| "__int128" { $$ = CYNew CYIdentifier("__int128"); }
| "long" { $$ = CYNew CYIdentifier("long"); }
| IntegerType[pass] { $$ = $pass; }
| TypeSigning[signing] "char" { $$ = CYNew CYTypeCharacter($signing); }
| TypeSigning[signing] "__int128" { $$ = CYNew CYTypeInt128($signing); }
+ | "float" { $$ = CYNew CYTypeFloating(0); }
+ | "double" { $$ = CYNew CYTypeFloating(1); }
+ | "long" "double" { $$ = CYNew CYTypeFloating(2); }
;
PrimitiveReference
return typed_->Replace(context);
}
+CYTarget *CYTypeFloating::Replace(CYContext &context) {
+ switch (length_) {
+ case 0: return $V("float");
+ case 1: return $V("double");
+ case 2: return $V("longdouble");
+ default: _assert(false);
+ }
+}
+
CYTarget *CYTypeInt128::Replace(CYContext &context) {
return $V(signing_ == CYTypeUnsigned ? "uint128" : "int128");
}
virtual void Output(CYOutput &out) const;
};
+struct CYTypeFloating :
+ CYTypeSpecifier
+{
+ int length_;
+
+ CYTypeFloating(int length) :
+ length_(length)
+ {
+ }
+
+ virtual CYTarget *Replace(CYContext &context);
+ virtual void Output(CYOutput &out) const;
+};
+
struct CYTypeVoid :
CYTypeSpecifier
{
return &ffi_type_float;
}
+template <>
+ffi_type *Primitive<long double>::GetFFI(CYPool &pool) const {
+ return &ffi_type_longdouble;
+}
+
template <>
ffi_type *Primitive<double>::GetFFI(CYPool &pool) const {
return &ffi_type_double;
break;
case 'c': type = new(pool) Primitive<signed char>(); break;
+ case 'D': type = new(pool) Primitive<long double>(); break;
case 'd': type = new(pool) Primitive<double>(); break;
case 'f': type = new(pool) Primitive<float>(); break;
case 'i': type = new(pool) Primitive<signed int>(); break;
return "f";
}
+template <>
+const char *Primitive<long double>::Encode(CYPool &pool) const {
+ return "D";
+}
+
template <>
const char *Primitive<signed char>::Encode(CYPool &pool) const {
return "c";