[Lazarus] How do I tell codetools to use implicitly loaded unit for code complesion?

Michael Ring mail at michael-ring.org
Wed Oct 22 22:05:33 CEST 2014


OK, I found out what is going on.

FindControllerUnit in components/codetools/definetemplates.pas already 
contains a copy of the arm version of cpuinfo.pas but it does not 
include the mips version of cpuinfo.pas.

so FindControllerUnit does not find a match and returns an empty string 
-> the Value of -Wp get discarded.

I have attached a patch that adds the missing definitions for mipsel.

Please note that the definitions differ from the ones in trunk; I have 
asked sergej to merge my latest changes for mipsel but he did not yet 
find the time to do so.

So trunk is outdated and it makes no sense to use the definitions 
currently available there.

Michael

Am 22.10.14 um 09:51 schrieb Michael Ring:
> Thank you for the hint on macros, I will see if I can come up with a 
> patch.
>
> The lookup of the controllerunitstr looks like the 'right' solution, 
> for my purposes it would be enough to simply add the value of -Wp, but 
> this would only help for mipsel target, for arm there usually exists a 
> mapping from the controller model to a more generalized unit.
>
> How do you import definitions like those, do you duplicate the code 
> from fpc or do you use the units provided by fpc?
>
> If you duplicate the code it is perhaps better to also make the unit 
> files match the controller names in fpc so that the list of 
> controllers does not need to get implemented in both fpc and lazarus.
>
> Michael
>
> Am 21.10.14 um 23:28 schrieb Mattias Gaertner:
>>
>>> Michael Ring <mail at michael-ring.org> hat am 21. Oktober 2014 um 22:27
>>> geschrieben:
>>> [...]
>>> Example: -Wppic32mx795f512h
>>>
>>> should load unit pic32mx795f512h
>> The IDE already does that.
>> Search for MacroControllerUnit.
>>
>>> to make life a (very little) harder the fully correct rule for 
>>> selecting
>>> the right unit is:
>>>
>>> search for uppercase(-WpVALUE) in array embeddedcontrollers (defined in
>>> [arm,mipsel,avr]/cpuinfo.pas) and load the unit with name defined in 
>>> the
>>> field controllerunitstr
>>>
>>> Is something like this doable?
>> Theoretically yes. Is that needed?
>>
>>
>>> I already hardcoded the unit for my testing purposes (Works fine), but
>>> failed to find a way to get the value of the -Wp switch in
>>> GetHiddenUsedUnits.
>> Mattias
>>
>> -- 
>> _______________________________________________
>> Lazarus mailing list
>> Lazarus at lists.lazarus.freepascal.org
>> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
>
> -- 
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
Index: components/codetools/definetemplates.pas
===================================================================
--- components/codetools/definetemplates.pas	(revision 46642)
+++ components/codetools/definetemplates.pas	(working copy)
@@ -6618,7 +6618,7 @@
       controllerunitstr: string[20];
     end;
   const
-    ControllerTypes: array[0..211] of TControllerType =
+    ControllerTypes: array[0..302] of TControllerType =
      ((controllertypestr:'';                  controllerunitstr:''),
       (controllertypestr:'LPC810M021FN8';     controllerunitstr:'LPC8xx'),
       (controllertypestr:'LPC811M001FDH16';   controllerunitstr:'LPC8xx'),
@@ -6830,7 +6830,99 @@
       (controllertypestr:'XMC4500X768';       controllerunitstr:'XMC4500'),
       (controllertypestr:'XMC4502X768';       controllerunitstr:'XMC4502'),
       (controllertypestr:'XMC4504X512';       controllerunitstr:'XMC4504'),
-      (controllertypestr:'THUMB2_BARE';       controllerunitstr:'THUMB2_BARE'));
+      (controllertypestr:'THUMB2_BARE';       controllerunitstr:'THUMB2_BARE'),
+      (controllertypestr:'PIC32MX110F016B';	controllerunitstr:'PIC32MX110F016B'),
+      (controllertypestr:'PIC32MX110F016C';	controllerunitstr:'PIC32MX110F016C'),
+      (controllertypestr:'PIC32MX110F016D';	controllerunitstr:'PIC32MX110F016D'),
+      (controllertypestr:'PIC32MX120F032B';	controllerunitstr:'PIC32MX120F032B'),
+      (controllertypestr:'PIC32MX120F032C';	controllerunitstr:'PIC32MX120F032C'),
+      (controllertypestr:'PIC32MX120F032D';	controllerunitstr:'PIC32MX120F032D'),
+      (controllertypestr:'PIC32MX130F064B';	controllerunitstr:'PIC32MX130F064B'),
+      (controllertypestr:'PIC32MX130F064C';	controllerunitstr:'PIC32MX130F064C'),
+      (controllertypestr:'PIC32MX130F064D';	controllerunitstr:'PIC32MX130F064D'),
+      (controllertypestr:'PIC32MX150F128B';	controllerunitstr:'PIC32MX150F128B'),
+      (controllertypestr:'PIC32MX150F128C';	controllerunitstr:'PIC32MX150F128C'),
+      (controllertypestr:'PIC32MX150F128D';	controllerunitstr:'PIC32MX150F128D'),
+      (controllertypestr:'PIC32MX170F256B';	controllerunitstr:'PIC32MX170F256B'),
+      (controllertypestr:'PIC32MX170F256C';	controllerunitstr:'PIC32MX170F256C'),
+      (controllertypestr:'PIC32MX170F256D';	controllerunitstr:'PIC32MX170F256D'),
+      (controllertypestr:'PIC32MX210F016B';	controllerunitstr:'PIC32MX210F016B'),
+      (controllertypestr:'PIC32MX210F016C';	controllerunitstr:'PIC32MX210F016C'),
+      (controllertypestr:'PIC32MX210F016D';	controllerunitstr:'PIC32MX210F016D'),
+      (controllertypestr:'PIC32MX220F032B';	controllerunitstr:'PIC32MX220F032B'),
+      (controllertypestr:'PIC32MX220F032C';	controllerunitstr:'PIC32MX220F032C'),
+      (controllertypestr:'PIC32MX220F032D';	controllerunitstr:'PIC32MX220F032D'),
+      (controllertypestr:'PIC32MX230F064B';	controllerunitstr:'PIC32MX230F064B'),
+      (controllertypestr:'PIC32MX230F064C';	controllerunitstr:'PIC32MX230F064C'),
+      (controllertypestr:'PIC32MX230F064D';	controllerunitstr:'PIC32MX230F064D'),
+      (controllertypestr:'PIC32MX250F128B';	controllerunitstr:'PIC32MX250F128B'),
+      (controllertypestr:'PIC32MX250F128C';	controllerunitstr:'PIC32MX250F128C'),
+      (controllertypestr:'PIC32MX250F128D';	controllerunitstr:'PIC32MX250F128D'),
+      (controllertypestr:'PIC32MX270F256B';	controllerunitstr:'PIC32MX270F256B'),
+      (controllertypestr:'PIC32MX270F256C';	controllerunitstr:'PIC32MX270F256C'),
+      (controllertypestr:'PIC32MX270F256D';	controllerunitstr:'PIC32MX270F256D'),
+      (controllertypestr:'PIC32MX320F032H';	controllerunitstr:'PIC32MX320F032H'),
+      (controllertypestr:'PIC32MX320F064H';	controllerunitstr:'PIC32MX320F064H'),
+      (controllertypestr:'PIC32MX320F128H';	controllerunitstr:'PIC32MX320F128H'),
+      (controllertypestr:'PIC32MX320F128L';	controllerunitstr:'PIC32MX320F128L'),
+      (controllertypestr:'PIC32MX330F064H';	controllerunitstr:'PIC32MX330F064H'),
+      (controllertypestr:'PIC32MX330F064L';	controllerunitstr:'PIC32MX330F064L'),
+      (controllertypestr:'PIC32MX340F128H';	controllerunitstr:'PIC32MX340F128H'),
+      (controllertypestr:'PIC32MX340F128L';	controllerunitstr:'PIC32MX340F128L'),
+      (controllertypestr:'PIC32MX340F256H';	controllerunitstr:'PIC32MX340F256H'),
+      (controllertypestr:'PIC32MX340F512H';	controllerunitstr:'PIC32MX340F512H'),
+      (controllertypestr:'PIC32MX350F128H';	controllerunitstr:'PIC32MX350F128H'),
+      (controllertypestr:'PIC32MX350F128L';	controllerunitstr:'PIC32MX350F128L'),
+      (controllertypestr:'PIC32MX350F256H';	controllerunitstr:'PIC32MX350F256H'),
+      (controllertypestr:'PIC32MX350F256L';	controllerunitstr:'PIC32MX350F256L'),
+      (controllertypestr:'PIC32MX360F256L';	controllerunitstr:'PIC32MX360F256L'),
+      (controllertypestr:'PIC32MX360F512L';	controllerunitstr:'PIC32MX360F512L'),
+      (controllertypestr:'PIC32MX370F512H';	controllerunitstr:'PIC32MX370F512H'),
+      (controllertypestr:'PIC32MX370F512L';	controllerunitstr:'PIC32MX370F512L'),
+      (controllertypestr:'PIC32MX420F032H';	controllerunitstr:'PIC32MX420F032H'),
+      (controllertypestr:'PIC32MX430F064H';	controllerunitstr:'PIC32MX430F064H'),
+      (controllertypestr:'PIC32MX430F064L';	controllerunitstr:'PIC32MX430F064L'),
+      (controllertypestr:'PIC32MX440F128H';	controllerunitstr:'PIC32MX440F128H'),
+      (controllertypestr:'PIC32MX440F128L';	controllerunitstr:'PIC32MX440F128L'),
+      (controllertypestr:'PIC32MX440F256H';	controllerunitstr:'PIC32MX440F256H'),
+      (controllertypestr:'PIC32MX440F512H';	controllerunitstr:'PIC32MX440F512H'),
+      (controllertypestr:'PIC32MX450F128H';	controllerunitstr:'PIC32MX450F128H'),
+      (controllertypestr:'PIC32MX450F128L';	controllerunitstr:'PIC32MX450F128L'),
+      (controllertypestr:'PIC32MX450F256H';	controllerunitstr:'PIC32MX450F256H'),
+      (controllertypestr:'PIC32MX450F256L';	controllerunitstr:'PIC32MX450F256L'),
+      (controllertypestr:'PIC32MX460F256L';	controllerunitstr:'PIC32MX460F256L'),
+      (controllertypestr:'PIC32MX460F512L';	controllerunitstr:'PIC32MX460F512L'),
+      (controllertypestr:'PIC32MX460F512H';	controllerunitstr:'PIC32MX460F512H'),
+      (controllertypestr:'PIC32MX460F512L';	controllerunitstr:'PIC32MX460F512L'),
+      (controllertypestr:'PIC32MX534F064H';	controllerunitstr:'PIC32MX534F064H'),
+      (controllertypestr:'PIC32MX534F064L';	controllerunitstr:'PIC32MX534F064L'),
+      (controllertypestr:'PIC32MX564F064H';	controllerunitstr:'PIC32MX564F064H'),
+      (controllertypestr:'PIC32MX564F064L';	controllerunitstr:'PIC32MX564F064L'),
+      (controllertypestr:'PIC32MX564F128H';	controllerunitstr:'PIC32MX564F128H'),
+      (controllertypestr:'PIC32MX564F128L';	controllerunitstr:'PIC32MX564F128L'),
+      (controllertypestr:'PIC32MX575F256H';	controllerunitstr:'PIC32MX575F256H'),
+      (controllertypestr:'PIC32MX575F256L';	controllerunitstr:'PIC32MX575F256L'),
+      (controllertypestr:'PIC32MX575F512H';	controllerunitstr:'PIC32MX575F512H'),
+      (controllertypestr:'PIC32MX575F512L';	controllerunitstr:'PIC32MX575F512L'),
+      (controllertypestr:'PIC32MX664F064H';	controllerunitstr:'PIC32MX664F064H'),
+      (controllertypestr:'PIC32MX664F064L';	controllerunitstr:'PIC32MX664F064L'),
+      (controllertypestr:'PIC32MX664F128H';	controllerunitstr:'PIC32MX664F128H'),
+      (controllertypestr:'PIC32MX664F128L';	controllerunitstr:'PIC32MX664F128L'),
+      (controllertypestr:'PIC32MX675F256H';	controllerunitstr:'PIC32MX675F256H'),
+      (controllertypestr:'PIC32MX675F256L';	controllerunitstr:'PIC32MX675F256L'),
+      (controllertypestr:'PIC32MX675F512H';	controllerunitstr:'PIC32MX675F512H'),
+      (controllertypestr:'PIC32MX675F512L';	controllerunitstr:'PIC32MX675F512L'),
+      (controllertypestr:'PIC32MX695F512H';	controllerunitstr:'PIC32MX695F512H'),
+      (controllertypestr:'PIC32MX695F512L';	controllerunitstr:'PIC32MX695F512L'),
+      (controllertypestr:'PIC32MX764F128H';	controllerunitstr:'PIC32MX764F128H'),
+      (controllertypestr:'PIC32MX764F128L';	controllerunitstr:'PIC32MX764F128L'),
+      (controllertypestr:'PIC32MX775F256H';	controllerunitstr:'PIC32MX775F256H'),
+      (controllertypestr:'PIC32MX775F256L';	controllerunitstr:'PIC32MX775F256L'),
+      (controllertypestr:'PIC32MX775F512H';	controllerunitstr:'PIC32MX775F512H'),
+      (controllertypestr:'PIC32MX775F512L';	controllerunitstr:'PIC32MX775F512L'),
+      (controllertypestr:'PIC32MX795F512H';	controllerunitstr:'PIC32MX795F512H'),
+      (controllertypestr:'PIC32MX795F512L';	controllerunitstr:'PIC32MX795F512L'));
+
   var
     i: integer;
     str: String;


More information about the Lazarus mailing list