IRC channel logs

2020-04-21.log

back to list of logs

<lampilelo>i think i can make a bytevector of size (sizeof '*) and put the address stored in the pointer there, then bytevector->pointer, not sure though
<lampilelo>seems sketchy for sure
<mwette>I think you have it.
<mwette>But you need the pointer-pointer to point to something, right?
<mwette>Or are you just getting a pointer back?
<lampilelo>i invoked C function that returns a pointer to a new object
<mwette>I think you should be OK.
<lampilelo>i hope nothing blows up
***Aurora_iz_kosmos is now known as Aurora_v_kosmose
<lampilelo>ok, it appears to be working, it blown-up at first but after some changes (that in my mind shouldn't change anything), it started working
<lampilelo>but now i wonder what happens with a char* returned from the function, it's allocated on the heap, so i guess i should free it?
<lampilelo>guile doesn't automatically put it under GC?
<lampilelo>it's so confusing, next time i
<lampilelo>i'll do it with a module in c
***hugh_marera_ is now known as hugh_marera
<mwette>No. You want a finalizer. Maybe you could use a guardian (see ref man) and call free().
<mwette>I'm working on a tool to automate generating FFI code from C headers. I don't know how to approach the memory management issue in a general, or semi-automated, sense.
<lampilelo>how do i make a finalizer from guile then?
<lampilelo>you mean i just make a foreign function pointer to the specific free function?
<mwette>not sure in this case. If you use foreign objects, then I think it can be done.
<mwette>guardians -- you add the object to a guardian and then poll it. When the gc is ready to free the pointer the guardian will cough it up and you can free the memory.
<mwette>or if you can get your C code to use scm_gc_malloc() from libguile
<lampilelo>ah, i see, i didn't know about guardians
<lampilelo>ok, that's it for today, thanks for the guidance mwette
<mwette>seeya
<dsmith>Especially coughing guardians...
<mwette>... technically speaking.
***catonano_ is now known as catonano
<daviid>dsmith-work, and others who are interested in guile-sqlite3 - https://notabug.org/guile-sqlite3/guile-sqlite3
***d4ryus2 is now known as d4ryus
***rekado_ is now known as rekado
<daviid>tohoyn: do you read this channel log?
<tohoyn>moving discussion to the channel: Is it now possible to pass GObject types as procedure arguments in G-Golf? This is needed by list stores.
<tohoyn>what about GValue arguments?
<daviid>tohoyn: I pushed a series of patches that address the problems you raised, you should pull the latest g-golf devel branch, make/install and try again, here is a snipset - http://paste.debian.net/1141803/
<daviid>I didn't try a gobject, but you should be able to do that, if not let me know, paste a snipset so can reproduce ... tx
<str1ngs>daviid : hello daviid, just a FYI there is now a g-golf package in guix :)
<tohoyn>daviid: The snippet works.
<daviid>str1ngs: ah great, thanks! do you have a way to 'mark it' as experirental there?
<str1ngs>tohoyn: I'm not sure I under stand the GObject question. can you elaborate? just that all g-golf classes derive from GObject. and you can pass them to procedures.
<daviid>tohoyn: great
<str1ngs>daviid I could have submitted it as g-golf-next. but instead I just commented in the declaration g-golf is still WIP
<str1ngs>as far as I know nomad is the only package that is using g-golf right now. so you'll have to manually install and use g-golf.
<tohoyn>str1ngs: GtkListStore needs GObject type arguments for the data
<str1ngs>and the nomad in guix is not the one ported to g-golf .. yet.
<str1ngs>tohoyn ah you mean like what nomad_scheme_get_type() would return?
<str1ngs>or macros like NOMAD_TYPE_SCHEME?
<tohoyn>str1ngs: I think that they are GTypeInfo structs
<str1ngs>makes sense now, thanks for elaborating.
<str1ngs>tohoyn: I might have missed your IRC queries apologies.
<tohoyn>daviid: The original list store example I sent you earlier works when modified
<tohoyn>str1ngs: it seems that G-Golf needs the types as symbols now
<tohoyn>str1ngs: primitive types like "int" and "string"
<str1ngs>symbols makes sense for this. like how flags and enums work.
<tohoyn>str1ngs: actually I suspect that the types passed as arguments are GType values
<tohoyn>str1ngs: see https://developer.gnome.org/gtk3/stable/GtkListStore.html#gtk-list-store-newv
<str1ngs>i'm curious what your use case is here tohoyn are you using a Tree or Model?
<dsmith>daviid: Ah. Thanks for the link.
<tohoyn>str1ngs: do you want to see the list store example?
<str1ngs>tohoyn: sure that would be interesting, thank you.
<tohoyn>str1ngs: see http://paste.debian.net/1141811/
<daviid>dsmith: welcome, I sent an email to the list maintainer, it should appear there as well soon hopefully
<str1ngs>tohoyn: treeview makes sense, thanks for the example.
<str1ngs>I added this to g-golf examples :)
<dsmith-work>UGT Greetings, Guilers
<RhodiumToad>good afternoon
***wxie1 is now known as wxie
<tohoyn>daviid: hello
<tohoyn>daviid: GtkTreePath is not imported properly. After (gi-import-by-name "Gtk" "TreePath") type <gtk-tree-path> is not defined.
<daviid>tohoyn: it seems it is a struct, not a gobject
<tohoyn>daviid: yes
<daviid>opaque struct can only be used through there api interfaces
<tohoyn>daviid: ok
<daviid>tohoyn: about the list-store gobject problem, if you can paste a small example I can 'play with', that would help
<daviid>same for GtkTreePath if you have a problem
<tohoyn>daviid: see https://paste.debian.net/1141871/ for passing GOOPS objects as G-Golf argument
<tohoyn>daviid: it doesn't work
<daviid>ok, will look at it tx
<daviid>tohoyn: not sure what you expect, wrt to your paste, gtk-list-store-newv expect a list of g-type
<tohoyn>daviid: to pass the <a> object into the store
<tohoyn>daviid: there is a bug with tree views, see https://paste.debian.net/1141881/
<daviid>you must call gtk-init
<tohoyn>daviid: ok
<tohoyn>daviid: it works now
<daviid>tohoyn: yes, but back to your earlier paste, <a> is not a g-type, so there is no way to initialize the GValue ...
<tohoyn>daviid: ok
<daviid>tohoyn: are you by any cahnce trying to reproduce something that did work using guile-gnome, that I can look at to compare?
<tohoyn>daviid: I'm trying to make G-Golf support to my own programming language Theme-D. If I encounter such problems I will report to you.
<tohoyn>daviid: I have already implemented guile-gnome support to Theme-D.
<daviid>i doubt you could do (gtk-list-store-newv 2 '(int <a>)) in guile-gnome but ...
<daviid>tohoyn: what should work is (gtk-list-store-newv 2 '(int object)) - but then gtk-list-store-set-value will currently fail, even if you pass a g-object subclass instance, which might be a bug, though I don't know how a list-store would render such a value, it still might be a bug/limitation of g-golf as it is
*sneek stretches
<tohoyn>daviid: function gtk-text-buffer-create-tag is not imported when you do (gi-import "Gtk"). I suppose that it is because the function has a variable argument list.
<daviid>probably
<dsmith-work>So I finally did it. I've enabled paredit in Scheme buffers. Just gotta do it.