Ejemplo n.º 1
0
 /**
  * @param LuaSandbox $sandbox
  * @param string $name
  * @throws InvalidVariableNameException
  */
 public function assignInSandbox(LuaSandbox $sandbox, $name)
 {
     $sandbox->assertValidIdentifier($name);
     $this->sandbox = $sandbox;
     $refl = new \ReflectionObject($this->object);
     $methods = array();
     foreach ($refl->getMethods() as $method) {
         if ($method->isPublic() && !$method->isStatic() && !$method->isConstructor() && !$method->isDestructor()) {
             $methods[] = $method->name;
         }
     }
     $lua_methods = $this->createLuaMethodsForObject($methods, $this->object);
     $getter = $this->createGetterForObject();
     $setter = $this->createSetterForObject();
     $this->sandbox->runFile(__DIR__ . '/assignObject.lua');
     $this->sandbox->call('assignObject_', array($name, $lua_methods, $getter, $setter));
     $sandbox->unsetVar('assignObject_');
 }