home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / Languages / python / PyObjC-0.47-MIHS / pyobjc-0.47-src / Modules / OC_PythonString.m < prev    next >
Encoding:
Text File  |  1996-10-04  |  1.3 KB  |  66 lines

  1. /* Copyright (c) 1996 by Lele Gaifax.  All Rights Reserved
  2.  *
  3.  * This software may be used and distributed freely for any purpose
  4.  * provided that this notice is included unchanged on any and all
  5.  * copies. The author does not warrant or guarantee this software in
  6.  * any way.
  7.  *
  8.  * This file is part of the PyObjC package.
  9.  *
  10.  * $RCSfile: OC_PythonString.m,v $
  11.  * $Revision: 1.1.1.2 $
  12.  * $Date: 1996/10/04 20:59:03 $
  13.  *
  14.  * Created Thu Sep  5 19:49:36 1996.
  15.  */
  16.  
  17. #include "OC_PythonString.h"
  18.  
  19. #define CLASS_VERSION 0
  20.  
  21. @implementation OC_PythonString
  22.  
  23. + (void) initialize
  24. {
  25.   if (self == [OC_PythonString class])
  26.     {
  27.       [OC_PythonString setVersion:CLASS_VERSION];
  28.     }
  29. }
  30.  
  31. + (id <PythonObject>) fromString:(char *) str andSize:(int) size
  32. {
  33.   PyObject *pystr = PyString_FromStringAndSize (str, size);
  34.   id <PythonObject> result = [self newWithObject:pystr];
  35.  
  36.   Py_DECREF(pystr);
  37.   return result;
  38. }
  39.  
  40. + (id <PythonObject>) fromString:(char *) str
  41. {
  42.   PyObject *pystr = PyString_FromString (str);
  43.   id <PythonObject> result = [self newWithObject:pystr];
  44.  
  45.   Py_DECREF(pystr);
  46.   return result;
  47. }
  48.  
  49. - (int) size
  50. {
  51.   return PyString_Size ([self object]);
  52. }
  53.  
  54. - (char *) asString
  55. {
  56.   return PyString_AsString ([self object]);
  57. }
  58.  
  59. @end /* OC_PythonString class implementation */
  60.  
  61. /*
  62. ** Local Variables:
  63. ** change-log-default-name:"../ChangeLog.PyObjC"
  64. ** End:
  65. */
  66.