On 08/30/2013 12:55 PM, Marvin Humphrey wrote: > On Thu, Aug 29, 2013 at 11:16 PM, Philip Southam <[email protected]> wrote: >> Thanks Peter. I've gotten as far as getting a value out of >> LUCY_Compiler_Highlight_Spans. Now the part I'm struggling with is >> unmarshalling the data out of the returned spans cfish_VArray* object. >> In lines 141-148 of this gist[1] I've done my best to port the perl >> example referenced in the markmail link. It compiles and runs, but >> instead of printing (line 148) what I would expect to be a matching >> term, I get something like: >> >> Lucy::Search::Span@0x00000000026fec90 >> >> indicating I'm not interacting with the spans object returned on line >> 143 properly. Anyone have any suggestions? >> >> >> [1]: https://gist.github.com/philipsoutham/6386741 > > That's the default To_String() method, which is inherited by > Lucy::Search::Span from Clownfish::Object. (For the implementation, see > `Obj_To_String_IMP` clownfish/runtime/core/Clownfish/Obj.c.) Since Span > doesn't have its own stringification routine, you'll need to extract the data > you want using its accesssors, whose fully qualified names are > `LUCY_Span_Get_Offset`, `LUCY_Span_Get_Length` and `LUCY_Span_Get_Weight`. > > Those methods are declared in core/Lucy/Search/Span.cfh (here's one)... > > /** Accessor for <code>offset</code> attribute. > */ > public int32_t > Get_Offset(Span *self); > > ... and implemented in core/Lucy/Search/Span.c: > > int32_t > Span_Get_Offset_IMP(Span *self) { > return Span_IVARS(self)->offset; > } > > HTH, > > Marvin Humphrey >
Thanks, with these clues I was able to get what I wanted (albeit with a little more ceremony than I would like). If you're curious, you can see it in action here[1]. [1]: https://github.com/philipsoutham/golucy/blob/8e12c7343bcb161b82ad85978e565d17bc67a32c/v0.0.1/searcher.go#L132 -- Philip Southam Chief Architect / Яeverse Эngineer http://zefr.com
