badly formed .kl output

I am trying to wrap the vector class in Arnold, but I am mirroring the built-in Math extension.

ext_AtPoint = ext.add_mirror('AtPoint', 'Vec3', 'Math')\
  .add_comment("""/**
 * 3D point (single precision)
 */""")

the code compiles with scons but the test fails with a syntax error, this is the generated code...

Float32 AtPoint_CxxConstPtr.cxxGet_x()
{
    if (Fabric_Guarded && !this.ptr)
        throw "Call of AtPoint_CxxConstPtr.cxxGet_x on null AtPoint_CxxConstPtr";
    return this.ptr->{  }.cxxGet_x();
}

Comments

  • scaronscaron Posts: 163

    I didn't even know this ->{whatever} syntax was valid .kl so I searched the builtin extensions and found it deep in Jerome's work with Containers and FabricSynchronization. What does it do?

  • benblobenblo Posts: 27

    Uh, didn't know either... I gotta say, the fact that there's isn't a comprehensive specification for the KL language is kind of annoying. Or even a proper reference for the builtin types (ref page for String anyone?)

    Anyway, looks to me like like data->{Type} is casting a Data pointer back to the actual object it's pointing at, as seen in FabricSynchronization/ComputeContext.kl:

    inline Float32 Float32.atomicGet!( ) {
      Data d = this.data();
      d->{UInt32}.atomicGet();
      return this;
    }
    

    (Actually in that particular case it looks like a reinterpret_cast.)

    But in your case, AtPoint_CxxConstPtr isn't a Data object (or is it?)... I'd imagine what's missing is something like:

    return this.ptr->{AtPoint}.cxxGet_x();
    

    R&D Developer at Dwarf Animation Studio

  • scaronscaron Posts: 163

    @benblo said:

    But in your case, AtPoint_CxxConstPtr isn't a Data object (or is it?)... I'd imagine what's missing is something like:

    return this.ptr->{AtPoint}.cxxGet_x();
    

    Yes, that is what it should be but it is obviously just missing... If I put AtPoint in there it works, but there are many many of them.

  • jfriedmanjfriedman Posts: 79 ✭✭

    I'm getting the same thing. I'm also in the dark about what ->{} actually does.

  • scaronscaron Posts: 163
    edited March 29

    @jfriedman to work around it I just commented out all the methods/op/funcs in vector.defns.kludge.py... but I just tried a second ago to comment only the methods/ops and not the funcs and it seems to compile without issue. The extension loaded too without the syntax error.

  • jfriedmanjfriedman Posts: 79 ✭✭
    edited March 29

    @scaron I did the same. I actually have a working wrapper now, though I had to edit KL and C++ to get there.

  • scaronscaron Posts: 163

    I have avoided editing the KL and C++ so far, I edited only to test my theory about what was wrong but nothing permanent. If you comment out the methods/ops in the vector.defns.kludge.py do you still need to hand edit the generated KL and C++?

  • jfriedmanjfriedman Posts: 79 ✭✭

    @scaron I did remove the methods in question and that eliminated the need to edit the KL for this particular problem, but I still have others.

Sign In or Register to comment.