[darwinbuild-changes] [9] trunk/darwinxref/DBDataStore.c

source_changes at macosforge.org source_changes at macosforge.org
Wed Oct 4 01:36:44 PDT 2006


Revision: 9
          http://trac.macosforge.org/projects/darwinbuild/changeset/9
Author:   kevin
Date:     2006-10-04 01:36:44 -0700 (Wed, 04 Oct 2006)

Log Message:
-----------
- Added inheritance to builds

Modified Paths:
--------------
    trunk/darwinxref/DBDataStore.c

Modified: trunk/darwinxref/DBDataStore.c
===================================================================
--- trunk/darwinxref/DBDataStore.c	2005-06-03 21:07:09 UTC (rev 8)
+++ trunk/darwinxref/DBDataStore.c	2006-10-04 08:36:44 UTC (rev 9)
@@ -223,7 +223,7 @@
 	return res;
 }
 
-CFStringRef DBCopyPropString(void* session, CFStringRef build, CFStringRef project, CFStringRef property) {
+CFStringRef _DBCopyPropString(void* session, CFStringRef build, CFStringRef project, CFStringRef property) {
 	char* cbuild = strdup_cfstr(build);
 	char* cproj = strdup_cfstr(project);
 	char* cprop = strdup_cfstr(property);
@@ -239,7 +239,7 @@
 	return res;
 }
 
-CFArrayRef DBCopyPropArray(void* session, CFStringRef build, CFStringRef project, CFStringRef property) {
+CFArrayRef _DBCopyPropArray(void* session, CFStringRef build, CFStringRef project, CFStringRef property) {
 	char* cbuild = strdup_cfstr(build);
 	char* cproj = strdup_cfstr(project);
 	char* cprop = strdup_cfstr(property);
@@ -255,9 +255,7 @@
 	return res;
 }
 
-
-
-CFDictionaryRef DBCopyPropDictionary(void* session, CFStringRef build, CFStringRef project, CFStringRef property) {
+CFDictionaryRef _DBCopyPropDictionary(void* session, CFStringRef build, CFStringRef project, CFStringRef property) {
 	char* cbuild = strdup_cfstr(build);
 	char* cproj = strdup_cfstr(project);
 	char* cprop = strdup_cfstr(property);
@@ -273,6 +271,61 @@
 	return res;
 }
 
+//
+// Kluge to globally support build aliases ("original") and inheritance ("inherits") properties.
+//
+CFTypeRef _DBCopyPropWithInheritance(void* session, CFStringRef build, CFStringRef project, CFStringRef property,
+	CFTypeRef (*func)(void*, CFStringRef, CFStringRef, CFStringRef)) {
+
+	CFTypeRef res = NULL;
+
+	CFMutableArrayRef builds = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
+	CFArrayAppendValue(builds, build);
+
+	CFStringRef original = NULL;
+
+	// Look for the property in the current build and all inheritied builds
+	// if a build alias ("original") is found, break out of the search path
+	// and restart using the original name instead.
+	do {
+		res = func(session, build, project, property);
+		if (res) break;
+		
+		original = _DBCopyPropString(session, build, project, CFSTR("original"));
+		if (original) break;
+
+		CFStringRef inherits = _DBCopyPropString(session, build, NULL, CFSTR("inherits"));
+		if (inherits) CFArrayAppendValue(builds, inherits);
+		build = inherits;
+	} while (build != NULL);
+
+	if (res == NULL && original != NULL) {
+		CFIndex i, count = CFArrayGetCount(builds);
+		for (i = 0; i < count; ++i) {
+			build = CFArrayGetValueAtIndex(builds, i);
+			res = func(session, build, original, property);
+			if (res) break;
+		}
+	}
+	if (builds) CFRelease(builds);
+	if (original) CFRelease(original);
+	return res;
+}
+
+
+CFStringRef DBCopyPropString(void* session, CFStringRef build, CFStringRef project, CFStringRef property) {
+	return (CFStringRef)_DBCopyPropWithInheritance(session, build, project, property, (void*)_DBCopyPropString);
+}
+
+CFArrayRef DBCopyPropArray(void* session, CFStringRef build, CFStringRef project, CFStringRef property) {
+	return (CFArrayRef)_DBCopyPropWithInheritance(session, build, project, property, (void*)_DBCopyPropArray);
+}
+
+CFDictionaryRef DBCopyPropDictionary(void* session, CFStringRef build, CFStringRef project, CFStringRef property) {
+	return (CFDictionaryRef)_DBCopyPropWithInheritance(session, build, project, property, (void*)_DBCopyPropDictionary);
+}
+
+
 int DBSetProp(void* session, CFStringRef build, CFStringRef project, CFStringRef property, CFTypeRef value) {
 	int res = 0;
 	CFTypeID type = DBCopyPropType(session, property);

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20061004/29ab5baf/attachment.html


More information about the darwinbuild-changes mailing list