author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Thu, 17 Sep 2015 07:36:40 +0100 | |
changeset 49 | 307d55f736ec |
parent 42 | a428eeead6ad |
permissions | -rw-r--r-- |
32
d7464405cbda
Package renamed from cvut:fel/cface to jv:cface
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
24
diff
changeset
|
1 |
"{ Package: 'jv:cface' }" |
1 | 2 |
|
3 |
"{ NameSpace: Cface }" |
|
4 |
||
39
5ff8fcdb5228
Added support for generating classes for typedef'd types.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
5 |
CDerivedTypeNode subclass:#CTypedefNode |
5ff8fcdb5228
Added support for generating classes for typedef'd types.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
6 |
instanceVariableNames:'type' |
42
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
7 |
classVariableNames:'C99IntTypes2FFITypes' |
1 | 8 |
poolDictionaries:'' |
9 |
category:'Cface-C AST' |
|
10 |
! |
|
11 |
||
12 |
!CTypedefNode class methodsFor:'documentation'! |
|
13 |
||
14 |
history |
|
15 |
||
16 |
"Created: / 25-10-2007 / 15:07:10 / haja" |
|
17 |
"Created: #local / 25-10-2007 / 15:07:18 / haja" |
|
18 |
"Created: #local: / 25-10-2007 / 15:07:18 / haja" |
|
19 |
"Created: #names / 25-10-2007 / 15:07:18 / haja" |
|
20 |
"Created: #names: / 25-10-2007 / 15:07:18 / haja" |
|
21 |
"Created: #local:names: / 25-10-2007 / 15:08:27 / haja" |
|
22 |
"Deleted: #local / 29-10-2007 / 19:58:35 / haja" |
|
23 |
"Deleted: #local: / 29-10-2007 / 19:58:35 / haja" |
|
24 |
"Deleted: #names / 29-10-2007 / 19:58:35 / haja" |
|
25 |
"Deleted: #names: / 29-10-2007 / 19:58:35 / haja" |
|
26 |
"Created: #name / 29-10-2007 / 19:58:43 / haja" |
|
27 |
"Created: #name: / 29-10-2007 / 19:58:43 / haja" |
|
28 |
"Created: #id / 29-10-2007 / 19:58:43 / haja" |
|
29 |
"Created: #id: / 29-10-2007 / 19:58:43 / haja" |
|
30 |
"Created: #name:id: / 29-10-2007 / 19:59:29 / haja" |
|
31 |
"Deleted: #local:names: / 29-10-2007 / 19:59:43 / haja" |
|
32 |
"Created: #acceptVisitor: / 02-11-2007 / 10:46:04 / haja" |
|
33 |
"Created: #foreign / 19-11-2007 / 09:41:32 / haja" |
|
34 |
"Created: #foreign: / 19-11-2007 / 09:41:32 / haja" |
|
35 |
"Created: #name:id:foreign: / 19-11-2007 / 09:41:41 / haja" |
|
36 |
"Deleted: #name:id: / 19-11-2007 / 09:41:43 / haja" |
|
37 |
! ! |
|
38 |
||
42
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
39 |
!CTypedefNode class methodsFor:'initialization'! |
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
40 |
|
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
41 |
initialize |
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
42 |
"Invoked at system start or when the class is dynamically loaded." |
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
43 |
|
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
44 |
"/ please change as required (and remove this comment) |
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
45 |
|
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
46 |
C99IntTypes2FFITypes := Dictionary withKeysAndValues:#( |
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
47 |
int8_t sint8 |
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
48 |
int16_t sint16 |
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
49 |
int32_t sint32 |
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
50 |
int64_t sint64 |
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
51 |
|
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
52 |
uint8_t uint8 |
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
53 |
uint16_t uint16 |
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
54 |
uint32_t uint32 |
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
55 |
uint64_t uint64 |
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
56 |
) |
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
57 |
|
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
58 |
"Modified: / 12-08-2015 / 07:38:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
59 |
! ! |
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
60 |
|
1 | 61 |
!CTypedefNode methodsFor:'accessing'! |
62 |
||
5
c110eef5b9ef
- externalization of libraryName (now supports unix & win32 simultaneously)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
63 |
cByteSize |
c110eef5b9ef
- externalization of libraryName (now supports unix & win32 simultaneously)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
64 |
|
c110eef5b9ef
- externalization of libraryName (now supports unix & win32 simultaneously)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
65 |
^type cByteSize |
c110eef5b9ef
- externalization of libraryName (now supports unix & win32 simultaneously)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
66 |
|
c110eef5b9ef
- externalization of libraryName (now supports unix & win32 simultaneously)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
67 |
"Created: / 09-07-2008 / 19:39:38 / Jan Vrany <vranyj1@fel.cvut.cz>" |
c110eef5b9ef
- externalization of libraryName (now supports unix & win32 simultaneously)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
68 |
! |
c110eef5b9ef
- externalization of libraryName (now supports unix & win32 simultaneously)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2
diff
changeset
|
69 |
|
2
cfd2c393abfe
Smalltalk/X generator improvements:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
70 |
ffiTypeSymbol |
42
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
71 |
C99IntTypes2FFITypes at: cName ifPresent:[ :ffiType | ^ ffiType ]. |
41
edb5e4849b79
Type resolving reintroduced again.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
72 |
type isCPointerToCStructure ifTrue:[ |
edb5e4849b79
Type resolving reintroduced again.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
73 |
^ self smalltalkClassName ? #pointer |
edb5e4849b79
Type resolving reintroduced again.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
74 |
]. |
edb5e4849b79
Type resolving reintroduced again.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
75 |
^ type ffiTypeSymbol |
2
cfd2c393abfe
Smalltalk/X generator improvements:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
76 |
|
cfd2c393abfe
Smalltalk/X generator improvements:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
77 |
"Created: / 03-07-2008 / 22:40:25 / Jan Vrany <vranyj1@fel.cvut.cz>" |
42
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
78 |
"Modified: / 12-08-2015 / 07:39:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2
cfd2c393abfe
Smalltalk/X generator improvements:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
79 |
! |
cfd2c393abfe
Smalltalk/X generator improvements:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
80 |
|
1 | 81 |
type |
82 |
^ type |
|
83 |
||
84 |
"Created: / 10-02-2008 / 19:23:13 / janfrog" |
|
85 |
! |
|
86 |
||
87 |
type:something |
|
88 |
type := something. |
|
89 |
||
90 |
"Created: / 10-02-2008 / 19:23:13 / janfrog" |
|
91 |
! ! |
|
92 |
||
93 |
!CTypedefNode methodsFor:'printing'! |
|
94 |
||
95 |
printOn: stream indent: level |
|
96 |
||
6
ae25dce94003
Added SVNMapping. Now it is able to parse libsvn.def
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5
diff
changeset
|
97 |
self printLineOn: stream indent: level. |
1 | 98 |
stream |
99 |
nextPutAll: '(typedef '; cr; |
|
100 |
next: level + 1 put: Character tab; nextPutAll: cName; cr; |
|
101 |
next: level + 1 put: Character tab. |
|
102 |
type printOn: stream indent: level + 1. |
|
103 |
stream nextPut: $) |
|
104 |
||
105 |
"Created: / 17-02-2008 / 18:13:13 / janfrog" |
|
106 |
"Modified: / 18-02-2008 / 15:12:01 / janfrog" |
|
6
ae25dce94003
Added SVNMapping. Now it is able to parse libsvn.def
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5
diff
changeset
|
107 |
"Modified: / 10-07-2008 / 20:05:26 / Jan Vrany <vranyj1@fel.cvut.cz>" |
1 | 108 |
! ! |
109 |
||
24 | 110 |
!CTypedefNode methodsFor:'testing'! |
111 |
||
112 |
isForeign |
|
113 |
||
114 |
^foreign ? false |
|
115 |
||
116 |
"Created: / 04-07-2008 / 11:46:39 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
117 |
! ! |
|
118 |
||
1 | 119 |
!CTypedefNode methodsFor:'visiting'! |
120 |
||
121 |
acceptVisitor:aVisitor |
|
122 |
"Double dispatch back to the visitor, passing my type encoded in |
|
123 |
the selector (visitor pattern)" |
|
124 |
"stub code automatically generated - please change if required" |
|
125 |
||
126 |
^ aVisitor visitCTypedefNode:self |
|
127 |
||
128 |
"Created: / 02-11-2007 / 10:46:04 / haja" |
|
129 |
"Modified: / 10-02-2008 / 10:45:50 / janfrog" |
|
130 |
! ! |
|
131 |
||
132 |
!CTypedefNode class methodsFor:'documentation'! |
|
133 |
||
134 |
version |
|
19
1297bf936bfb
Some fixes for modern GCC XML
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14
diff
changeset
|
135 |
^ '$Id$' |
14 | 136 |
! |
137 |
||
138 |
version_SVN |
|
139 |
^ '$Id$' |
|
1 | 140 |
! ! |
39
5ff8fcdb5228
Added support for generating classes for typedef'd types.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
141 |
|
42
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
142 |
|
a428eeead6ad
64bit fixes: for C99 fixed-width int types, generate proper fixed-width FFI types. For int and longs generate generic, machine-dependent FFI types
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
143 |
CTypedefNode initialize! |