diff options
Diffstat (limited to 'src/html/catom.nim')
| -rw-r--r-- | src/html/catom.nim | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/html/catom.nim b/src/html/catom.nim index 4a0b4f65..0c866b71 100644 --- a/src/html/catom.nim +++ b/src/html/catom.nim @@ -98,6 +98,7 @@ macro makeStaticAtom = satText = "text" satTimeout = "timeout" satTitle = "title" + satToString = "toString" satTouchmove = "touchmove" satTouchstart = "touchstart" satType = "type" @@ -200,6 +201,9 @@ func toAtom*(factory: CAtomFactory; attrType: StaticAtom): CAtom = func toStr*(factory: CAtomFactory; atom: CAtom): string = return factory.atomMap[int(atom)] +func toStr*(factory: CAtomFactory; sa: StaticAtom): string = + return factory.toStr(factory.toAtom(sa)) + func toTagType*(factory: CAtomFactory; atom: CAtom): TagType = let i = int(atom) if i <= int(TagType.high): @@ -212,6 +216,9 @@ func toStaticAtom*(factory: CAtomFactory; atom: CAtom): StaticAtom = return StaticAtom(i) return atUnknown +func toStaticAtom*(factory: CAtomFactory; s: string): StaticAtom = + return factory.toStaticAtom(factory.toAtom(s)) + # Forward declaration hack var getFactoryImpl*: proc(ctx: JSContext): CAtomFactory {.nimcall, noSideEffect, raises: [].} @@ -225,6 +232,15 @@ proc toAtom*(ctx: JSContext; s: string): CAtom = proc toStaticAtom*(ctx: JSContext; atom: CAtom): StaticAtom = return ctx.getFactoryImpl().toStaticAtom(atom) +proc toStaticAtom*(ctx: JSContext; s: string): StaticAtom = + return ctx.getFactoryImpl().toStaticAtom(s) + +proc toStr*(ctx: JSContext; atom: CAtom): string = + return ctx.getFactoryImpl().toStr(atom) + +proc toStr*(ctx: JSContext; sa: StaticAtom): string = + return ctx.getFactoryImpl().toStr(sa) + proc fromJS*(ctx: JSContext; val: JSValue; res: var CAtom): Opt[void] = var s: string ?ctx.fromJS(val, s) |