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

refactor: drop usage of dummy arguments for multi-inheritance #54

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ui/components/abstract/ScriptObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class ScriptObject extends FrameScriptObject {

_name: string | null;

constructor(_dummy: unknown) {
super(_dummy);
constructor(..._args: unknown[]) {
super(..._args);

this._name = null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ui/components/abstract/ScriptRegion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class ScriptRegion extends multipleClasses(ScriptObject, LayoutFrame) {

_parent: Frame | null;

constructor(_dummy: unknown) {
super(_dummy);
constructor(..._args: unknown[]) {
super(_args);

this._parent = null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ui/components/simple/Frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Frame extends ScriptRegion {
strataLink: LinkedListLink<this>;

constructor(parent: Frame | null) {
super(null);
super();

this.id = 0;
this.flags = 0;
Expand Down Expand Up @@ -189,7 +189,7 @@ class Frame extends ScriptRegion {
}
}

// TODO: Seems to be necessary with split getter/setters + inheritance
// Note: Seems to be necessary with split getter/setters + inheritance
get parent() {
return this._parent;
}
Expand Down
8 changes: 5 additions & 3 deletions src/ui/components/simple/Region.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { LinkedListLink } from '../../../utils';

import Frame from './Frame';

abstract class Region extends ScriptRegion {
class Region extends ScriptRegion {
drawLayerType: DrawLayerType | null;
shown: boolean;
visible: boolean;
Expand All @@ -17,7 +17,7 @@ abstract class Region extends ScriptRegion {
regionLink: LinkedListLink<this>;

constructor(frame: Frame, drawLayerType: DrawLayerType, show: boolean) {
super(null);
super();

this.drawLayerType = null;
this.shown = false;
Expand All @@ -34,7 +34,9 @@ abstract class Region extends ScriptRegion {
}
}

abstract draw(_batch: RenderBatch): void;
draw(_batch: RenderBatch) {
throw new Error(`${this.constructor.name} must implement 'draw'`);
}

onRegionChanged() {
// TODO: Implementation
Expand Down
2 changes: 1 addition & 1 deletion src/ui/scripting/FrameScriptObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class FrameScriptObject {
luaRef: lua_Ref | null;
scripts: ScriptRegistry;

constructor(_dummy: unknown) {
constructor(..._args: unknown[]) {
this.luaRef = null;

this.scripts = new ScriptRegistry();
Expand Down
4 changes: 2 additions & 2 deletions src/utils/inheritance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const multipleClasses = <
}

const cls = class extends base {
constructor(..._args: any[]) {
constructor(...args: any[]) {
// Create an instance of the base class
super();
super(...args);

// Construct temporary throw-away instance of other class and assign own properties
// Warning: using `this` as a reference in other class' constructor will not work correctly
Expand Down
Loading