1.1 --- a/src/API.cpp Mon Jul 30 22:30:38 2012 -0700
1.2 +++ b/src/API.cpp Wed Aug 01 22:32:59 2012 -0700
1.3 @@ -347,23 +347,6 @@
1.4 native->bind(function);
1.5 }
1.6
1.7 -// :TODO: this leaks an interior pointer.
1.8 -static const char *
1.9 -GetTypeName(Type *type)
1.10 -{
1.11 - if (type->isArray())
1.12 - return "array";
1.13 - if (type->isFunction())
1.14 - return "function";
1.15 - if (type->isVoid())
1.16 - return "void";
1.17 - if (type->isReference())
1.18 - type = type->contained();
1.19 - if (type->tag())
1.20 - return type->tag()->chars();
1.21 - return "int";
1.22 -}
1.23 -
1.24 static inline const char *
1.25 GetInvokeTypeName(Ke::Parameter::Type type)
1.26 {
1.27 @@ -392,7 +375,7 @@
1.28 case Ke::Parameter::Array:
1.29 return type->isArray() &&
1.30 type->levels() == 1 &&
1.31 - type->contained()->isPrimitive() &&
1.32 + (type->contained()->isPrimitive() || type->contained()->isEnum()) &&
1.33 (type->contained()->primitive() != PrimitiveType_Char);
1.34 case Ke::Parameter::CharArray:
1.35 return type->isCharArray();
1.36 @@ -401,9 +384,9 @@
1.37 case Ke::Parameter::FloatRef:
1.38 return type->isReference() && type->contained()->isFloat();
1.39 case Ke::Parameter::Int:
1.40 - return type->isInt32();
1.41 + return type->isInt32() || type->isEnum();
1.42 case Ke::Parameter::IntRef:
1.43 - return type->isReference() && type->contained()->isInt32();
1.44 + return type->isReference() && (type->contained()->isInt32() || type->contained()->isEnum());
1.45 default:
1.46 return false;
1.47 }
1.48 @@ -428,7 +411,10 @@
1.49
1.50 // Functions can only return tagged cells, for ISPE1-compatible Invoke().
1.51 ke::Local<ke::Type> returnType(ke::ZONE(), fun->type()->returnType());
1.52 - if (!returnType->isPrimitive() && !returnType->isVoid()) {
1.53 + if (!returnType->isPrimitive() &&
1.54 + !returnType->isEnum() &&
1.55 + !returnType->isVoid())
1.56 + {
1.57 ke::ZONE()->reportError(Message_CannotInvokeReturnType, GetTypeName(returnType));
1.58 return false;
1.59 }