Annotation of nono/cli/cli_app.cpp, revision 1.1.1.8

1.1       root        1: //
                      2: // nono
1.1.1.3   root        3: // Copyright (C) 2020 nono project
                      4: // Licensed under nono-license.txt
1.1       root        5: //
                      6: 
                      7: #include "header.h"
1.1.1.8 ! root        8: #include "cuimessage.h"
1.1       root        9: #include "mainapp.h"
1.1.1.3   root       10: #include "mpu680x0.h"
1.1       root       11: #include "pluto.h"
1.1.1.7   root       12: #include "scheduler.h"
1.1       root       13: #include "vm.h"
                     14: 
                     15: // wxApp と相似にするためのクラス
                     16: class CLIApp
                     17: {
                     18:  public:
1.1.1.4   root       19:        int OnInit();
1.1       root       20:        bool Parse();
1.1.1.7   root       21:        int OnCreate();
1.1.1.8 ! root       22:        void OnHalt();
1.1       root       23: 
                     24:        int ac;
                     25:        char **av;
                     26: };
                     27: 
                     28: int
                     29: main(int ac, char *av[])
                     30: {
1.1.1.2   root       31:        std::unique_ptr<CLIApp> app(new CLIApp());
1.1       root       32: 
                     33:        // wxApp とよく似せるため
                     34:        app->ac = ac;
                     35:        app->av = av;
1.1.1.4   root       36:        return app->OnInit();
1.1       root       37: }
                     38: 
                     39: // ここがエントリポイント(のつもり)
1.1.1.4   root       40: int
1.1       root       41: CLIApp::OnInit()
                     42: {
1.1.1.4   root       43:        int rv;
                     44: 
1.1.1.6   root       45:        // CLI 側では関係ないが wx 側で必要なので初期化は2ステージに分かれている
                     46:        rv = gMainApp.Init1(true, ac, av);
1.1.1.4   root       47:        if (rv != MainApp::PASS) {
                     48:                return rv;
1.1       root       49:        }
1.1.1.6   root       50:        if (!gMainApp.Init2()) {
1.1.1.4   root       51:                return EXIT_FAILURE;
1.1       root       52:        }
                     53: 
                     54:        // メインウィンドウに相当するところ
                     55:        OnCreate();
                     56: 
1.1.1.4   root       57:        return EXIT_SUCCESS;
1.1       root       58: }
                     59: 
                     60: // メインウィンドウ作成後のイベントに相当するところ
1.1.1.7   root       61: int
1.1       root       62: CLIApp::OnCreate()
                     63: {
1.1.1.8 ! root       64:        if (gMPU680x0) {
        !            65:                CUIMessage::Connect(UIMessage::HALT,
        !            66:                        [&](const UIMessage&) { OnHalt(); });
        !            67:        }
        !            68:        // UIMessage の処理を開始する。
        !            69:        UIMessage::Attach(&CUIMessage::Process);
        !            70: 
1.1.1.6   root       71:        // 電源投入
1.1       root       72:        gVM->PowerButton();
                     73: 
1.1.1.7   root       74:        // スケジューラの終了を待つ
                     75: 
                     76:        gScheduler->Wait();
                     77: 
                     78:        return 0;
1.1       root       79: }
1.1.1.3   root       80: 
                     81: // m680x0 ダブルバスフォールト時に呼ばれるコールバック。
                     82: void
1.1.1.8 ! root       83: CLIApp::OnHalt()
1.1.1.3   root       84: {
                     85:        // どうする?
                     86:        warnx("Double bus fault has occurred in VM");
                     87: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.