Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement dependency resolver #165

Open
romandev opened this issue Nov 8, 2017 · 0 comments
Open

Implement dependency resolver #165

romandev opened this issue Nov 8, 2017 · 0 comments
Assignees

Comments

@romandev
Copy link
Member

romandev commented Nov 8, 2017

(WIP: To be updated design document)

Basic steps

  • Read IDL file
  • Parsing IDL fragment
  • Generate binding code

Read IDL file

  • One IDL file should be represented to one IDL fragment.

Parsing IDL fragment

  • Use WebIDL2 parser to create AST(Abstract Syntax Tree)
  • In this step, should create IDL definition objects(interface, enum and so on) from IDL fragment.

Create IDL definition object

We should create IDL definition object(e.g. IDL interface, IDL enum and so on) from IDL fragment.
For example, if there is an IDL fragment,

interface Hello {
  attribute World world;
  attribute double yaho;
};

enum World {
  "absolute",
  "bacardi"
};

We can create two IDL definition objects for Hello and World. Once the IDL definition object is created, it should keep the object in map-like data structure we called IDL definition map.

Dependency check

During creating IDL definition objects from IDL fragment, each task should check whether some type is already defined or not.
For example, if there is an IDL fragment as follows:

interface Hello {
  attribute World world;
  attribute double yaho;
};

The above Hello interface needs World type and double type. The double type is a kind of basic types but the World type is not. If IDL definition of World type exists in the same IDL fragment, then might be no problem fortunately. But if not exists in above case, we have to wait for IDL definition object which is defined from external another IDL fragment.
To check this dependency, we should have IDL definition map in global area and update it whenever creating a new IDL definition object. For example, creating IDL definition object for Hello interface, it's only possible if IDL definition object for World is already created.

Undefined type map

While creating IDL definition object in parsing step, if we faced undefined type, we should wait for the type to be resolved. BTW, there is no way to block thread in code level in JavaScript(TypeScript as well). So, we should use Promise and if the type is already defined, the Promise should be resolved.
In other words, if we faced undefined type, we should queue the task into pending queue we called undefined type map.

No dependency

Happy case!

Generate binding code

  • If the generator code doesn't
@romandev romandev self-assigned this Nov 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant