Book a Demo

Author Topic: Typedefs and function pointers  (Read 6015 times)

inad

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Typedefs and function pointers
« on: February 26, 2009, 08:33:31 pm »
Apologies if this has been already answered. Forum search yields no results.

Are there any specific stereotypes, tagged values, etc in EA that can be used to model a C/C++ function pointer typedef ?

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Typedefs and function pointers
« Reply #1 on: February 27, 2009, 12:48:54 am »
Yes, but you need to know where to look.

In the EA help index look up C++ | Modeling conventions. You will find what you need, as well as some other useful stuff.

I checked EA 7.1 build 834 and the 7.5 beta so you should be OK with either.

HTH, David
No, you can't have it!

inad

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: Typedefs and function pointers
« Reply #2 on: February 27, 2009, 09:04:41 pm »
Thanks. I actually tried some sample code to see how EA imported it into a UML model as well. I can see that the conventions you mention are followed, but not really for function pointers. E.g.:

Code: [Select]
typedef signed int sint32;
yields a typedef stereotyped class with signed int as a parent just as the documentation says.

However:

Code: [Select]
typedef int (*fnptr_t)(int arg1, void *arg2);
results in nothing. If you declare a variable or a class member of that type:

Code: [Select]
fnptr_t f;
that simply shows inside the class as a member of type:

Code: [Select]
fnptr_t
without the type itself being modelled.

Since I don't plan to use the code generation feature and I just want to show a function pointer in my model, I think I'll just use a typedef stereotyped class with an operation having the signature of the function the pointer points to. Probably not kosher UML but it'll do.
« Last Edit: February 27, 2009, 09:06:08 pm by inad »

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Typedefs and function pointers
« Reply #3 on: February 28, 2009, 01:06:38 am »
Hi inad,

Hmm, I'm not really sure if this fits what you want to do, but isn't a function pointer something like a degenerate interface that contains only a single operation with the signature specified in the function pointer definition?
So instead of using a specially stereotyped class, you could define just such an interface.

WBR
Günther