浏览代码

* PChar -> PAnsiChar

Michaël Van Canneyt 2 年之前
父节点
当前提交
89b91dfd74

+ 1 - 1
packages/objcrtl/examples/objcrtltest.pas

@@ -95,7 +95,7 @@ begin
 end;
 
 
-procedure RegisterSubclass(NewClassName: PChar);
+procedure RegisterSubclass(NewClassName: PAnsiChar);
 var
   cl  : _Class;
   b   : Boolean;

+ 39 - 39
packages/objcrtl/src/objcrtl.pas

@@ -113,13 +113,13 @@ type
   end;
 
 var
-  sel_getName : function (sel: SEL): PChar; cdecl = nil;
-  sel_registerName : function (str: PChar): SEL; cdecl = nil;
-  object_getClassName : function (obj: id): PChar; cdecl = nil;
+  sel_getName : function (sel: SEL): PAnsiChar; cdecl = nil;
+  sel_registerName : function (str: PAnsiChar): SEL; cdecl = nil;
+  object_getClassName : function (obj: id): PAnsiChar; cdecl = nil;
   object_getIndexedIvars : function (obj: id ): Pointer; cdecl = nil;
 
   sel_isMapped: function (sel: SEL): Boolean; cdecl = nil;
-  sel_getUid: function (const str: PChar): SEL; cdecl = nil;
+  sel_getUid: function (const str: PAnsiChar): SEL; cdecl = nil;
 
   object_copy : function (obj:id; size:size_t):id; cdecl = nil;
   object_dispose : function (obj:id):id; cdecl = nil;
@@ -130,21 +130,21 @@ var
   object_getIvar : function (obj:id; ivar:Ivar):id; cdecl = nil;
   object_setIvar : procedure (obj:id; ivar:Ivar; value:id); cdecl = nil;
 
-  object_setInstanceVariable : function (obj:id; name:pchar; value:pointer):Ivar; cdecl = nil;
-  object_getInstanceVariable : function (obj:id; name:pchar; var outValue: Pointer):Ivar; cdecl = nil;
+  object_setInstanceVariable : function (obj:id; name:PAnsiChar; value:pointer):Ivar; cdecl = nil;
+  object_getInstanceVariable : function (obj:id; name:PAnsiChar; var outValue: Pointer):Ivar; cdecl = nil;
 
-  objc_getClass : function (name:pchar):id; cdecl = nil;
-  objc_getMetaClass : function (name:pchar):id; cdecl = nil;
-  objc_lookUpClass : function (name:pchar):id; cdecl = nil;
-  objc_getRequiredClass : function (name:pchar):id; cdecl = nil;
-  objc_getFutureClass : function (name:pchar):_Class; cdecl = nil;
-  objc_setFutureClass : procedure (cls:_Class; name:pchar); cdecl = nil;
+  objc_getClass : function (name:PAnsiChar):id; cdecl = nil;
+  objc_getMetaClass : function (name:PAnsiChar):id; cdecl = nil;
+  objc_lookUpClass : function (name:PAnsiChar):id; cdecl = nil;
+  objc_getRequiredClass : function (name:PAnsiChar):id; cdecl = nil;
+  objc_getFutureClass : function (name:PAnsiChar):_Class; cdecl = nil;
+  objc_setFutureClass : procedure (cls:_Class; name:PAnsiChar); cdecl = nil;
   objc_getClassList : function (buffer:pClass; bufferCount:longint):longint; cdecl = nil;
 
-  objc_getProtocol : function (name:pchar): PProtocol; cdecl = nil;
+  objc_getProtocol : function (name:PAnsiChar): PProtocol; cdecl = nil;
   objc_copyProtocolList : function (outCount:pdword):PArrayPProtocol; cdecl = nil;
 
-  class_getName : function (cls:_Class):PChar; cdecl = nil;
+  class_getName : function (cls:_Class):PAnsiChar; cdecl = nil;
   class_isMetaClass : function (cls:_Class):BOOL; cdecl = nil;
   class_getSuperclass : function (cls:_Class):_Class; cdecl = nil;
   class_setSuperclass : function (cls: _Class; newSuper: _Class): _Class; cdecl = nil;
@@ -155,8 +155,8 @@ var
 
   class_getInstanceSize : function (cls:_Class):size_t; cdecl = nil;
 
-  class_getInstanceVariable : function (cls:_Class; name:pchar):Ivar; cdecl = nil;
-  class_getClassVariable : function (cls:_Class; name:pchar):Ivar; cdecl = nil;
+  class_getInstanceVariable : function (cls:_Class; name:PAnsiChar):Ivar; cdecl = nil;
+  class_getClassVariable : function (cls:_Class; name:PAnsiChar):Ivar; cdecl = nil;
   class_copyIvarList : function (cls:_Class; outCount:pdword):PIvar; cdecl = nil;
 
   class_getInstanceMethod : function (cls:_Class; name:SEL):Method; cdecl = nil;
@@ -169,59 +169,59 @@ var
   class_conformsToProtocol : function (cls:_Class; var protocol: Protocol):BOOL; cdecl = nil;
   class_copyProtocolList : function (cls:_Class; var outCount: dword):PArrayPProtocol; cdecl = nil;
 
-  class_getProperty : function (cls:_Class; name: pchar): objc_property_t; cdecl = nil;
+  class_getProperty : function (cls:_Class; name: PAnsiChar): objc_property_t; cdecl = nil;
   class_copyPropertyList : function (cls:_Class; var Count:dword):Pobjc_property_t; cdecl = nil;
 
-  class_getIvarLayout : function (cls:_Class):Pchar; cdecl = nil;
-  class_getWeakIvarLayout : function (cls:_Class):Pchar; cdecl = nil;
+  class_getIvarLayout : function (cls:_Class):PAnsiChar; cdecl = nil;
+  class_getWeakIvarLayout : function (cls:_Class):PAnsiChar; cdecl = nil;
 
   class_createInstance : function (cls:_Class; extraBytes:size_t):id; cdecl = nil;
 
-  objc_allocateClassPair : function (superclass:_Class; name:pchar; extraBytes:size_t):_Class; cdecl = nil;
+  objc_allocateClassPair : function (superclass:_Class; name:PAnsiChar; extraBytes:size_t):_Class; cdecl = nil;
   objc_registerClassPair : procedure (cls:_Class); cdecl = nil;
-  objc_duplicateClass : function (original:_Class; name:pchar; extraBytes:size_t):_Class; cdecl = nil;
+  objc_duplicateClass : function (original:_Class; name:PAnsiChar; extraBytes:size_t):_Class; cdecl = nil;
   objc_disposeClassPair : procedure (cls:_Class); cdecl = nil;
 
-  class_addMethod : function (cls:_Class; name:SEL; imp:IMP; types:pchar):BOOL; cdecl = nil;
-  class_replaceMethod : function (cls:_Class; name:SEL; imp:IMP; types:pchar):IMP; cdecl = nil;
-  class_addIvar: function (cls:_Class; name:pchar; size:size_t; alignment:uint8_t; types:pchar):BOOL; cdecl = nil;
+  class_addMethod : function (cls:_Class; name:SEL; imp:IMP; types:PAnsiChar):BOOL; cdecl = nil;
+  class_replaceMethod : function (cls:_Class; name:SEL; imp:IMP; types:PAnsiChar):IMP; cdecl = nil;
+  class_addIvar: function (cls:_Class; name:PAnsiChar; size:size_t; alignment:uint8_t; types:PAnsiChar):BOOL; cdecl = nil;
   class_addProtocol : function (cls:_Class; protocol:pProtocol):BOOL; cdecl = nil;
-  class_setIvarLayout : procedure (cls:_Class; layout:pchar); cdecl = nil;
-  class_setWeakIvarLayout : procedure (cls:_Class; layout:pchar); cdecl = nil;
+  class_setIvarLayout : procedure (cls:_Class; layout:PAnsiChar); cdecl = nil;
+  class_setWeakIvarLayout : procedure (cls:_Class; layout:PAnsiChar); cdecl = nil;
 
   method_getName : function (m:Method):SEL; cdecl = nil;
   method_getImplementation : function (m:Method):IMP; cdecl = nil;
-  method_getTypeEncoding : function (m:Method):Pchar; cdecl = nil;
+  method_getTypeEncoding : function (m:Method):PAnsiChar; cdecl = nil;
 
   method_getNumberOfArguments : function (m:Method):dword; cdecl = nil;
-  method_copyReturnType : function (m:Method):Pchar; cdecl = nil;
-  method_copyArgumentType : function (m:Method; index:dword):Pchar; cdecl = nil;
-  method_getReturnType : procedure (m:Method; dst:pchar; dst_len:size_t); cdecl = nil;
-  method_getArgumentType : procedure (m:Method; index:dword; dst:pchar; dst_len:size_t); cdecl = nil;
+  method_copyReturnType : function (m:Method):PAnsiChar; cdecl = nil;
+  method_copyArgumentType : function (m:Method; index:dword):PAnsiChar; cdecl = nil;
+  method_getReturnType : procedure (m:Method; dst:PAnsiChar; dst_len:size_t); cdecl = nil;
+  method_getArgumentType : procedure (m:Method; index:dword; dst:PAnsiChar; dst_len:size_t); cdecl = nil;
   method_getDescription : function (m: Method) : Pobjc_method_description; cdecl = nil;
 
   method_setImplementation: function (m:Method; imp:IMP):IMP; cdecl = nil;
   method_exchangeImplementations : procedure (m1:Method; m2:Method); cdecl = nil;
 
-  ivar_getName : function (v:Ivar):Pchar; cdecl = nil;
-  ivar_getTypeEncoding : function (v:Ivar):Pchar; cdecl = nil;
+  ivar_getName : function (v:Ivar):PAnsiChar; cdecl = nil;
+  ivar_getTypeEncoding : function (v:Ivar):PAnsiChar; cdecl = nil;
   ivar_getOffset : function (v:Ivar):ptrdiff_t; cdecl = nil;
 
-  property_getName :function (_property:objc_property_t):Pchar; cdecl = nil;
-  property_getAttributes : function (_property:objc_property_t):Pchar; cdecl = nil;
+  property_getName :function (_property:objc_property_t):PAnsiChar; cdecl = nil;
+  property_getAttributes : function (_property:objc_property_t):PAnsiChar; cdecl = nil;
 
 
   protocol_conformsToProtocol : function (proto:pProtocol; other:pProtocol):BOOL; cdecl = nil;
   protocol_isEqual : function (proto:pProtocol; other:pProtocol):BOOL; cdecl = nil;
   protocol_getMethodDescription : function (p: PProtocol; aSel: SEL; isRequiredMethod, isInstanceMethod: BOOL): objc_method_description; cdecl = nil;
   protocol_copyMethodDescriptionList : function (p: PProtocol; isRequiredMethod, isInstanceMethod: BOOL ; var outCount: LongWord): Pobjc_method_description; cdecl = nil;
-  protocol_getProperty : function (proto:PProtocol; name:pchar; isRequiredProperty:BOOL; isInstanceProperty:BOOL):objc_property_t; cdecl = nil;
+  protocol_getProperty : function (proto:PProtocol; name:PAnsiChar; isRequiredProperty:BOOL; isInstanceProperty:BOOL):objc_property_t; cdecl = nil;
   protocol_copyPropertyList : function (proto:PProtocol; outCount:pdword):Pobjc_property_t; cdecl = nil;
   protocol_copyProtocolList : function (proto:PProtocol; outCount:pdword):PArrayPProtocol; cdecl = nil;
 
-  objc_copyImageNames : function (var outCount:dword): PPchar; cdecl = nil;
-  class_getImageName : function (cls:_Class):Pchar; cdecl = nil;
-  objc_copyClassNamesForImage : function (image:pchar; var outCount: Dword):PPchar; cdecl = nil;
+  objc_copyImageNames : function (var outCount:dword): PPAnsiChar; cdecl = nil;
+  class_getImageName : function (cls:_Class):PAnsiChar; cdecl = nil;
+  objc_copyClassNamesForImage : function (image:PAnsiChar; var outCount: Dword):PPAnsiChar; cdecl = nil;
 
   sel_isEqual : function (lhs:SEL; rhs:SEL):BOOL; cdecl = nil;
   objc_enumerationMutation : procedure (_para1:id); cdecl = nil;

+ 27 - 27
packages/objcrtl/src/objcrtl10.pas

@@ -53,7 +53,7 @@ begin
 end;
 
 
-function allocstr(const src: String): Pchar;
+function allocstr(const src: AnsiString): PAnsiChar;
 begin
   Result := ObjCAllocMem(length(src)+1);
   if src <> '' then System.Move(src[1], Result^, length(src));
@@ -126,7 +126,7 @@ type
   objc_class1 = packed record
 	  isa           : Pobjc_class1;
 	  super_class   : Pobjc_class1;
-	  name          : PChar;
+	  name          : PAnsiChar;
 	  version       : culong;
 	  info          : culong;
 	  instance_size : culong;
@@ -143,8 +143,8 @@ type
   //Category1 = Pobjc_category1;
 
   //objc_category1 = packed record
-  // 	category_name     : PChar;
-	//  class_name        : PChar;
+  // 	category_name     : PAnsiChar;
+	//  class_name        : PAnsiChar;
   //  instance_methods  : Pobjc_method_list1;
 	//  class_methods     : Pobjc_method_list1;
   //  protocols         : Pobjc_protocol_list1;
@@ -156,8 +156,8 @@ type
   Ivar1 = Pobjc_ivar1;
 
   objc_ivar1 = packed record
-  	ivar_name   : PChar;
-	  ivar_type   : PChar;
+  	ivar_name   : PAnsiChar;
+	  ivar_type   : PAnsiChar;
   	ivar_offset : cint;
     {$ifdef __alpha__}
   	space: cint;
@@ -178,7 +178,7 @@ type
 
   objc_method1 = packed record
     method_name   : SEL1;
-    method_types  : PChar;
+    method_types  : PAnsiChar;
     method_imp    : IMP1;
   end;
 
@@ -230,15 +230,15 @@ type
     methods : array of objc_method1;
     count   : Integer;
   public
-    procedure AddMethod(name:SEL; imp:IMP; types:pchar);
+    procedure AddMethod(name:SEL; imp:IMP; types:PAnsiChar);
     function AllocMethodList: Pobjc_method_list1;
   end;
   //PClassMethod1Reg = ^TClassMethod1Reg;
 
   TIVar1Reg = record
     size      : Integer;
-    types     : String;
-    name      : String;
+    types     : AnsiString;
+    name      : AnsiString;
     alignment : Uint8_t;
   end;
 
@@ -249,13 +249,13 @@ type
     ivarscount  : Integer;
     ivars       : array of TIVar1Reg;
   public
-    procedure AddIVar(name:pchar; size:size_t; alignment:uint8_t; types:pchar);
+    procedure AddIVar(name:PAnsiChar; size:size_t; alignment:uint8_t; types:PAnsiChar);
     function AllocIVarsList(ivarOffset: Integer; out ivarssize: Integer): Pobjc_ivar_list1;
   end;
 
 { TClassMethod1Reg }
 
-procedure TClassMethod1Reg.AddMethod(name: SEL; imp: IMP; types: pchar);
+procedure TClassMethod1Reg.AddMethod(name: SEL; imp: IMP; types: PAnsiChar);
 begin
   if length(methods) = count then begin
     if count = 0 then SetLength(methods, 4)
@@ -285,8 +285,8 @@ begin
   end;
 end;
 
-procedure TClassIVar1Reg.AddIVar(name: pchar; size: size_t; alignment: uint8_t;
-  types: pchar);
+procedure TClassIVar1Reg.AddIVar(name: PAnsiChar; size: size_t; alignment: uint8_t;
+  types: PAnsiChar);
 begin
   if ivarscount = length(ivars) then begin
     if ivarscount = 0 then SetLength(ivars, 4)
@@ -347,7 +347,7 @@ begin
   Pid1(PtrUInt(obj) + ivar_getOffset(_ivar))^ := value;
 end;
 
-function class_getName10(cls:_Class):PChar; cdecl;
+function class_getName10(cls:_Class):PAnsiChar; cdecl;
 begin
   Result := _Class1(cls)^.name;
 end;
@@ -404,7 +404,7 @@ begin
   Result := nil;
 end;
 
-function objc_allocateClassPair10(superclass:_Class; name:pchar; extraBytes:size_t):_Class; cdecl;
+function objc_allocateClassPair10(superclass:_Class; name:PAnsiChar; extraBytes:size_t):_Class; cdecl;
 var
   super  : _Class1;
   root_class   : _Class1;
@@ -519,7 +519,7 @@ begin
   if new_class <> nil then objc_addClass(new_class);
 end;
 
-function objc_duplicateClass10(original:_Class; name:pchar; extraBytes:size_t):_Class; cdecl;
+function objc_duplicateClass10(original:_Class; name:PAnsiChar; extraBytes:size_t):_Class; cdecl;
 begin
   //todo:
   Result := nil;
@@ -530,12 +530,12 @@ begin
   //todo:
 end;
 
-function class_addMethod10(cls:_Class; name:SEL; _imp:IMP; types:pchar):BOOL; cdecl;
+function class_addMethod10(cls:_Class; name:SEL; _imp:IMP; types:PAnsiChar):BOOL; cdecl;
 begin
   if not Assigned(cls) or not Assigned(name) or not Assigned(_imp) or not Assigned(types) then begin
     {$IFDEF DEBUG}
     write('* Bad params?: cls  = ', Integer(cls));
-    write(' name = ', PChar(name));
+    write(' name = ', PAnsiChar(name));
     write(' imp  = ', Integer(_imp));
     writeln(' type = ', types);
     {$ENDIF}
@@ -553,7 +553,7 @@ begin
   {$ENDIF}
   TClassMethod1Reg(_Class1(cls)^.methodLists).AddMethod(name, _imp, types);
   {$IFDEF DEBUG}
-    writeln('"',PChar(name), '" added successfully');
+    writeln('"',PAnsiChar(name), '" added successfully');
   except
     writeln('* exception while adding method');
   end;
@@ -561,7 +561,7 @@ begin
   Result := true;
 end;
 
-function class_addIvar10(cls:_Class; name:pchar; size:size_t; alignment:uint8_t; types:pchar):BOOL; cdecl;
+function class_addIvar10(cls:_Class; name:PAnsiChar; size:size_t; alignment:uint8_t; types:PAnsiChar):BOOL; cdecl;
 var
   cls1 : _Class1;
 begin
@@ -591,18 +591,18 @@ begin
   Result := IMP(Method1(m)^.method_imp);
 end;
 
-function method_getTypeEncoding10(m:Method):Pchar; cdecl;
+function method_getTypeEncoding10(m:Method):PAnsiChar; cdecl;
 begin
   Result := IMP(Method1(m)^.method_types);
 end;
 
-function method_copyReturnType10(m:Method):Pchar; cdecl;
+function method_copyReturnType10(m:Method):PAnsiChar; cdecl;
 begin
   //todo:
   Result := nil;
 end;
 
-function method_copyArgumentType10(m:Method; index:dword):Pchar; cdecl;
+function method_copyArgumentType10(m:Method; index:dword):PAnsiChar; cdecl;
 begin
   //todo:
   Result := nil;
@@ -615,12 +615,12 @@ begin
   Method1(m)^.method_imp := IMP1(_imp);
 end;
 
-function ivar_getName10(v:Ivar):Pchar; cdecl;
+function ivar_getName10(v:Ivar):PAnsiChar; cdecl;
 begin
   Result := IVar1(v)^.ivar_name;
 end;
 
-function ivar_getTypeEncoding10(v:Ivar):Pchar; cdecl;
+function ivar_getTypeEncoding10(v:Ivar):PAnsiChar; cdecl;
 begin
   Result := IVar1(v)^.ivar_type;
 end;
@@ -635,7 +635,7 @@ begin
   Result := lhs = rhs; //???
 end;
 
-function objc_getProtocol10(name:pchar): PProtocol; cdecl;
+function objc_getProtocol10(name:PAnsiChar): PProtocol; cdecl;
 begin
   //todo:
   Result := nil;

+ 12 - 12
packages/objcrtl/src/objcrtlutils.pas

@@ -17,13 +17,13 @@ interface
 uses
   objcrtl;
 
-function alloc(classname: PChar): id; inline;
-function allocex(classname: PChar; extraBytes: Integer): id; inline;
-function objcclass(classname: PChar): _class; inline;
-function selector(cmdname: PChar): SEL; inline;
+function alloc(classname: PAnsiChar): id; inline;
+function allocex(classname: PAnsiChar; extraBytes: Integer): id; inline;
+function objcclass(classname: PAnsiChar): _class; inline;
+function selector(cmdname: PAnsiChar): SEL; inline;
 procedure release(objc: id); inline;
-function AllocAndInit(classname: PChar): id; inline;
-function AllocAndInitEx(classname: PChar; extraBytes: Integer): id; inline;
+function AllocAndInit(classname: PAnsiChar): id; inline;
+function AllocAndInitEx(classname: PAnsiChar; extraBytes: Integer): id; inline;
 function super(obj: id): objc_super;
 
 implementation
@@ -39,23 +39,23 @@ begin
   Result.class_ := class_getSuperclass(object_getClass(obj));
 end;
 
-function allocex(classname: PChar; extraBytes: Integer): id; inline;
+function allocex(classname: PAnsiChar; extraBytes: Integer): id; inline;
 begin
   Result := class_createInstance( objcclass(classname), extraBytes);
 end;
 
-function alloc(classname: PChar): id; inline;
+function alloc(classname: PAnsiChar): id; inline;
 begin
   Result := allocex(classname, 0);
   // Result := objc_msgSend( objc_getClass(classname), selector('alloc'), []);
 end;
 
-function objcclass(classname: PChar): _class; inline;
+function objcclass(classname: PAnsiChar): _class; inline;
 begin
   Result := _class(objc_getClass(classname));
 end;
 
-function selector(cmdname: PChar): SEL; inline;
+function selector(cmdname: PAnsiChar): SEL; inline;
 begin
   Result := sel_registerName(cmdname);
 end;
@@ -66,13 +66,13 @@ begin
   objc_msgSend(objc, SEL_release, []);
 end;
 
-function AllocAndInit(classname: PChar): id; inline;
+function AllocAndInit(classname: PAnsiChar): id; inline;
 begin
   if SEL_init=nil then SEL_init := selector('init');
   Result:= objc_msgSend( alloc( classname ), SEL_init, []);
 end;
 
-function AllocAndInitEx(classname: PChar; extraBytes: Integer): id; inline;
+function AllocAndInitEx(classname: PAnsiChar; extraBytes: Integer): id; inline;
 begin
   if SEL_init=nil then SEL_init := selector('init');
   Result := objc_msgSend( allocEx( classname, extraBytes ), SEL_init, []);