mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Resolved Issue #451: Improve the Network Stack
Resolved Issue #473: Add support for Notification Observers (iOS) and Broadcast Receivers (Android)
This commit is contained in:
140
declarations.ios.d.ts
vendored
140
declarations.ios.d.ts
vendored
@@ -4,6 +4,75 @@
|
||||
* Provides API for working with native C types, pointers, pointer arithmetic and memory.
|
||||
*/
|
||||
declare module interop {
|
||||
|
||||
/**
|
||||
* A type that is used to represent a void*.
|
||||
*/
|
||||
interface Pointer {
|
||||
/**
|
||||
* Creates a new pointer with the given offset.
|
||||
* @param offset The offset in bytes.
|
||||
*/
|
||||
new (offset: number);
|
||||
|
||||
/**
|
||||
* Creates a new pointer by adding an offset to the current pointer.
|
||||
* @param offset The offset in bytes.
|
||||
*/
|
||||
add(offset: number): Pointer;
|
||||
|
||||
/**
|
||||
* Creates a new pointer by removing an offset from the current pointer.
|
||||
* @param offset The offset in bytes.
|
||||
*/
|
||||
subtract(offset: number): Pointer;
|
||||
|
||||
/**
|
||||
* Converts the value of this instance to a number.
|
||||
*/
|
||||
toNumber(): number;
|
||||
}
|
||||
|
||||
var Pointer;
|
||||
|
||||
/**
|
||||
* A pointer that will free the memory it points to automatically when garbage collected.
|
||||
*/
|
||||
interface AdoptedPointer extends Pointer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the pointer adopted.
|
||||
* After a call to adopt the pointer will hold its memory.
|
||||
* @param ptr The pointer to adopt.
|
||||
*/
|
||||
function adopt(ptr: Pointer): AdoptedPointer;
|
||||
|
||||
/**
|
||||
* Allocates memory.
|
||||
* @param size The size in bytes.
|
||||
*/
|
||||
function alloc(size: number): AdoptedPointer;
|
||||
|
||||
/**
|
||||
* Releases the memory of a pointer.
|
||||
* The pointer should not be adopted.
|
||||
* @param ptr A pointer to the memory to free.
|
||||
*/
|
||||
function free(ptr: Pointer): void;
|
||||
|
||||
/**
|
||||
* Returns the size of the provided type.
|
||||
* @param type A class constructor (of Objective-C interface), an instance (wrapper of Objective-C interface), struct constructor, struct instance, reference, protocol, function (for c function), fundamental types.
|
||||
*/
|
||||
function sizeof(type: any): number;
|
||||
|
||||
/**
|
||||
* From a JavaScript object gets a pointer to the backing native object.
|
||||
* @param instance A class constructor (of Objective-C interface), an instance (wrapper of Objective-C interface), struct instance, reference, protocol, function (for c function) or block.
|
||||
*/
|
||||
function handleof(instance: any): Pointer;
|
||||
|
||||
/**
|
||||
* A type that wraps a pointer and allows read/write operations on its value.
|
||||
*/
|
||||
@@ -45,34 +114,18 @@ declare module interop {
|
||||
* Dereferences the pointer.
|
||||
*/
|
||||
value: any;
|
||||
};
|
||||
}
|
||||
|
||||
interface FunctionReference<T> {
|
||||
(...params);
|
||||
}
|
||||
|
||||
/**
|
||||
* A type that is used to represent a void*.
|
||||
* Creates a function reference that can be marshalled as a native function pointer.
|
||||
* The JavaScript reference must be held alive as long as the native code needs the function.
|
||||
*/
|
||||
interface Pointer {
|
||||
/**
|
||||
* Creates a new pointer with the given offset.
|
||||
* @param offset The offset in bytes.
|
||||
*/
|
||||
new (offset: number);
|
||||
|
||||
/**
|
||||
* Creates a new pointer by adding an offset to the current pointer.
|
||||
* @param offset The offset in bytes.
|
||||
*/
|
||||
add(offset: number): Pointer;
|
||||
|
||||
/**
|
||||
* Creates a new pointer by removing an offset from the current pointer.
|
||||
* @param offset The offset in bytes.
|
||||
*/
|
||||
subtract(offset: number): Pointer;
|
||||
|
||||
/**
|
||||
* Converts the value of this instance to a number.
|
||||
*/
|
||||
toNumber(): number;
|
||||
var FunctionReference: {
|
||||
new <T>(func: T): FunctionReference<T>;
|
||||
}
|
||||
|
||||
interface Type<T> {
|
||||
@@ -92,13 +145,42 @@ declare module interop {
|
||||
uint64: Type<number>;
|
||||
float: Type<number>;
|
||||
double: Type<number>;
|
||||
//UTF8CString: Type<Reference<types.int8>>;
|
||||
|
||||
UTF8CString: Type<Reference<number>>;
|
||||
unichar: Type<string>;
|
||||
id: Type<NSObject>;
|
||||
protocol: Type<Object>;
|
||||
"class": Type<NSObject>;
|
||||
|
||||
id: Type<any>;
|
||||
protocol: Type<any>;
|
||||
"class": Type<any>;
|
||||
selector: Type<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type for JavaScript constructors for C structs.
|
||||
*/
|
||||
interface StructType<T> extends Type<T> {
|
||||
|
||||
/**
|
||||
* Create a new instance of the struct.
|
||||
*/
|
||||
new (): T;
|
||||
|
||||
/**
|
||||
* Create a new instance of the struct and initialize it from the fields of the provided object.
|
||||
* @param obj Initializer.
|
||||
*/
|
||||
new (obj: T): T;
|
||||
|
||||
/**
|
||||
* Create a new struct by copying the memory from the provided pointer.
|
||||
*/
|
||||
new (obj: Pointer): T;
|
||||
|
||||
/**
|
||||
* Checks two structs for equality.
|
||||
*/
|
||||
equals(left: T, right: T): boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare function __collect(): void;
|
||||
Reference in New Issue
Block a user