Skip to content

Commit

Permalink
feat(ClassHierarchy): hierarchy subclasses Array
Browse files Browse the repository at this point in the history
  • Loading branch information
floryst committed Jun 23, 2021
1 parent a815919 commit 9f5e34c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Sources/Common/Core/ClassHierarchy/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default class ClassHierarchy extends Array {
push(...args) {
// no perf issue since args.length should be small
const newArgs = args.filter((arg) => !this.includes(arg));
return super.push(...newArgs);
}
}
8 changes: 7 additions & 1 deletion Sources/macro.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import vtk from './vtk';
import ClassHierarchy from './Common/Core/ClassHierarchy';

let globalMTime = 0;

Expand Down Expand Up @@ -214,7 +215,12 @@ export function obj(publicAPI = {}, model = {}) {
if (!Number.isInteger(model.mtime)) {
model.mtime = ++globalMTime;
}
model.classHierarchy = ['vtkObject'];

if (!('classHierarchy' in model)) {
model.classHierarchy = new ClassHierarchy('vtkObject');
} else if (!(model.classHierarchy instanceof ClassHierarchy)) {
model.classHierarchy = ClassHierarchy.from(model.classHierarchy);
}

function off(index) {
callbacks[index] = null;
Expand Down

0 comments on commit 9f5e34c

Please sign in to comment.