- CypressReader
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 02 Oct 2012 09:01:43 +0000
changeset 21 c88f472e1c23
parent 20 cdf3ee8ceeaa
child 22 9086d6f7096a
- CypressReader added: #readMethod:from: - CypressAbstractReader added:7 methods changed: #readPackage:as:from: - extensions ...
CypressAbstractReader.st
CypressReader.st
Make.proto
bc.mak
cypress.rc
lccmake.bat
mingwmake.bat
--- a/CypressAbstractReader.st	Tue Sep 18 13:49:14 2012 +0000
+++ b/CypressAbstractReader.st	Tue Oct 02 09:01:43 2012 +0000
@@ -30,10 +30,24 @@
 
 !CypressAbstractReader methodsFor:'reading'!
 
-readPackage:arg1 as:arg2 from:arg3
-    "raise an error: must be redefined in concrete subclass(es)"
+readPackage: name as: packageIdOrNil from: directory
+    | pkgdir pkg |
+
+    pkgdir := CypressRepository packageDirectoryForPackageName: name in: directory.
+    pkgdir isNil ifTrue:[ 
+        self error: 'No package named ', name ,' found in ', directory pathName.
+    ].
 
-    ^ self subclassResponsibility
+    packageId := packageIdOrNil.
+
+    pkg := CypressPackage new.
+    self 
+        readPropertiesFor: pkg from: pkgdir;
+        readClassesFor: pkg from: pkgdir;
+        readExtensionsFor: pkg from: pkgdir.
+    ^pkg
+
+    "Created: / 18-09-2012 / 13:16:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 readPackage: name from: directory
@@ -42,6 +56,109 @@
     "Created: / 18-09-2012 / 09:43:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!CypressAbstractReader methodsFor:'reading-private'!
+
+readClass: name from: directory
+    | clsdir cls |
+
+    clsdir := directory / name.
+    clsdir exists ifFalse:[
+        clsdir := clsdir withSuffix: self defaultFileSuffixForClass.
+    ].
+    clsdir exists ifFalse:[
+        self error: 'No such class in ', directory pathName.
+        ^nil.
+    ].
+
+    cls := CypressClass new.
+    self 
+        readPropertiesFor: cls from: clsdir;
+        readMethodsFor: cls from: clsdir.
+    ^cls
+
+    "Created: / 18-09-2012 / 09:54:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+readClassesFor: pkg from: directory
+
+    directory directoryContentsAsFilenamesDo:[:each|
+        each suffix = self defaultFileSuffixForClass ifTrue:[
+            pkg classes add: (self readClass: each baseName from: directory)
+        ]
+    ]
+
+    "Created: / 18-09-2012 / 09:52:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+readExtensionsFor: pkg from: directory
+
+    directory directoryContentsAsFilenamesDo:[:each|
+        each suffix = self defaultFileSuffixForExtensions ifTrue:[
+            | clsname dir |
+
+            clsname := each withoutSuffix baseName.
+            dir := each / 'class'.
+            dir exists ifTrue:[
+                self readMethodsForClassNamed: clsname meta: true from: dir into: pkg extensions.
+            ].
+            dir := each / 'instance'.
+            dir exists ifTrue:[
+                self readMethodsForClassNamed: clsname meta: false from: dir into: pkg extensions.
+            ]
+
+        ]
+    ]
+
+    "Created: / 18-09-2012 / 10:11:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+readMethod:arg1 from:arg2
+    "raise an error: must be redefined in concrete subclass(es)"
+
+    ^ self subclassResponsibility
+!
+
+readMethodsFor: cls from: directory
+    | dir |
+
+    (dir := directory / 'class') exists ifTrue:[
+        self readMethodsForClassNamed: cls name meta: true from: dir into: cls methods
+    ].
+    (dir := directory / 'instance') exists ifTrue:[
+        self readMethodsForClassNamed: cls name meta: false from: dir into: cls methods
+    ]
+
+    "Created: / 18-09-2012 / 09:56:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+readMethodsForClassNamed: clsname meta: isClassMethod from: dir into: collection
+
+    dir directoryContentsAsFilenamesDo:[:each|
+        each suffix = 'st' ifTrue:[
+            | mthd |
+
+            mthd := self readMethod: each baseName from: dir.
+            mthd meta: isClassMethod.
+            mthd klass: clsname.
+            collection add: mthd.
+        ]
+    ]
+
+    "Created: / 18-09-2012 / 10:07:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+readPropertiesFor: model from: directory
+    | props propFile |
+
+    propFile := directory / self defaultFileNameForProperties.
+    props := propFile exists 
+        ifTrue:[CypressJSONReader parse: propFile]
+        ifFalse:[Dictionary new].
+    model properties: props.
+
+    "Created: / 18-09-2012 / 09:47:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !CypressAbstractReader class methodsFor:'documentation'!
 
 version_SVN
--- a/CypressReader.st	Tue Sep 18 13:49:14 2012 +0000
+++ b/CypressReader.st	Tue Oct 02 09:01:43 2012 +0000
@@ -27,6 +27,41 @@
 "
 ! !
 
+!CypressReader methodsFor:'reading-private'!
+
+readMethod: name from: directory
+    | mthdfile mthd |
+
+    mthdfile := directory / name.
+    mthdfile exists ifFalse:[
+        mthdfile := mthdfile withSuffix: self defaultFileSuffixForMethod.
+    ].
+    mthdfile exists ifFalse:[
+        self error: 'No such method in ', directory pathName.
+        ^nil.
+    ].
+
+    mthd := CypressMethod new.
+    mthdfile readingFileDo:[:s|
+        | line |
+        "Method file starts with following four lines: 
+                1. a single double-quote 
+                2. 'notice: ' + the contents of the copyrightLine property (see above) 
+                3. 'category: ' + method category/protocol 
+                4. a single double-quote"
+
+        (line := s nextLine) ~= '"' ifTrue:[ self error: 'Malformed method file'. ^nil].
+        ((line := s nextLine) startsWith:'notice: ') ifTrue:[ self error: 'Malformed method file - expecing notice on second line'. ^nil].
+        ((line := s nextLine) startsWith:'category: ') ifTrue:[ self error: 'Malformed method file - expecing category on third line'. ^nil].
+        mthd category: (line copyFrom: 'category: ' size + 1).
+        (line := s nextLine) ~= '"' ifTrue:[ self error: 'Malformed method file'. ^nil].
+        mthd source: s upToEnd.
+    ].
+    ^mthd
+
+    "Created: / 18-09-2012 / 10:03:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !CypressReader class methodsFor:'documentation'!
 
 version_SVN
--- a/Make.proto	Tue Sep 18 13:49:14 2012 +0000
+++ b/Make.proto	Tue Oct 02 09:01:43 2012 +0000
@@ -107,6 +107,7 @@
 
 prereq: $(REQUIRED_SUPPORT_DIRS)
 	cd ../../libbasic && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
+	cd ../soap/wsdl && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd ../regex && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd ../../libbasic2 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd ../refactoryBrowser/helpers && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
@@ -140,7 +141,6 @@
 	cd ../xml/stx && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd ../../libwidg3 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd ../../libtool && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
-	cd $(TOP)/../exept/libcrypt/ssl && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd $(TOP)/../exept/expecco/manifestApi && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd ../webServer && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
 	cd $(TOP)/../exept/ctypes/inspector && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
--- a/bc.mak	Tue Sep 18 13:49:14 2012 +0000
+++ b/bc.mak	Tue Oct 02 09:01:43 2012 +0000
@@ -51,6 +51,7 @@
 # build all prerequisite packages for this package
 prereq:
 	pushd ..\..\libbasic & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
+	pushd ..\soap\wsdl & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\regex & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\..\libbasic2 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\refactoryBrowser\helpers & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
@@ -84,7 +85,6 @@
 	pushd ..\xml\stx & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\..\libwidg3 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\..\libtool & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
-	pushd ..\..\..\exept\libcrypt\ssl & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\..\..\exept\expecco\manifestApi & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\webServer & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
 	pushd ..\..\..\exept\ctypes\inspector & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
--- a/cypress.rc	Tue Sep 18 13:49:14 2012 +0000
+++ b/cypress.rc	Tue Oct 02 09:01:43 2012 +0000
@@ -3,7 +3,7 @@
 // automagically generated from the projectDefinition: stx_goodies_cypress.
 //
 VS_VERSION_INFO VERSIONINFO
-  FILEVERSION     6,2,16,16
+  FILEVERSION     6,2,21,21
   PRODUCTVERSION  6,2,3,1
 #if (__BORLANDC__)
   FILEFLAGSMASK   VS_FF_DEBUG | VS_FF_PRERELEASE
@@ -20,12 +20,12 @@
     BEGIN
       VALUE "CompanyName", "Jan Vrany\0"
       VALUE "FileDescription", "Cypress Package Format Reader/Writer (LIB)\0"
-      VALUE "FileVersion", "6.2.16.16\0"
+      VALUE "FileVersion", "6.2.21.21\0"
       VALUE "InternalName", "stx:goodies/cypress\0"
       VALUE "LegalCopyright", "Copyright Jan Vrany & Dale Henrichs 2012\0"
       VALUE "ProductName", "Cypress\0"
       VALUE "ProductVersion", "6.2.3.1\0"
-      VALUE "ProductDate", "Tue, 18 Sep 2012 13:50:01 GMT\0"
+      VALUE "ProductDate", "Tue, 02 Oct 2012 09:03:00 GMT\0"
     END
 
   END
--- a/lccmake.bat	Tue Sep 18 13:49:14 2012 +0000
+++ b/lccmake.bat	Tue Oct 02 09:01:43 2012 +0000
@@ -3,6 +3,6 @@
 @REM type lccmake, and wait...
 @REM do not edit - automatically generated from ProjectDefinition
 @REM -------
-make.exe -N -f bc.mak USELCC=1 %*
+make.exe -N -f bc.mak -DUSELCC=1 %*
 
 
--- a/mingwmake.bat	Tue Sep 18 13:49:14 2012 +0000
+++ b/mingwmake.bat	Tue Oct 02 09:01:43 2012 +0000
@@ -3,6 +3,6 @@
 @REM type mingwmake, and wait...
 @REM do not edit - automatically generated from ProjectDefinition
 @REM -------
-make.exe -N -f bc.mak USEMINGW=1 %*
+make.exe -N -f bc.mak -DUSEMINGW=1 %*