elk icon indicating copy to clipboard operation
elk copied to clipboard

Add layout option type registration to melk

Open uruuru opened this issue 8 years ago • 1 comments

Due to the changes introduced in pull request #192, a mechanism to register layout option types (that implement IDataObject) should be added to the melk language, e.g.:

type KVector

The type must provide a default constructor and if the type is Cloneable it must implement a reasonable clone method. The following code is then generated as part of the *MetaDataProvider.

ElkReflect.register(KVector.class, 
             () -> new KVector(),
             (v) -> ((KVector)v).clone());

The documentation of layout options must be updated accordingly.

uruuru avatar Jul 05 '17 13:07 uruuru

As discussed in #236, the classes generated from the melk language are probably the wrong place for this because they might not be invoked yet when someone tries to access a default value that requires ElkReflect registration. The initialization code should be as close as possible to the actual Java type declaration, e.g. KVector should register itself in a static initializer.

spoenemann avatar Sep 11 '17 13:09 spoenemann