projects
/
ldk-java
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add Variant-Level docs on complex and unitary enums.
[ldk-java]
/
typescript_strings.py
diff --git
a/typescript_strings.py
b/typescript_strings.py
index c097921f7d43de5ebc733be09392e1b24e19a6e4..270eeccc85c30ad486e782abc82509f5b62c35b4 100644
(file)
--- a/
typescript_strings.py
+++ b/
typescript_strings.py
@@
-120,9
+120,10
@@
void *malloc(size_t size);
void free(void *ptr);
#define MALLOC(a, _) malloc(a)
void free(void *ptr);
#define MALLOC(a, _) malloc(a)
-#define FREE(p) if ((
long)(p) > 1024
) { free(p); }
+#define FREE(p) if ((
unsigned long)(p) > 4096
) { free(p); }
#define DO_ASSERT(a) (void)(a)
#define CHECK(a)
#define DO_ASSERT(a) (void)(a)
#define CHECK(a)
+#define CHECK_ACCESS(p)
"""
else:
self.c_file_pfx = self.c_file_pfx + """
"""
else:
self.c_file_pfx = self.c_file_pfx + """
@@
-174,11
+175,21
@@
static void alloc_freed(void* ptr) {
__real_free(it);
}
static void FREE(void* ptr) {
__real_free(it);
}
static void FREE(void* ptr) {
- if ((
long)ptr < 1024
) return; // Rust loves to create pointers to the NULL page for dummys
+ if ((
unsigned long)ptr <= 4096
) return; // Rust loves to create pointers to the NULL page for dummys
alloc_freed(ptr);
__real_free(ptr);
}
alloc_freed(ptr);
__real_free(ptr);
}
+static void CHECK_ACCESS(void* ptr) {
+ allocation* it = allocation_ll;
+ while (it->ptr != ptr) {
+ it = it->next;
+ if (it == NULL) {
+ return; // addrsan should catch malloc-unknown and print more info than we have
+ }
+ }
+}
+
void* __wrap_malloc(size_t len) {
void* res = __real_malloc(len);
new_allocation(res, "malloc call");
void* __wrap_malloc(size_t len) {
void* res = __real_malloc(len);
new_allocation(res, "malloc call");
@@
-461,9
+472,11
@@
const decodeString = (stringPointer, free = true) => {
out_typescript_enum_fields = ""
out_typescript_enum_fields = ""
- for var in variants:
+ for var
, var_docs
in variants:
out_c = out_c + "\t\tcase %d: return %s;\n" % (ord_v, var)
ord_v = ord_v + 1
out_c = out_c + "\t\tcase %d: return %s;\n" % (ord_v, var)
ord_v = ord_v + 1
+ if var_docs is not None:
+ out_typescript_enum_fields += f"/**\n * {var_docs}\n */\n"
out_typescript_enum_fields += f"{var},\n\t\t\t\t"
out_c = out_c + "\t}\n"
out_c = out_c + "\tabort();\n"
out_typescript_enum_fields += f"{var},\n\t\t\t\t"
out_c = out_c + "\t}\n"
out_c = out_c + "\tabort();\n"
@@
-472,7
+485,7
@@
const decodeString = (stringPointer, free = true) => {
out_c = out_c + "static inline int32_t LDK" + struct_name + "_to_js(LDK" + struct_name + " val) {\n"
out_c = out_c + "\tswitch (val) {\n"
ord_v = 0
out_c = out_c + "static inline int32_t LDK" + struct_name + "_to_js(LDK" + struct_name + " val) {\n"
out_c = out_c + "\tswitch (val) {\n"
ord_v = 0
- for var in variants:
+ for var
, _
in variants:
out_c = out_c + "\t\tcase " + var + ": return %d;\n" % ord_v
ord_v = ord_v + 1
out_c = out_c + "\t\tdefault: abort();\n"
out_c = out_c + "\t\tcase " + var + ": return %d;\n" % ord_v
ord_v = ord_v + 1
out_c = out_c + "\t\tdefault: abort();\n"