ReadWriteSync::ReadWriteSync( LPCSTR Name ) { hMutexNoWriter = NULL; hEventNoReader = NULL; hSemNumReaders = NULL; char buffer[80]; if( ConstructName( "YSQMutexNoWriter", Name, buffer, sizeof(buffer) ) ){ hMutexNoWriter = CreateMutex( NULL, FALSE, buffer ); } if( ConstructName( "YSQEventNoReader", Name, buffer, sizeof(buffer) ) ){ hEventNoReader = CreateEvent( NULL, TRUE, TRUE, buffer ); } if( ConstructName( "YSQSemNumReaders", Name, buffer, sizeof(buffer) ) ){ hSemNumReaders = CreateSemaphore( NULL, TRUE, 0x7fffffff, buffer ); } if( hMutexNoWriter==NULL || hEventNoReader==NULL || hSemNumReaders==NULL ){ Release(); } }
Parser::StmtResult Parser::ParseIfStmt() { auto Loc = ConsumeToken(); ExprResult Condition; if (!ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after, "IF")) goto error; Condition = ParseExpectedFollowupExpression("("); if(Condition.isInvalid()) { if(!SkipUntil(tok::r_paren, true, true)) goto error; } if (!ExpectAndConsume(tok::r_paren)) goto error; if(Features.FixedForm && !Tok.isAtStartOfStatement()) ReLexAmbiguousIdentifier(FixedFormAmbiguities.getMatcherForKeywordsAfterIF()); if (!ConsumeIfPresent(tok::kw_THEN)) { // if-stmt if(Tok.isAtStartOfStatement()) { Diag.Report(getExpectedLoc(), diag::err_expected_executable_stmt); return StmtError(); } auto Result = Actions.ActOnIfStmt(Context, Loc, Condition, StmtConstructName, StmtLabel); if(Result.isInvalid()) return Result; // NB: Don't give the action stmt my label StmtLabel = nullptr; auto Action = ParseActionStmt(); Actions.ActOnEndIfStmt(Context, Loc, ConstructName(SourceLocation(), nullptr), nullptr); return Action.isInvalid()? StmtError() : Result; } // if-construct. return Actions.ActOnIfStmt(Context, Loc, Condition, StmtConstructName, StmtLabel); error: SkipUntilNextStatement(); return Actions.ActOnIfStmt(Context, Loc, Condition, StmtConstructName, StmtLabel); }
OP_STATUS ExtensionsManagerListViewItem::ConstructItemWidget(QuickWidget** widget) { *widget = NULL; // name_col OpAutoPtr<QuickStackLayout> name_col( OP_NEW(QuickStackLayout, (QuickStackLayout::VERTICAL))); RETURN_OOM_IF_NULL(name_col.get()); name_col->SetPreferredWidth(WidgetSizes::Fill); name_col->SetMinimumWidth(EXTENSION_NAME_MINIMUM_WIDTH); m_extension_name = ConstructName(); RETURN_OOM_IF_NULL(m_extension_name); RETURN_IF_ERROR(name_col->InsertWidget(m_extension_name)); m_author_version = ConstructAuthorAndVersion(); RETURN_OOM_IF_NULL(m_author_version); RETURN_IF_ERROR(name_col->InsertWidget(m_author_version)); // name_and_buttons_row OpAutoPtr<QuickStackLayout> name_and_buttons_row( OP_NEW(QuickStackLayout, (QuickStackLayout::HORIZONTAL))); RETURN_OOM_IF_NULL(name_and_buttons_row.get()); RETURN_IF_ERROR(name_and_buttons_row->InsertWidget(name_col.release())); QuickStackLayout* control_buttons = ConstructControlButtons(); RETURN_OOM_IF_NULL(control_buttons); RETURN_IF_ERROR(name_and_buttons_row->InsertWidget(control_buttons)); // main_col OpAutoPtr<QuickStackLayout> main_col( OP_NEW(QuickStackLayout, (QuickStackLayout::VERTICAL))); RETURN_OOM_IF_NULL(main_col.get()); RETURN_IF_ERROR(main_col->InsertWidget(name_and_buttons_row.release())); RETURN_IF_ERROR(main_col->InsertEmptyWidget(0, TEXT_SPACING, 0, TEXT_SPACING)); m_description = ConstructDescription(); RETURN_OOM_IF_NULL(m_description); RETURN_IF_ERROR(main_col->InsertWidget(m_description)); QuickStackLayout* debug_buttons = ConstructDebugButtons(); if (debug_buttons) { RETURN_IF_ERROR(main_col->InsertWidget(debug_buttons)); } // row_content OpAutoPtr<QuickStackLayout> row_content( OP_NEW(QuickStackLayout, (QuickStackLayout::HORIZONTAL))); RETURN_OOM_IF_NULL(row_content.get()); RETURN_IF_ERROR( row_content->InsertEmptyWidget(EXTENSION_ICON_PADDING, 0, EXTENSION_ICON_PADDING, 0)); m_icon = ConstructExtensionIcon(); RETURN_OOM_IF_NULL(m_icon); RETURN_IF_ERROR(row_content->InsertWidget(m_icon)); RETURN_IF_ERROR( row_content->InsertEmptyWidget(EXTENSION_ICON_PADDING, 0, EXTENSION_ICON_PADDING, 0)); RETURN_IF_ERROR(row_content->InsertWidget(main_col.release())); if (debug_buttons) { RETURN_IF_ERROR(row_content->InsertEmptyWidget(2, 0, 2, 0)); } // row OpAutoPtr<QuickStackLayout> row( OP_NEW(QuickStackLayout, (QuickStackLayout::VERTICAL))); RETURN_OOM_IF_NULL(row.get()); RETURN_IF_ERROR(row->InsertEmptyWidget(0, ROW_ITEM_TOP_PADDING, 0, ROW_ITEM_TOP_PADDING)); RETURN_IF_ERROR(row->InsertWidget(row_content.release())); RETURN_IF_ERROR(row->InsertEmptyWidget(0, ROW_ITEM_BOTTOM_PADDING, 0, ROW_ITEM_BOTTOM_PADDING)); QuickSkinElement *quick_skin_element = QuickSkinWrap(row.release(), "Extensions Panel List Item Skin"); RETURN_OOM_IF_NULL(quick_skin_element); quick_skin_element->GetOpWidget()->SetAlwaysHoverable(TRUE); *widget = quick_skin_element; UpdateControlButtonsState(); SetEnabled(!GetModelItem().IsDisabled()); return OpStatus::OK; }