Browse Source

*fix compile warnings and hints in googleapiconv and googlediscoverytopas

  - Fix compiler warnings and hints and unused local variables
  - Change deprecated ClassHeader to ClassComment
  - Fix comment in helper script
wsherman 2 years ago
parent
commit
6453af40d8

+ 3 - 4
packages/googleapi/generator/googleapiconv.pp

@@ -197,7 +197,7 @@ procedure TGoogleAPIConverter.RegisterUnit(FileName :String; L : TAPIEntries);
 
 Var
   I : Integer;
-  UN,N,V : String;
+  UN,N : String;
 
 begin
   UN:=ChangeFileext(ExtractFileName(FileName),'');
@@ -268,10 +268,9 @@ procedure TGoogleAPIConverter.CreateFPMake(FileName :String; L : TAPIEntries);
 
 Var
   I : Integer;
-  UN,N,V : String;
+  N : String;
 
 begin
-  UN:=ChangeFileext(ExtractFileName(FileName),'');
   With TStringList.Create do
     try
       Add('program fpmake;');
@@ -307,7 +306,7 @@ begin
       For I:=0 to L.Count-1 do
         begin
         N:=L[i].APIUnitName;
-        Add(Format('    T:=StdDep(P.Targets.AddUnit(''%s''));',[ExtractFileName(L[i].FAPIUnitName)]));
+        Add(Format('    T:=StdDep(P.Targets.AddUnit(''%s''));',[ExtractFileName(N)]));
         end;
       Add('    end;');
       Add('end;');

+ 15 - 15
packages/googleapi/generator/googlediscoverytopas.pp

@@ -702,7 +702,9 @@ begin
         DoLog('Class type, adding properties first');
         CollectTypes(S.Properties,NamePrefix+S.Name+PropertyTypeSuffix);
         end;
-    end;
+  else
+    //no other cases to handle
+  end;
   if (NamePrefix='') then
     AddType(S,'',True)
   else if (Not S.BaseType) and (Not BaseArrayElement) and (S.Ref='') then
@@ -920,7 +922,7 @@ Var
 begin
   if ASchema=Nil then
     Raise Exception.Create(AClassName+' : no Schema');
-  ClassHeader(AClassName);
+  ClassComment(AClassName);
   AddLn('%s = Class(%s)',[AClassName,BaseClassName]);
   AddLn('Private');
   NeedGetWriteName:=False;
@@ -998,7 +1000,7 @@ begin
     Raise Exception.Create(AClassName+' : no item Schema');
   AItemName:=GetPropertyType('',AItemSchema);
   AEnumeratorName:=AClassName+'Enumerator';
-  ClassHeader(AEnumeratorName);
+  ClassComment(AEnumeratorName);
   AddLn('%s = Class(%s)',[AEnumeratorName,'TBaseListEnumerator']);
   AddLn('Public');
   IncIndent;
@@ -1008,7 +1010,7 @@ begin
   AddLn('end;');
   AddLn('');
   AddLn('');
-  ClassHeader(AClassName);
+  ClassComment(AClassName);
   AddLn('%s = Class(%s)',[AClassName,BaseListClassName]);
   AddLn('Private');
   IncINdent;
@@ -1030,10 +1032,6 @@ end;
 
 procedure TDiscoveryJSONToPas.CreateSetArrayLength(AClassName: String; ASchema, AItemSchema: TSchema);
 
-Var
-  S : TSchema;
-  N : String;
-
 begin
   //not used
 end;
@@ -1081,7 +1079,7 @@ Var
 begin
   NeedGetWriteName:=False;
   NeedSetArrayLength:=False;
-  ClassHeader(AClassName);
+  ClassComment(AClassName);
   For S in ASchema.ClassProperties do
     begin
     N:=S.PropertyName;
@@ -1120,7 +1118,7 @@ begin
   CreateArrayClassEnumeratorImplementation(ACLassName,ASchema,AItemSchema);
   AItemName:=GetPropertyType('',AItemSchema);
   AEnumeratorName:=AClassName+'Enumerator';
-  ClassHeader(AClassName);
+  ClassComment(AClassName);
   Addln('');
   Addln('Function %s.GetI (AIndex : Integer) : %s;',[AClassName,AItemName]);
   SimpleMethodBody([Format('Result:=%s(Objects[AIndex]);',[AItemName])]);
@@ -1147,7 +1145,7 @@ begin
     Raise Exception.Create(AClassName+' : no ItemSchema');
   AItemName:=GetPropertyType('',AItemSchema);
   AEnumeratorName:=AClassName+'Enumerator';
-  ClassHeader(AEnumeratorName);
+  ClassComment(AEnumeratorName);
   AddLn('Function %s.GetCurrent  : %s;',[AEnumeratorName,AItemName]);
   SimpleMethodBody([Format('Result:=%s(Inherited GetCurrent);',[AItemName])]);
 end;
@@ -1238,6 +1236,8 @@ begin
       dtClass: CreateClassImplementation(S.PascalName,S.Schema,S.ItemSchema);
       dtArray: if UseListForArray then
        CreateArrayClassImplementation(S.PascalName,S.Schema,S.ItemSchema);
+    else
+      //no other cases to handle
     end;
   CreateResourceClassImplementations('',Description.Resources);
   CreateAPIClassImplementation;
@@ -1464,7 +1464,7 @@ Var
 
 begin
   CN:=Res.TypeName;
-  ClassHeader(CN);
+  ClassComment(CN);
   For M in Res.methods do
     begin
     AssignParamNames(Res,M);
@@ -1667,7 +1667,7 @@ Var
 
 begin
   CN:=Res.TypeName;
-  ClassHeader(CN);
+  ClassComment(CN);
   CreateResourceClassMethodsImplementation(Res,CN);
   For M in Res.methods do
     begin
@@ -1753,7 +1753,7 @@ Var
 
 begin
   CN:=GetAPIClassName;
-  Classheader(CN);
+  ClassComment(CN);
   AddLn('%s = Class(TGoogleAPI)',[CN]);
   AddLn('Private');
   IncIndent;
@@ -1814,7 +1814,7 @@ Var
 
 begin
   CN:=GetAPIClassName;
-  ClassHeader(CN);
+  ClassComment(CN);
   AddLn('Class Function %s.APIName : String;',[CN]);
   StringRes(Description.name);
   AddLn('Class Function %s.APIVersion : String;',[CN]);

+ 1 - 1
packages/googleapi/generator/run_google_api_bindings_gen.sh

@@ -4,7 +4,7 @@
 #   If they exist, this script deletes the "./_google_api_bindings_tmp"
 #   and "./_google_api_icons_tmp" directories before attempting
 #   to convert new files. It does not download any JSON, but works on
-#   files which must already be present in "./_google_api_bindings_tmp"
+#   files which must already be present in "./_google_api_json_tmp"
 #   (use "./fetch_google_json.sh" to download the JSON files)
 
 shopt -s nocaseglob  #ignore case for filename matches