|
|
@@ -20,14 +20,8 @@ namespace ToolCore
|
|
|
if (ftype->type_->asPrimitiveType())
|
|
|
{
|
|
|
JSBPrimitiveType* ptype = ftype->type_->asPrimitiveType();
|
|
|
- if (ptype->kind_ == JSBPrimitiveType::Bool)
|
|
|
- scriptType = "Bool";
|
|
|
- if (ptype->kind_ == JSBPrimitiveType::Int && ptype->isUnsigned_)
|
|
|
- scriptType = "UInt";
|
|
|
- else if (ptype->kind_ == JSBPrimitiveType::Int)
|
|
|
- scriptType = "Int";
|
|
|
- if (ptype->kind_ == JSBPrimitiveType::Float)
|
|
|
- scriptType = "Float";
|
|
|
+ scriptType = GetPrimitiveType(ptype);
|
|
|
+ return scriptType;
|
|
|
}
|
|
|
|
|
|
if (ftype->type_->asStringHashType() || ftype->type_->asStringType())
|
|
|
@@ -61,6 +55,19 @@ namespace ToolCore
|
|
|
|
|
|
}
|
|
|
|
|
|
+ String JSBHaxe::GetPrimitiveType(JSBPrimitiveType* ptype)
|
|
|
+ {
|
|
|
+ if (ptype->kind_ == JSBPrimitiveType::Bool)
|
|
|
+ return "Bool";
|
|
|
+ if (ptype->kind_ == JSBPrimitiveType::Int && ptype->isUnsigned_)
|
|
|
+ return "UInt";
|
|
|
+ else if (ptype->kind_ == JSBPrimitiveType::Int)
|
|
|
+ return "Int";
|
|
|
+ if (ptype->kind_ == JSBPrimitiveType::Float)
|
|
|
+ return "Float";
|
|
|
+ return "Dynamic";
|
|
|
+ }
|
|
|
+
|
|
|
void JSBHaxe::Begin()
|
|
|
{
|
|
|
source_ += "//Atomic Haxe Definitions\n\n";
|
|
|
@@ -352,22 +359,23 @@ namespace ToolCore
|
|
|
|
|
|
void JSBHaxe::ExportModuleConstants(JSBModule* module)
|
|
|
{
|
|
|
- Vector<String>& constants = module->GetConstants();
|
|
|
+ HashMap<String, JSBPrimitiveType*>& constants = module->GetConstants();
|
|
|
+
|
|
|
+ Vector<String>& constantsName = constants.Keys();
|
|
|
|
|
|
if (!constants.Size())
|
|
|
return;
|
|
|
|
|
|
source_ += "\n";
|
|
|
|
|
|
- for (unsigned i = 0; i < constants.Size(); i++)
|
|
|
+ for (unsigned i = 0; i < constantsName.Size(); i++)
|
|
|
{
|
|
|
- const String& cname = constants.At(i);
|
|
|
+ const String& cname = constantsName.At(i);
|
|
|
|
|
|
- source_ += " public static var " + cname + ": Int;\n";
|
|
|
+ source_ += " public static inline var " + cname + ": " + GetPrimitiveType(constants[cname]) + ";\n";
|
|
|
}
|
|
|
|
|
|
source_ += "\n";
|
|
|
-
|
|
|
}
|
|
|
|
|
|
void JSBHaxe::ExportEnums(JSBModule* module)
|