Commits

Anonymous committed fe8a005

Really updated the WebServicesTool stuff. May have debugging cruft.

Cleaned up test cases.

  • Participants
  • Parent commits 4aa893c

Comments (0)

Files changed (4)

pyobjc/Examples/WebServicesTool/WSTApplicationDelegateClass.py

 from WSTConnectionWindowControllerClass import WSTConnectionWindowController
 
 class WSTApplicationDelegate (NSObject):
-	def newConnectionAction_(self, sender):
-		WSTConnectionWindowController.connectionWindowController().showWindow_(sender)
+  def newConnectionAction_(self, sender):
+    WSTConnectionWindowController.connectionWindowController().showWindow_(sender)
 
-	def applicationDidFinishLaunching_(self, aNotification):
-		self.newConnectionAction_(None)
+  def applicationDidFinishLaunching_(self, aNotification):
+    print "foo"
+    self.newConnectionAction_(None)
+    print "bar"

pyobjc/Examples/WebServicesTool/WSTConnectionWindowControllerClass.py

         '_methodPrefix' )
     
     def connectionWindowController(self):
+        print "Creating window controller...."
         return WSTConnectionWindowController.alloc().init()
            
     def init(self):
+        print "Into"
+
         self = self.initWithWindowNibName_("WSTConnection")
+
+        print "next"
         
         self._toolbarItems = NSMutableDictionary.alloc().init()
         self._toolbarDefaultItemIdentifiers = NSMutableArray.alloc().init()
         self._toolbarAllowedItemIdentifiers = NSMutableArray.alloc().init()
+
+        print "bob"
         
         self._methods = []
+
+        print "Initialized window controller..."
                 
         return self
     

pyobjc/Examples/WebServicesTool/main-bin-python.m

 #import <sys/param.h>
 #import <unistd.h>
 
-int pyobjc_main(int argc, char * const *argv, char *envp[])
+int pyobjc_main(int argc, char * const *argv, char * const *envp)
 {
   [[NSAutoreleasePool alloc] init];
 
   const char **childArgv = alloca(sizeof(char *) * (argc + 5));
+  char **childEnvp = (char **)envp;
   const char *pythonBinPathPtr;
   const char *mainPyPathPtr;
   NSEnumerator *bundleEnumerator = [[NSBundle allFrameworks] reverseObjectEnumerator];
   NSBundle *aBundle;
-  NSMutableArray *bundlePaths = [[NSMutableArray array] retain];
+  NSBundle *mainBundle = [NSBundle mainBundle];
+  NSMutableArray *bundlePaths = [NSMutableArray array];
   int i;
 
+  if ( !getenv("DYLD_FRAMEWORK_PATH") ) {
+    NSArray *paths = [NSArray arrayWithObjects: [mainBundle sharedFrameworksPath], [mainBundle privateFrameworksPath], nil];
+    NSString *joinedPaths = [paths componentsJoinedByString: @":"];
+    const char *dyldFrameworkPath = [[NSString stringWithFormat: @"DYLD_FRAMEWORK_PATH=%@", joinedPaths] UTF8String];
+    const char *dyldLibraryPath = [[NSString stringWithFormat: @"DYLD_LIBRARY_PATH=%@", joinedPaths] UTF8String];
+
+    for(i=0; envp[i]; i++);
+    childEnvp = malloc( sizeof(char *) * (i+5) );
+
+    bcopy( envp, childEnvp, ( i * sizeof(char *) ) );
+
+    childEnvp[i++] = (char *)dyldFrameworkPath;
+    childEnvp[i++] = (char *)dyldLibraryPath;
+    //!    childEnvp[i++] = "DYLD_NO_FIX_PREBINDING=1";  Can't decide if this is a good idea.
+    if ([[NSUserDefaults standardUserDefaults] boolForKey: @"DYLD_PRINT_LIBRARIES"])
+      childEnvp[i++] = (char *)"DYLD_PRINT_LIBRARIES=1";
+    childEnvp[i++] = NULL;
+  }
+
   while ( aBundle = [bundleEnumerator nextObject] ) {
     if ( [[[aBundle bundlePath] pathExtension] isEqualToString: @"framework"] )
       [bundlePaths addObject: [aBundle bundlePath]];
 
   NSString *pythonBinPath = [[NSUserDefaults standardUserDefaults] stringForKey: @"PythonBinPath"];
   pythonBinPath = pythonBinPath ? pythonBinPath : @"/usr/bin/python";
-  [pythonBinPath retain];
   pythonBinPathPtr = [pythonBinPath UTF8String];
 
-  NSString *mainPyFile = [[[NSBundle mainBundle] infoDictionary] objectForKey: @"PrincipalPythonFile"];
+  NSString *mainPyFile = [[mainBundle infoDictionary] objectForKey: @"PrincipalPythonFile"];
   NSString *mainPyPath = nil;
 
   if (mainPyFile)
-    mainPyPath = [[NSBundle mainBundle] pathForResource: mainPyFile ofType: nil];
+    mainPyPath = [mainBundle pathForResource: mainPyFile ofType: nil];
 
   if ( !mainPyPath )
-    mainPyPath = [[NSBundle mainBundle] pathForResource: @"Main.py" ofType: nil];
+    mainPyPath = [mainBundle pathForResource: @"Main.py" ofType: nil];
 
   if ( !mainPyPath )
     [NSException raise: NSInternalInconsistencyException
                 format: @"%s:%d pyobjc_main() Failed to find main python entry point for application.  Exiting.", __FILE__, __LINE__];
-  [mainPyPath retain];
   mainPyPathPtr = [mainPyPath UTF8String];
 
   childArgv[0] = argv[0];
   childArgv[i+2] = [[bundlePaths componentsJoinedByString: @":"] UTF8String];
   childArgv[i+3] = NULL;
 
-  return execve(pythonBinPathPtr, (char **)childArgv, envp);
+  if ([[[NSProcessInfo processInfo] environment] objectForKey: @"SHOWPID"])
+    NSLog(@"Process ID is: %d (\n\tgdb %s %d\n to debug)", getpid(), pythonBinPathPtr, getpid());
+
+  return execve(pythonBinPathPtr, (char **)childArgv, childEnvp);
 }
 
-int main(int argc, char * const *argv, char *envp[])
+int main(int argc, char * const *argv, char * const *envp)
 {
   return pyobjc_main(argc, argv, envp);
 }

pyobjc/Lib/objc/test/test_objc.py

 
 import objc
 
-class Test_lookup_class(unittest.TestCase):
-    def testNoSuchClassErrorRaised(self):
+class TestBOOL(unittest.TestCase):
+    def testBooleans(self):
+        self.assert_( objc.YES, "YES was not true." )
+        self.assert_( not objc.NO, "NO was true." )
+    
+class TestClassLookup(unittest.TestCase):
+    def testLookupClassNoSuchClassErrorRaised(self):
         self.assertRaises( objc.nosuchclass_error, objc.lookup_class, "" )
         self.assertRaises( objc.nosuchclass_error, objc.lookup_class, "ThisClassReallyShouldNotExist" )
         self.assertRaises( TypeError, objc.lookup_class, 1 )
 
-    def testNSObject(self):
-        self.assert_( objc.lookup_class("NSObject"), "Failed to find NSObject class." )
-        self.assertEqual( objc.lookup_class( "NSObject" ), objc.runtime.NSObject,
-                          "objc.runtime.NSObject and objc.lookup_class('NSObject') were different." )
-
-class Test_runtime(unittest.TestCase):
-    def testNoSuchClassErrorRaised(self):
+    def testRuntimeNoSuchClassErrorRaised(self):
         try:
             objc.runtime.ThisClassReallyShouldNotExist
         except objc.nosuchclass_error:
         else:
             fail("objc.runtime.ThisClassReallyShouldNotExist should have thrown a nosuchclass_error.  It didn't.")
 
-    def testNSObject(self):
-        self.assert_( objc.runtime.NSObject, "Failed to find NSObject class." )
-        self.assertEqual( objc.runtime.NSObject, objc.lookup_class( "NSObject" ),
+    def testRuntimeConsistency(self):
+        self.assert_( objc.lookup_class("NSObject"), "Failed to find NSObject class." )
+        self.assertEqual( objc.lookup_class( "NSObject" ), objc.runtime.NSObject,
                           "objc.runtime.NSObject and objc.lookup_class('NSObject') were different." )
 
-class Test_Object_Instantiation(unittest.TestCase):
+    def testClassList(self):
+        ###! This test should probably be moved down to the Foundation test suite... 
+        self.assert_( objc.runtime.NSObject in objc.class_list(), "class_list() does not appear to contain NSObject class" )
+        self.assert_( objc.runtime.NSException in objc.class_list(), "class_list() does not appear to contain NSException class" )
+        self.assert_( objc.runtime.NSMutableArray in objc.class_list(), "class_list() does not appear to contain NSMutableArray class" )
+
+class TestObjectInstantiation(unittest.TestCase):
     def testInstantiation(self):
         anInstance = objc.runtime.NSObject.new()
         self.assert_( anInstance, "Failed to instantiate an instance" )
         self.assert_( isinstance( anInstance, objc.runtime.NSObject ), "Instantiated object not an instance of NSObject." )
         self.assert_( anInstance.isEqual_( anInstance ), "Instance !isEqual: to itself." )
 
-class Test_method_invocation(unittest.TestCase):
+class TestMethodInvocation(unittest.TestCase):
     def setUp(self):
         self.NSObjectInstance = objc.runtime.NSObject.alloc()
 
 
 def suite():
     suite = unittest.TestSuite()
-    suite.addTest(unittest.makeSuite(Test_lookup_class))
-    suite.addTest(unittest.makeSuite(Test_runtime))
-    suite.addTest(unittest.makeSuite(Test_Object_Instantiation))
-    suite.addTest(unittest.makeSuite(Test_method_invocation))
+    suite.addTest( unittest.makeSuite( TestBOOL ) )
+    suite.addTest( unittest.makeSuite( TestClassLookup ) )
+    suite.addTest( unittest.makeSuite( TestObjectInstantiation ) )
+    suite.addTest( unittest.makeSuite( TestMethodInvocation ) )
     return suite
 
 if __name__ == '__main__':