From ec2915345b5e5bd7817c09b6094810d3f26ffc6c Mon Sep 17 00:00:00 2001 From: dencap Date: Mon, 16 Nov 2015 15:15:58 +0100 Subject: [PATCH] Removed long.js files from folder bytebuffer, fixed some function signatures and updated the version of long available in folder long --- bytebuffer/bytebuffer.d.ts | 2 +- long/long-tests.ts | 2 +- long/long.d.ts | 405 +++++++++++++++++++++++++++++++------ 3 files changed, 343 insertions(+), 66 deletions(-) diff --git a/bytebuffer/bytebuffer.d.ts b/bytebuffer/bytebuffer.d.ts index bf1251e5f6..0bfaed7c16 100644 --- a/bytebuffer/bytebuffer.d.ts +++ b/bytebuffer/bytebuffer.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped // Definitions by: SINTEF-9012 -/// +/// declare class ByteBuffer { diff --git a/long/long-tests.ts b/long/long-tests.ts index f70835f662..928cc94530 100644 --- a/long/long-tests.ts +++ b/long/long-tests.ts @@ -2,7 +2,7 @@ import Long = require("long"); -var val: dcodeIO.Long; +var val: Long; var n: number = 42; var b: boolean = true; var s: string = "1337"; diff --git a/long/long.d.ts b/long/long.d.ts index 32d773b9d1..f059ff5656 100644 --- a/long/long.d.ts +++ b/long/long.d.ts @@ -1,75 +1,352 @@ -// Type definitions for Long.js v2.2.5 -// Project: https://github.com/dcodeIO/Long.js -// Definitions by: Peter Kooijmans +// Type definitions for long.js 3.0.2 +// Project: https://github.com/dcodeIO/long.js +// Definitions by: Denis Cappellin // Definitions: https://github.com/borisyankov/DefinitelyTyped +// Definitions by: Peter Kooijmans -declare module dcodeIO { - interface LongStatic { - new (low: number, high?: number, unsigned?: boolean): Long; +declare class Long +{ + /** + * Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as signed integers. See the from* functions below for more convenient ways of constructing Longs. + */ + constructor( low: number, high?: number, unsigned?: boolean ); - MAX_UNSIGNED_VALUE: Long; - MAX_VALUE: Long; - MIN_VALUE: Long; - NEG_ONE: Long; - ONE: Long; - UONE: Long; - UZERO: Long; - ZERO: Long; + /** + * Maximum unsigned value. + */ + static MAX_UNSIGNED_VALUE: Long; - fromBits(lowBits: number, highBits: number, unsigned?: boolean): Long; - fromInt(value: number, unsigned?: boolean): Long; - fromNumber(value: number, unsigned?: boolean): Long; - fromString(str: string, unsigned?: boolean | number, radix?: number): Long; - fromValue(val: Long | number | string): Long; - isLong(obj: any): boolean; - } + /** + * Maximum signed value. + */ + static MAX_VALUE: Long; - interface Long { - high: number; - low: number; - unsigned: boolean; + /** + * Minimum signed value. + */ + static MIN_VALUE: Long; - add(other: Long | number | string): Long; - and(other: Long | number | string): Long; - compare(other: Long | number | string): number; - div(divisor: Long | number | string): Long; - equals(other: Long | number | string): boolean; - getHighBits(): number; - getHighBitsUnsigned(): number; - getLowBits(): number; - getLowBitsUnsigned(): number; - getNumBitsAbs(): number; - greaterThan(other: Long | number | string): boolean; - greaterThanOrEqual(other: Long | number | string): boolean; - isEven(): boolean; - isNegative(): boolean; - isOdd(): boolean; - isPositive(): boolean; - isZero(): boolean; - lessThan(other: Long | number | string): boolean; - lessThanOrEqual(other: Long | number | string): boolean; - modulo(divisor: Long | number | string): Long; - multiply(multiplier: Long | number | string): Long; - negate(): Long; - not(): Long; - notEquals(other: Long | number | string): boolean; - or(other: Long | number | string): Long; - shiftLeft(numBits: number | Long): Long; - shiftRight(numBits: number | Long): Long; - shiftRightUnsigned(numBits: number | Long): Long; - subtract(other: Long | number | string): Long; - toInt(): number; - toNumber(): number; - toSigned(): Long; - toString(radix?: number): string; - toUnsigned(): Long; - xor(other: Long | number | string): Long; - } + /** + * Signed negative one. + */ + static NEG_ONE: Long; - export var Long: LongStatic; + /** + * Signed one. + */ + static ONE: Long; + + /** + * Unsigned one. + */ + static UONE: Long; + + /** + * Unsigned zero. + */ + static UZERO: Long; + + /** + * Signed zero + */ + static ZERO: Long; + + /** + * The high 32 bits as a signed value. + */ + high: number; + + /** + * The low 32 bits as a signed value. + */ + low: number; + + /** + * Whether unsigned or not. + */ + unsigned: boolean; + + /** + * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is assumed to use 32 bits. + */ + static fromBits( lowBits:number, highBits:number, unsigned?:boolean ): Long; + + /** + * Returns a Long representing the given 32 bit integer value. + */ + static fromInt( value: number, unsigned?: boolean ): Long; + + /** + * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. + */ + static fromNumber( value: number, unsigned?: boolean ): Long; + + /** + * Returns a Long representation of the given string, written using the specified radix. + */ + static fromString( str: string, unsigned?: boolean | number, radix?: number ): Long; + + /** + * Tests if the specified object is a Long. + */ + static isLong( obj: any ): boolean; + + /** + * Converts the specified value to a Long. + */ + static fromValue( val: Long | number | string | {low: number, high: number, unsigned: boolean} ): Long; + + /** + * Returns the sum of this and the specified Long. + */ + add( addend: number | Long | string ): Long; + + /** + * Returns the bitwise AND of this Long and the specified. + */ + and( other: Long | number | string ): Long; + + /** + * Compares this Long's value with the specified's. + */ + compare( other: Long | number | string ): number; + + /** + * Compares this Long's value with the specified's. + */ + comp( other: Long | number | string ): number; + + /** + * Returns this Long divided by the specified. + */ + divide( divisor: Long | number | string ): Long; + + /** + * Returns this Long divided by the specified. + */ + div( divisor: Long | number | string ): Long; + + /** + * Tests if this Long's value equals the specified's. + */ + equals( other: Long | number | string ): boolean; + + /** + * Tests if this Long's value equals the specified's. + */ + eq( other: Long | number | string ): boolean; + + /** + * Gets the high 32 bits as a signed integer. + */ + getHighBits(): number; + + /** + * Gets the high 32 bits as an unsigned integer. + */ + getHighBitsUnsigned(): number; + + /** + * Gets the low 32 bits as a signed integer. + */ + getLowBits(): number; + + /** + * Gets the low 32 bits as an unsigned integer. + */ + getLowBitsUnsigned(): number; + + /** + * Gets the number of bits needed to represent the absolute value of this Long. + */ + getNumBitsAbs(): number; + + /** + * Tests if this Long's value is greater than the specified's. + */ + greaterThan( other: Long | number | string ): boolean; + + /** + * Tests if this Long's value is greater than the specified's. + */ + gt( other: Long | number | string ): boolean; + + /** + * Tests if this Long's value is greater than or equal the specified's. + */ + greaterThanOrEqual( other: Long | number | string ): boolean; + + /** + * Tests if this Long's value is greater than or equal the specified's. + */ + gte( other: Long | number | string ): boolean; + + /** + * Tests if this Long's value is even. + */ + isEven(): boolean; + + /** + * Tests if this Long's value is negative. + */ + isNegative(): boolean; + + /** + * Tests if this Long's value is odd. + */ + isOdd(): boolean; + + /** + * Tests if this Long's value is positive. + */ + isPositive(): boolean; + + /** + * Tests if this Long's value equals zero. + */ + isZero(): boolean; + + /** + * Tests if this Long's value is less than the specified's. + */ + lessThan( other: Long | number | string ): boolean; + + /** + * Tests if this Long's value is less than the specified's. + */ + lt( other: Long | number | string ): boolean; + + /** + * Tests if this Long's value is less than or equal the specified's. + */ + lessThanOrEqual( other: Long | number | string ): boolean; + + /** + * Tests if this Long's value is less than or equal the specified's. + */ + lte( other: Long | number | string ): boolean; + + /** + * Returns this Long modulo the specified. + */ + modulo( other: Long | number | string ): Long; + + /** + * Returns this Long modulo the specified. + */ + mod( other: Long | number | string ): Long; + + /** + * Returns the product of this and the specified Long. + */ + multiply( multiplier: Long | number | string ): Long; + + /** + * Returns the product of this and the specified Long. + */ + mul( multiplier: Long | number | string ): Long; + + /** + * Negates this Long's value. + */ + negate(): Long; + + /** + * Negates this Long's value. + */ + neg(): Long; + + /** + * Returns the bitwise NOT of this Long. + */ + not(): Long; + + /** + * Tests if this Long's value differs from the specified's. + */ + notEquals( other: Long | number | string ): boolean; + + /** + * Tests if this Long's value differs from the specified's. + */ + neq( other: Long | number | string ): boolean; + + /** + * Returns the bitwise OR of this Long and the specified. + */ + or( other: Long | number | string ): Long; + + /** + * Returns this Long with bits shifted to the left by the given amount. + */ + shiftLeft( numBits: number | Long ): Long; + + /** + * Returns this Long with bits shifted to the left by the given amount. + */ + shl( numBits: number | Long ): Long; + + /** + * Returns this Long with bits arithmetically shifted to the right by the given amount. + */ + shiftRight( numBits: number | Long ): Long; + + /** + * Returns this Long with bits arithmetically shifted to the right by the given amount. + */ + shr( numBits: number | Long ): Long; + + /** + * Returns this Long with bits logically shifted to the right by the given amount. + */ + shiftRightUnsigned( numBits: number | Long ): Long; + + /** + * Returns this Long with bits logically shifted to the right by the given amount. + */ + shru( numBits: number | Long ): Long; + + /** + * Returns the difference of this and the specified Long. + */ + subtract( subtrahend: number | Long | string ): Long; + + /** + * Returns the difference of this and the specified Long. + */ + sub( subtrahend: number | Long |string ): Long; + + /** + * Converts the Long to a 32 bit integer, assuming it is a 32 bit integer. + */ + toInt(): number; + + /** + * Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa). + */ + toNumber(): number; + + /** + * Converts this Long to signed. + */ + toSigned(): Long; + + /** + * Converts the Long to a string written in the specified radix. + */ + toString( radix?: number ): string; + + /** + * Converts this Long to unsigned. + */ + toUnsigned(): Long; + + /** + * Returns the bitwise XOR of this Long and the given one. + */ + xor( other: Long | number | string ): Long; } -declare module "long" { - var Long: dcodeIO.LongStatic; +declare module 'long' { export = Long; } \ No newline at end of file