forked from lkesteloot/turbopascal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNative.js
25 lines (20 loc) · 774 Bytes
/
Native.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Tracks a list of native functions that can be called from Pascal.
if (typeof define !== 'function') { var define = require('amdefine')(module) };
define(function () {
var Native = function () {
// List of NativeProcedure objects. The index within the array is the
// number passed to the "CSP" instruction.
this.nativeProcedures = [];
};
// Adds a native method, returning its index.
Native.prototype.add = function (nativeProcedure) {
var index = this.nativeProcedures.length;
this.nativeProcedures.push(nativeProcedure);
return index;
};
// Get a native method by index.
Native.prototype.get = function (index) {
return this.nativeProcedures[index];
};
return Native;
});