michaelrsweet / mxml

Tiny XML library.
https://www.msweet.org/mxml
Apache License 2.0
428 stars 157 forks source link

Add context to all callbacks #106

Closed michaelrsweet closed 2 months ago

michaelrsweet commented 14 years ago

Version: 3.x-feature Original reporter:

Continue bug#66.

Another example is the mxmlSetErrorCallback() which has no context assigned. It would be much easier to use if there is ability to set some void* context.

Also, I am not sure I understand why the error callback is thread specific.

This kind of library usually needs no global context. First argument of every function may provide the necessary context.

For the error callback, except of context it would be nice to get a details of the object that caused the error, or have a separate callback for errors during parsing. For example, if I parse 3 XML I want to present a different messages for each [without using globals].

Thanks

michaelrsweet commented 14 years ago

Original reporter:

Also, return last callback from set, so can restore after use.

michaelrsweet commented 13 years ago

Original reporter: Michael Sweet

Will consider this for Mini-XML 3.0.

michaelrsweet commented 5 years ago

Not for 3.0...

AaronLasseigne commented 4 years ago

I'm in the process of writing an mruby gem that uses this library. I would love to see this happen. I'm looking to catch errors and bubble them up through mruby but I need to be able to provide context to do that. So, 👍 from me!

michaelrsweet commented 2 months ago

This is now part of Git master for 4.0.