diff --git a/bindings/pascocoa/parser/ObjCParserTypes.pas b/bindings/pascocoa/parser/ObjCParserTypes.pas index 206186846..ccea05247 100755 --- a/bindings/pascocoa/parser/ObjCParserTypes.pas +++ b/bindings/pascocoa/parser/ObjCParserTypes.pas @@ -439,12 +439,13 @@ type TObjCClassProperty = class(TEntity) protected + function DoParse(AParser: TTextParser): Boolean; override; + public _Attribs : TObjCPropertyAttributes; _Getter : AnsiString; _Setter : AnsiString; _Type : TEntity; _Name : AnsiString; - function DoParse(AParser: TTextParser): Boolean; override; end; TClassDef = class(TEntity) @@ -2901,6 +2902,7 @@ begin Result := true; end; + initialization finalization diff --git a/bindings/pascocoa/parser/ObjCParserUtils.pas b/bindings/pascocoa/parser/ObjCParserUtils.pas index 42a5ae56c..894427c40 100755 --- a/bindings/pascocoa/parser/ObjCParserUtils.pas +++ b/bindings/pascocoa/parser/ObjCParserUtils.pas @@ -98,6 +98,16 @@ function GetObjCVarType(const TypeName: AnsiString):TObjcConvertVarType; //): Bo implementation +function GetterSetterName(const PropName: AnsiString; etterName: AnsiString; isSetter: Boolean): AnsiString; +begin + if etterName = '' then begin + if isSetter then Result := 'set'+PropName + else Result := 'get'+PropName; + end else + Result := etterName; +end; + + procedure WriteOutRecordField(AField: TStructField; const Prefix: AnsiString; subs: TStrings); forward; procedure WriteOutRecord(struct: TEntityStruct; const Prefix, RecPrefix : AnsiString; subs: TStrings); forward; @@ -1165,20 +1175,29 @@ var mtds : TStringList; // name of methods restype: TObjCResultTypeDef; + // over : TStringList; // overloaded names + + isProtEmpty : Boolean; + protidx : Integer; + pr : TObjCClassProperty; const SpacePrefix = ' '; begin + isProtEmpty := true; + subs.Add(''); subs.Add(' { '+cl._ClassName +' }'); subs.Add(''); s := ' ' + cl._ClassName + ' = class'; if cl._SuperClass <> '' then begin subs.Add(s + '('+cl._SuperClass+')'); + protidx := subs.Count; subs.Add(' public'); subs.Add(' class function getClass: objc.id; override;'); end else begin subs.Add(s + '{from category '+ cl._Category +'}'); + protidx := subs.Count; subs.Add(' public'); end; @@ -1212,16 +1231,34 @@ begin if cmt <> '' then s := s + '{'+cmt+'}'; end; - + subs.Add(SpacePrefix + s); end else if obj is TPrecompiler then begin WriteOutIfDefPrecompiler(TPrecompiler(obj), SpacePrefix, subs); end; end; + + for j := 0 to cl.Items.Count - 1 do begin + obj := TObject(cl.Items[j]); + if obj is TObjCClassProperty then begin + pr := obj as TObjCClassProperty; + subs.Add(' property ' + pr._Name+';'); + + if isProtEmpty then begin + subs.Insert(protidx, ' protected'); inc(protidx); + isProtEmpty := false; + end; + subs.Insert(protidx, ' function '+GetterSetterName(pr._Name, pr._Getter, false)+';'); + inc(protidx); + subs.Insert(protidx, ' procedure '+GetterSetterName(pr._Name, pr._Setter, true) +';'); + inc(protidx); + end; + end; + finally mtds.Free; end; - + subs.Add(' end;'); subs.Add(''); end; diff --git a/bindings/pascocoa/parser/objcparser.pas b/bindings/pascocoa/parser/objcparser.pas index a8e855cb5..19d1b2ed9 100755 --- a/bindings/pascocoa/parser/objcparser.pas +++ b/bindings/pascocoa/parser/objcparser.pas @@ -20,9 +20,8 @@ uses IniFiles, SysUtils, ObjCParserUtils, - ObjCParserTypes, - gnuccFeatures, - ObjCToPas in 'ObjCToPas.pas'; + ObjCParserTypes, + gnuccFeatures; type // this object is used only for precomile directives handling