Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting and marking abstract classes #11

Merged
merged 1 commit into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/XML-Writer-Core/BlockClosure.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ Extension { #name : #BlockClosure }

{ #category : #'*XML-Writer-Core' }
BlockClosure >> embedInXMLMarkupWriter: aMarkupWriter [

self cull: aMarkupWriter writer
]
15 changes: 8 additions & 7 deletions src/XML-Writer-Core/Character.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Extension { #name : #Character }

{ #category : #'*XML-Writer-Core' }
Character >> embedInXMLMarkupWriter: aMarkupWriter [

self asString embedInXMLMarkupWriter: aMarkupWriter
]

Expand All @@ -10,7 +11,7 @@ Character >> isXMLWriterNameChar [
"Range tests are faster and use less memory than a BitmapCharacterSet, and
a temp is used because Character in newer SpurVM images has no 'value'
inst var.

NameStartChar ::=
':' | [A-Z] | '_' | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] |
[#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] |
Expand Down Expand Up @@ -46,7 +47,7 @@ Character >> isXMLWriterNameChar [
tempValue <= 16r2040
ifTrue: [
tempValue <= 16r36F
ifTrue: [
ifTrue: [
tempValue <= 16rF6
ifTrue: [
tempValue <= 16rD6
Expand All @@ -60,7 +61,7 @@ Character >> isXMLWriterNameChar [
^ tempValue >= 16r300]]
ifFalse: [
tempValue <= 16r1FFF
ifTrue: [
ifTrue: [
tempValue <= 16r37D
ifFalse: [^ tempValue >= 16r37F].
^ tempValue >= 16r370]
Expand Down Expand Up @@ -89,15 +90,15 @@ Character >> isXMLWriterNameChar [
ifFalse: [
tempValue >= 16r10000
ifFalse: [^ false].
^ tempValue <= 16rEFFFF]]].
^ tempValue <= 16rEFFFF]]]
]

{ #category : #'*XML-Writer-Core' }
Character >> isXMLWriterNameStartChar [
"Range tests are faster and use less memory than a BitmapCharacterSet, and
a temp is used because Character in newer SpurVM images has no 'value'
inst var.

NameStartChar ::=
':' | [A-Z] | '_' | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] |
[#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] |
Expand All @@ -116,7 +117,7 @@ Character >> isXMLWriterNameStartChar [
tempValue <= 16r5A "$Z asciiValue hex"
ifTrue: [^ true].
^ tempValue == 16r5F]. "$_ asciiValue hex"

^ tempValue == 16r3A]. "$: asciiValue hex"

tempValue <= 16r200D
Expand Down Expand Up @@ -163,5 +164,5 @@ Character >> isXMLWriterNameStartChar [
ifFalse: [
tempValue <= 16rFDCF
ifFalse: [^ false].
^ tempValue >= 16rF900]]].
^ tempValue >= 16rF900]]]
]
3 changes: 2 additions & 1 deletion src/XML-Writer-Core/Collection.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ Extension { #name : #Collection }

{ #category : #'*XML-Writer-Core' }
Collection >> embedInXMLMarkupWriter: aMarkupWriter [
self do: [:each | each embedInXMLMarkupWriter: aMarkupWriter]

self do: [ :each | each embedInXMLMarkupWriter: aMarkupWriter ]
]
7 changes: 4 additions & 3 deletions src/XML-Writer-Core/StandardOrderedDictionary.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ Extension { #name : #StandardOrderedDictionary }

{ #category : #'*XML-Writer-Core' }
StandardOrderedDictionary >> writeAttributesOn: aWriter [
self keysDo: [:attributeName |

self keysDo: [ :attributeName |
aWriter
writeAttributeName: attributeName
value: (self at: attributeName ifAbsent: '')]
value: (self at: attributeName ifAbsent: '') ]
]

{ #category : #'*XML-Writer-Core' }
Expand Down Expand Up @@ -39,5 +40,5 @@ StandardOrderedDictionary >> writeCanonicalAttributesOn: aWriter [
attributeName := sortedAttributeNames at: i.
aWriter
writeAttributeName: attributeName
value: (self at: attributeName)].
value: (self at: attributeName)]
]
19 changes: 9 additions & 10 deletions src/XML-Writer-Core/String.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@ Extension { #name : #String }

{ #category : #'*XML-Writer-Core' }
String >> embedInXMLMarkupWriter: aMarkupWriter [

aMarkupWriter writer string: self
]

{ #category : #'*XML-Writer-Core' }
String >> xmlWriterLocalNameAfterPrefix: aPrefix [
"optimized"
| prefixSize |

| prefixSize |
(prefixSize := aPrefix size) == 0
ifTrue: [^ self]
ifFalse: [^ self copyFrom: prefixSize + 2 to: self size]
ifTrue: [ ^ self ]
ifFalse: [ ^ self copyFrom: prefixSize + 2 to: self size ]
]

{ #category : #'*XML-Writer-Core' }
String >> xmlWriterPrefixBeforeLocalName [
"optimized"
| i |

| i |
i := self size.
[i == 0]
whileFalse: [
((self at: i) == $:)
ifTrue: [^ (self copyFrom: 1 to: i - 1)].
i := i - 1].
^ ''.
[ i == 0 ] whileFalse: [
(self at: i) == $: ifTrue: [ ^ self copyFrom: 1 to: i - 1 ].
i := i - 1 ].
^ ''
]
98 changes: 52 additions & 46 deletions src/XML-Writer-Core/XMLAttributeDeclarationWriter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -15,136 +15,142 @@ Class {

{ #category : #accessing }
XMLAttributeDeclarationWriter >> attribute [
^ attribute ifNil: [attribute := '']

^ attribute ifNil: [ attribute := '' ]
]

{ #category : #accessing }
XMLAttributeDeclarationWriter >> attribute: aName [

attribute := aName
]

{ #category : #accessing }
XMLAttributeDeclarationWriter >> declarationType [

^ 'ATTLIST'
]

{ #category : #accessing }
XMLAttributeDeclarationWriter >> defaultPragma [
^ defaultPragma ifNil: [defaultPragma := '']

^ defaultPragma ifNil: [ defaultPragma := '' ]
]

{ #category : #accessing }
XMLAttributeDeclarationWriter >> defaultPragma: aDefaultPragma [
defaultPragma :=
(aDefaultPragma notNil
and: [aDefaultPragma notEmpty
and: [aDefaultPragma first == $#]])
ifTrue: [aDefaultPragma allButFirst]
ifFalse: [aDefaultPragma]

defaultPragma := (aDefaultPragma notNil and: [
aDefaultPragma notEmpty and: [
aDefaultPragma first == $# ] ])
ifTrue: [ aDefaultPragma allButFirst ]
ifFalse: [ aDefaultPragma ]
]

{ #category : #accessing }
XMLAttributeDeclarationWriter >> defaultValue [
^ defaultValue ifNil: [defaultValue := '']

^ defaultValue ifNil: [ defaultValue := '' ]
]

{ #category : #accessing }
XMLAttributeDeclarationWriter >> defaultValue: aDefaultValue [

defaultValue := aDefaultValue
]

{ #category : #accessing }
XMLAttributeDeclarationWriter >> element [

^ self name
]

{ #category : #accessing }
XMLAttributeDeclarationWriter >> element: aName [

self name: aName
]

{ #category : #accessing }
XMLAttributeDeclarationWriter >> type [
^ type ifNil: [type := 'CDATA']

^ type ifNil: [ type := 'CDATA' ]
]

{ #category : #accessing }
XMLAttributeDeclarationWriter >> type: aType [

type := aType
]

{ #category : #private }
XMLAttributeDeclarationWriter >> writeAttribute [

self writer
space;
writeName: self attribute
]

{ #category : #private }
XMLAttributeDeclarationWriter >> writeBody [
self isOmittable
ifFalse: [
self
writeAttribute;
writeType;
writeDefaultPragma;
writeDefaultValue]

self isOmittable ifFalse: [
self
writeAttribute;
writeType;
writeDefaultPragma;
writeDefaultValue ]
]

{ #category : #writing }
XMLAttributeDeclarationWriter >> writeDefaultPragma [
self defaultPragma notEmpty
ifTrue: [
self writer
space;
nextPut: $#;
nextPutAll: self defaultPragma]

self defaultPragma notEmpty ifTrue: [
self writer
space;
nextPut: $#;
nextPutAll: self defaultPragma ]
]

{ #category : #writing }
XMLAttributeDeclarationWriter >> writeDefaultValue [
(self defaultPragma isEmpty
or: [self defaultPragma = 'FIXED'])

(self defaultPragma isEmpty or: [ self defaultPragma = 'FIXED' ])
ifTrue: [
self writer
space;
writeEscapedContentString: self defaultValue]
writeEscapedContentString: self defaultValue ]
]

{ #category : #private }
XMLAttributeDeclarationWriter >> writeType [
| typeString typeStringSize isEnumeration nameStart |

| typeString typeStringSize isEnumeration nameStart |
self writer space.
typeString := self type.
typeStringSize := typeString size.
isEnumeration := false.
1 to: typeStringSize do: [:i | | nextChar |
1 to: typeStringSize do: [ :i |
| nextChar |
nextChar := typeString at: i.
isEnumeration
ifTrue: [
nameStart
ifNil: [
nextChar isXMLWriterNameStartChar
ifTrue: [nameStart := i]
ifFalse: [self writer nextPut: nextChar]]
ifTrue: [ nameStart := i ]
ifFalse: [ self writer nextPut: nextChar ] ]
ifNotNil: [
nextChar isXMLWriterNameChar
ifFalse: [
self writer writeName:
(typeString
copyFrom: nameStart
to: i - 1).
nameStart := nil.
self writer nextPut: nextChar]]]
nextChar isXMLWriterNameChar ifFalse: [
self writer writeName:
(typeString copyFrom: nameStart to: i - 1).
nameStart := nil.
self writer nextPut: nextChar ] ] ]
ifFalse: [
isEnumeration := nextChar == $(.
self writer nextPut: nextChar]].

nameStart
ifNotNil: [
self writer writeName:
(typeString
copyFrom: nameStart
to: typeStringSize)]
self writer nextPut: nextChar ] ].

nameStart ifNotNil: [
self writer writeName:
(typeString copyFrom: nameStart to: typeStringSize) ]
]
33 changes: 18 additions & 15 deletions src/XML-Writer-Core/XMLCDataWriter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,41 @@ Class {

{ #category : #accessing }
XMLCDataWriter >> string [
^ string ifNil: [string := '']

^ string ifNil: [ string := '' ]
]

{ #category : #accessing }
XMLCDataWriter >> string: aString [

string := aString
]

{ #category : #private }
XMLCDataWriter >> writeBody [

self writer isCanonical
ifTrue: [
self parent
ifNotNil: [:parent | parent newStringMarkupBeingWritten].
self writer writeEscapedContent: self string]
ifFalse: [self writer nextPutAll: self string]
self parent ifNotNil: [ :parent |
parent newStringMarkupBeingWritten ].
self writer writeEscapedContent: self string ]
ifFalse: [ self writer nextPutAll: self string ]
]

{ #category : #private }
XMLCDataWriter >> writeEpilogue [
self isCanonical
ifFalse: [
self writer
nextPutAll: ']]>';
formatAfterCData: self]

self isCanonical ifFalse: [
self writer
nextPutAll: ']]>';
formatAfterCData: self ]
]

{ #category : #private }
XMLCDataWriter >> writePrologue [
self isCanonical
ifFalse: [
self writer
formatBeforeCData: self;
nextPutAll: '<![CDATA[']

self isCanonical ifFalse: [
self writer
formatBeforeCData: self;
nextPutAll: '<![CDATA[' ]
]
Loading