2 small questions on "import" statement

Pavel Vasev pavel.vasev at gmail.com
Fri Mar 13 08:42:03 UTC 2015


Hi Anton!

I tried to use/implement import statement.

Because it is already semi-implemented, I hoped it will be
easy task. However I cannot complete it without your help.

1. Could you please fix parser to allow "." (dot) in component names. E.g:
``````````````````````````````````````
import components.scatter 1.0 as ScatterScene

Item {
  ScatterScene.App
  {
  ^ Parser says here: Unexpected token punc undefined, expected punc
  }
}
``````````````````````````````````````
Probably this is not a "dot in component names" problem, but it anyway
refuses to parse...


2. Path lookup - need your advice.

I found that `parseQML` function returns $imports array.

I checked and see that after parseQML you always call
`new QMLComponent` method. E.g:
``````````````````````````````````````````````
    var tree = parseQML(src);
    var component = new QMLComponent({ object: tree, context:
executionContext });
```````````````````````````````````````````````
So I think it is possible to keep `tree.$imports` value somewhere in
component,
here or inside QMLComponent constructor.

The goal for keeping $imports of current component is to have access to it
in
`construct` function when constructing the children of current document.

We can perform some cached lookups of qmldir files contents and decide
whenever we should use component from some qmldir file.

For now, I digged a little to your code and I cannot understand, where is
it better to keep $imports? I tried metaobject, and context, but seems they
are not what I need.
Could you please make some advice?

Best Regards,
Pavel

p.s. I understand that most of your efforts currently are on qml-to-js
convertor.
However it doesn't seem to be ready tomorrow, because it is not easy task.
And current parser/qtcore are "working things". So please give some
attention to them too, because they are just working... Thank you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/qmlweb/attachments/20150313/d2c8924f/attachment.html>


More information about the QmlWeb mailing list