[SVN] plist.c: Changes for Ruby 1.9

Charles Turner vze26m98 at optonline.net
Thu Aug 28 18:08:21 UTC 2008


This diff file shows the patches I made to get the plist bundle to work 
with
ruby 1.9.0 (2007-12-25 revision 14709) [i686-darwin9.4.0]

I made no attempt to write code that compiled for another Ruby version. 
Zip of the diff attached below.

-Charles

--- /Library/Application Support/TextMate/Support/lib/osx/plist/plist.c
+++ plist.c
@@ -165,14 +165,14 @@
 		// even though binary shouldn't be < 6 characters
 		UInt8 *bytes;
 		int len;
-		if (RSTRING_LEN(buffer) < 6) {
+		if (RSTRING(buffer)->len < 6) {
 			bytes = ALLOC_N(UInt8, 6);
 			memset(bytes, '\n', 6);
-			MEMCPY(bytes, RSTRING_PTR(buffer), UInt8, RSTRING_LEN(buffer));
+			MEMCPY(bytes, RSTRING(buffer)->ptr, UInt8, RSTRING(buffer)->len);
 			len = 6;
 		} else {
-			bytes = (UInt8 *)RSTRING_PTR(buffer);
-			len = RSTRING_LEN(buffer);
+			bytes = (UInt8 *)RSTRING(buffer)->ptr;
+			len = RSTRING(buffer)->len;
 		}
 		CFReadStreamRef readStream = 
CFReadStreamCreateWithBytesNoCopy(kCFAllocatorDefault, bytes, len, 
kCFAllocatorNull);
 		CFReadStreamOpen(readStream);
@@ -181,7 +181,7 @@
 		CFRelease(readStream);
 	} else {
 		// Format wasn't requested
-		CFDataRef data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, 
(const UInt8*)RSTRING_PTR(buffer), RSTRING_LEN(buffer), 
kCFAllocatorNull);
+		CFDataRef data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, 
(const UInt8*)RSTRING(buffer)->ptr, RSTRING(buffer)->len, 
kCFAllocatorNull);
 		plist = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, data, 
kCFPropertyListImmutable, &error);
 		CFRelease(data);
 	}
@@ -455,15 +455,15 @@
 	if (RTEST(str_blob(obj))) {
 		// convert to CFDataRef
 		StringValue(obj);
-		CFDataRef data = CFDataCreate(kCFAllocatorDefault, (const 
UInt8*)RSTRING_PTR(obj), (CFIndex)RSTRING_LEN(obj));
+		CFDataRef data = CFDataCreate(kCFAllocatorDefault, (const 
UInt8*)RSTRING(obj)->ptr, (CFIndex)RSTRING(obj)->len);
 		return data;
 	} else {
 		// convert to CFStringRef
 		StringValue(obj);
-		CFStringRef string = CFStringCreateWithBytes(kCFAllocatorDefault, 
(const UInt8*)RSTRING_PTR(obj), (CFIndex)RSTRING_LEN(obj), 
kCFStringEncodingUTF8, false);
+		CFStringRef string = CFStringCreateWithBytes(kCFAllocatorDefault, 
(const UInt8*)RSTRING(obj)->ptr, (CFIndex)RSTRING(obj)->len, 
kCFStringEncodingUTF8, false);
 		if (!string) {
 			// try MacRoman
-			string = CFStringCreateWithBytes(kCFAllocatorDefault, (const 
UInt8*)RSTRING_PTR(obj), (CFIndex)RSTRING_LEN(obj), 
kCFStringEncodingMacRoman, false);
+			string = CFStringCreateWithBytes(kCFAllocatorDefault, (const 
UInt8*)RSTRING(obj)->ptr, (CFIndex)RSTRING(obj)->len, 
kCFStringEncodingMacRoman, false);
 		}
 		return string;
 	}
@@ -481,9 +481,9 @@
 
 // Converts a Hash to a CFDictionaryREf
 CFDictionaryRef convertHash(VALUE obj) {
-	CFIndex count = (CFIndex)RHASH_TBL(obj)->num_entries;
+	CFIndex count = (CFIndex)RHASH(obj)->tbl->num_entries;
 	CFMutableDictionaryRef dict = 
CFDictionaryCreateMutable(kCFAllocatorDefault, count, 
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
-	st_foreach(RHASH_TBL(obj), iterateHash, (VALUE)dict);
+	st_foreach(RHASH(obj)->tbl, iterateHash, (VALUE)dict);
 	return dict;
 }
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plist-1.9.diff.zip
Type: application/zip
Size: 1466 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate-dev/attachments/20080828/c0cae37b/attachment.zip>


More information about the textmate-dev mailing list