Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » B3 » Using B3 language with Java classes
Using B3 language with Java classes [message #606388] Mon, 10 May 2010 13:46 Go to next message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
Hi,

I just manage to launch an eclipse workbench with the B3 language.
I try to create a simple example.
My workspace look like it :
A java package called "test1",
In this package, to Class called "A.java" and "B,java",
A folder called ''B3Files';
In this folder, a b3 file called test1.B3.

in test.b3 I try to import the package test1, but I don't manage to do it.
I also implement the method : function square(Number x) : x * x ;
As written in the B3Book manual page 24.
but B3 don't recognize the class "Number"
I think it miss an import

thanks,

Jérémie
Re: Using B3 language with Java classes [message #606390 is a reply to message #606388] Mon, 10 May 2010 14:29 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Hi,
An example with a square function for Number would look like this:

square.b3--------------
import java.util.List;
import java.lang.Number;

function main(List argv) : square(3) ;

function square(Number n) : n * n;
----------

Will check that the documentation shows this correctly.
(A note, type inference is not that smart yet, and as a result, a bit
more typing than what the finished b3 will have is required).

Regarding access to classes.
----
The b3 environment sees classes from all bundles that are visible from
the OSGi managed classpath. To make b3 see more things, a bundle needs
to declare itself to be a buddy of b3.

So, if you want to call java code from B3, create a bundle, and add the
following to the MANIFEST.MF of the bundle where you have the classes
you want to expose to b3.

Eclipse-RegisterBuddy: org.eclipse.b3.backend

This is done in the org.eclipse.b3.beelang.tests project/bundle.

- henrik


On 5/10/10 3:46 PM, jeremie wrote:
> Hi,
>
> I just manage to launch an eclipse workbench with the B3 language.
> I try to create a simple example.
> My workspace look like it :
> A java package called "test1",
> In this package, to Class called "A.java" and "B,java",
> A folder called ''B3Files';
> In this folder, a b3 file called test1.B3.
>
> in test.b3 I try to import the package test1, but I don't manage to do it.
> I also implement the method : function square(Number x) : x * x ;
> As written in the B3Book manual page 24.
> but B3 don't recognize the class "Number"
> I think it miss an import
>
> thanks,
> Jérémie
>
>
>
>
Re: Using B3 language with Java classes [message #606394 is a reply to message #606388] Mon, 10 May 2010 14:32 Go to previous message
jeremie is currently offline jeremieFriend
Messages: 233
Registered: April 2010
Senior Member
I manage to use the Class number :

import java.lang.Number;

But I still can't import My owned classes : test1.A and test1.B
Previous Topic:first launch of an eclipse workbench with B3 language
Next Topic:first launch of an eclipse workbench with B3 language
Goto Forum:
  


Current Time: Thu Dec 26 16:28:45 GMT 2024

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

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

Back to the top