-- Mapper.mesa
-- Last changed by Doug Wyatt, September 4, 1980 9:11 AM
DIRECTORY
Vector USING [Vec, Matrix];
Mapper: DEFINITIONS = {
Handle: TYPE = LONG POINTER TO Object;
Vec: TYPE = Vector.Vec;
Matrix: TYPE = Vector.Matrix;
-- Client interface for a Mapper
NewMapper: PROC[] RETURNS[Handle];
Map: PROC[self: Handle, v: Vec] RETURNS[Vec] = INLINE {
self.procs.Map[self,@v,TRUE]; RETURN[v]
};
MapDelta: PROC[self: Handle, v: Vec] RETURNS[Vec] = INLINE {
self.procs.Map[self,@v,FALSE]; RETURN[v]
};
InverseMap: PROC[self: Handle, v: Vec] RETURNS[Vec] = INLINE {
self.procs.InverseMap[self,@v,TRUE]; RETURN[v]
};
InverseMapDelta: PROC[self: Handle, v: Vec] RETURNS[Vec] = INLINE {
self.procs.InverseMap[self,@v,FALSE]; RETURN[v]
};
Translate: PROC[self: Handle, v: Vec] = INLINE {
self.procs.Translate[self,@v]
};
Concat: PROC[self: Handle, m: Matrix] = INLINE {
self.procs.Concat[self,@m]
};
Ortho: PROC[self: Handle] RETURNS[BOOLEAN] = INLINE {
RETURN[self.procs.Ortho[self]]
};
Read: PROC[self: Handle] RETURNS[m: Matrix, v: Vec] = INLINE {
self.procs.Read[self,@m,@v]; RETURN[m,v]
};
Copy: PROC[self: Handle] RETURNS[Handle] = INLINE {
RETURN[self.procs.Copy[self]]
};
Free: PROC[selfPtr: LONG POINTER TO Handle] = INLINE {
IF selfPtr↑#NIL THEN selfPtr↑.procs.Free[selfPtr]
};
-- Actual representation for a Mapper interface
Object: PRIVATE TYPE = RECORD [
procs: LONG POINTER TO READONLY Procs,
data: LONG POINTER TO Data
];
Procs: PRIVATE TYPE = RECORD [
Map: PROC[self: Handle, v: POINTER TO Vec, t: BOOLEAN],
InverseMap: PROC[self: Handle, v: POINTER TO Vec, t: BOOLEAN],
Translate: PROC[self: Handle, v: POINTER TO Vec],
Concat: PROC[self: Handle, m: POINTER TO Matrix],
Ortho: PROC[self: Handle] RETURNS[BOOLEAN],
Read: PROC[self: Handle,
m: POINTER TO Matrix, v: POINTER TO Vec],
Copy: PROC[self: Handle] RETURNS[Handle],
Free: PROC[selfPtr: LONG POINTER TO Handle]
];
Data: PRIVATE TYPE;
MapperImpl: PROGRAM;
}.