|
@@ -101,10 +101,10 @@ bool JSComponentFile::PushModule()
|
|
|
String pathName, fileName, ext;
|
|
String pathName, fileName, ext;
|
|
|
SplitPath(path, pathName, fileName, ext);
|
|
SplitPath(path, pathName, fileName, ext);
|
|
|
|
|
|
|
|
- if (path.Contains('/') || path.Contains('\\'))
|
|
|
|
|
- pathName += "/" + fileName;
|
|
|
|
|
- else
|
|
|
|
|
- pathName = fileName;
|
|
|
|
|
|
|
+ if (path.Contains('/') || path.Contains('\\'))
|
|
|
|
|
+ pathName += "/" + fileName;
|
|
|
|
|
+ else
|
|
|
|
|
+ pathName = fileName;
|
|
|
|
|
|
|
|
duk_get_global_string(ctx, "require");
|
|
duk_get_global_string(ctx, "require");
|
|
|
duk_push_string(ctx, pathName.CString());
|
|
duk_push_string(ctx, pathName.CString());
|
|
@@ -224,49 +224,56 @@ bool JSComponentFile::BeginLoad(Deserializer& source)
|
|
|
|
|
|
|
|
String eval;
|
|
String eval;
|
|
|
bool valid = false;
|
|
bool valid = false;
|
|
|
|
|
+ int leftBracketCount = 0;
|
|
|
|
|
+ int rightBracketCount = 0;
|
|
|
for (unsigned i = 0; i < lines.Size(); i++)
|
|
for (unsigned i = 0; i < lines.Size(); i++)
|
|
|
{
|
|
{
|
|
|
String line = lines[i];
|
|
String line = lines[i];
|
|
|
|
|
|
|
|
|
|
+ bool added = false;
|
|
|
|
|
+
|
|
|
if (!eval.Length())
|
|
if (!eval.Length())
|
|
|
{
|
|
{
|
|
|
line = line.Trimmed();
|
|
line = line.Trimmed();
|
|
|
|
|
|
|
|
if (line.StartsWith("inspectorFields"))
|
|
if (line.StartsWith("inspectorFields"))
|
|
|
{
|
|
{
|
|
|
|
|
+ added = true;
|
|
|
eval = line + "\n";
|
|
eval = line + "\n";
|
|
|
- if (line.Contains("}"))
|
|
|
|
|
- {
|
|
|
|
|
- valid = true;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
else if (line.StartsWith("this.inspectorFields"))
|
|
else if (line.StartsWith("this.inspectorFields"))
|
|
|
{
|
|
{
|
|
|
|
|
+ added = true;
|
|
|
eval = line.Substring(5) + "\n";
|
|
eval = line.Substring(5) + "\n";
|
|
|
- if (line.Contains("}"))
|
|
|
|
|
- {
|
|
|
|
|
- valid = true;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
else if (line.StartsWith("var inspectorFields"))
|
|
else if (line.StartsWith("var inspectorFields"))
|
|
|
{
|
|
{
|
|
|
|
|
+ added = true;
|
|
|
eval = line.Substring(4) + "\n";
|
|
eval = line.Substring(4) + "\n";
|
|
|
- if (line.Contains("}"))
|
|
|
|
|
- {
|
|
|
|
|
- valid = true;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
|
|
+ added = true;
|
|
|
eval += line + "\n";
|
|
eval += line + "\n";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (line.Contains("}") && eval.Length())
|
|
|
|
|
|
|
+ if (added) {
|
|
|
|
|
+
|
|
|
|
|
+ for (unsigned j = 0; j < line.Length(); j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (line.At(j) == '{')
|
|
|
|
|
+ leftBracketCount++;
|
|
|
|
|
+
|
|
|
|
|
+ else if (line.At(j) == '}')
|
|
|
|
|
+ rightBracketCount++;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (eval.Length() && leftBracketCount && leftBracketCount == rightBracketCount)
|
|
|
{
|
|
{
|
|
|
valid = true;
|
|
valid = true;
|
|
|
break;
|
|
break;
|
|
@@ -359,7 +366,42 @@ bool JSComponentFile::BeginLoad(Deserializer& source)
|
|
|
|
|
|
|
|
duk_pop(ctx);
|
|
duk_pop(ctx);
|
|
|
|
|
|
|
|
- if (length > 1)
|
|
|
|
|
|
|
+ // detect int enum
|
|
|
|
|
+ if (length > 1 && (variantType == VAR_INT || variantType == VAR_FLOAT
|
|
|
|
|
+ || variantType == VAR_DOUBLE))
|
|
|
|
|
+ {
|
|
|
|
|
+ duk_get_prop_index(ctx, -1, 1);
|
|
|
|
|
+
|
|
|
|
|
+ if (duk_is_number(ctx, -1))
|
|
|
|
|
+ {
|
|
|
|
|
+ js_to_variant(ctx, -1, defaultValue);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (duk_is_array(ctx, -1))
|
|
|
|
|
+ {
|
|
|
|
|
+ int enumLength = duk_get_length(ctx, -1);
|
|
|
|
|
+
|
|
|
|
|
+ for (unsigned i = 0; i < enumLength; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ duk_get_prop_index(ctx, -1, i);
|
|
|
|
|
+ String enumName = duk_require_string(ctx, -1);
|
|
|
|
|
+ enums_[name].Push(EnumInfo(enumName, Variant(float(i))));
|
|
|
|
|
+ duk_pop(ctx);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ duk_pop(ctx);
|
|
|
|
|
+
|
|
|
|
|
+ if (length > 2)
|
|
|
|
|
+ {
|
|
|
|
|
+ duk_get_prop_index(ctx, -1, 2);
|
|
|
|
|
+ // default value
|
|
|
|
|
+ js_to_variant(ctx, -1, defaultValue);
|
|
|
|
|
+ duk_pop(ctx);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (length > 1)
|
|
|
{
|
|
{
|
|
|
duk_get_prop_index(ctx, -1, 1);
|
|
duk_get_prop_index(ctx, -1, 1);
|
|
|
// default value
|
|
// default value
|