Skip to content

Commit

Permalink
Decorator works.
Browse files Browse the repository at this point in the history
  • Loading branch information
WorldofJARcraft committed Jun 7, 2019
1 parent 43c7c16 commit e1f8b96
Show file tree
Hide file tree
Showing 52 changed files with 193 additions and 39 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
library
instance: aHunspellAPI
Instance := aHunspellAPI
Instance: aValue
Instance := aValue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
library
instance
Instance ifNil: [
Instance := self basicNew initialize
Instance := SPCHunspellAPIDecorator new
].
^ Instance
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
library
new: dictionaryPath withAffix: affixPath
| hunspell |
hunspell := self basicNew initialize.
hunspell createHandle: dictionaryPath affix: affixPath.
^ hunspell
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library
systemArchitecture

^ Smalltalk image wordSize * 8.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
spellchecking
addDictionary: aDictionaryPath
((self class libraryExists and: [ self class fileExists: aDictionaryPath ]) and: [ self class handleNotNil]) ifTrue: [
((self class libraryExists and: [ self class fileExists: aDictionaryPath ]) and: [ self handleNotNil]) ifTrue: [
self apiAdd: self apiHandle dictionary: aDictionaryPath
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
spellchecking
addWordToDictionary: aString
(self class libraryExists and: [ self class handleNotNil]) ifTrue: [
(self class libraryExists and: [ self handleNotNil]) ifTrue: [
self apiAdd: self apiHandle word: aString
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
affixPath: anObject
affixPath := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
affixPath
^ affixPath
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ createHandle: dictionaryPath affix: affixPath
| handle |
"Local variable for debugging."
self class libraryExists ifTrue: [
self dictionaryPath: dictionaryPath.
self affixPath: affixPath.
handle :=self apiCreateHandle: affixPath dPath: dictionaryPath.
self apiHandle: handle
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ createHandle
| handle |
"Left local variable for easier debugging."
self class libraryExists ifTrue: [
handle :=self apiCreateHandle: SPCSpellChecker defaultAffixPath dPath: SPCSpellChecker defaultDictionaryPath.
self dictionaryPath: SPCSpellChecker defaultAffixPath.
self affixPath: SPCSpellChecker defaultDictionaryPath.
handle :=self apiCreateHandle: self affixPath dPath: self dictionaryPath.
self apiHandle: (handle)
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
private
destroyHandle
(self class libraryExists and: [ self class handleNotNil]) ifTrue: [
(self class libraryExists and: [ self handleNotNil]) ifTrue: [
self apiDestroyHandle: self apiHandle
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
dictionaryPath: anObject
dictionaryPath := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
dictionaryPath
^ dictionaryPath
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ library installation
downloadLibraries
| vmDir bitsPerWord |
vmDir := self class vmDirectory.
bitsPerWord := self systemArchitecture.
bitsPerWord := self class systemArchitecture.
'Fetching SpellChecking dependencies' displayProgressAt: Sensor cursorPoint from: 0 to: 1 during: [ :bar | (Smalltalk os platformName asLowercase caseOf: {
['mac os'] -> [ self installLibrariesForMacOS: bitsPerWord in: vmDir ].
['win32'] -> [ self installLibrariesForWindows: bitsPerWord in: vmDir ].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ private
freeSuggestionList: aSuggestionList

aSuggestionList listSize ifNil: [Error signal: 'no list size specified'].
(self class libraryExists and: [ self class handleNotNil]) ifTrue: [
(self class libraryExists and: [ self handleNotNil]) ifTrue: [
self apiFreeSuggests: self apiHandle list: aSuggestionList size: aSuggestionList listSize
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ getSuggestionList: aString

| list |
list := SPCHunspellSuggestList externalNew.
(self class libraryExists and: [ self class handleNotNil]) ifTrue: [
(self class libraryExists and: [ self handleNotNil]) ifTrue: [
list listSize: (self apiSuggest: self apiHandle list: list word: aString).
].
^ list
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
private
handleNotNil
^ self apiHandle isNil not
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
spellchecking
isDecorator

^ false
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
spellchecking
isWordCorrect: aString
(self class libraryExists and: [ self class handleNotNil]) ifTrue: [
(self class libraryExists and: [ self handleNotNil]) ifTrue: [
^ (self apiCheckWord: self apiHandle Text: aString) > 0
] ifFalse: [
^ true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
spellchecking
removeWordFromDictionary: aString
((self class libraryExists) and: [ self class handleNotNil]) ifTrue: [
((self class libraryExists) and: [ self handleNotNil]) ifTrue: [
self apiRemove: self apiHandle word: aString
]

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
{
"class" : {
"Instance:" : "ea 6/7/2019 16:30",
"fileExists:" : "ea 5/28/2019 19:29",
"handleNotNil" : "ea 5/28/2019 19:23",
"instance" : "ea 5/28/2019 18:53",
"instance:" : "ea 5/28/2019 19:27",
"instance" : "ea 6/7/2019 16:21",
"libraryExists" : "ea 5/28/2019 19:10",
"moduleName" : "ea 4/30/2019 19:14",
"new" : "ea 5/28/2019 18:59",
"new:withAffix:" : "ea 6/7/2019 15:29",
"ressourceDirectory" : "ea 5/23/2019 17:26",
"systemArchitecture" : "ea 6/7/2019 17:09",
"vmDirectory" : "ea 5/23/2019 17:27" },
"instance" : {
"addDictionary:" : "ea 5/28/2019 19:29",
"addWordToDictionary:" : "ea 5/28/2019 19:31",
"addDictionary:" : "ea 6/7/2019 16:29",
"addWordToDictionary:" : "ea 6/7/2019 16:29",
"affixPath" : "ea 6/7/2019 15:50",
"affixPath:" : "ea 6/7/2019 15:50",
"apiAdd:dictionary:" : "ea 4/30/2019 19:15",
"apiAdd:word:" : "ea 4/30/2019 19:15",
"apiCheckWord:Text:" : "ea 4/30/2019 19:13",
Expand All @@ -23,26 +26,29 @@
"apiRemove:word:" : "ea 4/30/2019 19:18",
"apiSuggest:list:word:" : "ea 4/30/2019 19:18",
"chooseDictionaryPath" : "mka 6/4/2019 10:35",
"createHandle" : "ea 5/28/2019 19:14",
"createHandle:affix:" : "ea 5/28/2019 19:14",
"destroyHandle" : "ea 5/28/2019 19:25",
"createHandle" : "ea 6/7/2019 15:51",
"createHandle:affix:" : "ea 6/7/2019 15:52",
"destroyHandle" : "ea 6/7/2019 16:34",
"dictionaryPath" : "ea 6/7/2019 15:50",
"dictionaryPath:" : "ea 6/7/2019 15:50",
"downloadDictionaries" : "ea 5/23/2019 18:05",
"downloadFileTo:fromURL:toFileNamed:inBinary:" : "ea 4/30/2019 19:21",
"downloadLibraries" : "ea 5/23/2019 18:05",
"downloadLibraries" : "ea 6/7/2019 17:09",
"finalize" : "mka 5/14/2019 11:42",
"findLinuxLibraryPaths:" : "ea 4/28/2019 15:16",
"freeSuggestionList:" : "ea 5/28/2019 19:25",
"getSuggestionList:" : "ea 5/28/2019 19:26",
"freeSuggestionList:" : "ea 6/7/2019 17:10",
"getSuggestionList:" : "ea 6/7/2019 17:04",
"getSuggestions:" : "ow 7/14/2018 14:24",
"handleNotNil" : "ea 6/7/2019 16:51",
"importDictionary:withAffix:of:" : "mka 6/4/2019 10:35",
"initialize" : "mka 6/3/2019 21:46",
"installDependencies" : "ea 5/21/2019 16:11",
"installLibrariesForLinux:in:" : "ea 5/23/2019 20:16",
"installLibrariesForMacOS:in:" : "ea 5/23/2019 19:36",
"installLibrariesForWindows:in:" : "ea 5/23/2019 19:35",
"isDecorator" : "ea 6/7/2019 15:25",
"isFile:ofCorrectType:" : "mka 6/3/2019 11:09",
"isNilObject" : "mka 5/14/2019 18:02",
"isWordCorrect:" : "ea 5/28/2019 19:24",
"removeWordFromDictionary:" : "ea 5/28/2019 19:31",
"selectFileFromFileChooserWithCaption:" : "mka 6/3/2019 10:47",
"systemArchitecture" : "ea 4/30/2019 19:43" } }
"isWordCorrect:" : "ea 6/7/2019 16:29",
"removeWordFromDictionary:" : "ea 6/7/2019 16:29",
"selectFileFromFileChooserWithCaption:" : "mka 6/3/2019 10:47" } }
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
],
"commentStamp" : "ow 7/21/2018 17:23",
"instvars" : [
"apiHandle" ],
"apiHandle",
"dictionaryPath",
"affixPath" ],
"name" : "SPCHunspellAPI",
"pools" : [
],
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
spellchecking
addDictionary: dictionaryPath
self addDictionary: dictionaryPath andAffix: SPCSpellChecker defaultAffixPath
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
spellchecking
addDictionary: aDictionaryPath andAffix: anAffixPath
| newHunspellAPI |
newHunspellAPI := SPCHunspellAPI new: aDictionaryPath withAffix: anAffixPath.
self instances add: newHunspellAPI
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
spellchecking
addWordToDictionary: aString
self instances do: [ :instance | instance addWordToDictionary: aString ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
spellchecking
createHandle: aDictionarypath affix: anAffixPath
self instances add: (SPCHunspellAPI new: aDictionarypath withAffix: anAffixPath)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
spellchecking
createHandle
self instances add: SPCHunspellAPI new createHandle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
spellchecking
destroyHandle
self instances do: [ :instance | instance destroyHandle ].
self instances: OrderedCollection new
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
spellchecking
getSuggestions: aString

^ self instances inject: OrderedCollection new into: [ :currentSuggestions :currentInstance | currentSuggestions add: (currentInstance getSuggestions: aString)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
initialization
initialize
self instances: OrderedCollection new
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
spellchecking
installDependencies
"I the future, every hunspellapi object may have own dependencies."
self instances do: [ :instance | instance installDependencies ].
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
instances: anObject
instances := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
instances
^ instances
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
isDecorator
^ true
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
spellchecking
isNilObject
^ false
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
spellchecking
isWordCorrect: aString
self instances do: [ :instance | (instance isWordCorrect: aString) ifTrue: [ ^ true ] ].
^ false
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
spellchecking
removeWordFromDictionary: aString
self instances do: [ :instance | instance removeWordFromDictionary: aString ].
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"class" : {
},
"instance" : {
"addDictionary:" : "ea 6/7/2019 16:02",
"addDictionary:andAffix:" : "ea 6/7/2019 15:57",
"addWordToDictionary:" : "ea 6/7/2019 16:06",
"createHandle" : "ea 6/7/2019 16:03",
"createHandle:affix:" : "ea 6/7/2019 16:04",
"destroyHandle" : "ea 6/7/2019 16:58",
"getSuggestions:" : "ea 6/7/2019 16:09",
"initialize" : "ea 6/7/2019 15:23",
"installDependencies" : "ea 6/7/2019 16:24",
"instances" : "ea 6/7/2019 15:23",
"instances:" : "ea 6/7/2019 15:23",
"isDecorator" : "ea 6/7/2019 15:25",
"isNilObject" : "ea 6/7/2019 16:16",
"isWordCorrect:" : "ea 6/7/2019 16:11",
"removeWordFromDictionary:" : "ea 6/7/2019 16:12" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "Spellcheck-Core",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
"instances" ],
"name" : "SPCHunspellAPIDecorator",
"pools" : [
],
"super" : "Object",
"type" : "normal" }
Loading

0 comments on commit e1f8b96

Please sign in to comment.