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: 152

    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: 152

    @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.

Sign In or Register to comment.