本文整理汇总了C++中Object函数的典型用法代码示例。如果您正苦于以下问题:C++ Object函数的具体用法?C++ Object怎么用?C++ Object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Object函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_object_only
Object create_object_only(CStrRef s, ObjectData *root) {
return Object();
}
示例2: Object
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);
}
//.........这里部分代码省略.........
示例3: Object
Object Object::fiberUnmarshal(FiberReferenceMap &refMap) const {
if (m_px) {
return m_px->fiberUnmarshal(refMap);
}
return Object();
}
示例4: LOG_DEBUG
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++;
}
}
}
}
示例5: invokeImpl
//.........这里部分代码省略.........
// 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;
}
示例6: Object
Object c_WaitableWaitHandle::t_getcreator() {
return Object();
}
示例7: Object
Object ResourceData::fiberUnmarshal(FiberReferenceMap &refMap) const {
return Object();
}
示例8: createBacktrace
//.........这里部分代码省略.........
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++) {
示例9: return
List::Proxy::operator py::Object () const
{
return (Object(::fetch(myList->handle(), myIndex)));
}
示例10: TEST
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);
}
}
示例11: Node
Node(const Object& d = Object(),Node *p = NULL,Node *q=NULL):data(d),prev(p),next(q){}
示例12: DoStartSzen
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 );
//.........这里部分代码省略.........
示例13: Object
//Object
Object::Object() {
Object(0, 0, 0, 0, 0, 0, 0, -1);
}
示例14: event_http_request_cb
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()));
}
示例15: Object
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);
}
//.........这里部分代码省略.........