// WARNING: Call with input locked!
void SC_TerminalClient::interpretInput()
{
	char *data = mInputBuf.getData();
	int c = mInputBuf.getSize();
	int i = 0;
	while( i < c ) {
		switch (data[i]) {
		case kInterpretCmdLine:
			interpretCmdLine(s_interpretCmdLine, data, i);
			break;
		case kInterpretPrintCmdLine:
			interpretCmdLine(s_interpretPrintCmdLine, data, i);
			break;

		case kRecompileLibrary:
			recompileLibrary();
			break;

		default:
			++i;
			continue;
		}

		data += i+1;
		c -= i+1;
		i = 0;
	}
	mInputBuf.reset();
	if( mUseReadline ) pthread_cond_signal( &mInputCond );
}
// Note: called only if the input thread does not perform an asynchronous read operation
void SC_TerminalClient::interpretInput()
{
	char *data = mInputBuf.getData();
	int c = mInputBuf.getSize();
	int i = 0;
	while( i < c ) {
		switch (data[i]) {
		case kInterpretCmdLine:
			interpretCmdLine(data, i, true);
			break;
		case kInterpretPrintCmdLine:
			interpretCmdLine(data, i, false);
			break;

		case kRecompileLibrary:
			recompileLibrary();
			break;

		default:
			++i;
			continue;
		}

		data += i+1;
		c -= i+1;
		i = 0;
	}
	mInputBuf.reset();

	if (mUseReadline)
		mReadlineSem.post();
	else
		startInputRead();
}
bool QcApplication::event( QEvent *e )
{
  if( e->type() == QEvent::FileOpen ) {

    // open the file dragged onto the application icon on Mac

    QFileOpenEvent *fe = static_cast<QFileOpenEvent*>(e);

    QtCollider::lockLang();
    gMainVMGlobals->canCallOS = true;

    QString cmdLine = QString("Document.open(\"%1\")").arg(fe->file());
    char *method = strdup( "interpretPrintCmdLine" );
    interpretCmdLine( cmdLine.toStdString().c_str(), cmdLine.size(), method );
    free(method);

    gMainVMGlobals->canCallOS = false;
    QtCollider::unlockLang();

    return true;
  }

  return QApplication::event( e );
}