Skip to content

Commit

Permalink
fix(vector-pools): fix regression/update buffer arg types
Browse files Browse the repository at this point in the history
- switch from Vec => NumericArray for backing buffers
  • Loading branch information
postspectacular committed Feb 1, 2021
1 parent b20a3dd commit 27a3614
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
7 changes: 4 additions & 3 deletions packages/vector-pools/src/alist.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { wrap } from "./wrap";
import type { NumericArray } from "@thi.ng/api";
import type { StridedVec, Vec } from "@thi.ng/vectors";
import type { VecFactory } from "./api";
import { wrap } from "./wrap";

export abstract class AVecList<T extends StridedVec> {
buffer: Vec;
buffer: NumericArray;
factory: VecFactory;

start: number;
Expand All @@ -26,7 +27,7 @@ export abstract class AVecList<T extends StridedVec> {
* @param factory -
*/
constructor(
buffer: Vec,
buffer: NumericArray,
capacity: number,
size: number,
start = 0,
Expand Down
5 changes: 3 additions & 2 deletions packages/vector-pools/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import {
IObjectOf,
IRelease,
NULL_LOGGER,
NumericArray,
Type,
TypedArray,
} from "@thi.ng/api";
import type { MemPool, MemPoolOpts } from "@thi.ng/malloc";
import type { ReadonlyVec, StridedVec, Vec } from "@thi.ng/vectors";
import type { ReadonlyVec, StridedVec } from "@thi.ng/vectors";

export interface AttribSpec {
type: GLType | Type;
Expand Down Expand Up @@ -50,7 +51,7 @@ export interface IVecPool extends IRelease {
}

export type VecFactory = (
buf: Vec,
buf: NumericArray,
size: number,
index: number,
stride: number
Expand Down
5 changes: 3 additions & 2 deletions packages/vector-pools/src/array-list.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { NumericArray } from "@thi.ng/api";
import type { StridedVec } from "@thi.ng/vectors";
import { AVecList } from "./alist";
import type { StridedVec, Vec } from "@thi.ng/vectors";
import type { VecFactory } from "./api";

export class VecArrayList<T extends StridedVec> extends AVecList<T> {
Expand All @@ -15,7 +16,7 @@ export class VecArrayList<T extends StridedVec> extends AVecList<T> {
* @param start -
*/
constructor(
buffer: Vec,
buffer: NumericArray,
capacity: number,
size: number,
start = 0,
Expand Down
5 changes: 3 additions & 2 deletions packages/vector-pools/src/linked-list.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { NumericArray } from "@thi.ng/api";
import type { StridedVec } from "@thi.ng/vectors";
import { AVecList } from "./alist";
import type { StridedVec, Vec } from "@thi.ng/vectors";
import type { VecFactory } from "./api";

interface Cell<T extends StridedVec> {
Expand Down Expand Up @@ -29,7 +30,7 @@ export class VecLinkedList<T extends StridedVec> extends AVecList<T> {
*/
constructor(
closed: boolean,
buffer: Vec,
buffer: NumericArray,
capacity: number,
size: number,
start = 0,
Expand Down
5 changes: 3 additions & 2 deletions packages/vector-pools/src/wrap.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { gvec, IVector, Vec, Vec2, Vec3, Vec4 } from "@thi.ng/vectors";
import type { NumericArray } from "@thi.ng/api";
import { gvec, IVector, Vec2, Vec3, Vec4 } from "@thi.ng/vectors";

export const wrap = (
buf: Vec,
buf: NumericArray,
size: number,
idx: number,
stride: number
Expand Down

0 comments on commit 27a3614

Please sign in to comment.