<< 22-05-2025 >>

00:41:23*tiorock joined #nim
00:41:23*tiorock quit (Changing host)
00:41:23*tiorock joined #nim
00:41:23*rockcavera is now known as Guest973
00:41:23*Guest973 quit (Killed (silver.libera.chat (Nickname regained by services)))
00:41:23*tiorock is now known as rockcavera
00:43:25*tiorock joined #nim
00:43:25*tiorock quit (Changing host)
00:43:25*tiorock joined #nim
00:43:25*rockcavera quit (Killed (tantalum.libera.chat (Nickname regained by services)))
00:43:25*tiorock is now known as rockcavera
00:55:40*tiorock joined #nim
00:55:40*tiorock quit (Changing host)
00:55:40*tiorock joined #nim
00:55:40*rockcavera is now known as Guest5049
00:55:40*tiorock is now known as rockcavera
00:57:49*tiorock joined #nim
00:57:49*tiorock quit (Changing host)
00:57:49*tiorock joined #nim
00:57:49*rockcavera is now known as Guest9943
00:57:49*tiorock is now known as rockcavera
00:59:28*Guest5049 quit (Ping timeout: 252 seconds)
01:00:34*Guest9943 quit (Ping timeout: 252 seconds)
01:35:15*SchweinDeBurg quit (Quit: WeeChat 4.7.0-dev)
01:45:02*tiorock joined #nim
01:45:02*tiorock quit (Changing host)
01:45:02*tiorock joined #nim
01:45:02*rockcavera is now known as Guest7663
01:45:02*Guest7663 quit (Killed (platinum.libera.chat (Nickname regained by services)))
01:45:02*tiorock is now known as rockcavera
01:50:32FromDiscord<.tokyovigilante> hey, I'm trying to use the buffer format codes in `drm_fourcc.h` on linux, but using Futhark to import the header doesn't bring in the defines, which are all along the lines of `#define DRM_FORMAT_XRGB8888 fourcc_code('X', 'R', '2', '4') / [31:0] x:R:G:B 8:8:8:8 little endian /`
01:50:46FromDiscord<.tokyovigilante> Is there any way I can import these as an enum or set of consts programmatically?
01:51:23FromDiscord<Elegantbeef> I assume `fourcc_code` is also a macro?
01:57:38FromDiscord<.tokyovigilante> yup
01:58:16FromDiscord<Elegantbeef> Well you could write code that calls them call then use `gcc -e` to expand the code and then run c2nim on it
01:58:26FromDiscord<.tokyovigilante> basically just shifts by 0, 8, 16, or 24 bits to encode the 4cc into a 32 bit int
01:58:27FromDiscord<Elegantbeef> But really you'll have to port the macros into compile time procedures
01:58:42FromDiscord<.tokyovigilante> maybe easier to just search and replace 🙂
02:10:58FromDiscord<.tokyovigilante> If I've got this `let DRM_FORMAT_D1 = fourcc_code('D', '1', ' ', ' ')` and I've rewritten `fourcc_code` as a template that takes 4 8-bit chars and does the appropriate bit shift to a `uint32`, is there an easy way to interpret eg 'D' as a char? ie 'D' vs "D" as in C
02:11:28FromDiscord<Elegantbeef> You mean convert it to a byte?
02:11:36FromDiscord<Elegantbeef> Or uint8
02:12:41FromDiscord<.tokyovigilante> I do, is there any shorthand for uint8('D') for example where D = 68
02:12:53FromDiscord<Elegantbeef> You just wrote the shorthand 😄
02:12:58FromDiscord<.tokyovigilante> lol ok
02:13:04FromDiscord<.tokyovigilante> not very short
02:13:05FromDiscord<Elegantbeef> unless you want to write `68u8` instead
02:15:36FromDiscord<.tokyovigilante> actually I am being dumb, 'D' is already a char in Nim, my template just needs to take char params not uint8
02:16:39FromDiscord<Elegantbeef> Hey I wasn't going to say it
02:18:23FromDiscord<.tokyovigilante> Its ok, leave my ego at the door most days
02:32:48*rockcavera quit (Remote host closed the connection)
02:45:57FromDiscord<.tokyovigilante> hmm, seems this doesn't like being run as part of an enum definition either, can I turn this into a macro?
02:46:01FromDiscord<.tokyovigilante> sent a code paste, see https://play.nim-lang.org/#pasty=lOGVFXlC
02:46:22FromDiscord<.tokyovigilante> type DRMFormat = enum↵ DRM_FORMAT_C1 = fourcc_code('C', '1', ' ', ' ') #[
02:46:44FromDiscord<.tokyovigilante> (edit) "type" => "`type" | "') #[" => "')`"
02:46:49FromDiscord<.tokyovigilante> to generate something like this?
02:47:02FromDiscord<.tokyovigilante> (edit) "`type DRMFormat = enum↵ DRM_FORMAT_C1 = fourcc_code('C', '1', ' ', ' ')`" => "sent a code paste, see https://play.nim-lang.org/#pasty=ZjhlGpxJ"
02:57:40FromDiscord<Elegantbeef> Why are you using a nim macro?
02:57:56FromDiscord<Elegantbeef> Make it a procedure and it'll work
04:07:23tokyovigilanteit doesn’t seem to work with a procedure inside a macro unfortunately, the second item complains about a duplicate definition of fourcc
04:13:32FromDiscord<Elegantbeef> Quit puting a procedure inside a macro
04:13:35FromDiscord<Elegantbeef> Just make it a procedure
04:21:29*amadaluzia joined #nim
04:22:06*SchweinDeBurg joined #nim
04:25:47FromDiscord<janakali> sent a code paste, see https://play.nim-lang.org/#pasty=aCNpcVks
04:31:17FromDiscord<.tokyovigilante> Yup I’ve got that but then a second item doesn’t work because of an error around reusing fourcc()
05:55:45Amun-RaI implementer fourcc this way (less writing): https://play.nim-lang.org/#pasty=HAcIKaZa
05:55:51Amun-Raimplemented*
06:12:47*alexdaguy joined #nim
06:42:17*amadaluzia quit (Ping timeout: 252 seconds)
06:56:21*xtr00 quit (Read error: Connection reset by peer)
07:01:29*xtr00 joined #nim
08:23:29*beholders_eye joined #nim
08:48:49FromDiscord<janakali> sent a code paste, see https://play.nim-lang.org/#pasty=OPhbjKOh
08:49:36FromDiscord<janakali> (edit) "https://play.nim-lang.org/#pasty=soUYTVMa" => "https://play.nim-lang.org/#pasty=LmPrMesL"
08:50:25FromDiscord<.tokyovigilante> In reply to @janakali "<@765483892026114049> the error is": Thanks and to Amun-Ra, I figured that out independently after staring at mine and Amun-Ra's for some time wondering why mine wasn't working. Appreciate the help though!
10:31:36*fabricio joined #nim
11:02:33FromDiscord<.tokyovigilante> sent a code paste, see https://play.nim-lang.org/#pasty=jsnxJfkj
11:03:08FromDiscord<.tokyovigilante> What ordinal format is the enum initialiser expecting? And does this depend on the values I give it when I define it?
11:03:37FromDiscord<.tokyovigilante> ah, seems it does
11:03:59FromDiscord<.tokyovigilante> if I remove `DRM_FORMAT_BIG_ENDIAN = 1'u32 shl 31` then the above compiles
11:08:01Amun-Rareplace DRMFromat(val) with cast[DRMFormat](val) and she'll be right
11:09:15FromDiscord<.tokyovigilante> outstanding, thanks again
11:10:09Amun-Rawatch out for converting to enums with holes
11:13:33FromDiscord<.tokyovigilante> ta, presumably it's enough to catch that exception?
11:16:40Amun-Raif you have an enum with holes you have to be sure the value is value before the conversion/cast
11:17:14Amun-Raif you'll try to do the convertion compile-time it'll end up with compile error
11:17:54Amun-Raif you use cast or convert when in release mode magic (as in UB) things will happen
11:18:08Amun-Rahttps://play.nim-lang.org/#pasty=FgkNqdzl
11:19:16Amun-Raand don't use enum for flags; if you need a distinct flag type use distinct uint32/etc.
11:19:48FromDiscord<.tokyovigilante> okey-dokey, may need to rethink the approach, thanks
11:21:27Amun-Raare you trying to wrap drm_fourcc.h?
11:22:28FromDiscord<.tokyovigilante> yup, and I only really need to care about the names for pretty-printing, and then selecting specific format
11:23:00FromDiscord<.tokyovigilante> so maybe this is a waste of time, other than good learning the ins and outs of some of these concepts
11:23:27Amun-RaI'll show you how i'd to that, gimme a sec
11:23:38FromDiscord<.tokyovigilante> np, thanks
11:35:39Amun-Ra.tokyovigilante: https://play.nim-lang.org/#pasty=PcpRuHFf
11:36:55Amun-Rait's not the only way to do those kind of operations it's just how I do it
11:36:55*ntat joined #nim
11:38:48FromDiscord<.tokyovigilante> wow, thanks! will give it a read over
11:40:20*fabricio quit (Quit: WeeChat 3.5)
11:40:38*fabricio joined #nim
11:46:21Amun-Rano worries
11:48:24Amun-Rafeel free to ask me any questions, I'll be online until 13:30 GMT
12:06:45*beholders_eye quit (Ping timeout: 248 seconds)
12:33:28*ntat quit (Quit: leaving)
13:12:47*xtr00 quit (Read error: Connection reset by peer)
13:17:17*xtr00 joined #nim
14:49:12*PMunch_ joined #nim
14:52:03*PMunch__ quit (Ping timeout: 245 seconds)
14:55:49*xutaxkamay quit (Ping timeout: 248 seconds)
15:13:10*xtr00 quit (Read error: Connection reset by peer)
15:21:00*xtr00 joined #nim
15:26:47*beholders_eye joined #nim
15:52:36*alexdaguy quit (Quit: w)
16:06:34*fabricio quit (Ping timeout: 260 seconds)
16:09:39*beholders_eye quit (Ping timeout: 276 seconds)
16:17:38FromDiscord<nervecenter> sent a code paste, see https://play.nim-lang.org/#pasty=YfrtzVGB
16:17:42FromDiscord<nervecenter> (edit) "https://play.nim-lang.org/#pasty=krhAWJiS" => "https://play.nim-lang.org/#pasty=vZrCsAPS"
16:18:05FromDiscord<nervecenter> Or any specific width integer type for that matter
16:18:53FromDiscord<nervecenter> Oh right, `i, I, u, U`
16:18:56FromDiscord<nervecenter> Nvm
16:21:05FromDiscord<nervecenter> Okay, well now how do I cast a variable int from one width to another
16:21:35FromDiscord<nervecenter> sent a code paste, see https://play.nim-lang.org/#pasty=LXdPdFgg
16:22:39FromDiscord<lainlaylie> does a normal conversion not work
16:24:20FromDiscord<griffith1deadly> sent a code paste, see https://play.nim-lang.org/#pasty=xErXIjld
16:39:01FromDiscord<janakali> sent a code paste, see https://play.nim-lang.org/#pasty=soUDHsKs
16:40:11*SchweinDeBurg quit (Quit: WeeChat 4.7.0-dev)
16:43:32FromDiscord<nervecenter> In reply to @griffith1deadly "isn't you should use": Same thing, UFCS produces the same AST result
16:44:04FromDiscord<nervecenter> In reply to @janakali "<@143177514385145856> https://nim-lang.org/docs/man": I am exactly trying to interpret a bit pattern as a new type. I need the sign bit to not be interpreted.
16:44:31FromDiscord<nervecenter> I specifically need a cast and to lop off the upper 8 bits.
16:45:12FromDiscord<griffith1deadly> In reply to @nervecenter "Same thing, UFCS produces": no↵https://play.nim-lang.org/#pasty=NDeacUJh
16:47:05FromDiscord<griffith1deadly> compiler think that use trying to access field `cast` of type `int16` instead of proc call
16:47:32FromDiscord<nervecenter> Odd, I made exactly this change once before and it produced the same error on the same line. Now it isn't? Maybe I'm going insane.
16:47:39FromDiscord<griffith1deadly> (edit) "use" => "you"
16:48:19FromDiscord<griffith1deadly> In reply to @nervecenter "Odd, I made exactly": isn't you try `number.cast[uint8]()`? that's also wrong syntax for that
16:51:54FromDiscord<griffith1deadly> https://play.nim-lang.org/#pasty=iSoyrZhc
16:52:01FromDiscord<griffith1deadly> you can do something like that
16:52:08FromDiscord<griffith1deadly> but you can't directly that with cast
17:00:16FromDiscord<janakali> btw, here's a reason why cast doesn't work with UFCS: https://github.com/nim-lang/Nim/pull/8528#issuecomment-410399934
17:02:24FromDiscord<janakali> TIL