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

Clarification of use of offsets in type encoding in custom classes #4

Closed
jmbldwn opened this issue Jun 16, 2018 · 3 comments
Closed

Comments

@jmbldwn
Copy link

jmbldwn commented Jun 16, 2018

Again, great package! This might just be a clarification, but as I'm trying to figure out why my delegate doesn't work, I'm noticing a few things I don't entirely understand that might help me figure it out.

I've created a custom class so I can register a delegate. I've used the FileManagerDelegate example as a template for my own.

Your readme mentions:

Note: You might have to specify individual offsets in the type encoding, see this example.

I'd love to know what you mean by this, and what it means for how I define my delegate.

For reference, I'm creating a delegate for AVCaptureVideoDataOutputSampleBufferDelegate. One thing I noted is the use of the term 'c40' for the return value of the FileManagerDelegate example, which is a bool. I assume this means bool and char are the same, but not sure what the 40 is for.

This may not be my problem, but it might be nice to have this be clearer in the docs.

const AVCaptureVideoDataOutputSampleBufferDelegate = objc.createClass(
    'AVCaptureVideoDataOutputSampleBufferDelegate',
    'NSObject',
    {
        'captureOutput:didOutputSampleBuffer:fromConnection:': (
            self,
            cmd,
            captureOutput,
            sampleBuffer,
            connection
        ) => {
            console.log(
                '-[AVCaptureVideoDataOutputSampleBufferDelegate captureOutput:didOutputSampleBuffer:fromConnection:]'
            );
            return 1;
        },

        _encodings: {
            'captureOutput:didOutputSampleBuffer:fromConnection:': [
                'v',
                ['@0', ':8', '@16', '@24', '@32']
            ]
        }
    }
);
@jmbldwn
Copy link
Author

jmbldwn commented Jun 17, 2018

I think I figured out I should be using 'v' for void return value. I'd still like to understand the offset notation, though.

@lukaskollmer
Copy link
Owner

@jmbldwn
Copy link
Author

jmbldwn commented Jun 17, 2018

Thanks for that. It looks like the correct encoding for

- (void)captureOutput:(AVCaptureOutput *)output 
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer 
       fromConnection:(AVCaptureConnection *)connection;

is

        _encodings: {
            'captureOutput:didOutputSampleBuffer:fromConnection:': [
                'v40',
                ['@0', ':8', '@16', '@24', '@32']
            ]
        }

@jmbldwn jmbldwn closed this as completed Jun 18, 2018
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

No branches or pull requests

2 participants