src/tools/tRuby.h

Go to the documentation of this file.
00001 #ifndef _TRUBY_H_
00002 #define _TRUBY_H_
00003 
00004 #include "aa_config.h"
00005 
00006 #ifdef HAVE_LIBRUBY
00007 
00008 #include <ruby.h>
00009 #include <intern.h>
00010 #include <stdexcept>
00011 #include <string>
00012 #include "tDirectories.h"
00013 
00014 namespace tRuby
00015 {
00019 void CheckStatus(int status);
00020 
00024 void InitializeInterpreter();
00025 
00029 void CleanupInterpreter();
00030 
00036 void Require(const char * file);
00037 
00044 void Load(const tPath & path, const char * filename, bool wrap=false);
00045 
00053 VALUE Eval(std::string code);
00054 
00063 class Sandbox
00064 {
00065 public:
00070     Sandbox(float timeout=0);
00071 
00072     virtual ~Sandbox();
00073 
00084     VALUE Eval(std::string code);
00085 
00093     void Import(const char * constant);
00094 
00103     void Load(const tPath & path, const char * filename);
00104 protected:
00105     VALUE sandbox_;
00106     VALUE & GetSandbox();
00107     static VALUE EvalProtect(VALUE data);
00108     static VALUE ConstGetProtect(VALUE file);
00109     static VALUE LoadProtect(VALUE file);
00110 };
00111 
00118 class Safe : public Sandbox
00119 {
00120 public:
00121     Safe(float timeout=0);
00122     virtual ~Safe();
00123 };
00124 }
00125 #endif // HAVE_LIBRUBY
00126 
00127 #endif // ! _TRUBY_H_

Generated on Sat Mar 15 22:56:01 2008 for Armagetron Advanced by  doxygen 1.5.4