Mercurial > projects > dstep
view dstep/coredata/NSManagedObject.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | |
children | b9de51448c6b |
line wrap: on
line source
/** * Copyright: Copyright (c) 2009 Jacob Carlborg. * Authors: Jacob Carlborg * Version: Initial created: Sep 25, 2009 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) */ module dstep.coredata.NSManagedObject; import dstep.coredata.NSEntityDescription; import dstep.coredata.NSManagedObjectContext; import dstep.coredata.NSManagedObjectID; import dstep.foundation.NSArray; import dstep.foundation.NSDictionary; import dstep.foundation.NSError; import dstep.foundation.NSKeyValueObserving; import dstep.foundation.NSObject; import dstep.foundation.NSSet; import dstep.foundation.NSString; import dstep.objc.bridge.Bridge; import dstep.objc.objc; class NSManagedObject : NSObject { mixin (ObjcWrap); NSManagedObject initWithEntity (NSEntityDescription entity, NSManagedObjectContext context) { id result = invokeObjcSelf!(id, "initWithEntity:insertIntoManagedObjectContext:", NSEntityDescription, NSManagedObjectContext)(entity, context); return result is this.objcObject ? this : (result !is null ? new NSManagedObject(result) : null); } this (NSEntityDescription entity, NSManagedObjectContext context) { super(NSManagedObject.alloc.initWithEntity(entity, context).objcObject); } NSManagedObjectContext managedObjectContext () { return invokeObjcSelf!(NSManagedObjectContext, "managedObjectContext"); } NSEntityDescription entity () { return invokeObjcSelf!(NSEntityDescription, "entity"); } NSManagedObjectID objectID () { return invokeObjcSelf!(NSManagedObjectID, "objectID"); } bool isInserted () { return invokeObjcSelf!(bool, "isInserted"); } bool isUpdated () { return invokeObjcSelf!(bool, "isUpdated"); } bool isDeleted () { return invokeObjcSelf!(bool, "isDeleted"); } bool isFault () { return invokeObjcSelf!(bool, "isFault"); } bool hasFaultForRelationshipNamed (NSString key) { return invokeObjcSelf!(bool, "hasFaultForRelationshipNamed:", NSString)(key); } void willAccessValueForKey (NSString key) { return invokeObjcSelf!(void, "willAccessValueForKey:", NSString)(key); } void didAccessValueForKey (NSString key) { return invokeObjcSelf!(void, "didAccessValueForKey:", NSString)(key); } void willChangeValueForKey (NSString key) { return invokeObjcSelf!(void, "willChangeValueForKey:", NSString)(key); } void didChangeValueForKey (NSString key) { return invokeObjcSelf!(void, "didChangeValueForKey:", NSString)(key); } void willChangeValueForKey (NSString inKey, uint inMutationKind, NSSet inObjects) { return invokeObjcSelf!(void, "willChangeValueForKey:withSetMutation:usingObjects:", NSString, uint, NSSet)(inKey, inMutationKind, inObjects); } void didChangeValueForKey (NSString inKey, uint inMutationKind, NSSet inObjects) { return invokeObjcSelf!(void, "didChangeValueForKey:withSetMutation:usingObjects:", NSString, uint, NSSet)(inKey, inMutationKind, inObjects); } void setObservationInfo (void* inObservationInfo) { return invokeObjcSelf!(void, "setObservationInfo:", void*)(inObservationInfo); } void* observationInfo () { return invokeObjcSelf!(void*, "observationInfo"); } void awakeFromFetch () { return invokeObjcSelf!(void, "awakeFromFetch"); } void awakeFromInsert () { return invokeObjcSelf!(void, "awakeFromInsert"); } void willSave () { return invokeObjcSelf!(void, "willSave"); } void didSave () { return invokeObjcSelf!(void, "didSave"); } void willTurnIntoFault () { return invokeObjcSelf!(void, "willTurnIntoFault"); } void didTurnIntoFault () { return invokeObjcSelf!(void, "didTurnIntoFault"); } Object valueForKey (NSString key) { return invokeObjcSelf!(Object, "valueForKey:", NSString)(key); } void setValue (Object value, NSString key) { return invokeObjcSelf!(void, "setValue:forKey:", Object, NSString)(value, key); } Object primitiveValueForKey (NSString key) { return invokeObjcSelf!(Object, "primitiveValueForKey:", NSString)(key); } void setPrimitiveValue (Object value, NSString key) { return invokeObjcSelf!(void, "setPrimitiveValue:forKey:", Object, NSString)(value, key); } NSDictionary committedValuesForKeys (NSArray keys) { return invokeObjcSelf!(NSDictionary, "committedValuesForKeys:", NSArray)(keys); } NSDictionary changedValues () { return invokeObjcSelf!(NSDictionary, "changedValues"); } bool validateValue (id* value, NSString key, ref NSError error) { id __arg2; if (error) __arg2 = error.objcObject; bool result = invokeObjcSelf!(bool, "validateValue:forKey:error:", id*, NSString, id*)(value, key, &__arg2); if (__arg2) error = new NSError(__arg2); return result; } bool validateForDelete (ref NSError error) { id __arg0; if (error) __arg0 = error.objcObject; bool result = invokeObjcSelf!(bool, "validateForDelete:", id*)(&__arg0); if (__arg0) error = new NSError(__arg0); return result; } bool validateForInsert (ref NSError error) { id __arg0; if (error) __arg0 = error.objcObject; bool result = invokeObjcSelf!(bool, "validateForInsert:", id*)(&__arg0); if (__arg0) error = new NSError(__arg0); return result; } bool validateForUpdate (ref NSError error) { id __arg0; if (error) __arg0 = error.objcObject; bool result = invokeObjcSelf!(bool, "validateForUpdate:", id*)(&__arg0); if (__arg0) error = new NSError(__arg0); return result; } }