00:15:49 | FromDiscord | <timotheecour> look at treeRepr and it should become clear |
00:17:12 | FromDiscord | <timotheecour> (edit) "look at treeRepr and it should become clear" => "sent a code paste, see https://paste.rs/L0Q" |
00:30:13 | * | auxym_ joined #nim |
00:31:09 | FromDiscord | <rb3.nim> Thanks @timotheecour. I did take a look at the treeRepr, but couldn't see an indicator in the AST to check if a variable was declared with `let` or `var`. That macro you posted seems to work with types, not variables, unless Im missing something |
00:32:40 | FromDiscord | <timotheecour> yes, i see. |
00:35:29 | FromDiscord | <timotheecour> sent a code paste, see https://paste.rs/HVn |
00:40:13 | * | def- quit (Quit: -) |
00:41:05 | * | def- joined #nim |
00:42:21 | FromDiscord | <rb3.nim> Seems like what I need, but I can't seem to get it to work in a macro: https://play.nim-lang.org/#ix=3x4q. Doesn't seem like the overload resolution thing works inside the `test2` macro |
00:42:34 | FromDiscord | <rb3.nim> (edit) removed "seem to" |
00:43:57 | FromDiscord | <Rika> Does it have to be in a macro |
00:45:07 | FromDiscord | <rb3.nim> Ya, I intend to use it as a utility to write a bunch of macros |
00:45:54 | FromDiscord | <rb3.nim> This seems to work, but in my real code it's not working: https://play.nim-lang.org/#ix=3x4r. Gonna try to repo... |
00:46:09 | FromDiscord | <rb3.nim> (edit) "repo..." => "repro..." |
00:48:49 | FromDiscord | <gogolxdong (liuxiaodong)> Is there any uint128 library? |
00:51:02 | FromDiscord | <timotheecour> https://github.com/nim-lang/RFCs/issues/399 |
01:13:14 | * | neurocyte8 joined #nim |
01:13:14 | * | neurocyte8 quit (Changing host) |
01:13:14 | * | neurocyte8 joined #nim |
01:15:19 | * | neurocyte quit (Ping timeout: 250 seconds) |
01:15:19 | * | neurocyte8 is now known as neurocyte |
01:23:35 | FromDiscord | <gogolxdong (liuxiaodong)> Nice, is there any way to get pow(2, 67)? |
01:30:53 | FromDiscord | <gogolxdong (liuxiaodong)> I mean the precise integer result rather than scientific notation which loses tailing digits. |
01:32:26 | FromDiscord | <gogolxdong (liuxiaodong)> handy like 2\\67 in python. |
01:36:19 | mst | that would require bigints, a quick poke around suggests the 'stint' nimble package has an implementation |
01:37:00 | mst | there's also one called just 'bigints' |
01:38:44 | FromDiscord | <Rika> well he asked before that about uint128 |
01:38:53 | FromDiscord | <Rika> (gives more perf) |
01:39:06 | FromDiscord | <Rika> i assume you can import compiler for the int128 lib there? |
02:25:16 | * | auxym_ quit (Ping timeout: 252 seconds) |
02:58:29 | FromDiscord | <HAT> Hey folks! I'm playing around with Win32 in Nim, if a function returns a type that is not yet defined in winim could I get a rough point in the direction of going about implementing it? |
02:59:08 | FromDiscord | <HAT> (edit) "type" => "structure" | "it?" => "it?↵↵Specifically I'm interested in implementing a PROCESS32ENTRY" |
02:59:32 | FromDiscord | <HAT> (edit) "returns" => "takes" | "takesa structure ... that" added "to populate it" |
03:00:28 | FromDiscord | <HAT> (edit) "Hey folks! I'm playing around with Win32 in Nim, if" => "sent" | "function takes a structure to populate it that is not yet defined in winim could I get a rough point in the direction of going about implementing it?↵↵Specifically I'm interested in implementing a PROCESS32ENTRY" => "code paste, see https://play.nim-lang.org/#ix=3x4N" |
03:03:04 | FromDiscord | <HAT> The Process32First() function that I'm using doesn't exist either, I guess I'm going to have to learn the FFI? I'm finding it quite confusing, I guess I'll just keep researching. |
03:07:59 | * | rockcavera quit (Remote host closed the connection) |
03:08:04 | * | arkurious quit (Quit: Leaving) |
03:12:59 | FromDiscord | <ajusa> Anyone here used Nimx? I'm trying to center align the text in a Label but haven't been able to figure it out |
03:26:05 | FromDiscord | <ajusa> Well I got that working, but I can't get it to work within the Nimx DSL |
03:36:06 | FromDiscord | <Varriount> In reply to @HAT "The Process32First() function that": Pretty much. You redefine the structure in Nim, ensuring that the order of the fields are the same, and that each Nim field's type is the same size as its corresponding C field. |
03:37:03 | FromDiscord | <Varriount> Just keep in mind that a C integer is not the same size as a Nim integer |
03:37:50 | FromDiscord | <Varriount> Nim has `cint`, `cfloat`, etc. for that. |
03:38:27 | FromDiscord | <Rika> winim probably has the proper types for dword etc |
03:41:00 | FromDiscord | <HAT> @Varriount Thank you! |
04:03:29 | FromDiscord | <Varriount> In reply to @HAT "<@!169336940846514176> Thank you!": Don't be afraid to look at Winim, or the C bindings for various things in the standard library. |
04:03:41 | * | flynn quit (Read error: Connection reset by peer) |
04:04:48 | * | flynn joined #nim |
04:06:01 | * | supakeen quit (Quit: WeeChat 3.2) |
04:06:30 | * | supakeen joined #nim |
04:06:31 | FromDiscord | <HAT> I find the prospect of taking a peak under the hood a bit intimidating, but I'll give it a crack. |
05:33:30 | NimEventer | New thread by Treeform: Is there no way to pass a specific overload to a macro?, see https://forum.nim-lang.org/t/8369 |
06:13:22 | * | PMunch joined #nim |
06:24:21 | madprops | how to I filter out empty chars from a seq? https://play.nim-lang.org/#ix=3x5h |
06:25:46 | PMunch | A char can't be empty |
06:26:55 | madprops | oh wait it's filling it with ' ' |
06:26:59 | madprops | (a space0 |
06:27:12 | PMunch | Yup |
06:27:26 | PMunch | There are a couple ways you can do it, depending on what you need |
06:27:52 | PMunch | a myStr.splitWhitespace.join might do the trick |
06:47:33 | FromDiscord | <retkid> sent a code paste, see https://play.nim-lang.org/#ix=3x5m |
06:47:40 | FromDiscord | <retkid> i needed a quick stresstest to see if my code was running native or in jvm |
06:47:47 | FromDiscord | <retkid> rate my prime number checker |
06:48:08 | FromDiscord | <retkid> i thought it was cleaver |
06:48:10 | FromDiscord | <retkid> sent a code paste, see https://play.nim-lang.org/#ix=3x5n |
06:51:48 | FromDiscord | <impbox [ftsf]> `wholeNumber = floor(check)` ? |
06:52:35 | FromDiscord | <impbox [ftsf]> why doubly linked list? |
06:52:37 | FromDiscord | <Elegantbeef> Or just `int.float` if you're truncating \:D |
06:53:03 | FromDiscord | <impbox [ftsf]> foo.int.float i wonder if the two type conversions is faster than floor? |
06:53:59 | FromDiscord | <impbox [ftsf]> aww nim doesn't have `frac` |
06:54:10 | FromDiscord | <Elegantbeef> It does indirectly |
06:54:22 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/math.html#splitDecimal%2CT |
06:54:59 | FromDiscord | <impbox [ftsf]> yeah, but less useful if you only want the fractional part |
07:00:07 | madprops | do you think specifying let vs var, helps in the long run? |
07:00:20 | FromDiscord | <Rika> Yes |
07:00:33 | FromDiscord | <Rika> Well, define “helps” first actually |
07:00:37 | FromDiscord | <impbox [ftsf]> when it helps it helps, sometimes it helps |
07:00:42 | madprops | avoids lots of accidents |
07:00:45 | FromDiscord | <Rika> Yes |
07:00:47 | FromDiscord | <impbox [ftsf]> by catching you doing things you don't want to do |
07:00:57 | FromDiscord | <Elegantbeef> It reduces the amount of mutable code reducing side effects |
07:01:06 | FromDiscord | <impbox [ftsf]> but sometimes you realise you actually wanted a var |
07:01:09 | * | max22- joined #nim |
07:06:46 | madprops | yeah I often have to turn lets into vars |
07:07:22 | madprops | but I guess it's worth it |
07:07:26 | madprops | plus it has the added information to it |
07:08:12 | madprops | like you also know, like the compiler, if it changes or not |
07:09:13 | FromDiscord | <retkid> In reply to @impbox "why doubly linked list?": had problems with arrays, got that to work |
07:09:20 | FromDiscord | <retkid> i couldn't find the floor function |
07:09:28 | FromDiscord | <retkid> (edit) "i couldn't find the floor function ... " added "either, so i made up for that with brains" |
07:09:31 | FromDiscord | <retkid> but now i know |
07:10:37 | FromDiscord | <retkid> i was afraid of using let and not var because these vars get wiped every loop so what if the memory space cant be overwritten or worse, what if it makes a new entry for every int |
07:10:53 | FromDiscord | <retkid> so i kinda just thought "eh, i'll figure out var vs let later" |
07:11:59 | FromDiscord | <Rika> In reply to @retkid "i was afraid of": What? |
07:12:25 | FromDiscord | <Elegantbeef> var/let is purely a compile time thing |
07:12:36 | FromDiscord | <Rika> If you aren’t that well versed in how memory works then don’t worry about it until it actually happens |
07:12:41 | FromDiscord | <impbox [ftsf]> you should use a seq[int] |
07:12:52 | FromDiscord | <Rika> Don’t preemptively work around a problem that you think exists |
07:12:52 | FromDiscord | <impbox [ftsf]> var primenumbers: seq[int] |
07:13:18 | FromDiscord | <impbox [ftsf]> also returning a which is never touched? |
07:13:37 | FromDiscord | <impbox [ftsf]> how does someone get the output? |
07:16:49 | FromDiscord | <Rika> I also just noticed that you’re using three periods for the for loop? |
07:17:02 | FromDiscord | <impbox [ftsf]> makes it go faster |
07:17:09 | FromDiscord | <Rika> Lol |
07:22:27 | * | jjido joined #nim |
07:58:36 | PMunch | Is there any convention for renaming C functions starting with underscores/double underscores? |
07:58:53 | FromDiscord | <impbox [ftsf]> `function_name` ? |
07:58:57 | PMunch | Just removing them is the obvious choice, but then they might suddenly collide with something |
07:59:05 | FromDiscord | <impbox [ftsf]> (edit) "`function_name` ?" => "sent a code paste, see https://play.nim-lang.org/#ix=" |
07:59:18 | PMunch | Hmm, I think something is going on with formatting.. |
07:59:22 | FromDiscord | <impbox [ftsf]> yeah |
07:59:26 | FromDiscord | <impbox [ftsf]> add backticks |
07:59:36 | FromDiscord | <impbox [ftsf]> and preserve the original name with underscores |
07:59:52 | PMunch | Ah, yeah that works |
08:16:51 | FromDiscord | <haxscramper> sent a code paste, see https://paste.rs/LvS |
08:17:33 | FromDiscord | <impbox [ftsf]> oh, i guess not? |
08:18:20 | * | byanka_ joined #nim |
08:18:54 | FromDiscord | <impbox [ftsf]> strangely it works with spaces but not underscores |
08:20:47 | * | byanka quit (Ping timeout: 240 seconds) |
08:21:44 | FromDiscord | <Rika> I believe there is no case where you can preserve underscore at the start or end of an identifier |
08:22:46 | FromDiscord | <impbox [ftsf]> maybe just add a prefix in that case |
08:23:44 | PMunch | Ah, bummer. Yeah I guess a prefix would be possible |
08:24:06 | PMunch | So there is no consensus on how to do this? |
08:24:23 | FromDiscord | <impbox [ftsf]> what's the function for? why is it ? |
08:24:27 | FromDiscord | <impbox [ftsf]> should it even be exposed? |
08:24:35 | FromDiscord | <impbox [ftsf]> if it's a function it means "magic" right? |
08:25:10 | FromDiscord | <impbox [ftsf]> or reserved for compiler stuff |
08:27:47 | PMunch | Eh, it means more something like "private" |
08:28:25 | PMunch | Essentially I'm wrapping C code, and I need to match type definitions exactly |
08:43:10 | FromDiscord | <haxscramper> I think consensus is to use `importc: "thing"` |
08:43:16 | FromDiscord | <haxscramper> Or you can use unicode underscore |
08:43:25 | FromDiscord | <haxscramper> I bet there are a few dozens to pick from |
08:44:04 | FromDiscord | <haxscramper> !eval let _____test = "123"; echo _____test |
08:44:07 | NimBot | 123 |
08:44:16 | FromDiscord | <haxscramper> here you go |
08:44:28 | PMunch | But how would you even type those.. |
08:44:36 | FromDiscord | <haxscramper> \:) |
08:45:42 | FromDiscord | <haxscramper> Well, on a more serious note - I think stroppping should support this, but I heavily change proc names anyway, and don't like rely on the implicit `importc` without specifying `"procname"` so |
08:46:05 | FromDiscord | <haxscramper> And everyone seems to be doing the same, to some extent |
08:47:02 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
08:50:56 | PMunch | Well my goal is to write something similar to Zigs automatic C header file importer. To be able to just specify a C header file in my code and have it automatically be available to me |
08:51:13 | PMunch | And for that I need some robust scheme for renaming illegal variables |
08:54:00 | FromDiscord | <Elegantbeef> `strutils.nimIdentNormalize`? |
08:56:02 | FromDiscord | <haxscramper> for hcparse I just went with hard renaming everything to nep1 |
08:56:02 | FromDiscord | <haxscramper> that does not work with `cName` and `cName_` |
08:56:09 | FromDiscord | <haxscramper> Those two have identical normalized values, but different inC |
08:56:19 | FromDiscord | <Elegantbeef> Ah right forgot stupidity existed |
08:56:21 | FromDiscord | <haxscramper> I keep cache of all renames across whole project I'm wrapping |
08:56:53 | FromDiscord | <haxscramper> PMunch\: do you want to make it semi-automatic like nimterop? |
08:57:29 | FromDiscord | <haxscramper> Automatic file importer must first parse whole project at once to deal with forward declaration graph cycles |
08:57:37 | FromDiscord | <haxscramper> Etc. |
08:57:57 | FromDiscord | <haxscramper> I mean it would only wrap what's imported in `<header>`? |
08:58:22 | * | Vladar joined #nim |
09:01:16 | * | ozzz quit (Ping timeout: 252 seconds) |
09:01:51 | * | idf quit (Quit: ZNC 1.8.2 - https://znc.in) |
09:02:00 | * | idf joined #nim |
09:02:34 | * | ozzz joined #nim |
09:03:03 | PMunch | @ElegantBeef, the goal is to be fully automatic |
09:06:39 | FromDiscord | <haxscramper> You can keep cache of all identifiers, do per-character diff and replace things like `cName` and `cname` with `cName` and `c[Lower]Name`, where `[Lower]` is determined to be necessary because diff between `cName` and `cname` is `c[N-n]ame` |
09:07:06 | FromDiscord | <haxscramper> I do this ... somewhere, I think it was for XML parsing that defined 240 similarlty named enum values |
09:07:38 | PMunch | Hmm, not sure if I totally understand how this works |
09:09:47 | * | pro joined #nim |
09:12:11 | FromDiscord | <haxscramper> You just store list of all known identifiers, and when new one comes in you check whether it (normalized) form is already known |
09:12:30 | FromDiscord | <haxscramper> Then you repeatedly "fix" it, untils there is no known rename like this |
09:12:43 | FromDiscord | <haxscramper> Simplest one would be to just add number increments |
09:13:06 | FromDiscord | <haxscramper> `cName` is `cName`, `cname` is `cname1`, `cname_` is `cname2` etc. |
09:13:46 | PMunch | Hmm, given an array of cstring, how can I get a cstringArray type? It's ptr UncheckedArray[cstring], but I can't seem to cast ptr array[0..0, cstring] to a cstringArray.. |
09:13:48 | FromDiscord | <haxscramper> https://github.com/haxscramper/hmisc/blob/master/src/hmisc/algo/namegen.nim |
09:14:45 | PMunch | Aha, just a cast :P |
09:15:00 | FromDiscord | <haxscramper> you can probably cast it via `cast[ptr UncheckedArray[cstring](addr ptrToNimArray[][0])` |
09:15:03 | PMunch | Ah I see |
09:15:09 | PMunch | Yeah I guess that works |
10:07:34 | * | jjido joined #nim |
10:10:03 | * | jjido quit (Client Quit) |
10:33:00 | * | flynn quit (Read error: Connection reset by peer) |
10:34:08 | * | flynn joined #nim |
10:51:10 | FromDiscord | <gogolxdong (liuxiaodong)> Is there any way to parse integer from sha256 result? |
10:52:40 | FromDiscord | <rb3.nim> what's the correct equivalent of `sym is converter` (check if a symbol is a converter)? |
10:53:41 | PMunch | Hmm, this error message should be a bit more specific about what type it is expecting: http://ix.io/3x6R |
10:53:55 | PMunch | gogolxdong, what do you mean? |
10:55:41 | * | auxym_ joined #nim |
11:02:29 | PMunch | @rb3.nim you can use getImpl.kind to check if it is a nnkConverterDef |
11:04:27 | FromDiscord | <gogolxdong (liuxiaodong)> like `int.from_bytes(sp_quality_string, "big", signed=False)` in python |
11:05:24 | FromDiscord | <gogolxdong (liuxiaodong)> which sp\_quality\_string is the result of sha256 |
11:06:25 | FromDiscord | <rb3.nim> Thanks @PMunch. What I want to do is take an `untyped` symbol and check if it's callable, without resorting to `compiles`. The first step I thought of is to check `declared(sym)`, and then try `sym is proc`. Ill try `getImpl` to check for converter |
11:08:45 | PMunch | Ah, untyped doesn't have type information |
11:08:47 | * | auxym_ quit (Ping timeout: 240 seconds) |
11:08:52 | PMunch | Which is the entire point of it |
11:09:14 | PMunch | It's before the type checking pass, so Nim doesn't know anything about what type it might be |
11:10:11 | PMunch | What I typically do is output a statement that accepts a `typed` argument and handles it accordingly |
11:11:03 | PMunch | gogolxdong, seems like you might want parseHex |
11:11:04 | FromDiscord | <rb3.nim> Ya, so I'll have to convert it to an `nnkSym` right? so will try passing it to a macro with `typed` arg like you say |
11:11:16 | PMunch | Correct |
11:19:08 | * | auxym_ joined #nim |
11:22:05 | * | auxym_ quit (Client Quit) |
11:22:33 | * | auxym_ joined #nim |
11:31:58 | * | auxym_ quit (Ping timeout: 252 seconds) |
11:49:19 | * | jjido joined #nim |
11:57:51 | * | xet7 quit (Read error: Connection reset by peer) |
11:59:18 | * | xet7 joined #nim |
12:05:03 | PMunch | Hmm, is there a way to check if two types are binary compatible? |
12:05:45 | PMunch | Ie. if I want to add overrides so that a C int might become an enum or a void * might be a specific type in Nim land? |
12:06:02 | * | supakeen quit (Quit: WeeChat 3.2) |
12:06:16 | PMunch | But ensure that the enum is actually the same underlying int type and that the specific type is actually a pointer of some kind |
12:06:30 | * | supakeen joined #nim |
12:07:00 | FromDiscord | <haxscramper> That has to be solved on case-by-case basis I think. I mean, `void` is a `pointer`, but for enums this is different |
12:07:11 | FromDiscord | <haxscramper> What are your exact use cases? |
12:07:44 | FromDiscord | <haxscramper> int-as-bitset, int-as-enum and `void`-as-actually-pretty-concrete-pointer? |
12:09:18 | PMunch | Well I have already wrapped this library by hand, but now I want to transition to using my libclang based binding generator. But I have added some more type information to make it a bit safer, combined a bunch of constants into an enum for example. I want to add the possibility to create manual overrides of type signatures, but these would be checked to make sure they are actually compatible |
12:11:43 | FromDiscord | <haxscramper> I create a "Raw" wrappers for a procedure using original C signature and then allow to automatically declare wrapper one that does type conversion using nim code. This also allows me to introduce semi-automatic checks for exit codes, wrap things into return-via-pointer-to-argument and other things |
12:11:45 | FromDiscord | <haxscramper> Also |
12:12:03 | FromDiscord | <TimApple> Can someone point me to a tutorial for Nim that would be at complete newb level? Thanks |
12:12:06 | FromDiscord | <haxscramper> Because wrapper logic is implemented in nim I don't have to worry about potential unsafety on the wrapper edge |
12:12:18 | PMunch | Hmm, that is a good point |
12:12:53 | FromDiscord | <haxscramper> Any sort of let's wrap `int` as nim `enum` might lead to silent bugs due to reliance on implementaiton details and such |
12:12:57 | PMunch | @TimApple: https://narimiran.github.io/nim-basics/ |
12:13:04 | FromDiscord | <TimApple> Thanks |
12:14:34 | FromDiscord | <haxscramper> I simply allow wrapper generator users to provide their own callback that can invoke arbitrary logic like https://github.com/haxscramper/hcparse/blob/master/src/hcparse/hc_impls.nim#L78 |
12:14:49 | FromDiscord | <haxscramper> But in the end it is impossible to do without some sort of manual work |
12:15:08 | FromDiscord | <haxscramper> You can write `yaml/S-expression` file with signature patterns |
12:15:26 | FromDiscord | <haxscramper> For example you can do something like nim `lispRepr()` ast, but |
12:16:30 | FromDiscord | <haxscramper> Well, we have S-expression parser in the stdlib, and this is the best way to specify AST patterns. If C procedure declarations unifies with any of the matchers you invoke custom logic and provide two-level wrappers for it |
12:18:07 | FromDiscord | <haxscramper> Something like that |
12:18:12 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3x7h |
12:29:51 | FromDiscord | <TimApple> I'm installing nim for the first time. Windows 11 thinks nimble is a trojan. |
12:33:32 | PMunch | Yeah, it's a false positive |
12:34:47 | PMunch | Basically Nim has been used to write some malware, this meant that these malware samples where fingerprinted and added to various malware databases. Only problem is that they didn't add enough counter-examples in their fingerprinting so now legitimate Nim programs are sometimes fingerprinted as malware |
12:35:47 | PMunch | There is an ongoing effort to report false positives to the malware vendors, hopefully this will help, but in the meantime we get false positives for Nim and Nimble.. |
12:36:03 | FromDiscord | <TimApple> Thanks for the info |
12:38:14 | PMunch | Please report the files here as false positives: https://www.microsoft.com/en-us/wdsi/filesubmission/. The more people who report them the greater the chance is that Microsoft will improve the fingerprinting |
12:41:49 | * | pro quit (Quit: WeeChat 3.2) |
12:47:45 | FromDiscord | <dom96> Yeah, this really shows how ridiculous av software is |
13:03:07 | FromDiscord | <smartlyweird> Hey everyone. Im trying to find any solution to embed lua scripts into nim just the way how its done with c# or any other language. |
13:03:54 | FromDiscord | <smartlyweird> I saw examples where there's a lib to call lua in nim flavour. But i dont think it'd be compatible with my project |
13:04:48 | FromDiscord | <smartlyweird> I want to make a independent dll which i can load in my program and it could load lua scripts arbitrarily |
13:06:23 | FromDiscord | <haxscramper> The library also provides direct wrappers for the LUA API, so you can use these directly https://github.com/jangko/nimLUA/blob/master/nimLUA/lua.nim#L149 |
13:06:35 | arkanoid | Pmu |
13:06:38 | arkanoid | Ups |
13:06:44 | FromDiscord | <haxscramper> And take any C tutorial for it |
13:08:22 | arkanoid | PMunch: I read that you were trying to use libclang to parse C headers. I'm dealing with a header file that requires double or triple preprocessor passes and both c2nim and nimterop are failing to parse without a lot of manual edits. Do you know if libclang does that? |
13:08:57 | PMunch | That is kinda the problem I'm trying to solve here |
13:09:23 | PMunch | Use an actual C compiler to do all the heavy lifting, and just extract the information it reads |
13:09:33 | PMunch | Seems to work fairly well so far |
13:10:18 | * | arkurious joined #nim |
13:11:27 | arkanoid | If you want a testcase, I'm dealing with data binding wsdl files. In particular, I've been trying to generate nim wrapper of the C interface generated by gSOAP given a wsdl |
13:12:21 | arkanoid | In general, this would enable the automatic generation of API from a wsdl, just like Microsoft or Oracle does |
13:15:52 | PMunch | My current test-case is Unbound |
13:15:54 | arkanoid | I gave up that path due to the fact that I'm not a C/C++ programmer and I had some difficulties in handling all the things required to make c2nim happy. I'm writing a pure nim converted based on xmltree but it's a very difficult job there too |
13:17:04 | arkanoid | If you have a prototype to test, I'd be happy to run it on the headers I'm talking about |
13:17:11 | PMunch | I'm writing dynamic libraries for it and need to know about all its data-structures and such, so I'm trying to have automatic generation of those |
13:17:26 | PMunch | Currently it's super hacky and just outputs text :P |
13:17:54 | arkanoid | Yeah, my XML converted is at that stage too |
13:18:11 | arkanoid | But please don't give up! You've a fanbase here |
13:19:05 | FromDiscord | <haxscramper> btw, PMunch, if you are interested in examples on using libclang (and getting data from it) you can see anything in https://github.com/haxscramper/hcparse/tree/master/src/hcparse or ask me |
13:19:46 | FromDiscord | <haxscramper> I added `[]`/`.kind`-based API on top of clang visitors |
13:20:00 | FromDiscord | <haxscramper> But otherwise it is pretty close to the wrappers you are using |
13:20:03 | PMunch | arkanoid, if you want to give it a go you can copy this: http://ix.io/3x7N/nim |
13:21:29 | PMunch | Then write a test.h file that #includes the stuff you would need from C and potentially add some -I things in line 95 |
13:21:48 | FromDiscord | <smartlyweird> In reply to @haxscramper "The library also provides": Nice! Btw came across this link https://www.mail-archive.com/[email protected]/msg00742.html |
13:21:52 | PMunch | But keep in mind that this is pre-PoC code :P |
13:22:26 | FromDiscord | <smartlyweird> But not sure if i can call any lua script arbitrarily instead of one which is embedded |
13:23:41 | PMunch | Wait, have you already written something like this haxscramper? |
13:25:50 | FromDiscord | <haxscramper> I've been on this for the last year |
13:26:07 | FromDiscord | <haxscramper> But it is not ready yet |
13:26:08 | FromDiscord | <haxscramper> And I don't have any concrete timeline |
13:26:34 | FromDiscord | <haxscramper> Because I had some redesign considerations etc. |
13:27:02 | FromDiscord | <haxscramper> After arkanoid's struggles with c2nim and another discussion in the telegram |
13:27:30 | PMunch | Hmm, and here I was hoping that I'd have something I could use for real-life production code over the weekend :P |
13:27:53 | FromDiscord | <haxscramper> I also wrap c++ |
13:28:06 | FromDiscord | <haxscramper> Which is an absolutely astonishing levels of grossness |
13:28:21 | PMunch | Haha, yeah I'm focusing on C for now :P |
13:28:37 | FromDiscord | <haxscramper> std\:\:string is just |
13:28:58 | arkanoid | PMunch: where I can get the clang module? |
13:29:27 | PMunch | nimble install clang |
13:29:33 | arkanoid | oh! |
13:29:56 | PMunch | I think it's that one, but it might be the one called libclang :P |
13:30:03 | PMunch | It's the most recent one |
13:31:31 | arkanoid | this is the most recent one https://github.com/samdmarshall/libclang-nim |
13:35:07 | arkanoid | do you know why c2nim didn't follow a similar path since the beginning? |
13:35:21 | arkanoid | parsing C from scratch, isn't this reinventing the wheel? |
13:36:09 | FromDiscord | <haxscramper> libclang cant' |
13:36:10 | FromDiscord | <haxscramper> well |
13:36:50 | FromDiscord | <haxscramper> there must be three ways of wrapping total - manually (or using helper macro) via `importcpp`, using dumb tool like c2nim or nimterop that barely understands C/C++ |
13:36:59 | FromDiscord | <haxscramper> And using libclang or libtooling |
13:37:13 | FromDiscord | <haxscramper> libtooling is an ultimate solution, but it has severe chicked-egg problem |
13:37:28 | arkanoid | nimterop uses tree-sitter, that's not at "barely" level afaik |
13:37:38 | FromDiscord | <haxscramper> That is barely |
13:37:46 | FromDiscord | <haxscramper> trust me, if you can parse C syntax it means |
13:37:49 | FromDiscord | <haxscramper> it means nothing |
13:38:36 | FromDiscord | <haxscramper> oh, btw, nimterop does not understand preprocessor, instead just degates things to `gcc -CPE`, which means no processing of the platform-specific things |
13:38:49 | FromDiscord | <haxscramper> anyway |
13:38:54 | arkanoid | I trust you |
13:39:05 | arkanoid | yeah I know that nimterop skips the preprocessing |
13:39:16 | arkanoid | problem is that it makes code explode, in my context |
13:39:25 | arkanoid | as I'm dealing with generated .h |
13:39:27 | FromDiscord | <haxscramper> this is a viable solution because it a dumb solution |
13:39:57 | FromDiscord | <haxscramper> if you try to get smart with C and especially C++ wrapping you get into almost infinite sinkhole of "fixing" things |
13:40:13 | FromDiscord | <haxscramper> But ideal pipeline for c2nim is |
13:40:17 | FromDiscord | <haxscramper> "ideal" my ass |
13:40:26 | FromDiscord | <haxscramper> use boost wave to deal with preprocessor |
13:40:37 | FromDiscord | <haxscramper> use tree-sitter to deal with C syntax |
13:40:50 | FromDiscord | <haxscramper> provide user-defined hooks on every stage |
13:41:00 | FromDiscord | <haxscramper> preprocessor, ast convesion etc. |
13:41:09 | arkanoid | I won't touch c++ even with very long branch |
13:41:46 | FromDiscord | <haxscramper> But this still leaves a lot of problems such as forward declarations cycles, C library dependencies (yes, believe or not C(++) libraries do depend on each other) |
13:42:17 | FromDiscord | <haxscramper> Latter is especially complicated problem, because nim thinks of two `importcpp: "std::string"` as two different types |
13:42:28 | FromDiscord | <haxscramper> btw we have three incomplete C++ stdlib wrappers in the nimble |
13:42:33 | FromDiscord | <haxscramper> they all define string |
13:42:40 | FromDiscord | <haxscramper> these strings are not interoperable with each other |
13:42:55 | FromDiscord | <haxscramper> nim won't allow this |
13:43:57 | FromDiscord | <haxscramper> libclang has full understanding of the code, but it is also a problem |
13:44:05 | FromDiscord | <haxscramper> Because it is not a feature, it is a requirement |
13:44:17 | PMunch | I'm basically just doing libclang because that's how Zig does it |
13:44:26 | PMunch | And the Zig way apparently works really well |
13:44:46 | arkanoid | does Zig convert C to Zig successfully? |
13:45:21 | FromDiscord | <haxscramper> For example, a while back someone asked me if my tool could help them wrap a library, and I tested it (with what I had at the moment). In the end I realized that it can't be wrapped directly, because it uses a configure script and insanely convoluted build system, where I would have to basically integrate hcparse into |
13:45:33 | FromDiscord | <haxscramper> But c2nim-like would handle it almost perfectly well |
13:45:41 | FromDiscord | <haxscramper> but reimplementing C parser |
13:45:42 | PMunch | @arkanoid, how it works in Zig: https://ziglang.org/documentation/0.8.0/#Import-from-C-Header-File |
13:45:47 | FromDiscord | <haxscramper> ... |
13:47:25 | arkanoid | PMunch: whoa! That's a real FFI. Beats nim without even playing |
13:47:25 | FromDiscord | <haxscramper> Although I don't understand why c2nim didn't use gcc's parsers, IIRC it was implemented in bison |
13:47:49 | PMunch | Exactly, and there really isn't a good reason why Nim couldn't do the same thing |
13:48:10 | FromDiscord | <haxscramper> I think that having intermediate wrapper files is better in the long run |
13:48:21 | PMunch | I mean we're invoking a C compiler at some point, so half the work is just getting all the definitions for stuff |
13:48:22 | arkanoid | nim deserves a similar thing. Why don't just grab Zig code that does that and convert to nim? |
13:48:51 | PMunch | I did have a look at the Zig code, not quite sure what it was doing though |
13:49:02 | PMunch | Uses a completely different way of parsing than I do.. |
13:49:13 | PMunch | Maybe I'll rewrite it if down the line my way doesn't work |
13:50:09 | arkanoid | haxscramper, why do you think that manual wrapping would work on the long run? |
13:50:12 | FromDiscord | <haxscramper> do you have a link to that part of compiler, or I should go search myself? |
13:50:21 | PMunch | The plan is basically to just get all the type definitions and procedure signatures converted to Nim, then the rest is just a matter of linking it together with the original C sources and it should work fine |
13:50:24 | * | PMunch crosses fingers |
13:50:58 | arkanoid | it would be a game changer |
13:52:39 | PMunch | @haxscramper, this seems to be the main entry point of the parsing: https://github.com/ziglang/zig/blob/master/src/translate_c.zig#L355 |
13:52:41 | FromDiscord | <haxscramper> Not manual wrapping↵(<@709044657232936960_arkanoid=5b=49=52=43=5d>) |
13:52:54 | FromDiscord | <haxscramper> Explicit `.nim` with wrappersr written down |
13:52:57 | FromDiscord | <haxscramper> That you can document |
13:53:11 | FromDiscord | <haxscramper> Also you can rename things to nep1 compliant style |
13:53:25 | FromDiscord | <haxscramper> Also provide wrappers that turn error codes to exceptions |
13:53:47 | FromDiscord | <haxscramper> Also write examples that don't operate on "magically" created types, but instead use things that are written in the code |
13:54:03 | FromDiscord | <haxscramper> Also there is no middlemen between you writing things and nim compiler |
13:54:52 | FromDiscord | <haxscramper> But I don't mean "manual" I mean that you can have `import wrapper/somefile`, but how exactly it is generated is not my problem |
13:55:12 | FromDiscord | <haxscramper> Also I don't have to drag wrapper system alongside compiler implementation |
13:55:22 | FromDiscord | <haxscramper> IIRC nimterop runs `toast` binary each time I compile code |
13:55:25 | FromDiscord | <Rika> makes sense |
13:55:35 | arkanoid | make sense, yeah |
13:55:50 | FromDiscord | <Rika> its easier to debug things when things arent "autogen"ed on cct |
13:55:51 | FromDiscord | <Rika> (edit) "cct" => "ct" |
13:55:56 | arkanoid | I do agree that nimifing interface is good |
13:56:02 | FromDiscord | <haxscramper> Exactly |
13:56:28 | FromDiscord | <haxscramper> Too much magic |
13:56:28 | FromDiscord | <haxscramper> Too complicated interface |
13:56:29 | FromDiscord | <haxscramper> My main issue with nimterop basically↵(@Rika) |
13:56:33 | FromDiscord | <haxscramper> If I don't like something in the `.nim` wrapper I can just open and edit |
13:56:38 | FromDiscord | <Rika> also no reason to run the gen every time you compile no |
13:56:39 | arkanoid | zig translate-c is the command line tool that does the same thing of compile-time @cImport, apparently |
13:57:17 | arkanoid | maybe c2nim is the nearest point to equilibrium before diving into madness |
13:57:36 | arkanoid | but if someone else is already maintaining that madness, why not |
13:58:22 | FromDiscord | <haxscramper> idea of c2nim is the closes you can go to the "average library" yes |
13:58:37 | FromDiscord | <haxscramper> Automate 95% of work |
13:58:52 | FromDiscord | <dom96> Anybody ever used this? https://cxx.rs |
13:58:54 | FromDiscord | <haxscramper> But sometimes you need 100%, and that's where things start to get super fun |
13:59:00 | FromDiscord | <haxscramper> Like wrapping Qt |
13:59:02 | FromDiscord | <Rika> if only 100% was automatable |
13:59:11 | FromDiscord | <haxscramper> 5% of qt is probably full-time work for a month |
13:59:21 | FromDiscord | <haxscramper> It is, but that's hard to do↵(@Rika) |
13:59:30 | FromDiscord | <Rika> i meant practically in this case |
13:59:31 | FromDiscord | <Rika> so yeah |
13:59:45 | FromDiscord | <haxscramper> NO, I mean it is practically possible as well |
13:59:57 | FromDiscord | <Rika> really? |
14:00:01 | FromDiscord | <Rika> what is holding us back then |
14:00:26 | FromDiscord | <haxscramper> It just requires an order of magnitude more work from both person wrapping a library and person implementing wrapper generator |
14:01:07 | * | pro joined #nim |
14:01:17 | FromDiscord | <haxscramper> Nothing, I'm already working on this↵(@Rika) |
14:01:21 | FromDiscord | <Rika> i see |
14:01:24 | FromDiscord | <Rika> GL |
14:01:26 | arkanoid | is the typing that's more difficult, or the functions |
14:01:27 | FromDiscord | <haxscramper> Right now I can safely say that I'm |
14:01:36 | FromDiscord | <haxscramper> closer to the end than to the start |
14:01:42 | FromDiscord | <haxscramper> that's all I can safely say |
14:01:48 | FromDiscord | <haxscramper> which is a lot btw |
14:02:31 | FromDiscord | <haxscramper> No, the most difficult part is considering the library as a whole, at once↵(<@709044657232936960_arkanoid=5b=49=52=43=5d>) |
14:02:31 | * | PMunch quit (Quit: Leaving) |
14:02:40 | arkanoid | shouldn't this be a join effort of nim experts like you? seems important, and now that I know that another nim competitor is doing that successfully, why not? |
14:02:56 | FromDiscord | <Rika> "nim experts" are very scarce 🙂 |
14:03:01 | FromDiscord | <haxscramper> yeah |
14:03:31 | FromDiscord | <Rika> im pretty sure theyre all booked too |
14:03:51 | FromDiscord | <Rika> so yeah arkanoid you better become one sooner or later 😛 |
14:04:03 | arkanoid | if only I used nim instead of python for scientific computing years ago! |
14:04:33 | FromDiscord | <Rika> it probably would have taken you a lot more work to make (years ago)\ |
14:04:44 | FromDiscord | <Rika> not a lot of libraries back then after all |
14:04:46 | arkanoid | I've converted one of my old algorithms just for fun and it goes three times faster |
14:05:04 | FromDiscord | <Rika> damn thats pretty huge |
14:05:34 | arkanoid | yeah but I was already using numpy, thats a C library with python interface |
14:06:12 | FromDiscord | <Rika> thats even more huge isnt it since that means for 2/3rds of the time it's just python being python.... |
14:07:10 | arkanoid | exactly. Basically doing IPC to avoid GIL. With nim I used async mixed with multithreading and is smoooth |
14:07:19 | * | rockcavera joined #nim |
14:07:19 | * | rockcavera quit (Changing host) |
14:07:19 | * | rockcavera joined #nim |
14:08:47 | arkanoid | Btw, I want to learn how to parse. I realizes that I lack basic knowledge of this topic. |
14:09:00 | FromDiscord | <haxscramper> sent a long message, see http://ix.io/3x7X |
14:10:16 | arkanoid | I nave this piece of code that walks all over a directory of XML schema files, and reaches all nodes in order according to dependencies. Now I think I would need a grammar but I lack this knowledge |
14:10:18 | FromDiscord | <haxscramper> Having to do this requires to have graph library with graph algorithms, which I have to write from scratch, because nim did not really have anything of that sort, and closes alternative `disruptek/gram` used `static` for graph properties, but due to some implementation details I had to temporarity turn directed graph into undirected |
14:11:16 | FromDiscord | <haxscramper> Also C can do `struct A; struct B { a A;}` in one header, and `struct B; struct A { b B; }` in another header |
14:11:42 | FromDiscord | <haxscramper> It is easy to fix with c2nim - just copy things into one header |
14:13:01 | FromDiscord | <haxscramper> An maybe fix some imports. But if I must automate 100% then I have to keep track of all movements (or make things work as if there were no movements at all, which is easier due to `export` in nim - I can pretend that all files expose both `A` and `B`, while having them saved in a third file). |
14:13:03 | FromDiscord | <haxscramper> And so on |
14:14:33 | FromDiscord | <haxscramper> But I don't thin c2nim will ever switch to boost+tree-sitter implementation, nor does it have to, because this can be done using external tool |
14:16:52 | * | pro quit (Quit: WeeChat 3.2) |
14:17:11 | arkanoid | I fear there's quite a lot of different opinions on this topic |
14:17:25 | FromDiscord | <haxscramper> parsing? |
14:17:35 | FromDiscord | <haxscramper> or the wall of text I just dumped? |
14:19:08 | arkanoid | from the point of view of a nim user who doesn't like C++, but it's quite ok with C, the current FFI nim offers hard to use when header is quite convoluted, so welcome to project where complexity is on the other side |
14:19:10 | arkanoid | the wall of text |
14:19:57 | FromDiscord | <cabboose> Hey I’m a bit confused with HashSets; I assumed the `[]` proc would just use the hash of the object and give you whatever element in the set had that same hash value but that doesn’t seem to be the case for me |
14:20:37 | FromDiscord | <haxscramper> No, hashset does not simply reuse the hash, it also compares object for equality in case of collisions |
14:20:45 | FromDiscord | <cabboose> ah |
14:20:53 | FromDiscord | <cabboose> that sucks |
14:20:55 | FromDiscord | <haxscramper> So object must be `hash(X) == hash(Y) and X == Y` to be considered equal IIRC |
14:21:01 | FromDiscord | <haxscramper> you can overload `==` |
14:21:09 | FromDiscord | <cabboose> I thought I had though |
14:21:25 | FromDiscord | <Rika> can you make a playground example? |
14:21:31 | FromDiscord | <cabboose> I have; maybe it’s not using it though, I’ll have another tinker in the morning |
14:21:40 | FromDiscord | <haxscramper> Yes, usually having complexity on the other side is preferrable↵(<@709044657232936960_arkanoid=5b=49=52=43=5d>) |
14:21:58 | FromDiscord | <cabboose> Unfortunately the mrs is forcing me off which is why i asked here instead of madly throwing things at it to fix it |
14:22:07 | FromDiscord | <cabboose> i’ll check in on the forum tomorrow if i cant figure it |
14:22:09 | FromDiscord | <cabboose> thanks |
14:38:54 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
14:39:44 | arkanoid | I'm giving c2nim another try, just to test again after some time the same thing I've been struggling months ago |
14:40:00 | arkanoid | but I'd like to ask now, instead of guessing |
14:40:15 | arkanoid | what does this C define means? #define SOAP_STRINGIFY(s) #s |
14:41:10 | arkanoid | what that second hash means? |
14:42:22 | FromDiscord | <haxscramper> `#s` converts `s` token to string |
14:42:47 | FromDiscord | <haxscramper> nim version is a `template soap(s: untyped): untyped = astToStr(s)` |
14:42:55 | FromDiscord | <dom96> @haxscramper what is the approach your taking for FFI? are you building a better c2nim? |
14:43:01 | FromDiscord | <dom96> (edit) "your" => "you're" |
14:43:33 | FromDiscord | <haxscramper> including that, yes |
14:43:38 | FromDiscord | <haxscramper> But not the only part |
14:43:49 | FromDiscord | <haxscramper> Well, I think better c2nim is a one-week project at most |
14:44:39 | arkanoid | haxscramper, so in #ifdef C2NIM that would become "def SOAP_STRINGIFY(s) template SOAP_STRINGIFY(s: untyped): untyped = astToStr(s)" ? |
14:46:10 | * | jjido joined #nim |
14:46:58 | FromDiscord | <haxscramper> No, I don't think so. From the documentation of `#def` in c2nim I think there is no way to have `#s` |
14:47:14 | FromDiscord | <haxscramper> Maybe you can try to |
14:47:36 | FromDiscord | <haxscramper> `#def SOAP_STRINGIFY(s) #s`? At least that's how I understand `#def` |
14:47:47 | FromDiscord | <haxscramper> > ↵> #def is very similar to C's #define, so in general the macro definition can be copied and pasted into a #def directive.↵> |
14:48:23 | arkanoid | yeah I've already tried "def SOAP_STRINGIFY(s) #s", but I get Error: identifier expected, but got: s |
14:49:54 | FromDiscord | <dom96> In reply to @haxscramper "But not the only": what's the other part? |
14:50:35 | FromDiscord | <haxscramper> Remaining 5% for full automation |
14:50:45 | FromDiscord | <haxscramper> c2nim approach is not automatic, it is about first 95% |
14:50:58 | FromDiscord | <haxscramper> It is relatively easy to do, you just push decision to the end users |
14:51:28 | FromDiscord | <haxscramper> But if you need to squeeze the last 5%, it becomes exponentially more difficult to implement |
14:51:55 | FromDiscord | <haxscramper> But this is equally important in the long run |
14:53:11 | FromDiscord | <dom96> how are you getting that last 5%? |
14:53:40 | FromDiscord | <haxscramper> using libclang instead of boost-wave+tree-sitter |
14:58:26 | FromDiscord | <dom96> Nice, likely the best approach. I've considered doing the same after writing an obfuscator using libclang |
15:03:53 | FromDiscord | <haxscramper> For full automation yes, but average use case requires 95% |
15:04:52 | FromDiscord | <enthus1ast> 🤣 to avoid this annoying antivirus false positive?↵(@dom96) |
15:06:27 | FromDiscord | <dom96> hah |
15:06:46 | FromDiscord | <dom96> nah, it was my BSc project |
15:07:38 | FromDiscord | <enthus1ast> \:) |
15:08:05 | FromDiscord | <dom96> you can try it here: https://picheta.me/obfuscator |
15:13:55 | FromDiscord | <ajusa> Does Nimx require laying out all the elements by hand? There's no automatic layout system similar to flexbox? |
15:15:15 | FromDiscord | <ajusa> Also, it seems like there aren't many cross platform options for GUI interfaces that work on Android as well - Nimx and Qt seem to be the only ones that can be used |
15:23:35 | * | flynn quit (Read error: Connection reset by peer) |
15:24:43 | * | flynn joined #nim |
15:29:06 | FromDiscord | <whisperdev> required type for fd: SocketHandle↵ but expression 'fd' is of type: SocketHandle |
15:54:04 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
16:07:32 | NimEventer | New thread by Kalbhairab: How to reverse string in nim, see https://forum.nim-lang.org/t/8370 |
16:29:44 | FromDiscord | <enthus1ast> @ajusa\: maybe fidget, at least this is the plan I think |
16:30:07 | FromDiscord | <enthus1ast> https://github.com/treeform/fidget |
16:30:14 | FromDiscord | <ajusa> Yeah, but Fidget 2 is months away so I don't want to spend too much time working with normal Fidget |
16:30:48 | FromDiscord | <ajusa> Treeform's mentioned that it'll be very different, plus it will support stuff like touch events and scrolling I think |
16:31:21 | FromDiscord | <enthus1ast> Then you're better informed than me 😁 |
16:32:20 | FromDiscord | <enthus1ast> Currently building guis is terrible, only html is crossplatform |
16:32:31 | arkanoid | haxscramper, do you know what's the name of "#define SOAP_STRINGIFY(s) #s" thing? I'm trying to google it, but I lack the right keyword |
16:32:56 | FromDiscord | <ajusa> Ah okay 😅. ↵Yeah I think I'll just write this using Jester and opening a link to the local server in the user's browser, that seems like the easiest way of doing things... |
16:33:15 | FromDiscord | <haxscramper> https://gcc.gnu.org/onlinedocs/gcc-4.8.5/cpp/Stringification.html#:~:text=When%20a%20macro%20parameter%20is,This%20is%20called%20stringification%20. |
16:34:51 | * | Gustavo6046 quit (Quit: ZNC 1.8.2 - https://znc.in) |
16:37:40 | NimEventer | New Nimble package! kombinator - Kombinator is a tool to generate commands line from parameters combination from a config file., see https://gitlab.com/ArMour85/kombinator.git |
16:39:26 | * | Gustavo6046 joined #nim |
16:57:26 | FromDiscord | <gogolxdong (liuxiaodong)> `/home/lingx/.nimble/pkgs/websock-0.1.0/websock/extensions/compression/deflate.nim(384, 8) Error: cannot bind another '=destroy' to: DeflateExt:ObjectType; previous declaration was constructed here implicitly: /home/lingx/.nimble/pkgs/chronos-3.0.6/chronos/asyncmacro2.nim(321, 33)` |
16:57:39 | FromDiscord | <Yardanico> that's a known issue with arc |
16:57:42 | FromDiscord | <Yardanico> lemme show you |
16:57:58 | FromDiscord | <Yardanico> https://github.com/nim-lang/Nim/issues/14226 |
17:04:16 | arkanoid | haxscramper, thanks! Gonna ask in the forum for a solution |
17:09:49 | NimEventer | New thread by Giaco: C2nim and Stringification, see https://forum.nim-lang.org/t/8372 |
17:22:20 | FromDiscord | <dom96> happy Friday! |
17:23:15 | FromDiscord | <dom96> oooh nimforum on HN front page |
17:33:57 | * | jjido joined #nim |
17:47:00 | * | Gustavo6046 quit (Quit: ZNC 1.8.2 - https://znc.in) |
18:02:39 | * | stkrdknmibalz joined #nim |
18:04:04 | * | byanka_ quit (Read error: Connection reset by peer) |
18:04:48 | * | byanka_ joined #nim |
18:13:10 | nrds | <Prestige99> seems like people are complaining that it's "mobile first" and uses javascript, lol |
18:14:08 | * | nrds quit (Remote host closed the connection) |
18:14:31 | * | nrds joined #nim |
18:23:40 | FromDiscord | <retkid> hey |
18:23:49 | FromDiscord | <retkid> is there any nim header i can generate |
18:24:00 | FromDiscord | <retkid> i just need a function name and an output |
18:24:11 | FromDiscord | <retkid> i could read the source but i feel like thats gonna be annoying |
18:40:01 | NimEventer | New thread by Alexeypetrushin: Any plans for better optional arguments?, see https://forum.nim-lang.org/t/8373 |
18:44:58 | FromDiscord | <retkid> can functions be used in the parameters for other functions? |
18:45:17 | FromDiscord | <retkid> or do you have to pass them to vars before? |
18:52:11 | FromDiscord | <haxscramper> Yes, nim has first-order functions `proc a(cb: proc())` |
18:52:40 | FromDiscord | <haxscramper> What exactly do you mean by "nim header"? Header file?↵(@retkid) |
18:52:58 | FromDiscord | <haxscramper> https://nim-lang.org/docs/manual.html#types-procedural-type |
18:53:32 | FromDiscord | <retkid> i want a list of functions with return types |
18:53:46 | FromDiscord | <retkid> im writing some python to parse it now |
18:55:23 | FromDiscord | <haxscramper> There is a `--header` option, but it is deprecated |
18:55:53 | FromDiscord | <haxscramper> "official" way is to write some external tool, or generate wrappers manually based on `exportc` procs |
18:56:22 | FromDiscord | <retkid> https://media.discordapp.net/attachments/371759389889003532/880888483634380851/unknown.png |
18:56:34 | FromDiscord | <retkid> now all i need to do is get the paramater types |
18:56:37 | FromDiscord | <retkid> (edit) "paramater" => "parameter" |
18:56:38 | FromDiscord | <retkid> but |
18:56:57 | FromDiscord | <retkid> the putting functions in the function is kinda hard |
18:57:28 | FromDiscord | <retkid> i suppose it wont be difficult if the function is in the file |
18:57:37 | FromDiscord | <retkid> if the function is somewhere else that might be impossible |
18:57:57 | FromDiscord | <haxscramper> you are parsing nim code? |
18:58:25 | FromDiscord | <retkid> yes |
18:58:37 | FromDiscord | <Recruit_main707> for what? |
18:58:54 | FromDiscord | <retkid> just need a list of functions, param, and return type |
18:59:02 | FromDiscord | <retkid> so i can automatically generate classes for ffi |
18:59:54 | FromDiscord | <retkid> (edit) "param," => "param types," |
18:59:55 | FromDiscord | <Recruit_main707> id say macro as pragma would probably be more useful but alright |
19:00:14 | FromDiscord | <Recruit_main707> i actually did something similar but ive lost the code probably |
19:01:01 | FromDiscord | <retkid> sent a code paste, see https://play.nim-lang.org/#ix=3x9v |
19:01:15 | FromDiscord | <retkid> all i need is the params which are really dicey |
19:03:06 | FromDiscord | <haxscramper> `import compiler`? |
19:03:26 | FromDiscord | <retkid> ? |
19:03:38 | FromDiscord | <Recruit_main707> you can use the compiler as a module |
19:03:45 | FromDiscord | <haxscramper> https://github.com/haxscramper/hnimast/blob/master/src/hnimast/pnode_parse.nim#L13 |
19:04:10 | FromDiscord | <haxscramper> yes, parsing nim using naive string handling is not the best idea |
19:04:25 | FromDiscord | <retkid> yea thats why im using py |
19:04:32 | FromDiscord | <haxscramper> That is, if you need somewhat robust solution |
19:04:45 | FromDiscord | <retkid> parsing a language with that language can cause weird unexpected issues |
19:04:55 | FromDiscord | <retkid> or maybe i underthought it |
19:05:12 | FromDiscord | <Recruit_main707> that sentence definetly doesnt make sense xd |
19:05:36 | FromDiscord | <retkid> lol idk lemme be im running on half steam and cheese cake |
19:05:41 | FromDiscord | <Recruit_main707> specially in nim because you can use the actual compiler |
19:06:29 | FromDiscord | <Recruit_main707> yeah yeah, no worries, whatever you are comfortable man, checking the nim way could also be useful to learn tho |
19:07:10 | FromDiscord | <retkid> well, this stuff is pretty simple so i would really only be learning how to split strings in nim |
19:07:17 | FromDiscord | <retkid> unless im doing the compiler which might be overkill |
19:08:50 | FromDiscord | <retkid> ooh i have an idea |
19:12:00 | FromDiscord | <Recruit_main707> https://stackoverflow.com/questions/32487507/nim-code-parser |
19:18:35 | FromDiscord | <haxscramper> This answer is ancient and all API has changed since |
19:18:37 | FromDiscord | <haxscramper> Also `import compiler.modules, compiler.ast, compiler.astalgo, compiler.passes, compiler.llstream` |
19:18:37 | FromDiscord | <haxscramper> First time seeing it like thsi |
19:45:50 | FromDiscord | <Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=3x9K |
19:47:22 | FromDiscord | <Ayy Lmao> The error is `Error: unhandled exception: ccgexprs.nim(809, 10) `tupType.kind == tyTuple` [AssertionDefect]` |
20:18:37 | * | auxym_ joined #nim |
20:44:49 | * | cyraxjoe quit (Read error: Connection reset by peer) |
20:45:44 | * | cyraxjoe joined #nim |
20:47:34 | * | Gustavo6046 joined #nim |
21:08:37 | arkanoid | c2nim is trying to parse inside a "#if defined(MYSYMBOL)" even if #assumendef MYSYMBOL is in C2NIM section |
21:09:51 | arkanoid | can you take a look at the .h file I'm trying to feed to c2nim and find out why? |
21:10:40 | * | auxym_ quit (Ping timeout: 240 seconds) |
21:15:12 | arkanoid | documentation says it should work on these constructs: https://github.com/nim-lang/c2nim/blob/master/doc/c2nim.rst#assumedef-and-assumendef-directives |
21:17:39 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
21:20:17 | FromDiscord | <haxscramper> If you share your header file I will look into it with hcparse & try out my latest idea. If everything goes well I might be able to produce working result |
21:20:51 | FromDiscord | <haxscramper> will look into it tomorrow |
21:21:53 | arkanoid | haxscramper https://termbin.com/5ttm9 |
21:22:52 | arkanoid | haxscramper, if you feed this to c2nim, you get error on line 716, inside the block defined by WITH_PURE_VIRTUAL, that is assumendef |
21:25:29 | arkanoid | haxscramper, this is and include that is required by the .h generated procedurally, so this is human generated probably. The real deal is the next file once this works |
21:26:10 | FromDiscord | <haxscramper> Can you also share it as well so I have more things to test on |
21:28:35 | FromDiscord | <haxscramper> First file you linked also contains implementation of the template function (at the very end) - it should be simply wrapped or converted as well? |
21:32:07 | * | max22- quit (Quit: Leaving) |
21:33:29 | arkanoid | haxscramper: sure. this is soapH.h https://termbin.com/8xvc, this is soapStub.h https://termbin.com/fgvu , these are both generated procedurally using thr gSOAP toolkit that reads a .wsdl and creates data binding |
21:35:41 | arkanoid | haxscramper: this is the bash script that generates them https://termbin.com/aim6 |
21:37:45 | arkanoid | long story short, wsdl2h takes a wsdl file and returns a .h file that has an internal sytax similar to C but is parsed by next tool. soapcpp2 takes this .h and creates actual .h and .c files that compiles successfully with gcc |
21:41:28 | arkanoid | and about your question about the template function at the very end: as you can see by the command line of the bash script I've shared, I've selected to generate C code and not C++, so __cplusplus should not be defined |
21:44:20 | FromDiscord | <haxscramper> Good. Hopefully boost wave would be able to correctly process all of this. |
21:44:29 | FromDiscord | <haxscramper> All of these macro defines |
21:45:27 | arkanoid | I though you were using libclang |
21:46:42 | NimEventer | New thread by Ggibson: How to make a const array in a proc w/ template?, see https://forum.nim-lang.org/t/8374 |
21:46:53 | arkanoid | all the assumendef you find on top are just picked from manual |
21:47:30 | arkanoid | any idea why WITH_PURE_VIRTUAL block is parsed even if it is assumendef? |
21:54:00 | FromDiscord | <haxscramper> Probably c2nim bug |
21:54:19 | FromDiscord | <haxscramper> In reply to @arkanoid "I though you were": I'm using everything |
21:54:54 | arkanoid | haha |
21:55:29 | arkanoid | I would be very curious watching you writing nim code. Have you ever though about doing screencasts? |
22:00:09 | * | rockcavera quit (Remote host closed the connection) |
22:09:57 | arkanoid | haxscramper, I've read what wave boost is, I didn't even know about it's existance. It says to be even more compliant than Intel compiler proprocessor |
22:34:28 | arkanoid | haxscramper, I'm trying to learn by reading your code. May you tell me where wrapWithConfig is defined? https://github.com/haxscramper/hcparse/blob/5bbe20c005bb947d0dafc77c20e8a37b2ee1062a/src/hcparse/clang_raw/make_wrap.nim#L47 |
22:39:56 | FromDiscord | <dan> i have been asking myself this for quite some time, but why is there a need to specify the header when cimporting? 🤔 |
22:40:17 | FromDiscord | <dan> is there information missing from the nim declaration? |
22:43:26 | FromDiscord | <dan> also adding onto that: what is the recommended way of exposing a c interfare to a nim shared library? is it better to just write my own header and practically re-wrap it in nim or use the nim feature of generating a header which afaik then depends on the nimbase.h? |
22:47:17 | * | xet7 quit (Remote host closed the connection) |
22:48:05 | * | xet7 joined #nim |
23:12:23 | * | Vladar quit (Remote host closed the connection) |
23:12:28 | FromDiscord | <ajusa> I'm trying to convert a proc to a template but I'm getting↵` Error: in expression '"test"()': identifier expected, but found '"test"'`, still somewhat new to templates in Nim though. Any idea what I'm doing wrong? |
23:13:29 | FromDiscord | <ajusa> Minimal example: https://play.nim-lang.org/#ix=3xaw |
23:20:57 | * | auxym_ joined #nim |
23:33:00 | * | flynn quit (Read error: Connection reset by peer) |
23:34:06 | * | flynn joined #nim |
23:44:23 | FromDiscord | <Paulo> maybe i got it wrong, but I can use nimscripts to set compiler options like "--threads:on", right? if so, how do i do it? |
23:54:35 | FromDiscord | <Elegantbeef> @ajusa\: inside templates the parameters are replaced wherever a identifier matches |
23:55:07 | FromDiscord | <Elegantbeef> @Paulo\: you can do `switch("threads", "on")` in a config.nims or `yourMainFile.nims` |
23:55:49 | FromDiscord | <Paulo> In reply to @Elegantbeef "<@164144089682411520>\: you can do": thank you |