diff -r a8735148dcf0 -r e9d804821c48 src/API.cpp --- a/src/API.cpp Mon Jul 30 22:30:38 2012 -0700 +++ b/src/API.cpp Wed Aug 01 22:32:59 2012 -0700 @@ -347,23 +347,6 @@ native->bind(function); } -// :TODO: this leaks an interior pointer. -static const char * -GetTypeName(Type *type) -{ - if (type->isArray()) - return "array"; - if (type->isFunction()) - return "function"; - if (type->isVoid()) - return "void"; - if (type->isReference()) - type = type->contained(); - if (type->tag()) - return type->tag()->chars(); - return "int"; -} - static inline const char * GetInvokeTypeName(Ke::Parameter::Type type) { @@ -392,7 +375,7 @@ case Ke::Parameter::Array: return type->isArray() && type->levels() == 1 && - type->contained()->isPrimitive() && + (type->contained()->isPrimitive() || type->contained()->isEnum()) && (type->contained()->primitive() != PrimitiveType_Char); case Ke::Parameter::CharArray: return type->isCharArray(); @@ -401,9 +384,9 @@ case Ke::Parameter::FloatRef: return type->isReference() && type->contained()->isFloat(); case Ke::Parameter::Int: - return type->isInt32(); + return type->isInt32() || type->isEnum(); case Ke::Parameter::IntRef: - return type->isReference() && type->contained()->isInt32(); + return type->isReference() && (type->contained()->isInt32() || type->contained()->isEnum()); default: return false; } @@ -428,7 +411,10 @@ // Functions can only return tagged cells, for ISPE1-compatible Invoke(). ke::Local returnType(ke::ZONE(), fun->type()->returnType()); - if (!returnType->isPrimitive() && !returnType->isVoid()) { + if (!returnType->isPrimitive() && + !returnType->isEnum() && + !returnType->isVoid()) + { ke::ZONE()->reportError(Message_CannotInvokeReturnType, GetTypeName(returnType)); return false; }