Menu

Diff of /trunk/Src/USourceGen.pas [r14] .. [r15]  Maximize  Restore

Switch to side-by-side view

--- a/trunk/Src/USourceGen.pas
+++ b/trunk/Src/USourceGen.pas
@@ -71,6 +71,8 @@
  *                        methods as IncludeSnippets & IncludeSnippets.
  *                      - Added support for calling conventions and overload
  *                        directives in routine prototypes.
+ * v2.1 of 08 Jul 2009  - Fixed bug where units required by constants and type
+ *                        definitions were not being added to generated units.
  *
  *
  * ***** BEGIN LICENSE BLOCK *****
@@ -130,6 +132,13 @@
   TConstAndTypeList = class(TObject)
   strict private
     type
+      {
+      TUnitRecorder:
+        Method that is called to record the units required by a constant or
+        type.
+          @param Units [in] String list containing list of units.
+      }
+      TUnitRecorder = procedure(const Units: TStringList) of object;
       {
       TEnumerator:
         Enumerator for snippets in TConstAndTypeList.
@@ -178,7 +187,7 @@
     destructor Destroy; override;
       {Class destructor. Tears down object.
       }
-    procedure Add(const ConstOrType: TRoutine);
+    procedure Add(const ConstOrType: TRoutine; const UnitRecorder: TUnitRecorder);
       {Adds a constant or type snippet to the list, ignoring duplicates.
         @param ConstOrType [in] Constant or type snippet to be added.
         @except Exception raised if dependency list is not valid.
@@ -202,12 +211,13 @@
   }
   TSourceAnalyser = class(TObject)
   strict private
-    fTypesAndConsts: TConstAndTypeList; // Value of TypesAndConsts property
-    fIntfRoutines: TRoutineList;        // Value of IntfRoutines property
-    fAllRoutines: TRoutineList;         // Value of AllRoutines property
-    fForwardRoutines: TRoutineList;     // Value of ForwardRoutines property
-    fRequiredRoutines: TRoutineList;    // Value of RequiredRoutines property
-    fUnits: TStringList;                // Value of Units property
+    var
+      fTypesAndConsts: TConstAndTypeList; // Value of TypesAndConsts property
+      fIntfRoutines: TRoutineList;        // Value of IntfRoutines property
+      fAllRoutines: TRoutineList;         // Value of AllRoutines property
+      fForwardRoutines: TRoutineList;     // Value of ForwardRoutines property
+      fRequiredRoutines: TRoutineList;    // Value of RequiredRoutines property
+      fUnits: TStringList;                // Value of Units property
     procedure AddIntfRoutine(const Routine: TRoutine);
       {Adds a user-specified routine to list of routines specified by user.
       Duplicates ignored.
@@ -784,7 +794,7 @@
     @param TypeOrConst [in] Type of constant snippet to be added.
   }
 begin
-  fTypesAndConsts.Add(TypeOrConst);
+  fTypesAndConsts.Add(TypeOrConst, RequireUnits);
 end;
 
 constructor TSourceAnalyser.Create;
@@ -898,7 +908,7 @@
 
 { TConstAndTypeList }
 
-procedure TConstAndTypeList.Add(const ConstOrType: TRoutine);
+procedure TConstAndTypeList.Add(const ConstOrType: TRoutine; const UnitRecorder: TUnitRecorder);
   {Adds a constant or type snippet to the list, ignoring duplicates.
     @param ConstOrType [in] Constant or type snippet to be added.
     @except Exception raised if dependency list is not valid.
@@ -919,7 +929,8 @@
   // Add all required snippets to list before adding this one: this ensures
   // required snippets preceed those that depend on them
   for RequiredSnip in ConstOrType.Depends do
-    Add(RequiredSnip);
+    Add(RequiredSnip, UnitRecorder);
+  UnitRecorder(ConstOrType.Units);
   fItems.Add(ConstOrType)
 end;
 
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.