Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
fix Variant type generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Niels-Be committed Mar 20, 2020
1 parent 0f05e74 commit f4d7fe6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions bin/generate-client-interfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ const helpers = {
if (a == b) { return options.fn(this); }
return options.inverse(this);
},
unlesseq(a, b, options) {
if (a != b) { return options.fn(this); }
return options.inverse(this);
},

tsType: tsType,
outType(args) {
Expand Down
8 changes: 4 additions & 4 deletions templates/javascript-class.js.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ export class {{className $.name}} extends EventEmitter {
{{#each property}}
//@property({ name: '{{$.name}}', signature: '{{$.type}}', access: {{accessConst $.access}} }){{#ifeq $.access "read"}}
{{$.name}}() {
return this.propertiesDBusInterface.Get(this.dbusInterfaceName, '{{$.name}}');
return this.propertiesDBusInterface.Get(this.dbusInterfaceName, '{{$.name}}'){{#unlesseq $.type "v"}}.then((variant) => variant.value){{/unlesseq}};
}{{/ifeq}}{{#ifeq $.access "write"}}
{{$.name}}(value) {
return this.propertiesDBusInterface.Set(this.dbusInterfaceName, '{{$.name}}', value);
return this.propertiesDBusInterface.Set(this.dbusInterfaceName, '{{$.name}}', {{#ifeq $.type "v"}}value{{else}}new DBus.Variant("{{$.type}}", value){{/ifeq}});
}{{/ifeq}}{{#ifeq $.access "readwrite"}}
{{$.name}}(value) {
if(value !== undefined) {
return this.propertiesDBusInterface.Set(this.dbusInterfaceName, '{{$.name}}', value);
return this.propertiesDBusInterface.Set(this.dbusInterfaceName, '{{$.name}}', {{#ifeq $.type "v"}}value{{else}}new DBus.Variant("{{$.type}}", value){{/ifeq}});
} else {
return this.propertiesDBusInterface.Get(this.dbusInterfaceName, '{{$.name}}');
return this.propertiesDBusInterface.Get(this.dbusInterfaceName, '{{$.name}}'){{#unlesseq $.type "v"}}.then((variant) => variant.value){{/unlesseq}};
}
}{{/ifeq}}

Expand Down
8 changes: 4 additions & 4 deletions templates/typescript-class.ts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ export class {{className $.name}} extends EventEmitter {
{{#each property}}
//@property({ name: '{{$.name}}', signature: '{{$.type}}', access: {{accessConst $.access}} }){{#ifeq $.access "read"}}
public {{$.name}}(): Promise<{{tsType $.type}}> {
return this.propertiesDBusInterface.Get(this.dbusInterfaceName, '{{$.name}}');
return this.propertiesDBusInterface.Get(this.dbusInterfaceName, '{{$.name}}'){{#unlesseq $.type "v"}}.then((variant) => variant.value){{/unlesseq}};
}{{/ifeq}}{{#ifeq $.access "write"}}
public {{$.name}}(value: {{tsType $.type}}): Promise<void> {
return this.propertiesDBusInterface.Set(this.dbusInterfaceName, '{{$.name}}', value);
return this.propertiesDBusInterface.Set(this.dbusInterfaceName, '{{$.name}}', {{#ifeq $.type "v"}}value{{else}}new DBus.Variant("{{$.type}}", value){{/ifeq}});
}{{/ifeq}}{{#ifeq $.access "readwrite"}}
public {{$.name}}(): Promise<{{tsType $.type}}>;
public {{$.name}}(value: {{tsType $.type}}): Promise<void>;
public {{$.name}}(value?: {{tsType $.type}}): Promise<any> {
if(value !== undefined) {
return this.propertiesDBusInterface.Set(this.dbusInterfaceName, '{{$.name}}', value);
return this.propertiesDBusInterface.Set(this.dbusInterfaceName, '{{$.name}}', {{#ifeq $.type "v"}}value{{else}}new DBus.Variant("{{$.type}}", value){{/ifeq}});
} else {
return this.propertiesDBusInterface.Get(this.dbusInterfaceName, '{{$.name}}');
return this.propertiesDBusInterface.Get(this.dbusInterfaceName, '{{$.name}}'){{#unlesseq $.type "v"}}.then((variant) => variant.value){{/unlesseq}};
}
}{{/ifeq}}

Expand Down

0 comments on commit f4d7fe6

Please sign in to comment.