Hi martin,

I agree, its probably a good thing to have. I would store the callback
as an svalue into the context, as you propose and call it using
apply_svalue. that way one can also pass an object with `() lfun.

arne

On Thu, 9 May 2013, Martin B?hr wrote:

hi,

the JSON module can only encode objects if they provide an encode_json
function. i find this a bit limiting because it is hardly possible to
add encode_json to all classes that would need it.

better would be to allow the caller of JSON.encode provide a callback
for objects that the module can't handle by itself.

it seems to me the simplest would be to add an argument to JSON.encode
to allow passing a function. and then call that function of the object
has none of its own.

i am unfamiliar with CMODs
but i think in src/post_modules/JSON/json.cmod
i need to add the function to the encode_context and then
call it in the PIKE_T_OBJECT case.

also what i am wondering is, should i store the whole svalue for the function
or just the functionpointer itself? (is that u.efun->function?)

greetings, martin.
  • cal... Martin Bähr
    • ... Arne Goedeke
      • ... Martin Bähr
        • ... Arne Goedeke
          • ... Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum
            • ... Martin Bähr
              • ... Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum
                • ... Arne Goedeke
                • ... Martin Bähr
                • ... Martin Bähr
                • ... Arne Goedeke
                • ... Martin Bähr

Reply via email to