LibraryDefinition.st
changeset 17242 03455ae3b8d0
parent 17231 7a0932dedec0
child 18120 e3a375d5f6a8
child 18502 52c60aea0795
--- a/LibraryDefinition.st	Mon Dec 22 01:19:04 2014 +0100
+++ b/LibraryDefinition.st	Mon Dec 22 01:46:55 2014 +0100
@@ -60,7 +60,7 @@
 fileDescription
     "Return a description string which will appear in nt.def / bc.def and the rc-file"
 
-    ^self description , ' (LIB)'
+    ^ self description , ' (LIB)'
 
     "Created: / 14-09-2006 / 10:55:23 / cg"
 !
@@ -76,16 +76,13 @@
 !LibraryDefinition class methodsFor:'file generation'!
 
 basicFileNamesToGenerate
-    "answer a dictionary (filename -> generator method) with all the files, that have to be generated for this
-     package"
+    "answer a dictionary (filename -> generator method) with all the files, 
+     that have to be generated for this package"
 
     |dict|
 
     dict := super basicFileNamesToGenerate.
-
-    dict
-	at:'libInit.cc'         put:#'generate_libInit_dot_cc'.
-
+    dict at:'libInit.cc' put:#'generate_libInit_dot_cc'.
     ^ dict.
 !
 
@@ -140,9 +137,9 @@
 
 extensionLine_libInit_dot_cc_mappings
 
-^Dictionary new
-    at: 'LIBRARY_NAME' put: ( self st2c:(self package copy asString replaceAny:':/' with:$_) );
-    yourself
+    ^ Dictionary new
+        at: 'LIBRARY_NAME' put: ( self st2c:(self package copy asString replaceAny:':/' with:$_) );
+        yourself
 
     "Created: / 09-08-2006 / 11:19:59 / fm"
     "Modified: / 14-09-2006 / 18:56:26 / cg"
@@ -150,14 +147,13 @@
 
 libInit_dot_cc_mappings
 
-^Dictionary new
-    at: 'LIBRARY_NAME' put: (self libraryName);
-    at: 'PACKAGE' put: (self package);
-    at: 'DEFINITION_CLASSES' put: (self generate_definitionClassLine_libInit_dot_cc);
-    at: 'CLASSES' put: (self generateClassLines_libInit_dot_cc);
-    at: 'EXTENSION' put: (self generateExtensionLine_libInit_dot_cc);
-
-    yourself
+    ^ Dictionary new
+        at: 'LIBRARY_NAME' put: (self libraryName);
+        at: 'PACKAGE' put: (self package);
+        at: 'DEFINITION_CLASSES' put: (self generate_definitionClassLine_libInit_dot_cc);
+        at: 'CLASSES' put: (self generateClassLines_libInit_dot_cc);
+        at: 'EXTENSION' put: (self generateExtensionLine_libInit_dot_cc);
+        yourself
 
     "Created: / 09-08-2006 / 11:20:24 / fm"
     "Modified: / 16-08-2006 / 18:19:03 / User"
@@ -215,11 +211,11 @@
 generateExtensionLine_libInit_dot_cc
     |mappings|
 
-    ^self hasExtensionMethods
-	ifFalse:['']
-	ifTrue:[
-	    mappings := self extensionLine_libInit_dot_cc_mappings.
-	    self replaceMappings: mappings in: self extensionLine_libInit_dot_cc.]
+    ^ self hasExtensionMethods
+        ifFalse:['']
+        ifTrue:[
+            mappings := self extensionLine_libInit_dot_cc_mappings.
+            self replaceMappings: mappings in: self extensionLine_libInit_dot_cc.]
 
     "
      DapasXProject generateExtensionLine_libInit_dot_cc
@@ -348,7 +344,7 @@
 
 extensionLine_libInit_dot_cc
 
-^'_%(LIBRARY_NAME)_extensions_Init(pass,__pRT__,snd);'
+    ^ '_%(LIBRARY_NAME)_extensions_Init(pass,__pRT__,snd);'
 
     "Created: / 08-08-2006 / 15:48:56 / fm"
     "Modified: / 08-08-2006 / 19:32:33 / fm"
@@ -650,8 +646,57 @@
 
 !LibraryDefinition class methodsFor:'queries'!
 
+definitionClassOfApplicationBundle
+    "Return the applicationDefinition of the applicationBundle or nil. 
+     This is the applicationDefinition of the package which gets actually deployed.
+     For example, for all stx libraries, this will be stx_projects_smalltalk.
+     For expecco, this would be exept_expecco_application.
+     The algorithm here follows the parent hierarchy (not the class hierarchy) of the package name.
+     Some classes may explicitly redefine this (if the folder structure is not hierarchical).
+     This information is currently used for automatic check of language translations.
+
+     Notice: libraries which are used by more than one project, should only return the one
+     which is their 'natural' bundle - usually defined by the position in the package hierarchy.
+     This is a little experimental - may change."
+
+    |libPackageID parentPackageID parentDefinitionClass|
+
+    libPackageID := self package asPackageId.
+    [
+        parentPackageID := libPackageID parentPackage.
+        parentPackageID isNil ifTrue:[^ nil].
+
+        parentDefinitionClass := parentPackageID projectDefinitionClass.
+        parentDefinitionClass notNil ifTrue:[
+            ^ parentDefinitionClass definitionClassOfApplicationBundle
+        ].
+        libPackageID := parentPackageID
+    ] loop.
+
+    "
+     exept_expecco definitionClassOfApplicationBundle
+    "
+!
+
 projectType
     ^ LibraryType
+!
+
+supportedLanguages
+    "Returns a list of languages that (should be / are) supported by this application or library.
+     Currently this is only used by lint, to verify that the corresponding languages are 
+     present in the resource files."
+
+    |app|
+
+    (app := self definitionClassOfApplicationBundle) notNil ifTrue:[
+        ^ app supportedLanguages
+    ].
+    ^ super supportedLanguages.
+
+    "
+     exept_expecco definitionClassOfApplicationBundle
+    "
 ! !
 
 !LibraryDefinition class methodsFor:'sanity checks'!
@@ -705,10 +750,10 @@
 !LibraryDefinition class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/LibraryDefinition.st,v 1.122 2014-12-19 14:24:09 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/LibraryDefinition.st,v 1.123 2014-12-22 00:46:55 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/LibraryDefinition.st,v 1.122 2014-12-19 14:24:09 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/LibraryDefinition.st,v 1.123 2014-12-22 00:46:55 cg Exp $'
 ! !