@efffrida/il2cpp-bridge 0.0.19 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Assembly.d.ts +10 -0
- package/dist/Assembly.d.ts.map +1 -1
- package/dist/Assembly.js +11 -0
- package/dist/Assembly.js.map +1 -1
- package/dist/Class.d.ts +54 -4
- package/dist/Class.d.ts.map +1 -1
- package/dist/Class.js +54 -1
- package/dist/Class.js.map +1 -1
- package/dist/Equivalence.d.ts +37 -0
- package/dist/Equivalence.d.ts.map +1 -0
- package/dist/Equivalence.js +37 -0
- package/dist/Equivalence.js.map +1 -0
- package/dist/Extensions.d.ts +85 -0
- package/dist/Extensions.d.ts.map +1 -0
- package/dist/Extensions.js +177 -0
- package/dist/Extensions.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/Assembly.ts +19 -0
- package/src/Class.ts +222 -20
- package/src/Equivalence.ts +44 -0
- package/src/Extensions.ts +239 -0
- package/src/index.ts +12 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 1.0.0
|
|
3
|
+
* @category Extensions
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import "frida-il2cpp-bridge";
|
|
7
|
+
|
|
8
|
+
import { Array, Option, Record } from "effect";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
* @category Extensions
|
|
13
|
+
*/
|
|
14
|
+
export class Dictionary<
|
|
15
|
+
K extends Il2Cpp.Field.Type = Il2Cpp.Field.Type,
|
|
16
|
+
V extends Il2Cpp.Field.Type = Il2Cpp.Field.Type,
|
|
17
|
+
>
|
|
18
|
+
extends Il2Cpp.Object
|
|
19
|
+
{
|
|
20
|
+
/** Gets the pairs count of the current dictionary. */
|
|
21
|
+
public get length(): number {
|
|
22
|
+
return this.method<number>("get_Count").invoke();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Gets all keys of the current dictionary. */
|
|
26
|
+
public get keys(): Array<K> {
|
|
27
|
+
const keys = Il2Cpp.array<K>(this.class.generics[0], this.length);
|
|
28
|
+
this.method<Il2Cpp.Object>("get_Keys").invoke().method("CopyTo").invoke(keys, 0);
|
|
29
|
+
return Array.fromIterable(keys);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Gets all values of the current dictionary. */
|
|
33
|
+
public get values(): Array<V> {
|
|
34
|
+
const values = Il2Cpp.array<V>(this.class.generics[1], this.length);
|
|
35
|
+
this.method<Il2Cpp.Object>("get_Values").invoke().method("CopyTo").invoke(values, 0);
|
|
36
|
+
return Array.fromIterable(values);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Gets all pairs of the current dictionary. */
|
|
40
|
+
public get entries(): Array<[K, V]> {
|
|
41
|
+
return Array.zip(this.keys, this.values);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Gets the value by the specified key of the current dictionary. */
|
|
45
|
+
public get(key: K): V {
|
|
46
|
+
return this.method<V>("get_Item").invoke(key);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Sets the pair of the current dictionary. */
|
|
50
|
+
public set(key: K, value: V): void {
|
|
51
|
+
this.method<void>("set_Item").invoke(key, value);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Adds a new key to the current dictionary. */
|
|
55
|
+
public add(key: K, value: V): void {
|
|
56
|
+
this.method<void>("Add").invoke(key, value);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Clears the current dictionary. */
|
|
60
|
+
public clear(): void {
|
|
61
|
+
this.method<void>("Clear").invoke();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Determines if the key is in the current dictionary. */
|
|
65
|
+
public containsKey(key: K): boolean {
|
|
66
|
+
return this.method<boolean>("ContainsKey").invoke(key);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Determines if the value is in the current dictionary. */
|
|
70
|
+
public containsValue(value: V): boolean {
|
|
71
|
+
return this.method<boolean>("ContainsValue").invoke(value);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Finds a key in the current dictionary and returns its index. */
|
|
75
|
+
public find(key: K): number {
|
|
76
|
+
return this.method<number>("FindEntry").invoke(key);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Removes the given key from the current dictionary. */
|
|
80
|
+
public remove(key: K): boolean {
|
|
81
|
+
return this.method<boolean>("Remove").invoke(key);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public *[Symbol.iterator](): IterableIterator<[K, V]> {
|
|
85
|
+
const entries = this.entries;
|
|
86
|
+
for (let i = 0; i < this.length; i++) {
|
|
87
|
+
yield entries[i];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public override toString(): string {
|
|
92
|
+
return this.isNull() ? "null" : `{${[...this.entries].map(([k, v]) => `${k}: ${v}`).join(", ")}}`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public toRecord(keys?: Array<K> | undefined): Record<string, V> {
|
|
96
|
+
return Record.fromEntries(
|
|
97
|
+
Array.filterMap(keys ?? this.keys, (key) =>
|
|
98
|
+
Option.product(
|
|
99
|
+
key instanceof Il2Cpp.String ? Option.fromNullable(key.content) : Option.some(key.toString()),
|
|
100
|
+
this.containsKey(key) ? Option.some(this.get(key)) : Option.none()
|
|
101
|
+
)
|
|
102
|
+
)
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** The Dictionary class. */
|
|
107
|
+
public static get class() {
|
|
108
|
+
return Il2Cpp.corlib.class("System.Collections.Generic.Dictionary`2");
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Lifts an Il2Cpp.Object to a Dictionary. */
|
|
112
|
+
public static lift<
|
|
113
|
+
K extends Il2Cpp.Field.Type = Il2Cpp.Field.Type,
|
|
114
|
+
V extends Il2Cpp.Field.Type = Il2Cpp.Field.Type,
|
|
115
|
+
>(object: Il2Cpp.Object): Dictionary<K, V> {
|
|
116
|
+
return new Dictionary<K, V>(object.handle);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Creates a new dictionary with the given elements. */
|
|
120
|
+
public static of<K extends Il2Cpp.Field.Type = Il2Cpp.Field.Type, V extends Il2Cpp.Field.Type = Il2Cpp.Field.Type>(
|
|
121
|
+
keyClass: Il2Cpp.Class,
|
|
122
|
+
valueClass: Il2Cpp.Class,
|
|
123
|
+
elements?: Map<K, V> | undefined
|
|
124
|
+
): Dictionary<K, V> {
|
|
125
|
+
const dictionary = new Dictionary<K, V>(Dictionary.class.inflate(keyClass, valueClass).alloc());
|
|
126
|
+
for (const [key, value] of elements ?? []) {
|
|
127
|
+
dictionary.set(key, value);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return dictionary;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @since 1.0.0
|
|
136
|
+
* @category Extensions
|
|
137
|
+
*/
|
|
138
|
+
export class List<T extends Il2Cpp.Field.Type = Il2Cpp.Field.Type> extends Il2Cpp.Object {
|
|
139
|
+
public get capacity(): number {
|
|
140
|
+
return this.method<number>("get_Capacity").invoke();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public set capacity(value: number) {
|
|
144
|
+
this.method("set_Capacity").invoke(value);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Gets the element count of the current list. */
|
|
148
|
+
public get length(): number {
|
|
149
|
+
return this.method<number>("get_Count").invoke();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Gets the value by the specified index of the current list. */
|
|
153
|
+
public get(index: number): T {
|
|
154
|
+
return this.method<T>("get_Item").invoke(index);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Sets the element of the current list. */
|
|
158
|
+
public set(index: number, value: T): void {
|
|
159
|
+
this.method("set_Item").invoke(index, value);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Adds a new element to the current list. */
|
|
163
|
+
public add(item: T): void {
|
|
164
|
+
this.method("Add").invoke(item);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Clears the current list. */
|
|
168
|
+
public clear(): void {
|
|
169
|
+
this.method("Clear").invoke();
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Determines if the key is in the current list. */
|
|
173
|
+
public contains(item: T): boolean {
|
|
174
|
+
return this.method<boolean>("Contains").invoke(item);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Determines the index of the element of the current list. */
|
|
178
|
+
public indexOf(item: T): number {
|
|
179
|
+
return this.method<number>("IndexOf").invoke(item);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Inserts an element at the given index of the current list. */
|
|
183
|
+
public insert(index: number, item: T): void {
|
|
184
|
+
this.method("Insert").invoke(index, item);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Removes a data element from the current list. */
|
|
188
|
+
public remove(item: T): boolean {
|
|
189
|
+
return this.method<boolean>("Remove").invoke(item);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Reverses the current list. */
|
|
193
|
+
public reverse(): void {
|
|
194
|
+
this.method("Reverse").invoke();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** Sorts the current list. */
|
|
198
|
+
public sort(): void {
|
|
199
|
+
this.method("Sort").invoke();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Converts the current list to an array. */
|
|
203
|
+
public get toArray(): Il2Cpp.Array<T> {
|
|
204
|
+
return this.method<Il2Cpp.Array<T>>("ToArray").invoke();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
public *[Symbol.iterator](): IterableIterator<T> {
|
|
208
|
+
for (let i = 0; i < this.length; i++) {
|
|
209
|
+
yield this.get(i);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
public override toString(): string {
|
|
214
|
+
return this.toArray.toString();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** The List class. */
|
|
218
|
+
public static get class() {
|
|
219
|
+
return Il2Cpp.corlib.class("System.Collections.Generic.List`1");
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** Lifts an Il2Cpp.Array to a List. */
|
|
223
|
+
public static lift<T extends Il2Cpp.Field.Type = Il2Cpp.Field.Type>(object: Il2Cpp.Object): List<T> {
|
|
224
|
+
return new List<T>(object.handle);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** Creates a new list with the given elements. */
|
|
228
|
+
public static of<T extends Il2Cpp.Field.Type = Il2Cpp.Field.Type>(
|
|
229
|
+
klass: Il2Cpp.Class,
|
|
230
|
+
elements: Array<T> | undefined = []
|
|
231
|
+
): List<T> {
|
|
232
|
+
const list = new List<T>(List.class.inflate(klass).alloc());
|
|
233
|
+
for (const element of elements) {
|
|
234
|
+
list.add(element);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return list;
|
|
238
|
+
}
|
|
239
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,18 @@ export * as Assembly from "./Assembly.ts"
|
|
|
14
14
|
*/
|
|
15
15
|
export * as Class from "./Class.ts"
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
* @category Equivalence
|
|
20
|
+
*/
|
|
21
|
+
export * as Equivalence from "./Equivalence.ts"
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @since 1.0.0
|
|
25
|
+
* @category Extensions
|
|
26
|
+
*/
|
|
27
|
+
export * as Extensions from "./Extensions.ts"
|
|
28
|
+
|
|
17
29
|
/**
|
|
18
30
|
* @since 1.0.0
|
|
19
31
|
* @category FridaIl2cppBridge
|