Recent

Author Topic: h2paswizard: Retain comments in original line within typedef/type conversions  (Read 428 times)

BrainChemistry

  • Jr. Member
  • **
  • Posts: 75
Hello,

h2paswizard translates the C struct below correctly into the corresponding Pascal record, but the comments are cut out and inserted at the top. This behaviour seems to be hardcoded in h2pas (the underlying tool) and I cannot think of a way to prevent this with a pre-h2pas or after-h2pas tools (chains). - Or am I missing anything?

Any hint desired. Best regards.

Example:

Code: C  [Select][+][-]
  1. typedef struct SDL_HapticDirection
  2. {
  3.     Uint8 type;         /**< The type of encoding. */
  4.     Sint32 dir[3];      /**< The encoded direction. */
  5. } SDL_HapticDirection;

This is what happens (comments copied at the top):
Code: Pascal  [Select][+][-]
  1. {*< The type of encoding.  }
  2. {*< The encoded direction.  }
  3. type
  4.   PSDL_HapticDirection = ^TSDL_HapticDirection;
  5.   TSDL_HapticDirection = record
  6.       type_: cuint8;
  7.       dir: array[0..2] of cint32;
  8.     end;

This is what is desired (comments retain next to fields):

Code: Pascal  [Select][+][-]
  1. type
  2.   PSDL_HapticDirection = ^TSDL_HapticDirection;
  3.   TSDL_HapticDirection = record
  4.       type_: cuint8;                    {*< The type of encoding.  }
  5.       dir: array[0..2] of cint32;       {*< The encoded direction.  }
  6.     end;

Leledumbo

  • Hero Member
  • *****
  • Posts: 8530
  • Programming + Glam Metal + Tae Kwon Do = Me
Interestingly, here's the offending commit message:
Quote
commit 31a3763f12bb5605dd59173822a1765adec41ae0
Author: carl <carl@freepascal.org>
Date:   Fri Aug 13 02:35:29 2004 +0000

      + bugfixes with C++ comments, they are now placed above the definition
      * some bugfixes with the _label reserved word.
So the behavior seems intentional. Just note that date, seems nobody touches this since then.

BrainChemistry

  • Jr. Member
  • **
  • Posts: 75
Interestingly, here's the offending commit message:
Quote
commit 31a3763f12bb5605dd59173822a1765adec41ae0
Author: carl <carl@freepascal.org>
Date:   Fri Aug 13 02:35:29 2004 +0000

      + bugfixes with C++ comments, they are now placed above the definition
      * some bugfixes with the _label reserved word.
So the behavior seems intentional. Just note that date, seems nobody touches this since then.

Thanks for the hint. I conclude from the commit message that there are troubles if comments are placed next to the fields with C++ comments. Maybe there is a better solution for this though except for adding all the comment above. For example there could be a switch to influence the result.

Seenkao

  • Sr. Member
  • ****
  • Posts: 431
    • New ZenGL.
Если мне память не изменяет, то вы можете сделать стандартные комментарии, такие как "//" или "(* ... *)" и они не изменят своего местоположения при переводе. Но я могу ошибаться. Уже около года как не переводил.

google translate:
If my memory serves me, you can make standard comments like "//" or "(* ... *)" and they won't change their location when translated. But I may be wrong. I haven't translated for about a year now.
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.
Работаю над ZenGL.
Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL. :)

 

TinyPortal © 2005-2018