176 lines
5.7 KiB
TypeScript
176 lines
5.7 KiB
TypeScript
/*
|
|
* Tencent is pleased to support the open source community by making Puerts available.
|
|
* Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
|
|
* Puerts is licensed under the BSD 3-Clause License, except for the third-party components listed in the file 'LICENSE' which may be subject to their corresponding license terms.
|
|
* This file is subject to the terms and conditions defined in file 'LICENSE', which is part of this source code package.
|
|
*/
|
|
|
|
declare module "ue" {
|
|
type ArgumentTypes<T> = T extends (... args: infer U ) => infer R ? U: never;
|
|
|
|
interface $CallbackID {}
|
|
|
|
interface $Delegate<T extends (...args: any) => any> {
|
|
Bind(fn : T): void;
|
|
Bind(target: Object, methodName: string): void;
|
|
Unbind(): void;
|
|
IsBound(): boolean;
|
|
Execute(...a: ArgumentTypes<T>) : ReturnType<T>;
|
|
}
|
|
|
|
interface $MulticastDelegate<T extends (...args: any) => any> {
|
|
Add(fn : T): void;
|
|
Add(target: Object, methodName: string): void;
|
|
Remove(fn : T): void;
|
|
Broadcast(...a: ArgumentTypes<T>) : ReturnType<T>;
|
|
Clear(): void;
|
|
}
|
|
|
|
interface FixSizeArray<T> {
|
|
Num(): number;
|
|
Get(Index: number): T;
|
|
GetRef(Index: number): T;
|
|
Set(Index: number, Value: T): void;
|
|
}
|
|
|
|
interface TArray<T> {
|
|
Num(): number;
|
|
Add(...args: T[]): void;
|
|
Get(Index: number): T;
|
|
GetRef(Index: number): T;
|
|
Set(Index: number, Value: T): void;
|
|
Contains(Value: T): boolean;
|
|
FindIndex(Value: T): number;
|
|
RemoveAt(Index: number): void;
|
|
IsValidIndex(Index: number): boolean;
|
|
Empty(): void;
|
|
[Symbol.iterator](): IterableIterator<T>;
|
|
}
|
|
|
|
interface TSet<T> {
|
|
Num(): number;
|
|
Add(Value: T): void;
|
|
Get(Index: number): T; // TODO - 这个接口要用Index吗?
|
|
GetRef(Index: number): T;
|
|
// Set(Index: number, Value: T): void;
|
|
Contains(Value: T): boolean;
|
|
FindIndex(Value: T): number;
|
|
RemoveAt(Index: number): void;
|
|
GetMaxIndex(): number; // TODO - GetMaxIndex的返回值是InvalidIndex,合理吗?(GetMaxIndex的解释应该是:最大合法index+1),当调用Empty,返回值为0
|
|
IsValidIndex(Index: number): boolean;
|
|
Empty(): void;
|
|
[Symbol.iterator](): IterableIterator<T>;
|
|
}
|
|
|
|
interface TMap<TKey, TValue> {
|
|
Num(): number;
|
|
Add(Key: TKey, Value: TValue): void;
|
|
Get(Key: TKey): TValue | undefined;
|
|
GetRef(Key: TKey): TValue | undefined;
|
|
Set(Key: TKey, Value: TValue): void; // 即Add()。TODO - 有存在的必要吗?
|
|
Remove(Key: TKey): void;
|
|
GetMaxIndex(): number; // TODO - 接口注释要说明返回的是kv的索引。只有调用了Empty后才会返回0
|
|
IsValidIndex(Index: number): boolean;
|
|
GetKey(Index: number): TKey; // TODO - 对于非法index,是否应该返回undefined
|
|
Empty(): void;
|
|
[Symbol.iterator](): IterableIterator<[TKey, TValue]>;
|
|
}
|
|
|
|
interface TSharedPtr<T> {
|
|
__tid_SharedPtr: T
|
|
Equals(other: TSharedPtr<T>):boolean
|
|
}
|
|
|
|
type BuiltinBool = 0;
|
|
type BuiltinByte = 1;
|
|
type BuiltinInt = 2;
|
|
type BuiltinFloat = 3;
|
|
type BuiltinDouble = 4;
|
|
type BuiltinInt64 = 5;
|
|
type BuiltinString = 6;
|
|
type BuiltinText = 7;
|
|
type BuiltinName = 8;
|
|
|
|
const BuiltinBool = 0;
|
|
const BuiltinByte = 1;
|
|
const BuiltinInt = 2;
|
|
const BuiltinFloat = 3;
|
|
const BuiltinDouble = 4;
|
|
const BuiltinInt64 = 5;
|
|
const BuiltinString = 6;
|
|
const BuiltinText = 7;
|
|
const BuiltinName = 8;
|
|
|
|
type ContainerKVType<T> =
|
|
T extends BuiltinBool ? boolean :
|
|
T extends BuiltinByte | BuiltinInt | BuiltinFloat | BuiltinDouble ? number :
|
|
T extends BuiltinInt64 ? bigint :
|
|
T extends BuiltinString | BuiltinText | BuiltinName ? string :
|
|
T extends {__typeKeyDoNoAccess: infer R} ? R :
|
|
T extends {new (...args:any[]): infer R} ? R :
|
|
never;
|
|
|
|
type SupportedContainerKVType = BuiltinBool | BuiltinByte | BuiltinInt | BuiltinFloat | BuiltinDouble | BuiltinInt64 | BuiltinString | BuiltinText | BuiltinName | {StaticClass(): Class} | {StaticStruct(): ScriptStruct} | {__typeKeyDoNoAccess: any}
|
|
|
|
function NewArray<T extends SupportedContainerKVType>(t: T): TArray<ContainerKVType<T>>;
|
|
function NewSet<T extends SupportedContainerKVType>(t: T): TSet<ContainerKVType<T>>;
|
|
function NewMap<TKey extends SupportedContainerKVType, TValue extends SupportedContainerKVType>(k: TKey, v: TValue): TMap<ContainerKVType<TKey>, ContainerKVType<TValue>>;
|
|
|
|
type DataPropertyNames<T> = {
|
|
[K in keyof T]: T[K] extends (...args: any) => any ? never : K;
|
|
}[keyof T];
|
|
|
|
type DataPropertiesOnly<T> = {
|
|
[P in DataPropertyNames<T>]: T[P] extends object ? DataPropertiesOnly<T[P]> : T[P]
|
|
};
|
|
|
|
function NewObject(Cls: Class, Outer?: Object, Name?:string, ObjectFlags?: number, JsTakeRef?: boolean): Object;
|
|
|
|
function NewStruct(St: ScriptStruct): object;
|
|
|
|
function FNameLiteral(str:string):string;
|
|
|
|
type TWeakObjectPtr<T> = {
|
|
[K in keyof T]: T[K];
|
|
}
|
|
|
|
type TSoftObjectPtr<T> = {
|
|
Get():T;
|
|
LoadSynchronous(): T;
|
|
}
|
|
|
|
type TLazyObjectPtr<T> = {
|
|
[K in keyof T]: T[K];
|
|
}
|
|
|
|
type TSubclassOf<T> = {
|
|
[K in keyof T]: T[K];
|
|
}
|
|
|
|
type TSoftClassPtr<T> = {
|
|
Get():Class;
|
|
LoadSynchronous(): Class;
|
|
}
|
|
|
|
class UInt64Ptr { }
|
|
|
|
class FloatPtr { }
|
|
|
|
class DoublePtr { }
|
|
|
|
class Int64Ptr { }
|
|
|
|
class UInt32Ptr { }
|
|
|
|
class Int32Ptr { }
|
|
|
|
class CharPtr { }
|
|
|
|
class ShortPtr { }
|
|
|
|
class BoolPtr { }
|
|
|
|
class StringPtr { }
|
|
|
|
}
|