Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6789] Android: KrollFunction Doesn't Allow for Return Values

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2011-12-30T16:38:55.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sRelease 2.0.0, Release 1.8.1
ComponentsAndroid
Labelsmodule_module, qe-testadded
ReporterDawson Toth
AssigneeDawson Toth
Created2011-12-20T12:38:28.000+0000
Updated2014-06-19T12:44:40.000+0000

Description

Problem

With the 1.8.0.1 changes and KrollFunction being introduced, return values were overlooked.

Why it was Overlooked

Nothing in core or our private modules utilizes this portion of the API. But our demo module in the public repository makes use of it, and there may be third party developers that are using it.

How to Test

Create a new module: {quote} titanium create --type=module --name=testcb --id=ti.testcb --platform=android {quote} Update the TestcbModule.java:
package ti.testcb;

import java.util.HashMap;

import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.KrollFunction;
import org.appcelerator.kroll.annotations.Kroll;

@Kroll.module(name="Testcb", id="ti.testcb")
public class TestcbModule extends KrollModule
{
        public TestcbModule()
        {
                super();
        }

        @Kroll.method     
        public String initiateCrank(KrollFunction crank) {
                return crank.call(getKrollObject(), new HashMap()).toString();
        }
}
Update the example/app.js:
var win = Ti.UI.createWindow({
        backgroundColor: '#fff'
});
win.add(Ti.UI.createLabel({
        text: require('ti.testcb').initiateCrank(function() {
                return 'PASS: Is your refrigerator running? Tee hee.';
        }) || 'FAIL: Critical failure of joke Kroll traversal!'
}));
win.open();

Pull Request

Master: https://github.com/appcelerator/titanium_mobile/pull/1072 1_8_X: https://github.com/appcelerator/titanium_mobile/pull/1073

Comments

  1. Wilson Luu 2012-01-12

    Closing bug. Verified fix on: SDK build: 1.9.0.v20120112104633 Runtime: V8, Rhino Titanium Studio, build: 1.0.8.201201111843 Device: Droid 3 (2.3.4)

JSON Source