CodeGeneratorTool.st
branchjv
changeset 15566 184cea584be5
parent 13657 fdc78070d46d
parent 15399 3c49989e6963
child 16116 1e20be47b2a4
--- a/CodeGeneratorTool.st	Sun Jan 12 23:30:25 2014 +0000
+++ b/CodeGeneratorTool.st	Wed Apr 01 10:38:01 2015 +0100
@@ -11,6 +11,8 @@
 "
 "{ Package: 'stx:libtool' }"
 
+"{ NameSpace: Smalltalk }"
+
 Object subclass:#CodeGeneratorTool
 	instanceVariableNames:'compositeChangeCollector compositeChangeNesting userPreferences
 		generateComments confirmChanges targetClass'
@@ -363,7 +365,7 @@
     "return the contents of COPYRIGHT_TEMPLATE_FILE resources
      or a standard template"
 
-    |fn|
+    |fn copyrightHolder|
 
     CopyrightTemplate notNil ifTrue:[^ CopyrightTemplate].
 
@@ -374,7 +376,13 @@
             ^ fn contentsAsString.
         ].
     ].
-    ^ ' COPYRIGHT (c) %1 by >>yourCompany<<
+    (OperatingSystem getDomainName endsWith:'exept.de') ifTrue:[
+        copyrightHolder := 'eXept Sofware AG'.
+    ] ifFalse:[
+        copyrightHolder := '>>your company<<'.
+    ].
+
+    ^ ' COPYRIGHT (c) %1 by %2
               All Rights Reserved
 
  This software is furnished under a license and may be used
@@ -382,8 +390,7 @@
  inclusion of the above copyright notice.   This software may not
  be provided or otherwise made available to, or used by, any
  other person.  No title to or ownership of the software is
- hereby transferred.
-'.
+ hereby transferred.' bindWith:'%1' with:copyrightHolder.
 !
 
 copyrightTemplate:aString
@@ -455,7 +462,7 @@
                 )
             )
              #(#MenuItem
-                #label: 'Help'
+                #label: 'MENU_Help'
                 #translateLabel: true
                 #startGroup: #right
                 #submenu: 
@@ -544,7 +551,7 @@
                 )
             )
              #(#MenuItem
-                #label: 'Help'
+                #label: 'MENU_Help'
                 #translateLabel: true
                 #startGroup: #right
                 #submenu: 
@@ -831,6 +838,12 @@
     self subclassResponsibility
 ! !
 
+!CodeGeneratorTool class methodsFor:'testing'!
+
+isAbstract
+    ^ self == CodeGeneratorTool
+! !
+
 !CodeGeneratorTool class methodsFor:'utilities'!
 
 missingRequiredProtocolFor:aClass
@@ -840,12 +853,17 @@
 
     |requiredSelectors implementedSelectors|
 
+    aClass isAbstract ifTrue:[
+        "abstract classes are not responsible for methods to be defined in subclasses"    
+        ^ #().
+    ].
+
     requiredSelectors := IdentitySet new.
     implementedSelectors := IdentitySet withAll:(aClass methodDictionary keys).
 
     aClass allSuperclassesDo:[:eachSuperClass |
         eachSuperClass methodDictionary keysAndValuesDo:[:eachSelector :eachMethod |
-            (eachMethod sends:#subclassResponsibility or:#subclassResponsibility:) ifTrue:[
+            (eachMethod sendsAny:#( #subclassResponsibility #subclassResponsibility: )) ifTrue:[
                 (implementedSelectors includes:eachSelector) ifFalse:[
                     requiredSelectors add:eachSelector.
                 ]
@@ -859,6 +877,7 @@
     ^ requiredSelectors
 
     "Modified: / 08-08-2011 / 18:44:58 / cg"
+    "Modified: / 10-01-2015 / 06:46:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !CodeGeneratorTool methodsFor:'bulk changes'!
@@ -1666,7 +1685,13 @@
     category := categoryOrNil ? (Compiler defaultMethodCategory).
 
     skipIfSame ifTrue:[
-        compiler := aClass compilerClass new.
+        "JV: Do not use class's compilerClass, it may differ from
+         the compiler of this generator's language. For instance,
+         when compiling Smalltalk extension to Java or JavaScript class.
+         So, use proper compiler for language the receiver is generator for,
+         i.e., Compiler for SmalltalkCodeGenerator, JavaScriptCompiler for
+         JavaScriptCodeGenerator..."
+        compiler := self compilerClass new.
         compiler parseMethod:theCode in:aClass ignoreErrors:true ignoreWarnings:true.
 
         selector := compiler selector.
@@ -1698,6 +1723,15 @@
 
     "Modified: / 21-08-2006 / 18:39:06 / cg"
     "Modified (format): / 21-01-2012 / 10:40:59 / cg"
+    "Modified (format): / 05-08-2014 / 21:06:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+compilerClass
+    "Return a real compiler classto use to compile code"
+
+    ^ self subclassResponsibility
+
+    "Created: / 05-08-2014 / 21:01:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !CodeGeneratorTool methodsFor:'initialization'!
@@ -1756,19 +1790,10 @@
 !CodeGeneratorTool class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.104 2013-10-10 14:23:37 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.112 2015-02-24 11:49:55 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.104 2013-10-10 14:23:37 cg Exp $'
-!
-
-version_HG
-
-    ^ '$Changeset: <not expanded> $'
-!
-
-version_SVN
-    ^ '$Id: CodeGeneratorTool.st 8074 2012-11-30 17:23:39Z vranyj1 $'
+    ^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.112 2015-02-24 11:49:55 cg Exp $'
 ! !