"{ Package: 'cvut:fel/cface' }"
"{ NameSpace: Cface }"
Object subclass:#TypeMapping
instanceVariableNames:'smalltalkPackage'
classVariableNames:''
poolDictionaries:''
category:'Cface-Mappings'
!
!TypeMapping methodsFor:'accessing'!
kindForFunction:cFunction
|firstArgType|
cFunction arguments isEmpty ifTrue:[^#static].
firstArgType := cFunction arguments first type.
^(firstArgType isCPointerNode and:[firstArgType type isCStructNode])
ifTrue:[#method]
ifFalse:[#static]
"Answers class which should contain function call"
"Created: / 03-07-2008 / 22:09:41 / Jan Vrany <vranyj1@fel.cvut.cz>"
!
smalltalkClassForEnum:cEnum
^ self smalltalkClassForType:cEnum
"Answers class which should contain function call"
"Created: / 17-02-2008 / 20:52:00 / janfrog"
!
smalltalkClassForFunction:cFunction
|firstArgType|
cFunction arguments isEmpty ifTrue:[^nil].
firstArgType := cFunction arguments first type.
^(firstArgType isCPointerNode and:[firstArgType type isCStructNode])
ifTrue:[firstArgType type smalltalkClass]
ifFalse:[nil]
"Answers class which should contain function call"
"Created: / 17-02-2008 / 22:15:09 / janfrog"
!
smalltalkClassForStruct:cStruct
^ self smalltalkClassForType:cStruct
"Answers class which should contain function call"
"Created: / 17-02-2008 / 20:52:37 / janfrog"
!
smalltalkClassForType:cType
^ self smalltalkize: cType cName
"Created: / 17-02-2008 / 20:52:54 / janfrog"
!
smalltalkNameForEnumValue:cEnumField
^ self smalltalkClassForType:cEnumField
"Answers class which should contain function call"
"Created: / 04-07-2008 / 11:32:01 / Jan Vrany <vranyj1@fel.cvut.cz>"
!
smalltalkNameForStructField:cStructField
^ self smalltalkize: cStructField cName
"Created: / 17-02-2008 / 21:22:15 / janfrog"
!
smalltalkNamespace
^#Smalltalk
"Created: / 17-02-2008 / 20:51:05 / janfrog"
!
smalltalkPackage
^ smalltalkPackage
"Created: / 03-07-2008 / 21:12:55 / Jan Vrany <vranyj1@fel.cvut.cz>"
!
smalltalkPackage:package
smalltalkPackage := package.
"Created: / 03-07-2008 / 21:12:55 / Jan Vrany <vranyj1@fel.cvut.cz>"
!
smalltalkSelectorForFunction:cFunction
^String streamContents:
[:s|
s nextPutAll:(self smalltalkize: cFunction cName).
cFunction arguments size > 0 ifTrue:
[s nextPut:$:].
cFunction arguments size > 1 ifTrue:
[(cFunction arguments copyFrom:2) do:
[:argument|
s
nextPutAll: (self smalltalkize: argument cName);
nextPut:$:]]]
"Created: / 17-02-2008 / 22:15:44 / janfrog"
"Modified: / 04-07-2008 / 08:28:35 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !
!TypeMapping methodsFor:'private - utilities'!
smalltalkize: input
| inputStream outputStream |
inputStream := input readStream.
outputStream := (String new:input size) writeStream.
[ inputStream atEnd ] whileFalse:
[|c|
c := inputStream next.
c = $_
ifTrue:[outputStream nextPut: inputStream next asUppercase]
ifFalse:[outputStream nextPut: c]].
^outputStream contents.
"
Cface::TypeMapping new smalltalkize:'test'
Cface::TypeMapping new smalltalkize:'test_of_smalltalkize'
"
"Created: / 08-02-2008 / 09:34:40 / janfrog"
"Modified: / 03-07-2008 / 22:31:24 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !
!TypeMapping class methodsFor:'documentation'!
version
^ '$Header: /opt/data/cvs/cvut-fel/cface/Cface__TypeMapping.st,v 1.1 2008/02/26 16:00:36 vranyj1 Exp $'
! !