Beispiel #1
0
char *Scfull (Tobj co, int ci, int mci) {
    sbufp[(sbufi = 0)] = '\000';
    highci = mci;
    codestr (co, ci);
    highci = -1;
    return copysbuf ();
}
Beispiel #2
0
bool ansi_c_languaget::parse(
  const std::string &path,
  message_handlert &message_handler)
{
  // store the path

  parse_path=path;

  // preprocessing

  std::ostringstream o_preprocessed;

  if(preprocess(path, o_preprocessed, message_handler))
    return true;

  std::istringstream i_preprocessed(o_preprocessed.str());

  // parsing

  std::string code;
  internal_additions(code);
  std::istringstream codestr(code);

  ansi_c_parser.clear();
  ansi_c_parser.filename="<built-in>";
  ansi_c_parser.in=&codestr;
  ansi_c_parser.set_message_handler(&message_handler);
  ansi_c_parser.grammar=ansi_c_parsert::LANGUAGE;

  if(config.ansi_c.os==configt::ansi_ct::OS_WIN32)
    ansi_c_parser.mode=ansi_c_parsert::MSC;
  else
    ansi_c_parser.mode=ansi_c_parsert::GCC;

  ansi_c_scanner_init();

  bool result=ansi_c_parser.parse();

  if(!result)
  {
    ansi_c_parser.line_no=0;
    ansi_c_parser.filename=path;
    ansi_c_parser.in=&i_preprocessed;
    ansi_c_scanner_init();
    result=ansi_c_parser.parse();
  }

  // save result
  parse_tree.swap(ansi_c_parser.parse_tree);

  // save some memory
  ansi_c_parser.clear();

  return result;
}
Beispiel #3
0
bool ansi_c_languaget::parse(
  std::istream &instream,
  const std::string &path)
{
  // store the path
  parse_path=path;

  // preprocessing
  std::ostringstream o_preprocessed;

  if(preprocess(instream, path, o_preprocessed))
    return true;

  std::istringstream i_preprocessed(o_preprocessed.str());

  // parsing

  std::string code;
  ansi_c_internal_additions(code);
  std::istringstream codestr(code);

  ansi_c_parser.clear();
  ansi_c_parser.set_file(ID_built_in);
  ansi_c_parser.in=&codestr;
  ansi_c_parser.set_message_handler(get_message_handler());
  ansi_c_parser.for_has_scope=config.ansi_c.for_has_scope;
  ansi_c_parser.cpp98=false; // it's not C++
  ansi_c_parser.cpp11=false; // it's not C++
  ansi_c_parser.mode=config.ansi_c.mode;

  ansi_c_scanner_init();

  bool result=ansi_c_parser.parse();

  if(!result)
  {
    ansi_c_parser.set_line_no(0);
    ansi_c_parser.set_file(path);
    ansi_c_parser.in=&i_preprocessed;
    ansi_c_scanner_init();
    result=ansi_c_parser.parse();
  }

  // save result
  parse_tree.swap(ansi_c_parser.parse_tree);

  // save some memory
  ansi_c_parser.clear();

  return result;
}
Beispiel #4
0
static void scalarstr (Tobj to) {
    switch (Tgettype (to)) {
    case T_INTEGER:
        appendi (Tgetinteger (to));
        break;
    case T_REAL:
        appendd (Tgetreal (to));
        break;
    case T_STRING:
        appends ("\""), appends (Tgetstring (to)), appends ("\"");
        break;
    case T_CODE:
        codestr (to, 0);
        break;
    }
}
size_t
CoreAudioReadStream::getFrames(size_t count, float *frames)
{
    if (!m_channelCount) return 0;
    if (count == 0) return 0;

    m_d->buffer.mBuffers[0].mDataByteSize =
        sizeof(float) * m_channelCount * count;
    
    m_d->buffer.mBuffers[0].mData = frames;

    UInt32 framesRead = count;

    m_d->err = ExtAudioFileRead(m_d->file, &framesRead, &m_d->buffer);
    if (m_d->err) {
        m_error = "CoreAudioReadStream: Error in decoder: code " + codestr(m_d->err);
        throw InvalidFileFormat(m_path, "error in decoder");
    }

 //   cerr << "CoreAudioReadStream::getFrames: " << count << " frames requested across " << m_channelCount << " channel(s), " << framesRead << " frames actually read" << std::endl;

    return framesRead;
}
Beispiel #6
0
static void codestr (Tobj co, int ci) {
    int ct, ct1;
    int ci1, ci2;

    if (highci == ci)
        appends (" >> ");
    switch ((ct = TCgettype (co, ci))) {
    case C_ASSIGN:
        codestr (co, (ci1 = TCgetfp (co, ci)));
        appends (" = ");
        codestr (co, TCgetnext (co, ci1));
        break;
    case C_OR:
    case C_AND:
    case C_EQ:
    case C_NE:
    case C_LT:
    case C_LE:
    case C_GT:
    case C_GE:
    case C_PLUS:
    case C_MINUS:
    case C_MUL:
    case C_DIV:
    case C_MOD:
        codestr (co, (ci1 = TCgetfp (co, ci)));
        switch (ct) {
        case C_OR:    appends (" | ");  break;
        case C_AND:   appends (" & ");  break;
        case C_EQ:    appends (" == "); break;
        case C_NE:    appends (" ~= "); break;
        case C_LT:    appends (" < ");  break;
        case C_LE:    appends (" <= "); break;
        case C_GT:    appends (" > ");  break;
        case C_GE:    appends (" >= "); break;
        case C_PLUS:  appends (" + ");  break;
        case C_MINUS: appends (" - ");  break;
        case C_MUL:   appends (" * ");  break;
        case C_DIV:   appends (" / ");  break;
        case C_MOD:   appends (" % ");  break;
        }
        codestr (co, TCgetnext (co, ci1));
        break;
    case C_NOT:
        appends ("~");
        codestr (co, TCgetfp (co, ci));
        break;
    case C_UMINUS:
        appends ("-");
        codestr (co, TCgetfp (co, ci));
        break;
    case C_PEXPR:
        appends ("(");
        codestr (co, TCgetfp (co, ci));
        appends (")");
        break;
    case C_FCALL:
        codestr (co, (ci1 = TCgetfp (co, ci)));
        appends (" (");
        codestr (co, TCgetnext (co, ci1));
        appends (")");
        break;
    case C_INTEGER:
        appendi (TCgetinteger (co, ci));
        break;
    case C_REAL:
        appendd (TCgetreal (co, ci));
        break;
    case C_STRING:
        appends ("\""), appends (TCgetstring (co, ci)), appends ("\"");
        break;
    case C_GVAR:
    case C_LVAR:
        ci1 = TCgetfp (co, ci);
        appends (TCgetstring (co, ci1));
        if (ct == C_LVAR)
            ci1 = TCgetnext (co, ci1);
        for (
            ci1 = TCgetnext (co, ci1); ci1 != C_NULL;
            ci1 = TCgetnext (co, ci1)
        ) {
            switch (TCgettype (co, ci1)) {
            case C_STRING:
                appends ("."), appends (TCgetstring (co, ci1));
                break;
            case C_INTEGER:
                appends ("[");
                appendi (TCgetinteger (co, ci1));
                appends ("]");
                break;
            case C_REAL:
                appends ("[");
                appendd (TCgetreal (co, ci1));
                appends ("]");
                break;
            default:
                appends ("[");
                codestr (co, ci1);
                appends ("]");
            }
        }
        break;
    case C_PVAR:
        appends ("<var>");
        break;
    case C_FUNCTION:
        ci1 = TCgetnext (co, TCgetnext (co, TCgetfp (co, ci)));
        appends ("function (");
        codestr (co, ci1);
        ci1 = TCgetnext (co, ci1);
        if (TCgettype (co, ci1) == C_INTERNAL) {
            appends (") internal \"");
            appends (Ifuncs[TCgetinteger (co, TCgetfp (co, ci1))].name);
            appends ("\"");
        } else {
            appends (") {");
            INDINC (2);
            for (; ci1 != C_NULL; ci1 = TCgetnext (co, ci1)) {
                appendnl ();
                if (TCgettype (co, ci1) == C_DECL)
                    appends ("local "), codestr (co, ci1), appends (";");
                else
                    codestr (co, ci1);
            }
            INDDEC (2);
            appendnl ();
            appends ("}");
        }
        break;
    case C_TCONS:
        appends ("[");
        INDINC (2);
        ci1 = TCgetfp (co, ci);
        while (ci1 != C_NULL) {
            appendnl ();
            codestr (co, ci1);
            appends (" = ");
            ci1 = TCgetnext (co, ci1);
            codestr (co, ci1);
            appends (";");
            ci1 = TCgetnext (co, ci1);
        }
        INDDEC (2);
        appendnl ();
        appends ("]");
        break;
    case C_DECL:
        ci1 = TCgetfp (co, ci);
        while (ci1 != C_NULL) {
            appends (TCgetstring (co, ci1));
            ci1 = TCgetnext (co, ci1);
            if (ci1 != C_NULL)
                appends (", ");
        }
        break;
    case C_STMT:
        ci1 = TCgetfp (co, ci);
        if (ci1 == C_NULL) {
            appends (";");
            break;
        }
        if (TCgetnext (co, ci1) == C_NULL) {
            codestr (co, ci1);
            ct1 = TCgettype (co, ci1);
            if (!C_ISSTMT (ct1))
                appends (";");
        } else {
            appends (" {");
            INDINC (2);
            for (; ci1 != C_NULL; ci1 = TCgetnext (co, ci1)) {
                appendnl ();
                codestr (co, ci1);
            }
            INDDEC (2);
            appendnl ();
            appends ("}");
        }
        break;
    case C_IF:
        ci1 = TCgetfp (co, ci);
        appends ("if (");
        codestr (co, ci1);
        appends (")");
        ci1 = TCgetnext (co, ci1);
        ci2 = TCgetfp (co, ci1);
        if (ci2 == C_NULL || TCgetnext (co, ci2) == C_NULL) {
            INDINC (2);
            appendnl ();
            codestr (co, ci1);
            INDDEC (2);
        } else {
            codestr (co, ci1);
        }
        ci1 = TCgetnext (co, ci1);
        if (ci1 == C_NULL)
            break;
        if (ci2 == C_NULL || TCgetnext (co, ci2) == C_NULL) {
            appendnl ();
            appends ("else");
        } else {
            appends (" else");
        }
        ci2 = TCgetfp (co, ci1);
        if (ci2 == C_NULL || TCgetnext (co, ci2) == C_NULL) {
            INDINC (2);
            appendnl ();
            codestr (co, ci1);
            INDDEC (2);
        } else {
            codestr (co, ci1);
        }
        break;
    case C_WHILE:
        ci1 = TCgetfp (co, ci);
        appends ("while (");
        codestr (co, ci1);
        ci1 = TCgetnext (co, ci1);
        ci2 = TCgetfp (co, ci1);
        if (ci2 == C_NULL || TCgetnext (co, ci2) == C_NULL) {
            appends (")");
            INDINC (2);
            appendnl ();
            codestr (co, ci1);
            INDDEC (2);
        } else {
            appends (")");
            codestr (co, ci1);
        }
        break;
    case C_FOR:
        ci1 = TCgetfp (co, ci);
        appends ("for (");
        codestr (co, ci1);
        appends ("; ");
        ci1 = TCgetnext (co, ci1);
        codestr (co, ci1);
        appends ("; ");
        ci1 = TCgetnext (co, ci1);
        codestr (co, ci1);
        ci1 = TCgetnext (co, ci1);
        ci2 = TCgetfp (co, ci1);
        if (ci2 == C_NULL || TCgetnext (co, ci2) == C_NULL) {
            appends (")");
            INDINC (2);
            appendnl ();
            codestr (co, ci1);
            INDDEC (2);
        } else {
            appends (")");
            codestr (co, ci1);
        }
        break;
    case C_FORIN:
        ci1 = TCgetfp (co, ci);
        appends ("for (");
        codestr (co, ci1);
        appends (" in ");
        ci1 = TCgetnext (co, ci1);
        codestr (co, ci1);
        ci1 = TCgetnext (co, ci1);
        ci2 = TCgetfp (co, ci1);
        if (ci2 == C_NULL || TCgetnext (co, ci2) == C_NULL) {
            appends (")");
            INDINC (2);
            appendnl ();
            codestr (co, ci1);
            INDDEC (2);
        } else {
            appends (")");
            codestr (co, ci1);
        }
        break;
    case C_BREAK:
        appends ("break;");
        break;
    case C_CONTINUE:
        appends ("continue;");
        break;
    case C_RETURN:
        ci1 = TCgetfp (co, ci);
        appends ("return");
        if (ci1 != C_NULL) {
            appends (" ");
            codestr (co, ci1);
        }
        appends (";");
        break;
    case C_ARGS:
        ci1 = TCgetfp (co, ci);
        while (ci1 != C_NULL) {
            codestr (co, ci1);
            ci1 = TCgetnext (co, ci1);
            if (ci1 != C_NULL)
                appends (", ");
        }
        break;
    default:
        panic1 (POS, "codestr", "bad object type: %d", ct);
    }
}
Beispiel #7
0
int processArgs(int argc, char **argv)
{
    if (argc > 2) {
        QString arg1(argv[1]);
        if (arg1 == QLatin1String("-i") ||
                arg1 == QLatin1String("-install")) {
            if (argc > 2) {
                QString account;
                QString password;
                QString path(argv[2]);
                if (argc > 3) {
                    account = argv[3];
                }
                if (argc > 4) {
                    password = argv[4];
                }
                printf("The service %s installed.\n",
                       (QtServiceController::install(path, account, password) ? "was" : "was not"));
                return 0;
            }
        } else {
            QString serviceName(argv[1]);
            QtServiceController controller(serviceName);
            QString option(argv[2]);
            if (option == QLatin1String("-u") ||
                    option == QLatin1String("-uninstall")) {
                printf("The service \"%s\" %s uninstalled.\n",
                       controller.serviceName().toLatin1().constData(),
                       (controller.uninstall() ? "was" : "was not"));
                return 0;
            } else if (option == QLatin1String("-s") ||
                       option == QLatin1String("-start")) {
                QStringList args;
                for (int i = 3; i < argc; ++i) {
                    args.append(QString::fromLocal8Bit(argv[i]));
                }
                printf("The service \"%s\" %s started.\n",
                       controller.serviceName().toLatin1().constData(),
                       (controller.start(args) ? "was" : "was not"));
                return 0;
            } else if (option == QLatin1String("-t") ||
                       option == QLatin1String("-terminate")) {
                printf("The service \"%s\" %s stopped.\n",
                       controller.serviceName().toLatin1().constData(),
                       (controller.stop() ? "was" : "was not"));
                return 0;
            } else if (option == QLatin1String("-p") ||
                       option == QLatin1String("-pause")) {
                printf("The service \"%s\" %s paused.\n",
                       controller.serviceName().toLatin1().constData(),
                       (controller.pause() ? "was" : "was not"));
                return 0;
            } else if (option == QLatin1String("-r") ||
                       option == QLatin1String("-resume")) {
                printf("The service \"%s\" %s resumed.\n",
                       controller.serviceName().toLatin1().constData(),
                       (controller.resume() ? "was" : "was not"));
                return 0;
            } else if (option == QLatin1String("-c") ||
                       option == QLatin1String("-command")) {
                if (argc > 3) {
                    QString codestr(argv[3]);
                    int code = codestr.toInt();
                    printf("The command %s sent to the service \"%s\".\n",
                           (controller.sendCommand(code) ? "was" : "was not"),
                           controller.serviceName().toLatin1().constData());
                    return 0;
                }
            } else if (option == QLatin1String("-v") ||
                       option == QLatin1String("-version")) {
                bool installed = controller.isInstalled();
                printf("The service\n"
                       "\t\"%s\"\n\n", controller.serviceName().toLatin1().constData());
                printf("is %s", (installed ? "installed" : "not installed"));
                printf(" and %s\n\n", (controller.isRunning() ? "running" : "not running"));
                if (installed) {
                    printf("path: %s\n", controller.serviceFilePath().toLatin1().data());
                    printf("description: %s\n", controller.serviceDescription().toLatin1().data());
                    printf("startup: %s\n", controller.startupType() == QtServiceController::AutoStartup ? "Auto" : "Manual");
                }
                return 0;
            }
        }
    }
    printf("controller [-i PATH | SERVICE_NAME [-v | -u | -s | -t | -p | -r | -c CODE] | -h] [-w]\n\n"
           "\t-i(nstall) PATH\t: Install the service\n"
           "\t-v(ersion)\t: Print status of the service\n"
           "\t-u(ninstall)\t: Uninstall the service\n"
           "\t-s(tart)\t: Start the service\n"
           "\t-t(erminate)\t: Stop the service\n"
           "\t-p(ause)\t: Pause the service\n"
           "\t-r(esume)\t: Resume the service\n"
           "\t-c(ommand) CODE\t: Send a command to the service\n"
           "\t-h(elp)\t\t: Print this help info\n"
           "\t-w(ait)\t\t: Wait for keypress when done\n");
    return 0;
}
Beispiel #8
0
void event_device::debug_input_event() const
{
   std::string typestr(boost::lexical_cast<std::string>(m_iev.type));
   std::string codestr(boost::lexical_cast<std::string>(m_iev.code));
   const char *type = typestr.c_str(), *code = codestr.c_str();

   switch (m_iev.type)
   {
      case EV_SYN: type = "SYN"; break;
      case EV_KEY: type = "KEY"; break;
      case EV_REL: type = "REL"; break;
      case EV_ABS: type = "ABS"; break;
      case EV_MSC: type = "MSC"; break;
      case EV_SW:  type = "SW";  break;
      case EV_LED: type = "LED"; break;
      case EV_SND: type = "SND"; break;
      case EV_REP: type = "REP"; break;
      case EV_FF:  type = "FF";  break;
      case EV_PWR: type = "PWR"; break;
      case EV_FF_STATUS: type = "FF_STATUS"; break;
   }

   if (m_iev.type == EV_KEY)
   {
      switch (m_iev.code)
      {
         case KEY_RESERVED: code = "RESERVED"; break;
         case KEY_ESC: code = "ESC"; break;
         case KEY_1: code = "1"; break;
         case KEY_2: code = "2"; break;
         case KEY_3: code = "3"; break;
         case KEY_4: code = "4"; break;
         case KEY_5: code = "5"; break;
         case KEY_6: code = "6"; break;
         case KEY_7: code = "7"; break;
         case KEY_8: code = "8"; break;
         case KEY_9: code = "9"; break;
         case KEY_0: code = "0"; break;
         case KEY_MINUS: code = "MINUS"; break;
         case KEY_EQUAL: code = "EQUAL"; break;
         case KEY_BACKSPACE: code = "BACKSPACE"; break;
         case KEY_TAB: code = "TAB"; break;
         case KEY_Q: code = "Q"; break;
         case KEY_W: code = "W"; break;
         case KEY_E: code = "E"; break;
         case KEY_R: code = "R"; break;
         case KEY_T: code = "T"; break;
         case KEY_Y: code = "Y"; break;
         case KEY_U: code = "U"; break;
         case KEY_I: code = "I"; break;
         case KEY_O: code = "O"; break;
         case KEY_P: code = "P"; break;
         case KEY_LEFTBRACE: code = "LEFTBRACE"; break;
         case KEY_RIGHTBRACE: code = "RIGHTBRACE"; break;
         case KEY_ENTER: code = "ENTER"; break;
         case KEY_LEFTCTRL: code = "LEFTCTRL"; break;
         case KEY_A: code = "A"; break;
         case KEY_S: code = "S"; break;
         case KEY_D: code = "D"; break;
         case KEY_F: code = "F"; break;
         case KEY_G: code = "G"; break;
         case KEY_H: code = "H"; break;
         case KEY_J: code = "J"; break;
         case KEY_K: code = "K"; break;
         case KEY_L: code = "L"; break;
         case KEY_SEMICOLON: code = "SEMICOLON"; break;
         case KEY_APOSTROPHE: code = "APOSTROPHE"; break;
         case KEY_GRAVE: code = "GRAVE"; break;
         case KEY_LEFTSHIFT: code = "LEFTSHIFT"; break;
         case KEY_BACKSLASH: code = "BACKSLASH"; break;
         case KEY_Z: code = "Z"; break;
         case KEY_X: code = "X"; break;
         case KEY_C: code = "C"; break;
         case KEY_V: code = "V"; break;
         case KEY_B: code = "B"; break;
         case KEY_N: code = "N"; break;
         case KEY_M: code = "M"; break;
         case KEY_COMMA: code = "COMMA"; break;
         case KEY_DOT: code = "DOT"; break;
         case KEY_SLASH: code = "SLASH"; break;
         case KEY_RIGHTSHIFT: code = "RIGHTSHIFT"; break;
         case KEY_KPASTERISK: code = "KPASTERISK"; break;
         case KEY_LEFTALT: code = "LEFTALT"; break;
         case KEY_SPACE: code = "SPACE"; break;
         case KEY_CAPSLOCK: code = "CAPSLOCK"; break;
         case KEY_F1: code = "F1"; break;
         case KEY_F2: code = "F2"; break;
         case KEY_F3: code = "F3"; break;
         case KEY_F4: code = "F4"; break;
         case KEY_F5: code = "F5"; break;
         case KEY_F6: code = "F6"; break;
         case KEY_F7: code = "F7"; break;
         case KEY_F8: code = "F8"; break;
         case KEY_F9: code = "F9"; break;
         case KEY_F10: code = "F10"; break;
         case KEY_NUMLOCK: code = "NUMLOCK"; break;
         case KEY_SCROLLLOCK: code = "SCROLLLOCK"; break;
         case KEY_KP7: code = "KP7"; break;
         case KEY_KP8: code = "KP8"; break;
         case KEY_KP9: code = "KP9"; break;
         case KEY_KPMINUS: code = "KPMINUS"; break;
         case KEY_KP4: code = "KP4"; break;
         case KEY_KP5: code = "KP5"; break;
         case KEY_KP6: code = "KP6"; break;
         case KEY_KPPLUS: code = "KPPLUS"; break;
         case KEY_KP1: code = "KP1"; break;
         case KEY_KP2: code = "KP2"; break;
         case KEY_KP3: code = "KP3"; break;
         case KEY_KP0: code = "KP0"; break;
         case KEY_KPDOT: code = "KPDOT"; break;

         case KEY_ZENKAKUHANKAKU: code = "ZENKAKUHANKAKU"; break;
         case KEY_102ND: code = "102ND"; break;
         case KEY_F11: code = "F11"; break;
         case KEY_F12: code = "F12"; break;
         case KEY_RO: code = "RO"; break;
         case KEY_KATAKANA: code = "KATAKANA"; break;
         case KEY_HIRAGANA: code = "HIRAGANA"; break;
         case KEY_HENKAN: code = "HENKAN"; break;
         case KEY_KATAKANAHIRAGANA: code = "KATAKANAHIRAGANA"; break;
         case KEY_MUHENKAN: code = "MUHENKAN"; break;
         case KEY_KPJPCOMMA: code = "KPJPCOMMA"; break;
         case KEY_KPENTER: code = "KPENTER"; break;
         case KEY_RIGHTCTRL: code = "RIGHTCTRL"; break;
         case KEY_KPSLASH: code = "KPSLASH"; break;
         case KEY_SYSRQ: code = "SYSRQ"; break;
         case KEY_RIGHTALT: code = "RIGHTALT"; break;
         case KEY_LINEFEED: code = "LINEFEED"; break;
         case KEY_HOME: code = "HOME"; break;
         case KEY_UP: code = "UP"; break;
         case KEY_PAGEUP: code = "PAGEUP"; break;
         case KEY_LEFT: code = "LEFT"; break;
         case KEY_RIGHT: code = "RIGHT"; break;
         case KEY_END: code = "END"; break;
         case KEY_DOWN: code = "DOWN"; break;
         case KEY_PAGEDOWN: code = "PAGEDOWN"; break;
         case KEY_INSERT: code = "INSERT"; break;
         case KEY_DELETE: code = "DELETE"; break;
         case KEY_MACRO: code = "MACRO"; break;
         case KEY_MUTE: code = "MUTE"; break;
         case KEY_VOLUMEDOWN: code = "VOLUMEDOWN"; break;
         case KEY_VOLUMEUP: code = "VOLUMEUP"; break;
         case KEY_POWER: code = "POWER"; break;
         case KEY_KPEQUAL: code = "KPEQUAL"; break;
         case KEY_KPPLUSMINUS: code = "KPPLUSMINUS"; break;
         case KEY_PAUSE: code = "PAUSE"; break;
         case KEY_SCALE: code = "SCALE"; break;

         case KEY_KPCOMMA: code = "KPCOMMA"; break;
         case KEY_HANGEUL: code = "HANGEUL"; break;

         case KEY_HANJA: code = "HANJA"; break;
         case KEY_YEN: code = "YEN"; break;
         case KEY_LEFTMETA: code = "LEFTMETA"; break;
         case KEY_RIGHTMETA: code = "RIGHTMETA"; break;
         case KEY_COMPOSE: code = "COMPOSE"; break;

         case KEY_STOP: code = "STOP"; break;
         case KEY_AGAIN: code = "AGAIN"; break;
         case KEY_PROPS: code = "PROPS"; break;
         case KEY_UNDO: code = "UNDO"; break;
         case KEY_FRONT: code = "FRONT"; break;
         case KEY_COPY: code = "COPY"; break;
         case KEY_OPEN: code = "OPEN"; break;
         case KEY_PASTE: code = "PASTE"; break;
         case KEY_FIND: code = "FIND"; break;
         case KEY_CUT: code = "CUT"; break;
         case KEY_HELP: code = "HELP"; break;
         case KEY_MENU: code = "MENU"; break;
         case KEY_CALC: code = "CALC"; break;
         case KEY_SETUP: code = "SETUP"; break;
         case KEY_SLEEP: code = "SLEEP"; break;
         case KEY_WAKEUP: code = "WAKEUP"; break;
         case KEY_FILE: code = "FILE"; break;
         case KEY_SENDFILE: code = "SENDFILE"; break;
         case KEY_DELETEFILE: code = "DELETEFILE"; break;
         case KEY_XFER: code = "XFER"; break;
         case KEY_PROG1: code = "PROG1"; break;
         case KEY_PROG2: code = "PROG2"; break;
         case KEY_WWW: code = "WWW"; break;
         case KEY_MSDOS: code = "MSDOS"; break;
         case KEY_COFFEE: code = "COFFEE"; break;

         case KEY_DIRECTION: code = "DIRECTION"; break;
         case KEY_CYCLEWINDOWS: code = "CYCLEWINDOWS"; break;
         case KEY_MAIL: code = "MAIL"; break;
         case KEY_BOOKMARKS: code = "BOOKMARKS"; break;
         case KEY_COMPUTER: code = "COMPUTER"; break;
         case KEY_BACK: code = "BACK"; break;
         case KEY_FORWARD: code = "FORWARD"; break;
         case KEY_CLOSECD: code = "CLOSECD"; break;
         case KEY_EJECTCD: code = "EJECTCD"; break;
         case KEY_EJECTCLOSECD: code = "EJECTCLOSECD"; break;
         case KEY_NEXTSONG: code = "NEXTSONG"; break;
         case KEY_PLAYPAUSE: code = "PLAYPAUSE"; break;
         case KEY_PREVIOUSSONG: code = "PREVIOUSSONG"; break;
         case KEY_STOPCD: code = "STOPCD"; break;
         case KEY_RECORD: code = "RECORD"; break;
         case KEY_REWIND: code = "REWIND"; break;
         case KEY_PHONE: code = "PHONE"; break;
         case KEY_ISO: code = "ISO"; break;
         case KEY_CONFIG: code = "CONFIG"; break;
         case KEY_HOMEPAGE: code = "HOMEPAGE"; break;
         case KEY_REFRESH: code = "REFRESH"; break;
         case KEY_EXIT: code = "EXIT"; break;
         case KEY_MOVE: code = "MOVE"; break;
         case KEY_EDIT: code = "EDIT"; break;
         case KEY_SCROLLUP: code = "SCROLLUP"; break;
         case KEY_SCROLLDOWN: code = "SCROLLDOWN"; break;
         case KEY_KPLEFTPAREN: code = "KPLEFTPAREN"; break;
         case KEY_KPRIGHTPAREN: code = "KPRIGHTPAREN"; break;
         case KEY_NEW: code = "NEW"; break;
         case KEY_REDO: code = "REDO"; break;

         case KEY_F13: code = "F13"; break;
         case KEY_F14: code = "F14"; break;
         case KEY_F15: code = "F15"; break;
         case KEY_F16: code = "F16"; break;
         case KEY_F17: code = "F17"; break;
         case KEY_F18: code = "F18"; break;
         case KEY_F19: code = "F19"; break;
         case KEY_F20: code = "F20"; break;
         case KEY_F21: code = "F21"; break;
         case KEY_F22: code = "F22"; break;
         case KEY_F23: code = "F23"; break;
         case KEY_F24: code = "F24"; break;

         case KEY_PLAYCD: code = "PLAYCD"; break;
         case KEY_PAUSECD: code = "PAUSECD"; break;
         case KEY_PROG3: code = "PROG3"; break;
         case KEY_PROG4: code = "PROG4"; break;
         case KEY_DASHBOARD: code = "DASHBOARD"; break;
         case KEY_SUSPEND: code = "SUSPEND"; break;
         case KEY_CLOSE: code = "CLOSE"; break;
         case KEY_PLAY: code = "PLAY"; break;
         case KEY_FASTFORWARD: code = "FASTFORWARD"; break;
         case KEY_BASSBOOST: code = "BASSBOOST"; break;
         case KEY_PRINT: code = "PRINT"; break;
         case KEY_HP: code = "HP"; break;
         case KEY_CAMERA: code = "CAMERA"; break;
         case KEY_SOUND: code = "SOUND"; break;
         case KEY_QUESTION: code = "QUESTION"; break;
         case KEY_EMAIL: code = "EMAIL"; break;
         case KEY_CHAT: code = "CHAT"; break;
         case KEY_SEARCH: code = "SEARCH"; break;
         case KEY_CONNECT: code = "CONNECT"; break;
         case KEY_FINANCE: code = "FINANCE"; break;
         case KEY_SPORT: code = "SPORT"; break;
         case KEY_SHOP: code = "SHOP"; break;
         case KEY_ALTERASE: code = "ALTERASE"; break;
         case KEY_CANCEL: code = "CANCEL"; break;
         case KEY_BRIGHTNESSDOWN: code = "BRIGHTNESSDOWN"; break;
         case KEY_BRIGHTNESSUP: code = "BRIGHTNESSUP"; break;
         case KEY_MEDIA: code = "MEDIA"; break;

         case KEY_SWITCHVIDEOMODE: code = "SWITCHVIDEOMODE"; break;
         case KEY_KBDILLUMTOGGLE: code = "KBDILLUMTOGGLE"; break;
         case KEY_KBDILLUMDOWN: code = "KBDILLUMDOWN"; break;
         case KEY_KBDILLUMUP: code = "KBDILLUMUP"; break;

         case KEY_SEND: code = "SEND"; break;
         case KEY_REPLY: code = "REPLY"; break;
         case KEY_FORWARDMAIL: code = "FORWARDMAIL"; break;
         case KEY_SAVE: code = "SAVE"; break;
         case KEY_DOCUMENTS: code = "DOCUMENTS"; break;

         case KEY_BATTERY: code = "BATTERY"; break;

         case KEY_BLUETOOTH: code = "BLUETOOTH"; break;
         case KEY_WLAN: code = "WLAN"; break;
         case KEY_UWB: code = "UWB"; break;

         case KEY_UNKNOWN: code = "UNKNOWN"; break;

         case KEY_VIDEO_NEXT: code = "VIDEO_NEXT"; break;
         case KEY_VIDEO_PREV: code = "VIDEO_PREV"; break;
         case KEY_BRIGHTNESS_CYCLE: code = "BRIGHTNESS_CYCLE"; break;
         case KEY_BRIGHTNESS_ZERO: code = "BRIGHTNESS_ZERO"; break;
         case KEY_DISPLAY_OFF: code = "DISPLAY_OFF"; break;

         case KEY_WIMAX: code = "WIMAX"; break;
         case KEY_RFKILL: code = "RFKILL"; break;

         case KEY_MICMUTE: code = "MICMUTE"; break;

         case BTN_0: code = "0"; break;
         case BTN_1: code = "1"; break;
         case BTN_2: code = "2"; break;
         case BTN_3: code = "3"; break;
         case BTN_4: code = "4"; break;
         case BTN_5: code = "5"; break;
         case BTN_6: code = "6"; break;
         case BTN_7: code = "7"; break;
         case BTN_8: code = "8"; break;
         case BTN_9: code = "9"; break;

         case BTN_LEFT: code = "LEFT"; break;
         case BTN_RIGHT: code = "RIGHT"; break;
         case BTN_MIDDLE: code = "MIDDLE"; break;
         case BTN_SIDE: code = "SIDE"; break;
         case BTN_EXTRA: code = "EXTRA"; break;
         case BTN_FORWARD: code = "FORWARD"; break;
         case BTN_BACK: code = "BACK"; break;
         case BTN_TASK: code = "TASK"; break;

         case BTN_TRIGGER: code = "TRIGGER"; break;
         case BTN_THUMB: code = "THUMB"; break;
         case BTN_THUMB2: code = "THUMB2"; break;
         case BTN_TOP: code = "TOP"; break;
         case BTN_TOP2: code = "TOP2"; break;
         case BTN_PINKIE: code = "PINKIE"; break;
         case BTN_BASE: code = "BASE"; break;
         case BTN_BASE2: code = "BASE2"; break;
         case BTN_BASE3: code = "BASE3"; break;
         case BTN_BASE4: code = "BASE4"; break;
         case BTN_BASE5: code = "BASE5"; break;
         case BTN_BASE6: code = "BASE6"; break;
         case BTN_DEAD: code = "DEAD"; break;

         case BTN_A: code = "A"; break;
         case BTN_B: code = "B"; break;
         case BTN_C: code = "C"; break;
         case BTN_X: code = "X"; break;
         case BTN_Y: code = "Y"; break;
         case BTN_Z: code = "Z"; break;
         case BTN_TL: code = "TL"; break;
         case BTN_TR: code = "TR"; break;
         case BTN_TL2: code = "TL2"; break;
         case BTN_TR2: code = "TR2"; break;
         case BTN_SELECT: code = "SELECT"; break;
         case BTN_START: code = "START"; break;
         case BTN_MODE: code = "MODE"; break;
         case BTN_THUMBL: code = "THUMBL"; break;
         case BTN_THUMBR: code = "THUMBR"; break;

         case BTN_TOOL_PEN: code = "TOOL_PEN"; break;
         case BTN_TOOL_RUBBER: code = "TOOL_RUBBER"; break;
         case BTN_TOOL_BRUSH: code = "TOOL_BRUSH"; break;
         case BTN_TOOL_PENCIL: code = "TOOL_PENCIL"; break;
         case BTN_TOOL_AIRBRUSH: code = "TOOL_AIRBRUSH"; break;
         case BTN_TOOL_FINGER: code = "TOOL_FINGER"; break;
         case BTN_TOOL_MOUSE: code = "TOOL_MOUSE"; break;
         case BTN_TOOL_LENS: code = "TOOL_LENS"; break;
         case BTN_TOOL_QUINTTAP: code = "TOOL_QUINTTAP"; break;
         case BTN_TOUCH: code = "TOUCH"; break;
         case BTN_STYLUS: code = "STYLUS"; break;
         case BTN_STYLUS2: code = "STYLUS2"; break;
         case BTN_TOOL_DOUBLETAP: code = "TOOL_DOUBLETAP"; break;
         case BTN_TOOL_TRIPLETAP: code = "TOOL_TRIPLETAP"; break;
         case BTN_TOOL_QUADTAP: code = "TOOL_QUADTAP"; break;

         case BTN_GEAR_DOWN: code = "GEAR_DOWN"; break;
         case BTN_GEAR_UP: code = "GEAR_UP"; break;

         case KEY_OK: code = "OK"; break;
         case KEY_SELECT: code = "SELECT"; break;
         case KEY_GOTO: code = "GOTO"; break;
         case KEY_CLEAR: code = "CLEAR"; break;
         case KEY_POWER2: code = "POWER2"; break;
         case KEY_OPTION: code = "OPTION"; break;
         case KEY_INFO: code = "INFO"; break;
         case KEY_TIME: code = "TIME"; break;
         case KEY_VENDOR: code = "VENDOR"; break;
         case KEY_ARCHIVE: code = "ARCHIVE"; break;
         case KEY_PROGRAM: code = "PROGRAM"; break;
         case KEY_CHANNEL: code = "CHANNEL"; break;
         case KEY_FAVORITES: code = "FAVORITES"; break;
         case KEY_EPG: code = "EPG"; break;
         case KEY_PVR: code = "PVR"; break;
         case KEY_MHP: code = "MHP"; break;
         case KEY_LANGUAGE: code = "LANGUAGE"; break;
         case KEY_TITLE: code = "TITLE"; break;
         case KEY_SUBTITLE: code = "SUBTITLE"; break;
         case KEY_ANGLE: code = "ANGLE"; break;
         case KEY_ZOOM: code = "ZOOM"; break;
         case KEY_MODE: code = "MODE"; break;
         case KEY_KEYBOARD: code = "KEYBOARD"; break;
         case KEY_SCREEN: code = "SCREEN"; break;
         case KEY_PC: code = "PC"; break;
         case KEY_TV: code = "TV"; break;
         case KEY_TV2: code = "TV2"; break;
         case KEY_VCR: code = "VCR"; break;
         case KEY_VCR2: code = "VCR2"; break;
         case KEY_SAT: code = "SAT"; break;
         case KEY_SAT2: code = "SAT2"; break;
         case KEY_CD: code = "CD"; break;
         case KEY_TAPE: code = "TAPE"; break;
         case KEY_RADIO: code = "RADIO"; break;
         case KEY_TUNER: code = "TUNER"; break;
         case KEY_PLAYER: code = "PLAYER"; break;
         case KEY_TEXT: code = "TEXT"; break;
         case KEY_DVD: code = "DVD"; break;
         case KEY_AUX: code = "AUX"; break;
         case KEY_MP3: code = "MP3"; break;
         case KEY_AUDIO: code = "AUDIO"; break;
         case KEY_VIDEO: code = "VIDEO"; break;
         case KEY_DIRECTORY: code = "DIRECTORY"; break;
         case KEY_LIST: code = "LIST"; break;
         case KEY_MEMO: code = "MEMO"; break;
         case KEY_CALENDAR: code = "CALENDAR"; break;
         case KEY_RED: code = "RED"; break;
         case KEY_GREEN: code = "GREEN"; break;
         case KEY_YELLOW: code = "YELLOW"; break;
         case KEY_BLUE: code = "BLUE"; break;
         case KEY_CHANNELUP: code = "CHANNELUP"; break;
         case KEY_CHANNELDOWN: code = "CHANNELDOWN"; break;
         case KEY_FIRST: code = "FIRST"; break;
         case KEY_LAST: code = "LAST"; break;
         case KEY_AB: code = "AB"; break;
         case KEY_NEXT: code = "NEXT"; break;
         case KEY_RESTART: code = "RESTART"; break;
         case KEY_SLOW: code = "SLOW"; break;
         case KEY_SHUFFLE: code = "SHUFFLE"; break;
         case KEY_BREAK: code = "BREAK"; break;
         case KEY_PREVIOUS: code = "PREVIOUS"; break;
         case KEY_DIGITS: code = "DIGITS"; break;
         case KEY_TEEN: code = "TEEN"; break;
         case KEY_TWEN: code = "TWEN"; break;
         case KEY_VIDEOPHONE: code = "VIDEOPHONE"; break;
         case KEY_GAMES: code = "GAMES"; break;
         case KEY_ZOOMIN: code = "ZOOMIN"; break;
         case KEY_ZOOMOUT: code = "ZOOMOUT"; break;
         case KEY_ZOOMRESET: code = "ZOOMRESET"; break;
         case KEY_WORDPROCESSOR: code = "WORDPROCESSOR"; break;
         case KEY_EDITOR: code = "EDITOR"; break;
         case KEY_SPREADSHEET: code = "SPREADSHEET"; break;
         case KEY_GRAPHICSEDITOR: code = "GRAPHICSEDITOR"; break;
         case KEY_PRESENTATION: code = "PRESENTATION"; break;
         case KEY_DATABASE: code = "DATABASE"; break;
         case KEY_NEWS: code = "NEWS"; break;
         case KEY_VOICEMAIL: code = "VOICEMAIL"; break;
         case KEY_ADDRESSBOOK: code = "ADDRESSBOOK"; break;
         case KEY_MESSENGER: code = "MESSENGER"; break;
         case KEY_DISPLAYTOGGLE: code = "DISPLAYTOGGLE"; break;
         case KEY_SPELLCHECK: code = "SPELLCHECK"; break;
         case KEY_LOGOFF: code = "LOGOFF"; break;

         case KEY_DOLLAR: code = "DOLLAR"; break;
         case KEY_EURO: code = "EURO"; break;

         case KEY_FRAMEBACK: code = "FRAMEBACK"; break;
         case KEY_FRAMEFORWARD: code = "FRAMEFORWARD"; break;
         case KEY_CONTEXT_MENU: code = "CONTEXT_MENU"; break;
         case KEY_MEDIA_REPEAT: code = "MEDIA_REPEAT"; break;
         case KEY_10CHANNELSUP: code = "10CHANNELSUP"; break;
         case KEY_10CHANNELSDOWN: code = "10CHANNELSDOWN"; break;
         case KEY_IMAGES: code = "IMAGES"; break;

         case KEY_DEL_EOL: code = "DEL_EOL"; break;
         case KEY_DEL_EOS: code = "DEL_EOS"; break;
         case KEY_INS_LINE: code = "INS_LINE"; break;
         case KEY_DEL_LINE: code = "DEL_LINE"; break;

         case KEY_FN: code = "FN"; break;
         case KEY_FN_ESC: code = "FN_ESC"; break;
         case KEY_FN_F1: code = "FN_F1"; break;
         case KEY_FN_F2: code = "FN_F2"; break;
         case KEY_FN_F3: code = "FN_F3"; break;
         case KEY_FN_F4: code = "FN_F4"; break;
         case KEY_FN_F5: code = "FN_F5"; break;
         case KEY_FN_F6: code = "FN_F6"; break;
         case KEY_FN_F7: code = "FN_F7"; break;
         case KEY_FN_F8: code = "FN_F8"; break;
         case KEY_FN_F9: code = "FN_F9"; break;
         case KEY_FN_F10: code = "FN_F10"; break;
         case KEY_FN_F11: code = "FN_F11"; break;
         case KEY_FN_F12: code = "FN_F12"; break;
         case KEY_FN_1: code = "FN_1"; break;
         case KEY_FN_2: code = "FN_2"; break;
         case KEY_FN_D: code = "FN_D"; break;
         case KEY_FN_E: code = "FN_E"; break;
         case KEY_FN_F: code = "FN_F"; break;
         case KEY_FN_S: code = "FN_S"; break;
         case KEY_FN_B: code = "FN_B"; break;

         case KEY_BRL_DOT1: code = "BRL_DOT1"; break;
         case KEY_BRL_DOT2: code = "BRL_DOT2"; break;
         case KEY_BRL_DOT3: code = "BRL_DOT3"; break;
         case KEY_BRL_DOT4: code = "BRL_DOT4"; break;
         case KEY_BRL_DOT5: code = "BRL_DOT5"; break;
         case KEY_BRL_DOT6: code = "BRL_DOT6"; break;
         case KEY_BRL_DOT7: code = "BRL_DOT7"; break;
         case KEY_BRL_DOT8: code = "BRL_DOT8"; break;
         case KEY_BRL_DOT9: code = "BRL_DOT9"; break;
         case KEY_BRL_DOT10: code = "BRL_DOT10"; break;

         case KEY_NUMERIC_0: code = "NUMERIC_0"; break;
         case KEY_NUMERIC_1: code = "NUMERIC_1"; break;
         case KEY_NUMERIC_2: code = "NUMERIC_2"; break;
         case KEY_NUMERIC_3: code = "NUMERIC_3"; break;
         case KEY_NUMERIC_4: code = "NUMERIC_4"; break;
         case KEY_NUMERIC_5: code = "NUMERIC_5"; break;
         case KEY_NUMERIC_6: code = "NUMERIC_6"; break;
         case KEY_NUMERIC_7: code = "NUMERIC_7"; break;
         case KEY_NUMERIC_8: code = "NUMERIC_8"; break;
         case KEY_NUMERIC_9: code = "NUMERIC_9"; break;
         case KEY_NUMERIC_STAR: code = "NUMERIC_STAR"; break;
         case KEY_NUMERIC_POUND: code = "NUMERIC_POUND"; break;

         case KEY_CAMERA_FOCUS: code = "CAMERA_FOCUS"; break;
         case KEY_WPS_BUTTON: code = "WPS_BUTTON"; break;

         case KEY_TOUCHPAD_TOGGLE: code = "TOUCHPAD_TOGGLE"; break;
         case KEY_TOUCHPAD_ON: code = "TOUCHPAD_ON"; break;
         case KEY_TOUCHPAD_OFF: code = "TOUCHPAD_OFF"; break;

         case KEY_CAMERA_ZOOMIN: code = "CAMERA_ZOOMIN"; break;
         case KEY_CAMERA_ZOOMOUT: code = "CAMERA_ZOOMOUT"; break;
         case KEY_CAMERA_UP: code = "CAMERA_UP"; break;
         case KEY_CAMERA_DOWN: code = "CAMERA_DOWN"; break;
         case KEY_CAMERA_LEFT: code = "CAMERA_LEFT"; break;
         case KEY_CAMERA_RIGHT: code = "CAMERA_RIGHT"; break;

         default: code = codestr.c_str(); break;
      }
   }

   char buffer[256];
   sprintf(buffer, "%d.%06d type=%s code=%s -> %d", int(m_iev.time.tv_sec), int(m_iev.time.tv_usec), type, code, m_iev.value);
   m_log(log_level::DEBUG, std::string(buffer));
}
Beispiel #9
0
bool ansi_c_languaget::parse(
  std::istream &instream,
  const std::string &path)
{
  // store the path

  parse_path=path;

  // preprocessing

  std::ostringstream o_preprocessed;

  if(preprocess(instream, path, o_preprocessed))
    return true;

  std::istringstream i_preprocessed(o_preprocessed.str());

  // parsing

  std::string code;
  ansi_c_internal_additions(code);
  std::istringstream codestr(code);

  ansi_c_parser.clear();
  ansi_c_parser.set_file(ID_built_in);
  ansi_c_parser.in=&codestr;
  ansi_c_parser.set_message_handler(get_message_handler());
  ansi_c_parser.for_has_scope=config.ansi_c.for_has_scope;
  ansi_c_parser.cpp98=false; // it's not C++
  ansi_c_parser.cpp11=false; // it's not C++

  switch(config.ansi_c.mode)
  {
  case configt::ansi_ct::flavourt::MODE_CODEWARRIOR_C_CPP:
    ansi_c_parser.mode=ansi_c_parsert::CW;
    break;
   
  case configt::ansi_ct::flavourt::MODE_VISUAL_STUDIO_C_CPP:
    ansi_c_parser.mode=ansi_c_parsert::MSC;
    break;
    
  case configt::ansi_ct::flavourt::MODE_ANSI_C_CPP:
    ansi_c_parser.mode=ansi_c_parsert::ANSI;
    break;
    
  case configt::ansi_ct::flavourt::MODE_GCC_C:
  case configt::ansi_ct::flavourt::MODE_GCC_CPP:
    ansi_c_parser.mode=ansi_c_parsert::GCC;
    break;
    
  case configt::ansi_ct::flavourt::MODE_ARM_C_CPP:
    ansi_c_parser.mode=ansi_c_parsert::ARM;
    break;
    
  default:
    assert(false);
  }

  ansi_c_scanner_init();

  bool result=ansi_c_parser.parse();

  if(!result)
  {
    ansi_c_parser.set_line_no(0);
    ansi_c_parser.set_file(path);
    ansi_c_parser.in=&i_preprocessed;
    ansi_c_scanner_init();
    result=ansi_c_parser.parse();
  }

  // save result
  parse_tree.swap(ansi_c_parser.parse_tree);

  // save some memory
  ansi_c_parser.clear();

  return result;
}
CoreAudioReadStream::CoreAudioReadStream(string path) :
    m_path(path),
    m_d(new D)
{
    m_channelCount = 0;
    m_sampleRate = 0;

    if (!QFile(m_path).exists()) {
        throw FileNotFound(m_path);
    }

    QByteArray ba = m_path.toLocal8Bit();

    CFURLRef url = CFURLCreateFromFileSystemRepresentation
        (kCFAllocatorDefault,
         (const UInt8 *)ba.data(),
         (CFIndex)ba.length(),
         false);

    //!!! how do we find out if the file open fails because of DRM protection?

#if (MACOSX_DEPLOYMENT_TARGET <= 1040 && MAC_OS_X_VERSION_MIN_REQUIRED <= 1040)
    FSRef fsref;
    if (!CFURLGetFSRef(url, &fsref)) { // returns Boolean, not error code
        m_error = "CoreAudioReadStream: Error looking up FS ref (file not found?)";
        throw FileReadFailed(m_path);
    }
    m_d->err = ExtAudioFileOpen(&fsref, &m_d->file);
#else
    m_d->err = ExtAudioFileOpenURL(url, &m_d->file);
#endif

    CFRelease(url);

    if (m_d->err) { 
        m_error = "CoreAudioReadStream: Error opening file: code " + codestr(m_d->err);
        throw InvalidFileFormat(path, "failed to open audio file");
    }
    if (!m_d->file) { 
        m_error = "CoreAudioReadStream: Failed to open file, but no error reported!";
        throw InvalidFileFormat(path, "failed to open audio file");
    }
    
    UInt32 propsize = sizeof(AudioStreamBasicDescription);
    m_d->err = ExtAudioFileGetProperty
	(m_d->file, kExtAudioFileProperty_FileDataFormat, &propsize, &m_d->asbd);
    
    if (m_d->err) {
        m_error = "CoreAudioReadStream: Error in getting basic description: code " + codestr(m_d->err);
        ExtAudioFileDispose(m_d->file);
        throw FileOperationFailed(m_path, "get basic description", codestr(m_d->err));
    }
	
    m_channelCount = m_d->asbd.mChannelsPerFrame;
    m_sampleRate = m_d->asbd.mSampleRate;

    cerr << "CoreAudioReadStream: " << m_channelCount << " channels, " << m_sampleRate << " Hz" << std::endl;


    m_d->asbd.mSampleRate = getSampleRate();

    m_d->asbd.mFormatID = kAudioFormatLinearPCM;
    m_d->asbd.mFormatFlags =
        kAudioFormatFlagIsFloat |
        kAudioFormatFlagIsPacked |
        kAudioFormatFlagsNativeEndian;
    m_d->asbd.mBitsPerChannel = sizeof(float) * 8;
    m_d->asbd.mBytesPerFrame = sizeof(float) * m_channelCount;
    m_d->asbd.mBytesPerPacket = sizeof(float) * m_channelCount;
    m_d->asbd.mFramesPerPacket = 1;
    m_d->asbd.mReserved = 0;
	
    m_d->err = ExtAudioFileSetProperty
	(m_d->file, kExtAudioFileProperty_ClientDataFormat, propsize, &m_d->asbd);
    
    if (m_d->err) {
        m_error = "CoreAudioReadStream: Error in setting client format: code " + codestr(m_d->err);
        throw FileOperationFailed(m_path, "set client format", codestr(m_d->err));
    }

    m_d->buffer.mNumberBuffers = 1;
    m_d->buffer.mBuffers[0].mNumberChannels = m_channelCount;
    m_d->buffer.mBuffers[0].mDataByteSize = 0;
    m_d->buffer.mBuffers[0].mData = 0;
}