Mercurial > projects > dstep
view dstep/foundation/NSFormatter.d @ 14:89f3c3ef1fd2
Added the Foundation framework
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 03 Aug 2009 15:23:15 +0200 |
parents | |
children | 19885b43130e |
line wrap: on
line source
/** * Copyright: Copyright (c) 2009 Jacob Carlborg. * Authors: Jacob Carlborg * Version: Initial created: Aug 3, 2009 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) */ module dstep.foundation.NSFormatter; import dstep.foundation.NSAttributedString; import dstep.foundation.NSDictionary; import dstep.foundation.NSObject; import dstep.foundation.NSRange; import dstep.foundation.NSString; import dstep.objc.bridge.Bridge; import dstep.objc.objc : id; class NSFormatter : NSObject, INSCopying, INSCoding { mixin ObjcWrap; NSString stringForObjectValue (Object obj) { return invokeObjcSelf!(NSString, "stringForObjectValue:", Object)(obj); } NSAttributedString attributedStringForObjectValue (Object obj, NSDictionary attrs) { return invokeObjcSelf!(NSAttributedString, "attributedStringForObjectValue:withDefaultAttributes:", Object, NSDictionary)(obj, attrs); } NSString editingStringForObjectValue (Object obj) { return invokeObjcSelf!(NSString, "editingStringForObjectValue:", Object)(obj); } bool getObjectValue (id* obj, NSString string, NSString** error) { return invokeObjcSelf!(bool, "getObjectValue:forString:errorDescription:", id*, NSString, NSString**)(obj, string, error); } bool isPartialStringValid (NSString partialString, NSString** newString, NSString** error) { return invokeObjcSelf!(bool, "isPartialStringValid:newEditingString:errorDescription:", NSString, NSString**, NSString**)(partialString, newString, error); } bool isPartialStringValid (NSString** partialStringPtr, NSRangePointer proposedSelRangePtr, NSString origString, NSRange origSelRange, NSString** error) { return invokeObjcSelf!(bool, "isPartialStringValid:proposedSelectedRange:originalString:originalSelectedRange:errorDescription:", NSString**, NSRangePointer, NSString, NSRange, NSString**)(partialStringPtr, proposedSelRangePtr, origString, origSelRange, error); } Object copyWithZone (NSZone* zone) { return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); } void encodeWithCoder (NSCoder aCoder) { return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); } Object initWithCoder (NSCoder aDecoder) { return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); } this (NSCoder aDecoder) { objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass); id result = Bridge.invokeObjcMethod!(id, "initWithCoder:", NSCoder)(objcObject, aDecoder); if (result) objcObject = ret; dObject = this; } }