(root)/
gcc-13.2.0/
gcc/
testsuite/
objc-obj-c++-shared/
nsconstantstring-class-impl.h
       1  /* A small NSConstantString implementation for use with the NeXT runtime.
       2     Copyright (C) 2011 Free Software Foundation, Inc.
       3  		     
       4     Contributed by Iain Sandoe <iains@gcc.gnu.org>
       5  
       6  This file is part of GCC.
       7  
       8  GCC is free software; you can redistribute it and/or modify
       9  it under the terms of the GNU General Public License as published by
      10  the Free Software Foundation; either version 3, or (at your option)
      11  any later version.
      12  
      13  GCC is distributed in the hope that it will be useful,
      14  but WITHOUT ANY WARRANTY; without even the implied warranty of
      15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16  GNU General Public License for more details.
      17  
      18  You should have received a copy of the GNU General Public License
      19  along with GCC; see the file COPYING3.  If not see
      20  <http://www.gnu.org/licenses/>.  */
      21  
      22  #ifdef __NEXT_RUNTIME__
      23  
      24  #include "nsconstantstring-class.h"
      25  #include <string.h>
      26  
      27  /* On full-fledged Mac OS X systems, NSConstantString is provided
      28     as part of the Foundation framework.  However, on bare Darwin systems,
      29     Foundation is not included, and hence there is no NSConstantString 
      30     implementation to link against.
      31  
      32     This code is derived from the GNU runtime's NXConstantString implementation.
      33  */
      34  
      35  @implementation NSConstantString
      36  /* NeXT requires this or forward:  */
      37  +initialize { return self; }
      38  
      39  -(const char *) cString
      40  {
      41    return (c_string);
      42  }
      43  
      44  -(unsigned int) length
      45  {
      46    return (len);
      47  }
      48  @end
      49  
      50  TNS_STRING_REF_T _NSConstantStringClassReference;
      51  
      52  /* The NSConstantString metaclass will need to be initialized before we can
      53     send messages to strings.  */
      54  
      55  void objc_constant_string_init (void) __attribute__((constructor));
      56  void objc_constant_string_init (void) {
      57    memcpy (&_NSConstantStringClassReference,
      58  	  objc_getClass ("NSConstantString"),
      59  	  sizeof (_NSConstantStringClassReference));
      60  }
      61  #endif