diff --git a/package.json b/package.json index 287c8eb..36d0dfa 100644 --- a/package.json +++ b/package.json @@ -60,8 +60,8 @@ "autogypi": "~0.2.2", "cbuild": "~0.1.1", "node-gyp": "^3.4.0", - "tap": "^8.0.0", - "tslint": "^3.15.1", - "typescript": "^2.0.8" + "tap": "^8.0.1", + "tslint": "^4.0.2", + "typescript": "^2.0.10" } } diff --git a/src/Type.ts b/src/Type.ts index 9a8a115..729a7af 100644 --- a/src/Type.ts +++ b/src/Type.ts @@ -1,7 +1,7 @@ // This file is part of nbind, copyright (C) 2014-2016 BusFaster Ltd. // Released under the MIT license, see LICENSE. -export var { +export const { Type, makeType, structureList } = typeModule(typeModule); @@ -94,7 +94,7 @@ export const enum StateFlags { none = 0, isPersistent = 1, - isDeleted = 2, + isDeleted = 2 } // These must match C++ enum StructureType in TypeID.h diff --git a/src/em/BindClass.ts b/src/em/BindClass.ts index d8b4aaa..61e1c40 100644 --- a/src/em/BindClass.ts +++ b/src/em/BindClass.ts @@ -15,25 +15,25 @@ import {TypeFlags, TypeSpecWithName, TypeSpecWithParam, PolicyTbl} from '../Type setEvil((code: string) => eval(code)); export namespace _nbind { - export var BindType = _type.BindType; - export var Wrapper = _wrapper.Wrapper; + export const BindType = _type.BindType; + export const Wrapper = _wrapper.Wrapper; } export namespace _nbind { - export var addMethod: typeof _globals.addMethod; - export var getType: typeof _globals.getType; + export let addMethod: typeof _globals.addMethod; + export let getType: typeof _globals.getType; - export var pushValue: typeof _value.pushValue; - export var popValue: typeof _value.popValue; + export let pushValue: typeof _value.pushValue; + export let popValue: typeof _value.popValue; - export var resources: typeof _resource.resources; + export let resources: typeof _resource.resources; - export var makeCaller: typeof _caller.makeCaller; - export var makeMethodCaller: typeof _caller.makeMethodCaller; + export let makeCaller: typeof _caller.makeCaller; + export let makeMethodCaller: typeof _caller.makeMethodCaller; type Wrapper = _wrapper.Wrapper; - export var makeBound: typeof _wrapper.makeBound; + export let makeBound: typeof _wrapper.makeBound; // Any subtype (not instance but type) of Wrapper. // Declared as anything that constructs something compatible with Wrapper. @@ -46,7 +46,7 @@ export namespace _nbind { export const ptrMarker = {}; - export var callUpcast: (upcast: number, ptr: number) => number; + export let callUpcast: (upcast: number, ptr: number) => number; export interface MethodSpec { name: string; diff --git a/src/em/BindingStd.ts b/src/em/BindingStd.ts index ebd82ae..3d0db6a 100644 --- a/src/em/BindingStd.ts +++ b/src/em/BindingStd.ts @@ -14,13 +14,13 @@ import {TypeSpecWithParam, PolicyTbl} from '../Type'; setEvil((code: string) => eval(code)); export namespace _nbind { - export var Pool = _globals.Pool; - export var BindType = _type.BindType; + export const Pool = _globals.Pool; + export const BindType = _type.BindType; } export namespace _nbind { - export var resources: typeof _resource.resources; + export let resources: typeof _resource.resources; export function pushArray(arr: any[], type: ArrayType) { if(!arr) return(0); diff --git a/src/em/BindingType.ts b/src/em/BindingType.ts index 368b133..5103261 100644 --- a/src/em/BindingType.ts +++ b/src/em/BindingType.ts @@ -20,9 +20,9 @@ export namespace _nbind { export const { Type, makeType, getComplexType } = _typeModule(_typeModule); - export var Pool: typeof _globals.Pool; + export let Pool: typeof _globals.Pool; - export var resources: typeof _resource.resources; + export let resources: typeof _resource.resources; // A type definition, which registers itself upon construction. diff --git a/src/em/Buffer.ts b/src/em/Buffer.ts index d96255e..88c2af1 100644 --- a/src/em/Buffer.ts +++ b/src/em/Buffer.ts @@ -12,16 +12,16 @@ import {PolicyTbl} from '../Type'; setEvil((code: string) => eval(code)); export namespace _nbind { - export var Pool = _globals.Pool; - export var BindType = _type.BindType; - export var External = _external.External; + export const Pool = _globals.Pool; + export const BindType = _type.BindType; + export const External = _external.External; } export namespace _nbind { - export var externalList: typeof _external.externalList; + export let externalList: typeof _external.externalList; - export var resources: typeof _resource.resources; + export let resources: typeof _resource.resources; class ExternalBuffer extends External< number[] | ArrayBuffer | DataView | Uint8Array | Buffer diff --git a/src/em/Callback.ts b/src/em/Callback.ts index 93c4010..976b4c2 100644 --- a/src/em/Callback.ts +++ b/src/em/Callback.ts @@ -20,21 +20,21 @@ import {_nbind as _external} from './External'; setEvil((code: string) => eval(code)); export namespace _nbind { - export var BindType = _type.BindType; - export var External = _external.External; + export const BindType = _type.BindType; + export const External = _external.External; } export namespace _nbind { - export var readTypeIdList: typeof _globals.readTypeIdList; - export var throwError: typeof _globals.throwError; + export let readTypeIdList: typeof _globals.readTypeIdList; + export let throwError: typeof _globals.throwError; - export var makeJSCaller: typeof _caller.makeJSCaller; + export let makeJSCaller: typeof _caller.makeJSCaller; // List of invoker functions for all argument and return value combinations // seen so far. - export var callbackSignatureList: _globals.Func[] = []; + export let callbackSignatureList: _globals.Func[] = []; export class CallbackType extends BindType { wireWrite = (func: _globals.Func) => { diff --git a/src/em/Caller.ts b/src/em/Caller.ts index 4b43db5..f2725f0 100644 --- a/src/em/Caller.ts +++ b/src/em/Caller.ts @@ -26,15 +26,15 @@ export namespace _nbind { type FuncList = _globals.FuncList; type TypeIdList = _globals.TypeIdList; - export var getTypes: typeof _globals.getTypes; - export var getDynCall: typeof _globals.getDynCall; + export let getTypes: typeof _globals.getTypes; + export let getDynCall: typeof _globals.getDynCall; - export var pushPointer: typeof _class.pushPointer; + export let pushPointer: typeof _class.pushPointer; - export var externalList: _external.External[]; + export let externalList: _external.External[]; - export var listResources: typeof _resource.listResources; - export var resources: typeof _resource.resources; + export let listResources: typeof _resource.listResources; + export let resources: typeof _resource.resources; /** Make a list of argument names a1, a2, a3... * for dynamically generating function source code. */ diff --git a/src/em/External.ts b/src/em/External.ts index 031a6cc..d3545a6 100644 --- a/src/em/External.ts +++ b/src/em/External.ts @@ -17,7 +17,7 @@ import {_nbind as _type} from './BindingType'; setEvil((code: string) => eval(code)); export namespace _nbind { - export var BindType = _type.BindType; + export const BindType = _type.BindType; } export namespace _nbind { @@ -28,7 +28,7 @@ export namespace _nbind { // The first element is a dummy value just so that a valid index to // the list always tests as true (useful for the free list implementation). - export var externalList: (External | number)[] = [0]; + export let externalList: (External | number)[] = [0]; // Head of free list for recycling available slots in the externals list. let firstFreeExternal = 0; diff --git a/src/em/GC.ts b/src/em/GC.ts index 11f7b62..3046048 100644 --- a/src/em/GC.ts +++ b/src/em/GC.ts @@ -31,7 +31,7 @@ export namespace _nbind { } // tslint:disable-next-line:no-empty - export var mark = (obj: Wrapper) => {}; + export let mark = (obj: Wrapper) => {}; export function toggleLightGC(enable: boolean) { if(enable) { diff --git a/src/em/Globals.ts b/src/em/Globals.ts index d551520..29fbec8 100644 --- a/src/em/Globals.ts +++ b/src/em/Globals.ts @@ -25,13 +25,13 @@ export namespace _nbind { export type Invoker = (ptr: number, ...args: any[]) => any; export type TypeIdList = (number | string)[]; - export var BindType: typeof _type.BindType; - export var getComplexType: typeof _type.getComplexType; + export let BindType: typeof _type.BindType; + export let getComplexType: typeof _type.getComplexType; - export var resources: typeof _resource.resources; - export var listResources: typeof _resource.listResources; + export let resources: typeof _resource.resources; + export let listResources: typeof _resource.listResources; - export var makeOverloader: typeof _caller.makeOverloader; + export let makeOverloader: typeof _caller.makeOverloader; // Mapping from numeric typeIDs and type names to objects with type information. @@ -77,8 +77,8 @@ export namespace _nbind { } type TypeConstructor = { new(spec: TypeSpecWithName): _type.BindType }; - export var makeTypeKindTbl: { [flags: number]: TypeConstructor }; - export var makeTypeNameTbl: { [name: string]: TypeConstructor }; + export let makeTypeKindTbl: { [flags: number]: TypeConstructor }; + export let makeTypeNameTbl: { [name: string]: TypeConstructor }; export function constructType(kind: TypeFlags, spec: TypeSpecWithName) { const construct = ( @@ -224,7 +224,7 @@ export namespace _nbind { throw(new Error(message)); } - export var bigEndian = false; + export let bigEndian = false; // Export the namespace to Emscripten compiled output. // This must be at the end of the namespace! diff --git a/src/em/Resource.ts b/src/em/Resource.ts index 597542f..8ae9fc7 100644 --- a/src/em/Resource.ts +++ b/src/em/Resource.ts @@ -57,7 +57,7 @@ export namespace _nbind { return(result); } - export var resources = { + export const resources = { pool: new Resource( 'var used=HEAPU32[_nbind.Pool.usedPtr],page=HEAPU32[_nbind.Pool.pagePtr];', '_nbind.Pool.lreset(used,page);' diff --git a/src/em/ValueObj.ts b/src/em/ValueObj.ts index a495424..4d297b8 100644 --- a/src/em/ValueObj.ts +++ b/src/em/ValueObj.ts @@ -24,17 +24,17 @@ setEvil((code: string) => eval(code)); const _defineHidden = defineHidden; export namespace _nbind { - export var BindType = _type.BindType; + export const BindType = _type.BindType; } export namespace _nbind { - export var popShared: typeof _class.popShared; + export let popShared: typeof _class.popShared; type BindClassPtr = _class.BindClassPtr; - export var throwError: typeof _globals.throwError; - export var typeNameTbl: typeof _globals.typeNameTbl; - export var bigEndian: typeof _globals.bigEndian; + export let throwError: typeof _globals.throwError; + export let typeNameTbl: typeof _globals.typeNameTbl; + export let bigEndian: typeof _globals.bigEndian; export interface ValueObject { fromJS(output: (...args: any[]) => void): void; diff --git a/src/em/Wrapper.ts b/src/em/Wrapper.ts index fc34382..d647290 100644 --- a/src/em/Wrapper.ts +++ b/src/em/Wrapper.ts @@ -19,9 +19,9 @@ const _defineHidden = defineHidden; export namespace _nbind { - export var ptrMarker: typeof _class.ptrMarker; + export let ptrMarker: typeof _class.ptrMarker; - export var mark: typeof _gc.mark; + export let mark: typeof _gc.mark; /** Base class for wrapped instances of bound C++ classes. * Note that some hacks avoid ever constructing this, diff --git a/src/em/em-api.ts b/src/em/em-api.ts index d91f512..4ca7a2b 100644 --- a/src/em/em-api.ts +++ b/src/em/em-api.ts @@ -30,51 +30,49 @@ import {typeModule, TypeFlags, TypeSpecWithName} from '../Type'; setEvil((code: string) => eval(code)); const _removeAccessorPrefix = removeAccessorPrefix; - -// tslint:disable-next-line:no-unused-variable const _typeModule = typeModule; export namespace _nbind { - export var Pool: typeof _globals.Pool; - export var bigEndian: typeof _globals.bigEndian; + export let Pool: typeof _globals.Pool; + export let bigEndian: typeof _globals.bigEndian; - export var readTypeIdList: typeof _globals.readTypeIdList; - export var readAsciiString: typeof _globals.readAsciiString; - export var readPolicyList: typeof _globals.readPolicyList; - export var makeTypeKindTbl: typeof _globals.makeTypeKindTbl; - export var makeTypeNameTbl: typeof _globals.makeTypeNameTbl; - export var constructType: typeof _globals.constructType; - export var getType: typeof _globals.getType; - export var queryType: typeof _globals.queryType; + export let readTypeIdList: typeof _globals.readTypeIdList; + export let readAsciiString: typeof _globals.readAsciiString; + export let readPolicyList: typeof _globals.readPolicyList; + export let makeTypeKindTbl: typeof _globals.makeTypeKindTbl; + export let makeTypeNameTbl: typeof _globals.makeTypeNameTbl; + export let constructType: typeof _globals.constructType; + export let getType: typeof _globals.getType; + export let queryType: typeof _globals.queryType; - export var makeType: typeof _type.makeType; - export var getComplexType: typeof _type.getComplexType; - export var BindType: typeof _type.BindType; - export var PrimitiveType: typeof _type.PrimitiveType; - export var BooleanType: typeof _type.BooleanType; - export var CStringType: typeof _type.CStringType; + export let makeType: typeof _type.makeType; + export let getComplexType: typeof _type.getComplexType; + export let BindType: typeof _type.BindType; + export let PrimitiveType: typeof _type.PrimitiveType; + export let BooleanType: typeof _type.BooleanType; + export let CStringType: typeof _type.CStringType; - export var BindClass: typeof _class.BindClass; - export var BindClassPtr: typeof _class.BindClassPtr; - export var SharedClassPtr: typeof _class.BindClassPtr; - export var callUpcast: typeof _class.callUpcast; + export let BindClass: typeof _class.BindClass; + export let BindClassPtr: typeof _class.BindClassPtr; + export let SharedClassPtr: typeof _class.BindClassPtr; + export let callUpcast: typeof _class.callUpcast; - export var ExternalType: typeof _external.ExternalType; + export let ExternalType: typeof _external.ExternalType; - export var CallbackType: typeof _callback.CallbackType; + export let CallbackType: typeof _callback.CallbackType; - export var CreateValueType: typeof _value.CreateValueType; - export var Int64Type: typeof _value.Int64Type; - export var popValue: typeof _value.popValue; + export let CreateValueType: typeof _value.CreateValueType; + export let Int64Type: typeof _value.Int64Type; + export let popValue: typeof _value.popValue; - export var ArrayType: typeof _std.ArrayType; - export var StringType: typeof _std.StringType; + export let ArrayType: typeof _std.ArrayType; + export let StringType: typeof _std.StringType; - export var makeMethodCaller: typeof _caller.makeMethodCaller; + export let makeMethodCaller: typeof _caller.makeMethodCaller; - export var BufferType: typeof _buffer.BufferType; + export let BufferType: typeof _buffer.BufferType; - export var toggleLightGC: typeof _gc.toggleLightGC; + export let toggleLightGC: typeof _gc.toggleLightGC; } publishNamespace('_nbind'); @@ -114,13 +112,13 @@ class nbind { // tslint:disable-line:class-name }; _nbind.makeTypeNameTbl = { - 'bool': _nbind.BooleanType, - 'cbFunction &': _nbind.CallbackType, - 'std::string': _nbind.StringType, - 'External': _nbind.ExternalType, 'Buffer': _nbind.BufferType, + 'External': _nbind.ExternalType, 'Int64': _nbind.Int64Type, - '_nbind_new': _nbind.CreateValueType + '_nbind_new': _nbind.CreateValueType, + 'bool': _nbind.BooleanType, + 'cbFunction &': _nbind.CallbackType, + 'std::string': _nbind.StringType }; Module['toggleLightGC'] = _nbind.toggleLightGC; diff --git a/src/todts.ts b/src/todts.ts index 40841bc..8ddffbe 100644 --- a/src/todts.ts +++ b/src/todts.ts @@ -5,13 +5,13 @@ import {Reflect, BindType, BindClass, BindMethod, BindProperty} from './reflect' import {TypeFlags} from './Type'; const nameTbl: { [key: string]: [string, boolean] } = { - 'void': ['void', false], + 'Buffer': ['number[] | ArrayBuffer | DataView | Uint8Array | Buffer', true], + 'External': ['any', false], + 'Int64': ['number', false], // | Int64 (interface)? 'bool': ['boolean', false], 'cbFunction &': ['(...args: any[]) => any', true], 'std::string': ['string', false], - 'External': ['any', false], - 'Buffer': ['number[] | ArrayBuffer | DataView | Uint8Array | Buffer', true], - 'Int64': ['number', false] // | Int64 (interface)? + 'void': ['void', false] }; type PolicyTbl = { [key: string]: boolean }; diff --git a/src/tslint.json b/src/tslint.json index b6686df..04d1019 100644 --- a/src/tslint.json +++ b/src/tslint.json @@ -11,7 +11,6 @@ "interface-name": [ true, "never-prefix" ], "jsdoc-format": false, "label-position": true, - "label-undefined": true, "max-line-length": [ true, 96 ], "member-access": false, "member-ordering": [ true, { "order": [ @@ -38,10 +37,8 @@ "no-consecutive-blank-lines": true, "no-console": [ true, "log", "warn", "error" ], "no-construct": true, - "no-constructor-vars": true, "no-debugger": false, "no-default-export": true, - "no-duplicate-key": true, "no-duplicate-variable": true, "no-empty": true, "no-eval": false, @@ -56,9 +53,7 @@ "no-string-literal": false, "no-switch-case-fall-through": true, "no-trailing-whitespace": true, - "no-unreachable": true, "no-unused-expression": true, - "no-unused-variable": true, "no-use-before-declare": true, "no-var-keyword": true, "no-var-requires": true, @@ -80,7 +75,6 @@ { "call-signature": "onespace", "index-signature": "onespace", "parameter": "onespace", "property-declaration": "onespace", "variable-declaration": "onespace" } ], "use-isnan": true, - "use-strict": false, "variable-name": [ true, "check-format", "allow-leading-underscore", "allow-pascal-case" ], "whitespace": [ true, "check-decl", "check-operator", "check-module", "check-separator", "check-type", "check-typecast" ] }