codetools: parsing objcclass external name

git-svn-id: trunk@29293 -
This commit is contained in:
mattias 2011-02-01 16:55:50 +00:00
parent 29a1093583
commit a7c6e1a13f
4 changed files with 75 additions and 17 deletions

1
.gitattributes vendored
View File

@ -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/missingh2pasdirectives.pas svneol=native#text/plain
components/codetools/examples/scanexamples/modemacpas.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/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/overloadedfunction.pas svneol=native#text/plain
components/codetools/examples/scanexamples/publishedvars.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 components/codetools/examples/scanexamples/resourcetest1.pas svneol=native#text/plain

View File

@ -93,18 +93,19 @@ const
ctnClassAbstract = 40; ctnClassAbstract = 40;
ctnClassSealed = 41; ctnClassSealed = 41;
ctnClassInheritance = 42; ctnClassExternal = 42;
ctnClassGUID = 43; ctnClassInheritance = 43;
ctnClassConst = 44; ctnClassGUID = 44;
ctnClassType = 45; ctnClassConst = 45;
ctnClassVar = 46; ctnClassType = 46;
ctnClassClassVar = 47; ctnClassVar = 47;
ctnClassPrivate = 48; ctnClassClassVar = 48;
ctnClassProtected = 49; ctnClassPrivate = 49;
ctnClassPublic = 50; ctnClassProtected = 50;
ctnClassPublished = 51; ctnClassPublic = 51;
ctnProperty = 52; ctnClassPublished = 52;
ctnMethodMap = 53; ctnProperty = 53;
ctnMethodMap = 54;
ctnProcedure = 60; // childs: ctnProcedureHead, sections, ctnBeginBlock/ctnAsmBlock ctnProcedure = 60; // childs: ctnProcedureHead, sections, ctnBeginBlock/ctnAsmBlock
ctnProcedureHead = 61; // childs: ctnParameterList, operator: ctnVarDefinition, operator/function: ctnResultType ctnProcedureHead = 61; // childs: ctnParameterList, operator: ctnVarDefinition, operator/function: ctnResultType
@ -163,7 +164,7 @@ const
ctnCPPClass]; ctnCPPClass];
AllClassInterfaces = [ctnClassInterface,ctnDispinterface,ctnObjCProtocol]; AllClassInterfaces = [ctnClassInterface,ctnDispinterface,ctnObjCProtocol];
AllClassObjects = [ctnClass,ctnObject,ctnObjCClass,ctnObjCCategory,ctnCPPClass]; AllClassObjects = [ctnClass,ctnObject,ctnObjCClass,ctnObjCCategory,ctnCPPClass];
AllClassModifiers = [ctnClassAbstract, ctnClassSealed]; AllClassModifiers = [ctnClassAbstract, ctnClassSealed, ctnClassExternal];
AllDefinitionSections = AllDefinitionSections =
[ctnTypeSection,ctnVarSection,ctnConstSection,ctnResStrSection, [ctnTypeSection,ctnVarSection,ctnConstSection,ctnResStrSection,
ctnLabelSection]; ctnLabelSection];
@ -382,6 +383,7 @@ begin
ctnClassClassVar: Result:='Class Var'; ctnClassClassVar: Result:='Class Var';
ctnClassAbstract: Result:='abstract'; ctnClassAbstract: Result:='abstract';
ctnClassSealed: Result:='sealed'; ctnClassSealed: Result:='sealed';
ctnClassExternal: Result:='external';
ctnProcedure: Result:='Procedure'; ctnProcedure: Result:='Procedure';
ctnProcedureHead: Result:='ProcedureHead'; ctnProcedureHead: Result:='ProcedureHead';

View File

@ -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.

View File

@ -744,7 +744,7 @@ begin
// set CursorPos after class head // set CursorPos after class head
MoveCursorToNodeStart(ClassNode); MoveCursorToNodeStart(ClassNode);
// parse // parse
// - sealed, abstract // - sealed, abstract, external
// - inheritage // - inheritage
// - class sections (GUID, type, var, public, published, private, protected) // - class sections (GUID, type, var, public, published, private, protected)
// - methods (procedures, functions, constructors, destructors) // - methods (procedures, functions, constructors, destructors)
@ -776,6 +776,18 @@ begin
EndChildNode; EndChildNode;
ReadNextAtom; ReadNextAtom;
end; 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;
end; end;
// parse the inheritage // parse the inheritage
@ -3794,10 +3806,12 @@ begin
IsForward:=false; IsForward:=false;
while UpAtomIs('ABSTRACT') do while UpAtomIs('ABSTRACT') do
ReadNextAtom; ReadNextAtom;
end else if UpAtomIs('EXTERNAL') then begin end else if (ClassDesc in [ctnObjCClass]) and UpAtomIs('EXTERNAL') then begin
ReadNextAtom; ReadNextAtom;
if CurPos.Flag<>cafSemicolon then if UpAtomIs('NAME') then begin
RaiseCharExpectedButAtomFound(';'); ReadNextAtom;
ReadConstant(true,false,[]);
end;
end; end;
if (CurPos.Flag=cafRoundBracketOpen) then begin if (CurPos.Flag=cafRoundBracketOpen) then begin
// read inheritage brackets // read inheritage brackets