How to properly configure a webserver as a binary nimble package.

2024-08-22 Thread Nlits
Thanks for your response! I’m pretty sure that solves the `How do I locate the installed files from the binary run in the bin folder? Is there a good way to write a proc to find this on run?` issue by doing something like this: proc findStaticPath(): string = result = current

How to properly configure a webserver as a binary nimble package.

2024-08-20 Thread Nlits
**Project/Setup Info** * Framework: Jester/WS/Karax * OS: Linux/Ubuntu * Nim Version: Nim 2.0.8 * Nimble Version: v0.14.2 * Current Relevant .nimble details: srcDir= "src" binDir= "builds" bin = @["wssh"] installDirs = @["public"]

Nim “free(): invalid pointer” segfault (dynlib)

2024-04-26 Thread Nlits
> If you use a type like ` Table[string, CardObject]` accross DLL boundaries > you need to compile against nimrtl.dll etc, I hope you are aware. Again, the > piece of code already works without issues, but I will see if adding nimrtl > changes the main issue.

Nim “free(): invalid pointer” segfault (dynlib)

2024-04-26 Thread Nlits
Would you explain why? They are already defined like this: EventHandleProc = proc () {.gcsafe, nimcall.} CardSetLoadProc = proc (): Table[string, CardObject] {.gcsafe, nimcall.} Run And did you mean `EventHandleProc`? `CardSetLoadProc` works without any issues.

Nim “free(): invalid pointer” segfault (dynlib)

2024-04-25 Thread Nlits
Error: (with `import segfaults`) free(): invalid pointer Traceback (most recent call last) /home/runner/libmtg/src/libmtg/cards.nim(119) test1 SIGABRT: Abnormal termination. Aborted (core dumped) Error: execution of an external program failed: '/home/runner/libmtg

Can’t wrap my head around this TypeError

2024-04-25 Thread Nlits
Yep, I think you’re right. Changing source attr to a path string worked. I might just change it to int per later to signify that the ptr need not be resolved compile time… We will see.

Can’t wrap my head around this TypeError

2024-04-25 Thread Nlits
And the card types: CardObject* = object source: Cardset name*: string text*: string imageUrl*: string expansion*: string rarity*: string collectorNumber*: int cost*: seq[ManaCostType] # empty is land typ

Can’t wrap my head around this TypeError

2024-04-25 Thread Nlits
CardSet* = ref object cards*: Table[string, Card] # legalityBinding: set[] sourcePath: string # Local source path # Meta (optional) webSource: string # Web download url name: string # Can be "" Run ^^^ Is the definition.

Can’t wrap my head around this TypeError

2024-04-24 Thread Nlits
I get this type error from my code (the code with the error is above the error): Info: Using the environment variable: NIMBLE_DIR='/home/runner/libmtg/nimble-env' Hint: used config file '/home/runner/.choosenim/toolchains/nim-2.0.4/config/nim.cfg' [Conf] Hint: used config fi

Odd Segfault when using dynlib

2024-04-19 Thread Nlits
Works. I’m probably going to use this, tucked away somewhere where users of my lib don’t have to deal with it. Thanks for the help!

Odd Segfault when using dynlib

2024-04-19 Thread Nlits
It should be fine, because CardObject is not a ref, and afaik shouldn’t be using lib memory, although idrk.

Odd Segfault when using dynlib

2024-04-19 Thread Nlits
I get this segfault: Verifying dependencies for libmtg@0.1.0 Compiling /home/runner/libmtg/tests/test1 (from package libmtg) using c backend [OK] can import {"Island": (name: "Island", text: "({T}: Add {U}.)", imageUrl: "https://cards.scryfall.io/normal/front/a/c/acd

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 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 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?

Wasm3 (nim library) how to run c functions

2024-04-01 Thread Nlits
I have a c function: N_LIB_EXPORT N_CDECL(NCSTRING, add_nfunc)(NCSTRING* nfuncsX60flatArgs__p0, NI nfuncsX60flatArgs__p0Len_0); Run That is compiled to wasm successfully. I also am pretty sure I have the `loadWasmEnv` and `findFunction` part down. The thing I can’t wr

How to remove the N_LIB_PRIVATE from exported c code.

2024-04-01 Thread Nlits
Is there any reason why your wasm3 package is not on nimble? I was going to make my own wasm runtime wrapper, but now that I know one exists I don’t need to. As for the emcc keep alive thing, I will see if I need to use it. (I might)

How to remove the N_LIB_PRIVATE from exported c code.

2024-04-01 Thread Nlits
**Successful: (with dynlib pragma)** N_LIB_EXPORT N_CDECL(NCSTRING, add_nfunc)(NCSTRING* nfuncsX60flatArgs__p0, NI nfuncsX60flatArgs__p0Len_0); Run WAST: (export "add_nfunc" (func $52)) Run 👍

How to remove the N_LIB_PRIVATE from exported c code.

2024-04-01 Thread Nlits
Should I use just exportc and dynlib or should I use cdecl as the docs say too?

How to properly make a static type-checking macro?

2024-04-01 Thread Nlits
> You do not have a return type it should be : untyped. I had `: typed` there but the compiler bugged me to remove it as it was the default?

How to remove the N_LIB_PRIVATE from exported c code.

2024-04-01 Thread Nlits
I am using the `exportc` pragma to attempt to export to c then WASM, but the function never appears in the WASM and is generated with `N_LIB_PRIVATE` in the c code. Is there anyway to remove this or am I getting the cause of my issue completely wrong? (I found in the c code only the functions wi

How to properly make a static type-checking macro?

2024-04-01 Thread Nlits
With my current code I keep on getting typeDesc and type instead of both of them being types. How do I fix this specific issue or is there already a better implementation? macro typecheck*(arg: typed, typ: typed) = ## Type check a proc name with args to types let

How to determine the dependencies of a given nim file.

2024-03-30 Thread Nlits
Currently, I am creating a “custom” compiler that compiles nim code into c code, and then manually compiles that c code using emscripten as separate WASM files. (This is needed for future stuff) At the same time, I need to generate the dependencies of each c file, so that I can use it later to l

How to determine the dependencies of a given nim file.

2024-03-30 Thread Nlits
Perfect and quick reply! I will try it now.

Logarithm Implementation Tutorial

2024-03-28 Thread Nlits
> There is no need to compute pow(E, result) twice. Yes, that is small thing that fixing would probably increase the efficiency, I just didn’t get my thought process there while making the tutorial. Thanks for the feedback :) > pow should not be used, not to say inside while loop. Also, impleme

Logarithm Implementation Tutorial

2024-03-27 Thread Nlits
I was working on a project, got distracted, and somehow ended up making a tutorial on how to implement logBASE in pure nim. (The link is [here](https://logarithm-implementation-in-nim.pages.dev/release/)) The end result is this: from std/math import pow, almostEqual, E pro

Conversion between radicals and logs

2024-03-25 Thread Nlits
I have two questions: * Is it mathematically possible to convert between these two? Preferably from logarithms to radicals. (Losslessly) * How would I do this efficiently in nim? This is assuming I already have a radical object If you need any more info or details, please leave a response

Why are let variables not gcsafe? + General Threads and GCSafe understanding help

2024-03-01 Thread Nlits
Constants are gcsafe, and vars are not for “obvious reasons”. I am currently doubting my understanding of nim threads and gcsafe. I first believed by the naming and whatnot that locks stopped a thread to make sure it was the only one that could access a global var, which suggests this is an issu

Ptr byte to cstring?

2023-12-23 Thread Nlits
Although I get the point that the 0’s are not counted for the cstring length, but are for the buffer link. I don’t understand this: var buffer = [byte('a'), byte('b'), 0, 0, 0] let cstr = cast[cstring](buffer[0].addr) doAssert cstr == "ab" # Why does buffer[0] give both `a` a

Ptr byte to cstring?

2023-12-22 Thread Nlits
I am working with the [freeimage](https://nimble.directory/pkg/freeimage) nim library/wrapper, and have this code: proc compressJpeg(imgData: string): string = ## Use freeimage to compress the jpeg files # Open image var mem = FreeImage_OpenMemory(cast[ptr by

Errors within async are not being raised

2023-12-08 Thread Nlits
Fixed: Resorted to manual editing If anyone has any ideas on how to get the macro to work, I would still appreciate it

Errors within async are not being raised

2023-12-04 Thread Nlits
Might be related to

Errors within async are not being raised

2023-12-03 Thread Nlits
Thanks for your reply! I had something similar set before with a wrapper proc, but decided to change it because changing all the arguments twice was tedious. I am going to retry that method but with a template or macro to make it easier.

Errors within async are not being raised

2023-12-02 Thread Nlits
It seems some exceptions are being raised within an awaited async function, but the program stops without a raised error. It also might have to do with cligen dispatching an async proc, although I have no idea how I would efficiently change this. Reproducible Example: import std/[

Nimwave - build TUIs for the terminal, web, and desktop

2023-05-01 Thread Nlits
Honestly, >30 lines for a basic example is enough to overwhelm me. Idk, but I prefer the style of having a minimal example, and then finding things like procs and options on your own. I might look at common.nim again tho

Nimwave - build TUIs for the terminal, web, and desktop

2023-04-30 Thread Nlits
Do you have some basic starter code? The example repo is extremely confusing and feels like a project someone would work on for a few months, not an example.

How to disable highlighting in nim rstgen

2023-04-12 Thread Nlits
Any update on this? I am kind of confused.

How to disable highlighting in nim rstgen

2023-04-07 Thread Nlits
As a flag? It would seem more fitting to go along with the config option in the code. How would i check for a flag btw?

How to disable highlighting in nim rstgen

2023-04-07 Thread Nlits
What should the config option be named? And since it is a string table, should I do true/false, enabled/disabled or what.

How to disable highlighting in nim rstgen

2023-04-06 Thread Nlits
If there is no way is there a workaround?

How to disable highlighting in nim rstgen

2023-04-06 Thread Nlits
Is there a config option that does this? I am switching over to client side highlight.js because in the nim version there was no way to configure class names and it does not support that many languages. I am only switching for the highlight, and am keeping nim for the normal rstgen, which led me

Fstring and Split to Variable Error

2023-03-10 Thread Nlits
Well, split does not return a tuple, it returns a seq. So it can return any amount, and cannot ensure that it would be two. Also, `echo "Enter a file's path > " let file_path = readLine(stdin)` should not be together on the same line

RST in nim.

2023-03-05 Thread Nlits
In my case that is sub-optimal, how would I change that? Also, I found your example works, by my simple `print("Hello World")` does not, is there a reason for this? Run

RST in nim.

2023-03-04 Thread Nlits
More broken RST: ReStructuredText (rst): plain text markup hello world Run When I use it somehow turns into: > Hello world Can someone please tell me how to conf

RST in nim.

2023-03-02 Thread Nlits
After some testing, I can’t get it to highlight even with the capitalization. It even produces a blank output here: Run **Should be code above, no code above.**

import module just for comptime use

2023-03-02 Thread Nlits
I was trying to figure this out once too, recently I found this: but it seems to be incomplete. It be nice to see compile-time imports.

RST in nim.

2023-03-02 Thread Nlits
> What is it? Not compatible or slow? The c version is slow-ish (2s) and it just straight up does not compile to js. (The compilation issue is that something in rstgen uses stdout. > Not true. I tried it with python, and it said “py” was not a registered language or smth

RST in nim.

2023-03-01 Thread Nlits
I needed a way to turn RST to html in nim, so I looked at `packages/docutils/rstgen`. Here are some issues I have with it: * It is not js compatible (I tried making an api, and it was slow) * It only supports nim highlighting, not other popular languages * This one might not be related, but

Using nimble as a library

2023-02-20 Thread Nlits
Ok, more issues. The basic install proc I provided above does not work, as it handles dependencies and I am making my own dependency handler. How would I do just an install, as if the package has no dependencies.

Using nimble as a library

2023-02-20 Thread Nlits
Thanks a lot! I have figured out this: import nimblepkg/[options, packageinfo, download] import std/tables from nimble import removePackage, installFromDir, getDownloadInfo proc generateDummyOptions(): Options = result = initOptions() result.setNimBin

Using nimble as a library

2023-02-20 Thread Nlits
I was trying to use nimble as a library. I want to do 3 things: * Refresh the package list * Get package dependencies * Install a package without installing dependencies But there is the Options type everywhere that everything needs, and I don’t know how I would make one of these for nim

Quill - A nim js library for making text editors

2023-02-08 Thread Nlits
I adapted it to use nim DOM, link [here](https://gist.github.com/thatrandomperson5/fcc59ac4814a601d2d00ac18f5e3eb6d). The issue is that this is made for correct nim, but to work with a live text editor, it needs to handle broken nim code too. Right now I fixed it using a `try except`, but there

Quill - A nim js library for making text editors

2023-02-07 Thread Nlits
I will look at it! I agree this would be a good idea. And @inv2004, I tried shift+arrow and it did work. You should note that at it's core, it is a glorified `textarea`, so anything that works with a `textarea` tags will work here

Quill - A nim js library for making text editors

2023-02-06 Thread Nlits
This is just a fun project I made while being frustrated at codemirror because of it's complexity. It is very open in how you use it, in-fact, the `draw` proc lets you insert DOM nodes directly, so you have all the freedom! [Quill](https://github.com/thatrandomperson5/Quill) is meant to be easy

Random iterator call spawning?

2023-01-21 Thread Nlits
I fixed it, the trace was lying to me and the problem is somewhere else.

Random iterator call spawning?

2023-01-20 Thread Nlits
I get this confusing trace that I will explain below: Sending: StmtList Got: StmtList Got: Ident /home/runner/JumpLang/main.nim(6) main /home/runner/JumpLang/jumplang/interpreter.nim(110) interpret /home/runner/JumpLang/jumplang/interpreter.nim(100) visit /home

How do I fix this?

2023-01-15 Thread Nlits
I’m trying to make a better alternative to nimpretty, but I think it is out of my scope for now, although I might try again later.

How do I fix this?

2023-01-15 Thread Nlits
Code: import system except NimNode import compiler/macros2 import std/[os, strutils] type GoldConfig = ref object proc processFile(path: string, config: GoldConfig) = echo "Gold: ", path let data = readFile(path) echo data.parseStmt().astGen

How do I fix this?

2023-01-15 Thread Nlits
That would be nice, but I can’t seem to reproduce it. I tried here: but it works fine

How do I fix this?

2023-01-14 Thread Nlits
I shared the related code above, what other code do you need?

How do I fix this?

2023-01-14 Thread Nlits
Nimble test? Also I got macros2 from [here](https://github.com/elcritch/cdecl/blob/main/src/cdecl/compiler/macros2.nim) that’s where the error comes from and I don’t know the internals.

How do I fix this?

2023-01-13 Thread Nlits
I get this error out of nowhere: Warning: Using the environment variable: NIMBLE_DIR='/home/runner/GoldNim/nimble-env' Verifying dependencies for goldnim@0.1.0 Info: Dependency on cligen@>= 1.5.37 already satisfied Verifying dependencies for cligen@1.5.37 Building

Illformed AST?

2023-01-13 Thread Nlits
What is wrong with this code? Can the `{}` syntax not have idents? Hint: used config file '/home/runner/.choosenim/toolchains/nim-1.6.10/config/nim.cfg' [Conf] Hint: used config file '/home/runner/.choosenim/toolchains/nim-1.6.10/config/config.nims' [Conf] .

Type mistmatch for `int` and `sink T`

2022-12-30 Thread Nlits
Ah! I failed to catch that. It should be: `result.insert(tmp.byte, 0)`. Thanks for your help

Type mistmatch for `int` and `sink T`

2022-12-29 Thread Nlits
I have this code: proc encode*(s: openArray[int], lo: var int): seq[byte] = var mlength = findMaxLen(s, true) mlength = mlength.binLen + 1 var cache = "" for i in s: cache &= toBin(i, mlength) lo = mlength

How do I turn binary file data into hex representation

2022-10-16 Thread Nlits
Example of the first part of my problem: Expected bytes > BIMG010a���###$$$%%%"""!!!�� What I got from toHex(And back again) > BIMG010aººº###$$$%%%"""!!!ºï It is completely broken. Please help. Conversion script: proc toHexSeq(str:string): seq[string] =

How do I turn binary file data into hex representation

2022-10-15 Thread Nlits
How do i get the byte from the file? That was my main problem. The original binary string was messed up.

How do I turn binary file data into hex representation

2022-10-14 Thread Nlits
> Converting binary 2 string is corrupting my bytes! how do I just get a hex > rep of a binary file! I want hex as in `[2A,34,5B]` or `[0x2A,0x34,0x5B]` Anyone know how I would do this?

How would i safely turn a image from a url to a uri.

2022-09-16 Thread Nlits
Thanks! That helped!

How would i safely turn a image from a url to a uri.

2022-09-16 Thread Nlits
Well, i get this: Run And it does not render The code is an xml node, that is what the node_attrs was.

How would i safely turn a image from a url to a uri.

2022-09-15 Thread Nlits
I tried some things and the image never renders. It works when I save the data directly. Current code: let host = parseUri(url) var client = newHttpClient() client.headers = newHttpHeaders({"Referer": $host}) let rq = client.get(url) var m = newMimetypes() let su

Error when cross-compiling Nim with mingw

2022-09-01 Thread Nlits
I get this error: /nix/store/ap7nr6hb3q9zhphcy2s2bmxvvv g1yzcq-nim-unwrapped-1.4.8/nim/lib/pu re/dynlib.nim(110, 25) Error: undecla red identifier: "getEnv' This might be caused by a recursive m odule dependency: /nix/store/ap7nr6hb3q9zhphcy2s2bmxvvV g1