Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usability: introduce callback function types #193

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ototo
Copy link

@ototo ototo commented Sep 28, 2016

To let users of yajl writing code that is cleaner, a set of callback
function types is introduced by this patch.

Old (before this patch) way of using callbacks:

// Callback definition
static int my_parse_null(void *raw_ctx)
{
    ProjectSpecificType *ctx = (ProjectSpecificType *) raw_ctx;

    // the code that is using ctx follows...
}

// ...

// Setting the callback
yajl_callbacks cb;
cb.yajl_null = my_parse_null;

New (with this patch applied) way of using callbacks

// Callback definition
static int my_parse_null(ProjectSpecificType *ctx)
{
    // the code that is using ctx follows...
}

// ...

// Setting the callback
yajl_callbacks cb;
cb.yajl_null = (yajl_null_t) my_parse_null;

Both (the old and the new) ways of using callbacks are supported with no
changes to the existing code needed.

Signed-off-by: Serge Broslavsky [email protected]

To let users of yajl writing code that is cleaner, a set of callback
function types is introduced by this patch.

Old (before this patch) way of using callbacks:

    // Callback definition
    static int my_parse_null(void *raw_ctx)
    {
        ProjectSpecificType *ctx = (ProjectSpecificType *) raw_ctx;

        // the code that is using ctx follows...
    }

    // ...

    // Setting the callback
    yajl_callbacks cb;
    cb.yajl_null = my_parse_null;

New (with this patch applied) way of using callbacks

    // Callback definition
    static int my_parse_null(ProjectSpecificType *ctx)
    {
        // the code that is using ctx follows...
    }

    // ...

    // Setting the callback
    yajl_callbacks cb;
    cb.yajl_null = (yajl_null_t) my_parse_null;

Both (the old and the new) ways of using callbacks are supported with no
changes to the existing code needed.

Signed-off-by: Serge Broslavsky <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant