Talk:Macro plugin

From OpenKore Wiki
Revision as of 14:56, 25 December 2009 by EternalHarvest (talk | contribs) (Ideas for future versions)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Ideas for future versions

Everything written here is a fiction, DO NOT use this as a manual!
  • get rid of copy-pasted code in plugin
  • user's macros should be parsed to commands/args when loaded, not when executed
  • any block's name may be optional (in the same way as automacro's call may have no fixed name)
  • local variables, REAL variable stack

Macro syntax

Possible improvements:

  • get rid of necessity of @eval where it is possible (if, while, but would be good to have it everywhere)
  • if/while blocks
  • make label in while/end to be optional
# TEXT -- extrapolates variables and @keywords
# EXPR -- evaluates perl expression

; -- if it's already here, it should be universal and not command-dependent
do TEXT -- [1]
log TEXT -- [1]
pause EXPR
call TEXT EXPR -- [2]
(release|lock) (AUTOMACRONAME | all) -- [2]
stop
set OPTION TEXT -- [2]
LVALUE = TEXT [3]
:LABELNAME
goto TEXT -- [1]
if (EXPR) ...
while (EXPR) [as TEXT]
end [TEXT]
SUBNAME (...)
  • [1] can be made evaluating and falling back, is there any reason? Another way: quote these
  • [2] space is a BAD argument separator
  • [3] this would be a problem like [1] - currently it can be any text or @eval. But it's kind of stupid to have "$a = @eval ($b + $c)"

The biggest problem with macro syntax is if we want to keep it compatible and use same command names simultaneously.

Another idea: make completely new macro plugin based of evaluation of everything. Commands will be predefined perl subs.

API

There should be a module to provide API for communication with macroplugin, because user's macros and other code should not mess with macroplugin internals such as varstack.

Needed API calls:

  • set macro variable value
  • get macro variable value

Needed hooks from macro plugin:

  • macro variable changes

Concurrent macros

There should be possible to run many macros at the same time.

Some system of mutexes will allow:

  • compatibility with old macros (just set one mutex for every macros)
  • load many macro files at once and set mutex per file
  • autodiscover mutexes by parsing macros
  • of course, declaring mutexes in macros must be available