Skip to content
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

Improve the output code generated from Ballerina bindgen tool #40222

Open
NipunaRanasinghe opened this issue Apr 13, 2023 · 0 comments
Open

Improve the output code generated from Ballerina bindgen tool #40222

NipunaRanasinghe opened this issue Apr 13, 2023 · 0 comments
Assignees
Labels
Area/Bindgen Ballerina bindgen tool Priority/Low Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) Type/Improvement

Comments

@NipunaRanasinghe
Copy link
Contributor

NipunaRanasinghe commented Apr 13, 2023

Description

There seems to be some cases where the generated ballerina binding code can be improved using more optimized and readable syntax.

As an example, refer to the below code generated by the existing tool, that can be improved using query expressions.

public function f2(Foo[] arg0) returns Foo[]|error {
        handle externalObj = Foo_objArrayParamReturns(self.jObj, check jarrays:toHandle(arg0, "Foo"));
        Foo[] newObj = [];
        handle[] anyObj = <handle[]>check jarrays:fromHandle(externalObj, "handle");
        int count = anyObj.length();
        foreach int i in 0 ... count - 1 {
            Foo element = new (anyObj[i]);
            newObj[i] = element;
        }
        return newObj;
}

Describe your problem(s)

No response

Describe your solution(s)

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@NipunaRanasinghe NipunaRanasinghe added Type/Improvement Priority/Low Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) Area/Bindgen Ballerina bindgen tool labels Apr 13, 2023
@NipunaRanasinghe NipunaRanasinghe self-assigned this Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/Bindgen Ballerina bindgen tool Priority/Low Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) Type/Improvement
Projects
None yet
Development

No branches or pull requests

1 participant