Re: [Chicken-users] Chicken and GUI programming
Ah, also stay away from thread-wait-for-i/o on files descriptors. ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] how to declare foreign variably size structs?
One possible solution read a whole object into predefined record (define-record inotify wd mask cookie len name) ; this function make record and pass it into hepler function (define (read-event fd) (c-read-event (make-inotify) fd)) ; map inotify fields to record fields using lowlevel function C_block_item (define c-read-event (foreign-safe-lambda* void ((scheme-object res) (int fd)) "struct inotify_event* e; char buffer[sizeof(*e) + MAX_PATH]; if (read(fd,buffer,sizeof(buffer)) 0) C_return(C_SCHEME_FALSE); C_word* ptr = C_alloc(C_SIZEOF_STRING(e-len)); C_block_item(res,1) = C_fix(e-wd); C_block_item(res,2) = C_fix(e-mask); C_block_item(res,3) = C_fix(e-cookie); C_block_item(res,4) = C_fix(e-len); C_block_item(res,5) = C_string(ptr,e-name,numbytes); C_return(res);")) this should work but i worry that uint32 didnt't fit into the fixnum (C_fix stuff) ;; or something like this (match (file-read fd 1000) ((data size) (make-inotify wd: (read-uint32 data) mask: (read-uint32 data) cookie: (read-uint32 data) len: (read-uint32 data) name: (read-string data o_O 06/20/13 23:58:52, Geoffrey lordgeoff...@optusnet.com.au: Hi I am trying to declare of variably sized c struct as a foreign declaration. The one i am after is: struct inotify_event { int wd;/* Watch descriptor. */ uint32_t mask;/* Watch mask. */ uint32_t cookie;/* Cookie to synchronize two events. */ uint32_t len;/* Length (including NULs) of name. */ char name __flexarr;/* Name. */ }; Note that name field is variably sized. I believe in C you would allocate a larger block of memory and then cast it to (inotify_event*). By the skills of copy and paste i can do fixed size,and i can do a blob. But not a variable struct. Some help would be appreciated. Thanks ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Chicken C interface
this should work for basic list test (import foreign) # C_word C_listp(C_word p) { if (p == C_SCHEME_END_OF_LIST) { return C_SCHEME_TRUE; } // check for non-immidiate object and pair? if (!C_immediatep(p) C_pairp(p) == C_SCHEME_TRUE) { return C_listp(C_u_i_cdr(p)); } return C_SCHEME_FALSE; } # (define listp? (foreign-lambda scheme-object "C_listp" scheme-object)) (print (listp? 1)) (print (listp? (cons 1 2))) (print (listp? (cons (cons 1 2) (cons 3 4 (print (listp? 1.0)) (print (listp? '(1))) (print (listp? '(1 2))) 06/05/13 19:10:41, pluijzer . pluij...@gmail.com: Hello everybody, I was planning to use Chicken Scheme in a fashion more similar to Guile and Lua. i.e. passing Scheme Data Objects from Chicken to C and back using the C interface. I am a little confused though as how to have a C function return a Scheme List that is seen by the garbage collector. For example, is the code below correct, will the list be seen by the garbage collector? And if not, is there correct way to do this. # C_word give_12() { C_word *mem = C_alloc(C_SIZEOF_LIST(2)); C_word list = C_list(mem, 2, C_fix(1), C_fix(2)); return list; } # (print ((foreign-lambda scheme-object "give_12"))) Also there doesn't seem to be a C_listp predicate. Is this a concious omission? thank you in advance, Richard ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] problem building chicken 4.8.0.3 on mac 10.4
No such problem on 10.7 rules.make: line 114 is empty make error "*** missing separator. Stop." mean that line starts not with tab or valid make command so if u have changes in this file try to revert or check that editor didnt replace tab with spaces. if possible move to the latest gnu make version. o_O 06/03/13 12:58:28, Felix fe...@call-with-current-continuation.org: Hello! When trying make PLATFORM=macosx PREFIX=$HOME I get make -f ./Makefile.macosx CONFIG= all rules.make:114: *** missing separator. Stop. make: *** [all] Error 2 This is GNU make 3.80, running on Mac OS X 10.4 (ppc). Any help would be appreciated. cheers, felix ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users