Cface__CTypedefNode.st
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--
LLVM bindings: allow to specify path to llvm-config ..by setting LLVM_CONFIG variable when generating definitions for LLVM bindings. Example: make LVM_CONFIG=~/Projects/LLVM/sources1/build/Debug+Asserts/bin/llvm-config

"{ Package: 'jv:cface' }"

"{ NameSpace: Cface }"

CDerivedTypeNode subclass:#CTypedefNode
	instanceVariableNames:'type'
	classVariableNames:'C99IntTypes2FFITypes'
	poolDictionaries:''
	category:'Cface-C AST'
!

!CTypedefNode class methodsFor:'documentation'!

history

    "Created: / 25-10-2007 / 15:07:10 / haja"
    "Created: #local / 25-10-2007 / 15:07:18 / haja"
    "Created: #local: / 25-10-2007 / 15:07:18 / haja"
    "Created: #names / 25-10-2007 / 15:07:18 / haja"
    "Created: #names: / 25-10-2007 / 15:07:18 / haja"
    "Created: #local:names: / 25-10-2007 / 15:08:27 / haja"
    "Deleted: #local / 29-10-2007 / 19:58:35 / haja"
    "Deleted: #local: / 29-10-2007 / 19:58:35 / haja"
    "Deleted: #names / 29-10-2007 / 19:58:35 / haja"
    "Deleted: #names: / 29-10-2007 / 19:58:35 / haja"
    "Created: #name / 29-10-2007 / 19:58:43 / haja"
    "Created: #name: / 29-10-2007 / 19:58:43 / haja"
    "Created: #id / 29-10-2007 / 19:58:43 / haja"
    "Created: #id: / 29-10-2007 / 19:58:43 / haja"
    "Created: #name:id: / 29-10-2007 / 19:59:29 / haja"
    "Deleted: #local:names: / 29-10-2007 / 19:59:43 / haja"
    "Created: #acceptVisitor: / 02-11-2007 / 10:46:04 / haja"
    "Created: #foreign / 19-11-2007 / 09:41:32 / haja"
    "Created: #foreign: / 19-11-2007 / 09:41:32 / haja"
    "Created: #name:id:foreign: / 19-11-2007 / 09:41:41 / haja"
    "Deleted: #name:id: / 19-11-2007 / 09:41:43 / haja"
! !

!CTypedefNode class methodsFor:'initialization'!

initialize
    "Invoked at system start or when the class is dynamically loaded."

    "/ please change as required (and remove this comment)

    C99IntTypes2FFITypes := Dictionary withKeysAndValues:#(
        int8_t      sint8
        int16_t     sint16
        int32_t     sint32
        int64_t     sint64

        uint8_t     uint8
        uint16_t    uint16
        uint32_t    uint32
        uint64_t    uint64
    )

    "Modified: / 12-08-2015 / 07:38:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!CTypedefNode methodsFor:'accessing'!

cByteSize

    ^type cByteSize

    "Created: / 09-07-2008 / 19:39:38 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

ffiTypeSymbol
    C99IntTypes2FFITypes at: cName ifPresent:[ :ffiType | ^ ffiType ].
    type isCPointerToCStructure ifTrue:[ 
        ^ self smalltalkClassName ? #pointer
    ].
    ^ type ffiTypeSymbol

    "Created: / 03-07-2008 / 22:40:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 12-08-2015 / 07:39:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

type
    ^ type

    "Created: / 10-02-2008 / 19:23:13 / janfrog"
!

type:something
    type := something.

    "Created: / 10-02-2008 / 19:23:13 / janfrog"
! !

!CTypedefNode methodsFor:'printing'!

printOn: stream indent: level

    self printLineOn: stream indent: level.
    stream
        nextPutAll: '(typedef '; cr;
        next: level + 1 put: Character tab; nextPutAll: cName; cr;
        next: level + 1 put: Character tab.
    type printOn: stream indent: level + 1.
    stream nextPut: $)

    "Created: / 17-02-2008 / 18:13:13 / janfrog"
    "Modified: / 18-02-2008 / 15:12:01 / janfrog"
    "Modified: / 10-07-2008 / 20:05:26 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!CTypedefNode methodsFor:'testing'!

isForeign

    ^foreign ? false

    "Created: / 04-07-2008 / 11:46:39 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!CTypedefNode methodsFor:'visiting'!

acceptVisitor:aVisitor 
    "Double dispatch back to the visitor, passing my type encoded in
     the selector (visitor pattern)"
    "stub code automatically generated - please change if required"
    
    ^ aVisitor visitCTypedefNode:self

    "Created: / 02-11-2007 / 10:46:04 / haja"
    "Modified: / 10-02-2008 / 10:45:50 / janfrog"
! !

!CTypedefNode class methodsFor:'documentation'!

version
    ^ '$Id$'
!

version_SVN
    ^ '$Id$'
! !


CTypedefNode initialize!