|
Re: [EMF] Configure code generation to respect existing modelpackage indexes [message #1002243 is a reply to message #1002119] |
Fri, 18 January 2013 08:35 |
Ed Merks Messages: 33113 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
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03875 seconds