aboutsummaryrefslogtreecommitdiffstats
path: root/src/types
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-07-01 19:26:32 +0200
committerbptato <nincsnevem662@gmail.com>2023-07-01 19:57:54 +0200
commit2b10a9b7f61d58157f85c93e8e7b18b1e01e4b79 (patch)
treea6c544e5c0e49578d847985945448344540a9f7f /src/types
parentef136ac44db26074bf9528f17dee764f731ed4eb (diff)
downloadchawan-2b10a9b7f61d58157f85c93e8e7b18b1e01e4b79.tar.gz
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.)
Diffstat (limited to 'src/types')
-rw-r--r--src/types/blob.nim3
-rw-r--r--src/types/cookie.nim2
-rw-r--r--src/types/formdata.nim3
-rw-r--r--src/types/url.nim3
4 files changed, 11 insertions, 0 deletions
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