Fix in class generator (MethofDefinitionChange>>classVariableNames: now takes collection, not string)
"{ Package: 'jv:cface' }"
"{ NameSpace: Cface }"
TypeMapping subclass:#Libgit2Mapping
instanceVariableNames:''
classVariableNames:'TypeNameMap'
poolDictionaries:''
category:'Cface-Mappings'
!
!Libgit2Mapping class methodsFor:'initialization'!
initialize
"Invoked at system start or when the class is dynamically loaded."
"/ please change as required (and remove this comment)
TypeNameMap := Dictionary withKeysAndValues: #(
'git_checkout_opts' GitCheckoutOptions
'git_otype' GitObjectType
'git_strarray' GitStringArray
'git_error_t' GitErrorKlass
).
"Modified: / 30-09-2012 / 19:52:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!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-Internal-Handles'
"Created: / 05-09-2012 / 11:15:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
smalltalkCategoryForEnum: enum
^'Git-Internal-Constants'
"Created: / 17-09-2012 / 19:44:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
smalltalkCategoryForStruct:struct
^struct cByteSize == 0 ifTrue:[
'Git-Internal-Handles'
] ifFalse:[
'Git-Internal-Structures'
]
"Created: / 17-09-2012 / 19:43:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!Libgit2Mapping methodsFor:'mapping - class names'!
smalltalkClassNameForEnum:cEnum
| baseName |
TypeNameMap at: cEnum cName ifPresent:[:nm|^nm].
baseName := self smalltalkClassNameForDerivedType:cEnum.
baseName last = $T ifTrue:[
baseName := baseName allButLast.
].
(baseName endsWith: 'Type') ifFalse:[
baseName := baseName , 'Type'.
].
^baseName
"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
| baseName |
"Make GitOid a pure byte array to reduce stress on GC"
cStruct cName = '_git_oid' ifTrue:[
cStruct ffiPointerTypeSymbol:#charPointer.
].
TypeNameMap at: cStruct cName ifPresent:[:nm|^nm].
baseName := self smalltalkClassNameForDerivedType:cStruct.
^ cStruct cByteSize == 0 ifTrue:[
(baseName , 'Handle') asSymbol
] ifFalse:[
(baseName , 'Structure') asSymbol
]
"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:: $'
! !
Libgit2Mapping initialize!