Use file_ext everywhere, common base/header for TS files
[ldk-java] / typescript_strings.py
index 70e37331ba56db6230a7e39f6b2511f069ede9e7..dccd8cf3a8d9b0a0133868df8ca5e66818bfe708 100644 (file)
@@ -1,5 +1,14 @@
 class Consts:
     def __init__(self, DEBUG):
+        self.common_base = """
+            export default class CommonBase {
+                ptr: number;
+                ptrs_to: object[] = new Array(); // new LinkedList(); TODO: build linked list implementation
+                protected constructor(ptr: number) { this.ptr = ptr; }
+                public _test_only_get_ptr(): number { return this.ptr; }
+            }
+        """
+
         self.c_file_pfx = """#include <rust_types.h>
 #include <stdatomic.h>
 #include <lightning.h>
@@ -129,14 +138,10 @@ typedef bool jboolean;
 
 """
 
-        self.hu_struct_file_prefix = """package org.ldk.structs;
-
-import org.ldk.impl.bindings;
-import org.ldk.enums.*;
-import org.ldk.util.*;
-import java.util.Arrays;
+        self.hu_struct_file_prefix = f"""
+import CommonBase from './CommonBase';
+import * as bindings from '../bindings' // TODO: figure out location
 
-@SuppressWarnings("unchecked") // We correctly assign various generic arrays
 """
         self.c_fn_ty_pfx = ""
         self.c_fn_name_pfx = ""