Book a Demo

Author Topic: C++ PHP Code generation and attribute types  (Read 4173 times)

reddog

  • EA User
  • **
  • Posts: 26
  • Karma: +0/-0
    • View Profile
C++ PHP Code generation and attribute types
« on: December 08, 2004, 02:47:34 am »
Hi,
I am evaluating EA and I have some code generation questions.

Assume classA has an attribute int age.

If I then generate c++ then that's fine.  
If I later decide classA is to be PHP I end up with int $age;

Q1. Is there any way to design with variables being 'swapped' for appropriate language mappings at generation time? Thus int age; -> var $age;  ?

This could be done in some form of mapping screen, or maybe a 'swap variables for var's' option once we have a PHP dialog under tools- options.  Maybe a swapping options appears if we change the class language mapping?

Of course I can 'dance the dialogs' and change the attributes --- but what if I change my mind and then want java?

Q2. Associations normally map to attribute pointers - thats fine, but they are public, can I force them to be private?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: C++ PHP Code generation and attribute types
« Reply #1 on: December 08, 2004, 08:15:42 pm »
There isn't any way to map between datatypes from different languages when you change languages.  Generally EA doesn't expect that once you've modelled a class you'll be converting to a different language.  There will often be things that are only in one language, these just can't be transerred between the languages.

The problem with generating the wrong thing for PHP is nice and simple.  The template needs to be modified to always generate var instead of looking at the type.  I'll do that for the default templates, but it still doesn't really solve your problem.

Look in the Association Properties dialog, Target Role tab and in the top right there is a drop-down box "Access".

Simon

reddog

  • EA User
  • **
  • Posts: 26
  • Karma: +0/-0
    • View Profile
Re: C++ PHP Code generation and attribute types
« Reply #2 on: December 09, 2004, 03:58:02 pm »
Thanks for the info.

I take your point about language and design, it is just that one can switch between java and c++ for code gen/reverse  in Together and that works  fine --- of course it 'don't do' php !!

I had not found the Association Properties dialog etc, so I gave it a try --- but it switchs back to public for each new link, can one set a default other than public??

Also what is the 'configuration - programming language datatype' dialog used for?  

Maybe EA could somehow use this for mapping?

eg in the dialog, for c++
"Common Type" Integer -> "Datatype" int

so maybe , for php
"Common Type" Integer -> "Datatype" var $

Just a thought.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: C++ PHP Code generation and attribute types
« Reply #3 on: December 09, 2004, 06:46:34 pm »
I don't really know Together, but if you compare the datatypes for C++ and Java they're pretty much the same.  (Not including libraries)  It may do nothing at all with the datatypes.

You're on the right track with the common type, but the problem is when you don't have a one-one mapping.

As for the scope switching back to public all the time, from memory we have a request to make EA store the last scope used and use that for any new associations.  I don't know what is happening with it though.

Simon

reddog

  • EA User
  • **
  • Posts: 26
  • Karma: +0/-0
    • View Profile
Re: C++ PHP Code generation and attribute types
« Reply #4 on: December 10, 2004, 05:38:04 am »
Thanks for the reply(s).