From 2b10a9b7f61d58157f85c93e8e7b18b1e01e4b79 Mon Sep 17 00:00:00 2001 From: bptato Date: Sat, 1 Jul 2023 19:26:32 +0200 Subject: use =destroy instead of finalizers This should help with moving to ORC in the future. (Also, finalizers do not work very well in the first place.) --- src/types/blob.nim | 3 +++ src/types/cookie.nim | 2 ++ src/types/formdata.nim | 3 +++ src/types/url.nim | 3 +++ 4 files changed, 11 insertions(+) (limited to 'src/types') diff --git a/src/types/blob.nim b/src/types/blob.nim index d72d0505..505e4f7c 100644 --- a/src/types/blob.nim +++ b/src/types/blob.nim @@ -19,6 +19,9 @@ type path*: string file: File #TODO maybe use fd? +jsDestructor(Blob) +jsDestructor(WebFile) + proc newBlob*(buffer: pointer, size: int, ctype: string, deallocFun: DeallocFun): Blob = return Blob( diff --git a/src/types/cookie.nim b/src/types/cookie.nim index c6b526ee..7418963d 100644 --- a/src/types/cookie.nim +++ b/src/types/cookie.nim @@ -25,6 +25,8 @@ type filter*: URLFilter cookies*: seq[Cookie] +jsDestructor(Cookie) + proc parseCookieDate(val: string): Option[DateTime] = # cookie-date const Delimiters = {'\t', ' '..'/', ';'..'@', '['..'`', '{'..'~'} diff --git a/src/types/formdata.nim b/src/types/formdata.nim index 983508bf..2bc26e22 100644 --- a/src/types/formdata.nim +++ b/src/types/formdata.nim @@ -1,3 +1,4 @@ +import js/javascript import types/blob type @@ -13,6 +14,8 @@ type FormData* = ref object entries*: seq[FormDataEntry] +jsDestructor(FormData) + iterator items*(this: FormData): FormDataEntry {.inline.} = for entry in this.entries: yield entry diff --git a/src/types/url.nim b/src/types/url.nim index 968e642c..3eb6889c 100644 --- a/src/types/url.nim +++ b/src/types/url.nim @@ -60,6 +60,9 @@ type domain: Option[string] ]] +jsDestructor(URL) +jsDestructor(URLSearchParams) + const EmptyPath = UrlPath(opaque: true, s: "") const EmptyHost = Host(domain: "").some -- cgit