From ddc7d9d9c8483d1dae18504a433cc843672f3f17 Mon Sep 17 00:00:00 2001 From: "Esteban A. Maringolo" Date: Thu, 20 Jul 2023 12:15:23 -0300 Subject: [PATCH] Fixes #129, #130, #131 --- source/.configmaps | 12 ++++----- .../TonelApplicationLoader.class.st | 27 ++++++++++++++++--- source/TonelLoaderModel/TonelLoader.class.st | 10 ++++--- .../TonelLoaderApplication.class.st | 6 +++++ .../TonelLoaderModel.class.st | 7 +++++ .../TonelReaderClassDefinition.extension.st | 12 ++++----- source/TonelReaderModel/TonelParser.class.st | 18 ++++++++----- .../TonelReaderClassDefinition.class.st | 23 ++++++++-------- 8 files changed, 77 insertions(+), 38 deletions(-) diff --git a/source/.configmaps b/source/.configmaps index c01c334..e1f63e8 100644 --- a/source/.configmaps +++ b/source/.configmaps @@ -1,7 +1,7 @@ [ { #conditions : [ ], - #ts : 3851938730, + #ts : 3867308070, #comment : '', #formatVersion : '1.1', #applications : OrderedCollection [ @@ -22,13 +22,13 @@ }, { #name : 'TonelLoaderModel', - #versionName : '1.6.1', - #ts : 3854101104 + #versionName : '1.6.3', + #ts : 3867307944 }, { #name : 'TonelReaderModel', - #versionName : '1.5.7', - #ts : 3836968025 + #versionName : '1.6.2', + #ts : 3867235271 }, { #name : 'TonelTools', @@ -42,7 +42,7 @@ } ], #name : 'ENVY/Image Tonel', - #versionName : '1.6.1' + #versionName : '1.6.3' }, { #conditions : [ ], diff --git a/source/TonelLoaderModel/TonelApplicationLoader.class.st b/source/TonelLoaderModel/TonelApplicationLoader.class.st index 95622fe..890a210 100644 --- a/source/TonelLoaderModel/TonelApplicationLoader.class.st +++ b/source/TonelLoaderModel/TonelApplicationLoader.class.st @@ -49,7 +49,7 @@ TonelApplicationLoader >> autogenerateClassSideNewInitializers [ superclasses do: [:aSuperclass | | tonelClass | tonelClass := allDefinedClasses at: aSuperclass. "Only generate #new if it does not have it...we don't want to override it" - tonelClass includesClassSideNewMethod + (tonelClass includesClassSideNewMethod or: [self classSideNewMethodIsDefinedInSuperclassOf: tonelClass]) ifFalse: [ tonelClass addMethod: (TonelReaderMethodDefinition newInitializeMethodFor: aSuperclass)]] ] @@ -96,6 +96,27 @@ TonelApplicationLoader >> chooseVersionName [ ] +{ #category : 'loading-internal' } +TonelApplicationLoader >> classSideNewMethodIsDefinedInSuperclassOf: tonelClass [ + + | superClass superClassImplementor | + + superClass := + Smalltalk + classAt: tonelClass superclassIdentifier + ifAbsent: [ + self tonelApplication + definedClassNamed: tonelClass superclassIdentifier + ifAbsent: [self loader tonelClassNamed: tonelClass superclassIdentifier]]. + superClass isNil ifTrue: [^false]. + + (superClass class = TonelReaderClassDefinition) ifTrue: [^tonelClass includesClassSideNewMethod]. + superClassImplementor := (superClass class whichClassIncludesSelector: #new). + ^superClassImplementor notNil and: [superClassImplementor ~= Behavior] + + +] + { #category : 'loading-prompters' } TonelApplicationLoader >> computePrerequisites [ ^self loader prerequisitesFor: self tonelApplication current: tonelApplication prerequisites @@ -209,10 +230,10 @@ TonelApplicationLoader >> detectAllRootSuperclassesWithinApp [ superclasses := Set new. allDefinedClasses keysAndValuesDo: [:aClassName :tonelClass | superclassBlock := [:aClass | - (allDefinedClasses includesKey: aClass superclassIdentifier asString) + (allDefinedClasses includesKey: aClass superclassIdentifier asSymbol) ifTrue: [ superclassBlock - value: (allDefinedClasses at: aClass superclassIdentifier asString)] + value: (allDefinedClasses at: aClass superclassIdentifier asSymbol)] ifFalse: [aClass name]]. superclasses add: (superclassBlock value: tonelClass)]. ^superclasses diff --git a/source/TonelLoaderModel/TonelLoader.class.st b/source/TonelLoaderModel/TonelLoader.class.st index ebdd01b..b5f6bce 100644 --- a/source/TonelLoaderModel/TonelLoader.class.st +++ b/source/TonelLoaderModel/TonelLoader.class.st @@ -704,12 +704,14 @@ TonelLoader >> systemLoadedApplications [ { #category : 'accessing' } TonelLoader >> tonelClassNamed: aSymbol [ + "Returns the Tonel class definition defined in one of receiver's application. + + Answers: + + " self applications do: [:tonelApp | - (tonelApp allDefinedClasses - detect: [:tonelClass | tonelClass identifier = aSymbol] - ifNone: []) - ifNotNil: [:foundClass | ^foundClass]]. + (tonelApp definedClassNamed: aSymbol ifAbsent: []) ifNotNil: [:foundClass | ^foundClass]]. ^nil ] diff --git a/source/TonelLoaderModel/TonelLoaderApplication.class.st b/source/TonelLoaderModel/TonelLoaderApplication.class.st index 7a66236..95fd834 100644 --- a/source/TonelLoaderModel/TonelLoaderApplication.class.st +++ b/source/TonelLoaderModel/TonelLoaderApplication.class.st @@ -197,6 +197,12 @@ TonelLoaderApplication >> createTonelPackageNameMethodFor: anApp [ categorizeIn: #('Tonel-Metadata')] "Have it notify itself?" ] +{ #category : 'querying' } +TonelLoaderApplication >> definedClassNamed: aSymbol ifAbsent: aBlock [ + + ^self allDefinedClasses at: aSymbol ifAbsent: aBlock +] + { #category : 'loading' } TonelLoaderApplication >> definePoolDictionaries [ "Define the pool dictionaries declared in the receiver." diff --git a/source/TonelLoaderModel/TonelLoaderModel.class.st b/source/TonelLoaderModel/TonelLoaderModel.class.st index fdcba9e..4b0b182 100644 --- a/source/TonelLoaderModel/TonelLoaderModel.class.st +++ b/source/TonelLoaderModel/TonelLoaderModel.class.st @@ -3,3 +3,10 @@ Class { #superclass : 'Application', #category : 'TonelLoaderModel' } + +{ #category : 'Not categorized', + #vaVisibility : 'private' } +TonelLoaderModel class >> removing [ + + TonelLoaderSettings reset +] diff --git a/source/TonelLoaderModel/TonelReaderClassDefinition.extension.st b/source/TonelLoaderModel/TonelReaderClassDefinition.extension.st index a6f8028..03ca9ec 100644 --- a/source/TonelLoaderModel/TonelReaderClassDefinition.extension.st +++ b/source/TonelLoaderModel/TonelReaderClassDefinition.extension.st @@ -10,9 +10,9 @@ TonelReaderClassDefinition class >> appNamed: aString [ superclass: 'Application' "$NON-NLS$" variable: false fieldType: 'pointers' "$NON-NLS$" - instanceVariables: '' "$NON-NLS$" - classVariables: '' "$NON-NLS$" - poolDictionaries: '') "$NON-NLS$" + instanceVariables: #() + classVariables: #() + poolDictionaries: #()) addSubAppMethods; yourself ] @@ -25,9 +25,9 @@ TonelReaderClassDefinition class >> subAppNamed: aString [ superclass: 'SubApplication' "$NON-NLS$" variable: false fieldType: 'pointers' "$NON-NLS$" - instanceVariables: '' "$NON-NLS$" - classVariables: '' "$NON-NLS$" - poolDictionaries: '') "$NON-NLS$" + instanceVariables: #() + classVariables: #() + poolDictionaries: #()) addSubAppMethods; yourself ] diff --git a/source/TonelReaderModel/TonelParser.class.st b/source/TonelReaderModel/TonelParser.class.st index d26cba2..04aff9f 100644 --- a/source/TonelReaderModel/TonelParser.class.st +++ b/source/TonelReaderModel/TonelParser.class.st @@ -236,13 +236,17 @@ TonelParser >> newClassDefinitionFrom: anArray [ superclass: (metadata at: #superclass) variable: nil fieldType: typeName - instanceVariables: (metadata at: #instVars ifAbsent: [#()]) - classVariables: (metadata at: #classVars ifAbsent: [#()]) - poolDictionaries: (metadata at: #pools ifAbsent: [#()])) - category: (metadata at: #category); - classInstanceVariables: (metadata at: #classInstVars ifAbsent: [#()]); - classComment: classComment; - yourself) + instanceVariables: + ((metadata at: #instVars ifAbsent: [#()]) collect: [:each | each asString]) + classVariables: + ((metadata at: #classVars ifAbsent: [#()]) collect: [:each | each asString]) + poolDictionaries: + ((metadata at: #pools ifAbsent: [#()]) collect: [:each | each asString]) + ) + category: (metadata at: #category); + classInstanceVariables: (metadata at: #classInstVars ifAbsent: [#()]); + classComment: classComment; + yourself) ] diff --git a/source/TonelReaderModel/TonelReaderClassDefinition.class.st b/source/TonelReaderModel/TonelReaderClassDefinition.class.st index 60a6d9d..4585d06 100644 --- a/source/TonelReaderModel/TonelReaderClassDefinition.class.st +++ b/source/TonelReaderModel/TonelReaderClassDefinition.class.st @@ -36,7 +36,7 @@ TonelReaderClassDefinition class >> name: aString [ ] { #category : 'Initialize-Release' } -TonelReaderClassDefinition class >> name: nameString superclass: superString variable: varBoolean fieldType: fieldTypeString instanceVariables: instVarString classVariables: classVarString poolDictionaries: poolDictString [ +TonelReaderClassDefinition class >> name: nameString superclass: superString variable: varBoolean fieldType: fieldTypeString instanceVariables: instVars classVariables: classVars poolDictionaries: poolDicts [ "Answer a new instance of receiver with all the parameters specified as arguments." @@ -45,9 +45,9 @@ TonelReaderClassDefinition class >> name: nameString superclass: superString var superclass: superString variable: varBoolean fieldType: fieldTypeString - instanceVariables: instVarString - classVariables: classVarString - poolDictionaries: poolDictString; + instanceVariables: instVars + classVariables: classVars + poolDictionaries: poolDicts; yourself ] @@ -186,22 +186,21 @@ TonelReaderClassDefinition >> initialize: aString [ isSharedPool := false ] -{ #category : 'Initialize-Release' } -TonelReaderClassDefinition >> initializeWithName: nameString superclass: superString variable: varBoolean fieldType: fieldTypeString instanceVariables: instVarString classVariables: classVarString poolDictionaries: poolDictString [ +{ #category : 'Initialize-Release', + #vaVisibility : 'private' } +TonelReaderClassDefinition >> initializeWithName: nameString superclass: superString variable: varBoolean fieldType: fieldTypeString instanceVariables: instVars classVariables: classVars poolDictionaries: poolDicts [ name := nameString. identifier := nameString asSymbol. superclassIdentifier := superString asSymbol = #nil ifTrue: [nil] ifFalse: [superString asSymbol]. variableClass := varBoolean. fieldType := fieldTypeString. - instanceVariables := instVarString. + instanceVariables := instVars. classInstanceVariables := #(). "If the class has class instance variables, they are provided separately" - classVariables := classVarString. - poolDictionaries := poolDictString. + classVariables := classVars. + poolDictionaries := poolDicts. extension := false. - tonelMethods := OrderedCollection new. - - + tonelMethods := OrderedCollection new ] { #category : 'accessing' }