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

Allow for object oriented c bindings #73

Merged
merged 1 commit into from Aug 21, 2019

Conversation

jhlange
Copy link

@jhlange jhlange commented Aug 21, 2019

This change allows users to create an object oriented binding, by giving a pointer type hint of 'inst' (e.g. the 'instance object' which the given method is using).

As an example, if you were to take the vorbis binding and set the pointer hints to inst instead of ref:

      - {target: ^vorbis_, tips: [inst,ref,ref]}
      - {target: ^ogg_, self: arr, tips: [inst,ref]}

and add this to the rules section:

    function:
      - {action: replace, from: "^_comment_", to: _}
      - {action: replace, from: "^Ogg_stream" }
      - {action: replace, from: "^Ogg_sync" }

The bindings will be object oriented. As an example,

func CommentAddTag(vc *Comment, tag string, contents string) {...}

Becomes:

func (vc *Comment) AddTag(tag string, contents string) {...}

@xlab
Copy link
Owner

xlab commented Aug 21, 2019

Wow! Thank you for this addition, definitely a good helper.

P.s. although I avoided that feature for long time, because it's very tricky in general case.. But for simple bindings it's great.

@xlab xlab merged commit 8eeee8c into xlab:master Aug 21, 2019
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.

None yet

2 participants