Skip to content

Commit

Permalink
records
Browse files Browse the repository at this point in the history
  • Loading branch information
azahnen committed Jan 2, 2025
1 parent 7dbe734 commit 1d593e4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
4 changes: 2 additions & 2 deletions libxtracfg/js/types/generate-java-classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public abstract class Handler<T extends Handler.Context, U extends Handler.Conte
return notConnected();
}
${result} result = handle(new ${initCommand}(command.getOptions()), false, ignore -> {});
${result} result = handle(new ${initCommand}(command.options()), false, ignore -> {});
if (result instanceof ${failure}) {
return result;
Expand All @@ -155,7 +155,7 @@ public abstract class Handler<T extends Handler.Context, U extends Handler.Conte
}

code += `
return new ${failure}("Unknown command: " + command.getCommand());
return new ${failure}("Unknown command: " + command.command());
}
}
`;
Expand Down
28 changes: 21 additions & 7 deletions libxtracfg/js/types/java/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public record ${name}(`;
let i = 0;
for (const [key, entry] of props) {
i++;
/*if (isConst(entry)) {
if (isConst(entry)) {
continue;
}*/
}
const comma = i <= Object.keys(properties).length - 1 ? "," : "";
code += `
${getType(entry, suffixNs)} ${key}${comma}`;
Expand All @@ -40,9 +40,9 @@ public ${name}(`;
let j = 0;
for (const [key, entry] of props) {
j++;
/*if (isConst(entry)) {
if (isConst(entry)) {
continue;
}*/
}
const comma = j <= Object.keys(properties).length - 1 ? "," : "";
code += `
${getType(entry, suffixNs)} ${key}${comma}`;
Expand All @@ -52,8 +52,8 @@ public ${name}(`;
) {`;
for (const [key, entry] of props) {
if (isConst(entry)) {
code += `
this.${key} = ${getValue(entry)};`;
/*code += `
this.${key} = ${getValue(entry)};`;*/
continue;
}
if (Object.hasOwn(entry, "default")) {
Expand All @@ -68,10 +68,24 @@ public ${name}(`;
}

code += `
}
}
`;

for (const [key, entry] of props) {
if (isConst(entry)) {
code += `
public ${getType(entry, suffixNs)} ${key}() {
return ${getValue(entry)};
}
`;
}
}

code += `
}
`;

return code;
};

Expand Down
8 changes: 4 additions & 4 deletions libxtracfg/js/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,18 @@ export namespace Command {
*/
export class Connect extends Base {
declare readonly command: Enums.Main.Connect;
declare readonly options: Options.Options;
declare readonly options: Options.Base;

constructor(options: Options.Options = {}) {
constructor(options: Options.Base = {}) {
super(Enums.Main.Connect, options);
}
}

export class Info extends Base {
declare readonly command: Enums.Main.Info;
declare readonly options: Options.Options;
declare readonly options: Options.Base;

constructor(options: Options.Options = {}) {
constructor(options: Options.Base = {}) {
super(Enums.Main.Info, options);
}
}
Expand Down

0 comments on commit 1d593e4

Please sign in to comment.