~ubuntu-branches/ubuntu/lucid/gauche-c-wrapper/lucid

« back to all changes in this revision

Viewing changes to doc/c-wrapper-ref.texi

  • Committer: Bazaar Package Importer
  • Author(s): NIIBE Yutaka
  • Date: 2008-04-07 09:15:03 UTC
  • Revision ID: james.westby@ubuntu.com-20080407091503-wu0h414koe95kj4i
Tags: upstream-0.5.2
Import upstream version 0.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
\input texinfo @c -*-texinfo-*-
 
2
@comment %**start of header
 
3
@c EN
 
4
@setfilename c-wrapper-refe.info
 
5
@settitle c-wrapper reference manual
 
6
@dircategory The Algorithmic Language Scheme
 
7
@direntry
 
8
* c-wrapper reference: (c-wrapper-refe.info).   A generic wrapper for C libraries.
 
9
@end direntry
 
10
@c JP
 
11
@setfilename c-wrapper-refj.info
 
12
@settitle c-wrapper ��ե���󥹥ޥ˥奢��
 
13
@dircategory The Algorithmic Language Scheme
 
14
@direntry
 
15
* c-wrapper reference: (c-wrapper-refj.info).   A generic wrapper for C libraries.
 
16
@end direntry
 
17
@documentencoding euc-jp
 
18
@c COMMON
 
19
@comment %**end of header
 
20
 
 
21
@c $Id: c-wrapper-ref.texi 13 2005-09-29 15:31:11Z naoki $
 
22
 
 
23
@c module and class index
 
24
@defcodeindex md
 
25
@defcodeindex cl
 
26
 
 
27
@iftex
 
28
@finalout
 
29
@parskip 4pt plus 1pt
 
30
@end iftex
 
31
 
 
32
@titlepage
 
33
@c EN
 
34
@title c-wrapper reference manual
 
35
@subtitle version @VERSION@
 
36
@author KOGURO, Naoki (naoki@@koguro.net)
 
37
@c JP
 
38
@title c-wrapper ��ե���󥹥ޥ˥奢��
 
39
@subtitle version @VERSION@
 
40
@author KOGURO, Naoki (naoki@@koguro.net)
 
41
@c COMMON
 
42
 
 
43
@page
 
44
@vskip 0pt plus 1filll
 
45
Copyright @copyright{} 2006 KOGURO, Naoki(naoki@@koguro.net)
 
46
 
 
47
@end titlepage
 
48
 
 
49
@node Top, c-wrapper, (dir), (dir)
 
50
 
 
51
@ifnottex
 
52
@c EN
 
53
This is a reference manual of c-wrapper.
 
54
@c JP
 
55
�ܥɥ�����Ȥ�c-wrapper�Υ�ե���󥹥ޥ˥奢��Ǥ���
 
56
@c COMMON
 
57
@end ifnottex
 
58
 
 
59
@menu
 
60
* c-wrapper::                   
 
61
* objc-wrapper::                
 
62
* Function and Syntax Index::   
 
63
* Class Index::                 
 
64
* Variable Index::              
 
65
 
 
66
@detailmenu
 
67
 --- The Detailed Node Listing ---
 
68
 
 
69
c-wrapper
 
70
 
 
71
* Load a shared library::       
 
72
* Load a header file::          
 
73
* Classes and function about C types and values::  
 
74
 
 
75
objc-wrapper
 
76
 
 
77
* Load a framework library::    
 
78
* Load an Objectice-C header file::  
 
79
* Functions about Objective-C objects::  
 
80
 
 
81
@end detailmenu
 
82
@end menu
 
83
 
 
84
@node c-wrapper, objc-wrapper, Top, Top
 
85
@comment  node-name,  next,  previous,  up
 
86
@chapter c-wrapper
 
87
 
 
88
@c EN
 
89
@code{c-wrapper} is the module which enables to use C libraries.
 
90
@c JP
 
91
@code{c-wrapper}�Ȥϡ�C�Υ饤�֥���Gauche����Ȥ���褦�ˤ��뤿��Υ⥸�塼��Ǥ���
 
92
@c COMMON
 
93
 
 
94
@menu
 
95
* Load a shared library::       
 
96
* Load a header file::          
 
97
* Classes and function about C types and values::  
 
98
@end menu
 
99
 
 
100
@node Load a shared library, Load a header file, c-wrapper, c-wrapper
 
101
@comment  node-name,  next,  previous,  up
 
102
@section Load a shared library
 
103
 
 
104
@defun c-load-library file-or-list &keyword
 
105
@c EN
 
106
Load one or more shared libraries. If you omit the extension, c-wrapper add
 
107
a extension (.so, .dylib, and so on) automatically.
 
108
@c JP
 
109
��ͭ�饤�֥����ɤ߹��ߤޤ��� @var{file-or-list} �ǥꥹ�Ȥ��Ϥ���ʣ���Υ饤�֥�꤬�ɤ߹��ޤ�ޤ���
 
110
�ޤ���ĥ�Ҥ��ά������硢�Ķ��˱�������ĥ�� (.so �� .dylib �ʤ� ) ���ղä���ޤ���
 
111
@c COMMON
 
112
 
 
113
@c EN
 
114
Keyword arguments are:
 
115
@c JP
 
116
������ɰ����ˤϰʲ��Τ�Τ�Ϳ���뤳�Ȥ��Ǥ��ޤ���
 
117
@c COMMON
 
118
@table @code
 
119
@item :option option-string
 
120
@c EN
 
121
Specify library names and library load paths with ld like option.
 
122
@c JP
 
123
ld��Ϳ���륪�ץ����Τ褦�ʷ����Ƕ�ͭ�饤�֥����ɤ߹��ߥѥ��λ����Ԥ��ޤ��������Ȥ���Τϰʲ��Υ��ץ����Ǥ���
 
124
@c COMMON
 
125
@table @code
 
126
@item -llibrary       
 
127
@c EN
 
128
Load the library named @var{library}. For example, -lc means to load 'libc'.
 
129
@c JP
 
130
��ͭ�饤�֥�� @var{library} ���ɤ߹��ߤޤ����㤨�С�-lc �Τ褦�˻��ꤹ��� libc ���ɤ߹��ޤ�ޤ���
 
131
@c COMMON
 
132
@item -Ldir
 
133
@c EN
 
134
Add directory @var{dir} to the library search paths.
 
135
@c JP
 
136
��ͭ�饤�֥��Υ������ꥹ�Ȥ˥ǥ��쥯�ȥ� @var{dir} ���ɲä��ޤ���
 
137
@c COMMON
 
138
@end table
 
139
@end table
 
140
@end defun
 
141
 
 
142
@defun c-ld option-string
 
143
@c EN
 
144
This function is the same (c-load-library '() :option option-string). and is designed to use with a command returning linker flags like pkg-config.
 
145
@c JP
 
146
(c-load-library '() :option option-string) ��Ʊ���Ǥ������δؿ��� pkg-config �ʤɤΤ褦�ʥ�󥫤Υե饰���֤����ޥ�ɤ��Ȥ߹�碌�ƻȤ����Ȥ����ꤷ�Ƥ��ޤ���
 
147
@c COMMON
 
148
@example
 
149
(c-ld (process-output->string "pkg-config Wand --libs"))
 
150
@end example
 
151
@end defun
 
152
 
 
153
@node Load a header file, Classes and function about C types and values, Load a shared library, c-wrapper
 
154
@comment  node-name,  next,  previous,  up
 
155
@section Load a header file
 
156
 
 
157
@deffn {Macro} c-include file-or-list &keyword
 
158
@c EN
 
159
Load one or more header files and define functions, global variables, constants
 
160
, type definitions and macros in the current module. 
 
161
@c JP
 
162
���ꤵ�줿�إå��ե�������ɤ߹��ߡ��ؿ����������Х��ѿ����������������ޥ����򥫥��ȥ⥸�塼���������ޤ���
 
163
 
 
164
@c EN
 
165
Keyword arguments are:
 
166
@c JP
 
167
keyword �����ˤϰʲ��Τ�Τ���ꤹ�뤳�Ȥ��Ǥ��ޤ���
 
168
@c COMMON
 
169
@table @code
 
170
@item :include-dirs
 
171
@c EN
 
172
Sets up include directories. You can specify either a string file name or a list of string file names.
 
173
@c JP
 
174
���󥯥롼�ɥѥ�����ꤷ�ޤ���ʸ����⤷����ʸ����Υꥹ�Ȥ������ǽ�Ǥ���
 
175
@c COMMON
 
176
@item :option
 
177
@c EN
 
178
Sets up C preprocessor options.
 
179
@c JP
 
180
 C�ץ�ץ����å����Ϥ����ץ�������ꤷ�ޤ���ʸ���󤬻����ǽ�Ǥ���
 
181
@c COMMON
 
182
@item :import
 
183
@c EN
 
184
Sets up symbols which you want to define. You can specify a symbol, a string, a regexp, a procedure or a list of them.
 
185
If you put a procedure, it is called with two arguments, a header file name and a symbol. When the procedure returns @code{#f}, the symbol is ignored, and the symbol is defined otherwise.
 
186
@c JP
 
187
�إå��ե����뤫���ɤ߹��ॷ��ܥ����ꤷ�ޤ���
 
188
�����Ȥ��ơ�����ܥ롢ʸ��������ɽ������³���ȡ������Υꥹ�Ȥ������ǽ�Ǥ���
 
189
��³�����Ϥ��줿���ϡ�����ܥ뤬���Ĥ��뤿�Ӥ˥إå��ե�����Υѥ�̾�ȥ���ܥ�̾������Ȥ��ơ����μ�³�����ƤӽФ���ޤ���
 
190
��³����@code{#f}���֤�����礽�Υ���ܥ��̵�뤵�졢����ʳ����ͤξ��˥���ܥ뤬�������ޤ���
 
191
@c COMMON
 
192
@item :export?
 
193
@c EN
 
194
Specifies whether symbols in header files are exported or not. If you put @code{#t}, the symbols are exported automatically, and otherwise they are not exported.
 
195
@c JP
 
196
�����������ܥ��@code{export}���뤫�ɤ�������ꤷ�ޤ���
 
197
@code{#t}�ξ��������������ܥ���Ф���ưŪ��@code{export}���¹Ԥ���ޤ���@code{#f}�ξ��ϲ��⤷�ޤ���
 
198
@c COMMON
 
199
@item :compiled-lib 
 
200
@c EN
 
201
Sets up a shared library file name which cwcompile command generates.
 
202
At runtime, if the library is exists, loads it instead of parsing the header files. Otherwise, parses the header files.
 
203
@c JP
 
204
cwcompile���ޥ�ɤˤ����������ѡ����Ѥߤζ�ͭ�饤�֥���̾������ꤷ�ޤ���
 
205
�����ǻ��ꤵ�줿��ͭ�饤�֥�꤬¸�ߤ����硢�إå��ե������ѡ�����������ˤ��ζ�ͭ�饤�֥����ɤ߹��ߤޤ�����ͭ�饤�֥�꤬¸�ߤ��ʤ����ϡ��إå��ե�����Υѡ������Ԥ��ޤ���
 
206
@c COMMON
 
207
@end table
 
208
 
 
209
@c EN
 
210
In loading header files, @code{c-include} gets these information and defines symbols.
 
211
@table @asis
 
212
@item Function prototype
 
213
Defines a function with the same name. It applies @code{cast} to its arguments and @code{scm-cast} to its return value.
 
214
@item External variable
 
215
Defines an object with the same name.
 
216
@item @code{enum}
 
217
Defines a constant value with the same name.
 
218
@item @code{struct}
 
219
Defines a struct class. You can use it with @code{(c-struct tagname)}.
 
220
@item @code{union}
 
221
Defines a union class. You can use it with @code{(c-union tagname)}.
 
222
@item @code{typedef}
 
223
Defines a class with the name @code{<typename>}.
 
224
@item Objectlike macro
 
225
Defines a value with the same name if the macro body is an expression, all identifiers in the body have been defined and the expression has no side-effect.
 
226
 
 
227
You have to be careful to use the value because it is the header-load-time value, not macro-use-time value. It may be different from one you expected.
 
228
@item Functionlike macro
 
229
Defines a macro with the same name if the macro body is an expression or statements and all identifiers in the body have been defined.
 
230
@end table
 
231
 
 
232
@c JP
 
233
�إå��ե������ɤ߹��߻��ˡ��ʲ��ξ����������ؿ����ѿ��ʤɤ�������Ƥ����ޤ���
 
234
@table @asis
 
235
@item �ؿ��Υץ��ȥ��������
 
236
�ؿ�̾��Ʊ̾�Υ���ܥ�Ǵؿ����������ޤ����ʤ����δؿ��ϰ������Ф���@code{cast}������ͤ��Ф���@code{scm-cast}��Ŭ�Ѥ��ޤ���
 
237
@item �����ѿ����
 
238
�ѿ�̾��Ʊ̾�Υ���ܥ�dz����ѿ��򻲾Ȥ��륪�֥������Ȥ��������ޤ���
 
239
@item @code{enum}
 
240
���̾��Ʊ̾�Υ���ܥ��������������ޤ���
 
241
@item @code{struct}
 
242
��¤�ΤΥ��饹��������ޤ������Υ��饹��@code{(c-struct tagname)}�ǻ��Ȥ��뤳�Ȥ��Ǥ��ޤ���
 
243
@item @code{union}
 
244
�����ΤΥ��饹��������ޤ������Υ��饹��@code{(c-union tagname)}�ǻ��Ȥ��뤳�Ȥ��Ǥ��ޤ���
 
245
@item @code{typedef}
 
246
@code{<typename>}�Ȥ�������ܥ��C�η����б����륯�饹��������ޤ���
 
247
@item ���֥������ȷ��� (objectlike) �Υޥ���
 
248
�ޥ��������Ƥ����Ǥ��ꡢ���Ѥ���Ƥ��뼱�̻Ҥ����٤�����ѤߤǤ��ꡢ���������Ѥ�ڤܤ����Ǥʤ����ˡ��ޥ���̾��Ʊ̾�Υ���ܥ���ͤ��������ޤ����ʤ���C����ǤΥޥ����Ȥϰ�̣���ۤʤꡢ�����ͤϥإå��ե������ɤ߹��߻����Ǥ��ͤǤ��ꡢ�ޥ������ѻ����Ǥ��ͤǤϤ���ޤ���
 
249
@item �ؿ����� (functionlike) �Υޥ���
 
250
�ޥ��������Ƥ����⤷����ʸ�Ǥ�����Ѥ���Ƥ��뼱�̻Ҥ����٤�����Ѥߤξ��ˤΤߡ��ޥ���̾��Ʊ̾�Υ���ܥ�ǥޥ������������ޤ���
 
251
@end table
 
252
 
 
253
@c COMMON
 
254
@end deffn
 
255
 
 
256
@deffn {Macro} c-load file-or-list &keyword
 
257
@c EN
 
258
Loads libraries, parses header files and defines functions, global variables, constants, type definitions and macros in current module.
 
259
This macro does @code{c-load-library} and @code{c-include} at once.
 
260
@c JP
 
261
���ꤵ�줿�إå��ե�����ȥ饤�֥����ɤ߹��ߡ��ؿ����������Х��ѿ����������������ޥ����򥫥��ȥ⥸�塼���������ޤ���
 
262
@code{c-load-library}��@code{c-include}����٤˹Ԥ���ΤǤ���
 
263
@c COMMON
 
264
 
 
265
@c EN
 
266
Keyword arguments are:
 
267
@c JP
 
268
keyword �����ˤϰʲ��Τ�Τ���ꤹ�뤳�Ȥ��Ǥ��ޤ���
 
269
@c COMMON
 
270
@table @code
 
271
@item :cflags
 
272
@itemx :cppflags
 
273
@itemx :ldflags
 
274
@itemx :libs
 
275
@c EN
 
276
Sets up flags for parsing header files and loading libraries, @code{:cppflags} is passed to the preprocessor and @code{:ldflags} and @code{:libs} are used for loading libraries. cwcompile uses these flags, too.
 
277
@c JP
 
278
�إå��ե�����Υѡ����ȥ饤�֥��Υ����ɤǻȤ�����γƼ�ե饰����ꤷ�ޤ���@code{:cppflags}�ϥץ�ץ����å����Ϥ��졢@code{:ldflags}, @code{:libs}�ϥ饤�֥��Υ����ɤǻ��Ѥ���ޤ��������Υե饰��cwcompile�Ǥ�Ȥ��ޤ���
 
279
@c COMMON
 
280
@item :cflags-cmd
 
281
@itemx :cppflags-cmd
 
282
@itemx :ldflags-cmd
 
283
@itemx :libs-cmd
 
284
@c EN
 
285
Sets up commands which returns the flags. For example, if you want to parse gtk's header file, you can do the following:
 
286
@c JP
 
287
�Ƽ�ե饰��������뤿��Υ��ޥ�ɤ���ꤷ�ޤ����㤨�С�gtk�Υإå��ե������ѡ�������Ȥ���pkg-config��Ȥäưʲ��Τ褦�˥��ץ�������ꤹ�뤳�Ȥ��Ǥ��ޤ���
 
288
@c COMMON
 
289
@example
 
290
(c-load "gtk/gtk/h"
 
291
        :cppflags-cmd "pkg-config gtk+-2.0 --cflags-only-I"
 
292
        :cflags-cmd   "pkg-config gtk+-2.0 --cflags-only-other"
 
293
        :libs-cmd     "pkg-config gtk+-2.0 --libs"
 
294
        :compiled-lib "gtklib")
 
295
@end example
 
296
 
 
297
@item :import
 
298
@c EN
 
299
Sets up symbols which you want to define. You can specify a symbol, a string, a regexp, a procedure or a list of them.
 
300
If you put a procedure, it is called with two arguments, a header file name and a symbol. When the procedure returns @code{#f}, the symbol is ignored, and the symbol is defined otherwise.
 
301
@c JP
 
302
�إå��ե����뤫���ɤ߹��ॷ��ܥ����ꤷ�ޤ���
 
303
�����Ȥ��ơ�����ܥ롢ʸ��������ɽ������³���ȡ������Υꥹ�Ȥ������ǽ�Ǥ���
 
304
��³�����Ϥ��줿���ϡ�����ܥ뤬���Ĥ��뤿�Ӥ˥إå��ե�����Υѥ�̾�ȥ���ܥ�̾������Ȥ��ơ����μ�³�����ƤӽФ���ޤ���
 
305
��³����@code{#f}���֤�����礽�Υ���ܥ��̵�뤵�졢����ʳ����ͤξ��˥���ܥ뤬�������ޤ���
 
306
@c COMMON
 
307
@item :export?
 
308
@c EN
 
309
Specifies whether symbols in header files are exported or not. If you put @code{#t}, the symbols are exported automatically, and otherwise they are not exported.
 
310
@c JP
 
311
�����������ܥ��@code{export}���뤫�ɤ�������ꤷ�ޤ���
 
312
@code{#t}�ξ��������������ܥ���Ф���ưŪ��@code{export}���¹Ԥ���ޤ���@code{#f}�ξ��ϲ��⤷�ޤ���
 
313
@c COMMON
 
314
@item :compiled-lib 
 
315
@c EN
 
316
Sets up a shared library file name which cwcompile command generates.
 
317
At runtime, if the library is exists, loads it instead of parsing the header files. Otherwise, parses the header files.
 
318
@c JP
 
319
cwcompile���ޥ�ɤˤ����������ѡ����Ѥߤζ�ͭ�饤�֥���̾������ꤷ�ޤ���
 
320
�����ǻ��ꤵ�줿��ͭ�饤�֥�꤬¸�ߤ����硢�إå��ե������ѡ�����������ˤ��ζ�ͭ�饤�֥����ɤ߹��ߤޤ�����ͭ�饤�֥�꤬¸�ߤ��ʤ����ϡ��إå��ե�����Υѡ������Ԥ��ޤ���
 
321
@c COMMON
 
322
@end table
 
323
 
 
324
@c COMMON
 
325
@end deffn
 
326
 
 
327
@node Classes and function about C types and values,  , Load a header file, c-wrapper
 
328
@comment  node-name,  next,  previous,  up
 
329
@section Classes and functions about C types
 
330
 
 
331
@deftp {Class} <c-type>
 
332
@c EN
 
333
This is a basic class for the classes related with C types.
 
334
@c JP
 
335
C�η����б��������饹�δ��쥯�饹�Ǥ���
 
336
@c COMMON
 
337
@end deftp
 
338
 
 
339
@deftp {Class} <c-type-meta>
 
340
@c EN
 
341
This is a meta class for the classes related with C types. All the classes are instances of @code{<c-type-meta>}.
 
342
@c JP
 
343
C�η����б��������饹�Υ᥿���饹�Ǥ���C�η��Υ��饹�Ϥ��٤� @code{<c-type-meta>} �Υ��󥹥��󥹤Ȥʤ�ޤ���
 
344
@c COMMON
 
345
@end deftp
 
346
 
 
347
@deftp {Class} <c-char>
 
348
@deftpx {Class} <c-uchar>
 
349
@deftpx {Class} <c-short>
 
350
@deftpx {Class} <c-ushort>
 
351
@deftpx {Class} <c-int>
 
352
@deftpx {Class} <c-uint>
 
353
@deftpx {Class} <c-long>
 
354
@deftpx {Class} <c-ulong>
 
355
@deftpx {Class} <c-longlong>
 
356
@deftpx {Class} <c-ulonglong>
 
357
@deftpx {Class} <c-float>
 
358
@deftpx {Class} <c-double>
 
359
@clindex c-char
 
360
@clindex c-uchar
 
361
@clindex c-short
 
362
@clindex c-ushort
 
363
@clindex c-int
 
364
@clindex c-uint
 
365
@clindex c-long
 
366
@clindex c-ulong
 
367
@clindex c-longlong
 
368
@clindex c-ulonglong
 
369
@clindex c-float
 
370
@clindex c-double
 
371
@c EN
 
372
These are classes for arithmetic types in C. you can use @code{make} to make an instance of the class.
 
373
@c JP
 
374
C����λ��ѷ� (Arithmetic types) ���б����륯�饹�Ǥ��� @code{make} ��Ȥäƥ��󥹥��󥹤�������뤳�Ȥ��Ǥ��ޤ���
 
375
@c COMMON
 
376
@end deftp
 
377
 
 
378
@deftp {Class} <c-value-meta>
 
379
@clindex c-value-meta
 
380
@c EN
 
381
This is a meta class for the classes related with C arithmetic types.
 
382
@c JP
 
383
C����λ��ѷ� (Arithmetic types) ���б����륯�饹�Υ᥿���饹�Ǥ���
 
384
@c COMMON
 
385
@end deftp
 
386
 
 
387
@deffn {Method} ref (obj <c-value-meta>)
 
388
@c EN
 
389
Returns the value of @var{obj}.
 
390
@c JP
 
391
@var{obj} ���ͤ��֤��ޤ���
 
392
@c COMMON
 
393
@end deffn
 
394
 
 
395
@deffn {Method} (setter ref) (obj <c-value-meta>) value
 
396
@c EN
 
397
Sets @var{value} to @var{obj}.
 
398
@c JP
 
399
@var{obj} ���� @var{value} �����ꤷ�ޤ���
 
400
@c COMMON
 
401
@end deffn
 
402
 
 
403
@deftp {Class} <c-void>
 
404
@c EN
 
405
This is a class for void type in C.
 
406
@c JP
 
407
C����� void �����б����륯�饹�Ǥ���
 
408
@c COMMON
 
409
@end deftp
 
410
 
 
411
@deftp {Class} <c-ptr>
 
412
@c EN
 
413
This is an abstract class for pointer type in C. If you use a pointer type, make a concrete class with @code{ptr}.
 
414
@c JP
 
415
C����Υݥ��󥿷����б�������ݥ��饹�Ǥ����ºݤ˥ݥ��󥿷�����Ѥ�����ϡ���Ҥ��� @code{ptr} ����Ѥ��� @code{<c-ptr>} �ζ�ݥ��饹���������ɬ�פ�����ޤ���
 
416
@c COMMON
 
417
@end deftp
 
418
 
 
419
@deffn {Method} ptr (class <c-type-meta>)
 
420
@c EN
 
421
Makes a class for a pointer type of @var{class}, and it is a subclass of @code{<c-ptr>}. You can use @code{make} to make an instance of the class.
 
422
@c JP
 
423
@var{class} �ǻ��ꤵ�줿���Υݥ��󥿷����б����륯�饹���������ޤ������Υ��饹�� @code{<c-ptr>} �Υ��֥��饹�Ȥʤ�ޤ���@code{make} ��Ȥäƺ����������饹�Υ��󥹥��󥹤�������뤳�Ȥ��Ǥ��ޤ���
 
424
@c COMMON
 
425
@end deffn
 
426
 
 
427
@deffn {Method} ptr (obj <c-type>) 
 
428
@c EN
 
429
Returns a pointer object for @var{obj}.
 
430
@c JP
 
431
@var{obj} �Υݥ��󥿥��֥������Ȥ��֤��ޤ���
 
432
@c COMMON
 
433
@end deffn
 
434
 
 
435
@deftp {Class} <c-array>
 
436
@c EN
 
437
This is an abstract class for array type in C. If you use an array type, make a concrete class with @code{c-array}.
 
438
 
 
439
@code{<c-array>} is a subclass of @code{<sequence>}, and you can use the operations of sequence framework (@code{gauche.sequence} module).
 
440
@c JP
 
441
C�����������б�������ݥ��饹�Ǥ����ºݤ��������Ѥ�����ϡ���Ҥ��� @code{c-array} ����Ѥ��ơ�@code{<c-array>} �ζ�ݥ��饹���������ɬ�פ�����ޤ���
 
442
 
 
443
�ޤ� @code{<c-array>} �� @code{<sequence>} ��Ѿ����Ƥ��ꡢ�������󥹥ե졼���� (@code{gauche.sequence} �⥸�塼��) ���������Ƥ���������Ѥ��뤳�Ȥ��Ǥ��ޤ���
 
444
@c COMMON
 
445
@end deftp
 
446
 
 
447
@defun c-array (class <c-type-meta>) size
 
448
@c EN
 
449
Makes a class for an array type of @var{class}, and it is a subclass of @code{<c-array>}. You can use @code{make} to make an instance of the class.
 
450
@c JP
 
451
@var{class} �����礭�� @var{size} �����󥯥饹���������ޤ������Υ��饹�� @code{<c-array>} �Υ��֥��饹�Ȥʤ�ޤ���@code{make} ��Ȥäƺ����������饹�Υ��󥹥��󥹤�������뤳�Ȥ��Ǥ��ޤ���
 
452
@c COMMON
 
453
@end defun
 
454
 
 
455
@deftp {Class} <c-struct>
 
456
@c EN
 
457
This is an abstract class for struct type in C. 
 
458
@c JP
 
459
C����ι�¤�Τ��б�������ݥ��饹�Ǥ���
 
460
@c COMMON
 
461
@end deftp
 
462
 
 
463
@deftp {Class} <c-union>
 
464
@c EN
 
465
This is an abstract class for union type in C. 
 
466
@c JP
 
467
C����ζ����Τ��б�������ݥ��饹�Ǥ���
 
468
@c COMMON
 
469
@end deftp
 
470
 
 
471
@deffn {Macro} c-struct tagname
 
472
@c EN
 
473
Returns the struct class named @var{tagname}.
 
474
@c JP
 
475
@var{tagname}�Ȥ���̾���ι�¤�Υ��饹���֤��ޤ���
 
476
@c COMMON
 
477
@end deffn
 
478
 
 
479
@deffn {Macro} c-union tagname
 
480
@c EN
 
481
Returns the union class named @var{tagname}.
 
482
@c JP
 
483
@var{tagname}�Ȥ���̾���ζ����Υ��饹���֤��ޤ���
 
484
@c COMMON
 
485
@end deffn
 
486
 
 
487
@deffn {Method} ref (obj <c-struct>) member
 
488
@deffnx {Method} ref (obj <c-union>) member
 
489
@c EN
 
490
Returns the value of the @var{member} of the struct or union @var{obj}. If the type of the member is arithmetic type, the type of the return value is casted to @code{<real>} or @code{<integer>}.
 
491
@c JP
 
492
��¤�Τ⤷���϶����ΤΥ��� @var{member} ���ͤ��֤��ޤ������Ф����ѷ� (Arithmetic types) �ξ��� @code{<real>} �⤷���� @code{<integer>} ���Ѵ����줿�ͤ��֤�ޤ���
 
493
@c COMMON
 
494
@end deffn
 
495
 
 
496
@deffn {Method} (setter ref) (obj <c-struct>) member value
 
497
@deffnx {Method} (setter ref) (obj <c-union>) member value
 
498
@c EN
 
499
Sets @var{value} to the @var{member} of the struct or union @var{obj}.
 
500
@c JP
 
501
��¤�Τ⤷���϶����ΤΥ��� @var{member} ���ͤ򥻥åȤ��ޤ���
 
502
@c COMMON
 
503
@end deffn
 
504
 
 
505
@deftp {Class} <c-func-ptr>
 
506
@c EN
 
507
This is an abstract class for function pointer in C.
 
508
@c JP
 
509
C����δؿ��ݥ��󥿤��б�������ݥ��饹�Ǥ���
 
510
@c COMMON
 
511
@end deftp
 
512
 
 
513
@deffn {Method} deref ptrobj
 
514
@c EN
 
515
Returns a deference object of @var{ptrobj}. ('*' operator in C)
 
516
@c JP
 
517
�ݥ��󥿥��֥������� @var{ptrobj} �λ��Ȥ��֤��ޤ���
 
518
@c COMMON
 
519
@end deffn
 
520
 
 
521
@deffn {Method} c-sizeof (class <c-type-meta>)
 
522
@deffnx {Method} c-sizeof (obj <c-type>)
 
523
@c EN
 
524
Returns a size of @var{class} or @var{obj}.
 
525
@c JP
 
526
@var{class}�⤷����@var{obj}�Υ��������֤��ޤ���
 
527
@c COMMON
 
528
@end deffn
 
529
 
 
530
@deffn {Method} cast class obj
 
531
@c EN
 
532
Makes an instance of @var{class} from @var{obj}. The following rules are applied to make an instance.
 
533
 
 
534
@multitable @columnfractions 0.2 0.2 0.6
 
535
@item @var{class} @tab Type of @var{obj} @tab Description
 
536
 
 
537
@item Subclasses of @code{<c-value>}
 
538
@tab @code{<real>}
 
539
@tab Makes an instance of @var{class} which is the same value of @var{obj}.
 
540
 
 
541
@item Subclasses of @code{<c-value>}
 
542
@tab @code{<boolean>}
 
543
@tab Makes an instance of @var{class} which is 1 (if @var{obj} is @code{#t}) or 0 (if @var{obj} is @code{#f}).
 
544
 
 
545
@item @code{<c-ptr>} or @code{<c-func-ptr>}
 
546
@tab @code{<integer>}
 
547
@tab Makes a pointer object whose address is @var{obj}.
 
548
 
 
549
@item @code{<c-ptr>} or @code{<c-func-ptr>}
 
550
@tab @code{<c-ptr>} or @code{<c-func-ptr>}
 
551
@tab Makes a pointer object whose address is the same of @var{obj}.
 
552
 
 
553
@item @code{<c-ptr>} or @code{<c-func-ptr>}
 
554
@tab @code{<c-array>}
 
555
@tab Makes a pointer object whose address is the same of the first address of @var{obj}.
 
556
 
 
557
@item @code{<c-ptr>}
 
558
@tab @code{<string>}
 
559
@tab Makes a pointer object whose address points an internally-generated C string.
 
560
 
 
561
@item @code{<c-ptr>}
 
562
@tab @code{<uvector>}
 
563
@tab Makes a pointer object whose address points the buffer of @code{<uvector>}.
 
564
 
 
565
@item @code{<c-ptr>}
 
566
@tab @code{<sequence>}
 
567
@tab Makes a pointer object whost address points an internally-generated array which contains the same elements of @var{obj}.
 
568
 
 
569
@item @code{<c-array>}
 
570
@tab @code{<sequence>}
 
571
@tab Makes an array which contains the same elements of @var{obj}.
 
572
 
 
573
@item @code{<c-array>}
 
574
@tab @code{<c-ptr>}
 
575
@tab Makes an array object whose first address is @var{obj}.
 
576
 
 
577
@item @code{<c-func-ptr>}
 
578
@tab @code{<procedure>}
 
579
@tab Makes a pointer of a function which executes calls the procedure @var{obj}.
 
580
 
 
581
@item @code{<integer>} or @code{<real>}
 
582
@tab @code{<c-value>}
 
583
@tab Makes the value of @var{obj}.
 
584
 
 
585
@item @code{<boolean>}
 
586
@tab @code{<c-value>} or @code{<real>}
 
587
@tab Makes #f if the value of @var{obj} is 0, #t otherwise.
 
588
 
 
589
@item @code{<integer>}
 
590
@tab @code{<c-ptr>} or @code{<c-func-ptr>}
 
591
@tab Makes the pointer address of @var{obj}.
 
592
 
 
593
@item @code{<integer>}
 
594
@tab @code{<c-array>}
 
595
@tab Makes the first address of the array @var{obj}.
 
596
 
 
597
@item @code{<string>}
 
598
@tab @code{<c-ptr>} or @code{<c-func-ptr>}
 
599
@tab Makes a string from the address of @var{obj}. 
 
600
 
 
601
@item @code{<string>}
 
602
@tab @code{<c-array>}
 
603
@tab Makes a string from the array @var{obj}. It must be 0 terminated string.
 
604
 
 
605
@item @code{<collection>}
 
606
@tab @code{<c-array>}
 
607
@tab Makes an instance of @var{class} which contains the same values of @var{obj}, which are casted with @code{scm-cast}. 
 
608
@end multitable
 
609
 
 
610
@c JP
 
611
@var{obj} ���� @var{class} ���Υ��󥹥��󥹤��������ޤ��������Υ롼��ϰʲ����̤�Ǥ���
 
612
 
 
613
@multitable @columnfractions 0.2 0.2 0.6
 
614
@item @var{class} @tab @var{obj}�η� @tab ����
 
615
 
 
616
@item @code{<c-value>} ��Ѿ��������饹
 
617
@tab @code{<real>}
 
618
@tab @var{obj} ��Ʊ���ͤ���� @var{class} �Υ��󥹥��󥹤��������ޤ�
 
619
 
 
620
@item @code{<c-value>} ��Ѿ��������饹
 
621
@tab @code{<boolean>}
 
622
@tab @var{obj} �� @code{#t} �λ��� 1��@code{#f} �λ��� 0 ���ͤ���� @var{class} �Υ��󥹥��󥹤��������ޤ���
 
623
 
 
624
@item @code{<c-ptr>} �ޤ��� @code{<c-func-ptr>}
 
625
@tab @code{<integer>}
 
626
@tab @var{obj} �Υ��ɥ쥹����ĥݥ��󥿤��������ޤ�
 
627
 
 
628
@item @code{<c-ptr>} �ޤ��� @code{<c-func-ptr>}
 
629
@tab @code{<c-ptr>} �ޤ��� @code{<c-func-ptr>}
 
630
@tab @var{obj} ��Ʊ�����ɥ쥹����ĥݥ��󥿤��������ޤ�
 
631
 
 
632
@item @code{<c-ptr>} �ޤ��� @code{<c-func-ptr>}
 
633
@tab @code{<c-array>}
 
634
@tab @var{obj} ����Ƭ���ɥ쥹����ĥݥ��󥿤��������ޤ���
 
635
 
 
636
@item @code{<c-ptr>}
 
637
@tab @code{<string>}
 
638
@tab C��ʸ�������������������Ƭ���ɥ쥹����ĥݥ��󥿤��������ޤ���
 
639
 
 
640
@item @code{<c-ptr>}
 
641
@tab @code{<uvector>}
 
642
@tab @var{obj} ����Ƭ���ɥ쥹����ĥݥ��󥿤��������ޤ���
 
643
 
 
644
@item @code{<c-ptr>}
 
645
@tab @code{<sequence>}
 
646
@tab @var{obj} ��Ʊ�����Ƥ��������������������Ƭ���ɥ쥹����ĥݥ��󥿤��������ޤ���
 
647
 
 
648
@item @code{<c-array>}
 
649
@tab @code{<sequence>}
 
650
@tab @var{obj} ��Ʊ�����Ƥ�������������ޤ���
 
651
 
 
652
@item @code{<c-array>}
 
653
@tab @code{<c-ptr>}
 
654
@tab �ݥ��󥿤��ؤ������ΰ������ȸ��ʤ��� @var{class} �Υ��󥹥��󥹤��������ޤ���
 
655
 
 
656
@item @code{<c-func-ptr>}
 
657
@tab @code{<procedure>}
 
658
@tab @var{obj} ��¹Ԥ���ؿ��Υݥ��󥿤��������ޤ���
 
659
 
 
660
@item @code{<integer>} �ޤ��� @code{<real>}
 
661
@tab @code{<c-value>}
 
662
@tab @var{obj} ��Ʊ���ͤο��ͤ��֤��ޤ���
 
663
 
 
664
@item @code{<boolean>}
 
665
@tab @code{<c-value>} �ޤ��� @code{<real>}
 
666
@tab �ͤ� 0 �ΤȤ� @code{#f} ���������Ǥʤ���� @var{#t} ���֤�ޤ���
 
667
 
 
668
@item @code{<integer>}
 
669
@tab @code{<c-ptr>} �ޤ��� @code{<c-func-ptr>}
 
670
@tab �ݥ��󥿤Υ��ɥ쥹���֤�ޤ���
 
671
 
 
672
@item @code{<integer>}
 
673
@tab @code{<c-array>}
 
674
@tab �������Ƭ���ɥ쥹���֤�ޤ���
 
675
 
 
676
@item @code{<string>}
 
677
@tab @code{<c-ptr>} �ޤ��� @code{<c-func-ptr>}
 
678
@tab �ݥ��󥿤��ؤ������ΰ褬0��ü���줿ʸ����ȸ��ʤ���ʸ������������ޤ���
 
679
 
 
680
@item @code{<string>}
 
681
@tab @code{<c-array>}
 
682
@tab ��������Ƥ�0��ü���줿ʸ����ȸ��ʤ���ʸ������������ޤ���
 
683
 
 
684
@item @code{<collection>}
 
685
@tab @code{<c-array>}
 
686
@tab ��������Ƥ���� @var{class} �Υ��󥹥��󥹤��������ޤ��������Ǥ��ͤ� @code{scm-cast} �ǥ��㥹�Ȥ���ޤ���
 
687
@end multitable
 
688
 
 
689
@c COMMON
 
690
@end deffn
 
691
 
 
692
@defun scm-cast obj
 
693
@c EN
 
694
Returns the value of @var{obj} if @var{obj} is an instance of @code{<c-value>}. Otherwise, returns @var{obj}.
 
695
@c JP
 
696
@var{obj} �� @code{<c-value>} ���Ǥ�����Ͽ��ͤ��֤��ޤ��������Ǥʤ���� @var{obj} �򤽤Τޤ��֤��ޤ���
 
697
@c COMMON
 
698
@end defun
 
699
 
 
700
@defun make-null-ptr
 
701
@c EN
 
702
Returns NULL pointer.
 
703
@c JP
 
704
NULL�ݥ��󥿤��֤��ޤ���
 
705
@c COMMON
 
706
@end defun
 
707
 
 
708
@defun null-ptr? obj
 
709
@c EN
 
710
Returns @code{#t} if @var{obj} is a NULL pointer, @code{#f} otherwise.
 
711
@c JP
 
712
@var{obj} ��NULL�ݥ��󥿤Ǥ���� @code{#t} ���������Ǥʤ���� @code{#f} ���֤���ޤ���
 
713
@c COMMON
 
714
@end defun
 
715
 
 
716
@defun register-finalizer! ptrobj proc
 
717
@c EN
 
718
Register the finalizer @var{proc} to @var{ptrobj}. It is called when @var{ptrobj} is GCed.
 
719
@c JP
 
720
@var{ptrobj} �˥ե����ʥ饤�� @var{proc} ����Ͽ���ޤ���@var{ptrobj} ��GC�����Ȥ��� @var{proc} ���ƤФ�ޤ���
 
721
@c COMMON
 
722
@end defun
 
723
 
 
724
@defun unregister-finalizer! ptrobj
 
725
@c EN
 
726
Deletes the finalizer of @var{ptrobj}.
 
727
@c JP
 
728
@var{ptrobj} �Υե����ʥ饤���������ޤ���
 
729
@c COMMON
 
730
@end defun
 
731
 
 
732
@defun finalize! ptrobj
 
733
@c EN
 
734
Calls the finalizer of @var{ptrobj}, and deletes it from @var{ptrobj}.
 
735
@c JP
 
736
@var{ptrobj} �Υե����ʥ饤����¹Ԥ��ޤ�������ˤ�� @var{ptrobj} �Υե����ʥ饤���Ϻ������ޤ���
 
737
@c COMMON
 
738
@end defun
 
739
 
 
740
@node objc-wrapper, Function and Syntax Index, c-wrapper, Top
 
741
@comment  node-name,  next,  previous,  up
 
742
@chapter objc-wrapper
 
743
 
 
744
@c EN
 
745
@code{objc-wrapper} is the module which enables to use Objective-C libraries.
 
746
@c JP
 
747
@code{objc-wrapper} �Ȥ� Objective-C �Υ饤�֥��� Gauche ����Ȥ���褦�ˤ��뤿��Υ⥸�塼��Ǥ���
 
748
@c COMMON
 
749
 
 
750
@menu
 
751
* Load a framework library::    
 
752
* Load an Objectice-C header file::  
 
753
* Functions about Objective-C objects::  
 
754
@end menu
 
755
 
 
756
@node Load a framework library, Load an Objectice-C header file, objc-wrapper, objc-wrapper
 
757
@comment  node-name,  next,  previous,  up
 
758
@section Load a framework library
 
759
 
 
760
@defun c-load-framework framework
 
761
@c EN
 
762
Load a framework library @var{framework}.
 
763
 
 
764
@example
 
765
(c-load-framework "Foundation")
 
766
@end example
 
767
 
 
768
@c JP
 
769
�ե졼�����饤�֥�� @var{framework} ���ɤ߹��ߤޤ���
 
770
 
 
771
@example
 
772
(c-load-framework "Foundation")
 
773
@end example
 
774
 
 
775
@c COMMON
 
776
@end defun
 
777
 
 
778
@node Load an Objectice-C header file, Functions about Objective-C objects, Load a framework library, objc-wrapper
 
779
@comment  node-name,  next,  previous,  up
 
780
@section Load an Objective-C header file
 
781
 
 
782
@defun {Macro} c-include file-or-list &keyword
 
783
@c EN
 
784
This extends the @code{c-include} in @code{c-wrapper} module. it defines classes and methods of Objective-C code.
 
785
 
 
786
If Objective-C class @code{Foo} is defined in the header file, @code{c-include} defines two symbols @code{Foo} and @code{<Foo>}. @code{Foo} is an instance of @code{<c-struct:objc_object>} and indicates the Objective-C class @code{Foo}. @code{<Foo>} is an alias of the type @code{<id>}.
 
787
@c JP
 
788
@code{objc-wrapper} �⥸�塼��� @code{c-include} �Ǥ� Objective-C �Υ��饹�����᥽�å�����γ�ĥ���Ԥ��Ƥ��ޤ���
 
789
 
 
790
Objective-C �Υ��饹 @code{Foo} ���إå��ե�������������Ƥ�����硢 @code{Foo} �� @code{<Foo>} ��2�ĤΥ���ܥ뤬�������ޤ���@code{Foo} �� @code{<c-struct:objc_objcect>} ���Υ��֥������Ȥǥ��饹 @code{Foo} ���Τ�Τ�ؤ��Ƥ��ޤ���@code{<Foo>} �� @code{<id>} �Υ����ꥢ���Ȥʤ�ޤ���
 
791
@c COMMON
 
792
@end defun
 
793
 
 
794
@node Functions about Objective-C objects,  , Load an Objectice-C header file, objc-wrapper
 
795
@comment  node-name,  next,  previous,  up
 
796
@section Functions about Objective-C objects
 
797
 
 
798
@deffn {Macro} define-objc-class class-name super-class-name
 
799
@c EN
 
800
Defines Objective-C class @var{class-name} whose super class is @var{super-class-name}.
 
801
@c JP
 
802
@var{super-class-name}��Ѿ�����Objective-C�Υ��饹@var{class-name}��������ޤ���
 
803
@c COMMON
 
804
@end deffn
 
805
 
 
806
@deffn {Macro} define-objc-method objc-class ret-type (message-keyword varspec ...) body ...
 
807
@c EN
 
808
Defines an Objective-C method whose message keyword is @var{message-keyword} and return type is @var{ret-type}. @var{varspec} is a list, (variable-name variable-type).
 
809
 
 
810
In the body, you can use two variables @var{self} and @var{super}. @var{self} is the receiver object and @var{super} is the object which is casted to its super class.
 
811
@c JP
 
812
��å�����������ɤ�@var{message-keyword}�Ǥ�������ͤη���@var{ret-type}�Ǥ���褦��@var{objc-class}�Υ᥽�åɤ�������ޤ���@var{varspec}��(�ѿ�̾ �ѿ���)�Υꥹ�Ȥ���ꤷ�ޤ���
 
813
 
 
814
@var{body}�Ǥ�@var{self}��@var{super}��2�Ĥ��ѿ����Ȥ��ޤ������줾�졢�쥷���Х��֥������ȡ��쥷���Ф򥹡��ѥ��饹�˥��㥹�Ȥ������֥������Ȥ�ؤ��Ƥ��ޤ���
 
815
@c COMMON
 
816
 
 
817
@example
 
818
(define-objc-method MyFooClass <id> [:doSomething (v <c-int>)]
 
819
  [super :doSomething v]
 
820
  [self :foo v]
 
821
  (bar v) ;; The result of (bar v) is the return value of this method.
 
822
  )
 
823
@end example
 
824
@end deffn
 
825
 
 
826
@deffn {Method} object-apply (obj <c-struct:objc_object>) selector-or-args ...
 
827
@c EN
 
828
Calls the method of @var{obj}.
 
829
 
 
830
@example
 
831
[[NSString :alloc) :init]
 
832
 
 
833
[[NSString :startWithCString (@ "Hello, world") :encoding NSASCIIStringEncoding]]
 
834
@end example
 
835
 
 
836
@c JP
 
837
@var{obj} �Υ᥽�åɤ�ƤӽФ��ޤ���
 
838
 
 
839
@example
 
840
[[NSString :alloc] :init]
 
841
 
 
842
[[NSString :startWithCString (@ "Hello, world") :encoding NSASCIIStringEncoding]]
 
843
@end example
 
844
@c COMMON
 
845
@end deffn
 
846
 
 
847
@defun @@ str
 
848
@c EN
 
849
Returns Objective-C string.
 
850
@c JP
 
851
Objective-Cʸ������֤��ޤ���
 
852
@c COMMON
 
853
@end defun
 
854
 
 
855
@defun @@selector method-name
 
856
@c EN
 
857
Returns a selector of @var{method-name}.
 
858
@c JP
 
859
�᥽�å�̾ @var{method-name} �Υ��쥯�����֤��ޤ���
 
860
@c COMMON
 
861
@end defun
 
862
 
 
863
@node Function and Syntax Index, Class Index, objc-wrapper, Top
 
864
@comment  node-name,  next,  previous,  up
 
865
@appendix Function and Syntax Index
 
866
@printindex fn
 
867
 
 
868
@node Class Index, Variable Index, Function and Syntax Index, Top
 
869
@comment  node-name,  next,  previous,  up
 
870
@appendix Class Index
 
871
For readability, the surrounding @code{<} and @code{>} are stripped off.
 
872
@printindex cl
 
873
 
 
874
@node Variable Index,  , Class Index, Top
 
875
@comment  node-name,  next,  previous,  up
 
876
@appendix Variable Index
 
877
@printindex vr
 
878
 
 
879
@contents
 
880
@bye
 
881
 
 
882
@c Local variables:
 
883
@c outline-regexp: "@chap\\|@unnu\\|@\\(sub\\)*section"
 
884
@c end: