mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-23 07:01:39 +00:00
Converted ME and PE cocoa projects to objp.
--HG-- branch : objp rename : cocoa/se/main.m => cocoa/base/main.m
This commit is contained in:
38
cocoa/base/main.m
Normal file
38
cocoa/base/main.m
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright 2011 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "BSD" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.hardcoded.net/licenses/bsd_license
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <Python.h>
|
||||
#import <wchar.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSString *respath = [[NSBundle mainBundle] resourcePath];
|
||||
NSString *mainpy = [respath stringByAppendingPathComponent:@"dg_cocoa.py"];
|
||||
wchar_t wPythonPath[PATH_MAX+1];
|
||||
NSString *pypath = [respath stringByAppendingPathComponent:@"py"];
|
||||
mbstowcs(wPythonPath, [pypath fileSystemRepresentation], PATH_MAX+1);
|
||||
Py_SetPath(wPythonPath);
|
||||
Py_SetPythonHome(wPythonPath);
|
||||
Py_Initialize();
|
||||
PyEval_InitThreads();
|
||||
PyGILState_STATE gilState = PyGILState_Ensure();
|
||||
FILE* fp = fopen([mainpy UTF8String], "r");
|
||||
PyRun_SimpleFile(fp, [mainpy UTF8String]);
|
||||
fclose(fp);
|
||||
PyGILState_Release(gilState);
|
||||
if (gilState == PyGILState_LOCKED) {
|
||||
PyThreadState_Swap(NULL);
|
||||
PyEval_ReleaseLock();
|
||||
}
|
||||
int result = NSApplicationMain(argc, (const char **) argv);
|
||||
Py_Finalize();
|
||||
[pool release];
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user