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

swim.structure polyglot language bindings #12

Open
18 tasks
c9r opened this issue Sep 25, 2019 · 2 comments
Open
18 tasks

swim.structure polyglot language bindings #12

c9r opened this issue Sep 25, 2019 · 2 comments
Assignees
Labels
A-polyglot Area: polyglot language bindings C-enhancement Category: enhancement

Comments

@c9r
Copy link
Member

c9r commented Sep 25, 2019

Flesh out polyglot language bindings for the swim-structure Java library. The bindings are located in the swim-dynamic-structure Java library. The JavaScript bindings should be compatible with the @swim/structure TypeScript library. Make sure to bind static methods, in addition to instance methods.

Structure bindings

  • Add Item bindings.
  • Add Field bindings.
  • Add Attr bindings.
  • Add Slot bindings.
  • Add Value bindings
  • Add Record bindings
  • Add Data bindings.
  • Add Text bindings.
  • Add Num bindings.
  • Add Bool bindings.
  • Add Extant bindings.
  • Add Absent bindings.

Expression bindings

  • Add Expression bindings.
  • Add Operator bindings.
  • Add Selector bindings.
  • Add Func bindings.
  • Add Interpreter bindings.

Form bindings

  • Add Form bindings.
@c9r c9r added C-enhancement Category: enhancement A-polyglot Area: polyglot language bindings labels Sep 25, 2019
@c9r c9r added this to the 3.11 milestone Sep 25, 2019
@ajay-gov
Copy link
Member

ajay-gov commented Oct 7, 2019

Item 1 is a Slot. This should work I think but maybe this is not what you want to do?
assertEquals(context.eval("js", "record.getItem(1).stringValue().asString()"), "number"); assertEquals(context.eval("js", "record.getItem(1).key.numberValue()").asInt(), 78);

@freyadyu
Copy link

Hey Chris,

I committed my code with HostItem.java and ItemTypeSpec.java. I converted all methods in Item.java with corresponding functionalities in Item.ts, but I listed some left over questions I had while developing, we can sync when you in the office. At the meantime, I'll keep working on the rest of the list:

  • In Item.ts, there're only stringValue(), numberValue(), and booleanValue(). But in Item.java, besides those three methods, there're byteValue(), shortValue(), intValue(), longValue(), floatValue(), doubleValue(), integerValue(), charValue(). I added those in HostItem.java, but not sure whether I should keep them there cause there's no corresponding method in Item.ts.

  • If we want to keep those method in HostItem, I also met a problem while writing test case with integerValue(), need your instruction.

  • Met problem with writing HostLambda test case

  • For HostItemFilter, HostItemEvaluate, HostItemSubstitute, they involved with Selector and Interpreter bindings, need your instruction

  • For HostItemCast, HostItemCoerce, HostItemDisplay, HostItemDebug, HostItemGlobalScope need your instruction for test case

  • For HostItemFromObject test case, I met question with test case that fromObject() takes map as parameter with following error exception:
    Map<String, String> map = new HashMap<>();
    map.put("foo", "bar");
    bindings.putMember("mapOb", bridge.hostToGuest(Item.fromObject(map)));
    assertEquals(bridge.guestToHost(context.eval("js", "mapOb")), Slot.of("foo", "bar"));

    error:
      swim.dynamic.structure.ItemTypeSpec > testFromObject FAILED
      java.lang.IllegalArgumentException: {foo=bar}
      	at swim.structure/swim.structure.Value.fromObject(Value.java:1049)
      	at swim.structure/swim.structure.Item.fromObject(Item.java:943)
      	at swim.dynamic.structure/	 
        swim.dynamic.structure.ItemTypeSpec.testFromObject(ItemTypeSpec.java:87)
    
  • assertEqual case failed for HostItemToString

@ajay-gov ajay-gov removed this from the 3.11 milestone May 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-polyglot Area: polyglot language bindings C-enhancement Category: enhancement
Projects
None yet
Development

No branches or pull requests

3 participants