Source

pyobjc / pyobjc-core / Modules / objc / test / voidpointer.m

/*
 * This module is used in the unittests for object identity.
 */
#include "Python.h"
#include "pyobjc-api.h"

#import <Foundation/Foundation.h>

@interface OC_TestVoidPointer : NSObject
{
	void* value;
}

-(void*)getvalue;
-(void)setvalue:(void*)v;
@end

@implementation OC_TestVoidPointer
-(instancetype)init 
{
	self = [super init];
	if (self) {
		value = NULL;
	}
	return self;
}
-(void*)getvalue
{
	return value;
}
-(void)setvalue:(void*)v
{
	value = v;
}
@end

static PyMethodDef mod_methods[] = {
	{ 0, 0, 0, 0 }
};

#if PY_VERSION_HEX >= 0x03000000

static struct PyModuleDef mod_module = {
	PyModuleDef_HEAD_INIT,
	"voidpointer",
	NULL,
	0,
	mod_methods,
	NULL,
	NULL,
	NULL,
	NULL
};

#define INITERROR() return NULL
#define INITDONE() return m

PyObject* PyInit_voidpointer(void);

PyObject*
PyInit_voidpointer(void)

#else

#define INITERROR() return
#define INITDONE() return

void initvoidpointer(void);

void
initvoidpointer(void)
#endif
{
	PyObject* m;


#if PY_VERSION_HEX >= 0x03000000
	m = PyModule_Create(&mod_module);
#else
	m = Py_InitModule4("voidpointer", mod_methods,
		NULL, NULL, PYTHON_API_VERSION);
#endif
	if (!m) {
		INITERROR();
	}
	if (PyObjC_ImportAPI(m) < 0) {
		INITERROR();
	}

	if (PyModule_AddObject(m, "OC_TestVoidPointer", 
			PyObjCClass_New([OC_TestVoidPointer class])) < 0){
		INITERROR();
	}

	INITDONE();
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.