invoking a macro from a template?

2024-04-02 Thread janAkali
Don't know if it could be made with a template, but it works with a macro: macro declareFieldEnum*( peripheralName: untyped, registerName: untyped, fieldName: untyped, bitOffset: static int, bitWidth: static int, values: untyped ) =

invoking a macro from a template?

2024-04-02 Thread dwhall256
In the previous step, you guys helped me [make the declareEnum() macro](https://forum.nim-lang.org/t/11331) that generates an enum type. Now, I need to generate a proc that uses the enum type for a parameter. My first attempt employs a template: template declareFieldEnum*( pe

Wasm3 (nim library) how to run c functions

2024-04-02 Thread Nlits
I keep on getting `Restricted OPCODE [WasmError]`. Any ideas?

Wasm3 (nim library) how to run c functions

2024-04-02 Thread Nlits
I’m sticking to manually copying right now, as everything is small-scale, but once efficiency becomes and issue I will change it. I will also check out the update 👍

Wasm3 (nim library) how to run c functions

2024-04-02 Thread ElegantBeef
Using non-sized strings across the barrier will always be a pain since you manually have to copy each byte. I did push out a new version with a test example and introducing `copyFromMem` to make it easier to copy byte buffers from VM to Nim.

Wasm3 (nim library) how to run c functions

2024-04-02 Thread Nlits
Honestly this is just going over my head. I understand that is is a VM and you have to manually transfer all memory you want to use. I just don’t understand the implementation. Can you give some code examples of passing cstring’s and arrays of cstrings? (I am focusing on that for now, leaving re

Wasm3 (nim library) how to run c functions

2024-04-02 Thread ElegantBeef
You need to think of wasm as a completely separate environment so you cannot really share anything but `ptr UncheckedArray[uint8]` or `cstring` **from** the VM to the host since the VM and the Nim code have two completely different runtimes and data layout. The VM is also sandboxed so it cannot

Wasm3 (nim library) how to run c functions

2024-04-02 Thread Nlits
I managed to create this file: import wasm3 # import wasm3/wasm3c proc wasmSize*(_: typedesc[array]): uint32 = uint32 sizeof(uint32) proc wasmSize*(_: typedesc[seq]): uint32 = uint32 sizeof(uint32) proc wasmSize*(_: typedesc[pointer]): uint32 = uint32 si

Wasm3 (nim library) how to run c functions

2024-04-02 Thread Nlits
That definitely helps with passing arguments, but what do I do about the return type?

Attempting a DSL on top of htmlgen for fun/learning

2024-04-02 Thread RegularAlias
What do you mean accidentally valid? I also found that if I preassign h1 and p then I can concatenate them as siblings so long as I use &, but the goal here is to have a DSL which has a YAML-like syntax. Do you have any hints as to how I can achieve that? And thanks for the pointer about repr,

https://glycogencontrol.hashnode.dev/glycogen-control-au-trending-reviews-2024

2024-04-02 Thread Decock9
Smart Hemp Gummies AU/NZ: CBD-containing products can reduce the signs and symptoms of anxiety, chronic pain, and stress. CBD products are used by 20% of young people (18–29 years old). It is hardly astonishing that CBD Gummies are being consumed widely. Just a small number of the CBD Gummy bran

help with channels and threads

2024-04-02 Thread elcritch
> So, after much debugging... Always use initLock on your locks. Don't ever > forget it otherwise the lock will "work" without actually doing what it's > supposed to. You might also need deinitLock then. Oops, sorry I forgot that I'd changed that too. Yes, definitely init them (and conds as wel

Attempting a DSL on top of htmlgen for fun/learning

2024-04-02 Thread PMunch
You seem to be generating macro output which is only accidentally valid for htmlgen. If you change your code to this then it works fine: let html = traverseTree: dv(id = "1", h1(style = "value", "hello world"), p("This is a paragraph")) echo html

List of GC'ed types

2024-04-02 Thread PMunch
This should be put into the manual somewhere! As for the closure thing they get turned into a pointer to a normal procedure and a pointer to an environment. This environment contains all the state captured by the closure. When the closure is called it's actually a static procedure which is call

help with channels and threads

2024-04-02 Thread ggibson
SOLVED So, after much debugging... Always use `initLock` on your locks. Don't ever forget it otherwise the lock will "work" without actually doing what it's supposed to. You might also need `deinitLock` then.