Author Topic: Listing structure members for memory mapped registers  (Read 4773 times)

belzurkur

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Listing structure members for memory mapped registers
« on: June 30, 2012, 11:05:10 pm »
Greetings,

Old CW user here looking to migrate to SlickEdit.  I'm wondering if there is a way for SlickEdit to list structure members for memory mapped registers that are defined using the method shown below.   

Code: [Select]
#define IO_BASE  0x12345678

typedef struct
{
    unsigned short a;
    unsigned short b;
    unsigned short c;
} IO_Struct;

#define IO_Struct_Ptr  ((IO_Struct *) IO_BASE)

SlickEdit will list structure members if I change the definition to a constant object as shown below, but I'd rather not have to modify the include file for each new platform.

Code: [Select]
IO_Struct * const IO_Struct_Ptr  = (IO_Struct *)IO_BASE;

Any ideas?

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6437
  • Hero Points: 502
Re: Listing structure members for memory mapped registers
« Reply #1 on: July 01, 2012, 12:44:05 am »
You can define global preprocessing (options>lauguage>(category)>C++> preprocessing).

All other preprocessing is unknown when SlickEdit parses your source. Its not obvious to customers why there is this important limitation. Full compilation of your source would ruin our tagging system by killing the performance and requiring tons of exact include information that no one would want to setup.

Graeme

  • Senior Community Member
  • Posts: 2746
  • Hero Points: 340
Re: Listing structure members for memory mapped registers
« Reply #2 on: July 01, 2012, 12:56:35 am »
You can define global preprocessing (options>lauguage>(category)>C++> preprocessing).

All other preprocessing is unknown when SlickEdit parses your source. Its not obvious to customers why there is this important limitation. Full compilation of your source would ruin our tagging system by killing the performance and requiring tons of exact include information that no one would want to setup.

I've been trying this.  It doesn't seem to solve the problem.
With the cursor after IO_Struct_Ptr->    - Alt+dot doesn't give me anything ??

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6437
  • Hero Points: 502
Re: Listing structure members for memory mapped registers
« Reply #3 on: July 01, 2012, 01:26:21 am »
Interesting. The problem is that the parser picks this up but when the expression is evaluated at the cursor, it does not check global preprocessing.

The following works:

Code: [Select]
typedef struct
{
    unsigned short a;
    unsigned short b;
    unsigned short c;
} IO_Struct;
void main(int argc, char *argv[]) {
    ((IO_Struct *) whatever)->
}

but defining IO_Struct_Ptr to "((IO_Struct *) whatever)" doesn't work and then typing IO_Struct_Ptr-> does not work.

Even more interesting is that the following works WITHOUT defining global preprocessing.

Code: [Select]
#define MessageBox MessageBoxA
void MessageBoxA(int a,int b);

void main(int argc, char *argv[]) {
    MessageBox(<Alt+Comma here>
}

I don't know if this limit is intentional or not. It seems to me that if no symbol is found (IO_Struct_Ptr wouldn't be found), fall through code could check for a #define symbol type in the tag file (or current file) which in this case would be found (no need for defining global preprocessing!!!).

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3758
  • Hero Points: 494
Re: Listing structure members for memory mapped registers
« Reply #4 on: July 06, 2012, 04:52:06 pm »
I am adding some code in 17.0.1 to deal with this better.

belzurkur

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: Listing structure members for memory mapped registers
« Reply #5 on: July 10, 2012, 02:58:35 am »
I am adding some code in 17.0.1 to deal with this better.

Thank you, we're ordering three licenses this week.

Is it possible to comment only the selected text in a .c file?  I've only been able to comment an entire line.  I have changed Tools->Options->Languages->C/C++->Comments Comment line from '//' to '/*' & '*/'

The Location choices don't seem to cover 'selected text only'.

In CW, I could select text and just the selected text would be commented rather than the entire lines selected.


Graeme

  • Senior Community Member
  • Posts: 2746
  • Hero Points: 340
Re: Listing structure members for memory mapped registers
« Reply #6 on: July 10, 2012, 12:06:43 pm »
Do you mean if you have just a word selected that the word gets surrounded with /* ... */

If so, you could try this macro.  If there's nothing selected, it comments the current word at the cursor.  To load it, find vusrmacs.e in your configuration folder (or create it if it's not there), then add this code and load it using the load module command on the macro menu.

Code: [Select]
#include "slick.sh"
_command void my_comment_text() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_MARK)
{
   if (!select_active()) {
      select_whole_word();
   }
   _begin_select();
   _insert_text("/*");
   _end_select();
   deselect();
   right();
   right();
   _insert_text("*/");
}

Graeme

  • Senior Community Member
  • Posts: 2746
  • Hero Points: 340
Re: Listing structure members for memory mapped registers
« Reply #7 on: July 10, 2012, 12:12:16 pm »
I noticed after I posted that if the selected text spans more than one line it doesn't work correctly so here's a better version.

Code: [Select]
_command void my_comment_text() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_MARK)
{
   if (!select_active()) {
      select_whole_word();
   }
   _begin_select();
   int pline = p_line;
   _insert_text("/*");
   _end_select();
   deselect();
   if (p_line == pline) {
      right();
      right();
   }
   _insert_text("*/");
}

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3758
  • Hero Points: 494
Re: Listing structure members for memory mapped registers
« Reply #8 on: July 10, 2012, 02:25:38 pm »
You could use Surround With.  You just need to add a surround alias for comments, as follows:

1) Go to Document > C/C++ Options... > Aliases
2) Click on "Surround With"
3) Click "New..."
4) Name the alias "comment"
5) Make the text of the alias the following:
Code: [Select]
/*%\m sur_text -nobeautify%*/6) Then select your text, right click for and select Surround With... and choose "comment"

Then if you want to do it again, really fast.

1) Select some text again
2) Macro > Record Macro...
3) Right click and select Surround With... and choose "comment"
4) Macro > Stop Recording...
5) name the macro "my_comment_selection"
6) Click "Save and Bind to Key..." and pick a key binding or function key.

OR...

1) Select some text
2) Right click and choose "Edit this menu..."
3) Click on the entry for "Surround Selection With..."
4) Then click on "Insert After" and add a new menu entry named "Comment Selection" with the command name "surround-with comment" and message "Comment out selected text"

Now you can select and comment stuff out all day long.

We are looking into adding a "comment_selection" command and fixing "comment_erase" to handle selections or unstructured comments better.

belzurkur

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: Listing structure members for memory mapped registers
« Reply #9 on: July 10, 2012, 03:49:34 pm »
These are great, thank you both very much.