Source

pygamekit / standalone.cpp

#include "Python.h"

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initgamekit();
PyMODINIT_FUNC initmathutils();
#else
PyMODINIT_FUNC PyInit_gamekit(void);
PyMODINIT_FUNC PyInit_mathutils(void);
#endif

int main(int argc, char *argv[]){
  
  Py_SetProgramName(argv[0]);

  Py_Initialize();
  #if PY_MAJOR_VERSION < 3
    initmathutils();
    initgamekit();
  #else
    PyInit_mathutils(void);
    PyInit_gamekit(void);
  #endif
  PySys_SetArgvEx(argc, argv, 0);

  PyRun_SimpleString(
    "import gamekit, sys\n"
    "print sys.argv\n"
    "bname = sys.argv[0]\n"
    "ext = bname.split('.')[-1].lower()\n"
    "if ext in ('exe', 'bin', 'bin32', 'bin64'):\n"
    "    bname = bname[:-len(ext)-1]\n"
    "bname += '.blend'\n"
    "p = ''\n"
    "cfgfile = None\n"
    "for a in sys.argv[1:]:\n"
    "    if p:\n"
    "        if p=='-c':\n"
    "            cfgfile = a\n"
    "        elif p=='--pythonpath':\n"
    "            sys.path.append(a)\n"
    "        elif p=='--':\n"
    "            bname = a\n"
    "        else:\n"
    "            print('Unrecognized option %s'%p)\n"
    "        p = ''\n"
    "    else:\n"
    "        if a.startswith('-'):\n"
    "            p = a\n"
    "        else:\n"
    "            bname = a\n"
    "e = gamekit.Engine(bname,cfgfile)\n"
    "try:\n"
    "    import init\n"
    "except ImportError:\n"
    "    print('Error: Can\\'t import init.py')\n"
    "e.run()\n"
  );

  Py_Finalize();
  return 0;
}
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.