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

Should implement constructor in WebIDL. #70

Closed
romandev opened this issue Sep 16, 2017 · 7 comments
Closed

Should implement constructor in WebIDL. #70

romandev opened this issue Sep 16, 2017 · 7 comments
Assignees

Comments

@romandev
Copy link
Member

In the current implementation, we allow to create object in JS side although there is no constructor definition in WebIDL. It's seems a bug. We should allow to create object with constructor in JS side only if there is an explicit constructor in WebIDL level. To resolve the issue, we should implement constructor feature.

@romandev
Copy link
Member Author

@yjaeseok Are you interested in this issue?

@yjaeseok
Copy link
Contributor

Yes I am interested in this issue, But i have some question.

Calculator has only function (looks like static function), so user do not want to use constructor as class.
If we were to show the constructor correctly, would we need an example with member variables and functions or inheritance?

@romandev
Copy link
Member Author

Hi, @yjaeseok
We can add a constructor in Calculator example for now as follows:

[
    Constructor,
    Constructor(double createdTime)
]
interface Calculator {
    static void print();
    double add(double number1, double number2);
    ...
};

Then, our generator should generate glue codes(bridge codes) and then it should eventually call
developer's cpp constructor.

class Calculator {
 public:
  Calculator() {
    ...
  }

  Calculator(double created_time) {
    ...
  }
};

Yes, we might need variables and inheritance but it's not ready yet. We can implement them incrementally. :)

@yjaeseok
Copy link
Contributor

Hmm..
I have tried many ways It seems that it is hard to apply patch because of lack of understand concept. Could you help me with some advise?
@romandev

@yjaeseok
Copy link
Contributor

How could I get constructor value in template_cpp.njk file?

I think i have to modify idls.ts for idl parsing, but i do not understand how to access constructor parameter like member_info variable.

there is no member_info definition in any files.

@romandev
Copy link
Member Author

We might need a new data structure.
For example, we can think the constructor function is a special member of the interface.
It's my own thinking and your design can be different.

export interface InterfaceConstructor extends InterfaceMember {
}

Also, you can get the information from raw_idl_info.extAttrs.
Please see https://github.com/w3c/webidl2.js#extended-attributes

romandev pushed a commit that referenced this issue Oct 3, 2017
We need to implement constructor in WebIDL.
So I just implement simple constructor.

But we need to implement method overloading mechanism.

I refer to W3C Spec

ISSUE=#70
@yjaeseok
Copy link
Contributor

yjaeseok commented Oct 3, 2017

The issue is closed.

@yjaeseok yjaeseok closed this as completed Oct 3, 2017
romandev pushed a commit that referenced this issue Oct 18, 2017
We need to implement constructor in WebIDL.
So I just implement simple constructor.

But we need to implement method overloading mechanism.

I refer to W3C Spec

ISSUE=#70
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants