bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC/gdl2] EONull/NSNull


From: David Ayers
Subject: [RFC/gdl2] EONull/NSNull
Date: Mon, 30 Jun 2003 12:22:42 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20030507

Hello Everyone,

Time to get some of the outstanding patches in so to make testing of edge cases easier...

This patch should get rid of all instances of EONull and most classes. In compiled code which includes EONull.h EONull gets redefined to NSNull EONull becomes a subclass of NSNull, to satisfy NSClassFromString but sending it +class will return NSNull. Sending EONull +allocWithZone: or +null returns the NSNull instance. I'm not sure whether we should poseAsClass: NSNull in +intialize, but this option remains if there are any more ambiguities.

I've attached the new headers and class file instead of a diff to simplify reviewal. Save objections I'll commit this soon.

Cheers,
David

/* 
   EONull.h

   Copyright (C) 1996-2002, 2003 Free Software Foundation, Inc.

   Author: Mircea Oancea <mircea@jupiter.elcom.pub.ro>
   Date: 1996

   This file is part of the GNUstep Database Library.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this library; see the file COPYING.LIB.
   If not, write to the Free Software Foundation,
   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#ifndef __EONull_h__
#define __EONull_h__

#ifndef NeXT_Foundation_LIBRARY
#include <Foundation/NSNull.h>
#else
#include <Foundation/Foundation.h>
#endif

#include "EODefines.h"

@class NSString;

#define EONull NSNull

@interface EONull (EOSQLFormatting)
- (NSString *)sqlString;
@end

@interface NSObject (EONullTest)
- (BOOL)isEONull;
- (BOOL)isNotEONull;
@end

GDL2CONTROL_EXPORT BOOL isNilOrEONull(id v);

#endif /* __EONull_h__ */

/** 
   EONull.m <title>EONull Class</title>

   Copyright (C) 1996-2002 Free Software Foundation, Inc.

   Author: Mircea Oancea <mircea@jupiter.elcom.pub.ro>
   Date: 1996

   Author: Mirko Viviani <mirko.viviani@rccr.cremona.it>
   Date: February 2000

   $Revision: 1.6 $
   $Date: 2003/03/31 00:24:15 $

   <abstract></abstract>

   This file is part of the GNUstep Database Library.

   <license>
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this library; see the file COPYING.LIB.
   If not, write to the Free Software Foundation,
   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
   </license>
**/

#include "config.h"

RCS_ID("$Id: EONull.m,v 1.6 2003/03/31 00:24:15 ayers Exp $")

#ifndef NeXT_Foundation_LIBRARY
#include <Foundation/NSString.h>
#else
#include <Foundation/Foundation.h>
#endif

#include <EOControl/EONull.h>
#include <EOControl/EODebug.h>


@implementation EONull (EOSQLFormatting)

- (NSString *)sqlString
{
  EOFLOGObjectFnStart();
  EOFLOGObjectFnStop();

  return @"NULL";
}

//OK
- (id)valueForKey:(NSString *)key
{
  return self;
}

@end


@implementation NSObject (EONull)

- (BOOL)isEONull
{  
  return ((id)self == [NSNull null]);
}

- (BOOL)isNotEONull
{
  return ![self isEONull];
}

@end

BOOL isNilOrEONull(id v)
{
  return ((!v) || [v isEONull]);
}

/*
 * We keep this class to support NSClassFromString() which
 * scripting libraries my depend on.  Note that this is
 * not a fail-safe implementation.  You should rely on
 * [EONull+null] and pointer comparison.  Do not rely on
 * [obj isKindOfClass: NSClassFromString(@"EONull")]
 * or similar constructs.  They will return wrong results.
 * This is a small backdraw from using the new extension classes
 * in base / Foundation.
 */
#undef EONull
@interface EONull : NSNull
@end
@implementation EONull
+ (Class) class
{
  return [NSNull class];
}

+ (id) allocWithZone: (NSZone *)zone
{
  return [NSNull null];
}

+ null
{
  return [NSNull null];
}

@end


reply via email to

[Prev in Thread] Current Thread [Next in Thread]