|
|
@@ -172,18 +172,21 @@ bool JSComponentFile::InitModule()
|
|
|
if (!PushModule())
|
|
|
return false;
|
|
|
|
|
|
- if (duk_is_function(ctx, -1))
|
|
|
+ if (!duk_is_function(ctx, -1))
|
|
|
{
|
|
|
- // TODO: verify JSComponent in prototype chain
|
|
|
- scriptClass_ = true;
|
|
|
+ LOGERRORF("Component file does not export a function: %s", GetName().CString());
|
|
|
duk_set_top(ctx, top);
|
|
|
- return true;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
- if (!duk_is_object(ctx, -1))
|
|
|
+ // detect a script class vs a simple "flat" javascript component
|
|
|
+ // this means that if a script component class defines a constructor,
|
|
|
+ // it must take 0 arguments (which makes sense as when it is new'd from
|
|
|
+ // serialization, etc there will be no args to pass it
|
|
|
+
|
|
|
+ if (duk_get_length(ctx, -1) == 0)
|
|
|
{
|
|
|
- duk_set_top(ctx, top);
|
|
|
- return false;
|
|
|
+ scriptClass_ = true;
|
|
|
}
|
|
|
|
|
|
duk_set_top(ctx, top);
|