00:03:33 | FromDiscord | <geekrelief> @_gumbercules hi 😄 |
00:04:42 | FromDiscord | <_gumbercules> In reply to @geekrelief "<@204328759715692544> hi 😄": Good to see you 😄 Also good to see you're still plugging away with Nim 😄 |
00:05:00 | * | alphacentauri quit (Quit: WeeChat 4.0.5) |
00:07:10 | FromDiscord | <geekrelief> In reply to @_gumbercules "Good to see you": hehe, Actually I haven't touched Nim in several months, aside from some contract work and stuff related to gdnim. I do drop in from time to time to see what's up with internals because I chat with jmgomez everyday about the compiler's developemnt. I've been trying to figure out my art pipeline, so I can start prototyping with NimForUE. |
00:09:24 | FromDiscord | <geekrelief> Once I figure out what I can do with Blender + Unreal. I'll try to help out more with NimForUE's development. At the very least, make some docs or videos on how to use it and show off stuff on the gamedev channel. |
00:12:02 | FromDiscord | <geekrelief> lol my name collision issue is related to this old issue from years ago https://github.com/nim-lang/Nim/issues/16462 |
00:12:03 | arkanoid | would you help me how to call a __cdecl function from a statically compiled dll (ldd my.dll shows "not a dynamic executable") ? I'm on linux, but I can cross compile and run with wine I guess. The original exe runs with wine |
00:13:00 | FromDiscord | <_gumbercules> In reply to @geekrelief "Once I figure out": nice! |
00:13:03 | FromDiscord | <Elegantbeef> statically compiled dll? |
00:13:24 | FromDiscord | <Elegantbeef> You are attempting to load symbols from a dll it should be as simple as `proc doThing() {.importc: "name", dynLib: "dynLib.so".}` |
00:14:09 | FromDiscord | <Elegantbeef> I could be wrong but it being statically compiled has 0 barring on the exposed symbols in it |
00:15:31 | arkanoid | Elegantbeef, sorry, what do you mean by 0 barring? |
00:16:19 | FromDiscord | <Elegantbeef> da poop\ |
00:16:20 | FromDiscord | <Elegantbeef> bearing? English is da po |
00:16:30 | FromDiscord | <Elegantbeef> I mean it should have 0 influence on dynamic linking exposed symbols |
00:18:03 | arkanoid | Elegantbeef, you mean the function may well call LoadDll or anything like that at runtime? |
00:21:53 | FromDiscord | <sOkam! 🫐> @pmunch Why did you choose to go with `CXCursor -> JsonArray -> NimNode -> Nim` instead of just `CXCursor -> PNode -> Nim` with `PNode.renderTree`, or even just NimNode creation directly?↵Was that a conscious choice for some reason, or you just didn't know better at the time?↵The intermediate json step feels both slow and unnecessary, but maybe I'm missing some important detail |
00:37:16 | * | krux02_ joined #nim |
00:38:59 | * | krux02 quit (Ping timeout: 246 seconds) |
00:39:51 | FromDiscord | <geekrelief> sent a code paste, see https://play.nim-lang.org/#ix=4IgE |
00:44:33 | FromDiscord | <_gumbercules> In reply to @arkanoid "Elegantbeef, you mean the": Run dumpbin or whatever the equivalent tool is for your compiler toolchain to figure out what symbols the shared library exports |
00:45:19 | FromDiscord | <_gumbercules> If the symbol name is not listed, your C/C++ library isn't exporting it correctly. |
00:47:28 | arkanoid | _gumbercules, I'm on linux, trying to build a program that runs a specific function in a windows dll. The program would be a nim program compiled with --cpu:amd64 -d:mingw |
00:48:01 | arkanoid | _gumbercules, I'm trying to print demangled names with winedump dump -j export -C my.dll , but somehow it refuses to demangle |
00:48:24 | FromDiscord | <_gumbercules> Hmmm |
00:48:41 | arkanoid | by running wine dllexp.exe (by nirsoft) on my.dll, I can actually read demangled stuff |
00:49:36 | FromDiscord | <_gumbercules> I assume nm -g isnt going to work either then |
00:50:16 | FromDiscord | <_gumbercules> And it sounds like winedump is objdump essentially |
00:51:17 | arkanoid | _gumbercules, winedump actually has a "sym" option what works like "winedump sym 'mangledname'" and that actually works |
00:51:26 | FromDiscord | <_gumbercules> Nice!!!! |
00:51:36 | FromDiscord | <_gumbercules> I just was reading about sym hahaha |
00:51:43 | arkanoid | but I'd need to call it one by one, and winedump dump seems to refuse to do the same itself |
00:51:51 | FromDiscord | <_gumbercules> Ooph |
00:53:02 | FromDiscord | <_gumbercules> https://stackoverflow.com/questions/13777681/demangling-in-msvc |
00:53:12 | FromDiscord | <_gumbercules> Not sure if this is relevant or helpful |
00:53:26 | FromDiscord | <_gumbercules> Im not even sure if msvc js involved here or not |
00:53:32 | FromDiscord | <_gumbercules> Is involved even |
00:54:15 | arkanoid | well, my.dll is clearly compiled with msvc as the mangled name are in that form (they start with "?") |
00:54:42 | FromDiscord | <_gumbercules> Okay then maybe it will bear fruit |
00:54:53 | FromDiscord | <_gumbercules> 🤞 |
00:55:06 | arkanoid | example of mangled name "?SetStartProcessor@CF@@QEAAHH@Z" |
00:56:08 | arkanoid | no, neverming, winedump sym is demangling it wrong (!!!) |
00:57:14 | arkanoid | the output of winedump sym on that is "struct CF { void **vtable; /*FIXME: class definition */ };", the demangled output according to nirsoft dllexp.exe is "public: int __cdecl CF::SetStartProcessor(int) __ptr64" |
01:04:24 | FromDiscord | <_gumbercules> Ugh |
01:08:55 | FromDiscord | <geekrelief> @darthvaderbn fixed the issue with gdnim. https://github.com/geekrelief/gdnim/commit/72e2a135479e849aeeff72e45ffb7f64e5c614da |
01:51:33 | FromDiscord | <luxurymode> In reply to @_gumbercules "It definitely sounds like": That makes more sense, thanks. I'll open a PR... assuming there's a repo for this somewhere |
02:02:13 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#ix=4IgQ |
02:02:56 | FromDiscord | <Elegantbeef> `nim -v`? |
02:03:27 | FromDiscord | <user2m> sent a long message, see http://ix.io/4yj1 |
02:03:53 | FromDiscord | <Elegantbeef> Cmon update your Nim |
02:04:23 | FromDiscord | <user2m> i'm using the nimjwt package and I'm not sure if it works with 2.0 yet |
02:04:57 | FromDiscord | <leorize> nim 2.0 sounds fancy but not that much breaking changes are there |
02:04:59 | FromDiscord | <Elegantbeef> Nim 1.6.14 exists |
02:06:00 | FromDiscord | <user2m> just switched to 1.6.14 with choosenim and still same issue |
02:06:05 | FromDiscord | <user2m> I'll try 2 |
02:07:00 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#ix=4IgR |
02:07:18 | FromDiscord | <Elegantbeef> stable |
02:07:52 | FromDiscord | <user2m> as in `choosenim stable` ? |
02:08:09 | FromDiscord | <Elegantbeef> `choosenim update stable` |
02:08:09 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#ix=4IgS |
02:08:21 | FromDiscord | <user2m> gotcha |
02:08:43 | FromDiscord | <user2m> still same issue |
02:08:50 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#ix=4IgT |
02:09:59 | FromDiscord | <Elegantbeef> Is that the full error message? |
02:10:30 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#ix=4IgU |
02:11:15 | FromDiscord | <_gumbercules> In reply to @luxurymode "That makes more sense,": I think it should just be the main Nim repo but I could be mistaken. |
02:12:07 | FromDiscord | <Elegantbeef> Do you have two `Event` types in your modules? |
02:12:28 | FromDiscord | <Elegantbeef> Without a min repro it's hard to say anything |
02:13:31 | FromDiscord | <leorize> and here I thought Nim got improved error messages for these now |
02:13:55 | FromDiscord | <Elegantbeef> Hey I did it! |
02:13:59 | FromDiscord | <user2m> this is the full module |
02:14:00 | FromDiscord | <Elegantbeef> And then ring also did it |
02:14:07 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#ix=4IgV |
02:23:00 | FromDiscord | <Elegantbeef> `EventTarget` has a `onClick` field |
02:24:23 | arkanoid | what would be the nim signature equivalent for " __cdecl Foo::Foo(void) __ptr64" ? I'm trying with "proc (): pointer {.cdecl.}" but it fails |
02:25:11 | FromDiscord | <Elegantbeef> `proc foo(): ptr uint64 {.cdecl.}` |
02:25:38 | FromDiscord | <leorize> what an error message |
02:26:53 | FromDiscord | <Elegantbeef> Well it's a proc that takes an `event` |
02:26:53 | FromDiscord | <Elegantbeef> So yea it's a shitty message |
02:27:12 | FromDiscord | <leorize> maybe we should start training chatgpt to figure out nim errors |
02:27:31 | FromDiscord | <Elegantbeef> Or just fix the error messages |
02:27:41 | FromDiscord | <Elegantbeef> Hmm one of those has to be easier |
02:28:10 | arkanoid | Elegantbeef, thanks. Sadly it keeps going sigsegv :( https://play.nim-lang.org/#ix=4IgX |
02:28:47 | arkanoid | the loadLib and checkedSymAddr (load symbol) parts are ok, but calling the proc goes sigsegv |
02:28:56 | FromDiscord | <Elegantbeef> Have you considered making a proper system library? |
02:29:06 | FromDiscord | <Elegantbeef> With a proper exposed name |
02:29:17 | FromDiscord | <leorize> on Windows it's likely stdcall |
02:29:45 | FromDiscord | <Elegantbeef> Yea default is stdcall, but it shouldnt matter in this case since it's a void proc no? |
02:30:25 | FromDiscord | <leorize> true |
02:30:32 | FromDiscord | <leorize> that sym name reminds me of C++ mangling |
02:30:46 | arkanoid | yes, it's C++ mangling |
02:30:51 | arkanoid | I'm not the author if that dll |
02:31:04 | FromDiscord | <leorize> then are you building with msvc? |
02:31:20 | arkanoid | no, mingw |
02:31:31 | FromDiscord | <leorize> I don't remember what's the calling convention for stuff like constructors, though |
02:31:40 | FromDiscord | <leorize> mingw and msvc have different C++ ABI |
02:32:15 | arkanoid | I'm reading the calling convention with dllexp.exe, it says cdecl |
02:32:23 | arkanoid | leorize, oh! really? damn |
02:33:00 | FromDiscord | <user2m> In reply to @Elegantbeef "`EventTarget` has a `onClick`": ahh makes sense |
02:33:24 | FromDiscord | <Elegantbeef> Don't lie to me it doesnt make sense! |
02:33:34 | arkanoid | I'm not a windows daily user so I didn't know that :( I was expecting mingw to be able to use windows dlls |
02:35:50 | FromDiscord | <Elegantbeef> Afaik it should be able to use properly authored DLLs |
02:35:51 | FromDiscord | <Elegantbeef> But it's that are not properly authored that get in the way |
02:35:51 | FromDiscord | <leorize> C++ ABI is non-standardized, unfortunately |
02:36:07 | arkanoid | mmm, here they say that clang has an msvc compatible mode https://stackoverflow.com/a/7119896 |
02:36:17 | FromDiscord | <leorize> usually I'd recommend writing a bridge library that compiles to C++ and exposes C interfaces |
02:36:36 | FromDiscord | <leorize> the thing is that you don't know what the constructor symbol takes |
02:36:51 | FromDiscord | <Elegantbeef> Lol the complex chain of using a C++ dll |
02:37:38 | arkanoid | leorize, the mangled name should expose the arguments (?) dllexp.exe says quite clearly that that constructor takes no argument and has a cdecl call |
02:37:54 | arkanoid | from the report "public: __cdecl CFarsite::CFarsite(void) __ptr64" |
02:38:38 | FromDiscord | <leorize> i'd say that unless you can find docs saying exactly what msvc does I'd be very skeptical about it |
02:40:31 | arkanoid | leorize, thanks for the hint. I was taking ddlexp output as solid truth. |
02:44:09 | FromDiscord | <leorize> you're welcome, C++ is quite annoying to navigate |
02:46:58 | arkanoid | leorize, I read also that your suggestions about writing the C wrapper is present here too https://stackoverflow.com/a/2473242 . Damn, I was not aware about the C++ hell with msvc across versions |
02:47:37 | arkanoid | I only see two paths. Get msvc to that specific version and write a C wrapper, or possibly get clang + windows sdk work with that |
02:48:01 | FromDiscord | <leorize> something that you can try is to read up on some C++ wrapping engines |
02:48:08 | FromDiscord | <leorize> ie. the kind of stuff people use to wrap Qt |
02:48:42 | FromDiscord | <leorize> many of them just pivot to a C bridge but some appear to interface with C++ directly |
02:48:42 | FromDiscord | <leorize> but it is an annoying path |
02:56:23 | FromDiscord | <leorize> btw latest msvc abi should have backward compat for at most version 2015 |
03:02:58 | FromDiscord | <_gumbercules> I went through this hell recently minus the cross compilation |
03:03:45 | FromDiscord | <_gumbercules> ended up just writing a C API because I couldn't be bothered to fuck with the vtable in the struct memory layout on the Nim side |
03:04:08 | FromDiscord | <_gumbercules> well - I didn't write the C API - I found one but regardless |
03:05:58 | FromDiscord | <leorize> if nim ever got big this will be an issue for others, too \:P |
03:05:59 | FromDiscord | <leorize> the curse of ABI |
03:18:56 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#ix=4Ihd |
03:19:07 | FromDiscord | <Elegantbeef> Just make a C header generator, and problem solved! 😄 |
03:19:11 | FromDiscord | <Elegantbeef> Sorry pascal header generator |
03:19:15 | FromDiscord | <leorize> lol |
03:19:43 | FromDiscord | <Elegantbeef> Cannot tell if that's to me or to the error message |
03:19:54 | FromDiscord | <leorize> yes \:P |
03:20:10 | FromDiscord | <leorize> also I don't think async callback works for js |
03:20:12 | FromDiscord | <Elegantbeef> import another `addEventListener` that takes a `async` proc probably |
03:20:18 | FromDiscord | <Elegantbeef> I don't know JS async |
03:20:55 | FromDiscord | <Elegantbeef> Though given I have an open PR to jellyfin, I probably should learn it |
03:25:46 | FromDiscord | <leorize> it's more that I don't think the async macro was written to handle the callback case, but I might be wrong |
03:31:45 | FromDiscord | <user2m> sent a code paste, see https://paste.rs/reuNi |
03:32:40 | FromDiscord | <user2m> kinda odd something basic like that isn't included in std/asyncjs |
03:34:33 | FromDiscord | <leorize> nim's js backend is very underdeveloped |
03:37:22 | FromDiscord | <Elegantbeef> Less the backend and more the library |
04:18:20 | * | krux02_ quit (Remote host closed the connection) |
05:06:51 | FromDiscord | <pmunch> In reply to @heysokam "<@392962235737047041> Why did you": The reason for this was to allow Futhark to look at the existing program and change how things got wrapped. Of course I ended up solving this by generating `with` statements instead, so the benefit isn't quite as big. It does however mean that the macro doesn't have to serialize the inputs to pass to the program |
06:33:54 | * | rockcavera quit (Remote host closed the connection) |
06:38:56 | arkanoid | leorize: found some details https://clang.llvm.org/docs/MSVCCompatibility.html |
06:55:03 | * | Eternado joined #nim |
07:01:34 | * | PMunch joined #nim |
07:04:57 | * | advesperacit joined #nim |
07:06:06 | * | Eternado quit (Quit: Client closed) |
07:26:23 | * | azimut_ quit (Ping timeout: 252 seconds) |
08:22:13 | * | alphacentauri joined #nim |
09:19:06 | FromDiscord | <hotdog6666> @user2m https://nim-lang.org/docs/dom.html#addEventListener%2CEventTarget%2Ccstring%2Cproc%28Event%29%2CAddEventListenerOptions |
09:20:03 | FromDiscord | <hotdog6666> In reply to @leorize "nim's js backend is": It works fine for me |
09:36:00 | arkanoid | how can I show the compilation command line arguments that nim uses to invoke cc? |
09:36:11 | arkanoid | nimble --verbose still hides them |
09:55:22 | FromDiscord | <nnsee> `nim c --verbosity:2 whatever.nim` works for me |
10:26:37 | arkanoid | how to pass that to nimble build? |
10:39:06 | NimEventer | New thread by mildred: Idea : reuse libraries from other languages, see https://forum.nim-lang.org/t/10530 |
10:43:49 | FromDiscord | <marioboi3112> i am really confused with how many keywords nim has, when i asked gpt it said 108, when i asked google it says 70 when i asked another ai it said its 50, |
10:44:04 | FromDiscord | <marioboi3112> does anyone know how many keywords nim has? |
10:44:46 | FromDiscord | <vindaar> https://nim-lang.github.io/Nim/manual.html#lexical-analysis-identifiers-amp-keywords |
10:46:09 | FromDiscord | <marioboi3112> In reply to @vindaar "https://nim-lang.github.io/Nim/manual.html#lexical-": alright thanks! |
10:50:02 | PMunch | Asking an AI for a question like that is like asking your crazy uncle how far away the moon is |
10:50:51 | arkanoid | haha |
10:51:31 | arkanoid | what's the ratio behind which nim args wants --foo: , and which wants --foo= ? |
10:52:45 | arkanoid | for example --cc:clang, and --clang.exe= ? |
10:53:00 | FromDiscord | <marioboi3112> In reply to @PMunch "Asking an AI for": lol understandable |
10:54:42 | PMunch | arkanoid, = and : are the same |
10:54:58 | PMunch | You can do `--cc=clang` and `--clang.exe:<path>` |
10:55:05 | FromDiscord | <nnsee> In reply to @marioboi3112 "i am really confused": chatgpt has trouble adding 3 to 5, i wouldn't trust it with exact numbers like that |
10:55:13 | PMunch | So the ratio is 1 I guess |
10:55:34 | arkanoid | mmm |
10:56:13 | FromDiscord | <marioboi3112> In reply to @nnsee "chatgpt has trouble adding": yeah im surprised that i asked AI for such question... |
11:02:51 | arkanoid | do you know if I can use absolute paths for switch("clang.exe",...) ? |
11:05:16 | arkanoid | it seems to me that clang.exe and clang.linkerexe are completely ignored |
11:05:53 | arkanoid | I can type random strings in there but nimble build keeps searching for system clang |
11:45:37 | arkanoid | to me "nim cpp --cc:clang --clang.exe=this_is_ignored src/foo.nim" compiles with /usr/bin/clang++ |
11:46:03 | arkanoid | I can type jibberish into --clang.exe option, as it is completely ignored |
11:50:14 | PMunch | That's because you're compiling with cpp |
11:51:30 | PMunch | Try to set `--clang.cpp.exe` |
11:52:40 | arkanoid | ... just why |
12:07:19 | arkanoid | PMunch: thanks |
12:07:54 | PMunch | In case you want to set them system wide and have different binaries for C and C++ compilers |
12:08:35 | PMunch | But yeah, it should probably inherit clang.exe when not set to anything |
12:37:24 | arkanoid | I'm trying to cross compile from linux to windows using clang toolchain. I'm trying to compile a trivial hello world. If I use this config.nims https://termbin.com/vnm3v with "nimble build" I pass the compilation phase, but it fails the linking phase with error "lld: error: unable to find library -ldl" |
12:37:54 | arkanoid | afaik, windows does not have libdl, and I am not asking for it, why nim wants that for an helloworld? |
12:45:07 | FromDiscord | <firq> sent a long message, see http://ix.io/4IiB |
12:56:59 | FromDiscord | <nervecenter> I'm not completely sure but there is an important rule: Stuff created with `ref` is made on the heap and GC-managed, while dynamic types like strings created without `ref` are managed by a scoped stack pointer. So they'll be destroyed when they go out of scope. If you have an unsafe pointer into that data, it's probably a dangling reference after the scope exits. |
12:57:12 | FromDiscord | <nervecenter> (edit) removed "made on the heap and" |
12:57:59 | FromDiscord | <nervecenter> Probably best to ask in #internals |
13:03:34 | FromDiscord | <firq> Ok, I didn't know that distinction, but that makes sense. Thanks. |
13:05:20 | * | PMunch quit (Quit: Leaving) |
13:48:15 | arkanoid | leorize: success! I'm calling a windows msvc c++ function from a nim program cross-compiled with x86_64-w64-mingw32-clang++ ! :) |
13:50:24 | FromDiscord | <System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4IiR |
13:53:01 | FromDiscord | <odexine> ? |
13:53:05 | FromDiscord | <odexine> What architecture |
13:53:42 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @odexine "What architecture": My own↵But inspired from 6502 with the registers |
13:53:44 | arkanoid | but I'm quite puzzled: who is in charge to translate/demangle c++ names? I have to call checkedSymAddr passing the msvc c++ mangled name inside the dll |
13:54:14 | FromDiscord | <odexine> In reply to @sys64 "My own But inspired": How are we supposed to answer “are there any missing op codes” then ahaha |
13:54:32 | FromDiscord | <odexine> It’s up to you? Look at other architectures and decide what to add? |
13:57:17 | FromDiscord | <jviega> You only need one instruction for turing completeness 🙂 |
13:58:38 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @jviega "You only need one": Which one? |
13:58:42 | FromDiscord | <odexine> MOV |
13:58:50 | FromDiscord | <jviega> There are many options |
13:58:56 | FromDiscord | <odexine> That’s true as well |
13:58:59 | FromDiscord | <jviega> Google "one instruction machines" |
13:59:01 | FromDiscord | <odexine> The most famous one is the MOV one |
13:59:04 | FromDiscord | <jviega> It's a big thing |
13:59:29 | FromDiscord | <jviega> I thought it was ADD and Jump if Not Zero 🙂 |
14:00:06 | FromDiscord | <jviega> Anyway, you don't need any more to have turing completeness if that's the bar |
14:00:13 | FromDiscord | <odexine> I think a lot of people know about movfuscator |
14:00:36 | FromDiscord | <System64 ~ Flandre Scarlet> sent a code paste, see https://play.nim-lang.org/#ix=4IiX |
14:01:39 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @jviega "Google "one instruction machines"": Ah yeah and there is something↵https://github.com/xoreaxeaxeax/movfuscator |
14:01:44 | FromDiscord | <odexine> I was responding to your “which one is the only one needed for TC” |
14:02:13 | FromDiscord | <odexine> In reply to @odexine "I think a lot": Told ya @jtv |
14:02:49 | FromDiscord | <System64 ~ Flandre Scarlet> Ah yeah just saw that↵However it probably hurts performances |
14:03:05 | FromDiscord | <odexine> It does of course |
14:03:15 | FromDiscord | <odexine> That doesn’t matter in theory |
14:03:32 | FromDiscord | <jviega> Well, that's much newer, my attention in that space is about 20 years old 🙂 |
14:03:40 | FromDiscord | <odexine> True |
14:03:52 | FromDiscord | <odexine> Your attention in that space is nearly as old as me |
14:03:55 | FromDiscord | <jviega> 👴 Back in my day |
14:04:14 | FromDiscord | <jviega> 🧓 Uphill, both ways! |
14:04:27 | FromDiscord | <Phil> Don't forget the hail! |
14:08:37 | FromDiscord | <nnsee> sent a code paste, see https://play.nim-lang.org/#ix=4Ij1 |
14:16:07 | * | rockcavera joined #nim |
14:28:15 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @nnsee "if x86_64 is to": Oh god we won't talk about x86/64 ASM NOOOOOOOOO! |
14:33:38 | FromDiscord | <leorize> arkanoid\: congrats, so what's the trick? |
14:34:41 | arkanoid | leorize, this what I had to use https://termbin.com/mjin |
14:35:18 | arkanoid | so far, I'm having success dynamically loading the functions with dynlib.loadLib + checkedSymAddr |
14:35:39 | arkanoid | I should try to move the thing to importcpp |
14:36:04 | arkanoid | also I have to use mnvp mangled names as symbols |
14:36:42 | arkanoid | something like let "constructCF = cast[ConstructCF](lib.checkedSymAddr("??0CF@@QEAA@XZ"))" |
14:42:45 | FromDiscord | <nnsee> sent a long message, see http://ix.io/4Ijc |
15:33:51 | * | disso-peach quit (Quit: Leaving) |
15:48:43 | FromDiscord | <_gumbercules> In reply to @arkanoid "<@695851404832538684>, this what I": glad you got it sorted - what a headache |
15:59:15 | arkanoid | _gumbercules, yes, but I've learned a lot. Thanks for your hints |
15:59:43 | arkanoid | there are more even better holes in my understanding right now. One related to nim is: when it mangles/demangles in ffi |
16:05:04 | arkanoid | also I need to understand why I succeed in loading and running dll procs via dynlib, but if I try to importcpp instead the same signature I get "error: member reference base type 'void *' is not a structure or union" |
16:05:58 | FromDiscord | <leorize> if you can post the code with that error I could give you a few pointers |
16:06:38 | FromDiscord | <leorize> anything that passes through the compiler got mangled unless tricks like `importc` is used to change the mangling↵(<@709044657232936960_arkanoid=5b=49=52=43=5d>) |
16:12:56 | arkanoid | leorize, thank. I've just found something curious. If I importc: "<c++ mangled name>", it works! |
16:13:19 | arkanoid | but this is really confusing. I'm importing c++ mangled names via importc |
16:13:45 | FromDiscord | <leorize> importc is the "simple" way to name it |
16:14:04 | FromDiscord | <leorize> what it really does is that it imports a symbol by the verbatim name |
16:14:22 | arkanoid | does it mean that importc does nothing like remangling? |
16:14:29 | FromDiscord | <leorize> the C here just means no mangling, it doesn't even imply C calling convention |
16:14:34 | FromDiscord | <leorize> yep |
16:15:28 | arkanoid | this works: proc getErrorMessage(cf: CF, error: cint): cstring {.cdecl, dynlib:"CF.dll", importc: "?GetErrorMessage@CF@@QEAAPEADH@Z".} |
16:15:56 | arkanoid | but I'm failing to convert that to the proper importcpp |
16:16:08 | FromDiscord | <leorize> because you won't be able to |
16:16:18 | FromDiscord | <leorize> importcpp is a pattern generator |
16:16:43 | FromDiscord | <leorize> it doesn't actually "import" a symbol |
16:17:13 | FromDiscord | <leorize> it just generates C++ calls in the source code |
16:17:32 | FromDiscord | <leorize> and requires a header defining the symbol you want to use to be included |
16:17:38 | FromDiscord | <leorize> and definitely doesn't work with `dynlib` |
16:18:25 | arkanoid | oh, wow, the two seems wildly different |
16:19:24 | arkanoid | so importc looks for a specific mangled symbol name, whatever it is (no matter if c++), and calls is with the provided calling convention |
16:19:27 | FromDiscord | <leorize> basically think of `importcpp`/`importjs` as a fancy `emit` |
16:19:38 | FromDiscord | <leorize> yep |
16:21:10 | arkanoid | this makes sense! but why does the nim compiler lets me use importcpp even when I don't provide header pragma? |
16:21:49 | FromDiscord | <leorize> because no one blocked it \:P |
16:22:10 | arkanoid | damn, I've spent useless hours on this! |
16:22:40 | FromDiscord | <leorize> the nicer explaination is that it's typically used to access class procs, so you would already have a `type X {.importcpp, header.}` which effectively already imported the header |
16:23:13 | FromDiscord | <leorize> and ofc, you can also just `emit` a C++ proc definition and use it directly using `importcpp` |
16:24:05 | FromDiscord | <jmgomez> In reply to @arkanoid "this makes sense! but": because you dont have to |
16:24:19 | FromDiscord | <jmgomez> the header can be included somewhere else |
16:24:50 | arkanoid | but why does importcpp require header? I mean, if this works: proc getErrorMessage(cf: CF, error: cint): cstring {.cdecl, dynlib:"CF.dll", importc: "?GetErrorMessage@CF@@QEAAPEADH@Z".} . Should I be able to do proc getErrorMessage(cf: CF, error: cint): cstring {.cdecl, dynlib:"CF.dll", importcpp: "#.GetErrorMessage(@)".} ? |
16:26:04 | FromDiscord | <leorize> because it's a pattern generator |
16:26:11 | FromDiscord | <leorize> it doesn't do any symbol magic |
16:27:08 | arkanoid | ok, so that it will never generate the mangled name required to find the address into the dll |
16:27:19 | arkanoid | unless the header provides it (?) |
16:30:30 | arkanoid | btw, considering that demangling msvc c++ names is probably very possible at compile time (I'm using dllexp.exe and http://demangler.com/ right now), it could be possible to macro the thing. List exported dll procs, demangle the name, create nim signature, importc the mangled name, done |
16:30:52 | arkanoid | well, this is if you have no types :P |
16:41:45 | arkanoid | can I use absolute or relative function address instead of mangled name? |
16:45:57 | * | junaid_ joined #nim |
16:46:29 | FromDiscord | <Phil> sent a long message, see http://ix.io/4Ijx |
16:51:11 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4Ijz |
17:13:22 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @nnsee "`ADDSUBPS` > Adds odd-numbered": AAAAAAAAH my brain! |
17:23:32 | * | azimut joined #nim |
17:33:26 | * | advesperacit quit (Ping timeout: 272 seconds) |
17:33:32 | * | advesperacit_ joined #nim |
17:43:01 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#ix=4IjM |
18:09:28 | arkanoid | if I have a C++ function with signature "class CFSpots * __cdecl CF::GetSpots(void)", what's the return type? Is it an uncheckedArray[CFSpots], or is it a ptr CFSpots ? |
18:10:45 | FromDiscord | <mratsim> Anyone published a Rust package with a Nim backend?↵↵How did they handle calling the Nim compiler to build a .a static library and link it when people do `cargo build` or `cargo run` ? |
18:19:46 | FromDiscord | <.aingel.> In reply to @user2m "Does anyone know how": Dont know how much this will help but https://github.com/yglukhov/nimpy/issues/278 |
18:19:51 | FromDiscord | <.aingel.> The author says he doesn't have a good way to fix it |
18:19:59 | FromDiscord | <.aingel.> https://stackoverflow.com/questions/19292957/how-can-i-troubleshoot-python-could-not-find-platform-independent-libraries-pr |
18:20:11 | FromDiscord | <.aingel.> This might give you some info on how to force it to work |
18:25:24 | * | krux02 joined #nim |
18:30:58 | NimEventer | New thread by mratsim: Infiltrating Rust with Nim packages, see https://forum.nim-lang.org/t/10532 |
18:49:11 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#ix=4Ik5 |
19:07:05 | * | junaid_ quit (Remote host closed the connection) |
19:14:25 | FromDiscord | <raynei486> In reply to @arkanoid "if I have a": if it's a block of memory (not just pointer to one thing) then it should be `ptr uncheckedArray[CFSpots]` |
19:14:33 | FromDiscord | <raynei486> but most of the time that's the pattern anyways |
19:24:17 | FromDiscord | <.aingel.> In reply to @user2m "Figured it out! you": Awesome! |
19:24:31 | FromDiscord | <.aingel.> Maybe you can post that in the thread on github, or if you don't plan to i'll post it |
19:24:43 | FromDiscord | <.aingel.> Cause it can help someone else trying to do the same thing |
19:34:30 | FromDiscord | <Chronos [She/Her]> I have a lib for Java codegen but... I think I need to remake it :p |
19:34:37 | FromDiscord | <Chronos [She/Her]> This was when I was new to the language |
19:34:47 | FromDiscord | <Chronos [She/Her]> Wow literally a year ago- |
19:35:03 | FromDiscord | <Chronos [She/Her]> https://github.com/Yu-Vitaqua-fer-Chronos/Codegenlib |
19:35:19 | FromDiscord | <Chronos [She/Her]> Exactly a year ago from today- |
20:10:19 | FromDiscord | <ebahie> hello, i had a question about the json module. i have been writing a discord api wrapper to learn nim and ive been having issues understanding how to parse multiple practically identical json objects from a file and nested objects and how to do this recursively |
20:10:52 | FromDiscord | <ebahie> this is what the json looks like, it can have hundreds of messages i might add this is just so i can send it here |
20:11:02 | FromDiscord | <ebahie> https://media.discordapp.net/attachments/371759389889003532/1159945930376761394/message.json?ex=6532ded4&is=652069d4&hm=9d61233d57558254ebe5ca609db44cd6d06e5572bc781d441f9306985c988bfc& |
20:11:32 | FromDiscord | <ebahie> im mainly looking for content, username and timestamp |
20:16:11 | FromDiscord | <user2m> In reply to @.aingel. "Maybe you can post": just did! |
20:17:33 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/oYCTT |
20:17:57 | FromDiscord | <Elegantbeef> You also can use `std/jsonutils` to make hooks for your objects |
20:18:39 | * | derpydoo joined #nim |
20:20:36 | * | krux02 quit (Remote host closed the connection) |
20:20:48 | FromDiscord | <ebahie> sent a code paste, see https://play.nim-lang.org/#ix=4Ikw |
20:23:23 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#ix=4Ikx |
20:23:51 | FromDiscord | <user2m> (edit) "https://play.nim-lang.org/#ix=4Ikx" => "https://play.nim-lang.org/#ix=4Iky" |
20:24:15 | FromDiscord | <nervecenter> sent a long message, see http://ix.io/4Ikz |
20:24:16 | FromDiscord | <user2m> In reply to @ebahie "but how do i": once it's in a seq you can check how many response objects there are |
20:24:33 | FromDiscord | <nervecenter> (edit) "http://ix.io/4Ikz" => "http://ix.io/4IkA" |
20:24:40 | FromDiscord | <Elegantbeef> I mean we have `std/jsonutils` |
20:24:41 | FromDiscord | <Elegantbeef> So just write a json hook |
20:24:43 | FromDiscord | <nervecenter> (edit) "http://ix.io/4IkA" => "http://ix.io/4IkB" |
20:25:07 | FromDiscord | <nervecenter> (edit) "http://ix.io/4IkB" => "http://ix.io/4IkC" |
20:25:17 | FromDiscord | <nervecenter> (edit) "http://ix.io/4IkC" => "http://ix.io/4IkD" |
20:25:32 | FromDiscord | <Elegantbeef> Nerve you're suggesting a hook but manually |
20:25:45 | FromDiscord | <Elegantbeef> Using jsonhooks are much better than manual code as it is reusable |
20:25:59 | FromDiscord | <nervecenter> And if he uses it once it's 4 lines of code that he doesn't need to reuse |
20:26:03 | FromDiscord | <nervecenter> don't add necessary steps |
20:26:08 | FromDiscord | <nervecenter> (edit) "necessary" => "unecessary" |
20:26:08 | FromDiscord | <Elegantbeef> Lol |
20:26:34 | FromDiscord | <ebahie> alright ill see what i can do |
20:26:48 | FromDiscord | <Elegantbeef> The only difference between using json hook and your way is that yours does not compose |
20:26:49 | FromDiscord | <Elegantbeef> `std/jsonutils` has a generic interface so you can deserialise any type with a implemented hook |
20:27:34 | FromDiscord | <nervecenter> He hasn't brought up any reason to need composition or reuse just yet, he's not making an enterprise application, KISS |
20:27:43 | FromDiscord | <nervecenter> Teach the basics |
20:28:04 | FromDiscord | <ebahie> is jsonutils not included in nim 2.0.0? |
20:28:20 | FromDiscord | <ebahie> https://media.discordapp.net/attachments/371759389889003532/1159950286723502241/image.png?ex=6532e2e3&is=65206de3&hm=abf811f6fad52f92da220021adf36ce4916c086d3579a9c4f0e8bd73c432860e& |
20:28:23 | FromDiscord | <Elegantbeef> It is in 2.0 |
20:28:33 | FromDiscord | <Elegantbeef> `std/jsonutils` |
20:28:55 | FromDiscord | <Elegantbeef> To be fair using jsonhooks is the exact same complexity as your solution it's just more pluggable so there is not much reason not to |
20:29:10 | FromDiscord | <ebahie> In reply to @Elegantbeef "`std/jsonutils`": oooh ok |
20:29:26 | FromDiscord | <Elegantbeef> Always prefix std imports with `std/` |
20:29:30 | FromDiscord | <Elegantbeef> You can group them together doing `std/[a, b, c]` |
20:30:07 | FromDiscord | <ebahie> alrighty |
20:30:33 | FromDiscord | <Elegantbeef> But yes as nerve pointed out you do not need jsonutils, but it's highly suggested if you think any of these types will appear in other objects |
20:44:48 | FromDiscord | <.aingel.> In reply to @user2m "just did!": Awesome, thank you! |
20:58:38 | * | advesperacit_ quit (Ping timeout: 272 seconds) |
20:58:42 | * | advesperacit joined #nim |
21:59:50 | * | advesperacit quit () |
22:01:00 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4IkU |
22:07:48 | FromDiscord | <sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4IkV |
22:07:49 | FromDiscord | <sOkam! 🫐> that's my first thought |
22:08:46 | FromDiscord | <Phil> When statements not supported within the gui block |
22:09:06 | FromDiscord | <sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4IkW |
22:09:10 | FromDiscord | <sOkam! 🫐> oh |
22:09:50 | FromDiscord | <Phil> And if I do basically the entire body of the proc twice via when statement then I haven't really removed duplication, I've now simply moved it into the same proc |
22:11:16 | FromDiscord | <sOkam! 🫐> yeah pretty much |
22:11:27 | FromDiscord | <sOkam! 🫐> is implementing when blocks unfeasible? |
22:13:32 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4IkY |
22:13:48 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4IkY" => "https://play.nim-lang.org/#ix=4IkZ" |
22:14:15 | FromDiscord | <Phil> And as one might imagine `toListFormField` and `toFormField` are near identical except from where their values come from |
22:15:01 | FromDiscord | <Phil> (edit) "And as one might imagine `toListFormField` and `toFormField` are near identical except from where their values come from ... " added "and thus also where they need to modify them." |
22:17:36 | * | derpydoo quit (Quit: derpydoo) |
22:21:41 | FromDiscord | <ezquerra> sent a code paste, see https://play.nim-lang.org/#ix=4Il2 |
22:25:02 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4Il3 |
22:25:08 | FromDiscord | <Phil> on nim 2.0 |
22:31:09 | FromDiscord | <ezquerra> That's odd... I'm on nim 2.0 too |
22:31:35 | * | alphacentauri quit (Quit: WeeChat 4.0.5) |
22:32:19 | * | alphacentauri joined #nim |
22:32:42 | FromDiscord | <leorize> check if your variable was shadowed |
22:34:09 | FromDiscord | <ezquerra> sent a code paste, see https://play.nim-lang.org/#ix=4Il7 |
22:34:28 | FromDiscord | <Chronos [She/Her]> Sorry for interrupting but does anyone know if GitHub Actions has access to curl or? |
22:34:42 | FromDiscord | <leorize> yes, they have curl |
22:35:01 | FromDiscord | <ezquerra> It is actually generating a Hint, not a Warning but still (` Hint: 'work_size' is declared but not used [XDeclaredButNotUsed]`) |
22:35:15 | FromDiscord | <Chronos [She/Her]> Thanks! |
22:36:00 | FromDiscord | <leorize> I'm scared of that code \:P↵(@ezquerra) |
22:37:39 | FromDiscord | <leorize> if it doesn't work then maybe file an issue given that you have a minimal repro |
22:37:51 | FromDiscord | <ezquerra> Blame @mratsim 🙂 |
22:41:51 | FromDiscord | <Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4Ila |
22:42:45 | FromDiscord | <Chronos [She/Her]> sent a code paste, see https://play.nim-lang.org/#ix=4Ilb |
22:54:40 | * | alphacentauri quit (Quit: WeeChat 4.0.5) |
22:56:46 | FromDiscord | <Chronos [She/Her]> Removing the use of `nil`s in my code :) |
22:57:03 | FromDiscord | <Elegantbeef> Congrats! |
23:14:41 | FromDiscord | <inv2004> Hello, I started to check the one: https://github.com/jinyus/related_post_gen↵↵I am totally lost.↵Was trying to reading the rules and code, and it is not clear |
23:15:44 | FromDiscord | <inv2004> for example: `{p1: [a, b], p2: [b, c]}` which is correct amount of shared posts? code shows that it is `{p1: 1, p2: 0}` |
23:16:04 | FromDiscord | <inv2004> looks like it is some kind of "sliding" count, but I do not see anything like that in rules |
23:16:35 | FromDiscord | <inv2004> and it makes not sense |
23:19:12 | FromDiscord | <Chronos [She/Her]> In reply to @Elegantbeef "Congrats!": Hopefully I'll make my code completely type safe eventually lol |
23:19:23 | FromDiscord | <Chronos [She/Her]> Anyway, have a good day/night y'all, logging off for now |
23:25:33 | FromDiscord | <inv2004> I would add that it just count the last post |
23:42:03 | * | alphacentauri joined #nim |
23:46:09 | FromDiscord | <sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4Ill |
23:46:29 | FromDiscord | <Elegantbeef> `a..b` only works for sets |
23:46:38 | FromDiscord | <sOkam! 🫐> it also worked for arrays so far |
23:46:56 | FromDiscord | <leorize> you'd create an array containing a Slice |
23:48:18 | FromDiscord | <sOkam! 🫐> i guess |
23:49:07 | FromDiscord | <sOkam! 🫐> sent a code paste, see https://play.nim-lang.org/#ix=4Ilp |
23:49:51 | FromDiscord | <Elegantbeef> So does `{nkIdent, nkInfix, nkPar, nkCharLit..nkTripleStrLit}` |
23:49:52 | FromDiscord | <Elegantbeef> Atleast it should |
23:50:18 | FromDiscord | <leorize> a set is better for this job too |
23:51:15 | FromDiscord | <Elegantbeef> `O(1)` lookups go brrrrr |
23:51:47 | FromDiscord | <Elegantbeef> Plus memory efficient and faster to iterate |
23:51:55 | FromDiscord | <leorize> not to mention native support in `case of` |
23:52:30 | FromDiscord | <Elegantbeef> Now if only we could use `case` on 64bit and smaller sets |