997 lines · 20.0 KB · C
RawDownload
# 1 "ocstring.m"struct _PRIVATE { struct _PRIVATE *isa; };typedef struct _PRIVATE *id;struct _SHARED {  id isa;  id clsSuper;  char *clsName;  char *clsTypes;  short clsSizInstance;  short clsSizDict;  struct _SLT *clsDispTable;  long clsStatus;  struct modDescriptor *clsMod;  unsigned clsVersion;  id clsCats;  id *clsGlbl;};extern id  (* _imp(id,char*))();extern id  (* _impSuper(id,char*))();extern struct modDescriptor  *_OBJCBIND_ocstring(void);static char **selTransTbl;struct _SLT {char *_cmd;id (*_imp)();};struct modDescriptor {  char *modName;  char *modVersion;  long modStatus;  char *modMinSel;  char *modMaxSel;  id *modClsLst;  short modSelRef;  char **modSelTbl;  struct methodDescriptor *modMapTbl;};extern struct modDescriptor ocstring_modDesc; # 1 "../../util/stdarg.h"#include <stdarg.h> # 1 "../../util/assert.h"#include <assert.h> # 1 "../../util/ctype.h"#include <ctype.h> # 1 "../../util/stdlib.h"#include <stdlib.h> # 1 "../../util/stdio.h"#include <stdio.h> # 1 "../../util/stdio.h"#include <stdio.h> # 1 "../../util/stddef.h"#include <stddef.h> # 53 "../../include/objcrt/objcrt.h"typedef char*SEL;typedef char*STR;typedef char BOOL;typedef FILE*IOD;typedef id SHR;# 62 "../../include/objcrt/objcrt.h"typedef id(*IMP)();  typedef void(*ARGIMP)(id,SEL,void*);# 85 "../../include/objcrt/objcrt.h"extern BOOL msgFlag;extern FILE*msgIOD;extern FILE*dbgIOD;extern BOOL allocFlag;extern BOOL dbgFlag;extern BOOL noCacheFlag;extern BOOL noNilRcvr;# 98 "../../include/objcrt/objcrt.h"SEL selUid(STR);STR selName(SEL);void dbg(char*fmt,...);void prnstack(FILE*file);void loadobjc(void*modPtr);void unloadobjc(void*modPtr);# 107 "../../include/objcrt/objcrt.h"IMP fwdimp(id,SEL,IMP);IMP fwdimpSuper(id,SEL,IMP);void fwdmsg(id,SEL,void*,ARGIMP);id selptrfwd(id,SEL,id,id,id,id);  id idincref(id obj);id idassign(id*lhs,id rhs);id iddecref(id obj); extern id(*_fileIn)(FILE*);extern BOOL(*_fileOut)(FILE*,id);extern BOOL(*_storeOn)(STR,id);extern id(*_readFrom)(STR);void setfilein(id(*f)(FILE*));void setfileout(BOOL(*f)(FILE*,id)); extern id(*_showOn)(id,unsigned); void*OC_Malloc(size_t);void*OC_MallocAtomic(size_t);void*OC_Calloc(size_t);void*OC_Realloc(void*,size_t);void*OC_Free(void*data);# 1 "../../util/string.h"#include <string.h> # 32 "ocstring.h"typedef struct objstr{int count;int capacity;char*ptr;}*objstr_t;# 34 "ocstring.m"typedef struct{# 42 "../../include/objcrt/Object.h"id isa;# 46 "../../include/objcrt/Object.h"unsigned short attr;unsigned short objID;# 34 "array.h"unsigned capacity;# 42 "ocstring.h"struct objstr value;# 37 "ocstring.m"}TFString;# 40 "ocstring.h"struct String_PRIVATE { # 42 "../../include/objcrt/Object.h"id isa;# 46 "../../include/objcrt/Object.h"unsigned short attr;unsigned short objID;# 34 "array.h"unsigned capacity;# 42 "ocstring.h"struct objstr value;}; # 40 "ocstring.h"extern id  String; # 40 "ocstring.h"extern struct _SHARED _String;extern struct _SHARED __String;  # 48 "ocstring.m"static intstr_len(char*s){int len=0;while( *s++)len++;return len;} static voidstr_ncpy(char*dst,char*src,int n){int c=0;while(n--&&(c= *src++)){ *dst++=c;} *dst++='\0';} static voidstr_cpy(char*dst,char*src){int c=0;while((c= *src++)){ *dst++=c;} *dst++='\0';} static voidinit(objstr_t self,char*s,int n,int c){(void)0; self->count=n;self->capacity=c;self->ptr=(char*)OC_MallocAtomic(c); str_ncpy(self->ptr,s,n);self->ptr[n]='\0';} static id c_String_new(struct String_PRIVATE *self,SEL _cmd){id objcT0; # 94 "ocstring.m"return(objcT0=(id)self,(*(id(*)(id,SEL,unsigned))_imp(objcT0,selTransTbl[0]))(objcT0,selTransTbl[0],(16)));} static id c_String_new_(struct String_PRIVATE *self,SEL _cmd,unsigned nChars){id objcT1,objcT2; # 99 "ocstring.m"id newObj=(objcT1=__String.clsSuper,(*_impSuper(objcT1,selTransTbl[1]))((id)self,selTransTbl[1]));init((objcT2=newObj,(*(objstr_t(*)(id,SEL))_imp(objcT2,selTransTbl[2]))(objcT2,selTransTbl[2])),"",0,nChars);return newObj;} static voidinitstr(objstr_t self,char*s,int n){init(self,s,n,n+1);} static id c_String_str_(struct String_PRIVATE *self,SEL _cmd,STR aString){if(aString){id objcT3; # 114 "ocstring.m"id newObj=(objcT3=__String.clsSuper,(*_impSuper(objcT3,selTransTbl[1]))((id)self,selTransTbl[1]));int n=str_len(aString);# 121 "ocstring.m"initstr( &(((TFString*)newObj)->value),aString,n); return newObj;}else{id objcT4; # 127 "ocstring.m"return(objcT4=(id)self,(*_imp(objcT4,selTransTbl[1]))(objcT4,selTransTbl[1]));}} static id c_String_chars_count_(struct String_PRIVATE *self,SEL _cmd,STR aString,int n){if(aString){id objcT5; # 135 "ocstring.m"id newObj=(objcT5=__String.clsSuper,(*_impSuper(objcT5,selTransTbl[1]))((id)self,selTransTbl[1]));# 141 "ocstring.m"initstr( &(((TFString*)newObj)->value),aString,n); return newObj;}else{id objcT6; # 147 "ocstring.m"return(objcT6=(id)self,(*_imp(objcT6,selTransTbl[1]))(objcT6,selTransTbl[1]));}} static id c_String_vsprintf__(struct String_PRIVATE *self,SEL _cmd,STR format,va_list*ap){id objcT7; # 153 "ocstring.m"char aBuffer[(2048)];# 162 "ocstring.m"vsprintf(aBuffer,format, *ap);  return(objcT7=(id)self,(*(id(*)(id,SEL,STR))_imp(objcT7,selTransTbl[3]))(objcT7,selTransTbl[3],aBuffer));} static id c_String_sprintf_(struct String_PRIVATE *self,SEL _cmd,STR format,...){id objcT8; # 170 "ocstring.m"id newString;  va_list ap;va_start(ap,format);newString=(objcT8=(id)self,(*(id(*)(id,SEL,STR,va_list*))_imp(objcT8,selTransTbl[4]))(objcT8,selTransTbl[4],format, &ap));va_end(ap);return newString;} static voidcopy(objstr_t dst,objstr_t src){int n=src->count; (void)0; dst->count=n;dst->capacity=n+1;dst->ptr=(char*)OC_MallocAtomic(n+1);str_cpy(dst->ptr,src->ptr);} static id i_String_copy(struct String_PRIVATE *self,SEL _cmd){id objcT9,objcT10; # 195 "ocstring.m"id aCopy=(objcT9=_String.clsSuper,(*_impSuper(objcT9,selTransTbl[5]))((id)self,selTransTbl[5]));copy((objcT10=aCopy,(*(objstr_t(*)(id,SEL))_imp(objcT10,selTransTbl[2]))(objcT10,selTransTbl[2])),( &self->value));return aCopy;} static id i_String_deepCopy(struct String_PRIVATE *self,SEL _cmd){id objcT11; # 202 "ocstring.m"return(objcT11=(id)self,(*_imp(objcT11,selTransTbl[5]))(objcT11,selTransTbl[5]));} static voidclear(objstr_t self){OC_Free(self->ptr);self->ptr=NULL;} static id i_String_free(struct String_PRIVATE *self,SEL _cmd){id objcT12; # 214 "ocstring.m"clear(( &self->value));return(objcT12=_String.clsSuper,(*_impSuper(objcT12,selTransTbl[6]))((id)self,selTransTbl[6]));} static id i_String_release(struct String_PRIVATE *self,SEL _cmd){id objcT13;   return(objcT13=(id)self,(*(id(*)(id,SEL,SEL))_imp(objcT13,selTransTbl[7]))(objcT13,selTransTbl[7],_cmd)); } # 234 "ocstring.m"static intstr_cmp(char*s1,char*s2){int r;int c1,c2; while(1){c1= *s1++;c2= *s2++;if(c1=='\0')return(c2==0)?0: -1;if(c2=='\0')return 1;if((r=c1-c2))return r;} return 0;} static intcmpstr(objstr_t a,char*b){return str_cmp(a->ptr,b);} static int i_String_compare_(struct String_PRIVATE *self,SEL _cmd,id aStr){id objcT14; # 263 "ocstring.m"return((id)self==aStr)?0:cmpstr(( &self->value),(objcT14=aStr,(*(STR(*)(id,SEL))_imp(objcT14,selTransTbl[8]))(objcT14,selTransTbl[8])));} static int i_String_compareSTR_(struct String_PRIVATE *self,SEL _cmd,STR aString){return cmpstr(( &self->value),aString);} static unsignedstr_hash(char*s){unsigned hash=0; while(1){if( *s=='\0')break;elsehash^= *s++;if( *s=='\0')break;elsehash^=( *s++<<8);if( *s=='\0')break;elsehash^=( *s++<<16);if( *s=='\0')break;elsehash^=( *s++<<24);} return hash;} static unsignedhash(objstr_t self){return str_hash(self->ptr);} static unsigned i_String_hash(struct String_PRIVATE *self,SEL _cmd){return hash(( &self->value));} static intstr_dictcmp(char*s1,char*s2){int r;int c1,c2; while(1){while((c1= *s1++)&& !isalnum(c1)); while((c2= *s2++)&& !isalnum(c2)); if(c1=='\0')return(c2==0)?0: -1;if(c2=='\0')return 1;if(isupper(c1))c1=tolower(c1);if(isupper(c2))c2=tolower(c2);if((r=c1-c2))return r;} return 0;} static intdictcmp(objstr_t a,objstr_t b){return str_dictcmp(a->ptr,b->ptr);} static int i_String_dictCompare_(struct String_PRIVATE *self,SEL _cmd,id aStr){id objcT15; # 345 "ocstring.m"return dictcmp(( &self->value),(objcT15=aStr,(*(objstr_t(*)(id,SEL))_imp(objcT15,selTransTbl[2]))(objcT15,selTransTbl[2])));} static BOOL i_String_isEqual_(struct String_PRIVATE *self,SEL _cmd,id aStr){id objcT16; # 350 "ocstring.m"return((id)self==aStr)?(BOOL)1:((objcT16=(id)self,(*(int(*)(id,SEL,id))_imp(objcT16,selTransTbl[9]))(objcT16,selTransTbl[9],aStr))==0);} static BOOL i_String_isEqualSTR_(struct String_PRIVATE *self,SEL _cmd,STR aString){id objcT17; # 355 "ocstring.m"return(objcT17=(id)self,(*(int(*)(id,SEL,STR))_imp(objcT17,selTransTbl[10]))(objcT17,selTransTbl[10],aString))==0;} # 364 "ocstring.m"static objstr_t i_String_objstrvalue(struct String_PRIVATE *self,SEL _cmd){return &self->value;} static unsigned i_String_size(struct String_PRIVATE *self,SEL _cmd){return( &self->value)->count;}

Lines 1–500 of 997.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t