Exemple #1
0
    void Engine::Impl::quit(const std::string& message)
    {
        if(message.length())
        {
            fprintf(stderr, "Exit Requested: %s\n", message.c_str());
#ifdef _WIN32
            MessageBoxA(nullptr, message.c_str(), "Exit Requested", MB_SYSTEMMODAL);
#endif
            throw SystemExit(1);
        }
        throw SystemExit(0);
    }
Exemple #2
0
int SystemMainLoop() {
  SDL_Event event;
  
  return_code = -1;
  while(return_code == -1) {
    while(SDL_PollEvent(&event) && current) {
      switch(event.type) {
      case SDL_KEYDOWN:
      case SDL_KEYUP:
      case SDL_JOYAXISMOTION:
      case SDL_JOYBUTTONDOWN:
      case SDL_JOYBUTTONUP:
      case SDL_MOUSEBUTTONUP:
      case SDL_MOUSEBUTTONDOWN:
      //case SDL_MOUSEMOTION:
        SystemHandleInput(&event);
        break;
      case SDL_QUIT:
        SystemExit();
        break;
      default:
        /* ignore event */
        break;
      }
    }
    if(redisplay) {
      current->display();
      redisplay = 0;
    } else
      current->idle();
  }
  if(current->exit)
    (current->exit)();
  return return_code;
}
Exemple #3
0
void prependToSysPath(llvm::StringRef path) {
    BoxedList* sys_path = getSysPath();
    static BoxedString* insert_str = getStaticString("insert");
    CallattrFlags callattr_flags{.cls_only = false, .null_on_nonexistent = false, .argspec = ArgPassSpec(2) };
    autoDecref(callattr(sys_path, insert_str, callattr_flags, autoDecref(boxInt(0)), autoDecref(boxString(path)), NULL,
                        NULL, NULL));
}

static BoxedClass* sys_flags_cls;
class BoxedSysFlags : public Box {
public:
    Box* division_warning, *bytes_warning, *no_user_site, *optimize;

    BoxedSysFlags() {
        auto zero = boxInt(0);
        assert(zero);
        division_warning = incref(zero);
        bytes_warning = incref(zero);
        no_user_site = incref(zero);
        optimize = incref(zero);
        Py_DECREF(zero);
    }

    DEFAULT_CLASS(sys_flags_cls);

    static Box* __new__(Box* cls, Box* args, Box* kwargs) {
        raiseExcHelper(TypeError, "cannot create 'sys.flags' instances");
    }

    static void dealloc(BoxedSysFlags* self) {
        Py_DECREF(self->division_warning);
        Py_DECREF(self->bytes_warning);
        Py_DECREF(self->no_user_site);
        Py_DECREF(self->optimize);
    }
};

static std::string generateVersionString() {
    std::ostringstream oss;
    oss << PY_MAJOR_VERSION << '.' << PY_MINOR_VERSION << '.' << PY_MICRO_VERSION;
    oss << '\n';
    oss << "[Pyston " << PYSTON_VERSION_MAJOR << '.' << PYSTON_VERSION_MINOR << '.' << PYSTON_VERSION_MICRO << "]";
    return oss.str();
}
Exemple #4
0
void *
test_thread (void *v_param)
{
    uval thread_num = (uval)v_param;
    VPNum curVP;
    int done = 0;
    TIMER_DECL(1);

    SystemSavedState saveArea;
    SystemEnter(&saveArea);

    curVP = Scheduler::GetVP();

    // Wait for all the threads to start:
    sleep(10);

    // Have the threads wake up one at a time:
    sleep(thread_num);

    // Loop around doing a whole bunch of nothing, consuming CPU.
    // Hopefully the migration manager will load balance these
    // threads:
    while (!done) {
	// Check for test end:
	pthread_testcancel();

	START_TIMER;
	SystemExit(&saveArea);
	sched_yield();
	SystemEnter(&saveArea);
	END_TIMER;

	if (curVP != Scheduler::GetVP()) {
	    times[thread_num] = AVG_TIME;
	    done = 1;
	}
    }
    return NULL;
}
Exemple #5
0
PyDoc_STRVAR(exc_info_doc, "exc_info() -> (type, value, traceback)\n\
\n\
Return information about the most recent exception caught by an except\n\
clause in the current stack frame or in an older stack frame.");

PyDoc_STRVAR(exc_clear_doc, "exc_clear() -> None\n\
\n\
Clear global information on the current exception.  Subsequent calls to\n\
exc_info() will return (None,None,None) until another exception is raised\n\
in the current thread or the execution stack returns to a frame where\n\
another exception is being handled.");


PyDoc_STRVAR(exit_doc, "exit([status])\n\
\n\
Exit the interpreter by raising SystemExit(status).\n\
If the status is omitted or None, it defaults to zero (i.e., success).\n\
If the status is an integer, it will be used as the system exit status.\n\
If it is another kind of object, it will be printed and the system\n\
exit status will be one (i.e., failure).");

PyDoc_STRVAR(getdefaultencoding_doc, "getdefaultencoding() -> string\n\
\n\
Return the current default string encoding used by the Unicode \n\
implementation.");

PyDoc_STRVAR(getfilesystemencoding_doc, "getfilesystemencoding() -> string\n\
\n\
Return the encoding used to convert Unicode filenames in\n\
operating system filenames.");

PyDoc_STRVAR(getrecursionlimit_doc, "getrecursionlimit()\n\
void keyCredits(int k, int x, int y)
{
  SystemExit();
}
void mouseCredits (int buttons, int state, int x, int y)
{
    if ( state == SYSTEM_MOUSEPRESSED )
        SystemExit();
}