Re: deelang usage

36 views
Skip to first unread message

Ross Bamford

unread,
Mar 16, 2013, 7:06:10 PM3/16/13
to deelang...@googlegroups.com
Hi,

It looks like you're expecting the block to be called if your method returns true, which isn't quite how it works. When a block is attached to a method, it's the method's responsibility to call the block. In order to make your method work as you appear to be expecting, you'd write the Java like:

import dee.lang.Block;

// ... later ...

public void compi(Block block, DeelangInteger a, DeelangInteger b) {
    if( a.equals(b)) 
        block.invoke();
  else
  getBinding().setErrorFlag(); // this will make the or block execute instead.
}

Note that the above code assumes your object extends DeelangObject (for the getBinding() method). If that's not the case, you'd need to stash the binding somewhere yourself. However, since you appear to be using the object as the self reference, it's really recommended to extend DeelangObject (or you'll find that many things, such as the or keyword, don't work).

Hope that helps!

Kind regards,
Ross

On Saturday, 16 March 2013 23:04:55 UTC, Deelang - General Discussion wrote:
---------- Forwarded message ----------
From: Stefan Dörr <doerrst@...>
Date: Wed, Mar 13, 2013 at 11:07 PM
Subject: deelang usage
To: roscopeco@<...>


Hello,

I'm sorry to bother you, but I have a question about the usage of deelang and couldn't find the answer after hours of research. Perhaps you could be that nice to help me here.

According to the example posted it looks like I can pass simple return values from java functions and evaluate then like this:

di1=1
di2=1
log("Test Var")
compi(di1,di2) {
log("equals")
} or {
log("not equal")
}

where compi is defined as:

public DeelangBoolean compi(DeelangInteger a, DeelangInteger b)
{
if( a.equals(b)) 
return binding.TRUE;
else
return binding.FALSE;
}

Unfortunately it fails with:

03-13 23:37:34.935: W/System.err(18781): com.roscopeco.deelang.compiler.dex.UnknownMethodException: Cannot bind method call 'de.giminisoft.gamepad.ScriptInterface.compi' with block and arguments [Ldee/lang/DeelangInteger;, Ldee/lang/DeelangInteger;]
03-13 23:37:34.945: W/System.err(18781):  at com.roscopeco.deelang.compiler.dex.DexCompilationUnit.visitMethodCall(Unknown Source)
03-13 23:37:34.950: W/System.err(18781):  at com.roscopeco.deelang.compiler.ASTVisitor.visit(Unknown Source)
03-13 23:37:34.955: W/System.err(18781):  at com.roscopeco.deelang.compiler.Compiler.compile(Unknown Source)
03-13 23:37:34.960: W/System.err(18781):  at com.roscopeco.deelang.compiler.Compiler.compile(Unknown Source)
03-13 23:37:34.965: W/System.err(18781):  at de.giminisoft.gamepad.MainActivity.onCreate(MainActivity.java:192)
03-13 23:37:34.970: W/System.err(18781):  at android.app.Activity.performCreate(Activity.java:5206)
03-13 23:37:34.975: W/System.err(18781):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
03-13 23:37:34.985: W/System.err(18781):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
03-13 23:37:34.990: W/System.err(18781):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
03-13 23:37:34.995: W/System.err(18781):  at android.app.ActivityThread.access$600(ActivityThread.java:140)
03-13 23:37:35.005: W/System.err(18781):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
03-13 23:37:35.005: W/System.err(18781):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-13 23:37:35.010: W/System.err(18781):  at android.os.Looper.loop(Looper.java:137)
03-13 23:37:35.020: W/System.err(18781):  at android.app.ActivityThread.main(ActivityThread.java:4898)
03-13 23:37:35.025: W/System.err(18781):  at java.lang.reflect.Method.invokeNative(Native Method)
03-13 23:37:35.030: W/System.err(18781):  at java.lang.reflect.Method.invoke(Method.java:511)
03-13 23:37:35.035: W/System.err(18781):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
03-13 23:37:35.040: W/System.err(18781):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
03-13 23:37:35.045: W/System.err(18781):  at dalvik.system.NativeStart.main(Native Method)

Furthermore I tried to use a simple function like this one:

public DeelangBoolean getTrue()
{
return binding.TRUE;
}

with this simple deelang-code:

log("Test Var")
getTrue() {
log("equals")
}

but also here the compiling fails.

My next try was this one

di1.equals(di2) {
     log("equal")
}

which also was not working. 

Could you give me a hint what I am doing wrong here? 

I am using deelang-complete-nocli-novm-0.22.jar in my own program to compile the deelang-code. 

Thank you in advance!

Best Regards,



Stefan

Reply all
Reply to author
Forward
0 new messages