/* Code for implementation for Objective-C EltNode objects Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc. Written by: R. Andrew McCallum Dept. of Computer Science, U. of Rochester, Rochester, NY 14627 This file is part of the GNU Objective-C 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; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This file gets included in all the ...EltNode.m files. Doing this silly #include stuff is a poor substitute for multiple inheritance. sigh. Pattern: @implementation FooEltNode : FooNode #include @end */ #include #include - initElement: (elt)anElement encoding: (const char *)eltEncoding { [super init]; _element = anElement; _elt_comparison_function = elt_get_comparison_function(eltEncoding); return self; } /* Archiving must mimic the above designated initializer */ - (void) encodeWithCoder: aCoder { const char *encoding; [super encodeWithCoder:aCoder]; encoding = elt_get_encoding(_elt_comparison_function); [aCoder encodeValueOfCType:@encode(char*) at:&encoding withName:@"EltNode Content Type Encoding"]; [aCoder encodeValueOfCType:encoding at:elt_get_ptr_to_member(encoding, &_element) withName:@"EltNode Content Element"]; } - (elt*) _elementDataPtr { return &_element; } - (int(**)(elt,elt)) _eltComparisonFunctionPtr { return &_elt_comparison_function; } - initWithCoder: aCoder { char *encoding; [super initWithCoder:aCoder]; [aCoder decodeValueOfCType:@encode(char*) at:&encoding withName:NULL]; *[self _eltComparisonFunctionPtr] = elt_get_comparison_function(encoding); [aCoder decodeValueOfCType:encoding at:[self _elementDataPtr] withName:NULL]; return self; } - (int(*)(elt,elt)) comparisonFunction { return _elt_comparison_function; } - (elt) elementData { return _element; } - (int) compare: anotherObject { /* perhaps we should do more checking first */ return _elt_comparison_function(_element, [anotherObject elementData]); } - printForDebugger { elt_fprintf_elt(stdout, elt_get_encoding(_elt_comparison_function), _element); printf("\n"); return self; }