From 081f2c530d9da5e3f619c5bb78b29c48f670fb09 Mon Sep 17 00:00:00 2001 From: David Ayers Date: Sat, 16 Sep 2006 03:27:17 +0000 Subject: [PATCH] * EOAccess/EOAttribute.[hm]: Add documentation. (_valueTypeChar): Replace char type with ... (_valueTypeCharacter): ... unichar type. ([_valueTypeCharacter): Add comment about caching issue. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@23531 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 ++++ EOAccess/EOAttribute.h | 2 +- EOAccess/EOAttribute.m | 84 ++++++++++++++++++++++++++++++++------ EOAccess/EOAttributePriv.h | 2 +- 4 files changed, 81 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index b220559..f2dbd72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-09-16 David Ayers + + * EOAccess/EOAttribute.[hm]: Add documentation. + (_valueTypeChar): Replace char type with ... + (_valueTypeCharacter): ... unichar type. + ([_valueTypeCharacter): Add comment about caching issue. + 2006-09-15 Matt Rice * EOInterface/EODisplayGroup.m: Correct selector name. diff --git a/EOAccess/EOAttribute.h b/EOAccess/EOAttribute.h index ec3f0e6..4ab3cbe 100644 --- a/EOAccess/EOAttribute.h +++ b/EOAccess/EOAttribute.h @@ -84,7 +84,7 @@ typedef enum { unsigned int _width; unsigned short _precision; short _scale; - char _valueTypeChar; /** First char of _valueType or \0 **/ + unichar _valueTypeCharacter; /** First char of _valueType or \0 **/ Class _valueClass; EOAdaptorValueType _adaptorValueType; EOFactoryMethodArgumentType _argumentType; diff --git a/EOAccess/EOAttribute.m b/EOAccess/EOAttribute.m index c3f9b38..834bf51 100644 --- a/EOAccess/EOAttribute.m +++ b/EOAccess/EOAttribute.m @@ -646,6 +646,23 @@ RCS_ID("$Id$") return isFlattened; } +/** + *

Returns the name of the class values of this attribute + * are represented by. The standard classes are NSNumber, + * NSString, NSData and NSDate for the corresponding + * [adaptorValueType]. A model can define more specific + * classes like NSDecimalNumber, NSCalendarDate and NSImage + * or custom classes which implement a factory method + * specified by [valueFactoryMethodName] to create instances + * with the data supplied by the data source.

+ *

If the valueClassName has not been set explicitly and the + * reciever [isFlattened], the valueClassName of the flattened + * attribute is returned.

+ *

Otherwise, if the reciever has a prototype then the + * valueClassName of the prototype is returned.

+ *

If all that fails, this method returns nil.

+ *

See also:[setValueClassName:]

+ */ - (NSString *)valueClassName { if (_valueClassName) @@ -657,6 +674,16 @@ RCS_ID("$Id$") return [_prototype valueClassName]; } +/** + *

Returns the adaptor specific name of externalType. This is + * the name use during SQL generation.

+ *

If the externalType has not been set explicitly and the + * reciever [isFlattened], the valueClassName of the flattened + * attribute is returned.

+ *

Otherwise, if the reciever has a prototype then the + * externalType of the prototype is returned.

+ *

If all that fails, this method returns nil.

+ */ - (NSString *)externalType { if (_externalType) @@ -668,6 +695,30 @@ RCS_ID("$Id$") return [_prototype externalType]; } +/** + *

Returns a one character string identifiying the underlying + * C type of an NSNumber [valueTypeName]. The legal values in GDL2 are:

+ *
    + *
  • @"c": char
  • + *
  • @"C": unsigned char
  • + *
  • @"s": short
  • + *
  • @"S": unsigned short
  • + *
  • @"i": int
  • + *
  • @"I": unsigned int
  • + *
  • @"l": long
  • + *
  • @"L": unsigned long
  • + *
  • @"u": long long
  • + *
  • @"U": unsigned long long
  • + *
  • @"f": float
  • + *
  • @"d": double
  • + *
+ *

If the valueType has not been set explicitly and the + * reciever [isFlattened], the valueClassName of the flattened + * attribute is returned.

+ *

Otherwise, if the reciever has a prototype then the + * valueType of the prototype is returned.

+ *

If all that fails, this method returns nil.

+ */ - (NSString *)valueType { if (_valueType) @@ -906,9 +957,9 @@ return nexexp ASSIGN(_valueType, type); if ([_valueType length]==1) - _valueTypeChar=(char)[_valueType characterAtIndex:0]; + _valueTypeCharacter = [_valueType characterAtIndex:0]; else - _valueTypeChar='\0'; + _valueTypeCharacter = '\0'; [self _setOverrideForKeyEnum: 4];//TODO } @@ -1659,8 +1710,8 @@ More details: { if (valueClass == GDL2_NSNumberClass) { - char valueTypeChar=[self _valueTypeChar]; - switch(valueTypeChar) + unichar valueTypeCharacter = [self _valueTypeCharacter]; + switch(valueTypeCharacter) { case 'i': *valueP = [GDL2_alloc(NSNumber) @@ -1854,17 +1905,26 @@ More details: return [_prototype _valueClass]; } -- (char)_valueTypeChar +/* + * This method returns the valueType as a unichar character. + * The value of the instance variable get set implicitly + * if the valueType is set explicitly with a legal value. + * Otherwise the effective valueType of reciever is used. + * TODO: Once this has been set later implicit changes to the + * valueType via flattend attrubutes or prototypes will not + * be honored. Value validation can be a hot spot so this method + * (or rather it's only use in validateValue:) should remain efficient. + */ +- (unichar)_valueTypeCharacter { - char valueTypeChar=_valueTypeChar; - if (valueTypeChar=='\0') + unichar valueTypeCharacter = _valueTypeCharacter; + if (valueTypeCharacter == '\0') { - // Compute it - NSString* valueType=[self valueType]; - if ([valueType length]==1) - valueTypeChar=(char)[valueType characterAtIndex:0]; + NSString* valueType = [self valueType]; + if ([valueType length] == 1) + valueTypeCharacter = [valueType characterAtIndex:0]; } - return valueTypeChar; + return valueTypeCharacter; }; @end diff --git a/EOAccess/EOAttributePriv.h b/EOAccess/EOAttributePriv.h index a9b57ac..3489f5b 100644 --- a/EOAccess/EOAttributePriv.h +++ b/EOAccess/EOAttributePriv.h @@ -34,7 +34,7 @@ - (EOAttribute *)realAttribute; - (Class)_valueClass; -- (char)_valueTypeChar; +- (unichar)_valueTypeCharacter; @end @interface EOAttribute (EOAttributePrivate2)