Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Define an int array return type
Define an int array return type [message #1769220] Fri, 28 July 2017 01:18 Go to next message
Waqas Ilyas is currently offline Waqas IlyasFriend
Messages: 80
Registered: July 2009
Member
Hi,

How can I define a data type rule that returns an int array?

Like for example have a look at this rule:

Bytes returns ecore::EByteArray hidden():
	TOKEN
;


The bytes here are unsigned so I want to use ecore:EIntArray instead. How can I do that?

Regards,
Waqas
Re: Define an int array return type [message #1769230 is a reply to message #1769220] Fri, 28 July 2017 06:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
i dont know a EIntArray in ecore.
so do you want to use a own edatatype and use it in xtext?
i think you need

- create a external ecore that define that datatype
- import that ecore in xtext
- write a valueconverter that supports the converstion from token to int[] and vice versa


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Define an int array return type [message #1769305 is a reply to message #1769230] Sat, 29 July 2017 01:22 Go to previous messageGo to next message
Waqas Ilyas is currently offline Waqas IlyasFriend
Messages: 80
Registered: July 2009
Member
Thanks a lot for the reply. I can write value converters, right now I am using ecore::EJavaObject and my converter returns int[]. But how do i create an external ecore datatype, and import it into Xtext? Any pointers would be really helpful.
Re: Define an int array return type [message #1769306 is a reply to message #1769305] Sat, 29 July 2017 05:13 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
That requires some basic reading on the eclipse modeling framework (emf)

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Define an int array return type [message #1769309 is a reply to message #1769306] Sat, 29 July 2017 05:56 Go to previous messageGo to next message
Waqas Ilyas is currently offline Waqas IlyasFriend
Messages: 80
Registered: July 2009
Member
I am familiar with EMF... have worked with it for a few years, but that was quite some time ago. I can try my hands at it again. Some pointers would be helpful.
Re: Define an int array return type [message #1769310 is a reply to message #1769309] Sat, 29 July 2017 06:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Create empty emf project
Add Xtext nature

Create a ecore file
Create a epackage with a edatatype
Create genmodel
Generate code

Import package in Xtext

Adapt workflow
(referencedResource=.......genmodel"



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Define an int array return type [message #1769831 is a reply to message #1769310] Thu, 03 August 2017 19:55 Go to previous message
Waqas Ilyas is currently offline Waqas IlyasFriend
Messages: 80
Registered: July 2009
Member
It worked perfectly, thanks a lot for all the help.
Previous Topic:modify the signature of "doGenerate" function
Next Topic:Xtext 2.11 has the option to switch parser entry rule from outside
Goto Forum:
  


Current Time: Fri Apr 26 06:22:43 GMT 2024

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

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

Back to the top