<div dir="ltr">Perhaps make a c-define-type for <span style="font-family:arial,sans-serif;font-size:13px">std::vector<VideoMode>* that you return the return value of .</span><span style="font-family:arial,sans-serif;font-size:13px">getFullscreenModes() as, and then make a -length and -ref procedure for this type.</span><div>
<span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">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.</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/8/16 Chris Mueller <span dir="ltr"><<a href="mailto:ruunsmail@gmail.com" target="_blank">ruunsmail@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
i'm currently coding a gambit binding for sfml and could need some<br>
adivces for a specific ffi problem from you.<br>
<br>
Assume we have a class VideoMode with the following constructor:<br>
<br>
class VideoMode {<br>
public:<br>
VideoMode(int width, int height, int bbp);<br>
# ...<br>
}<br>
<br>
<br>
I have defined an interface to scheme with:<br>
<br>
;; Release hook is ignored for this example<br>
(c-define-type VideoMode* (pointer "VideoMode"))<br>
<br>
;; Scheme's construction wrapper for VideoMode<br>
(define video-mode<br>
(c-lambda (int int int) VideoMode* "___result_voidstar = new<br>
VideoMode(___arg1, ___arg2, ___arg3);"))<br>
<br>
<br>
Now assume a function that retrieves all supporting video-modes in C++:<br>
<br>
std::vector<VideoMode> getFullscreenModes();<br>
<br>
<br>
I would like to write now a scheme-function (with c-lambda) that<br>
iterators through all elements from this std::vector<br>
and constructs/returns a scheme-vector with foreign-objects of type<br>
(pointer "VideoMode").<br>
<br>
How does the c-lambda code look like for this small issue? (Or how would<br>
you cope this problem alternatively?)<br>
<br>
<br>
Chris<br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
Gambit-list mailing list<br>
<a href="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</a><br>
<a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
</blockquote></div><br></div>