Conversation
89228a7 to
7e4766f
Compare
|
@kddnewton I need to see if jffi and project Panama are capable of passing a pointer to a function which returns what you want. Others will want this I am sure but I am not sure if I can use it at this point or not. |
|
@enebo any chance you can pass |
|
I could also provide a version of this that assumes stdin and fgets? |
|
@kddnewton It looks like I can make a function in JNR. Sometimes this is hit or miss but I will try and figure this out next week. So long as I can make the right signature this should work out ok. stdin+fgets might be possible too but I need to still bind it using JNR (JNR is in Java and not C) |
|
Err I misread your second suggestion but let's assume I can make a proper pointer to function and see where that goes. |
That would be great and would be quite a bit easier to call. In fact is there a use-case for using this for something different than stdin? |
61feb6b to
b61ab29
Compare
b61ab29 to
efdc2b7
Compare
Closes #1247 (our second-oldest open issue!)
Prism can now parse streams. In the C API you can use it like this:
Relevant signatures are:
We never touch the stream itself, so it's treated as an opaque pointer. It is the responsibility of the given function pointer to load one line at a time into its first parameter. From the Ruby API you can call it like:
where
streamis any object that responds togets(length).This is suitable for implementing streaming from stdin into the prism parser, while appropriately stopping the stream at the point that it hits an
__END__marker, as in:cc @enebo @eregon @seven1m