SourceForge.net Embedding

Embedding
Table of Contents

Using OOEU in applications


You can use OOEU as an embeddable scripting engine for your applications (whether an OOEU or a normal Euphoria application). First, you'll need to include eu.e (instead of eu.ex) in your application. Then use embed_routine() to allow scripts to call routines inside of your application, and use illegal_builtin() to restrict scripts from calling certain builtin routines. Then you can use do_eval() to run scripts.

Alternatively, eu.e can be compiled into a dynamic library (see the libooeu.dll/so files provided in the binary distribution) and use it that way in order to speed up your scripts' execution. Instead of including eu.e, simply include libooeu.e, and use it exactly the same way that you would use eu.e.

  • proc cleanup_debugger()   
  • proc clear_env()   
  • func do_eval( sequence eval_code )   
  • func embed_routine( sequence name, integer rid, sequence params, integer is_func )   
  • func get_current_env()   
  • func get_eval_err()   
  • proc illegal_builtin( sequence builtin )   
  • func new_env()   
  • proc switch_env( integer env )   

    Embedding
    Table of Contents

    [proc]
    cleanup_debugger
    ()

    Category: Embedding

    If your scripting uses the debugger, you should call this routine before your program exits in order to cleanly shut down the debugger. Failure to do so could cause a machine exception to occur when your application closes.

    See Also: clear_env, do_eval, embed_routine, get_current_env, get_eval_err, illegal_builtin, new_env, switch_env


    Embedding
    Table of Contents

    [proc]
    clear_env
    ()

    Category: Embedding

    Resets the current scripting environment. This allows an application to recycle scripting environments and avoid leaking resources by simply adding new scripting environments as they are needed.

    See Also: cleanup_debugger, do_eval, embed_routine, get_current_env, get_eval_err, illegal_builtin, new_env, switch_env


    Embedding
    Table of Contents

    [func]
    do_eval
    ( sequence eval_code )

    Category: Embedding

    This is the function that will run embedded OOEU code. The code should be passed as a sequence of text with '\n's breaking up lines. If a routine is passed, the entire routine should be passed at once, or an error will result. If any errors were encountered, the return value will be zero. If there were no errors, the return value will be 1.

    See Also: cleanup_debugger, clear_env, embed_routine, get_current_env, get_eval_err, illegal_builtin, new_env, switch_env


    Embedding
    Table of Contents

    [func]
    embed_routine
    ( sequence name, integer rid, sequence params, integer is_func )

    Category: Embedding

    This function is used to allow scripts to call routines in your application. The parameter values should be as follows:

    See Also: cleanup_debugger, clear_env, do_eval, get_current_env, get_eval_err, illegal_builtin, new_env, switch_env


    Embedding
    Table of Contents

    [func]
    get_current_env
    ()

    Category: Embedding

    Returns the handle for the currently active scripting environment.

    See Also: cleanup_debugger, clear_env, do_eval, embed_routine, get_eval_err, illegal_builtin, new_env, switch_env


    Embedding
    Table of Contents

    [func]
    get_eval_err
    ()

    Category: Embedding

    This function will return a sequence containing information about the error encountered.

    See Also: cleanup_debugger, clear_env, do_eval, embed_routine, get_current_env, illegal_builtin, new_env, switch_env


    Embedding
    Table of Contents

    [proc]
    illegal_builtin
    ( sequence builtin )

    Category: Embedding

    This procedure can be used to remove the ability of evaluated code from using builtin routines. Pass the name of the builtin routine, or a sequence of builtin routines, and if any code calls that routine, an illegal call error will occur. See the predefined lists supplied in illegal.e. For a full list of builtins that can be declared illegal, see keylist.e (with the addition of the question mark: "?").

    See Also: cleanup_debugger, clear_env, do_eval, embed_routine, get_current_env, get_eval_err, new_env, switch_env


    Embedding
    Table of Contents

    [func]
    new_env
    ()

    Category: Embedding

    Creates a new scripting environment. The return value is the handle of the environment. This environment will be completely separate from other scripting environments. Note that the initial environment is automatically set up for you.

    See Also: cleanup_debugger, clear_env, do_eval, embed_routine, get_current_env, get_eval_err, illegal_builtin, switch_env


    Embedding
    Table of Contents

    [proc]
    switch_env
    ( integer env )

    Category: Embedding

    Saves the current environment and switches to the specified environment.

    See Also: cleanup_debugger, clear_env, do_eval, embed_routine, get_current_env, get_eval_err, illegal_builtin, new_env