Perhaps make a c-define-type for std::vector<VideoMode>* that you return the return value of .getFullscreenModes() as, and then make a -length and -ref procedure for this type.

Remember that for c-define-type :s that do not have a release procedure specified, there is *no* deallocation (such as free() etc.) invoked at their scheme-world GC.



2013/8/16 Chris Mueller <ruunsmail@gmail.com>
Hi,

i'm currently coding a gambit binding for sfml and could need some
adivces for a specific ffi problem from you.

Assume we have a class VideoMode with the following constructor:

class VideoMode {
public:
   VideoMode(int width, int height, int bbp);
   # ...
}


I have defined an interface to scheme with:

;; Release hook is ignored for this example
(c-define-type VideoMode* (pointer "VideoMode"))

;; Scheme's construction wrapper for VideoMode
(define video-mode
   (c-lambda (int int int) VideoMode* "___result_voidstar = new
VideoMode(___arg1, ___arg2, ___arg3);"))


Now assume a function that retrieves all supporting video-modes in C++:

std::vector<VideoMode> getFullscreenModes();


I would like to write now a scheme-function (with c-lambda) that
iterators through all elements from this std::vector
and constructs/returns a scheme-vector with foreign-objects of type
(pointer "VideoMode").

How does the c-lambda code look like for this small issue? (Or how would
you cope this problem alternatively?)


Chris





_______________________________________________
Gambit-list mailing list
Gambit-list@iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list