diff --git a/.gitattributes b/.gitattributes index 944bde1e8a..738ea85ac0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -472,6 +472,7 @@ components/codetools/examples/scanexamples/methodjump1.pas svneol=native#text/pl components/codetools/examples/scanexamples/missingh2pasdirectives.pas svneol=native#text/plain components/codetools/examples/scanexamples/modemacpas.pas svneol=native#text/plain components/codetools/examples/scanexamples/nestedclasses.pas svneol=native#text/plain +components/codetools/examples/scanexamples/objctest1.pas svneol=native#text/plain components/codetools/examples/scanexamples/overloadedfunction.pas svneol=native#text/plain components/codetools/examples/scanexamples/publishedvars.pas svneol=native#text/plain components/codetools/examples/scanexamples/resourcetest1.pas svneol=native#text/plain diff --git a/components/codetools/codetree.pas b/components/codetools/codetree.pas index d00d2c7d7e..182fa74e29 100644 --- a/components/codetools/codetree.pas +++ b/components/codetools/codetree.pas @@ -93,18 +93,19 @@ const ctnClassAbstract = 40; ctnClassSealed = 41; - ctnClassInheritance = 42; - ctnClassGUID = 43; - ctnClassConst = 44; - ctnClassType = 45; - ctnClassVar = 46; - ctnClassClassVar = 47; - ctnClassPrivate = 48; - ctnClassProtected = 49; - ctnClassPublic = 50; - ctnClassPublished = 51; - ctnProperty = 52; - ctnMethodMap = 53; + ctnClassExternal = 42; + ctnClassInheritance = 43; + ctnClassGUID = 44; + ctnClassConst = 45; + ctnClassType = 46; + ctnClassVar = 47; + ctnClassClassVar = 48; + ctnClassPrivate = 49; + ctnClassProtected = 50; + ctnClassPublic = 51; + ctnClassPublished = 52; + ctnProperty = 53; + ctnMethodMap = 54; ctnProcedure = 60; // childs: ctnProcedureHead, sections, ctnBeginBlock/ctnAsmBlock ctnProcedureHead = 61; // childs: ctnParameterList, operator: ctnVarDefinition, operator/function: ctnResultType @@ -163,7 +164,7 @@ const ctnCPPClass]; AllClassInterfaces = [ctnClassInterface,ctnDispinterface,ctnObjCProtocol]; AllClassObjects = [ctnClass,ctnObject,ctnObjCClass,ctnObjCCategory,ctnCPPClass]; - AllClassModifiers = [ctnClassAbstract, ctnClassSealed]; + AllClassModifiers = [ctnClassAbstract, ctnClassSealed, ctnClassExternal]; AllDefinitionSections = [ctnTypeSection,ctnVarSection,ctnConstSection,ctnResStrSection, ctnLabelSection]; @@ -382,6 +383,7 @@ begin ctnClassClassVar: Result:='Class Var'; ctnClassAbstract: Result:='abstract'; ctnClassSealed: Result:='sealed'; + ctnClassExternal: Result:='external'; ctnProcedure: Result:='Procedure'; ctnProcedureHead: Result:='ProcedureHead'; diff --git a/components/codetools/examples/scanexamples/objctest1.pas b/components/codetools/examples/scanexamples/objctest1.pas new file mode 100644 index 0000000000..ffa446b5ff --- /dev/null +++ b/components/codetools/examples/scanexamples/objctest1.pas @@ -0,0 +1,41 @@ +unit objctest1; + +{$mode objfpc}{$H+} +{$modeswitch objectivec2} + +interface + +uses + Classes, SysUtils; + +type + NSSomeObject = objcclass(NSObject) + procedure method_(params: Integer); message 'method:'; + class procedure classmethod_(para: char); override; // "message 'classmethod:'" not required, compiler will get this from the parent class + end; + +type + ObjCClassName1 = objcclass + private + end; + + ObjCClassName2 = objcclass external name 'ExternalClassName' (ObjCSuperClassName, ProtocolName) + private + end; + + ObjCClassName3 = objcclass external (ObjCSuperClassName) + private + end; + + ObjCClassName4 = objcclass external + private + end; + + ObjCClassName5 = objcclass (ObjCSuperClassName) + private + end; + +implementation + +end. + diff --git a/components/codetools/pascalparsertool.pas b/components/codetools/pascalparsertool.pas index 0892faaf08..adeb6f1f6a 100644 --- a/components/codetools/pascalparsertool.pas +++ b/components/codetools/pascalparsertool.pas @@ -744,7 +744,7 @@ begin // set CursorPos after class head MoveCursorToNodeStart(ClassNode); // parse - // - sealed, abstract + // - sealed, abstract, external // - inheritage // - class sections (GUID, type, var, public, published, private, protected) // - methods (procedures, functions, constructors, destructors) @@ -776,6 +776,18 @@ begin EndChildNode; ReadNextAtom; end; + end + else if UpAtomIs('EXTERNAL') and (ClassNode.Desc in [ctnObjCClass]) then + begin + CreateChildNode; + CurNode.Desc:=ctnClassExternal; + ReadNextAtom; + if UpAtomIs('NAME') then begin + ReadNextAtom; + ReadConstant(true,false,[]); + end; + CurNode.EndPos:=CurPos.StartPos; + EndChildNode; end; end; // parse the inheritage @@ -3794,10 +3806,12 @@ begin IsForward:=false; while UpAtomIs('ABSTRACT') do ReadNextAtom; - end else if UpAtomIs('EXTERNAL') then begin + end else if (ClassDesc in [ctnObjCClass]) and UpAtomIs('EXTERNAL') then begin ReadNextAtom; - if CurPos.Flag<>cafSemicolon then - RaiseCharExpectedButAtomFound(';'); + if UpAtomIs('NAME') then begin + ReadNextAtom; + ReadConstant(true,false,[]); + end; end; if (CurPos.Flag=cafRoundBracketOpen) then begin // read inheritage brackets