TITANIUM_FUNCTION(ListView, replaceSectionAt)
		{
			const auto js_context = this_object.get_context();
			if (arguments.size() >= 2) {
				JSObject animation = js_context.CreateObject();
				std::vector<std::shared_ptr<ListSection>> sections;

				const auto _0 = arguments.at(0);
				TITANIUM_ASSERT(_0.IsNumber());
				const auto sectionIndex = static_cast<uint32_t>(_0);

				const auto _1 = arguments.at(1);
				TITANIUM_ASSERT(_1.IsObject());
				const auto js_sections = static_cast<JSObject>(_1);

				if (js_sections.IsArray()) {
					sections = static_cast<JSArray>(js_sections).GetPrivateItems<ListSection>();
				} else {
					sections.push_back(js_sections.GetPrivate<ListSection>());
				}

				if (arguments.size() >= 3) {
					const auto _2 = arguments.at(2);
					if (_2.IsObject()) {
						animation = listviewAnimationProperties_ctor__.CallAsConstructor({_2});
					}
				}

				replaceSectionAt(sectionIndex, sections, animation.GetPrivate<ListViewAnimationProperties>());
			}
			return this_object.get_context().CreateUndefined();
		}
コード例 #2
0
ファイル: FolderLib.cpp プロジェクト: OLR-xray/OLR-3.0
void CFolderHelper::DragOver(TObject *Sender, TObject *Source, int X, int Y, TDragState State, bool &Accept)
{
	TElTree* tv = dynamic_cast<TElTree*>(Sender); VERIFY(Sender);
	TElTreeItem* tgt;

    for (ELVecIt it=drag_items.begin(); it!=drag_items.end(); it++){
        TElTreeItem* src=*it;
        TSTItemPart IP;
        int HCol;
        if (!src) Accept = false;
        else{
            tgt = tv->GetItemAt(X, Y, IP, HCol);
            if (tgt){
                if (IsFolder(src)){
                    bool b = true;
                    for (TElTreeItem* itm=tgt->Parent; itm; itm=itm->Parent) if (itm==src){b=false; break;}
                    if (IsFolder(tgt)){
                        Accept = b&&(tgt!=src)&&(src->Parent!=tgt);
                    }else if (IsObject(tgt)){
                        Accept = b&&(src!=tgt->Parent)&&(tgt!=src)&&(tgt->Parent!=src->Parent);
                    }
                }else if (IsObject(src)){
                    if (IsFolder(tgt)){
                        Accept = (tgt!=src)&&(src->Parent!=tgt);
                    }else if (IsObject(tgt)){
                        Accept = (tgt!=src)&&(src->Parent!=tgt->Parent);
                    }
                }
            }else Accept = !!src->Parent;
        }
        if (false==Accept) return;
    }
}
コード例 #3
0
		void TableViewRow::ensureRowLabel() 
		{
			if (title__ == nullptr) {
				const auto Titanium_property = get_context().get_global_object().GetProperty("Titanium");
				TITANIUM_ASSERT(Titanium_property.IsObject());
				const auto Titanium = static_cast<JSObject>(Titanium_property);

				const auto UI_property = Titanium.GetProperty("UI");
				TITANIUM_ASSERT(UI_property.IsObject());
				const auto UI = static_cast<JSObject>(UI_property);

				const auto Label_property = UI.GetProperty("Label");
				TITANIUM_ASSERT(Label_property.IsObject());
				auto Label = static_cast<JSObject>(Label_property);

				const auto label = Label.CallAsConstructor();
				title__ = label.GetPrivate<TitaniumWindows::UI::Label>();
				title__->set_text("");
				title__->getViewLayoutDelegate()->set_left("0");

				EnsureRowComponentWidth(title__->getViewLayoutDelegate<WindowsViewLayoutDelegate>()->getComponent());

				add(label);
			}
		}
コード例 #4
0
		TITANIUM_FUNCTION(TableView, insertSectionBefore)
		{
			TITANIUM_LOG_WARN("TableView.insertSectionBefore is not implemented yet");
			if (arguments.size() < 3) {
				return get_context().CreateUndefined();
			} else if (arguments.size() >= 3) {
				const auto _0 = arguments.at(0);
				TITANIUM_ASSERT(_0.IsNumber());
				const auto _1 = arguments.at(1);
				TITANIUM_ASSERT(_1.IsObject());
				const auto _2 = arguments.at(2);
				//TITANIUM_ASSERT(_2.IsTableViewAnimationProperties());
				const double index = static_cast<double>(_0);
				const auto section = static_cast<JSObject>(_1);
				const auto animation = static_cast<JSObject>(_2);
				// insertSectionBefore(index, section, animation);
			} else if (arguments.size() >= 2) {
				const auto _0 = arguments.at(0);
				TITANIUM_ASSERT(_0.IsNumber());
				const auto _1 = arguments.at(1);
				TITANIUM_ASSERT(_1.IsObject());
				const double index = static_cast<double>(_0);
				const auto section = static_cast<JSObject>(_1);
				// insertSectionBefore(index, section);
			} else if (arguments.size() >= 1) {
				const auto _0 = arguments.at(0);
				TITANIUM_ASSERT(_0.IsNumber());
				const double index = static_cast<double>(_0);
				// insertSectionBefore(index);
			}
			return get_context().CreateUndefined();
		}
		TITANIUM_FUNCTION(DependencyObject, SetValue)
		{
			auto context = get_context();
			if (arguments.size() == 2) {
				auto _0 = arguments.at(0);
			TITANIUM_ASSERT_AND_THROW(_0.IsObject(), "Expected Object");
			auto object_dp = static_cast<JSObject>(_0);
 
			auto wrapper_dp = object_dp.GetPrivate<Windows::UI::Xaml::DependencyProperty>();
			// FIXME What if the type we want here is some parent class of the actual wrapper's class? I think we'll get nullptr here.
			// We need some way to know the underlying type the JSObject maps to, get that, then cast to the type we want...
			auto dp = wrapper_dp->unwrapWindows_UI_Xaml_DependencyProperty();

				auto _1 = arguments.at(1);
			TITANIUM_ASSERT_AND_THROW(_1.IsObject(), "Expected Object");
			auto object_value = static_cast<JSObject>(_1);
 
			auto wrapper_value = object_value.GetPrivate<Platform::Object>();
			// FIXME What if the type we want here is some parent class of the actual wrapper's class? I think we'll get nullptr here.
			// We need some way to know the underlying type the JSObject maps to, get that, then cast to the type we want...
			auto value = wrapper_value->unwrapPlatform_Object();

				unwrap()->SetValue(dp, value);
				return context.CreateUndefined(); 
			}

			// Catch-all if no arg count matches!
			TITANIUM_LOG_DEBUG("No method signature matched DependencyObject::SetValue with # of args: ", arguments.size());
			return context.CreateUndefined(); 
		}
コード例 #6
0
		TITANIUM_FUNCTION(ListSection, replaceItemsAt)
		{
			const auto js_context = this_object.get_context();
			if (arguments.size() >= 3) {
				const auto _0 = arguments.at(0);
				TITANIUM_ASSERT(_0.IsNumber());
				const auto _1 = arguments.at(1);
				TITANIUM_ASSERT(_1.IsNumber());
				const auto _2 = arguments.at(2);
				TITANIUM_ASSERT(_2.IsObject());

				JSObject animation = js_context.CreateObject();
				const auto index = static_cast<std::uint32_t>(_0);
				const auto count = static_cast<std::uint32_t>(_1);
				const auto dataItems = js_to_ListDataItem_array(static_cast<JSObject>(_2));

				if (arguments.size() >= 4) {
					const auto _3 = arguments.at(3);
					if (_3.IsObject()) {
						animation = listviewAnimationProperties_ctor__.CallAsConstructor({ _3 });
					}
				}

				replaceItemsAt(index, count, dataItems, animation.GetPrivate<ListViewAnimationProperties>());
			}
			return get_context().CreateUndefined();
		}
コード例 #7
0
		TITANIUM_FUNCTION(View, animateCamera)
		{
			if (arguments.size() > 1) {
				auto _0 = arguments.at(0);
				auto _1 = arguments.at(1);
				TITANIUM_ASSERT(_0.IsObject());
				TITANIUM_ASSERT(_1.IsObject());
				auto callback = static_cast<JSObject>(_1);
				animateCamera(js_to_CameraAnimationParams(static_cast<JSObject>(_0)), callback);
			}
			return get_context().CreateUndefined();
		}
コード例 #8
0
HandleProxy* V8EngineProxy::Call(HandleProxy *subject, const uint16_t *functionName, HandleProxy *_this, uint16_t argCount, HandleProxy** args)
{
	if (_this == nullptr) _this = subject; // (assume the subject is also "this" if not given)

	auto hThis = _this->Handle();
	if (hThis.IsEmpty() || !hThis->IsObject())
		throw exception("Call: The target instance handle ('this') does not represent an object.");

	auto hSubject = subject->Handle();
	Handle<Function> hFunc;

	if (functionName != nullptr) // (if no name is given, assume the subject IS a function object, otherwise get the property as a function)
	{
		if (hSubject.IsEmpty() || !hSubject->IsObject())
			throw exception("Call: The subject handle does not represent an object.");

		auto hProp = hSubject.As<Object>()->Get(NewUString(functionName));

		if (hProp.IsEmpty() || !hProp->IsFunction())
			throw exception("Call: The specified property does not represent a function.");

		hFunc = hProp.As<Function>();
	}
	else if (hSubject.IsEmpty() || !hSubject->IsFunction())
		throw exception("Call: The subject handle does not represent a function.");
	else
		hFunc = hSubject.As<Function>();

	TryCatch __tryCatch;

	Handle<Value> result;

	if (argCount > 0)
	{
		Handle<Value>* _args = new Handle<Value>[argCount];
		for (auto i = 0; i < argCount; i++)
			_args[i] = args[i]->Handle();
		result = hFunc->Call(hThis.As<Object>(), argCount, _args);
		delete[] _args;
	}
	else result = hFunc->Call(hThis.As<Object>(), 0, nullptr);

	HandleProxy *returnVal;

	if (__tryCatch.HasCaught())
	{
		returnVal = GetHandleProxy(GetErrorMessage(__tryCatch));
		returnVal->_Type = JSV_ExecutionError;
	}
	else returnVal = result.IsEmpty() ? nullptr : GetHandleProxy(result);

	return returnVal;
}
コード例 #9
0
ファイル: FolderLib.cpp プロジェクト: OLR-xray/OLR-3.0
BOOL CFolderHelper::RemoveItem(TElTree* tv, TElTreeItem* pNode, TOnItemRemove OnRemoveItem, TOnItemAfterRemove OnAfterRemoveItem)
{
	bool bRes = false;
    R_ASSERT(OnRemoveItem);
    if (pNode){
		tv->IsUpdating = true;
	    TElTreeItem* pSelNode = pNode->GetPrevSibling();
	    if (!pSelNode) pSelNode = pNode->GetNextSibling();
		AnsiString full_name;
    	if (IsFolder(pNode)){
//			if (mrYes==MessageDlg("Delete selected folder?", mtConfirmation, TMsgDlgButtons() << mbYes << mbNo, 0))
            {
                bRes = true;
		        for (TElTreeItem* item=pNode->GetFirstChild(); item&&(item->Level>pNode->Level); item=item->GetNext()){
                    MakeName(item,0,full_name,false);
                	if (IsObject(item)){
                    	bool res		= true;
                    	OnRemoveItem(full_name.c_str(),TYPE_OBJECT,res);
                    	if (!res) bRes	= FALSE;
                    }
                }
                if (bRes){
                    MakeName(pNode,0,full_name,true);
                    bool res			= true;
                	OnRemoveItem(full_name.c_str(),TYPE_FOLDER,res);
                	pNode->Delete();
                    if (!OnAfterRemoveItem.empty()) OnAfterRemoveItem();
                }
        	}
        }
    	if (IsObject(pNode)){
//			if (mrYes==MessageDlg("Delete selected item?", mtConfirmation, TMsgDlgButtons() << mbYes << mbNo, 0))
            {
				MakeName	(pNode,0,full_name,false);
                OnRemoveItem(full_name.c_str(),TYPE_OBJECT,bRes);
	            if (bRes){
                	pNode->Delete();
                    if (!OnAfterRemoveItem.empty()) OnAfterRemoveItem();
                }
        	}
        }
        if (bRes) tv->Selected = pSelNode;
        tv->IsUpdating 	= false;
        tv->SetFocus();
    }else{
		Msg				("#At first select item.");
    }
    return bRes;
}
		TITANIUM_FUNCTION(CoreDispatcher, RunIdleAsync)
		{
			auto context = get_context();
			if (arguments.size() == 1) {
				auto _0 = arguments.at(0);
			TITANIUM_ASSERT_AND_THROW(_0.IsObject(), "Expected Object");
			auto object_agileCallback = static_cast<JSObject>(_0);
 
			auto wrapper_agileCallback = object_agileCallback.GetPrivate<Windows::UI::Core::IdleDispatchedHandler>();
			// FIXME What if the type we want here is some parent class of the actual wrapper's class? I think we'll get nullptr here.
			// We need some way to know the underlying type the JSObject maps to, get that, then cast to the type we want...
			auto agileCallback = wrapper_agileCallback->unwrapWindows_UI_Core_IdleDispatchedHandler();

				auto method_result = unwrap()->RunIdleAsync(agileCallback);

			auto result = context.CreateObject(JSExport<Windows::Foundation::IAsyncAction>::Class());
			auto result_wrapper = result.GetPrivate<Windows::Foundation::IAsyncAction>();
			result_wrapper->wrap(method_result);

				return result;
			}

			// Catch-all if no arg count matches!
			TITANIUM_LOG_DEBUG("No method signature matched CoreDispatcher::RunIdleAsync with # of args: ", arguments.size());
			return context.CreateUndefined(); 
		}
コード例 #11
0
ファイル: JSONValue.cpp プロジェクト: Boshin/Urho3D
JSONValue JSONValue::CreateChild(const String& name, JSONValueType valueType)
{
    assert(IsObject());
    if (!IsObject())
        return JSONValue::EMPTY;

    Value jsonValue;
    if (valueType == JSON_OBJECT)
        jsonValue.SetObject();
    else if (valueType == JSON_ARRAY)
        jsonValue.SetArray();

    AddMember(name, jsonValue);

    return GetChild(name, valueType);
}
コード例 #12
0
ファイル: value.hpp プロジェクト: LMNetworks/icinga2
	bool IsObjectType(void) const
	{
		if (!IsObject())
			return false;

		return (dynamic_cast<T *>(boost::get<Object::Ptr>(m_Value).get()) != NULL);
	}
コード例 #13
0
ファイル: listingfetch.cpp プロジェクト: friman/ipdvr
std::shared_ptr<rapidjson::Document> ListingFetch::fetch(std::string singleUrl)
{
    std::unique_ptr<FetchJob_Curl> pFetcher(new FetchJob_Curl(singleUrl));

    bool res = pFetcher->run();

    if (res == false)
    {
        DEBUG_PRINT("Fetch failed from URL: " << singleUrl << std::endl);
        return nullptr;
    }
    else
    {
        DEBUG_PRINT("Read " << pFetcher->getSize() << " bytes from URL: " << singleUrl << std::endl);
    }

    auto spJsonDoc = std::make_shared<rapidjson::Document>();
    spJsonDoc->Parse(pFetcher->getData());

    if (spJsonDoc->IsObject() && spJsonDoc->HasMember("jsontv"))
    {
        DEBUG_PRINT("Parsed a valid JSONTV document." << std::endl);
        return spJsonDoc;
    }
    else
    {
        DEBUG_PRINT("JSON parse failed!" << std::endl);
        return nullptr;
    }
}
コード例 #14
0
ファイル: freeze.hpp プロジェクト: charlesw1234/learning
 template<typename VALUE_T>uint32_t
 Document_t<VALUE_T>::Locate(uint32_t pos, const char *path) const
 {
     char *cur, *next, *_path = strdup(path);
     for (cur = _path; cur != NULL; cur = next) {
         if ((next = strchr(cur, '.')) != NULL) *next++ = 0;
         if (strlen(cur) == strspn(cur, "0123456789")) {
             if (!IsArray(pos)) {
                 pos = UINT32_MAX; goto quit0;
             }
             uint32_t idx = atol(cur);
             if (idx >= GetArraySpace(pos)) {
                 pos = UINT32_MAX; goto quit0;
             }
             pos = GetArray(pos, idx);
         } else {
             if (!IsObject(pos)) {
                 pos = UINT32_MAX; goto quit0;
             }
             if ((pos = ObjectSearch(pos, cur)) == UINT32_MAX) {
                 pos = UINT32_MAX; goto quit0;
             }
         }
     }
 quit0:
     free(_path);
     return pos;
 }
コード例 #15
0
AnimationMaster AnimationMaster::Unserialize(Renderer* renderer,
		rapidjson::Value* value) {

	PASSERT( value->IsObject(), "AnimationMaster cannot unserialize because passed is not an object (Note: This may indicate parsing failure)");
	PASSERT(value->FindMember("animations")->value.IsArray(), "AnimationMaster cannot unserialize because animations field is not an array");
	PASSERT(value->FindMember("default")->value.IsString(), "AnimationMaster default should be string");

	std::map<PBase::String, AnimationSetEntry> anims;

	rapidjson::Value* animations = &value->FindMember("animations")->value;

	for (auto it = animations->Begin(); it != animations->End(); it++) {
		PASSERT(it->IsObject(), "AnimationMaster animation entry should be an object");
		PASSERT(it->FindMember("name")->value.IsString(), "AnimationMaster animation entry name should be string");
		PASSERT(it->FindMember("animation_file")->value.IsString(), "AnimationMaster animation file path should be string");

		String after;

		if (it->HasMember("after")) {
			PASSERT(it->FindMember("after")->value.IsString(), "after should be a string animation identifier");
			after = it->FindMember("after")->value.GetString();
		}

		anims[it->FindMember("name")->value.GetString()] = AnimationSetEntry(
			renderer->LoadAnimationSet(it->FindMember("animation_file")->value.GetString()),
			after);
	}

	return AnimationMaster(value->FindMember("default")->value.GetString(), anims);
}
コード例 #16
0
ファイル: OVR_JSON.cpp プロジェクト: beijingkaka/shellspace
const JSON * JsonReader::GetChildByName( const char * childName ) const
{
	assert( IsObject() );

	// Check if the the cached child pointer is valid.
	if ( !Parent->Children.IsNull( Child ) )
	{
		if ( OVR_strcmp( Child->Name, childName ) == 0 )
		{
			const JSON * c = Child;
			Child = c->pNext;	// Cache the next child.
			return c;
		}
	}
	// Itereate over all children.
    for ( const JSON * c = Parent->Children.GetFirst(); !Parent->Children.IsNull( c ); c = c->pNext )
	{
		if ( OVR_strcmp( c->Name, childName ) == 0 )
		{
			Child = c->pNext;	// Cache the next child.
			return c;
		}
	}
	return 0;
}
コード例 #17
0
ファイル: JSON_Model.cpp プロジェクト: ggggamer/silkopter
Qt::ItemFlags JSON_Model::flags(QModelIndex const& index) const
{
//    std::lock_guard<std::recursive_mutex> sm(mTreeMutex);


    if (!index.isValid())
    {
        return 0;
    }

    uint32_t default_flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;

    auto* ti = (Tree_Item*)index.internalPointer();
    if (!ti || !ti->m_json)
    {
        return Qt::ItemFlags(default_flags);
    }

    auto json = ti->m_json;
    if (json->IsObject() || json->IsArray())
    {
        return Qt::ItemFlags(default_flags);
    }

    return Qt::ItemFlags((index.column() == 0) ? default_flags : default_flags | Qt::ItemIsEditable);
}
		TITANIUM_FUNCTION(ListView, scrollToItem)
		{
			const auto js_context = this_object.get_context();
			if (arguments.size() >= 2) {
				JSObject animation = js_context.CreateObject();

				const auto _0 = arguments.at(0);
				TITANIUM_ASSERT(_0.IsNumber());
				const auto _1 = arguments.at(1);
				TITANIUM_ASSERT(_1.IsNumber());

				const auto sectionIndex = static_cast<uint32_t>(_0);
				const auto itemIndex    = static_cast<uint32_t>(_1);

				if (arguments.size() >= 3) {
					const auto _3 = arguments.at(2);
					if (_3.IsObject()) {
						animation = listviewAnimationProperties_ctor__.CallAsConstructor({_3});
					}
				}

				scrollToItem(sectionIndex, itemIndex, animation.GetPrivate<ListViewAnimationProperties>());
			}

			return this_object.get_context().CreateUndefined();
		}
コード例 #19
0
		TITANIUM_FUNCTION(File, write)
		{
			const auto js_context = this_object.get_context();

			if (arguments.size() < 1) {
				return js_context.CreateUndefined();
			}

			const auto _0 = arguments.at(0);

			const auto _1 = arguments.size() < 2 ? js_context.CreateBoolean(false) : arguments.at(1);
			TITANIUM_ASSERT(_1.IsBoolean());
			const auto append = static_cast<bool>(_1);

			if (_0.IsString()) {
				return js_context.CreateBoolean(write(static_cast<std::string>(arguments.at(0)), append));
			} else if (_0.IsObject()) {
				const auto js_object = static_cast<JSObject>(_0);
				const auto blob = js_object.GetPrivate<Titanium::Blob>();
				const auto file = js_object.GetPrivate<File>();
				if (blob != nullptr) {
					return js_context.CreateBoolean(write(blob, append));
				} else if (file != nullptr) {
					return js_context.CreateBoolean(write(file, append));
				}
			}
			return js_context.CreateNull();
		}
コード例 #20
0
ファイル: ScriptEntity.cpp プロジェクト: zuzak/Magnetite
		void ScriptEntity::think( float dt )
		{
			MagnetiteCore::Singleton->runOnMainThread( [&,dt]() { 
				// Perhaps a better (thread safe) mechanism for handling callbacks could be devised.
				PersistentContext ctx = MagnetiteCore::Singleton->getScriptManager()->getContext();
				Context::Scope scope( ctx );
				HandleScope hs;
				// Get the object prototype, which contains the script-side create.
				auto proto = mScriptObject->GetPrototype();
				if( proto->IsObject() )
				{
					auto protobj = proto.As<Object>();
					if( protobj->Has( v8::String::New("think") ) ) {
						auto createVal = protobj->Get( v8::String::New("think") );
						if( createVal->IsFunction() )
						{
							auto createFunc = createVal.As<Function>();
							ValueHandle args[] = { Number::New(dt) };
							createFunc->Call( mScriptObject, 1, args );
						}
					}
				}
			});
			
			BaseEntity::think(dt);
		}
コード例 #21
0
	TITANIUM_FUNCTION(Utils, base64encode)
	{
		if (arguments.size() >= 1) {
			const auto _0 = arguments.at(0);

			// Titanium.Blob / Titanium.Filesystem.File
			if (_0.IsObject()) {
				const auto js_obj = static_cast<JSObject>(_0);

				// Titanium.Blob
				const auto blob_obj = js_obj.GetPrivate<Blob>();
				if (blob_obj != nullptr) {
					return static_cast<JSValue>(base64encode(blob_obj)->get_object());
				}

				// Titanium.Filesystem.File
				const auto file_obj = js_obj.GetPrivate<Filesystem::File>();
				if (file_obj != nullptr) {
					return static_cast<JSValue>(base64encode(file_obj)->get_object());
				}

			// String
			} else if (_0.IsString()) {
				auto obj = static_cast<std::string>(_0);
				return static_cast<JSValue>(base64encode(obj)->get_object());
			}
		}
		return get_context().CreateUndefined();
	}
コード例 #22
0
ファイル: jsonlite.cpp プロジェクト: ospace/jsonlite_cpp
size_t Json::size() const {
    if (IsNull()) return 0;
    if (IsObject()) return object().size();
    if (IsArray()) return array().size();
    if (IsString()) return string().size();
    return 1;
}
コード例 #23
0
ファイル: as_datatype.cpp プロジェクト: VelocityRa/openspades
bool asCDataType::CanBeInstantiated() const
{
    if( GetSizeOnStackDWords() == 0 ) // Void
        return false;

    if( !IsObject() && !IsFuncdef() ) // Primitives
        return true;

    if (IsNullHandle()) // null
        return false;

    if( IsObjectHandle() && !(typeInfo->flags & asOBJ_NOHANDLE) ) // Handles
        return true;

    // Funcdefs cannot be instantiated without being handles
    // The exception being delegates, but these can only be created as temporary objects
    if (IsFuncdef())
        return false;

    asCObjectType *ot = typeInfo->CastToObjectType();
    if( ot && (ot->flags & asOBJ_REF) && ot->beh.factories.GetLength() == 0 ) // ref types without factories
        return false;

    if( ot && (ot->flags & asOBJ_ABSTRACT) && !IsObjectHandle() ) // Can't instantiate abstract classes
        return false;

    return true;
}
コード例 #24
0
bool System::Parse(rapidjson::Value& node) {
    if(node.IsArray()) {
        for(auto sound_itr = node.Begin(); sound_itr != node.End(); sound_itr ++) {
            if(sound_itr->IsObject()) {
                auto& element = (*sound_itr);

                std::shared_ptr<sound_info> sinfo = std::shared_ptr<sound_info>(new sound_info());

                if(element.HasMember("id") && element["id"].IsString()) {
                    sinfo->id = element["id"].GetString();
                }
                if(element.HasMember("src") && element["src"].IsString()) {
                    sinfo->src = element["src"].GetString();
                }
                if(element.HasMember("loop") && element["loop"].IsBool()) {
                    sinfo->loop = element["loop"].GetBool();
                }
                if(element.HasMember("volume") && element["volume"].IsNumber()) {
                    sinfo->volume = element["volume"].GetDouble();
                }
                if(element.HasMember("spatial") && element["spatial"].IsBool()) {
                    sinfo->spatial = element["spatial"].GetBool();
                }
                // store sound info
                sounds[sinfo->id] = sinfo;
            }
        }
    }

    return true;
}
コード例 #25
0
bool asCDataType::CanBeInstanciated() const
{
	if( GetSizeOnStackDWords() == 0 ||
		(IsObject() && 
		 (objectType->flags & asOBJ_REF) &&        // It's a ref type and
		 ((objectType->flags & asOBJ_NOHANDLE) ||  // the ref type doesn't support handles or
		  (!IsObjectHandle() &&                    // it's not a handle and
		   objectType->beh.factories.GetLength() == 0))) ) // the ref type cannot be instanciated
		return false;

	// An ASHANDLE type can only be declared as a handle, even though it is a value type
	if( IsObject() && (objectType->flags & asOBJ_ASHANDLE) && !IsObjectHandle() )
		return false;

	return true;
}
コード例 #26
0
ファイル: REGNRecord.cpp プロジェクト: Dienes/CBash
void REGNRecord::REGNEntry::IsObject(bool value)
    {
    if(value)
        RDAT.value.entryType = eObject;
    else if(IsObject())
        RDAT.value.entryType = eWeather;
    }
		TITANIUM_FUNCTION(Canvas, SetZIndex)
		{
			auto context = get_context();
			if (arguments.size() == 2) {
				auto _0 = arguments.at(0);
			TITANIUM_ASSERT_AND_THROW(_0.IsObject(), "Expected Object");
			auto object_element = static_cast<JSObject>(_0);
 
			auto wrapper_element = object_element.GetPrivate<Windows::UI::Xaml::UIElement>();
			// FIXME What if the type we want here is some parent class of the actual wrapper's class? I think we'll get nullptr here.
			// We need some way to know the underlying type the JSObject maps to, get that, then cast to the type we want...
			auto element = wrapper_element->unwrapWindows_UI_Xaml_UIElement();

				auto _1 = arguments.at(1); 
			TITANIUM_ASSERT_AND_THROW(_1.IsNumber(), "Expected Number");
			auto value = static_cast<int32_t>(_1);

				::Windows::UI::Xaml::Controls::Canvas::SetZIndex(element, value);
				return context.CreateUndefined(); 
			}

			// Catch-all if no arg count matches!
			TITANIUM_LOG_DEBUG("No method signature matched Canvas::SetZIndex with # of args: ", arguments.size());
			return context.CreateUndefined(); 
		}
コード例 #28
0
ファイル: Jzon.cpp プロジェクト: mqudsi/Jzon
	const Object &Node::AsObject() const
	{
		if (IsObject())
			return static_cast<const Object&>(*this);
		else
			throw TypeException();
	}
コード例 #29
0
ファイル: iotjs_binding.cpp プロジェクト: 0-T-0/iotjs
void JObject::SetProperty(const char* name, JRawValueType val) {
  IOTJS_ASSERT(IsObject());
  bool is_ok  = jerry_api_set_object_field_value(
        _obj_val.v_object,
        reinterpret_cast<const jerry_api_char_t*>(name),
        &val);
  IOTJS_ASSERT(is_ok);
}
コード例 #30
0
ファイル: packet.cpp プロジェクト: UltraFireFX/spitfireiii
void packet::VERIFYCASTLEID()
{
    if (!IsObject(data) || !KeyExists(data, "castleId"))
    {
        gserver->consoleLogger->information(Poco::format("castleId not received! - cmd: %s.%s - accountid:%?d - playername: %s", cmdtype, command, client->m_accountid, (char*)client->m_playername.c_str()));
        throw(1);
    }
}