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 to call function which take dictionaries type as parameter #185

Merged
merged 3 commits into from
Nov 29, 2017

Conversation

hwanseung
Copy link
Contributor

@hwanseung hwanseung commented Nov 12, 2017

This patch is first step to implement dictionaries feature.
it is possible only to call function which take dictionaries type
as parameter in this patch. so we should implement below things
to enhance dictionaries feature.

  • convert native object from javascript type and pass as parameter
  • should implement function which return dictionaries type

ISSUE=#169

Copy link
Member

@romandev romandev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for delayed review.

I'll review this patch tomorrow. As you know, I'm in burnout mode. :(

@hwanseung
Copy link
Contributor Author

i am fine. because these days i am focusing on chromium. :)

Copy link
Member

@romandev romandev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments.


import IDLDefinition from './idl_definition';
import IDLDictionary from './idl_dictionary';

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove unnecessary blank.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.



export default class DictionaryTypes {
dictionaries: IDLDictionary[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be readonly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i added readonly keyword.

}

export default class IDLDictionary extends IDLDefinition {
members: DictionaryMember[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be readonly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i added readonly keyword.

@@ -20,6 +20,9 @@ if (!EnumValidator::isValildEnum({{argument.name}}, enum_value_set)) {
.ThrowAsJavaScriptException();
return{% if not is_constructor %} Napi::Value(){% endif %};
}
{% elif argument.dictionary %}
{{argument.type | pascalcase}} {{argument.name}};
//FIXME(hwanseung): Make NatvieTypeTraits for dictionary types.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be // FIXME(hwanseung).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@@ -20,6 +20,9 @@ if (!EnumValidator::isValildEnum({{argument.name}}, enum_value_set)) {
.ThrowAsJavaScriptException();
return{% if not is_constructor %} Napi::Value(){% endif %};
}
{% elif argument.dictionary %}
{{argument.type | pascalcase}} {{argument.name}};
//FIXME(hwanseung): Make NatvieTypeTraits for dictionary types.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, why do we need NativeTypeTraits for dictionary?
You already implemented the dictionary to be generated as C++ code(native code).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes i made some code to be generated as C++ code.
but present, javascript object will not converted to c++ object.
actually that code is not exist yet. it should be implement.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check this comment as well :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i left comment. but it was pended. sorry.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following code might make some trouble like unused variable error as per compiler.
{{argument.type | pascalcase}} {{argument.name}};

The NativeTypeTraits should be implemented for primitive types. I'm not sure if we should make all custom types. Moreover, IDL dictionary type's name matches with native dictionary type's name perfectly in current implementation. So, I think the generated code should include the converter codes or generate converter codes here without adding a new NativeTypeTraits.

Copy link
Contributor Author

@hwanseung hwanseung Nov 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i didn't know about which NativeTypeTraits is only for primitive types.
i just want to comment out in order to make some converting codes to native dictionary type.
so i will change comment.
and {{argument.type | pascalcase}} {{argument.name}}; is used to pass parameter like below.

TestDict dicValue;
// FIXME(hwanseung): Convert to native dictionary object from javascript object.
  impl_->
  VoidMethodTestDictionaryArg(dicValue);

{% endfor %}
private:
{% for member in members %}
bool has_{{member.name}}_ = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always false?
It should be checked in runtime, so, it should not be generated I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, when javascript object will be converted to c++ object, it should be set true if that javascript object's attribute has value. actually that code is not exist yet. it should be implement.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I know but do we have to have the member variable to check whether it exists or not?
Is it just cache?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

um.. if there were boolean value in dictionary. and if it was passed as false value, it will be too hard to know that value came from javascript or it was just initial value.
so i think we have to know it was set or not.

Copy link
Member

@romandev romandev Nov 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

um.. if there were boolean value in dictionary. and if it was passed as false value, it will be
too hard to know that value came from javascript or it was just initial value.
so i think we have to know it was set or not.

The initial value you mentioned is a default value in WebIDL?

Copy link
Contributor Author

@hwanseung hwanseung Nov 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. it means initial value of native's members. but i am not sure it will be used or not.
so i will remove it now.

Signed-off-by: Hwanseung Lee <hs1217.lee@samsung.com>
Signed-off-by: Hwanseung Lee <hs1217.lee@samsung.com>
Copy link
Member

@romandev romandev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm; thanks!

@romandev romandev merged commit 578ba56 into lunchclass:master Nov 29, 2017
@hwanseung hwanseung deleted the dic branch December 13, 2017 00:17
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

Successfully merging this pull request may close these issues.

2 participants