Uses 11335K of libraries. Click here for Pure Java version (5400L/33K).
1 | sclass ManagedString extends AbstractManagedObject implements CharSequence { |
2 | replace Addr with int. |
3 | |
4 | S value; |
5 | |
6 | // usable but doesn't handle null |
7 | *(ManagedIntObjects_v1 mem, Addr *addr) { |
8 | super(mem); |
9 | value = mem.readString(addr); |
10 | } |
11 | |
12 | // ...unless you call this |
13 | bool isNull() { ret value == null; } |
14 | |
15 | // internal |
16 | *(ManagedIntObjects_v1 mem, S *value, Addr *addr) { |
17 | super(mem); |
18 | } |
19 | |
20 | // for proper null handling |
21 | static ManagedString load(ManagedIntObjects_v1 mem, Addr addr) { |
22 | S value = mem.readString(addr); |
23 | if (value == null) null; |
24 | ret new ManagedString(mem, value, addr); |
25 | } |
26 | |
27 | static ManagedString create(ManagedIntObjects_v1 mem, S value) { |
28 | if (value == null) null; |
29 | ret new ManagedString(mem, value, mem.newString(value)); |
30 | } |
31 | |
32 | // GC handling |
33 | public void scanForCollection(IManagedObjectCollector gc) { |
34 | gc.noteString(addr, lambda1 setAddr); |
35 | } |
36 | |
37 | @Override |
38 | public char charAt(int index) { |
39 | ret value.charAt(index); |
40 | } |
41 | |
42 | @Override |
43 | public int length() { |
44 | ret l(value); |
45 | } |
46 | |
47 | @Override |
48 | public CharSequence subSequence(int start, int end) { |
49 | ret value.substring(start, end); |
50 | } |
51 | |
52 | @Override |
53 | toString { ret value == null ? "" : value.toString(); } |
54 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1031656 |
Snippet name: | ManagedString |
Eternal ID of this version: | #1031656/6 |
Text MD5: | a8534770f7295cd51f87973b046a6012 |
Transpilation MD5: | 61970a164832cbe8210a73b7c012ea51 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-25 08:23:18 |
Source code size: | 1296 bytes / 54 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 190 / 376 |
Version history: | 5 change(s) |
Referenced in: | [show references] |