Skip to content
Seonghoi Lee edited this page Apr 27, 2020 · 2 revisions

AppManager

AppManager는 loop()에서 다음 규칙에 따라 Application을 관리합니다.

  • app stack에는 app instance가 항상 하나 이상 쌓여있습니다.
  • app stack의 가장 아래에는 항상 REPL app이 있습니다.
  • app stack의 가장 위에 있는 app instance는 foreground app이 됩니다.
  • foreground app 은 자신의 loop()을 매번 실행하게 됩니다.

Application

  • 다른 app에서 getAppManager().startApplication()을 호출하여 새로운 instance를 만들어낼 수 있습니다.

  • 만들어진 instance는 manager의 stack 최상단에 놓이게 됩니다.

  • foreground에 있는 동안 해당 app의 여러 함수가 실행됩니다.

  • 만약 또 다른 app을 실행할 경우 다른 앱이 foreground가 되며 모든 함수 실행을 멈춥니다.

     ⚠️ instance 가 사라지는 것은 아닙니다.
     실행한 app들이 죽고 자신이 다시 foreground가 된다면 모든 맴버가 복구됩니다.
    

Application loop

Application은 기본 함수를 정의할 수 있으며, 정의하지 않은 경우 부모 class의 함수를 overriding 합니다.

  • onInit은 처음 실행시 실행됩니다. 자신의 멤버를 초기화할 수 있습니다.

  • onDestruct은 해당 app이 파괴될 경우 실행됩니다.

  • onChat은 superuser가 채팅을 할 시 해당 채팅의 시작점을 인자로 받아 실행됩니다.

     새로 정의하지 않을 경우 AppCommand 목록을 살펴본 후 적합한 AppCommand가 있다면 실행됩니다.
    
  • loop은 해당 app이 foreground에 있는 동안 매 프레임마다 실행됩니다.

  • print는 해당 프레임에서 다른 함수가 requestUpdate를 요청하였을시 실행되며, EUDByteRW 객체를 인자로 받아 자신의 Text UI를 채워넣어야합니다.

  • onResume은 해당 app이 다른 app을 호출하였고, 그 호출한 app이 죽을 경우 한 번 실행됩니다.

Order

매 frame마다 foreground app은 다음 함수를 순차적으로 실행합니다. loop을 제외한 모든 함수는 foreground에 있어도 실행을 하지 않는 경우도 있습니다.

onResume - onInit - onChat - loop - onDestruct

onResumeonInit은 한 프레임에 같이 실행되는 경우는 없습니다.


Directory structure

SC-REPL
├── repl
│   ├── base
│   │   ├── referencetable.py (ReferenceTable)
│   │   ├── pool.py (DbPool, VarPool)
│   │   ├── encoder.py (ReadName, ReadNumber, ReadString)
│   │   └── eudbyterw.py (EUDByteRW)
│   │    
│   ├── core
│   │   ├── appmanager.py (AppManager, getAppManager)
│   │   ├── application.py (Application)
│   │   ├── appcommand.py (AppCommand)
│   │   ├── appmethod.py (AppMethod)
│   │   └── bridge.py (bridge_init, bridge_loop)
│   │
│   ├── apps
│   │   ├── repl.py (Application: REPL) (functions: REPL.addCommand...)
│   │   ├── logger.py (Application: Logger) (functions: Logger.format...)
│   │   ├── static.py (Application: StaticApp)
│   │   ├── scroll.py (Application: ScrollApp)
│   │   └── iocheck.py (supports Logger) (function: IOCheck)
│   │
│   ├── utils (utility functions)
│   │   ├── conststring.py (EPDConstString)
│   │   ├── debug.py (f_raiseError, f_raiseWarning)
│   │   ├── keycode.py (getKeyCode)
│   │   └── string.py (f_strlen, f_strcmp_ptrepd)
│   │
│   └── resources (more starcraft-ic things, needs much volume)
│       ├── encoder (argEncNumber, argEnc##)
│       └── table (starcraft things..)
│
└── plugins (plugins)

Clone this wiki locally