-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement to call function which take dictionaries type as parameter (#…
…185) 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
- Loading branch information
Showing
13 changed files
with
208 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright (c) 2017 The Bacardi Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import IDLDefinition from './idl_definition'; | ||
import IDLDictionary from './idl_dictionary'; | ||
|
||
export default class DictionaryTypes { | ||
readonly dictionaries: IDLDictionary[]; | ||
|
||
constructor(definitions: IDLDefinition[]) { | ||
this.dictionaries = []; | ||
definitions.forEach((definition) => { | ||
if (definition.isIDLDictionary()) { | ||
this.dictionaries.push(definition as IDLDictionary); | ||
} | ||
}); | ||
} | ||
|
||
public isDictionaryType(source: string): IDLDictionary { | ||
for (const item of this.dictionaries) { | ||
if (item.name == source) { | ||
return item; | ||
} | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Copyright (c) 2017 The Bacardi Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import IDLDefinition from './idl_definition'; | ||
import IDLIdentifier from './idl_identifier'; | ||
|
||
class DictionaryMember implements IDLIdentifier { | ||
readonly type: string; | ||
readonly name: string; | ||
|
||
constructor(raw_member_info: {}) { | ||
this.type = raw_member_info['idlType']['idlType']; | ||
this.name = raw_member_info['name']; | ||
} | ||
} | ||
|
||
export default class IDLDictionary extends IDLDefinition { | ||
readonly members: DictionaryMember[]; | ||
|
||
constructor(raw_idl_dic_info: {}) { | ||
super(raw_idl_dic_info['name'], raw_idl_dic_info); | ||
|
||
this.members = []; | ||
|
||
raw_idl_dic_info['members'].forEach(raw_member_info => { | ||
this.members.push(new DictionaryMember(raw_member_info)); | ||
}); | ||
} | ||
|
||
render(): void { | ||
// TODO(zino): We should implement this function. | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright (c) 2017 The Bacardi Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef GEN_DICTIONARY_{{name | snakecase | upper}}_H_ | ||
#define GEN_DICTIONARY_{{name | snakecase | upper}}_H_ | ||
|
||
class {{name}} { | ||
public: | ||
{% for member in members %} | ||
{{member.type}} {{member.name}}() const { | ||
return {{member.name}}_; | ||
} | ||
void set{{member.name | pascalcase}}({{member.type}} {{member.name}}) { | ||
{{member.name}}_ = {{member.name}}; | ||
} | ||
{% endfor %} | ||
private: | ||
{% for member in members %} | ||
{{member.type}} {{member.name}}_; | ||
{% endfor %} | ||
}; | ||
|
||
#endif // GEN_DICTIONARY_{{name | snakecase | upper}}_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Copyright (c) 2017 The Bacardi Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import * as bindings from 'bindings'; | ||
|
||
const bacardi = bindings('bacardi.node'); | ||
|
||
test( | ||
'Test call function which take dictionaries type as parameter', | ||
async () => { | ||
let test_interface = new bacardi.TestInterface(); | ||
|
||
var testDict = {a: 10}; | ||
test_interface.voidMethodTestDictionaryArg(testDict); | ||
expect(bacardi.TestInterface.getLastCallInfo()) | ||
.toBe('VoidMethodTestDictionaryArg()'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters