8000 Programatically calling a generator without passing metamodel as argument · Issue #432 · textX/textX · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Programatically calling a generator without passing metamodel as argument #432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
argenos opened this issue Apr 3, 2025 · 1 comment

Comments

@argenos
Copy link
argenos commented Apr 3, 2025

I'm trying to programmatically call a generator. The documentation suggests using generator_for_language_target(language_name, target_name, any_permitted=False) to get the callable, but this requires me to pass the metamodel as an argument robot_to_java(robot_mm, my_model) (from the examples).

According to the documentation , the GeneratorDesc should have a metamodel attribute, however this seems to be missing. For example, getting the description for textx->dot and looking at the attributes with dir():

gen_desc = generator_descriptions().get("textx").get("dot")
print(dir(gen_desc))

Returns the following attributes:

['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'description', 'generator', 'language', 'project_name', 'project_version', 'target']

Is there a way for me to use the metamodels already available to textx?

@igordejanovic
Copy link
Member

You are right. Looks like a bug in the docs.

You can get a meta-model of registered language using language_desciptions() function.

I think that this API needs some rework as the generator should be bound to its language and thus GeneratorDesc.generator function should accept only the model as the meta-model should be bound on generator description construction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0