Annotation of nono/lib/object.cpp, revision 1.1.1.2

1.1       root        1: //
                      2: // nono
                      3: // Copyright (C) 2018 [email protected]
                      4: //
                      5: 
                      6: #include "object.h"
                      7: #include "logger.h"
                      8: #include "mpu.h"
                      9: #include "scheduler.h"
                     10: #include "textscreen.h"
                     11: 
                     12: // 全オブジェクトのリスト
                     13: std::vector<Object*> gObjects;
                     14: 
                     15: // コンストラクタ
                     16: Object::Object()
                     17: {
                     18:        logname = "?";
                     19:        devname = "?";
                     20: 
                     21:        // 自分自身をリストに繋ぐ
                     22:        gObjects.push_back(this);
                     23: }
                     24: 
                     25: // デストラクタ
                     26: Object::~Object()
                     27: {
                     28: }
                     29: 
                     30: // メッセージ表示
                     31: // 常に表示 (あらかじめ loglevel の評価をした後で呼び出す用)
                     32: void
1.1.1.2 ! root       33: Object::putmsg(const char *fmt, ...) const
1.1       root       34: {
                     35:        va_list ap;
                     36: 
                     37:        va_start(ap, fmt);
                     38:        vputmsg(fmt, ap);
                     39:        va_end(ap);
                     40: }
                     41: 
                     42: // メッセージ出力 (va_list)
                     43: // 常に表示 (あらかじめ loglevel の評価をした後で呼び出す用)
                     44: void
1.1.1.2 ! root       45: Object::vputmsg(const char *fmt, va_list ap) const
1.1       root       46: {
1.1.1.2 ! root       47:        char buf[1024];
1.1       root       48:        int len;
                     49: 
                     50:        // デバイス名だけ生表示されても分かりづらいので括弧でもつけておく
1.1.1.2 ! root       51:        len = snprintf(buf, sizeof(buf), "(%s) ", devname);
        !            52:        vsnprintf(buf + len, sizeof(buf) - len, fmt, ap);
        !            53:        gLogger->Write(buf);
1.1       root       54: }
                     55: 
                     56: // ログ出力 (可変引数)
                     57: // 常に表示 (あらかじめ loglevel の評価をした後で呼び出す用)
                     58: void
1.1.1.2 ! root       59: Object::putlog(const char *fmt, ...) const
1.1       root       60: {
                     61:        va_list ap;
                     62: 
                     63:        va_start(ap, fmt);
                     64:        vputlog(fmt, ap);
                     65:        va_end(ap);
                     66: }
                     67: 
                     68: // ログ出力 (va_list)
                     69: // 常に表示 (あらかじめ loglevel の評価をした後で呼び出す用)
                     70: void
1.1.1.2 ! root       71: Object::vputlog(const char *fmt, va_list ap) const
1.1       root       72: {
1.1.1.2 ! root       73:        char buf[1024];
1.1       root       74:        uint64 vt;
                     75:        int len = 0;
                     76: 
                     77:        vt = gScheduler->GetVirtTime();
1.1.1.2 ! root       78:        len += snprintf(buf + len, sizeof(buf) - len, "%4d.%03d'%03d'%03d ",
1.1       root       79:                (int)(vt / 1000 / 1000 / 1000),
                     80:                (int)((vt / 1000 / 1000) % 1000),
                     81:                (int)((vt / 1000) % 1000),
                     82:                (int)(vt % 1000));
                     83: 
1.1.1.2 ! root       84:        len += snprintf(buf + len, sizeof(buf) - len, "%08x %s ",
1.1       root       85:                gMPU->GetPPC(), devname);
1.1.1.2 ! root       86:        vsnprintf(buf + len, sizeof(buf) - len, fmt, ap);
1.1       root       87: 
1.1.1.2 ! root       88:        gLogger->Write(buf);
1.1       root       89: }
                     90: 
                     91: // モニタースクリーンを更新する。
                     92: bool
                     93: Object::MonitorUpdate()
                     94: {
                     95:        // モニタースクリーンなし
                     96:        return false;
                     97: }

unix.superglobalmegacorp.com

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