Cface__Libgit2Mapping.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 10 Sep 2012 10:23:27 +0000
changeset 28 6a2e82ddbca1
parent 27 5a58064b5921
child 29 91d5e0a30fa4
permissions -rw-r--r--
- Updates to latest GCC XML that apparently reports structure sizes in bits instead of bytes.

"{ Package: 'cvut:fel/cface' }"

"{ NameSpace: Cface }"

TypeMapping subclass:#Libgit2Mapping
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Cface-Mappings'
!


!Libgit2Mapping methodsFor:'accessing'!

smalltalkNameForEnumValue:cEnumFieldType 
    |cairoName|

    cairoName := cEnumFieldType cName.
    (cairoName startsWith:'GIT_') ifTrue:[
        cairoName := cairoName copyFrom:5
    ].
    ^ cairoName asSymbol

    "
        Cface::CairoMapping new
            smalltalkNameForEnumValue:(Cface::CEnumValueNode new cName:'CAIRO_FONT_TYPE_TOY')

    "

    "Created: / 04-07-2008 / 11:32:01 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 04-09-2012 / 16:02:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

smalltalkPackage

    ^#'stx:libgit'

    "Created: / 03-07-2008 / 21:14:47 / Jan Vrany <vranyj1@fel.cvut.cz>"
    "Modified: / 04-09-2012 / 16:01:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Libgit2Mapping methodsFor:'mapping - categories'!

smalltalkCategoryForDerivedType:cType
    | className class |

    className := cType smalltalkName asSymbol.
    (className notNil and:[(class := Smalltalk at: className) notNil]) ifTrue:[
        ^class category
    ].
    ^'Git-Support-libgit2'

    "Created: / 05-09-2012 / 11:15:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Libgit2Mapping methodsFor:'mapping - class names'!

smalltalkClassNameForEnum:cEnum

    cEnum cName = 'git_otype' ifTrue:[
        ^#GitObjectType
    ].

    cEnum cName = 'git_error_t' ifTrue:[
        ^#GitErrorCode
    ].

    ^ self smalltalkClassNameForDerivedType:cEnum

    "Answers class which should contain function call"

    "Created: / 10-09-2012 / 09:30:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

smalltalkClassNameForFunction:cFunction 
    "Answers class which should contain function call"

    ^#GitPrimitives

    "Created: / 07-09-2012 / 15:04:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

smalltalkClassNameForStruct:cStruct
    
    "Make GitOid a pure byte array to reduce stress on GC"
    cStruct cName = '_git_oid' ifTrue:[
        cStruct ffiPointerTypeSymbol:#charPointer.
    ].

    ^ self smalltalkClassNameForDerivedType:cStruct

    "Answers class which should contain function call"

    "Created: / 10-09-2012 / 10:31:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Libgit2Mapping methodsFor:'mapping - selectors'!

smalltalkSelectorForFunction:cFunction
    | selector |

    selector := String streamContents:[:s|
        s nextPutAll: '_'.
        s nextPutAll: 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:$:]]].

    ^selector asSymbol

    "Created: / 07-09-2012 / 23:14:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Libgit2Mapping class methodsFor:'documentation'!

version_SVN
    ^ '$Id::                                                                                                                        $'
! !