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:32 | FromDiscord | <.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:46 | FromDiscord | <.tokyovigilante> Is there any way I can import these as an enum or set of consts programmatically? |
01:51:23 | FromDiscord | <Elegantbeef> I assume `fourcc_code` is also a macro? |
01:57:38 | FromDiscord | <.tokyovigilante> yup |
01:58:16 | FromDiscord | <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:26 | FromDiscord | <.tokyovigilante> basically just shifts by 0, 8, 16, or 24 bits to encode the 4cc into a 32 bit int |
01:58:27 | FromDiscord | <Elegantbeef> But really you'll have to port the macros into compile time procedures |
01:58:42 | FromDiscord | <.tokyovigilante> maybe easier to just search and replace 🙂 |
02:10:58 | FromDiscord | <.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:28 | FromDiscord | <Elegantbeef> You mean convert it to a byte? |
02:11:36 | FromDiscord | <Elegantbeef> Or uint8 |
02:12:41 | FromDiscord | <.tokyovigilante> I do, is there any shorthand for uint8('D') for example where D = 68 |
02:12:53 | FromDiscord | <Elegantbeef> You just wrote the shorthand 😄 |
02:12:58 | FromDiscord | <.tokyovigilante> lol ok |
02:13:04 | FromDiscord | <.tokyovigilante> not very short |
02:13:05 | FromDiscord | <Elegantbeef> unless you want to write `68u8` instead |
02:15:36 | FromDiscord | <.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:39 | FromDiscord | <Elegantbeef> Hey I wasn't going to say it |
02:18:23 | FromDiscord | <.tokyovigilante> Its ok, leave my ego at the door most days |
02:32:48 | * | rockcavera quit (Remote host closed the connection) |
02:45:57 | FromDiscord | <.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:01 | FromDiscord | <.tokyovigilante> sent a code paste, see https://play.nim-lang.org/#pasty=lOGVFXlC |
02:46:22 | FromDiscord | <.tokyovigilante> type DRMFormat = enum↵ DRM_FORMAT_C1 = fourcc_code('C', '1', ' ', ' ') #[ |
02:46:44 | FromDiscord | <.tokyovigilante> (edit) "type" => "`type" | "') #[" => "')`" |
02:46:49 | FromDiscord | <.tokyovigilante> to generate something like this? |
02:47:02 | FromDiscord | <.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:40 | FromDiscord | <Elegantbeef> Why are you using a nim macro? |
02:57:56 | FromDiscord | <Elegantbeef> Make it a procedure and it'll work |
04:07:23 | tokyovigilante | it doesn’t seem to work with a procedure inside a macro unfortunately, the second item complains about a duplicate definition of fourcc |
04:13:32 | FromDiscord | <Elegantbeef> Quit puting a procedure inside a macro |
04:13:35 | FromDiscord | <Elegantbeef> Just make it a procedure |
04:21:29 | * | amadaluzia joined #nim |
04:22:06 | * | SchweinDeBurg joined #nim |
04:25:47 | FromDiscord | <janakali> sent a code paste, see https://play.nim-lang.org/#pasty=aCNpcVks |
04:31:17 | FromDiscord | <.tokyovigilante> Yup I’ve got that but then a second item doesn’t work because of an error around reusing fourcc() |
05:55:45 | Amun-Ra | I implementer fourcc this way (less writing): https://play.nim-lang.org/#pasty=HAcIKaZa |
05:55:51 | Amun-Ra | implemented* |
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:49 | FromDiscord | <janakali> sent a code paste, see https://play.nim-lang.org/#pasty=OPhbjKOh |
08:49:36 | FromDiscord | <janakali> (edit) "https://play.nim-lang.org/#pasty=soUYTVMa" => "https://play.nim-lang.org/#pasty=LmPrMesL" |
08:50:25 | FromDiscord | <.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:33 | FromDiscord | <.tokyovigilante> sent a code paste, see https://play.nim-lang.org/#pasty=jsnxJfkj |
11:03:08 | FromDiscord | <.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:37 | FromDiscord | <.tokyovigilante> ah, seems it does |
11:03:59 | FromDiscord | <.tokyovigilante> if I remove `DRM_FORMAT_BIG_ENDIAN = 1'u32 shl 31` then the above compiles |
11:08:01 | Amun-Ra | replace DRMFromat(val) with cast[DRMFormat](val) and she'll be right |
11:09:15 | FromDiscord | <.tokyovigilante> outstanding, thanks again |
11:10:09 | Amun-Ra | watch out for converting to enums with holes |
11:13:33 | FromDiscord | <.tokyovigilante> ta, presumably it's enough to catch that exception? |
11:16:40 | Amun-Ra | if you have an enum with holes you have to be sure the value is value before the conversion/cast |
11:17:14 | Amun-Ra | if you'll try to do the convertion compile-time it'll end up with compile error |
11:17:54 | Amun-Ra | if you use cast or convert when in release mode magic (as in UB) things will happen |
11:18:08 | Amun-Ra | https://play.nim-lang.org/#pasty=FgkNqdzl |
11:19:16 | Amun-Ra | and don't use enum for flags; if you need a distinct flag type use distinct uint32/etc. |
11:19:48 | FromDiscord | <.tokyovigilante> okey-dokey, may need to rethink the approach, thanks |
11:21:27 | Amun-Ra | are you trying to wrap drm_fourcc.h? |
11:22:28 | FromDiscord | <.tokyovigilante> yup, and I only really need to care about the names for pretty-printing, and then selecting specific format |
11:23:00 | FromDiscord | <.tokyovigilante> so maybe this is a waste of time, other than good learning the ins and outs of some of these concepts |
11:23:27 | Amun-Ra | I'll show you how i'd to that, gimme a sec |
11:23:38 | FromDiscord | <.tokyovigilante> np, thanks |
11:35:39 | Amun-Ra | .tokyovigilante: https://play.nim-lang.org/#pasty=PcpRuHFf |
11:36:55 | Amun-Ra | it'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:48 | FromDiscord | <.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:21 | Amun-Ra | no worries |
11:48:24 | Amun-Ra | feel 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:38 | FromDiscord | <nervecenter> sent a code paste, see https://play.nim-lang.org/#pasty=YfrtzVGB |
16:17:42 | FromDiscord | <nervecenter> (edit) "https://play.nim-lang.org/#pasty=krhAWJiS" => "https://play.nim-lang.org/#pasty=vZrCsAPS" |
16:18:05 | FromDiscord | <nervecenter> Or any specific width integer type for that matter |
16:18:53 | FromDiscord | <nervecenter> Oh right, `i, I, u, U` |
16:18:56 | FromDiscord | <nervecenter> Nvm |
16:21:05 | FromDiscord | <nervecenter> Okay, well now how do I cast a variable int from one width to another |
16:21:35 | FromDiscord | <nervecenter> sent a code paste, see https://play.nim-lang.org/#pasty=LXdPdFgg |
16:22:39 | FromDiscord | <lainlaylie> does a normal conversion not work |
16:24:20 | FromDiscord | <griffith1deadly> sent a code paste, see https://play.nim-lang.org/#pasty=xErXIjld |
16:39:01 | FromDiscord | <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:32 | FromDiscord | <nervecenter> In reply to @griffith1deadly "isn't you should use": Same thing, UFCS produces the same AST result |
16:44:04 | FromDiscord | <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:31 | FromDiscord | <nervecenter> I specifically need a cast and to lop off the upper 8 bits. |
16:45:12 | FromDiscord | <griffith1deadly> In reply to @nervecenter "Same thing, UFCS produces": no↵https://play.nim-lang.org/#pasty=NDeacUJh |
16:47:05 | FromDiscord | <griffith1deadly> compiler think that use trying to access field `cast` of type `int16` instead of proc call |
16:47:32 | FromDiscord | <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:39 | FromDiscord | <griffith1deadly> (edit) "use" => "you" |
16:48:19 | FromDiscord | <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:54 | FromDiscord | <griffith1deadly> https://play.nim-lang.org/#pasty=iSoyrZhc |
16:52:01 | FromDiscord | <griffith1deadly> you can do something like that |
16:52:08 | FromDiscord | <griffith1deadly> but you can't directly that with cast |
17:00:16 | FromDiscord | <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:24 | FromDiscord | <janakali> TIL |