1
|
1 |
"{ Package: 'cvut:fel/cface' }"
|
|
2 |
|
|
3 |
"{ NameSpace: Cface }"
|
|
4 |
|
|
5 |
Object subclass:#TypeMapping
|
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'Cface-Mappings'
|
|
10 |
!
|
|
11 |
|
|
12 |
|
|
13 |
!TypeMapping methodsFor:'accessing'!
|
|
14 |
|
|
15 |
smalltalkClassForEnum:cEnum
|
|
16 |
^ self smalltalkClassForType:cEnum
|
|
17 |
|
|
18 |
"Answers class which should contain function call"
|
|
19 |
|
|
20 |
"Created: / 17-02-2008 / 20:52:00 / janfrog"
|
|
21 |
!
|
|
22 |
|
|
23 |
smalltalkClassForEnumValue:cEnumField
|
|
24 |
^ self smalltalkClassForType:cEnumField
|
|
25 |
|
|
26 |
"Answers class which should contain function call"
|
|
27 |
|
|
28 |
"Created: / 17-02-2008 / 20:52:26 / janfrog"
|
|
29 |
!
|
|
30 |
|
|
31 |
smalltalkClassForFunction:cFunction
|
|
32 |
|
|
33 |
|firstArgType|
|
|
34 |
|
|
35 |
cFunction arguments isEmpty ifTrue:[^nil].
|
|
36 |
firstArgType := cFunction arguments first type.
|
|
37 |
^(firstArgType isCPointerNode and:[firstArgType type isCStructNode])
|
|
38 |
ifTrue:[firstArgType type smalltalkClass]
|
|
39 |
ifFalse:[nil]
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
"Answers class which should contain function call"
|
|
46 |
|
|
47 |
"Created: / 17-02-2008 / 22:15:09 / janfrog"
|
|
48 |
!
|
|
49 |
|
|
50 |
smalltalkClassForStruct:cStruct
|
|
51 |
^ self smalltalkClassForType:cStruct
|
|
52 |
|
|
53 |
"Answers class which should contain function call"
|
|
54 |
|
|
55 |
"Created: / 17-02-2008 / 20:52:37 / janfrog"
|
|
56 |
!
|
|
57 |
|
|
58 |
smalltalkClassForType:cType
|
|
59 |
^ self smalltalkize: cType cName
|
|
60 |
|
|
61 |
"Created: / 17-02-2008 / 20:52:54 / janfrog"
|
|
62 |
!
|
|
63 |
|
|
64 |
smalltalkNameForStructField:cStructField
|
|
65 |
^ self smalltalkize: cStructField cName
|
|
66 |
|
|
67 |
"Created: / 17-02-2008 / 21:22:15 / janfrog"
|
|
68 |
!
|
|
69 |
|
|
70 |
smalltalkNamespace
|
|
71 |
|
|
72 |
^#Smalltalk
|
|
73 |
|
|
74 |
"Created: / 17-02-2008 / 20:51:05 / janfrog"
|
|
75 |
!
|
|
76 |
|
|
77 |
smalltalkSelectorForFunction:cFunction
|
|
78 |
|
|
79 |
^self smalltalkize: cFunction cName
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
"Answers class which should contain function call"
|
|
85 |
|
|
86 |
"Created: / 17-02-2008 / 22:15:44 / janfrog"
|
|
87 |
! !
|
|
88 |
|
|
89 |
!TypeMapping methodsFor:'private - utilities'!
|
|
90 |
|
|
91 |
smalltalkize: input
|
|
92 |
|
|
93 |
| inputStream outputStream |
|
|
94 |
inputStream := input readStream.
|
|
95 |
outputStream := (String new:input size) writeStream.
|
|
96 |
[ inputStream atEnd ] whileFalse:
|
|
97 |
[|c|
|
|
98 |
c := inputStream next.
|
|
99 |
c = $_
|
|
100 |
ifTrue:[outputStream nextPut: inputStream next asUppercase]
|
|
101 |
ifFalse:[outputStream nextPut: c]].
|
|
102 |
^outputStream contents.
|
|
103 |
|
|
104 |
"
|
|
105 |
Cface::Mappings new smalltalkize:'test'
|
|
106 |
Cface::Mappings new smalltalkize:'test_of_smalltalkize'
|
|
107 |
"
|
|
108 |
|
|
109 |
"Created: / 08-02-2008 / 09:34:40 / janfrog"
|
|
110 |
! !
|
|
111 |
|
|
112 |
!TypeMapping class methodsFor:'documentation'!
|
|
113 |
|
|
114 |
version
|
|
115 |
^ '$Header: /opt/data/cvs/cvut-fel/cface/Cface__TypeMapping.st,v 1.1 2008/02/26 16:00:36 vranyj1 Exp $'
|
|
116 |
! !
|