Permalink
Browse files

ObjCBridge related updates and cleanup

  • Loading branch information...
1 parent 029e0ad commit baac7e06801699facc27c25777ca0c0063856be4 @stevedekorte committed Jul 26, 2011
Showing with 82,323 additions and 4,299 deletions.
  1. +1 −0 addons/ObjcBridge/CMakeLists.txt
  2. +1 −0 addons/ObjcBridge/source/Io2Objc.m
  3. +23 −0 addons/ObjcBridge/source/IoLanguage.h
  4. +130 −0 addons/ObjcBridge/source/IoLanguage.m
  5. +7 −4 addons/ObjcBridge/source/IoObjcBridge.m
  6. +2 −0 addons/ObjcBridge/source/Objc2Io.h
  7. +9 −3 addons/ObjcBridge/source/Objc2Io.m
  8. +1 −1 addons/ObjcBridge/source/extra/Io_NSApplicationMain.m
  9. +1 −1 addons/OpenGL/source/IoVector_gl.c
  10. +2 −1 addons/ReadLine/source/IoReadLine.c
  11. +4 −4 build/CPackConfig.cmake
  12. +5 −5 build/CPackSourceConfig.cmake
  13. +13 −0 extras/IoLanguageKit/IoLangKit.h
  14. +24 −0 extras/IoLanguageKit/IoLangKit.m
  15. +1,298 −0 extras/IoLanguageKit/IoLanguageKit.xcodeproj/project.pbxproj
  16. +7 −0 extras/IoLanguageKit/IoLanguageKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  17. +15,826 −0 ...uageKit.xcodeproj/project.xcworkspace/xcuserdata/steve.xcuserdatad/UserInterfaceState.xcuserstate
  18. +10 −0 ...nguageKit.xcodeproj/project.xcworkspace/xcuserdata/steve.xcuserdatad/WorkspaceSettings.xcsettings
  19. +58 −0 ...LanguageKit/IoLanguageKit.xcodeproj/xcuserdata/steve.xcuserdatad/xcschemes/IoLanguageKit.xcscheme
  20. +22 −0 ...nguageKit/IoLanguageKit.xcodeproj/xcuserdata/steve.xcuserdatad/xcschemes/xcschememanagement.plist
  21. +30 −0 extras/IoLanguageKit/IoLanguageKit/IoLanguageKit-Info.plist
  22. +7 −0 extras/IoLanguageKit/IoLanguageKit/IoLanguageKit-Prefix.pch
  23. +2 −0 extras/IoLanguageKit/IoLanguageKit/en.lproj/InfoPlist.strings
  24. +16 −0 extras/IoLanguageKit/cleanup.io
  25. +370 −0 extras/IoTest/IoTest.xcodeproj/project.pbxproj
  26. +7 −0 extras/IoTest/IoTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  27. +6,890 −0 .../IoTest.xcodeproj/project.xcworkspace/xcuserdata/steve.xcuserdatad/UserInterfaceState.xcuserstate
  28. +91 −0 extras/IoTest/IoTest.xcodeproj/xcuserdata/steve.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
  29. +72 −0 extras/IoTest/IoTest.xcodeproj/xcuserdata/steve.xcuserdatad/xcschemes/IoTest.xcscheme
  30. +22 −0 extras/IoTest/IoTest.xcodeproj/xcuserdata/steve.xcuserdatad/xcschemes/xcschememanagement.plist
  31. +34 −0 extras/IoTest/IoTest/IoTest-Info.plist
  32. +7 −0 extras/IoTest/IoTest/IoTest-Prefix.pch
  33. +17 −0 extras/IoTest/IoTest/IoTestAppDelegate.h
  34. +82 −0 extras/IoTest/IoTest/IoTestAppDelegate.m
  35. +29 −0 extras/IoTest/IoTest/en.lproj/Credits.rtf
  36. +2 −0 extras/IoTest/IoTest/en.lproj/InfoPlist.strings
  37. +4,039 −0 extras/IoTest/IoTest/en.lproj/MainMenu.xib
  38. +14 −0 extras/IoTest/IoTest/main.m
  39. +10 −0 extras/osxmain/osxmain.xcodeproj/project.pbxproj
  40. +7 −0 extras/osxmain/osxmain.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  41. +8,186 −0 ...osxmain.xcodeproj/project.xcworkspace/xcuserdata/steve.xcuserdatad/UserInterfaceState.xcuserstate
  42. +76 −0 extras/osxmain/osxmain.xcodeproj/xcuserdata/steve.xcuserdatad/xcschemes/osxmain.xcscheme
  43. +22 −0 extras/osxmain/osxmain.xcodeproj/xcuserdata/steve.xcuserdatad/xcschemes/xcschememanagement.plist
  44. +3 −48 extras/osxvm/osxvm.xcodeproj/project.pbxproj
  45. +44,398 −4,017 ...m/osxvm.xcodeproj/project.xcworkspace/xcuserdata/steve.xcuserdatad/UserInterfaceState.xcuserstate
  46. +153 −0 extras/osxvm/osxvm.xcodeproj/xcuserdata/steve.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
  47. +1 −1 libs/basekit/source/CHash_inline.h
  48. +6 −3 libs/basekit/source/Common_inline.h
  49. +7 −7 libs/basekit/source/Date.c
  50. +3 −3 libs/basekit/source/List.c
  51. +2 −22 libs/basekit/source/List_inline.h
  52. +1 −1 libs/basekit/source/PointerHash_inline.h
  53. +12 −12 libs/basekit/source/PortableStrptime.c
  54. +1 −1 libs/basekit/source/RandomGen.c
  55. +4 −4 libs/basekit/source/Stack.c
  56. +1 −1 libs/basekit/source/Stack_inline.h
  57. +7 −5 libs/basekit/source/UArray.c
  58. +10 −8 libs/basekit/source/UArray.h
  59. +2 −2 libs/basekit/source/UArray_character.c
  60. +1 −1 libs/basekit/source/UArray_format.c
  61. +2 −2 libs/basekit/source/UArray_math.c
  62. +2 −2 libs/basekit/source/UArray_stream.c
  63. +12 −10 libs/basekit/source/UArray_string.c
  64. +1 −1 libs/basekit/source/UArray_utf.c
  65. +5 −5 libs/basekit/source/cencode.c
  66. +2 −2 libs/basekit/source/ucs2.c
  67. +2 −1 libs/coroutine/source/Coro.c
  68. +5 −1 libs/coroutine/source/context.c
  69. +2 −1 libs/garbagecollector/source/Collector.c
  70. +7 −0 libs/iovm/io/Directory.io
  71. +5 −3 libs/iovm/source/IoBlock.c
  72. +1 −0 libs/iovm/source/IoBlock.h
  73. +5 −3 libs/iovm/source/IoCFunction.c
  74. +4 −2 libs/iovm/source/IoCall.c
  75. +3 −1 libs/iovm/source/IoCollector.c
  76. +4 −2 libs/iovm/source/IoCoroutine.c
  77. +5 −3 libs/iovm/source/IoDate.c
  78. +5 −2 libs/iovm/source/IoDirectory.c
  79. +4 −2 libs/iovm/source/IoDuration.c
  80. +11 −9 libs/iovm/source/IoDynLib.c
  81. +4 −2 libs/iovm/source/IoError.c
  82. +8 −5 libs/iovm/source/IoFile.c
  83. +3 −3 libs/iovm/source/IoLexer.c
  84. +18 −16 libs/iovm/source/IoList.c
  85. +4 −2 libs/iovm/source/IoMap.c
  86. +7 −6 libs/iovm/source/IoMessage.c
  87. +6 −4 libs/iovm/source/IoNumber.c
  88. +8 −6 libs/iovm/source/IoObject.c
  89. +2 −2 libs/iovm/source/IoObject_inline.h
  90. +2 −0 libs/iovm/source/IoProfiler.c
  91. +3 −2 libs/iovm/source/IoSandbox.c
  92. +3 −2 libs/iovm/source/IoSeq.c
  93. +34 −24 libs/iovm/source/IoSeq_immutable.c
  94. +3 −3 libs/iovm/source/IoSeq_mutable.c
  95. +33 −11 libs/iovm/source/IoState.c
  96. +2 −2 libs/iovm/source/IoState.h
  97. +3 −2 libs/iovm/source/IoWeakLink.c
  98. +5 −0 makePackage.io
@@ -28,6 +28,7 @@ set(SRCS
"${CMAKE_CURRENT_SOURCE_DIR}/source/Objc2Io.m"
"${CMAKE_CURRENT_SOURCE_DIR}/source/ObjcSubclass.m"
"${CMAKE_CURRENT_SOURCE_DIR}/source/Runtime.m"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoLanguage.m"
)
set(CMAKE_EXE_LINKER_FLAGS "-framework AppKit")
@@ -429,6 +429,7 @@ BOOL respondsToSelector(id self, SEL sel, SEL selector)
return result;
}
+
/*IoObject *Io2Objc_print(Io2Objc *self, IoObject *locals, IoMessage *m)
{
printf("%s", [[DATA(self)->object description] cString]);
@@ -0,0 +1,23 @@
+//
+// IoLanguage.h
+// IoLanguageKit
+//
+// Created by Stephen Dekorte on 20110720.
+// Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "IoState.h"
+
+@interface IoLanguage : NSObject
+{
+ IoState *state;
+ id delegate;
+}
+
+- (void)setDelegate:anObject;
+- delegate;
+
+- doString:(NSString *)s;
+
+@end
@@ -0,0 +1,130 @@
+//
+// IoLanguage.m
+// IoLanguageKit
+//
+// Created by Stephen Dekorte on 20110720.
+// Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import "IoLanguage.h"
+#import "IoObjcBridge.h"
+#import "IoNumber.h"
+#import "Objc2Io.h"
+#import "Io2Objc.h"
+
+@protocol IoLanguageDelegate
+- (void)printCallback:(NSString *)s;
+- (void)exceptionCallback:anObject;
+- (void)exitCallback:(int)r;
+- (void)activeCoroCallback:(int)r;
+@end
+
+
+@implementation IoLanguage
+
+//void IoAddonsInit(IoObject *context);
+//IoState_setBindingsInitCallback(self, (IoStateBindingsInitCallback *)IoAddonsInit);
+
+void IoObjcBridgeInit(IoObject *context);
+
+void IoLanguageStateBindingsInitCallback(void *context, void *state)
+{
+ IoObjcBridgeInit(state);
+}
+
+void IoLanguageStatePrintCallback(void *context, const UArray *array)
+{
+ id self = (id)context;
+ if([self delegate] && [[self delegate] respondsToSelector:@selector(printCallback:)])
+ {
+ [[self delegate] printCallback:[NSString stringWithUTF8String:(const char *)UArray_bytes(array)]];
+ }
+}
+
+void IoLanguageStateExceptionCallback(void *context, IoObject *ioObj)
+{
+ id self = (id)context;
+ if([self delegate] && [[self delegate] respondsToSelector:@selector(exceptionCallback:)])
+ {
+ [[self delegate] exceptionCallback:nil];
+ }
+}
+
+void IoLanguageStateExitCallback(void *context, int r)
+{
+ id self = (id)context;
+ if([self delegate] && [[self delegate] respondsToSelector:@selector(IoStateExitCallback:)])
+ {
+ [[self delegate] exitCallback:r];
+ }
+}
+
+void ILanguageoStateActiveCoroCallback(void *context, int r)
+{
+ id self = (id)context;
+ if([self delegate] && [[self delegate] respondsToSelector:@selector(IoStateExitCallback:)])
+ {
+ [[self delegate] activeCoroCallback:r];
+ }
+}
+
+- init
+{
+ state = IoState_new();
+ //IoState_argc_argv_(self, argc, argv);
+ IoState_callbackContext_(state, (void *)self);
+ IoState_setBindingsInitCallback(state, IoLanguageStateBindingsInitCallback);
+ IoState_printCallback_(state, IoLanguageStatePrintCallback);
+ //IoState_activeCoroCallback_(state, ILanguageoStateActiveCoroCallback);
+ IoState_exitCallback_(state, IoLanguageStateExitCallback);
+ IoState_init(state);
+ return self;
+}
+
+- (void)dealloc
+{
+ IoState_free(state);
+ [super dealloc];
+}
+
+- (void)setDelegate:anObject
+{
+ delegate = anObject;
+}
+
+- delegate
+{
+ return delegate;
+}
+
+- doString:(NSString *)s
+{
+ IoObject *result = IoState_doCString_(state, [s UTF8String]);
+
+ if(ISSEQ(result)) // a string?
+ {
+ return [NSString stringWithUTF8String:(const char *)IoSeq_rawBytes(result)];
+ }
+
+ if (ISNUMBER(result)) // a number
+ {
+ return [NSNumber numberWithDouble:IoNumber_asDouble(result)];
+ }
+
+ if (ISIO2OBJC(result)) // a io proxy to objc? return the objc object
+ {
+ return Io2Objc_object(result);
+ }
+
+ if(result) // unknown Io object? return a proxy to it
+ {
+ Objc2Io *objc2io = [[[Objc2Io alloc] init] autorelease];
+ [objc2io setIoObject:result];
+ [objc2io setBridge:IoObjcBridge_sharedBridge()];
+ return objc2io;
+ }
+
+ return nil;
+}
+
+@end
@@ -13,6 +13,8 @@
#include "IoNumber.h"
#include "Io2Objc.h"
#include "Objc2Io.h"
+#include "Hash_superfast.h"
+#include "Hash_murmur.h"
int Pointer_equals_(void *v1, void *v2)
@@ -31,7 +33,7 @@ uintptr_t Pointer_murmurHash(const void *v)
}
-
+static const char *protoId = "ObjcBridge";
#define DATA(self) ((IoObjcBridgeData *)IoObject_dataPointer(self))
@@ -106,7 +108,7 @@ uintptr_t Pointer_murmurHash(const void *v)
sharedBridge = self;
- IoState_registerProtoWithFunc_(state, self, IoObjcBridge_proto);
+ IoState_registerProtoWithFunc_(state, self, protoId);
{
IoMethodTable methodTable[] = {
@@ -134,12 +136,13 @@ uintptr_t Pointer_murmurHash(const void *v)
IoObjcBridge *IoObjcBridge_new(void *state)
{
- return IoState_protoWithInitFunction_(state, IoObjcBridge_proto);
+ return sharedBridge;
+ //return IoState_protoWithInitFunction_(state, protoId);
}
void IoObjcBridge_free(IoObjcBridge *self)
{
- sharedBridge = NULL;
+ //sharedBridge = NULL;
CHASH_FOREACH(DATA(self)->objc2ios, k, v, [(id)v autorelease]);
CHASH_FOREACH(DATA(self)->io2objcs, k, v, Io2Objc_nullObjcBridge(v));
@@ -12,6 +12,8 @@
#include "IoObjcBridge.h"
#include "Runtime.h"
+#define ISOBJC2IO(self) IoObject_hasCloneFunc_(self, (IoTagCloneFunc *)Objc2Io_rawClone)
+
@interface Objc2Io : NSObject // NSProxy
{
IoObjcBridge *bridge;
@@ -1,5 +1,5 @@
-/* Copyright (c) 2003, Steve Dekorte
-* All rights reserved. See _BSDLicense.txt.
+/* Copyright (c) 2003, Steve Dekorte
+* All rights reserved. See _BSDLicense.txt.
*/
#include "Objc2Io.h"
@@ -11,6 +11,7 @@ @implementation Objc2Io
- init
{
self = [super init];
+ bridge = IoObjcBridge_sharedBridge();
//[obj retain]; // debug test
return self;
}
@@ -68,7 +69,7 @@ - (BOOL)respondsToSelector:(SEL)selector
- (NSMethodSignature *)methodSignatureForSelector:(SEL)selector
{
- if(IoObjcBridge_rawDebugOn(IoObjcBridge_sharedBridge()))
+ if(IoObjcBridge_rawDebugOn(bridge))
{
printf("methodSignatureForSelector(%s)\n", [NSStringFromSelector(selector) UTF8String]);
}
@@ -142,4 +143,9 @@ - (void)forwardInvocation:(NSInvocation *)invocation
}
}
+- (NSString *)description
+{
+ return [NSString stringWithUTF8String:IoObject_name(ioValue)];
+}
+
@end
@@ -6,7 +6,7 @@
{
NSString *path = [[[NSBundle mainBundle] resourcePath]
stringByAppendingPathComponent:@"main.io"];
- IoState_doFile_(state, (char *)[path cString]);
+ IoState_doFile_(state, (char *)[path UTF8String]);
NSApplicationMain(state->mainArgs->argc, (const char **)state->mainArgs->argv);
return 0x0;
@@ -13,7 +13,7 @@
void IoVector_glInit(IoObject *context)
{
IoState *state = IoObject_state(context);
- IoObject *self = IoState_protoWithInitFunction_(state, IoSeq_proto);
+ IoObject *self = IoSeq_new(state);
{
IoMethodTable methodTable[] = {
@@ -13,6 +13,7 @@ Binding to GNU readline.
#include "IoReadLine.h"
+static const char *protoId = "ReadLine";
IoTag *IoReadLine_newTag(void *state)
{
@@ -43,7 +44,7 @@ IoReadLine *IoReadLine_proto(void *state)
rl_initialize();
using_history();
- IoState_registerProtoWithFunc_((IoState *)state, self, IoReadLine_proto);
+ IoState_registerProtoWithFunc_((IoState *)state, self, protoId);
IoObject_addMethodTable_(self, methodTable);
@@ -57,16 +57,16 @@ SET(CPACK_PACKAGE_CONTACT "iolanguage@yahoogroups.com")
SET(CPACK_PACKAGE_DEFAULT_LOCATION "/")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "/opt/local/share/cmake-2.8/Templates/CPack.GenericDescription.txt")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Io Language")
-SET(CPACK_PACKAGE_FILE_NAME "IoLanguage-2011.07.13-Darwin")
+SET(CPACK_PACKAGE_FILE_NAME "IoLanguage-2011.07.24-Darwin")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "IoLanguage")
-SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "IoLanguage 2011.07.13")
+SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "IoLanguage 2011.07.24")
SET(CPACK_PACKAGE_NAME "IoLanguage")
SET(CPACK_PACKAGE_RELOCATABLE "true")
SET(CPACK_PACKAGE_VENDOR "iolanguage.com")
-SET(CPACK_PACKAGE_VERSION "2011.07.13")
+SET(CPACK_PACKAGE_VERSION "2011.07.24")
SET(CPACK_PACKAGE_VERSION_MAJOR "2011")
SET(CPACK_PACKAGE_VERSION_MINOR "07")
-SET(CPACK_PACKAGE_VERSION_PATCH "13")
+SET(CPACK_PACKAGE_VERSION_PATCH "24")
SET(CPACK_RESOURCE_FILE_LICENSE "/Users/steve/Developer/opensource/io/license/bsd_license.txt")
SET(CPACK_RESOURCE_FILE_README "/opt/local/share/cmake-2.8/Templates/CPack.GenericDescription.txt")
SET(CPACK_RESOURCE_FILE_WELCOME "/opt/local/share/cmake-2.8/Templates/CPack.GenericWelcome.txt")
@@ -59,16 +59,16 @@ SET(CPACK_PACKAGE_CONTACT "iolanguage@yahoogroups.com")
SET(CPACK_PACKAGE_DEFAULT_LOCATION "/")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "/opt/local/share/cmake-2.8/Templates/CPack.GenericDescription.txt")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Io Language")
-SET(CPACK_PACKAGE_FILE_NAME "IoLanguage-2011.07.13-Source")
+SET(CPACK_PACKAGE_FILE_NAME "IoLanguage-2011.07.24-Source")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "IoLanguage")
-SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "IoLanguage 2011.07.13")
+SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "IoLanguage 2011.07.24")
SET(CPACK_PACKAGE_NAME "IoLanguage")
SET(CPACK_PACKAGE_RELOCATABLE "true")
SET(CPACK_PACKAGE_VENDOR "iolanguage.com")
-SET(CPACK_PACKAGE_VERSION "2011.07.13")
+SET(CPACK_PACKAGE_VERSION "2011.07.24")
SET(CPACK_PACKAGE_VERSION_MAJOR "2011")
SET(CPACK_PACKAGE_VERSION_MINOR "07")
-SET(CPACK_PACKAGE_VERSION_PATCH "13")
+SET(CPACK_PACKAGE_VERSION_PATCH "24")
SET(CPACK_RESOURCE_FILE_LICENSE "/Users/steve/Developer/opensource/io/license/bsd_license.txt")
SET(CPACK_RESOURCE_FILE_README "/opt/local/share/cmake-2.8/Templates/CPack.GenericDescription.txt")
SET(CPACK_RESOURCE_FILE_WELCOME "/opt/local/share/cmake-2.8/Templates/CPack.GenericWelcome.txt")
@@ -78,7 +78,7 @@ SET(CPACK_SOURCE_GENERATOR "TGZ;TBZ2;TZ")
SET(CPACK_SOURCE_IGNORE_FILES "/CVS/;/\\.svn/;/\\.bzr/;/\\.hg/;/\\.git/;\\.swp$;\\.#;/#")
SET(CPACK_SOURCE_INSTALLED_DIRECTORIES "/Users/steve/Developer/opensource/io;/")
SET(CPACK_SOURCE_OUTPUT_CONFIG_FILE "/Users/steve/Developer/opensource/io/build/CPackSourceConfig.cmake")
-SET(CPACK_SOURCE_PACKAGE_FILE_NAME "IoLanguage-2011.07.13-Source")
+SET(CPACK_SOURCE_PACKAGE_FILE_NAME "IoLanguage-2011.07.24-Source")
SET(CPACK_SOURCE_TBZ2 "ON")
SET(CPACK_SOURCE_TGZ "ON")
SET(CPACK_SOURCE_TOPLEVEL_TAG "Darwin-Source")
@@ -0,0 +1,13 @@
+//
+// IoLangKit.h
+// IoLanguageKit
+//
+// Created by Steve Dekorte on 20110723.
+// Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface IoLangKit : NSObject
+
+@end
@@ -0,0 +1,24 @@
+//
+// IoLangKit.m
+// IoLanguageKit
+//
+// Created by Steve Dekorte on 20110723.
+// Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import "IoLangKit.h"
+
+@implementation IoLangKit
+
+- (id)init
+{
+ self = [super init];
+ if (self)
+ {
+ // Initialization code here.
+ }
+
+ return self;
+}
+
+@end
Oops, something went wrong. Retry.

0 comments on commit baac7e0

Please sign in to comment.