1"======================================================================
2|
3|   CCallbackDescriptor Method Definitions
4|
5|
6 ======================================================================"
7
8"======================================================================
9|
10| Copyright 2008, 2009 Free Software Foundation, Inc.
11| Written by Paolo Bonzini.
12|
13| This file is part of the GNU Smalltalk class library.
14|
15| The GNU Smalltalk class library is free software; you can redistribute it
16| and/or modify it under the terms of the GNU Lesser General Public License
17| as published by the Free Software Foundation; either version 2.1, or (at
18| your option) any later version.
19|
20| The GNU Smalltalk class library is distributed in the hope that it will be
21| useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
22| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
23| General Public License for more details.
24|
25| You should have received a copy of the GNU Lesser General Public License
26| along with the GNU Smalltalk class library; see the file COPYING.LIB.
27| If not, write to the Free Software Foundation, 59 Temple Place - Suite
28| 330, Boston, MA 02110-1301, USA.
29|
30 ======================================================================"
31
32
33
34CCallable subclass: CCallbackDescriptor [
35    | block |
36
37    <shape: #inherit>
38    <category: 'Language-C interface'>
39    <comment: 'I am not part of the Smalltalk definition.  My instances are
40able to convert blocks into C functions that can be passed to C.'>
41
42    CCallbackDescriptor class >> for: aBlock returning: returnTypeSymbol withArgs: argsArray [
43	"Answer a CCallbackDescriptor with the given block, return type and
44	 arguments."
45
46	<category: 'instance creation'>
47	^(super for: nil returning: returnTypeSymbol withArgs: argsArray)
48	    block: aBlock;
49	    link;
50	    yourself
51    ]
52
53    block [
54	"Answer the block of the function represented by the receiver."
55
56	<category: 'accessing'>
57	^block
58    ]
59
60    block: aBlock [
61	"Set the block of the function represented by the receiver."
62
63	<category: 'accessing'>
64	block := aBlock
65    ]
66
67    link [
68	"Make the address of the function point to the registered address."
69
70	<category: 'restoring'>
71	<primitive: VMpr_CCallbackDescriptor_link>
72
73	"Always executed."
74	self addToBeFinalized
75    ]
76]
77