~ubuntu-branches/ubuntu/hardy/swig1.3/hardy

« back to all changes in this revision

Viewing changes to Doc/Manual/Mzscheme.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:16:04 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205011604-ygx904it6413k3go
Tags: 1.3.27-1ubuntu1
Resynchronise with Debian again, for the new subversion packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
<html>
4
4
<head>
5
5
<title>SWIG and MzScheme</title>
 
6
<link rel="stylesheet" type="text/css" href="style.css">
6
7
</head>
7
8
 
8
9
<body bgcolor="#ffffff">
9
10
 
10
11
<H1><a name="MzScheme"></a>21 SWIG and MzScheme</H1>
11
12
<!-- INDEX -->
 
13
<div class="sectiontoc">
12
14
<ul>
13
15
<li><a href="#MzScheme_nn2">Creating native MzScheme structures</a>
14
16
</ul>
 
17
</div>
15
18
<!-- INDEX -->
16
19
 
17
20
 
22
25
<H2><a name="MzScheme_nn2"></a>21.1 Creating native MzScheme structures</H2>
23
26
 
24
27
 
 
28
<p>
25
29
Example interface file:
26
 
<blockquote>
 
30
</p>
 
31
 
 
32
<div class="code">
27
33
<pre>
28
34
/* define a macro for the struct creation */
29
35
%define handle_ptr(TYPE,NAME)
40
46
/* setup the typemaps for the pointer to an output parameter cntrs */
41
47
handle_ptr(struct diag_cntrs, cntrs);
42
48
</pre>
43
 
</blockquote>
 
49
</div>
44
50
 
 
51
<p>
45
52
Then in scheme, you can use regular struct access procedures like
46
 
<blockquote>
 
53
</p>
 
54
 
 
55
<div class="code">
47
56
<pre>
48
57
        ; suppose a function created a struct foo as 
49
58
        ; (define foo (make-diag-cntrs (#x1 #x2 #x3) (make-inspector))
52
61
        (format "0x~x" (diag-cntrs-field2 foo))
53
62
        ;etc...
54
63
</pre>
55
 
</blockquote>
 
64
</div>
56
65
 
 
66
<p>
57
67
That's pretty much it. It works with nested structs as well. 
 
68
</p>
58
69
 
59
70
</body>
60
71
</html>