* Source/Tests/TestDKMethod.m

Source/Tests/TestDKArgument.m:
  Tests for assignments in the initializers.
* Source/DKProxy.m
  Headers/DKProxy.h:
  -hasSameScopeAs: method to test whether two proxies fall into the scope of
  one and the same D-Bus service.
* Source/DKArgument.h: Expose a few accessors. 
* Source/DKArgument.m: Fix bug in the name assignment. Implement -name method.
  Let the proxy do the scope checking.
* Source/DKMethod.m: Shuffle a few statements around for more natural ordering.
* configure.ac: Leave a TODO about needing to fix the configure script
  ugliness.
* config.make.in: Another attempt to get linking done properly.

Many improvement suggested by Fred Kiefer.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/dbuskit/trunk@30687 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Niels Grewe 2010-06-11 21:52:09 +00:00
parent ee7d90418f
commit 517874dca8
9 changed files with 76 additions and 12 deletions

View File

@ -41,4 +41,9 @@
- (id) initWithEndpoint: (DKEndpoint*)anEndpoint
andService: (NSString*)aService
andPath: (NSString*)aPath;
/**
* Checks whether the to proxies are attached to the same D-Bus service.
*/
- (BOOL) hasSameScopeAs: (DKProxy*)aProxy;
@end

View File

@ -25,7 +25,7 @@
#import<Foundation/NSObject.h>
@class NSString, NSMutableArray;
@class NSString, NSMutableArray, DKProxy;
extern NSString *DKArgumentDirectionIn;
extern NSString *DKArgumentDirectionOut;
@ -87,6 +87,21 @@ extern NSString *DKArgumentDirectionOut;
* of the DKArgument.
*/
- (id) boxedValueForValueAt: (void*)buffer;
/**
* Returns the immediate parent from the proxy/method/argument/subargument tree.
*/
- (id) parent;
/**
* Returns the proxy from which the receiver descends, if any.
*/
- (DKProxy*) proxyParent;
/**
* Returns the name of the argument.
*/
- (NSString*)name;
@end
/**

View File

@ -192,7 +192,7 @@ DKUnboxedObjCTypeSizeForDBusType(int type)
name: _name
parent: _parent];
}
ASSIGNCOPY(_name, name);
ASSIGNCOPY(name, _name);
objCEquivalent = DKObjCClassForDBusType(DBusType);
parent = _parent;
return self;
@ -233,6 +233,11 @@ DKUnboxedObjCTypeSizeForDBusType(int type)
return DBusType;
}
- (NSString*)name
{
return name;
}
- (NSString*) DBusTypeSignature
{
return [NSString stringWithCharacters: (unichar*)&DBusType length: 1];
@ -367,12 +372,11 @@ DKUnboxedObjCTypeSizeForDBusType(int type)
case DBUS_TYPE_OBJECT_PATH:
if ([value isKindOfClass: [DKProxy class]])
{
// We need to make sure that the paths are from the same proxy, because
// that is the widest scope in which they are valid.
DKProxy *myProxy = [self proxyParent];
BOOL hasSameScope = ([[value _service] isEqualToString: [myProxy _service]]
&& [[value _endpoint] isEqual: [myProxy _endpoint]]);
if (hasSameScope)
/*
* We need to make sure that the paths are from the same proxy, because
* that is the widest scope in which they are valid.
*/
if ([[self proxyParent] hasSameScopeAs: value])
{
*buffer = (uintptr_t)[[value _path] UTF8String];
return YES;

View File

@ -42,14 +42,16 @@ DKMethod *_DKMethodIntrospect;
{
if ([DKMethod class] == self)
{
DKArgument *xmlOutArg = [[DKArgument alloc] initWithDBusSignature: "s"
name: @"data"
parent: _DKMethodIntrospect];
DKArgument *xmlOutArg = nil;
_DKMethodIntrospect = [[DKMethod alloc] initWithMethodName: @"Introspect"
interface: @"org.freedesktop.DBus.Introspectable"
parent: nil];
xmlOutArg = [[DKArgument alloc] initWithDBusSignature: "s"
name: @"data"
parent: _DKMethodIntrospect];
[_DKMethodIntrospect addArgument: xmlOutArg
direction: DKArgumentDirectionOut];
[xmlOutArg release];
}
}

View File

@ -204,6 +204,13 @@
return path;
}
- (BOOL) hasSameScopeAs: (DKProxy*)aProxy
{
BOOL sameService = [service isEqualToString: [aProxy _service]];
BOOL sameEndpoint = [endpoint isEqual: [aProxy _endpoint]];
return (sameService && sameEndpoint);
}
- (void) dealloc
{
[endpoint release];

View File

@ -86,6 +86,20 @@ static NSDictionary *basicSigsAndClasses;
parent: nil]);
}
- (void) testInitializerAssignments
{
DKArgument *fakeParent = [[DKArgument alloc] initWithDBusSignature: "s"
name: nil
parent: nil];
DKArgument *arg = [[DKArgument alloc] initWithDBusSignature: "s"
name: @"Foo"
parent: fakeParent];
UKObjectsEqual(@"Foo",[arg name]);
UKObjectsEqual(fakeParent, [arg parent]);
[arg release];
[fakeParent release];
}
- (void) testSimpleRoundtrip
{
NSEnumerator *enumerator = [basicSigs objectEnumerator];

View File

@ -21,6 +21,7 @@
*/
#import <Foundation/NSMethodSignature.h>
#import <Foundation/NSNull.h>
#import <UnitKit/UnitKit.h>
#import "../DKMethod.h"
@ -37,6 +38,19 @@
[DKMethod class];
}
}
- (void)testInitializerAssignments
{
NSNull *dummyParent = [NSNull null];
DKMethod *method = [[DKMethod alloc] initWithMethodName: @"Fooify"
interface: @"org.gnustep.fake"
parent: dummyParent];
UKObjectsEqual(@"Fooify",[method methodName]);
UKObjectsEqual(@"org.gnustep.fake", [method interface]);
UKObjectsEqual(dummyParent, [method parent]);
[method release];
}
- (void)testBuiltInIntrospectSignatureBoxed
{
NSMethodSignature *sig = [_DKMethodIntrospect methodSignature];

View File

@ -1,3 +1,3 @@
ADDITIONAL_OBJCFLAGS+=@DBUS_CFLAGS@
ADDITIONAL_LDFLAGS+=@DBUS_LIBS@
WARN_FLAGS+=@WARN_FLAGS@
DBusKit_LDFLAGS+=@DBUS_LIBS@

View File

@ -22,6 +22,9 @@ AC_SUBST(DBUS_LIBS)
#--------------------------------------------------------------------
# Check for -Wdeclaration-after-statement (adopted from gnustep-base)
# TODO: Doing it this way looks really ugly because there is a bunch
# of other tests executed before the result of the test is
# printed.
#--------------------------------------------------------------------
AC_MSG_CHECKING(whether the compiler supports -Wdeclaration-after-statement)