Update of /cvsroot/hoc/hoc/InterfaceGenerator
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18351/InterfaceGenerator
Modified Files:
ExportModule.hs
Log Message:
Add a hack to deal with the fact that NSObject is it's own meta-class.
Make all instance methods of NSObject also be class methods.
Index: ExportModule.hs
===================================================================
RCS file: /cvsroot/hoc/hoc/InterfaceGenerator/ExportModule.hs,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- ExportModule.hs 5 Oct 2005 02:55:49 -0000 1.9
+++ ExportModule.hs 20 Mar 2006 06:33:50 -0000 1.10
@@ -16,7 +16,7 @@
import Data.Set(setToList, unionManySets, mkSet, intersect)
import qualified Data.HashTable as HashTable
-import Data.List(nub, partition, isPrefixOf)
+import Data.List(nub, partition, isPrefixOf, group, sort)
import Data.Maybe(fromMaybe, catMaybes, mapMaybe, maybeToList, isNothing)
import qualified Data.Map as Map (lookup, findWithDefault)
import Text.PrettyPrint.HughesPJ
@@ -164,12 +164,24 @@
| Right mangledSel <- selsToDefine ]
methodInstances :: [ (String, String) ]
- methodInstances = mkDecls id instanceSels
- ++ mkDecls (++ "Class") classSels
+ methodInstances = map head . group . sort $
+ instanceDecls
+ ++ classDecls
+ ++ nsObjectHackDecls
where
mkDecls f classesAndSels = concat [ [(msMangled sel, f cls) | sel <- sels ]
| (cls, sels) <- classesAndSels ]
-
+
+ instanceDecls = mkDecls id instanceSels
+ classDecls = mkDecls (++ "Class") classSels
+
+ -- HACK for NSObject.
+ -- NSObject is it's own meta-class; that's hard to model
+ -- in our type system, so we just automatically make every
+ -- instance method of NSObject a class method, too.
+ nsObjectHackDecls = [ (sel, "NSObjectClass")
+ | (sel, "NSObject") <- instanceDecls ]
+
exportedSelNames = map msMangled selsToDefineOrImport
exportedSels = concatMap idsForSel exportedSelNames
exportedSelSet = mkSet exportedSelNames
|