22 #ifndef DIRECTOR_LINGO_LINGO_H 23 #define DIRECTOR_LINGO_LINGO_H 29 class SeekableReadStreamEndian;
34 struct ChunkReference;
36 struct PictureReference;
38 struct TheEntityField;
40 struct LingoV4Bytecode;
41 struct LingoV4TheEntity;
52 typedef void (*inst)(void);
54 #define ENTITY_INDEX(t,id) ((t) * 100000 + (id)) 56 int calcStringAlignment(
const char *s);
57 int calcCodeAlignment(
int l);
106 bool operator==(
Symbol &s)
const;
115 PArray() : _sorted(
false) {}
117 PArray(
int size) : _sorted(
false), arr(size) {}
124 FArray() : _sorted(
false) {}
126 FArray(
int size) : _sorted(
false), arr(size) {}
167 double asFloat()
const;
170 CastMemberID asMemberID(CastType castType = kCastTypeAny,
int castLib = 0)
const;
175 bool isVarRef()
const;
176 bool isCastRef()
const;
177 bool isArray()
const;
178 bool isNumeric()
const;
180 const char *type2str(
bool ilk =
false)
const;
182 int equalTo(
Datum &d,
bool ignoreCase =
false)
const;
183 uint32 compareTo(
Datum &d)
const;
185 bool operator==(
Datum &d)
const;
186 bool operator>(
Datum &d)
const;
187 bool operator<(
Datum &d)
const;
188 bool operator>=(
Datum &d)
const;
189 bool operator<=(
Datum &d)
const;
201 : source(src), type(t), startChunk(sc), endChunk(ec), start(s), end(e) {}
230 Builtin(
void (*func1)(
void),
int nargs1) : func(func1), nargs(nargs1) {}
240 typedef void (*XLibOpenerFunc)(ObjectType,
const Common::Path &);
241 typedef void (*XLibCloserFunc)(ObjectType);
253 ScriptData *retScript;
255 DatumHash *retLocalVars;
257 uint stackSizeBefore;
267 EventHandlerSourceType eventHandlerSourceType;
268 ScriptType scriptType;
277 eventHandlerSourceType = kNoneHandler;
279 passByDefault = pass;
288 eventHandlerSourceType = ehst;
289 scriptType = kNoneScript;
290 passByDefault = pass;
303 ScriptContextHash lctxContexts;
304 ScriptContextHash scriptContexts[kMaxScriptType + 1];
305 FactoryContextHash factoryContexts;
308 SymbolHash functionHandlers;
315 void addCode(
const Common::U32String &code, ScriptType type, uint16
id,
const char *scriptName =
nullptr, uint32 preprocFlags = kLPPNone);
316 void patchCode(
const Common::U32String &code, ScriptType type, uint16
id,
const char *scriptName =
nullptr, uint32 preprocFlags = kLPPNone);
317 void removeCode(ScriptType type, uint16
id);
318 void replaceCode(
const Common::U32String &code, ScriptType type, uint16
id,
const char *scriptName =
nullptr);
323 void patchScriptHandler(ScriptType type,
CastMemberID id);
334 ScriptData *script =
nullptr;
336 DatumHash *localVars =
nullptr;
342 enum LingoExecState {
358 int getMenuItemsNum(
Datum &d);
360 int getCastLibsNum();
366 void printStack(
const char *s, uint pc);
368 void printCallStack(uint pc);
371 Common::String decodeInstruction(ScriptData *sd, uint pc, uint *newPC = NULL);
376 void reloadBuiltIns();
379 void cleanupBuiltIns();
385 void cleanupMethods();
392 void closeOpenXLibs();
393 void reloadOpenXLibs();
399 void initEventHandlerTypes();
400 bool processEvent(LEvent event, ScriptType st,
CastMemberID scriptId,
int channelId = -1);
403 ScriptType event2script(LEvent ev);
410 void switchStateFromWindow();
412 void freezePlayState();
413 void pushContext(
const Symbol funcSym,
bool allowRetVal,
Datum defaultRetVal,
int paramCount,
int nargs);
414 void popContext(
bool aborting =
false);
415 void cleanLocalVars();
416 void varAssign(
const Datum &var,
const Datum &value);
417 Datum varFetch(
const Datum &var,
bool silent =
false);
419 Datum findVarV4(
int varType,
const Datum &
id);
421 void exposeXObject(
const char *name,
Datum obj);
423 int getAlignedType(
const Datum &d1,
const Datum &d2,
bool equality);
428 inst readInst() {
return getInst(_state->pc++); }
429 inst getInst(uint pc) {
return (*_state->script)[pc]; }
430 int readInt() {
return getInt(_state->pc++); }
432 double readFloat() {
double d = getFloat(_state->pc); _state->pc += calcCodeAlignment(
sizeof(
double));
return d; }
433 double getFloat(uint pc) {
return *(
double *)(&((*_state->script)[_state->pc])); }
434 char *readString() {
char *s = getString(_state->pc); _state->pc += calcStringAlignment(s);
return s; }
435 char *getString(uint pc) {
return (
char *)(&((*_state->script)[_state->pc])); }
440 void printArgs(
const char *funcname,
int nargs,
const char *prefix =
nullptr);
441 inline void printSTUBWithArglist(
const char *funcname,
int nargs) { printArgs(funcname, nargs,
"STUB: "); }
442 void convertVOIDtoString(
int arg,
int nargs);
443 void dropStack(
int nargs);
446 void lingoError(
const char *s, ...);
450 void func_beep(
int repeats);
451 void func_goto(
Datum &frame,
Datum &movie,
bool commandgo =
false );
452 void func_gotoloop();
453 void func_gotonext();
454 void func_gotoprevious();
456 void func_playdone();
457 void func_cursor(
Datum cursorDatum);
458 int func_marker(
int m);
459 uint16 func_label(
Datum &label);
463 void initTheEntities();
464 void cleanUpTheEntities();
465 const char *entity2str(
int id);
466 const char *field2str(
int id);
472 bool _preLoadEventAbort;
476 bool _updateMovieEnabled;
479 Datum getTheEntity(
int entity,
Datum &
id,
int field);
480 void setTheEntity(
int entity,
Datum &
id,
int field,
Datum &d);
482 void setTheSprite(
Datum &
id,
int field,
Datum &d);
484 void setTheCast(
Datum &
id,
int field,
Datum &d);
486 void setTheField(
Datum &id1,
int field,
Datum &d);
488 void setTheChunk(
Datum &chunk,
int field,
Datum &d);
491 Datum getTheDate(
int field);
492 Datum getTheTime(
int field);
493 Datum getTheDeskTopRectList();
503 int _currentChannelId;
512 TheEntityHash _theEntities;
513 TheEntityFieldHash _theEntityFields;
517 SymbolHash _builtinCmds;
518 SymbolHash _builtinFuncs;
519 SymbolHash _builtinConsts;
520 SymbolHash _builtinListHandlers;
522 XLibOpenerFuncHash _xlibOpeners;
523 XLibCloserFuncHash _xlibClosers;
525 OpenXLibsHash _openXLibs;
526 OpenXLibsStateHash _openXLibsState;
534 Datum peek(uint offset);
541 DatumHash _globalvars;
563 Symbol _currentInputEvent;
566 LingoExecState _state = kRunning;
567 bool (*_shouldPause)() =
nullptr;
571 void executeImmediateScripts(
Frame *frame);
572 void executePerFrameHook(
int frame,
int subframe);
577 void initCharNormalizations();
584 bool delBreakpoint(
int id);
595 extern Lingo *g_lingo;
Definition: algorithm.h:29
Definition: lingo-codegen.h:30
char32_t u32char_type_t
Definition: ustr.h:41
Definition: debugger.h:45
Definition: director.h:150
Definition: lingo-object.h:42
Definition: lobject.h:332
Definition: lingo-object.h:213