Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF] Configure code generation to respect existing modelpackage indexes
[EMF] Configure code generation to respect existing modelpackage indexes [message #1002119] Fri, 18 January 2013 01:04 Go to next message
Warwick Burrows is currently offline Warwick BurrowsFriend
Messages: 87
Registered: July 2009
Location: Austin, TX
Member
Hi,

I'm adding some new objects to my Ecore model and was wondering if its possible to direct the genmodel generation to respect the existing indexes used for classes, types, etc that are defined in the ModelPackage class. I added the classes to the end of the ecore file and the indexes generated are all correct except that the new class indexes are inserted before the last type's index definition and the last type's index is incremented then by the number of new classes. Which of course will not be binary compatible with existing compiled code. I tried setting "@generated NOT" in the comment for the last type's index definition (an enum type) but the generation process ignores it, resulting in both the enum type and the first new type sharing the same model package index.

Thanks,
Warwick
Re: [EMF] Configure code generation to respect existing modelpackage indexes [message #1002243 is a reply to message #1002119] Fri, 18 January 2013 08:35 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 26213
Registered: July 2009
Senior Member
Warwick,

Comments below.

On 18/01/2013 2:04 AM, Warwick Burrows wrote:
> Hi,
>
> I'm adding some new objects to my Ecore model and was wondering if its
> possible to direct the genmodel generation to respect the existing
> indexes used for classes, types, etc that are defined in the
> ModelPackage class.
You should add the classifiers to the end of the package. They're based
on the index in the list of GenPackage.genClassifiers
> I added the classes to the end of the ecore file and the indexes
> generated are all correct except that the new class indexes are
> inserted before the last type's index definition and the last type's
> index is incremented then by the number of new classes.
Yes, unfortunately the list of GenPackage.genClassifiers is reconciled
against the EPackage.eClassifiers like this

public boolean reconcile()
{
EPackage ePackage = getEcorePackage();
if (ePackage == null || ePackage.eIsProxy() || ePackage.eResource()
== null)
{
return false;
}
else
{
for (Iterator<GenClass> i = getGenClasses().iterator();
i.hasNext(); )
{
GenClass genClass = i.next();
if (!genClass.reconcile())
{
i.remove();
}
}

for (Iterator<GenEnum> i = getGenEnums().iterator(); i.hasNext(); )
{
GenEnum genEnum = i.next();
if (!genEnum.reconcile())
{
i.remove();
}
}

for (Iterator<GenDataType> i = getGenDataTypes().iterator();
i.hasNext(); )
{
GenDataType genDataType = i.next();
if (!genDataType.reconcile())
{
i.remove();
}
}

I.e., all the classes come first. That particularly use for the
generated Switch because it ensures that EClass IDs are consecutive
without gaps...

> Which of course will not be binary compatible with existing compiled
> code. I tried setting "@generated NOT" in the comment for the last
> type's index definition (an enum type) but the generation process
> ignores it, resulting in both the enum type and the first new type
> sharing the same model package index.
Note these indexes are generally only used within the generated model
itself, not by client code, i.e., in the generated Switch and
Validator. Not sure if API tooling allows you to mark them as "no
access" or something like that...
>
> Thanks,
> Warwick
Previous Topic:Existing XMI, meta-model changes
Next Topic:Create additional resource on file open
Goto Forum:
  


Current Time: Fri Nov 21 02:40:58 GMT 2014

Powered by FUDForum. Page generated in 0.02836 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software