Exemplo n.º 1
0
Object create_object_only(CStrRef s, ObjectData *root) {
  return Object();
}
Exemplo n.º 2
0
namespace HPHP {

const Object Object::s_nullObject = Object();

///////////////////////////////////////////////////////////////////////////////

void Object::compileTimeAssertions() {
  static_assert(sizeof(Object) == sizeof(ObjectBase), "Fix this.");
}

void ObjNR::compileTimeAssertions() {
  static_assert(offsetof(ObjNR, m_px) == kExpectedMPxOffset, "");
}

Object::~Object() {
  // force it out of line
}

Array Object::toArray() const {
  return m_px ? m_px->o_toArray() : Array();
}

String Object::toString() const {
  return m_px ? m_px->invokeToString() : String();
}

int64_t Object::toInt64ForCompare() const {
  check_collection_compare(m_px);
  return toInt64();
}

double Object::toDoubleForCompare() const {
  check_collection_compare(m_px);
  return toDouble();
}

bool Object::equal(const Object& v2) const {
  if (m_px == v2.get()) {
    return true;
  }
  if (!m_px || !v2.get()) {
    return false;
  }
  if (m_px->isCollection()) {
    return collectionEquals(m_px, v2.get());
  }
  if (UNLIKELY(m_px->instanceof(SystemLib::s_DateTimeInterfaceClass))) {
    return c_DateTime::GetTimestamp(*this) ==
        c_DateTime::GetTimestamp(v2);
  }
  if (v2.get()->getVMClass() != m_px->getVMClass()) {
    return false;
  }
  if (UNLIKELY(m_px->instanceof(SystemLib::s_ArrayObjectClass))) {
    // Compare the whole object, not just the array representation
    Array ar1(ArrayData::Create());
    Array ar2(ArrayData::Create());
    m_px->o_getArray(ar1, false);
    v2->o_getArray(ar2, false);
    return ar1->equal(ar2.get(), false);
  }
  return toArray().equal(v2.toArray());
}

bool Object::less(const Object& v2) const {
  check_collection_compare(m_px, v2.get());
  if (UNLIKELY(m_px->instanceof(SystemLib::s_DateTimeInterfaceClass))) {
    return c_DateTime::GetTimestamp(*this) <
        c_DateTime::GetTimestamp(v2);
  }
  return m_px != v2.m_px && toArray().less(v2.toArray());
}

bool Object::more(const Object& v2) const {
  check_collection_compare(m_px, v2.get());
  if (UNLIKELY(m_px->instanceof(SystemLib::s_DateTimeInterfaceClass))) {
    return c_DateTime::GetTimestamp(*this) >
        c_DateTime::GetTimestamp(v2);
  }
  return m_px != v2.m_px && toArray().more(v2.toArray());
}

static Variant warn_non_object() {
  raise_warning("Cannot access property on non-object");
  return uninit_null();
}

Variant Object::o_get(const String& propName, bool error /* = true */,
                      const String& context /* = null_string */) const {
  if (UNLIKELY(!m_px)) return warn_non_object();
  return m_px->o_get(propName, error, context);
}

Variant Object::o_set(const String& propName, const Variant& val,
                      const String& context /* = null_string */) {
  if (!m_px) {
    setToDefaultObject();
  }
  return m_px->o_set(propName, val, context);
}

Variant Object::o_setRef(const String& propName, const Variant& val,
                         const String& context /* = null_string */) {
  if (!m_px) {
    setToDefaultObject();
  }
  return m_px->o_setRef(propName, val, context);
}

Variant Object::o_set(const String& propName, RefResult val,
                      const String& context /* = null_string */) {
  return o_setRef(propName, variant(val), context);
}

const char* Object::classname_cstr() const {
  return m_px->o_getClassName().c_str();
}

///////////////////////////////////////////////////////////////////////////////
// output

void Object::serialize(VariableSerializer *serializer) const {
  if (m_px) {
    m_px->serialize(serializer);
  } else {
    serializer->writeNull();
  }
}

bool Object::unserialize(std::istream &in) {
  throw NotImplementedException(__func__);
}

void Object::setToDefaultObject() {
  raise_warning(Strings::CREATING_DEFAULT_OBJECT);
  operator=(SystemLib::AllocStdClassObject());
}

///////////////////////////////////////////////////////////////////////////////
}
Exemplo n.º 3
0
Object Object::fiberUnmarshal(FiberReferenceMap &refMap) const {
  if (m_px) {
    return m_px->fiberUnmarshal(refMap);
  }
  return Object();
}
Exemplo n.º 4
0
void Master::pyRegisterAllClasses(){

	LOG_DEBUG("called with "<<modulePluginClasses.size()<<" module+class pairs.");
	std::map<std::string,py::object> pyModules;
	py::object wooScope=boost::python::import("woo");

	auto synthesizePyModule=[&](const string& modName){
		py::object m(py::handle<>(PyModule_New(("woo."+modName).c_str())));
		m.attr("__file__")="<synthetic>";
		wooScope.attr(modName.c_str())=m;
		pyModules[modName.c_str()]=m;
		// http://stackoverflow.com/questions/11063243/synethsized-submodule-from-a-import-b-ok-vs-import-a-b-error/11063494
		py::extract<py::dict>(py::getattr(py::import("sys"),"modules"))()[("woo."+modName).c_str()]=m;
		LOG_DEBUG_EARLY("Synthesized new module woo."<<modName);
	};

	// this module is synthesized for core.Master; other synthetic modules are created on-demand in the loop below
	synthesizePyModule("core");
	py::scope core(py::import("woo.core"));

	this->pyRegisterClass();
	woo::ClassTrait::pyRegisterClass();
	woo::AttrTraitBase::pyRegisterClass();
	woo::TimingDeltas::pyRegisterClass();
	Object().pyRegisterClass(); // virtual method, therefore cannot be static

	// http://boost.2283326.n4.nabble.com/C-sig-How-to-create-package-structure-in-single-extension-module-td2697292.html

	list<pair<string,shared_ptr<Object>>> pythonables;
	for(const auto& moduleName: modulePluginClasses){
		string module(moduleName.first);
		string name(moduleName.second);
		shared_ptr<Object> obj;
		try {
			LOG_DEBUG("Factoring class "<<name);
			obj=factorClass(name);
			assert(obj);
			// needed for Master::childClasses
			for(int i=0;i<obj->getBaseClassNumber();i++) classBases[name].insert(obj->getBaseClassName(i));
			// needed for properly initialized class indices
			Indexable* indexable=dynamic_cast<Indexable*>(obj.get());
			if(indexable) indexable->createIndex();
			//
			if(pyModules.find(module)==pyModules.end()){
				try{
					// module existing as file, use it
					pyModules[module]=py::import(("woo."+module).c_str());
				} catch (py::error_already_set& e){
					// PyErr_Print shows error and clears error indicator
					if(getenv("WOO_DEBUG")) PyErr_Print();
					// this only clears the the error indicator
					else PyErr_Clear(); 
					synthesizePyModule(module);
				}
			}
			pythonables.push_back(make_pair(module,obj));
		}
		catch (std::runtime_error& e){
			/* FIXME: this catches all errors! Some of them are not harmful, however:
			 * when a class is not factorable, it is OK to skip it; */	
			 cerr<<"Caught non-critical error for class "<<module<<"."<<name;
		}
	}

	// handle Object specially
	// py::scope _scope(pyModules["core"]);
	// Object().pyRegisterClass(pyModules["core"]);

	/* python classes must be registered such that base classes come before derived ones;
	for now, just loop until we succeed; proper solution will be to build graphs of classes
	and traverse it from the top. It will be done once all classes are pythonable. */
	for(int i=0; i<11 && pythonables.size()>0; i++){
		if(i==10) throw std::runtime_error("Too many attempts to register python classes. Run again with WOO_DEBUG=1 to get better diagnostics.");
		LOG_DEBUG_EARLY_FRAGMENT(endl<<"[[[ Round "<<i<<" ]]]: ");
		std::list<string> done;
		for(auto I=pythonables.begin(); I!=pythonables.end(); ){
			const std::string& module=I->first;
			const shared_ptr<Object>& s=I->second;
			const std::string& klass=s->getClassName();
			try{
				LOG_DEBUG_EARLY_FRAGMENT("{{"<<klass<<"}}");
				py::scope _scope(pyModules[module]);
				s->pyRegisterClass();
				auto prev=I++;
				pythonables.erase(prev);
			} catch (...){
				LOG_DEBUG_EARLY("["<<klass<<"]");
				if(getenv("WOO_DEBUG")) PyErr_Print();
				else PyErr_Clear();
				I++;
			}
		}
	}
}
Exemplo n.º 5
0
Variant invokeImpl(void *extra, CArrRef params) {
  const char *function = (const char*)extra;
  // for TestExtFunction
  if (strcasecmp(function, "test") == 0) {
    return params[0];
  }

  // for TestExtPreg::test_preg_replace_callback
  if (strcasecmp(function, "next_year") == 0) {
    Array matches = params[0].toArray();
    return matches[1].toString() + String(matches[2].toInt32() + 1);
  }

  // for TestExtArray::test_array_filter
  if (strcasecmp(function, "odd") == 0) {
    return params[0].toInt32() & 1;
  }
  if (strcasecmp(function, "even") == 0) {
    return !(params[0].toInt32() & 1);
  }

  // for TestExtArray::test_array_map
  if (strcasecmp(function, "cube") == 0) {
    int n = params[0].toInt32();
    return n * n * n;
  }

  // for TestExtArray::test_array_multisort
  if (strcasecmp(function, "strtolower") == 0) {
    return f_strtolower(params[0]);
  }

  // for TestExtArray::test_array_reduce
  if (strcasecmp(function, "rsum") == 0) {
    int v = params[0].toInt32();
    int w = params[1].toInt32();
    v += w;
    return v;
  }
  if (strcasecmp(function, "rmul") == 0) {
    int v = params[0].toInt32();
    int w = params[1].toInt32();
    v *= w;
    return v;
  }

  // for TestExtArray::test_array_walk_recursive
  if (strcasecmp(function, "test_print") == 0) {
    String item = params[0].toString();
    String key = params[1].toString();
    echo(key + ": " + item + "\n");
  }

  // for TestExtArray::test_array_walk
  if (strcasecmp(function, "test_alter") == 0) {
    Variant &item1 = lval(((Array&)params).lvalAt(0));
    String key = params[1];
    String prefix = params[2];
    item1 = prefix + ": " + item1;
  }

  // for TestExtArray::test_array_udiff
  if (strcasecmp(function, "comp_func") == 0) {
    int n1 = params[0].toInt32();
    int n2 = params[1].toInt32();
    if (n1 == n2) return 0;
    return n1 > n2 ? 1 : -1;
  }

  // for TestExtArray::test_usort
  if (strcasecmp(function, "reverse_comp_func") == 0) {
    int n1 = params[0].toInt32();
    int n2 = params[1].toInt32();
    if (n1 == n2) return 0;
    return n1 > n2 ? -1 : 1;
  }

  // for TestExtArray::test_array_uintersect
  if (strcasecmp(function, "strcasecmp") == 0) {
    String s1 = params[0].toString();
    String s2 = params[1].toString();
    return strcasecmp(s1.data(), s2.data());
  }

  // for TestExtArray::test_uasort
  if (strcasecmp(function, "reverse_strcasecmp") == 0) {
    String s1 = params[0].toString();
    String s2 = params[1].toString();
    return strcasecmp(s2.data(), s1.data());
  }

  // for TestExtFbml
  if (strcasecmp(function, "urltr") == 0) {
    String s1 = params[0].toString();
    String s2 = params[1].toString();
    return String("url:") + s1 + "=" + s2;
  }

  // for TestExtCurl::test_curl_exec
  if (strcasecmp(function, "curl_write_func") == 0) {
    print("curl_write_func called with ");
    print(params[1]);
    return params[1].toString().size();
  }

  // for TestExtPreg::test_preg_replace
  if (strcasecmp(function, "strtoupper") == 0) {
    return f_strtoupper(params[0].toString());
  }
  if (strcasecmp(function, "test_preg_rep") == 0) {
    return test_preg_rep(params[0].toString(), params[1].toString(),
                       params[2].toString());
  }
  if (strcasecmp(function, "sprintf") == 0) {
    return f_sprintf(params.size(), params[0],
                     params.slice(1, params.size() - 1, false));
  }

  // for TestExtSqlite3::test_sqlite3
  if (strcasecmp(function, "lower") == 0) {
    return f_strtolower(params[0]);
  }
  if (strcasecmp(function, "sumlen_step") == 0) {
    return params[0].toInt64() + f_strlen(params[2]);
  }
  if (strcasecmp(function, "sumlen_fini") == 0) {
    return params[0].toInt64();
  }

  // for TestExtSoap
  if (strcasecmp(function, "hello") == 0) {
    return "Hello World";
  }
  if (strcasecmp(function, "add") == 0) {
    return params[0].toInt32() + params[1].toInt32();
  }
  if (strcasecmp(function, "sub") == 0) {
    return params[0].toInt32() - params[1].toInt32();
  }
  if (strcasecmp(function, "sum") == 0) {
    int sum = 0;
    for (ArrayIter iter(params[0]); iter; ++iter) {
      sum += iter.second().toInt32();
    }
    return sum;
  }
  if (strcasecmp(function, "strlen") == 0) {
    return f_strlen(params[0]);
  }
  if (strcasecmp(function, "fault") == 0) {
    return Object((NEWOBJ(c_SoapFault)())->create("MyFault","My fault string"));
  }

  // for TestExtServer
  if (strcasecmp(function, "xbox_process_message") == 0) {
    return StringUtil::Reverse(params[0]);
  }

  return true;
}
Exemplo n.º 6
0
Object c_WaitableWaitHandle::t_getcreator() {
  return Object();
}
Exemplo n.º 7
0
Object ResourceData::fiberUnmarshal(FiberReferenceMap &refMap) const {
  return Object();
}
Exemplo n.º 8
0
Array createBacktrace(const BacktraceArgs& btArgs) {
  Array bt = Array::Create();

  // If there is a parser frame, put it at the beginning of
  // the backtrace
  if (btArgs.m_parserFrame) {
    bt.append(
      make_map_array(
        s_file, btArgs.m_parserFrame->filename,
        s_line, btArgs.m_parserFrame->lineNumber
      )
    );
  }

  VMRegAnchor _;
  if (!vmfp()) {
    // If there are no VM frames, we're done
    return bt;
  }

  int depth = 0;
  ActRec* fp = nullptr;
  Offset pc = 0;

  // Get the fp and pc of the top frame (possibly skipping one frame)
  {
    if (btArgs.m_skipTop) {
      fp = getPrevActRec(vmfp(), &pc);
      if (!fp) {
        // We skipped over the only VM frame, we're done
        return bt;
      }
    } else {
      fp = vmfp();
      Unit *unit = vmfp()->m_func->unit();
      assert(unit);
      pc = unit->offsetOf(vmpc());
    }

    // Handle the top frame
    if (btArgs.m_withSelf) {
      // Builtins don't have a file and line number
      if (!fp->m_func->isBuiltin()) {
        Unit* unit = fp->m_func->unit();
        assert(unit);
        const char* filename = fp->m_func->filename()->data();
        Offset off = pc;

        ArrayInit frame(btArgs.m_parserFrame ? 4 : 2, ArrayInit::Map{});
        frame.set(s_file, filename);
        frame.set(s_line, unit->getLineNumber(off));
        if (btArgs.m_parserFrame) {
          frame.set(s_function, s_include);
          frame.set(s_args, Array::Create(btArgs.m_parserFrame->filename));
        }
        bt.append(frame.toVariant());
        depth++;
      }
    }
  }
  // Handle the subsequent VM frames
  Offset prevPc = 0;
  for (ActRec* prevFp = getPrevActRec(fp, &prevPc);
       fp != nullptr && (btArgs.m_limit == 0 || depth < btArgs.m_limit);
       fp = prevFp, pc = prevPc,
         prevFp = getPrevActRec(fp, &prevPc)) {
    // do not capture frame for HPHP only functions
    if (fp->m_func->isNoInjection()) {
      continue;
    }

    ArrayInit frame(7, ArrayInit::Map{});

    auto const curUnit = fp->m_func->unit();
    auto const curOp = *reinterpret_cast<const Op*>(curUnit->at(pc));
    auto const isReturning =
      curOp == Op::RetC || curOp == Op::RetV ||
      curOp == Op::CreateCont || curOp == Op::Await ||
      fp->localsDecRefd();

    // Builtins and generators don't have a file and line number
    if (prevFp && !prevFp->m_func->isBuiltin()) {
      auto const prevUnit = prevFp->m_func->unit();
      auto prevFile = prevUnit->filepath();
      if (prevFp->m_func->originalFilename()) {
        prevFile = prevFp->m_func->originalFilename();
      }
      assert(prevFile);
      frame.set(s_file, const_cast<StringData*>(prevFile));

      // In the normal method case, the "saved pc" for line number printing is
      // pointing at the cell conversion (Unbox/Pop) instruction, not the call
      // itself. For multi-line calls, this instruction is associated with the
      // subsequent line which results in an off-by-n. We're subtracting one
      // in order to look up the line associated with the FCall/FCallArray
      // instruction. Exception handling and the other opcodes (ex. BoxR)
      // already do the right thing. The emitter associates object access with
      // the subsequent expression and this would be difficult to modify.
      auto const opAtPrevPc =
        *reinterpret_cast<const Op*>(prevUnit->at(prevPc));
      Offset pcAdjust = 0;
      if (opAtPrevPc == Op::PopR ||
          opAtPrevPc == Op::UnboxR ||
          opAtPrevPc == Op::UnboxRNop) {
        pcAdjust = 1;
      }
      frame.set(s_line,
                prevFp->m_func->unit()->getLineNumber(prevPc - pcAdjust));
    }

    // check for include
    String funcname = const_cast<StringData*>(fp->m_func->name());
    if (fp->m_func->isClosureBody()) {
      static StringData* s_closure_label =
        makeStaticString("{closure}");
      funcname = s_closure_label;
    }

    // check for pseudomain
    if (funcname.empty()) {
      if (!prevFp && !btArgs.m_withPseudoMain) continue;
      else if (!prevFp) funcname = s_main;
      else funcname = s_include;
    }

    frame.set(s_function, funcname);

    if (!funcname.same(s_include)) {
      // Closures have an m_this but they aren't in object context
      Class* ctx = arGetContextClass(fp);
      if (ctx != nullptr && !fp->m_func->isClosureBody()) {
        frame.set(s_class, ctx->name()->data());
        if (fp->hasThis() && !isReturning) {
          if (btArgs.m_withThis) {
            frame.set(s_object, Object(fp->getThis()));
          }
          frame.set(s_type, "->");
        } else {
          frame.set(s_type, "::");
        }
      }
    }

    Array args = Array::Create();
    bool withNames = btArgs.m_withArgNames;
    bool withValues = btArgs.m_withArgValues;
    if (!btArgs.m_withArgNames && !btArgs.m_withArgValues) {
      // do nothing
    } else if (funcname.same(s_include)) {
      if (depth) {
        args.append(const_cast<StringData*>(curUnit->filepath()));
        frame.set(s_args, args);
      }
    } else if (!RuntimeOption::EnableArgsInBacktraces || isReturning) {
      // Provide an empty 'args' array to be consistent with hphpc
      frame.set(s_args, args);
    } else {
      const int nparams = fp->m_func->numNonVariadicParams();
      int nargs = fp->numArgs();
      int nformals = std::min(nparams, nargs);

      if (UNLIKELY(fp->hasVarEnv() && fp->getVarEnv()->getFP() != fp)) {
        // VarEnv is attached to eval or debugger frame, other than the current
        // frame. Access locals thru VarEnv.
        auto varEnv = fp->getVarEnv();
        auto func = fp->func();
        for (int i = 0; i < nformals; i++) {
          const StringData* argname = func->localVarName(i);
          TypedValue* tv = varEnv->lookup(argname);

          Variant val;
          if (tv != nullptr) { // the variable hasn't been unset
            val = withValues ? tvAsVariant(tv) : "";
          }

          if (withNames) {
            args.set(String(argname->data(), CopyString), val);
          } else {
            args.append(val);
          }
        }
      } else {
        for (int i = 0; i < nformals; i++) {
          const StringData* argname = withNames ? fp->func()->localVarName(i)
                                                : nullptr;
          Variant val = withValues ? tvAsVariant(frame_local(fp, i)) : "";

          if (withNames) {
            args.set(String(argname->data(), CopyString), val);
          } else {
            args.append(val);
          }
        }
      }

      /* builtin extra args are not stored in varenv */
      if (nargs > nparams && fp->hasExtraArgs()) {
        for (int i = nparams; i < nargs; i++) {
          TypedValue *arg = fp->getExtraArg(i - nparams);
          args.append(tvAsVariant(arg));
        }
      }
      frame.set(s_args, args);
    }

    bt.append(frame.toVariant());
    depth++;
  }
  return bt;

}
Exemplo n.º 9
0
 List::Proxy::operator py::Object () const
 {
     return (Object(::fetch(myList->handle(), myIndex)));
 }
Exemplo n.º 10
0
Arquivo: object.cpp Projeto: gkz/hhvm
TEST(Object, Casts) {
  // Test cast operations
  {
    EXPECT_FALSE(isa<c_Vector>(Object()));
    EXPECT_TRUE(isa_or_null<c_Vector>(Object()));

    auto dummy = req::make<c_Vector>();
    Object res(dummy);
    Object empty;
    EXPECT_TRUE(isa<c_Vector>(res));
    EXPECT_TRUE(isa_or_null<c_Vector>(res));

    EXPECT_FALSE(isa<c_Map>(res));
    EXPECT_FALSE(isa_or_null<c_Map>(res));

    // cast tests
    // Bad types and null pointers should throw.
    EXPECT_EQ(cast<c_Vector>(res), dummy);
    EXPECT_EQ(cast<ObjectData>(res), dummy);
    try {
      cast<c_Map>(res);
      EXPECT_FALSE(true);
    } catch(...) {
      EXPECT_TRUE(true);
    }
    try {
      cast<c_Vector>(empty);
      EXPECT_FALSE(true);
    } catch(...) {
      EXPECT_TRUE(true);
    }

    // cast_or_null tests
    // Bad types should throw, null pointers are ok.
    EXPECT_EQ(cast_or_null<ObjectData>(empty), nullptr);
    EXPECT_EQ(cast_or_null<ObjectData>(res), dummy);

    try {
      cast_or_null<c_Map>(res);
      EXPECT_FALSE(true);
    } catch(...) {
      EXPECT_TRUE(true);
    }

    // dyn_cast tests
    // Bad types are ok, null pointers should throw.
    EXPECT_EQ(dyn_cast<c_Vector>(res), dummy);
    EXPECT_EQ(dyn_cast<ObjectData>(res), dummy);
    EXPECT_EQ(dyn_cast<c_Map>(res), nullptr);

    try {
      dyn_cast<c_Vector>(empty);
      EXPECT_FALSE(true);
    } catch(...) {
      EXPECT_TRUE(true);
    }

    // dyn_cast_or_null
    // Bad types and null pointers are ok.  Should never throw.
    EXPECT_EQ(dyn_cast_or_null<c_Map>(res), nullptr);
    EXPECT_EQ(dyn_cast_or_null<ObjectData>(res), dummy);
    EXPECT_EQ(dyn_cast_or_null<ObjectData>(empty), nullptr);
  }
}
Exemplo n.º 11
0
	  Node(const Object& d = Object(),Node *p = NULL,Node *q=NULL):data(d),prev(p),next(q){}
Exemplo n.º 12
0
func DoStartSzen()
{

	RemoveAll(TIME);
	CreateObject(DARK,0,0,-1);
	CreateObject(TIME,0,0,-1);

	FindObjects( Find_Func("SetLightOff",1) );
	FindObjects( Find_Func("SetLightOn") );


	giPlrEnemy = 0;
	giPlrFriend = 1;

	gpIntroCandle1 = Object(302);
	gpIntroCandle2 = Object(303);
	gpIntroCandle3 = Object(301);
	gpIntroChandelier = Object(300);
	gpIntroTorch = Object(211);

	gDrawbridge = FindObject(CPT3);

	// Glühwürmchen erstellen

	CreateObject(FFAC, 627, 705, -1);
	CreateObject(FFAC, 1905, 770, -1);
	CreateObject(FFAC, 2170, 745, -1);
	CreateObject(FFAC, 2675, 490, -1);

	// Königin erstellen
	gNPCQueen = CreateObject( _PRC,0,0,giPlrFriend);
	MakeCrewMember( gNPCQueen, giPlrFriend );
	gNPCQueen->SetPosition(40,660);
	gNPCQueen->SetDir(1);
	gNPCQueen->SetName("$NPCQueen$");
	//AttachDialogue(gNPCQueen,"");

	// Hexe erstellen
	gNPCWitch = CreateObject( CLNK,0,0,giPlrFriend );
	MakeCrewMember( gNPCWitch, giPlrFriend );
	gNPCWitch->~SetName("Frau");
	gNPCWitch->~SetPosition(1170,750);
	AttachDialogue(gNPCWitch,"Alvelin");
	CreateContents(TIM1,gNPCWitch); // a dummy such that he does not collect the last barrel after ejecting it
	CreateContents(LAXE,gNPCWitch); // lumberjack's axe for looting the witch

	// Schmied erstellen
	gNPCBlacksmith = CreateObject( CLNK,0,0,giPlrFriend );
	MakeCrewMember( gNPCBlacksmith, giPlrFriend );
	gNPCBlacksmith->~SetName("Heinz");
	gNPCBlacksmith->~SetPosition(1515,770);
	AttachDialogue(gNPCBlacksmith,"Heinz");

	// Erfinder erstellen
	gNPCInventor = CreateObject( CLNK,0,0,giPlrFriend );
	MakeCrewMember( gNPCInventor, giPlrFriend );
	gNPCInventor->~SetName("Ingalf");
	gNPCInventor->SetPosition(865,800);
	AttachDialogue(gNPCInventor,"Ingalf");

	// Bürger erstellen
	gNPCCitizen = CreateObject( CLNK,0,0,giPlrFriend );
	MakeCrewMember( gNPCCitizen, giPlrFriend );
	gNPCCitizen->~SetName("Odilbert");
	gNPCCitizen->SetPosition(1215,750);
	AttachDialogue(gNPCCitizen,"Odilbert");

	// Abenteurer erstellen
	gNPCAdventurer1 = CreateObject( CLNK,0,0,giPlrFriend );
	MakeCrewMember( gNPCAdventurer1, giPlrFriend );
	gNPCAdventurer1->~SetName("Gernot");
	gNPCAdventurer1->SetPosition(2715,495);
	AttachDialogue(gNPCAdventurer1,"Gernot");

	// Abenteurer erstellen
	gNPCAdventurer2 = CreateObject( CLNK,0,0,giPlrFriend );
	MakeCrewMember( gNPCAdventurer2, giPlrFriend );
	gNPCAdventurer2->~SetName("Linnert");
	gNPCAdventurer2->SetPosition(2740,495);
	AttachDialogue(gNPCAdventurer2,"Linnert");

	// Farmer erstellen
	gNPCFarmer = CreateObject( CLNK,0,0,giPlrFriend );
	MakeCrewMember( gNPCFarmer, giPlrFriend );
	gNPCFarmer->~SetName("Armin");
	gNPCFarmer->SetPosition(1840,765);
	AttachDialogue(gNPCFarmer,"Armin");
	AttachDayNightCycle(gNPCFarmer,"Armin");
	CreateContents(TIM1,gNPCFarmer); // a dummy such that he does not collect items

	// Wirtin erstellen
	gNPCInnkeeper = CreateObject( CLNK,0,0,giPlrFriend );
	MakeCrewMember( gNPCInnkeeper, giPlrFriend );
	gNPCInnkeeper->~SetName("Bernika");
	gNPCInnkeeper->SetPosition(1315,750);
	AttachDialogue(gNPCInnkeeper,"Bernika");

	// Dirne erstellen
	gNPCProstitute = CreateObject( CLNK,0,0,giPlrFriend );
	MakeCrewMember( gNPCProstitute, giPlrFriend );
	gNPCProstitute->~SetName("Rovena");
	gNPCProstitute->SetPosition(1435,770);
	AttachDialogue(gNPCProstitute,"Rovena");

	// Wache erstellen
	gNPCGuard1 = CreateObject( CLNK,0,0,giPlrFriend );
	MakeCrewMember( gNPCGuard1, giPlrFriend );
	gNPCGuard1->~SetName("Helmar");
	gNPCGuard1->SetPosition(1615, 769);
	gNPCGuard1->SetDir(1);
	AttachDialogue(gNPCGuard1,"Helmar");

	// Wache erstellen
	gNPCGuard2 = CreateObject( CLNK,0,0,giPlrFriend );
	MakeCrewMember( gNPCGuard2, giPlrFriend );
	gNPCGuard2->~SetName("Eboreus");
	gNPCGuard2->SetPosition(395,690);
	AttachDialogue(gNPCGuard2,"Eboreus");

	// Wache erstellen
	gNPCGuard3 = CreateObject( CLNK,0,0,giPlrFriend );
	MakeCrewMember( gNPCGuard3, giPlrFriend );
	gNPCGuard3->~SetName("Radulf");
	gNPCGuard3->SetPosition(225, 448);
	AttachDialogue(gNPCGuard3,"Radulf");

	// Holzfäller erstellen
	gNPCLumberjack = CreateObject( CLNK,0,0,giPlrFriend );
	MakeCrewMember( gNPCLumberjack, giPlrFriend );
	gNPCLumberjack->~SetName("Answin");
	gNPCLumberjack->SetPosition(2000,755);
	AttachDialogue(gNPCLumberjack,"Answin");

	// Inuk erstellen
	gNPCInuk1 = CreateObject( CLNK,0,0,giPlrFriend );
	MakeCrewMember( gNPCInuk1, giPlrFriend );
	gNPCInuk1->~SetName("Bardrik");
	gNPCInuk1->SetPosition(3685,45);
	AttachDialogue(gNPCInuk1,"Bardrik");

	// Inuk erstellen
	gNPCInuk2 = CreateObject( CLNK,0,0,giPlrFriend );
	MakeCrewMember( gNPCInuk2, giPlrFriend );
	gNPCInuk2->~SetName("Jallik");
	gNPCInuk2->SetPosition(4465,340);
	AttachDialogue(gNPCInuk2,"Jallik");
	// Er hat 3 Fischfässer
	CreateContents(TIM1,gNPCInuk2); // a dummy such that he does not collect the last barrel after ejecting it
	CreateContents(FBRL,gNPCInuk2);
	CreateContents(FBRL,gNPCInuk2);
	CreateContents(FBRL,gNPCInuk2);

	// Magier erstellen
	gNPCCourtmage = CreateObject( MAGE,0,0,giPlrFriend );
	MakeCrewMember( gNPCCourtmage, giPlrFriend );
	gNPCCourtmage->~SetName("Nestor");
	gNPCCourtmage->SetPosition(200,480);
	AttachDialogue(gNPCCourtmage,"Nestor");


	//////////////////////////////////////////////////////////////

	// Bösen Magier erstellen
	gNPCGrandmaster = CreateObject( MAGE,0,0,giPlrEnemy );
	MakeCrewMember( gNPCGrandmaster, giPlrEnemy );
	gNPCGrandmaster->~SetName("OBW");


	//////////////////////////////////////////////////////////////

	// die Könige der KI-Spieler vernichten
	RemoveAll(KING);

	// erstellen
	//gNPC = CreateObject( CLNK,0,0,giPlrFriend );
	//MakeCrewMember( gNPC, giPlrFriend );
	//gNPC->~SetName("");

	CreateQuest("MainQuest");
	CreateQuest("Bandits");
	CreateQuest("MissingLooters");
	CreateQuest("KingsChalice");
	CreateQuest("DeepTreasure");
	CreateQuest("HuskyHunt");
	CreateQuest("Lumberjack");
	CreateQuest("SomethingFishy");
	CreateQuest("Whipped");
	CreateQuest("FunkyBread");
	//GetStory()->~CreateQuests();


	return;
}
Exemplo n.º 13
0
//Object
Object::Object() {
    Object(0, 0, 0, 0, 0, 0, 0, -1);
}
Exemplo n.º 14
0
Object XMLSerializerConstructorImp::construct(ExecState *exec, const List &)
{
  return Object(new XMLSerializer(exec));
}
 static void event_http_request_cb(evhttp_request_t *request, void *data) {
     EventHttpRequestResourceData *resource_data = (EventHttpRequestResourceData *) data;
     evhttp_request_own((evhttp_request_t *) resource_data->getInternalResourceData());
     vm_call_user_func(Object(resource_data->getCallback()), make_packed_array(Object(resource_data->getObjectData()), resource_data->getCallbackArg()));
 }
Exemplo n.º 16
0
 Object List::operator[] ( size_type i ) const
 {
     return (Object(::fetch(handle(), i)));
 }
Exemplo n.º 17
0
namespace HPHP {

const Object Object::s_nullObject = Object();

///////////////////////////////////////////////////////////////////////////////

HOT_FUNC
Object::~Object() {
  if (LIKELY(m_px != 0)) {
    if (UNLIKELY(m_px->decRefCount() == 0)) {
      m_px->destruct();
      if (LIKELY(m_px->getCount() == 0)) {
        delete m_px;
      }
    }
  }
}

ArrayIter Object::begin(const String& context /* = null_string */) const {
  if (!m_px) throw_null_pointer_exception();
  return m_px->begin(context);
}

MutableArrayIter Object::begin(Variant *key, Variant &val,
                               const String& context /*= null_string*/) const {
  if (!m_px) throw_null_pointer_exception();
  return m_px->begin(key, val, context);
}

Array Object::toArray() const {
  return m_px ? m_px->o_toArray() : Array();
}

int64_t Object::toInt64ForCompare() const {
  check_collection_compare(m_px);
  return toInt64();
}

double Object::toDoubleForCompare() const {
  check_collection_compare(m_px);
  return toDouble();
}

bool Object::equal(CObjRef v2) const {
  if (m_px == v2.get()) {
    return true;
  }
  if (!m_px || !v2.get()) {
    return false;
  }
  if (v2.get()->getVMClass() != m_px->getVMClass()) {
    return false;
  }
  if (m_px->isCollection()) {
    return collectionEquals(m_px, v2.get());
  }
  return toArray().equal(v2.toArray());
}

bool Object::less(CObjRef v2) const {
  check_collection_compare(m_px, v2.get());
  return m_px != v2.m_px && toArray().less(v2.toArray());
}

bool Object::more(CObjRef v2) const {
  check_collection_compare(m_px, v2.get());
  return m_px != v2.m_px && toArray().more(v2.toArray());
}

static Variant warn_non_object() {
  raise_warning("Cannot access property on non-object");
  return uninit_null();
}

Variant Object::o_get(const String& propName, bool error /* = true */,
                      const String& context /* = null_string */) const {
  if (UNLIKELY(!m_px)) return warn_non_object();
  return m_px->o_get(propName, error, context);
}

Variant Object::o_set(const String& propName, CVarRef val,
                      const String& context /* = null_string */) {
  if (!m_px) {
    setToDefaultObject();
  }
  return m_px->o_set(propName, val, context);
}

Variant Object::o_setRef(const String& propName, CVarRef val,
                         const String& context /* = null_string */) {
  if (!m_px) {
    setToDefaultObject();
  }
  return m_px->o_setRef(propName, val, context);
}

Variant Object::o_set(const String& propName, RefResult val,
                      const String& context /* = null_string */) {
  return o_setRef(propName, variant(val), context);
}

///////////////////////////////////////////////////////////////////////////////
// output

void Object::serialize(VariableSerializer *serializer) const {
  if (m_px) {
    m_px->serialize(serializer);
  } else {
    serializer->writeNull();
  }
}

bool Object::unserialize(std::istream &in) {
  throw NotImplementedException(__func__);
}

void Object::setToDefaultObject() {
  raise_warning(Strings::CREATING_DEFAULT_OBJECT);
  operator=(SystemLib::AllocStdClassObject());
}

///////////////////////////////////////////////////////////////////////////////
}
Exemplo n.º 18
0
Object co_stdclass(CArrRef params, bool init /* = true */) {
  return Object((NEW(c_stdclass)())->dynCreate(params, init));
}
Exemplo n.º 19
0
#include "ThreadWrapperBase.h"
#include "NativeExceptionBase.h"

#using <System.Windows.Forms.dll>

namespace ThreadManager
{
	ThreadWrapperBase::ThreadWrapperBase()
	{
		actionQueue = gcnew Queue<ActionItem^>();
		actionQueueLock = gcnew Object();
		doActionsLock = gcnew Object();
		terminated = gcnew ManualResetEvent(false);
		waitLock = gcnew ManualResetEvent(false);
		delegateDictionary = gcnew Dictionary<String^, Delegate^>();
		CreateThread();
	}

	void ThreadWrapperBase::StartThread(Object^ startArg)
	{
		thread->Start(startArg);
	}

	void ThreadWrapperBase::TerminateThread()
	{
		// set "terminated" to indicate we want to finish the thread
		if (terminated)
			terminated->Set();

		waitLock->Set();
Exemplo n.º 20
0
Object co___php_incomplete_class(CArrRef params, bool init /* = true */) {
  return Object((NEW(c___php_incomplete_class)())->dynCreate(params, init));
}
Exemplo n.º 21
0
namespace HPHP {

const Object Object::s_nullObject = Object();

///////////////////////////////////////////////////////////////////////////////

Array Object::toArray() const {
  return m_px ? m_px->o_toArray() : Array();
}

Variant Object::toKey() const {
  return m_px ? (isResource() ? m_px->o_toInt64() : m_px->t___tostring())
              : String();
}

bool Object::equal(CObjRef v2) const {
  if (m_px == v2.get())
    return true;
  if (!m_px || !v2.get())
    return false;
  if (isResource() || v2.isResource())
    return false;
  return (v2.get()->o_isClass(m_px->o_getClassName()) &&
          toArray().equal(v2.toArray()));
}

bool Object::less(CObjRef v2) const {
  return m_px != v2.m_px &&
    toArray().less(v2.toArray());
}

bool Object::more(CObjRef v2) const {
  return m_px != v2.m_px &&
    toArray().more(v2.toArray());
}

Variant Object::o_get(CStrRef propName, int64 hash /* = -1 */,
    bool error /* = true */) const {
  if (!m_px) throw NullPointerException();
  return m_px->o_get(propName, hash, error);
}

ObjectOffset Object::o_lval(CStrRef propName, int64 hash /* = -1 */) {
  if (!m_px) {
    operator=(NEW(c_stdclass)());
  }
  return ObjectOffset(m_px, propName, hash);
}

///////////////////////////////////////////////////////////////////////////////
// output

void Object::serialize(VariableSerializer *serializer) const {
  if (m_px) {
    m_px->serialize(serializer);
  } else {
    serializer->writeNull();
  }
}

bool Object::unserialize(std::istream &in) {
  throw NotImplementedException(__func__);
}

Object Object::fiberCopy() {
  if (m_px) {
    if (m_px->getCount() > 1) {
      ObjectData *px = (ObjectData*)FiberReferenceMap::Lookup(m_px);
      if (px == NULL) {
        px = m_px->clone();
        FiberReferenceMap::Insert(m_px, px);
      }
      return px;
    }
    return m_px->clone();
  }
  return Object();
}

///////////////////////////////////////////////////////////////////////////////
}
Exemplo n.º 22
0
EquivalenceScope::Object EquivalenceScope::GetObject(ASTContext &C, const Expr *E, VarDecl *Var, uint64_t Offset) {
  return Object(E, Offset, GetObject(C, Var));
}
Exemplo n.º 23
0
Object OpaqueObject::GetObject(int index) {
  if (index) {
    return Object(new OpaqueObject(index));
  }
  return Object();
}
Exemplo n.º 24
0
void Draw(void)													// Draw Our Scene
{
	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		// Clear Screen And Depth Buffer
	glLoadIdentity();											// Reset The Modelview Matrix

	glPushMatrix();												// Push The Modelview Matrix
	glBindTexture(GL_TEXTURE_2D, textures[7].texID);			// Select The Sky Texture
	glBegin(GL_QUADS);											// Begin Drawing Quads
		glTexCoord2f(1.0f,roll/1.5f+1.0f); glVertex3f( 28.0f,+7.0f,-50.0f);	// Top Right
		glTexCoord2f(0.0f,roll/1.5f+1.0f); glVertex3f(-28.0f,+7.0f,-50.0f);	// Top Left
		glTexCoord2f(0.0f,roll/1.5f+0.0f); glVertex3f(-28.0f,-3.0f,-50.0f);	// Bottom Left
		glTexCoord2f(1.0f,roll/1.5f+0.0f); glVertex3f( 28.0f,-3.0f,-50.0f);	// Bottom Right

		glTexCoord2f(1.5f,roll+1.0f); glVertex3f( 28.0f,+7.0f,-50.0f);		// Top Right
		glTexCoord2f(0.5f,roll+1.0f); glVertex3f(-28.0f,+7.0f,-50.0f);		// Top Left
		glTexCoord2f(0.5f,roll+0.0f); glVertex3f(-28.0f,-3.0f,-50.0f);		// Bottom Left
		glTexCoord2f(1.5f,roll+0.0f); glVertex3f( 28.0f,-3.0f,-50.0f);		// Bottom Right

		glTexCoord2f(1.0f,roll/1.5f+1.0f); glVertex3f( 28.0f,+7.0f,0.0f);	// Top Right
		glTexCoord2f(0.0f,roll/1.5f+1.0f); glVertex3f(-28.0f,+7.0f,0.0f);	// Top Left
		glTexCoord2f(0.0f,roll/1.5f+0.0f); glVertex3f(-28.0f,+7.0f,-50.0f);	// Bottom Left
		glTexCoord2f(1.0f,roll/1.5f+0.0f); glVertex3f( 28.0f,+7.0f,-50.0f);	// Bottom Right

		glTexCoord2f(1.5f,roll+1.0f); glVertex3f( 28.0f,+7.0f,0.0f);		// Top Right
		glTexCoord2f(0.5f,roll+1.0f); glVertex3f(-28.0f,+7.0f,0.0f);		// Top Left
		glTexCoord2f(0.5f,roll+0.0f); glVertex3f(-28.0f,+7.0f,-50.0f);		// Bottom Left
		glTexCoord2f(1.5f,roll+0.0f); glVertex3f( 28.0f,+7.0f,-50.0f);		// Bottom Right
	glEnd();													// Done Drawing Quads

	glBindTexture(GL_TEXTURE_2D, textures[6].texID);			// Select The Ground Texture
	glBegin(GL_QUADS);											// Draw A Quad
		glTexCoord2f(7.0f,4.0f-roll); glVertex3f( 27.0f,-3.0f,-50.0f);	// Top Right
		glTexCoord2f(0.0f,4.0f-roll); glVertex3f(-27.0f,-3.0f,-50.0f);	// Top Left
		glTexCoord2f(0.0f,0.0f-roll); glVertex3f(-27.0f,-3.0f,0.0f);	// Bottom Left
		glTexCoord2f(7.0f,0.0f-roll); glVertex3f( 27.0f,-3.0f,0.0f);	// Bottom Right
	glEnd();													// Done Drawing Quad

	DrawTargets();												// Draw Our Targets
	glPopMatrix();												// Pop The Modelview Matrix

	// Crosshair (In Ortho View)
	RECT window;												// Storage For Window Dimensions
	GetClientRect (g_window->hWnd,&window);						// Get Window Dimensions
	glMatrixMode(GL_PROJECTION);								// Select The Projection Matrix
	glPushMatrix();												// Store The Projection Matrix
	glLoadIdentity();											// Reset The Projection Matrix
	glOrtho(0,window.right,0,window.bottom,-1,1);				// Set Up An Ortho Screen
	glMatrixMode(GL_MODELVIEW);									// Select The Modelview Matrix
	glTranslated(mouse_x,window.bottom-mouse_y,0.0f);			// Move To The Current Mouse Position
	Object(16,16,8);											// Draw The Crosshair

	// Game Stats / Title
	glPrint(240,450,"NeHe Productions");						// Print Title
	glPrint(10,10,"Level: %i",level);							// Print Level
	glPrint(250,10,"Score: %i",score);							// Print Score

	if (miss>9)													// Have We Missed 10 Objects?
	{
		miss=9;													// Limit Misses To 10
		game=TRUE;												// Game Over TRUE
	}

	if (game)													// Is Game Over?
		glPrint(490,10,"GAME OVER");							// Game Over Message
	else
		glPrint(490,10,"Morale: %i/10",10-miss);				// Print Morale #/10

	glMatrixMode(GL_PROJECTION);								// Select The Projection Matrix
	glPopMatrix();												// Restore The Old Projection Matrix
	glMatrixMode(GL_MODELVIEW);									// Select The Modelview Matrix

	glFlush();													// Flush The GL Rendering Pipeline
}
Exemplo n.º 25
0
STKUNIT_UNIT_TEST(UnitTestTimer, UnitTest)
{
  stk_classic::diag::TimeBlock root_time_block(unitTestTimer());

  std::ostringstream strout;
  
  // Create subtimer and test lap time
  {
    static stk_classic::diag::Timer lap_timer("One second Wall time twice", unitTestTimer());
    
    stk_classic::diag::TimeBlock _time(lap_timer);
    double x = quick_work();
    x = x;
    std::ostringstream oss;
    oss << x << std::endl;
    
    ::sleep(1);

    lap_timer.lap();
    
    stk_classic::diag::MetricTraits<stk_classic::diag::WallTime>::Type lap_time = lap_timer.getMetric<stk_classic::diag::WallTime>().getLap();
  
    STKUNIT_ASSERT(lap_time >= 1.0);

    ::sleep(1);

    lap_timer.stop();
    
    lap_time = lap_timer.getMetric<stk_classic::diag::WallTime>().getLap();
  
    STKUNIT_ASSERT(lap_time >= 2.0);
  }

  // 
  {
    static stk_classic::diag::Timer run_timer("Run 100 times twice", unitTestTimer());
    
    for (int i = 0; i < 100; ++i) {
      stk_classic::diag::TimeBlock _time(run_timer);
      work();
    }

    stk_classic::diag::MetricTraits<stk_classic::diag::LapCount>::Type lap_count = run_timer.getMetric<stk_classic::diag::LapCount>().getAccumulatedLap(false);
  
    STKUNIT_ASSERT(lap_count == 100);
  }

  // Create second timer set
  {
    static stk_classic::diag::Timer second_timer("Second timer set", unitTestTimer(), unitTestSecondTimerSet());
    static stk_classic::diag::Timer second_timer_on_default("On default", second_timer);
    static stk_classic::diag::Timer second_timer_on("On", TIMER_APP_3, second_timer);
    static stk_classic::diag::Timer second_timer_off("Off", TIMER_APP_1, second_timer);
    
    stk_classic::diag::TimeBlock _time(second_timer);
    stk_classic::diag::TimeBlock _time1(second_timer_on_default);
    stk_classic::diag::TimeBlock _time2(second_timer_on);
    stk_classic::diag::TimeBlock _time3(second_timer_off);

    ::sleep(1);
  }

  // Grab previous subtimer and run 100 laps
  {
    static stk_classic::diag::Timer run_timer("Run 100 times twice", unitTestTimer());
    
    for (int i = 0; i < 100; ++i) {
      stk_classic::diag::TimeBlock _time(run_timer);
      work();
    }

    stk_classic::diag::MetricTraits<stk_classic::diag::LapCount>::Type lap_count = run_timer.getMetric<stk_classic::diag::LapCount>().getAccumulatedLap(false);
  
    STKUNIT_ASSERT(lap_count == 200);
  }

  // Create root object
  RootObject root_object;
    
  {
    stk_classic::diag::MetricTraits<stk_classic::diag::LapCount>::Type lap_count = root_object.m_timer.getMetric<stk_classic::diag::LapCount>().getAccumulatedLap(false);
  
    STKUNIT_ASSERT(lap_count == 0);
  }

  // Create object
  {
    Object time_object("One object", root_object);
    
    for (int i = 0; i < 100; ++i) {
      time_object.run();
    }

    stk_classic::diag::MetricTraits<stk_classic::diag::LapCount>::Type lap_count = time_object.m_timer.getMetric<stk_classic::diag::LapCount>().getAccumulatedLap(false);
  
    STKUNIT_ASSERT(lap_count == 100);
  }

  // Create object tree
  {
    std::vector<Object> object_vector;
    object_vector.push_back(Object("Object Tree", root_object));

    int id = 0;
    for (size_t i = 0; i < 2; ++i) {
      size_t ix = object_vector.size();
      object_vector.push_back(Object(id++, object_vector[0]));
      for (size_t j = 0; j < 2; ++j) {
        size_t jx = object_vector.size();
        object_vector.push_back(Object(id++, object_vector[ix]));
        for (int k = 0; k < 2; ++k) {    
          object_vector.push_back(Object(id++, object_vector[jx]));
        }
      }
    }
    
    stk_classic::diag::printTimersTable(strout, unitTestTimer(), stk_classic::diag::METRICS_ALL, false);
    
    stk_classic::diag::MetricTraits<stk_classic::diag::LapCount>::Type lap_count = 0;
    for (size_t j = 0; j < object_vector.size(); ++j) 
      lap_count += object_vector[j].m_timer.getMetric<stk_classic::diag::LapCount>().getAccumulatedLap(false);

    STKUNIT_ASSERT_EQUAL(lap_count, stk_classic::diag::MetricTraits<stk_classic::diag::LapCount>::Type(0));

    for (size_t j = 0; j < object_vector.size(); ++j) 
      object_vector[j].run();

    stk_classic::diag::printTimersTable(strout, unitTestTimer(), stk_classic::diag::METRICS_ALL, false);    

    lap_count = 0;
    for (size_t j = 0; j < object_vector.size(); ++j) 
      lap_count += object_vector[j].m_timer.getMetric<stk_classic::diag::LapCount>().getAccumulatedLap(false);

    STKUNIT_ASSERT_EQUAL(lap_count, stk_classic::diag::MetricTraits<stk_classic::diag::LapCount>::Type(object_vector.size()));

    for (size_t i = 1; i < 100; ++i) 
      for (size_t j = 0; j < object_vector.size(); ++j) 
        object_vector[j].run();

    stk_classic::diag::printTimersTable(strout, unitTestTimer(), stk_classic::diag::METRICS_ALL, false);    

    lap_count = 0;
    for (size_t j = 0; j < object_vector.size(); ++j) 
      lap_count += object_vector[j].m_timer.getMetric<stk_classic::diag::LapCount>().getAccumulatedLap(false);
  
    STKUNIT_ASSERT_EQUAL(lap_count, stk_classic::diag::MetricTraits<stk_classic::diag::LapCount>::Type(100*object_vector.size()));

    stk_classic::diag::printTimersTable(strout, unitTestTimer(), stk_classic::diag::METRICS_ALL, true);

    for (size_t i = 1; i < 100; ++i) 
      for (size_t j = 0; j < object_vector.size(); ++j) 
        object_vector[j].run();

    stk_classic::diag::printTimersTable(strout, unitTestTimer(), stk_classic::diag::METRICS_ALL, true);

    std::cout << strout.str() << std::endl;
    
//    dw().m(LOG_TIMER) << strout.str() << stk_classic::diag::dendl;
  }
}
Object Parser::parse_configspec(Scanner & scanner, bool merge)
{
    Section section;
    this->parse_configspec(scanner, section, merge);
    return Object(section);
}
Exemplo n.º 27
0
ContainSphere Scene::carregaObjecte(std::string obj) {
    objects.push_back(Object(obj));
    return calculateSphere();
}
Exemplo n.º 28
0
Object f_hphp_recursiveiteratoriterator_getinneriterator(CObjRef obj) {
  RecursiveIteratorIterator *rii = get_recursiveiteratoriterator(obj);
  unsigned int size = rii->m_iterators.size();
  ASSERT(size > 0);
  return size == 1 ? Object() : rii->m_iterators[size-1].first;
}
Exemplo n.º 29
0
namespace HPHP {

const Object Object::s_nullObject = Object();

///////////////////////////////////////////////////////////////////////////////

ArrayIterPtr Object::begin(CStrRef context /* = null_string */,
                           bool setIterDirty /* = false */) const {
  if (!m_px) throw NullPointerException();
  return m_px->begin(context);
}

MutableArrayIterPtr Object::begin(Variant *key, Variant &val,
                                  CStrRef context /* = null_string */,
                                  bool setIterDirty /* = false */) const {
  if (!m_px) throw NullPointerException();
  return m_px->begin(key, val, context);
}

Array Object::toArray() const {
  return m_px ? m_px->o_toArray(false) : Array();
}

Variant Object::toKey() const {
  return m_px ? (isResource() ? m_px->o_toInt64() : m_px->t___tostring())
    : String();
}

bool Object::equal(CObjRef v2) const {
  if (m_px == v2.get()) {
    return true;
  }
  if (!m_px || !v2.get()) {
    return false;
  }
  if (isResource() || v2.isResource()) {
    return false;
  }
  return (v2.get()->o_isClass(m_px->o_getClassName()) &&
          toArray().equal(v2.toArray()));
}

bool Object::less(CObjRef v2) const {
  return m_px != v2.m_px && toArray().less(v2.toArray());
}

bool Object::more(CObjRef v2) const {
  return m_px != v2.m_px && toArray().more(v2.toArray());
}

Variant Object::o_get(CStrRef propName, bool error /* = true */,
                      CStrRef context /* = null_string */) const {
  if (!m_px) throw NullPointerException();
  return m_px->o_get(propName, error, context);
}

Variant Object::o_getPublic(CStrRef propName, bool error /* = true */) const {
  if (!m_px) throw NullPointerException();
  return m_px->o_getPublic(propName, error);
}

Variant Object::o_set(CStrRef propName, CVarRef val,
                      CStrRef context /* = null_string */) {
  if (!m_px) {
    operator=(NEW(c_stdClass)());
  }
  return m_px->o_set(propName, val, false, context);
}

Variant Object::o_setPublic(CStrRef propName, CVarRef val) {
  if (!m_px) {
    operator=(NEW(c_stdClass)());
  }
  return m_px->o_setPublic(propName, val, false);
}

Variant &Object::o_lval(CStrRef propName, CVarRef tmpForGet,
                        CStrRef context /* = null_string */) {
  if (!m_px) {
    operator=(NEW(c_stdClass)());
  }
  return m_px->o_lval(propName, tmpForGet, context);
}

Variant &Object::o_unsetLval(CStrRef propName, CVarRef tmpForGet,
                             CStrRef context /* = null_string */) {
  if (!m_px) {
    return const_cast<Variant&>(tmpForGet);
  }
  return m_px->o_lval(propName, tmpForGet, context);
}

bool Object::o_isset(CStrRef propName,
                     CStrRef context /* = null_string */) const {
  if (!m_px) return false;
  return m_px->o_isset(propName, context);
}

bool Object::o_empty(CStrRef propName,
                     CStrRef context /* = null_string */) const {
  if (!m_px) return true;
  return m_px->o_empty(propName, context);
}

void Object::o_unset(CStrRef propName,
                     CStrRef context /* = null_string */) const {
  if (m_px) m_px->o_unset(propName, context);
}

Variant Object::o_argval(bool byRef, CStrRef propName,
    bool error /* = true */, CStrRef context /* = null_string */) {
  if (!byRef) {
    return o_get(propName, error, context);
  } else {
    return ref(o_lval(propName, context));
  }
}

///////////////////////////////////////////////////////////////////////////////
// output

void Object::serialize(VariableSerializer *serializer) const {
  if (m_px) {
    m_px->serialize(serializer);
  } else {
    serializer->writeNull();
  }
}

bool Object::unserialize(std::istream &in) {
  throw NotImplementedException(__func__);
}

Object Object::fiberMarshal(FiberReferenceMap &refMap) const {
  if (m_px) {
    return m_px->fiberMarshal(refMap);
  }
  return Object();
}

Object Object::fiberUnmarshal(FiberReferenceMap &refMap) const {
  if (m_px) {
    return m_px->fiberUnmarshal(refMap);
  }
  return Object();
}

///////////////////////////////////////////////////////////////////////////////
}
 Object Sequence::getItem(int index) const
 {
     return Object(NewReference(PySequence_GetItem(mPtr, index)));
 }