Time Value::GetOtherTime() const { if(IsNull()) return Null; return ToTime(GetSmall<Date>()); }
Value ConvertDouble::Format(const Value& q) const { if(IsNull(q)) return Null; return UPP::NFormat(pattern, (double)q); }
void LabelBox::Paint(Draw& w) { Size sz = GetSize(); if(!IsTransparent()) w.DrawRect(sz, SColorFace); Size lsz = GetLabelSize(); int d = lsz.cy >> 1; bool hline = sz.cy < 2 * Draw::GetStdFontCy(); bool vline = sz.cx < 2 * Draw::GetStdFontCy(); int ty = hline ? (sz.cy - lsz.cy) / 2 : 0; Size ts = PaintLabel(w, d + 2, ty, sz.cx, lsz.cy, !IsShowEnabled(), false, false, VisibleAccessKeys()); w.Begin(); w.ExcludeClip(d, ty, ts.cx + 4, ts.cy); if(GUI_GlobalStyle() >= GUISTYLE_XP || !IsNull(color)) { if(hline) { d = sz.cy / 2; w.DrawRect(0, d - 1, sz.cx, 1, SColorLight); w.DrawRect(0, d, sz.cx, 1, SColorShadow); w.DrawRect(0, d + 1, sz.cx, 1, SColorLight); } else if(vline) { d = sz.cx / 2; w.DrawRect(d - 1, 0, 1, sz.cy, SColorLight); w.DrawRect(d, 0, 1, sz.cy, SColorShadow); w.DrawRect(d + 1, 0, 1, sz.cy, SColorLight); } else { Color c = Nvl(color, LabelBoxColor); w.DrawRect(0, d + 2, 1, sz.cy - d - 4, c); w.DrawRect(sz.cx - 1, d + 2, 1, sz.cy - d - 4, c); w.DrawRect(2, sz.cy - 1, sz.cx - 4, 1, c); w.DrawRect(2, d, sz.cx - 4, 1, c); w.DrawRect(1, d + 1, 2, 1, c); w.DrawRect(1, d + 2, 1, 1, c); w.DrawRect(sz.cx - 3, d + 1, 2, 1, c); w.DrawRect(sz.cx - 2, d + 2, 1, 1, c); w.DrawRect(1, sz.cy - 2, 2, 1, c); w.DrawRect(1, sz.cy - 3, 1, 1, c); w.DrawRect(sz.cx - 3, sz.cy - 2, 2, 1, c); w.DrawRect(sz.cx - 2, sz.cy - 3, 1, 1, c); } } else { if(hline) { d = sz.cy / 2; w.DrawRect(0, d, sz.cx, 1, SColorShadow); w.DrawRect(0, d + 1, sz.cx, 1, SColorLight); } else if(vline) { d = sz.cx / 2; w.DrawRect(d, 0, 1, sz.cy, SColorShadow); w.DrawRect(d - 1, 1, 0, sz.cy, SColorLight); } else { w.DrawRect(1, d, sz.cx - 2, 1, SColorShadow); w.DrawRect(1, d + 1, sz.cx - 2, 1, SColorLight); w.DrawRect(0, d, 1, sz.cy - d - 1, SColorShadow); w.DrawRect(1, d + 1, 1, sz.cy - d - 2, SColorLight); w.DrawRect(sz.cx - 2, d, 1, sz.cy - d, SColorShadow); w.DrawRect(sz.cx - 1, d, 1, sz.cy - d, SColorLight); w.DrawRect(1, sz.cy - 2, sz.cx - 2, 1, SColorShadow); w.DrawRect(1, sz.cy - 1, sz.cx - 2, 1, SColorLight); } } w.End(); }
/** Worker function that displays the list of boot options that is passed in. The function loops over the entries of the list of boot options that is passed in. For each entry, the boot option description is displayed on a single line along with the position of the option in the list. In debug mode, the UEFI device path and the arguments of the boot option are displayed as well in subsequent lines. @param[in] BootOptionsList List of the boot options **/ STATIC VOID DisplayBootOptions ( IN LIST_ENTRY* BootOptionsList ) { EFI_STATUS Status; UINTN BootOptionCount; LIST_ENTRY *Entry; BDS_LOAD_OPTION *BdsLoadOption; BOOLEAN IsUnicode; BootOptionCount = 0 ; for (Entry = GetFirstNode (BootOptionsList); !IsNull (BootOptionsList, Entry); Entry = GetNextNode (BootOptionsList, Entry) ) { BdsLoadOption = LOAD_OPTION_FROM_LINK (Entry); Print (L"[%d] %s\n", ++BootOptionCount, BdsLoadOption->Description); DEBUG_CODE_BEGIN (); CHAR16* DevicePathTxt; EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol; ARM_BDS_LOADER_TYPE LoaderType; ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData; Status = gBS->LocateProtocol ( &gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol ); ASSERT_EFI_ERROR (Status); DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText ( BdsLoadOption->FilePathList, TRUE, TRUE ); Print (L"\t- %s\n", DevicePathTxt); OptionalData = BdsLoadOption->OptionalData; if (IS_ARM_BDS_BOOTENTRY (BdsLoadOption)) { LoaderType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType); if ((LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) || (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT ) ) { Print (L"\t- Arguments: %a\n", &OptionalData->Arguments.LinuxArguments + 1); } } else if (OptionalData != NULL) { if (IsPrintableString (OptionalData, &IsUnicode)) { if (IsUnicode) { Print (L"\t- Arguments: %s\n", OptionalData); } else { AsciiPrint ("\t- Arguments: %a\n", OptionalData); } } } FreePool (DevicePathTxt); DEBUG_CODE_END (); } }
dword ParaFormatting::Get(RichText::FormatInfo& formatinfo) { dword v = 0; if(!IsNull(before)) { formatinfo.before = ~before; v |= RichText::BEFORE; } if(!IsNull(lm)) { formatinfo.lm = ~lm; v |= RichText::LM; } if(!IsNull(indent)) { formatinfo.indent = ~indent; v |= RichText::INDENT; } if(!IsNull(rm)) { formatinfo.rm = ~rm; v |= RichText::RM; } if(!IsNull(after)) { formatinfo.after = ~after; v |= RichText::AFTER; } if(!IsNull(align)) { static int sw[] = { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_JUSTIFY }; formatinfo.align = sw[(int)~align]; v |= RichText::ALIGN; } if(!IsNull(page)) { formatinfo.newpage = page; v |= RichText::NEWPAGE; } if(!IsNull(keep)) { formatinfo.keep = keep; v |= RichText::KEEP; } if(!IsNull(keepnext)) { formatinfo.keepnext = keepnext; v |= RichText::KEEPNEXT; } if(!IsNull(orphan)) { formatinfo.orphan = orphan; v |= RichText::ORPHAN; } if(!IsNull(bullet)) { formatinfo.bullet = ~bullet; v |= RichText::BULLET; } if(!IsNull(linespacing)) { formatinfo.linespacing = ~linespacing; v |= RichText::SPACING; } if(IsNumbering()) { (RichPara::NumberFormat&)formatinfo = GetNumbering(); v |= RichText::NUMBERING; } if((RichText::TABS & formatinfo.paravalid) || tabs.GetCount()) { formatinfo.tab.Clear(); for(int i = 0; i < tabs.GetCount(); i++) { RichPara::Tab tab; tab.pos = tabs.Get(i, 0); tab.align = (int)tabs.Get(i, 1); tab.fillchar = (int)tabs.Get(i, 2); formatinfo.tab.Add(tab); } v |= RichText::TABS; } if(!IsNull(tabsize)) { formatinfo.tabsize = ~tabsize; v |= RichText::TABSIZE; } if(!IsNull(ruler)) { formatinfo.ruler = ~ruler; v |= RichText::RULER; } if(!IsNull(rulerink)) { formatinfo.rulerink = ~rulerink; v |= RichText::RULERINK; } if(!IsNull(rulerstyle)) { formatinfo.rulerstyle = ~rulerstyle; v |= RichText::RULERSTYLE; } return v; }
wxGraphicsRenderer* wxGraphicsObject::GetRenderer() const { return ( IsNull() ? NULL : GetGraphicsData()->GetRenderer() ); }
/** Worker function that asks for a boot option to be selected and returns a pointer to the structure describing the selected boot option. @param[in] BootOptionsList List of the boot options @retval EFI_SUCCESS Selection succeeded @retval !EFI_SUCCESS Input error or input cancelled **/ STATIC EFI_STATUS SelectBootOption ( IN LIST_ENTRY* BootOptionsList, IN CONST CHAR16* InputStatement, OUT BDS_LOAD_OPTION_ENTRY** BdsLoadOptionEntry ) { EFI_STATUS Status; UINTN BootOptionCount; UINT16 *BootOrder; LIST_ENTRY* Entry; UINTN BootOptionSelected; UINTN Index; // Get the number of boot options Status = GetGlobalEnvironmentVariable ( L"BootOrder", NULL, &BootOptionCount, (VOID**)&BootOrder ); if (EFI_ERROR (Status)) { goto ErrorExit; } FreePool (BootOrder); BootOptionCount /= sizeof (UINT16); // Check if a valid boot option(s) is found if (BootOptionCount == 0) { if (StrCmp (InputStatement, DELETE_BOOT_ENTRY) == 0) { Print (L"Nothing to remove!\n"); } else if (StrCmp (InputStatement, UPDATE_BOOT_ENTRY) == 0) { Print (L"Nothing to update!\n"); } else if (StrCmp (InputStatement, MOVE_BOOT_ENTRY) == 0) { Print (L"Nothing to move!\n"); } else { Print (L"No supported Boot Entry.\n"); } return EFI_NOT_FOUND; } // Get the index of the boot device to delete BootOptionSelected = 0; while (BootOptionSelected == 0) { Print (InputStatement); Status = GetHIInputInteger (&BootOptionSelected); if (EFI_ERROR (Status)) { Print (L"\n"); goto ErrorExit; } else if ((BootOptionSelected == 0) || (BootOptionSelected > BootOptionCount)) { Print (L"Invalid input (max %d)\n", BootOptionCount); BootOptionSelected = 0; } } // Get the structure of the Boot device to delete Index = 1; for (Entry = GetFirstNode (BootOptionsList); !IsNull (BootOptionsList, Entry); Entry = GetNextNode (BootOptionsList,Entry) ) { if (Index == BootOptionSelected) { *BdsLoadOptionEntry = LOAD_OPTION_ENTRY_FROM_LINK (Entry); break; } Index++; } ErrorExit: return Status; }
/** function to take a list of files to copy and a destination location and do the verification and copying of those files to that location. This function will report any errors to the user and halt. The key is to have this function called ONLY once. this allows for the parameter verification to happen correctly. @param[in] FileList A LIST_ENTRY* based list of files to move. @param[in] DestDir The destination location. @param[in] SilentMode TRUE to eliminate screen output. @param[in] RecursiveMode TRUE to copy directories. @param[in] Resp The response to the overwrite query (if always). @retval SHELL_SUCCESS the files were all moved. @retval SHELL_INVALID_PARAMETER a parameter was invalid @retval SHELL_SECURITY_VIOLATION a security violation ocurred @retval SHELL_WRITE_PROTECTED the destination was write protected @retval SHELL_OUT_OF_RESOURCES a memory allocation failed **/ SHELL_STATUS ValidateAndCopyFiles( IN CONST EFI_SHELL_FILE_INFO *FileList, IN CONST CHAR16 *DestDir, IN BOOLEAN SilentMode, IN BOOLEAN RecursiveMode, IN VOID **Resp ) { CHAR16 *HiiOutput; CHAR16 *HiiResultOk; CONST EFI_SHELL_FILE_INFO *Node; SHELL_STATUS ShellStatus; EFI_STATUS Status; CHAR16 *DestPath; VOID *Response; UINTN PathSize; CONST CHAR16 *Cwd; UINTN NewSize; CHAR16 *CleanFilePathStr; if (Resp == NULL) { Response = NULL; } else { Response = *Resp; } DestPath = NULL; ShellStatus = SHELL_SUCCESS; PathSize = 0; Cwd = ShellGetCurrentDir(NULL); CleanFilePathStr = NULL; ASSERT(FileList != NULL); ASSERT(DestDir != NULL); Status = ShellLevel2StripQuotes (DestDir, &CleanFilePathStr); if (EFI_ERROR (Status)) { if (Status == EFI_OUT_OF_RESOURCES) { return SHELL_OUT_OF_RESOURCES; } else { return SHELL_INVALID_PARAMETER; } } ASSERT (CleanFilePathStr != NULL); // // If we are trying to copy multiple files... make sure we got a directory for the target... // if (EFI_ERROR(ShellIsDirectory(CleanFilePathStr)) && FileList->Link.ForwardLink != FileList->Link.BackLink) { // // Error for destination not a directory // ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, L"cp", CleanFilePathStr); FreePool (CleanFilePathStr); return (SHELL_INVALID_PARAMETER); } for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link) ; !IsNull(&FileList->Link, &Node->Link) ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&FileList->Link, &Node->Link) ){ // // skip the directory traversing stuff... // if (StrCmp(Node->FileName, L".") == 0 || StrCmp(Node->FileName, L"..") == 0) { continue; } NewSize = StrSize(CleanFilePathStr); NewSize += StrSize(Node->FullName); NewSize += (Cwd == NULL)? 0 : (StrSize(Cwd) + sizeof(CHAR16)); if (NewSize > PathSize) { PathSize = NewSize; } // // Make sure got -r if required // if (!RecursiveMode && !EFI_ERROR(ShellIsDirectory(Node->FullName))) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_DIR_REQ), gShellLevel2HiiHandle, L"cp"); FreePool (CleanFilePathStr); return (SHELL_INVALID_PARAMETER); } // // make sure got dest as dir if needed // if (!EFI_ERROR(ShellIsDirectory(Node->FullName)) && EFI_ERROR(ShellIsDirectory(CleanFilePathStr))) { // // Error for destination not a directory // ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, L"cp", CleanFilePathStr); FreePool (CleanFilePathStr); return (SHELL_INVALID_PARAMETER); } } HiiOutput = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_CP_OUTPUT), NULL); HiiResultOk = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_GEN_RES_OK), NULL); DestPath = AllocateZeroPool(PathSize); if (DestPath == NULL || HiiOutput == NULL || HiiResultOk == NULL) { SHELL_FREE_NON_NULL(DestPath); SHELL_FREE_NON_NULL(HiiOutput); SHELL_FREE_NON_NULL(HiiResultOk); FreePool (CleanFilePathStr); return (SHELL_OUT_OF_RESOURCES); } // // Go through the list of files to copy... // for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link) ; !IsNull(&FileList->Link, &Node->Link) ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&FileList->Link, &Node->Link) ){ if (ShellGetExecutionBreakFlag()) { break; } ASSERT(Node->FileName != NULL); ASSERT(Node->FullName != NULL); // // skip the directory traversing stuff... // if (StrCmp(Node->FileName, L".") == 0 || StrCmp(Node->FileName, L"..") == 0) { continue; } if (FileList->Link.ForwardLink == FileList->Link.BackLink // 1 item && EFI_ERROR(ShellIsDirectory(CleanFilePathStr)) // not an existing directory ) { if (StrStr(CleanFilePathStr, L":") == NULL) { // // simple copy of a single file // if (Cwd != NULL) { StrCpyS(DestPath, PathSize / sizeof(CHAR16), Cwd); StrCatS(DestPath, PathSize / sizeof(CHAR16), L"\\"); } else { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr); FreePool (CleanFilePathStr); return (SHELL_INVALID_PARAMETER); } if (DestPath[StrLen(DestPath)-1] != L'\\' && CleanFilePathStr[0] != L'\\') { StrCatS(DestPath, PathSize / sizeof(CHAR16), L"\\"); } else if (DestPath[StrLen(DestPath)-1] == L'\\' && CleanFilePathStr[0] == L'\\') { ((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL; } StrCatS(DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr); } else { StrCpyS(DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr); } } else { // // we have multiple files or a directory in the DestDir // // // Check for leading slash // if (CleanFilePathStr[0] == L'\\') { // // Copy to the root of CWD // if (Cwd != NULL) { StrCpyS(DestPath, PathSize/sizeof(CHAR16), Cwd); StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\"); } else { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr); FreePool(CleanFilePathStr); return (SHELL_INVALID_PARAMETER); } while (PathRemoveLastItem(DestPath)); StrCatS(DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr+1); StrCatS(DestPath, PathSize/sizeof(CHAR16), Node->FileName); } else if (StrStr(CleanFilePathStr, L":") == NULL) { if (Cwd != NULL) { StrCpyS(DestPath, PathSize/sizeof(CHAR16), Cwd); StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\"); } else { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr); FreePool(CleanFilePathStr); return (SHELL_INVALID_PARAMETER); } if (DestPath[StrLen(DestPath)-1] != L'\\' && CleanFilePathStr[0] != L'\\') { StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\"); } else if (DestPath[StrLen(DestPath)-1] == L'\\' && CleanFilePathStr[0] == L'\\') { ((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL; } StrCatS(DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr); if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] != L'\\' && Node->FileName[0] != L'\\') { StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\"); } else if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] == L'\\' && Node->FileName[0] == L'\\') { ((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL; } StrCatS(DestPath, PathSize/sizeof(CHAR16), Node->FileName); } else { StrCpyS(DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr); if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] != L'\\' && Node->FileName[0] != L'\\') { StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\"); } else if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] == L'\\' && Node->FileName[0] == L'\\') { ((CHAR16*)CleanFilePathStr)[StrLen(CleanFilePathStr)-1] = CHAR_NULL; } StrCatS(DestPath, PathSize/sizeof(CHAR16), Node->FileName); } } // // Make sure the path exists // if (EFI_ERROR(VerifyIntermediateDirectories(DestPath))) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_DIR_WNF), gShellLevel2HiiHandle, L"cp", DestPath); ShellStatus = SHELL_DEVICE_ERROR; break; } if ( !EFI_ERROR(ShellIsDirectory(Node->FullName)) && !EFI_ERROR(ShellIsDirectory(DestPath)) && StrniCmp(Node->FullName, DestPath, StrLen(DestPath)) == NULL ){ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_SD_PARENT), gShellLevel2HiiHandle, L"cp"); ShellStatus = SHELL_INVALID_PARAMETER; break; } if (StringNoCaseCompare(&Node->FullName, &DestPath) == 0) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_SD_SAME), gShellLevel2HiiHandle, L"cp"); ShellStatus = SHELL_INVALID_PARAMETER; break; } if ((StrniCmp(Node->FullName, DestPath, StrLen(Node->FullName)) == 0) && (DestPath[StrLen(Node->FullName)] == CHAR_NULL || DestPath[StrLen(Node->FullName)] == L'\\') ) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_SD_SAME), gShellLevel2HiiHandle, L"cp"); ShellStatus = SHELL_INVALID_PARAMETER; break; } PathCleanUpDirectories(DestPath); if (!SilentMode) { ShellPrintEx(-1, -1, HiiOutput, Node->FullName, DestPath); } // // copy single file... // ShellStatus = CopySingleFile(Node->FullName, DestPath, &Response, SilentMode, L"cp"); if (ShellStatus != SHELL_SUCCESS) { break; } } if (ShellStatus == SHELL_SUCCESS && Resp == NULL) { ShellPrintEx(-1, -1, L"%s", HiiResultOk); } SHELL_FREE_NON_NULL(DestPath); SHELL_FREE_NON_NULL(HiiOutput); SHELL_FREE_NON_NULL(HiiResultOk); SHELL_FREE_NON_NULL(CleanFilePathStr); if (Resp == NULL) { SHELL_FREE_NON_NULL(Response); } return (ShellStatus); }
string CVariant::GetString(void) const { string s(""); if( IsNull() ) { switch( GetType() ) { case eDB_TinyInt: case eDB_SmallInt: case eDB_Int: case eDB_BigInt: case eDB_Numeric: s = "0"; break; case eDB_Float: case eDB_Double: s = "0.0"; break; default: break; } } else { switch( GetType() ) { case eDB_Char: case eDB_VarChar: case eDB_LongChar: s = ((CDB_String*)GetData())->Value(); break; case eDB_Binary: { CDB_Binary *b = (CDB_Binary*)GetData(); s = string((char*)b->Value(), b->Size()); break; } case eDB_LongBinary: { CDB_LongBinary *vb = (CDB_LongBinary*)GetData(); s = string((char*)vb->Value(), vb->DataSize()); break; } case eDB_VarBinary: { CDB_VarBinary *vb = (CDB_VarBinary*)GetData(); s = string((char*)vb->Value(), vb->Size()); break; } case eDB_TinyInt: s = NStr::IntToString(GetByte()); break; case eDB_SmallInt: s = NStr::IntToString(GetInt2()); break; case eDB_Int: s = NStr::IntToString(GetInt4()); break; case eDB_BigInt: s = NStr::Int8ToString(GetInt8()); break; case eDB_Float: s = NStr::DoubleToString(GetFloat()); break; case eDB_Double: s = NStr::DoubleToString(GetDouble()); break; case eDB_Bit: s = NStr::BoolToString(GetBit()); break; case eDB_Numeric: s = ((CDB_Numeric*)GetData())->Value(); break; case eDB_DateTime: case eDB_SmallDateTime: s = GetCTime().AsString(); break; case eDB_Text: case eDB_Image: { CDB_Stream* stream = (CDB_Stream*)GetData(); char* buff[4096]; size_t read_bytes = 0; s.reserve(stream->Size()); while ((read_bytes = stream->Read(buff, sizeof(buff))) != 0) { s.append((const char*) buff, read_bytes); if (read_bytes < sizeof(buff)) { break; } } } break; default: x_Verify_AssignType(eDB_UnsupportedType, "string"); break; } } return s; }
String AsJSON(Time tm) { return IsNull(tm) ? "null" : "\"\\/Date(" + AsString(1000 * (tm - Time(1970, 1, 1))) + ")\\/\""; }
String AsJSON(const Value& v, const String& sep, bool pretty) { String r; if(v.GetType() == VALUEMAP_V) { r << "{"; String sep1; if(pretty) { r << "\r\n"; sep1 = sep + '\t'; } ValueMap m = v; ValueArray va = m.GetValues(); for(int i = 0; i < m.GetCount(); i++) { if(i) { r << ","; if(pretty) r << "\r\n"; } if(pretty) r << sep1; r << AsJSON((String)m.GetKey(i)) << (pretty ? ": " : ":") << AsJSON(va[i], sep1, pretty); } if(pretty) r << "\r\n" << sep; r << "}"; return r; } if(v.GetType() == VALUEARRAY_V) { r << "["; String sep1; if(pretty) { r << "\r\n"; sep1 = sep + '\t'; } ValueArray va = v; for(int i = 0; i < va.GetCount(); i++) { if(i) { r << ","; if(pretty) r << "\r\n"; } if(pretty) r << sep1; r << AsJSON(va[i], sep1, pretty); } if(pretty) r << "\r\n" << sep; r << "]"; return r; } if(IsNumber(v) && IsNull(v)) return "null"; if(v.GetType() == INT_V) return Format("%d", (int)v); if(v.GetType() == BOOL_V) return (bool)v ? "true" : "false"; if(IsNumber(v)) return Format("%.16g", (double)v); if(IsString(v)) return AsCString((String)v, INT_MAX, NULL, ASCSTRING_JSON); if(IsDateTime(v)) return AsJSON((Time)v); if(IsNull(v)) return "null"; NEVER_("Non-JSON value in AsJSON: " + v.GetTypeName()); return "null"; }
bool Paragraph::Format(ParaTypo& pfmt, int cx, int zoom) const { int len = length + !!style.indent; Buffer<char> chr(len); Buffer<int> width(len); Buffer<ParaTypo::Part *> info(len); Buffer<ParaTypo::Part> pinfo(part.GetCount() + !!style.indent); const Part *pptr = part.Begin(); const Part *plim = part.End(); ParaTypo::Part *pp = pinfo; char *cp = chr; int *wp = width; ParaTypo::Part **ip = info; if(!IsNull(parafont)) { Font pf = parafont; // pf.Height(max(1, DocZoom(zoom, parafont.GetHeight()))); int n = DocZoom(zoom, parafont.GetHeight()); pf.Height(n ? n : 1); FontInfo f = pf.Info(); pfmt.SetMin(f.GetAscent(), f.GetDescent(), f.GetExternal()); } /* if(!IsNull(parafont)) { FontInfo f = w.GetFontInfo(parafont); pfmt.SetMin(DocZoom(zoom, f.GetAscent()), DocZoom(zoom, f.GetDescent()), DocZoom(zoom, f.GetExternal())); } */ if(style.indent) { static Part dummy; *cp++ = ' '; *wp++ = DocZoom(zoom, style.indent); pp->Set(Arial(0), Black); pp->voidptr = &dummy; *ip++ = pp; pp++; } while(pptr != plim) { if(pptr->pr) { *cp++ = '@'; Size sz = pptr->pr.GetStdSize(); *wp++ = pp->width = pptr->pr && !pptr->sz.cx ? sz.cx : DocZoom(zoom, pptr->sz.cx); *ip++ = pp; pp->ascent = minmax(pptr->pr && !pptr->sz.cy ? sz.cy : DocZoom(zoom, pptr->sz.cy), 0, 1000); pp->descent = 0; pp->external = pp->overhang = 0; pp->color = pptr->color; } else { Font font = pptr->font; font.Height(DocZoom(zoom, pptr->font.GetHeight())); FontInfo pf = pp->Set(font, pptr->color); const char *s = pptr->text; int n = pptr->text.GetLength(); while(n--) { *cp++ = *s; *wp++ = pf[*s == 31 ? 32 : ToUnicode((byte) *s, CHARSET_DEFAULT)]; *ip++ = pp; s++; } } pp->voidptr = (void *)pptr; pp++; pptr++; } return pfmt.Format(style.align, len, chr, width, info, cx); }
Value::operator WString() const { if(IsNull()) return Null; return GetType() == WSTRING_V ? RichValue<WString>::Extract(*this) : ((String)(*this)).ToWString();//!!! }
String Value::GetOtherString() const { if(IsNull()) return Null; return RichValue<WString>::Extract(*this).ToString(); }
void QmitkExampleView::ProcessSelectedImage() { // Before we even think about processing something, we need to make sure // that we have valid input. Don't be sloppy, this is a main reason // for application crashes if neglected. auto selectedDataNodes = this->GetDataManagerSelection(); if (selectedDataNodes.empty()) return; auto firstSelectedDataNode = selectedDataNodes.front(); if (firstSelectedDataNode.IsNull()) { QMessageBox::information(nullptr, "Example View", "Please load and select an image before starting image processing."); return; } auto data = firstSelectedDataNode->GetData(); // Something is selected, but does it contain data? if (data != nullptr) { // We don't use the auto keyword here, which would evaluate to a native // image pointer. Instead, we want a smart pointer in order to ensure that // the image isn't deleted somewhere else while we're using it. mitk::Image::Pointer image = dynamic_cast<mitk::Image*>(data); // Something is selected and it contains data, but is it an image? if (image.IsNotNull()) { auto imageName = firstSelectedDataNode->GetName(); auto offset = m_Controls.offsetSpinBox->value(); MITK_INFO << "Process image \"" << imageName << "\" ..."; // We're finally using the ExampleImageFilter from ExtExampleModule. auto filter = ExampleImageFilter::New(); filter->SetInput(image); filter->SetOffset(offset); filter->Update(); mitk::Image::Pointer processedImage = filter->GetOutput(); if (processedImage.IsNull() || !processedImage->IsInitialized()) return; MITK_INFO << " done"; // Stuff the resulting image into a data node, set some properties, // and add it to the data storage, which will eventually display the // image in the application. auto processedImageDataNode = mitk::DataNode::New(); processedImageDataNode->SetData(processedImage); QString name = QString("%1 (Offset: %2)").arg(imageName.c_str()).arg(offset); processedImageDataNode->SetName(name.toStdString()); // We don't really need to copy the level window, but if we wouldn't // do it, the new level window would be initialized to display the image // with optimal contrast in order to capture the whole range of pixel // values. This is also true for the input image as long as one didn't // modify its level window manually. Thus, the images would appear // identical unless you compare the level window widget for both images. mitk::LevelWindow levelWindow; if (firstSelectedDataNode->GetLevelWindow(levelWindow)) processedImageDataNode->SetLevelWindow(levelWindow); // We also attach our ExampleImageInteractor, which allows us to paint // on the resulting images by using the mouse as long as the CTRL key // is pressed. auto interactor = CreateExampleImageInteractor(); if (interactor.IsNotNull()) interactor->SetDataNode(processedImageDataNode); this->GetDataStorage()->Add(processedImageDataNode); } } // Now it's your turn. This class/method has lots of room for improvements, // for example: // // - What happens when multiple items are selected but the first one isn't // an image? - There isn't any feedback for the user at all. // - What's the front item of a selection? Does it depend on the order // of selection or the position in the Data Manager? - Isn't it // better to process all selected images? Don't forget to adjust the // titles of the UI widgets. // - In addition to the the displayed label, it's probably a good idea to // enable or disable the button depending on the selection. }
/** Get selection for OneOf and OrderedList (Left/Right will be ignored). @param Selection Pointer to current selection. @param MenuOption Pointer to the current input menu. @retval EFI_SUCCESS If Option input is processed successfully @retval EFI_DEVICE_ERROR If operation fails **/ EFI_STATUS GetSelectionInputPopUp ( IN UI_MENU_SELECTION *Selection, IN UI_MENU_OPTION *MenuOption ) { EFI_STATUS Status; EFI_INPUT_KEY Key; UINTN Index; CHAR16 *StringPtr; CHAR16 *TempStringPtr; UINTN Index2; UINTN TopOptionIndex; UINTN HighlightOptionIndex; UINTN Start; UINTN End; UINTN Top; UINTN Bottom; UINTN PopUpMenuLines; UINTN MenuLinesInView; UINTN PopUpWidth; CHAR16 Character; INT32 SavedAttribute; BOOLEAN ShowDownArrow; BOOLEAN ShowUpArrow; UINTN DimensionsWidth; LIST_ENTRY *Link; BOOLEAN OrderedList; UINT8 *ValueArray; UINT8 ValueType; EFI_HII_VALUE HiiValue; EFI_HII_VALUE *HiiValueArray; UINTN OptionCount; QUESTION_OPTION *OneOfOption; QUESTION_OPTION *CurrentOption; FORM_BROWSER_STATEMENT *Question; INTN Result; DimensionsWidth = gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn; ValueArray = NULL; ValueType = 0; CurrentOption = NULL; ShowDownArrow = FALSE; ShowUpArrow = FALSE; StringPtr = AllocateZeroPool ((gOptionBlockWidth + 1) * 2); ASSERT (StringPtr); Question = MenuOption->ThisTag; if (Question->Operand == EFI_IFR_ORDERED_LIST_OP) { ValueArray = Question->BufferValue; ValueType = Question->ValueType; OrderedList = TRUE; } else { OrderedList = FALSE; } // // Calculate Option count // if (OrderedList) { for (Index = 0; Index < Question->MaxContainers; Index++) { if (GetArrayData (ValueArray, ValueType, Index) == 0) { break; } } OptionCount = Index; } else { OptionCount = 0; Link = GetFirstNode (&Question->OptionListHead); while (!IsNull (&Question->OptionListHead, Link)) { OneOfOption = QUESTION_OPTION_FROM_LINK (Link); OptionCount++; Link = GetNextNode (&Question->OptionListHead, Link); } } // // Prepare HiiValue array // HiiValueArray = AllocateZeroPool (OptionCount * sizeof (EFI_HII_VALUE)); ASSERT (HiiValueArray != NULL); Link = GetFirstNode (&Question->OptionListHead); for (Index = 0; Index < OptionCount; Index++) { if (OrderedList) { HiiValueArray[Index].Type = ValueType; HiiValueArray[Index].Value.u64 = GetArrayData (ValueArray, ValueType, Index); } else { OneOfOption = QUESTION_OPTION_FROM_LINK (Link); CopyMem (&HiiValueArray[Index], &OneOfOption->Value, sizeof (EFI_HII_VALUE)); Link = GetNextNode (&Question->OptionListHead, Link); } } // // Move Suppressed Option to list tail // PopUpMenuLines = 0; for (Index = 0; Index < OptionCount; Index++) { OneOfOption = ValueToOption (Question, &HiiValueArray[OptionCount - Index - 1]); if (OneOfOption == NULL) { return EFI_NOT_FOUND; } RemoveEntryList (&OneOfOption->Link); if ((OneOfOption->SuppressExpression != NULL) && EvaluateExpressionList(OneOfOption->SuppressExpression, FALSE, NULL, NULL) != ExpressFalse) { // // This option is suppressed, insert to tail // InsertTailList (&Question->OptionListHead, &OneOfOption->Link); } else { // // Insert to head // InsertHeadList (&Question->OptionListHead, &OneOfOption->Link); PopUpMenuLines++; } } // // Get the number of one of options present and its size // PopUpWidth = 0; HighlightOptionIndex = 0; Link = GetFirstNode (&Question->OptionListHead); for (Index = 0; Index < PopUpMenuLines; Index++) { OneOfOption = QUESTION_OPTION_FROM_LINK (Link); StringPtr = GetToken (OneOfOption->Text, MenuOption->Handle); if (StrLen (StringPtr) > PopUpWidth) { PopUpWidth = StrLen (StringPtr); } FreePool (StringPtr); if (!OrderedList && (CompareHiiValue (&Question->HiiValue, &OneOfOption->Value, &Result, NULL) == EFI_SUCCESS) && (Result == 0)) { // // Find current selected Option for OneOf // HighlightOptionIndex = Index; } Link = GetNextNode (&Question->OptionListHead, Link); } // // Perform popup menu initialization. // PopUpWidth = PopUpWidth + POPUP_PAD_SPACE_COUNT; SavedAttribute = gST->ConOut->Mode->Attribute; gST->ConOut->SetAttribute (gST->ConOut, POPUP_TEXT | POPUP_BACKGROUND); if ((PopUpWidth + POPUP_FRAME_WIDTH) > DimensionsWidth) { PopUpWidth = DimensionsWidth - POPUP_FRAME_WIDTH; } Start = (DimensionsWidth - PopUpWidth - POPUP_FRAME_WIDTH) / 2 + gScreenDimensions.LeftColumn; End = Start + PopUpWidth + POPUP_FRAME_WIDTH; Top = gScreenDimensions.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT; Bottom = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight - 1; MenuLinesInView = Bottom - Top - 1; if (MenuLinesInView >= PopUpMenuLines) { Top = Top + (MenuLinesInView - PopUpMenuLines) / 2; Bottom = Top + PopUpMenuLines + 1; } else { ShowDownArrow = TRUE; } if (HighlightOptionIndex > (MenuLinesInView - 1)) { TopOptionIndex = HighlightOptionIndex - MenuLinesInView + 1; } else { TopOptionIndex = 0; } do { // // Clear that portion of the screen // ClearLines (Start, End, Top, Bottom, POPUP_TEXT | POPUP_BACKGROUND); // // Draw "One of" pop-up menu // Character = BOXDRAW_DOWN_RIGHT; PrintCharAt (Start, Top, Character); for (Index = Start; Index + 2 < End; Index++) { if ((ShowUpArrow) && ((Index + 1) == (Start + End) / 2)) { Character = GEOMETRICSHAPE_UP_TRIANGLE; } else { Character = BOXDRAW_HORIZONTAL; } PrintChar (Character); } Character = BOXDRAW_DOWN_LEFT; PrintChar (Character); Character = BOXDRAW_VERTICAL; for (Index = Top + 1; Index < Bottom; Index++) { PrintCharAt (Start, Index, Character); PrintCharAt (End - 1, Index, Character); } // // Move to top Option // Link = GetFirstNode (&Question->OptionListHead); for (Index = 0; Index < TopOptionIndex; Index++) { Link = GetNextNode (&Question->OptionListHead, Link); } // // Display the One of options // Index2 = Top + 1; for (Index = TopOptionIndex; (Index < PopUpMenuLines) && (Index2 < Bottom); Index++) { OneOfOption = QUESTION_OPTION_FROM_LINK (Link); Link = GetNextNode (&Question->OptionListHead, Link); StringPtr = GetToken (OneOfOption->Text, MenuOption->Handle); ASSERT (StringPtr != NULL); // // If the string occupies multiple lines, truncate it to fit in one line, // and append a "..." for indication. // if (StrLen (StringPtr) > (PopUpWidth - 1)) { TempStringPtr = AllocateZeroPool (sizeof (CHAR16) * (PopUpWidth - 1)); ASSERT ( TempStringPtr != NULL ); CopyMem (TempStringPtr, StringPtr, (sizeof (CHAR16) * (PopUpWidth - 5))); FreePool (StringPtr); StringPtr = TempStringPtr; StrCat (StringPtr, L"..."); } if (Index == HighlightOptionIndex) { // // Highlight the selected one // CurrentOption = OneOfOption; gST->ConOut->SetAttribute (gST->ConOut, PICKLIST_HIGHLIGHT_TEXT | PICKLIST_HIGHLIGHT_BACKGROUND); PrintStringAt (Start + 2, Index2, StringPtr); gST->ConOut->SetAttribute (gST->ConOut, POPUP_TEXT | POPUP_BACKGROUND); } else { gST->ConOut->SetAttribute (gST->ConOut, POPUP_TEXT | POPUP_BACKGROUND); PrintStringAt (Start + 2, Index2, StringPtr); } Index2++; FreePool (StringPtr); } Character = BOXDRAW_UP_RIGHT; PrintCharAt (Start, Bottom, Character); for (Index = Start; Index + 2 < End; Index++) { if ((ShowDownArrow) && ((Index + 1) == (Start + End) / 2)) { Character = GEOMETRICSHAPE_DOWN_TRIANGLE; } else { Character = BOXDRAW_HORIZONTAL; } PrintChar (Character); } Character = BOXDRAW_UP_LEFT; PrintChar (Character); // // Get User selection // Key.UnicodeChar = CHAR_NULL; if ((gDirection == SCAN_UP) || (gDirection == SCAN_DOWN)) { Key.ScanCode = gDirection; gDirection = 0; goto TheKey; } Status = WaitForKeyStroke (&Key); TheKey: switch (Key.UnicodeChar) { case '+': if (OrderedList) { if ((TopOptionIndex > 0) && (TopOptionIndex == HighlightOptionIndex)) { // // Highlight reaches the top of the popup window, scroll one menu item. // TopOptionIndex--; ShowDownArrow = TRUE; } if (TopOptionIndex == 0) { ShowUpArrow = FALSE; } if (HighlightOptionIndex > 0) { HighlightOptionIndex--; ASSERT (CurrentOption != NULL); SwapListEntries (CurrentOption->Link.BackLink, &CurrentOption->Link); } } break; case '-': // // If an ordered list op-code, we will allow for a popup of +/- keys // to create an ordered list of items // if (OrderedList) { if (((TopOptionIndex + MenuLinesInView) < PopUpMenuLines) && (HighlightOptionIndex == (TopOptionIndex + MenuLinesInView - 1))) { // // Highlight reaches the bottom of the popup window, scroll one menu item. // TopOptionIndex++; ShowUpArrow = TRUE; } if ((TopOptionIndex + MenuLinesInView) == PopUpMenuLines) { ShowDownArrow = FALSE; } if (HighlightOptionIndex < (PopUpMenuLines - 1)) { HighlightOptionIndex++; ASSERT (CurrentOption != NULL); SwapListEntries (&CurrentOption->Link, CurrentOption->Link.ForwardLink); } } break; case CHAR_NULL: switch (Key.ScanCode) { case SCAN_UP: case SCAN_DOWN: if (Key.ScanCode == SCAN_UP) { if ((TopOptionIndex > 0) && (TopOptionIndex == HighlightOptionIndex)) { // // Highlight reaches the top of the popup window, scroll one menu item. // TopOptionIndex--; ShowDownArrow = TRUE; } if (TopOptionIndex == 0) { ShowUpArrow = FALSE; } if (HighlightOptionIndex > 0) { HighlightOptionIndex--; } } else { if (((TopOptionIndex + MenuLinesInView) < PopUpMenuLines) && (HighlightOptionIndex == (TopOptionIndex + MenuLinesInView - 1))) { // // Highlight reaches the bottom of the popup window, scroll one menu item. // TopOptionIndex++; ShowUpArrow = TRUE; } if ((TopOptionIndex + MenuLinesInView) == PopUpMenuLines) { ShowDownArrow = FALSE; } if (HighlightOptionIndex < (PopUpMenuLines - 1)) { HighlightOptionIndex++; } } break; case SCAN_ESC: gST->ConOut->SetAttribute (gST->ConOut, SavedAttribute); // // Restore link list order for orderedlist // if (OrderedList) { HiiValue.Type = ValueType; HiiValue.Value.u64 = 0; for (Index = 0; Index < Question->MaxContainers; Index++) { HiiValue.Value.u64 = GetArrayData (ValueArray, ValueType, Index); if (HiiValue.Value.u64 == 0) { break; } OneOfOption = ValueToOption (Question, &HiiValue); if (OneOfOption == NULL) { return EFI_NOT_FOUND; } RemoveEntryList (&OneOfOption->Link); InsertTailList (&Question->OptionListHead, &OneOfOption->Link); } } FreePool (HiiValueArray); return EFI_DEVICE_ERROR; default: break; } break; case CHAR_CARRIAGE_RETURN: // // return the current selection // if (OrderedList) { Index = 0; Link = GetFirstNode (&Question->OptionListHead); while (!IsNull (&Question->OptionListHead, Link)) { OneOfOption = QUESTION_OPTION_FROM_LINK (Link); SetArrayData (ValueArray, ValueType, Index, OneOfOption->Value.Value.u64); Index++; if (Index > Question->MaxContainers) { break; } Link = GetNextNode (&Question->OptionListHead, Link); } } else { ASSERT (CurrentOption != NULL); CopyMem (&Question->HiiValue, &CurrentOption->Value, sizeof (EFI_HII_VALUE)); } gST->ConOut->SetAttribute (gST->ConOut, SavedAttribute); FreePool (HiiValueArray); Status = ValidateQuestion (Selection->FormSet, Selection->Form, Question, EFI_HII_EXPRESSION_INCONSISTENT_IF); if (EFI_ERROR (Status)) { // // Input value is not valid, restore Question Value // GetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE); } else { SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE); UpdateStatusBar (Selection, NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE); } return Status; default: break; } } while (TRUE); }
void VfkStream::ScanFile(int fx) { RTIMING("VfkStream::ScanFile"); Stream& strm = streams[fx]; int64 last_line = strm.GetSize(); while(last_line > 0) { strm.Seek(last_line - 1); if(strm.Get() == '\n') break; last_line--; } strm.Seek(0); try { int c; int64 rowpos = strm.GetPos(); while((c = strm.Get()) == '&' && ((c = strm.Get()) == 'H' || c == 'D') && IsAlpha(strm.Term())) { char type = c; int64 begin = strm.GetPos(); SkipRow(strm); rowpos = strm.GetPos(); int len = (int)(strm.GetPos() - begin); StringBuffer linebuf(len + 1); strm.Seek(begin); strm.Get(linebuf, len); linebuf[len] = 0; const char *b = linebuf; const char *id = b; while(IsIdent(*++b)) ; String ident(id, b); if(*b++ != ';') throw Exc(NFormat("';' expected after '%s' (found: '%c', %2:02x)", ident, *b)); if(type == 'D') { String fident = "X_" + ident; int f = tables.Find(fident); if(f < 0) throw Exc(NFormat("unexpected data for filter table '%s'", ident)); // b = ScanRow(b, tables[f]); } else if(IsAlpha(*b)) { String fident = "X_" + ident; Table& tbl = tables.GetAdd(fident); tbl.name = tbl.rawname = fident; tbl.row_count = 0; ScanHeader(b, tbl); } else { do { Vector<Value> row; row.SetCount(HDR_COUNT); if(*b == '\"') { WString text = ReadString(b, &b); if(IsDateTime(ident) && !IsNull(text)) { Time dt = VfkReadTime(text.ToString(), NULL); if(IsNull(dt)) throw Exc(NFormat("invalid date/time value %s", AsCString(text.ToString()))); row[HDR_DTM] = dt; } else { row[HDR_STR] = text; if(ident == "CODEPAGE") if(text == WString("EE8MSWIN1250")) charset = CHARSET_WIN1250; } } else { double num = ScanDouble(b, &b); if(IsNull(num)) throw Exc("invalid numeric value"); row[HDR_NUM] = num; } int l = header.FindLast(ident); row[HDR_ID] = ident; row[HDR_ORD] = (l >= 0 ? (int)header[l][HDR_ORD] + 1 : 0); header.Add(ident) = row; } while(*b++ == ';'); b--; } } strm.Seek(rowpos); while(strm.Get() == '&' && strm.Get() == 'B' && IsAlpha(strm.Term())) { int64 header_offset = strm.GetPos(); SkipRow(strm); int64 begin_offset = strm.GetPos(); int len = (int)(begin_offset - header_offset); Buffer<char> linebuf(len + 1); strm.Seek(header_offset); strm.Get(linebuf, len); linebuf[len] = 0; const char *b = linebuf; const char *id = b; while(IsIdent(*++b)) ; int idlen = b - id; String ident(id, b); if(*b++ != ';') throw Exc(NFormat("';' expected after '%s' (found: '%c', %2:02x)", ident, *b)); String name = ident; for(const VFKLongName *ln = vfk_long_names; ln->shortname; ln++) if(name == ln->shortname) { name = ln->longname; break; } Table& tbl = tables.GetAdd(name); tbl.name = name; tbl.rawname = ident; ScanHeader(b, tbl); int64 p = begin_offset, e = last_line; Buffer<char> idbuf(idlen + 3); while(p < e) { int64 m = (p + e) >> 1; while(m > p) { char part[100]; int partsize = (int)min<int64>(m - p, sizeof(part)); strm.Seek(m - partsize); strm.Get(part, partsize); const char *x = &part[partsize]; while(x > part && x[-1] != '\n') x--; int lfpos = x - part; if(x > part && --x > part && x[-1] == '\r') x--; m -= partsize - lfpos; if(x <= part) continue; if(*--x != '\xA4') break; m -= lfpos - (x - part); } strm.Seek(m); if(strm.Get(idbuf, idlen + 3) != idlen + 3 || idbuf[0] != '&' || idbuf[1] != 'D' || memcmp(~idbuf + 2, id, idlen) || idbuf[idlen + 2] != ';') e = m; else { SkipRow(strm); p = strm.GetPos(); } } int xgrp = file_groups.GetKey(fx); int f; for(f = 0; f < tbl.file_index.GetCount(); f++) if(file_groups.GetKey(tbl.file_index[f]) == xgrp) break; if(f >= tbl.file_index.GetCount()) { tbl.file_index.Add(fx); tbl.begin_offset.Add(begin_offset); tbl.end_offset.Add(p); } strm.Seek(p); } } catch(Exc e) { throw Exc(NFormat("%s (offset %n): %s", file_groups[fx], strm.GetPos(), e)); } }
static int really_list_abp_privacy_levels(ABP_DBHANDLE dbhandle, ABP_PRIVACY_LEVEL keys, ABP_PRIVACY_LEVEL *list, int active_only) { int status, use_where = TRUE, retval = 0; Arb_connection *dbcon; ABP_PRIVACY_LEVEL databuf = new_abp_privacy_level(), new_privacy_level; ABP_PRIVACY_LEVEL lb = NULL; ABP_PRIVACY_LEVEL ub = NULL; int nfields; int inb, j, offset; short *nbbuf, xid_type; if (databuf == NULL) return ABP_SYSERR; if (keys && WRONG_OBJ_TYPE(keys, PRIVACY_LEVEL)) { delete_abp_privacy_level(databuf); return ABP_ARGERR; } if (keys) { lb = keys; ub = next_abp_privacy_level(lb); if (ub && WRONG_OBJ_TYPE(ub, PRIVACY_LEVEL)) { delete_abp_privacy_level(databuf); return ABP_ARGERR; } if (ub == NULL) { ub = lb; } else if (next_abp_privacy_level(ub) != NULL) { delete_abp_privacy_level(databuf); return ABP_ARGERR; } } if (NotCustDbhandle(dbhandle)) { delete_abp_privacy_level(databuf); return ABP_ARGERR; } dbcon = dbhandle->cust_connection; nfields = sizeof(databuf->privacy_level_ref_data->bitfields) + sizeof(databuf->privacy_level_values_data->bitfields); nbbuf = (short *)calloc(nfields, sizeof(short)); if (nbbuf == NULL) { delete_abp_privacy_level(databuf); return ABP_SYSERR; } arb_dbfcmd(dbcon, "SELECT * from "); arb_dbfcmd(dbcon, "PRIVACY_LEVEL_REF"); arb_dbfcmd(dbcon, ", PRIVACY_LEVEL_VALUES"); arb_dbfcmd(dbcon, " WHERE PRIVACY_LEVEL_REF.privacy_level = PRIVACY_LEVEL_VALUES.privacy_level" ); if (keys) { int use_where = FALSE; if (IsNull(privacy_level_ref_privacy_level, lb->privacy_level_ref_data) || IsNull(privacy_level_ref_privacy_level, ub->privacy_level_ref_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_REF.privacy_level is NULL", use_where ? "WHERE" : "AND"); use_where = FALSE; } else if (IsSet(privacy_level_ref_privacy_level, lb->privacy_level_ref_data) && IsSet(privacy_level_ref_privacy_level, ub->privacy_level_ref_data) && lb->privacy_level_ref_data->privacy_level == ub->privacy_level_ref_data->privacy_level) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_REF.privacy_level = %d", use_where ? "WHERE" : "AND", lb->privacy_level_ref_data->privacy_level); use_where = FALSE; } else { if (IsSet(privacy_level_ref_privacy_level, lb->privacy_level_ref_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_REF.privacy_level >= %d", use_where ? "WHERE" : "AND", lb->privacy_level_ref_data->privacy_level); use_where = FALSE; } if (IsSet(privacy_level_ref_privacy_level, ub->privacy_level_ref_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_REF.privacy_level < %d", use_where ? "WHERE" : "AND", ub->privacy_level_ref_data->privacy_level); use_where = FALSE; } } if (IsNull(privacy_level_ref_is_default, lb->privacy_level_ref_data) || IsNull(privacy_level_ref_is_default, ub->privacy_level_ref_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_REF.is_default is NULL", use_where ? "WHERE" : "AND"); use_where = FALSE; } else if (IsSet(privacy_level_ref_is_default, lb->privacy_level_ref_data) && IsSet(privacy_level_ref_is_default, ub->privacy_level_ref_data) && lb->privacy_level_ref_data->is_default == ub->privacy_level_ref_data->is_default) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_REF.is_default = %d", use_where ? "WHERE" : "AND", lb->privacy_level_ref_data->is_default); use_where = FALSE; } else { if (IsSet(privacy_level_ref_is_default, lb->privacy_level_ref_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_REF.is_default >= %d", use_where ? "WHERE" : "AND", lb->privacy_level_ref_data->is_default); use_where = FALSE; } if (IsSet(privacy_level_ref_is_default, ub->privacy_level_ref_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_REF.is_default < %d", use_where ? "WHERE" : "AND", ub->privacy_level_ref_data->is_default); use_where = FALSE; } } if (IsNull(privacy_level_ref_is_internal, lb->privacy_level_ref_data) || IsNull(privacy_level_ref_is_internal, ub->privacy_level_ref_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_REF.is_internal is NULL", use_where ? "WHERE" : "AND"); use_where = FALSE; } else if (IsSet(privacy_level_ref_is_internal, lb->privacy_level_ref_data) && IsSet(privacy_level_ref_is_internal, ub->privacy_level_ref_data) && lb->privacy_level_ref_data->is_internal == ub->privacy_level_ref_data->is_internal) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_REF.is_internal = %d", use_where ? "WHERE" : "AND", lb->privacy_level_ref_data->is_internal); use_where = FALSE; } else { if (IsSet(privacy_level_ref_is_internal, lb->privacy_level_ref_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_REF.is_internal >= %d", use_where ? "WHERE" : "AND", lb->privacy_level_ref_data->is_internal); use_where = FALSE; } if (IsSet(privacy_level_ref_is_internal, ub->privacy_level_ref_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_REF.is_internal < %d", use_where ? "WHERE" : "AND", ub->privacy_level_ref_data->is_internal); use_where = FALSE; } } if (IsNull(privacy_level_values_privacy_level, lb->privacy_level_values_data) || IsNull(privacy_level_values_privacy_level, ub->privacy_level_values_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_VALUES.privacy_level is NULL", use_where ? "WHERE" : "AND"); use_where = FALSE; } else if (IsSet(privacy_level_values_privacy_level, lb->privacy_level_values_data) && IsSet(privacy_level_values_privacy_level, ub->privacy_level_values_data) && lb->privacy_level_values_data->privacy_level == ub->privacy_level_values_data->privacy_level) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_VALUES.privacy_level = %d", use_where ? "WHERE" : "AND", lb->privacy_level_values_data->privacy_level); use_where = FALSE; } else { if (IsSet(privacy_level_values_privacy_level, lb->privacy_level_values_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_VALUES.privacy_level >= %d", use_where ? "WHERE" : "AND", lb->privacy_level_values_data->privacy_level); use_where = FALSE; } if (IsSet(privacy_level_values_privacy_level, ub->privacy_level_values_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_VALUES.privacy_level < %d", use_where ? "WHERE" : "AND", ub->privacy_level_values_data->privacy_level); use_where = FALSE; } } if (IsNull(privacy_level_values_language_code, lb->privacy_level_values_data) || IsNull(privacy_level_values_language_code, ub->privacy_level_values_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_VALUES.language_code is NULL", use_where ? "WHERE" : "AND"); use_where = FALSE; } else if (IsSet(privacy_level_values_language_code, lb->privacy_level_values_data) && IsSet(privacy_level_values_language_code, ub->privacy_level_values_data) && lb->privacy_level_values_data->language_code == ub->privacy_level_values_data->language_code) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_VALUES.language_code = %d", use_where ? "WHERE" : "AND", lb->privacy_level_values_data->language_code); use_where = FALSE; } else { if (IsSet(privacy_level_values_language_code, lb->privacy_level_values_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_VALUES.language_code >= %d", use_where ? "WHERE" : "AND", lb->privacy_level_values_data->language_code); use_where = FALSE; } if (IsSet(privacy_level_values_language_code, ub->privacy_level_values_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_VALUES.language_code < %d", use_where ? "WHERE" : "AND", ub->privacy_level_values_data->language_code); use_where = FALSE; } } if (IsNull(privacy_level_values_short_display, lb->privacy_level_values_data) || IsNull(privacy_level_values_short_display, ub->privacy_level_values_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_VALUES.short_display is NULL", use_where ? "WHERE" : "AND"); use_where = FALSE; } else if (IsSet(privacy_level_values_short_display, lb->privacy_level_values_data) && IsSet(privacy_level_values_short_display, ub->privacy_level_values_data) && strcmp(lb->privacy_level_values_data->short_display, ub->privacy_level_values_data->short_display) == 0) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_VALUES.short_display = '%s'", use_where ? "WHERE" : "AND", lb->privacy_level_values_data->short_display); use_where = FALSE; } else { if (IsSet(privacy_level_values_short_display, lb->privacy_level_values_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_VALUES.short_display >= '%s'", use_where ? "WHERE" : "AND", lb->privacy_level_values_data->short_display); use_where = FALSE; } if (IsSet(privacy_level_values_short_display, ub->privacy_level_values_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_VALUES.short_display < '%s'", use_where ? "WHERE" : "AND", ub->privacy_level_values_data->short_display); use_where = FALSE; } } if (IsNull(privacy_level_values_display_value, lb->privacy_level_values_data) || IsNull(privacy_level_values_display_value, ub->privacy_level_values_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_VALUES.display_value is NULL", use_where ? "WHERE" : "AND"); use_where = FALSE; } else if (IsSet(privacy_level_values_display_value, lb->privacy_level_values_data) && IsSet(privacy_level_values_display_value, ub->privacy_level_values_data) && strcmp(lb->privacy_level_values_data->display_value, ub->privacy_level_values_data->display_value) == 0) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_VALUES.display_value = '%s'", use_where ? "WHERE" : "AND", lb->privacy_level_values_data->display_value); use_where = FALSE; } else { if (IsSet(privacy_level_values_display_value, lb->privacy_level_values_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_VALUES.display_value >= '%s'", use_where ? "WHERE" : "AND", lb->privacy_level_values_data->display_value); use_where = FALSE; } if (IsSet(privacy_level_values_display_value, ub->privacy_level_values_data)) { arb_dbfcmd(dbcon, " %s PRIVACY_LEVEL_VALUES.display_value < '%s'", use_where ? "WHERE" : "AND", ub->privacy_level_values_data->display_value); use_where = FALSE; } } } if ((status = arb_exec_string(dbcon, "", SQL_DEFER_EXECUTE)) != SUCCESS) { free(nbbuf); delete_abp_privacy_level(databuf); return ABP_DBERR; } offset = 0; if (privacy_level_ref_dbbind(dbcon, databuf->privacy_level_ref_data, nbbuf, &offset) == FAILURE) { free(nbbuf); delete_abp_privacy_level(databuf); return ABP_DBERR; } if (privacy_level_values_dbbind(dbcon, databuf->privacy_level_values_data, nbbuf, &offset) == FAILURE) { free(nbbuf); delete_abp_privacy_level(databuf); return ABP_DBERR; } *list = NULL; while ((status = arb_next_row(dbcon)) == ARB_MORE_DATA) { inb = 0; for (j = 0; j < sizeof(databuf->privacy_level_ref_data->bitfields); j++) { if (nbbuf[inb] == -1) databuf->privacy_level_ref_data->bitfields[j] = ABP_DB_NULL; else if (nbbuf[inb] == 0) databuf->privacy_level_ref_data->bitfields[j] = ABP_SET; inb++; } for (j = 0; j < sizeof(databuf->privacy_level_values_data->bitfields); j++) { if (nbbuf[inb] == -1) databuf->privacy_level_values_data->bitfields[j] = ABP_DB_NULL; else if (nbbuf[inb] == 0) databuf->privacy_level_values_data->bitfields[j] = ABP_SET; inb++; } if (*list == NULL) { *list = new_privacy_level = new_abp_privacy_level(); } else { new_privacy_level->object_data.next = (API_OBJECT)new_abp_privacy_level(); new_privacy_level = (ABP_PRIVACY_LEVEL)new_privacy_level->object_data.next; } if (new_privacy_level == NULL) { retval = ABP_SYSERR; break; } else { memcpy(new_privacy_level->privacy_level_ref_data, databuf->privacy_level_ref_data, sizeof(PRIVACY_LEVEL_REF_DATA)); memcpy(new_privacy_level->privacy_level_values_data, databuf->privacy_level_values_data, sizeof(PRIVACY_LEVEL_VALUES_DATA)); } } delete_abp_privacy_level(databuf); if (status == FAILURE) retval = ABP_DBERR; free(nbbuf); return retval ? retval : arb_dbcount(dbcon); }
bool USocketIOClientComponent::CallBPFunctionWithResponse(UObject* Target, const FString& FunctionName, TArray<TSharedPtr<FJsonValue>> Response) { if (!Target->IsValidLowLevel()) { UE_LOG(SocketIOLog, Warning, TEXT("CallFunctionByNameWithArguments: Target not found for '%s'"), *FunctionName); return false; } UFunction* Function = Target->FindFunction(FName(*FunctionName)); if (nullptr == Function) { UE_LOG(SocketIOLog, Warning, TEXT("CallFunctionByNameWithArguments: Function not found '%s'"), *FunctionName); return false; } //Check function signature TFieldIterator<UProperty> Iterator(Function); TArray<UProperty*> Properties; while (Iterator && (Iterator->PropertyFlags & CPF_Parm)) { UProperty* Prop = *Iterator; Properties.Add(Prop); ++Iterator; } auto ResponseJsonValue = USIOJConvert::ToSIOJsonValue(Response); bool bResponseNumNotZero = Response.Num() > 0; bool bNoFunctionParams = Properties.Num() == 0; bool bNullResponse = ResponseJsonValue->IsNull(); if (bNullResponse && bNoFunctionParams) { Target->ProcessEvent(Function, nullptr); return true; } else if (bResponseNumNotZero) { //function has too few params if (bNoFunctionParams) { UE_LOG(SocketIOLog, Warning, TEXT("CallFunctionByNameWithArguments: Function '%s' has too few parameters, callback parameters ignored : <%s>"), *FunctionName, *ResponseJsonValue->EncodeJson()); Target->ProcessEvent(Function, nullptr); return true; } struct FDynamicArgs { void* Arg01 = nullptr; USIOJsonValue* Arg02 = nullptr; }; //create the container FDynamicArgs Args = FDynamicArgs(); //add the full response array as second param Args.Arg02 = ResponseJsonValue; const FString& FirstParam = Properties[0]->GetCPPType(); auto FirstFJsonValue = Response[0]; //Is first param... //SIOJsonValue? if (FirstParam.Equals("USIOJsonValue*")) { //convenience wrapper, response is a single object USIOJsonValue* Value = NewObject<USIOJsonValue>(); Value->SetRootValue(FirstFJsonValue); Args.Arg01 = Value; Target->ProcessEvent(Function, &Args); return true; } //SIOJsonObject? else if (FirstParam.Equals("USIOJsonObject*")) { //convenience wrapper, response is a single object USIOJsonObject* ObjectValue = NewObject<USIOJsonObject>(); ObjectValue->SetRootObject(FirstFJsonValue->AsObject()); Args.Arg01 = ObjectValue; Target->ProcessEvent(Function, &Args); return true; } //String? else if (FirstParam.Equals("FString")) { FString StringValue = USIOJConvert::ToJsonString(FirstFJsonValue); Target->ProcessEvent(Function, &StringValue); return true; } //Float? else if (FirstParam.Equals("float")) { float NumberValue = (float)FirstFJsonValue->AsNumber(); Target->ProcessEvent(Function, &NumberValue); return true; } //Int? else if (FirstParam.Equals("int32")) { int NumberValue = (int)FirstFJsonValue->AsNumber(); Target->ProcessEvent(Function, &NumberValue); return true; } //bool? else if (FirstParam.Equals("bool")) { bool BoolValue = FirstFJsonValue->AsBool(); Target->ProcessEvent(Function, &BoolValue); return true; } //array? else if (FirstParam.Equals("TArray")) { UArrayProperty* ArrayProp = Cast<UArrayProperty>(Properties[0]); FString Inner; ArrayProp->GetCPPMacroType(Inner); //byte array is the only supported version if (Inner.Equals("uint8")) { TArray<uint8> Bytes = ResponseJsonValue->AsArray()[0]->AsBinary(); Target->ProcessEvent(Function, &Bytes); return true; } } } UE_LOG(SocketIOLog, Warning, TEXT("CallFunctionByNameWithArguments: Function '%s' signature not supported expected <%s>"), *FunctionName, *ResponseJsonValue->EncodeJson()); return false; }
/** Call back function when the timer event is signaled. @param[in] Event The Event this notify function registered to. @param[in] Context Pointer to the context data registered to the Event. **/ VOID EFIAPI ProcessAsyncTaskList ( IN EFI_EVENT Event, IN VOID* Context ) { NVME_CONTROLLER_PRIVATE_DATA *Private; EFI_PCI_IO_PROTOCOL *PciIo; NVME_CQ *Cq; UINT16 QueueId; UINT32 Data; LIST_ENTRY *Link; LIST_ENTRY *NextLink; NVME_PASS_THRU_ASYNC_REQ *AsyncRequest; NVME_BLKIO2_SUBTASK *Subtask; NVME_BLKIO2_REQUEST *BlkIo2Request; EFI_BLOCK_IO2_TOKEN *Token; BOOLEAN HasNewItem; EFI_STATUS Status; Private = (NVME_CONTROLLER_PRIVATE_DATA*)Context; QueueId = 2; Cq = Private->CqBuffer[QueueId] + Private->CqHdbl[QueueId].Cqh; HasNewItem = FALSE; PciIo = Private->PciIo; // // Submit asynchronous subtasks to the NVMe Submission Queue // for (Link = GetFirstNode (&Private->UnsubmittedSubtasks); !IsNull (&Private->UnsubmittedSubtasks, Link); Link = NextLink) { NextLink = GetNextNode (&Private->UnsubmittedSubtasks, Link); Subtask = NVME_BLKIO2_SUBTASK_FROM_LINK (Link); BlkIo2Request = Subtask->BlockIo2Request; Token = BlkIo2Request->Token; RemoveEntryList (Link); BlkIo2Request->UnsubmittedSubtaskNum--; // // If any previous subtask fails, do not process subsequent ones. // if (Token->TransactionStatus != EFI_SUCCESS) { if (IsListEmpty (&BlkIo2Request->SubtasksQueue) && BlkIo2Request->LastSubtaskSubmitted && (BlkIo2Request->UnsubmittedSubtaskNum == 0)) { // // Remove the BlockIo2 request from the device asynchronous queue. // RemoveEntryList (&BlkIo2Request->Link); FreePool (BlkIo2Request); gBS->SignalEvent (Token->Event); } FreePool (Subtask->CommandPacket->NvmeCmd); FreePool (Subtask->CommandPacket->NvmeCompletion); FreePool (Subtask->CommandPacket); FreePool (Subtask); continue; } Status = Private->Passthru.PassThru ( &Private->Passthru, Subtask->NamespaceId, Subtask->CommandPacket, Subtask->Event ); if (Status == EFI_NOT_READY) { InsertHeadList (&Private->UnsubmittedSubtasks, Link); BlkIo2Request->UnsubmittedSubtaskNum++; break; } else if (EFI_ERROR (Status)) { Token->TransactionStatus = EFI_DEVICE_ERROR; if (IsListEmpty (&BlkIo2Request->SubtasksQueue) && Subtask->IsLast) { // // Remove the BlockIo2 request from the device asynchronous queue. // RemoveEntryList (&BlkIo2Request->Link); FreePool (BlkIo2Request); gBS->SignalEvent (Token->Event); } FreePool (Subtask->CommandPacket->NvmeCmd); FreePool (Subtask->CommandPacket->NvmeCompletion); FreePool (Subtask->CommandPacket); FreePool (Subtask); } else { InsertTailList (&BlkIo2Request->SubtasksQueue, Link); if (Subtask->IsLast) { BlkIo2Request->LastSubtaskSubmitted = TRUE; } } } while (Cq->Pt != Private->Pt[QueueId]) { ASSERT (Cq->Sqid == QueueId); HasNewItem = TRUE; // // Find the command with given Command Id. // for (Link = GetFirstNode (&Private->AsyncPassThruQueue); !IsNull (&Private->AsyncPassThruQueue, Link); Link = NextLink) { NextLink = GetNextNode (&Private->AsyncPassThruQueue, Link); AsyncRequest = NVME_PASS_THRU_ASYNC_REQ_FROM_THIS (Link); if (AsyncRequest->CommandId == Cq->Cid) { // // Copy the Respose Queue entry for this command to the callers // response buffer. // CopyMem ( AsyncRequest->Packet->NvmeCompletion, Cq, sizeof(EFI_NVM_EXPRESS_COMPLETION) ); // // Free the resources allocated before cmd submission // if (AsyncRequest->MapData != NULL) { PciIo->Unmap (PciIo, AsyncRequest->MapData); } if (AsyncRequest->MapMeta != NULL) { PciIo->Unmap (PciIo, AsyncRequest->MapMeta); } if (AsyncRequest->MapPrpList != NULL) { PciIo->Unmap (PciIo, AsyncRequest->MapPrpList); } if (AsyncRequest->PrpListHost != NULL) { PciIo->FreeBuffer ( PciIo, AsyncRequest->PrpListNo, AsyncRequest->PrpListHost ); } RemoveEntryList (Link); gBS->SignalEvent (AsyncRequest->CallerEvent); FreePool (AsyncRequest); // // Update submission queue head. // Private->AsyncSqHead = Cq->Sqhd; break; } } Private->CqHdbl[QueueId].Cqh++; if (Private->CqHdbl[QueueId].Cqh > NVME_ASYNC_CCQ_SIZE) { Private->CqHdbl[QueueId].Cqh = 0; Private->Pt[QueueId] ^= 1; } Cq = Private->CqBuffer[QueueId] + Private->CqHdbl[QueueId].Cqh; } if (HasNewItem) { Data = ReadUnaligned32 ((UINT32*)&Private->CqHdbl[QueueId]); PciIo->Mem.Write ( PciIo, EfiPciIoWidthUint32, NVME_BAR, NVME_CQHDBL_OFFSET(QueueId, Private->Cap.Dstrd), 1, &Data ); } }
STATIC EFI_STATUS SelectBootDevice ( OUT BDS_SUPPORTED_DEVICE** SupportedBootDevice ) { EFI_STATUS Status; LIST_ENTRY SupportedDeviceList; UINTN SupportedDeviceCount; LIST_ENTRY* Entry; UINTN SupportedDeviceSelected; UINTN Index; // // List the Boot Devices supported // // Start all the drivers first BdsConnectAllDrivers (); // List the supported devices Status = BootDeviceListSupportedInit (&SupportedDeviceList); ASSERT_EFI_ERROR(Status); SupportedDeviceCount = 0; for (Entry = GetFirstNode (&SupportedDeviceList); !IsNull (&SupportedDeviceList,Entry); Entry = GetNextNode (&SupportedDeviceList,Entry) ) { *SupportedBootDevice = SUPPORTED_BOOT_DEVICE_FROM_LINK(Entry); Print(L"[%d] %s\n",SupportedDeviceCount+1,(*SupportedBootDevice)->Description); DEBUG_CODE_BEGIN(); CHAR16* DevicePathTxt; EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol; Status = gBS->LocateProtocol (&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol); ASSERT_EFI_ERROR(Status); DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText ((*SupportedBootDevice)->DevicePathProtocol,TRUE,TRUE); Print(L"\t- %s\n",DevicePathTxt); FreePool(DevicePathTxt); DEBUG_CODE_END(); SupportedDeviceCount++; } if (SupportedDeviceCount == 0) { Print(L"There is no supported device.\n"); Status = EFI_ABORTED; goto EXIT; } // // Select the Boot Device // SupportedDeviceSelected = 0; while (SupportedDeviceSelected == 0) { Print(L"Select the Boot Device: "); Status = GetHIInputInteger (&SupportedDeviceSelected); if (EFI_ERROR(Status)) { Status = EFI_ABORTED; goto EXIT; } else if ((SupportedDeviceSelected == 0) || (SupportedDeviceSelected > SupportedDeviceCount)) { Print(L"Invalid input (max %d)\n",SupportedDeviceCount); SupportedDeviceSelected = 0; } } // // Get the Device Path for the selected boot device // Index = 1; for (Entry = GetFirstNode (&SupportedDeviceList); !IsNull (&SupportedDeviceList,Entry); Entry = GetNextNode (&SupportedDeviceList,Entry) ) { if (Index == SupportedDeviceSelected) { *SupportedBootDevice = SUPPORTED_BOOT_DEVICE_FROM_LINK(Entry); break; } Index++; } EXIT: BootDeviceListSupportedFree (&SupportedDeviceList, *SupportedBootDevice); return Status; }
/** Translate a Framework Question ID to UEFI Question ID. @param FormSet FormSet context @param FwOpCode Framework Opcode @param FwQId Framework Question Id @param UefiQId UEFI Question ID. @retval EFI_SUCCESS The UEFI Question Id is found and returned. @retval EFI_NOT_FOUND The UEFI Question Id is not found. **/ EFI_STATUS FwQIdToUefiQId ( IN CONST FORM_BROWSER_FORMSET *FormSet, IN UINT8 FwOpCode, IN UINT16 FwQId, OUT UINT16 *UefiQId ) { LIST_ENTRY *FormList; LIST_ENTRY *StatementList; FORM_BROWSER_FORM *Form; FORM_BROWSER_STATEMENT *Statement; FORM_BROWSER_STATEMENT *StatementFound; EFI_STATUS Status; UINT8 UefiOp; *UefiQId = 0; StatementFound = NULL; FormList = GetFirstNode (&FormSet->FormListHead); while (!IsNull (&FormSet->FormListHead, FormList)) { Form = FORM_BROWSER_FORM_FROM_LINK (FormList); StatementList = GetFirstNode (&Form->StatementListHead); while (!IsNull (&Form->StatementListHead, StatementList)) { Statement = FORM_BROWSER_STATEMENT_FROM_LINK (StatementList); if (Statement->VarStoreId != 0 && Statement->Storage->Type == EFI_HII_VARSTORE_BUFFER) { if (FwQId == Statement->VarStoreInfo.VarOffset) { Status = QuestionOpFwToUefi (FwOpCode, &UefiOp); ASSERT_EFI_ERROR (Status); if ((UefiOp == Statement->Operand) && (FormSet->DefaultVarStoreId == Statement->VarStoreId)) { // // If ASSERT here, the Framework VFR file has two Questions with all three attibutes the same: // 1) Same Question Type, // 2) Same Variable Storage // 3) Refering to the Same offset in Variable Map (NvMap). // This is ambigurity as FwQIdToUefiQId () can't find which UEFI Question // ID to return. // // One possible solution is to remove the one of the duplicated questions in this Form Set. // ASSERT (StatementFound == NULL); StatementFound= Statement; // // Continue the search to check if the Form Set contains more than one questins that has the 3 attributes // with same value. // } } } StatementList = GetNextNode (&Form->StatementListHead, StatementList); } FormList = GetNextNode (&FormSet->FormListHead, FormList); } if (StatementFound != NULL) { *UefiQId = StatementFound->QuestionId; return EFI_SUCCESS; } return EFI_NOT_FOUND; }
EFI_STATUS BootMenuMain ( VOID ) { LIST_ENTRY BootOptionsList; UINTN OptionCount; UINTN BootOptionCount; EFI_STATUS Status; LIST_ENTRY* Entry; BDS_LOAD_OPTION* BootOption; UINTN BootOptionSelected; UINTN Index; UINTN BootMainEntryCount; BOOLEAN IsUnicode; BootOption = NULL; BootMainEntryCount = sizeof(BootMainEntries) / sizeof(struct BOOT_MAIN_ENTRY); while (TRUE) { // Get Boot#### list BootOptionList (&BootOptionsList); OptionCount = 1; // Display the Boot options for (Entry = GetFirstNode (&BootOptionsList); !IsNull (&BootOptionsList,Entry); Entry = GetNextNode (&BootOptionsList,Entry) ) { BootOption = LOAD_OPTION_FROM_LINK(Entry); Print(L"[%d] %s\n", OptionCount, BootOption->Description); DEBUG_CODE_BEGIN(); CHAR16* DevicePathTxt; EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol; ARM_BDS_LOADER_OPTIONAL_DATA* OptionalData; UINTN CmdLineSize; ARM_BDS_LOADER_TYPE LoaderType; Status = gBS->LocateProtocol (&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol); if (EFI_ERROR(Status)) { // You must provide an implementation of DevicePathToTextProtocol in your firmware (eg: DevicePathDxe) DEBUG((EFI_D_ERROR,"Error: Bds requires DevicePathToTextProtocol\n")); return Status; } DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText (BootOption->FilePathList, TRUE, TRUE); Print(L"\t- %s\n",DevicePathTxt); // If it is a supported BootEntry then print its details if (IS_ARM_BDS_BOOTENTRY (BootOption)) { OptionalData = BootOption->OptionalData; LoaderType = (ARM_BDS_LOADER_TYPE)ReadUnaligned32 ((CONST UINT32*)&OptionalData->Header.LoaderType); if ((LoaderType == BDS_LOADER_KERNEL_LINUX_ATAG) || (LoaderType == BDS_LOADER_KERNEL_LINUX_FDT)) { if (ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.InitrdSize) > 0) { CmdLineSize = ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.CmdLineSize); DevicePathTxt = DevicePathToTextProtocol->ConvertDevicePathToText ( GetAlignedDevicePath ((EFI_DEVICE_PATH*)((UINTN)(&OptionalData->Arguments.LinuxArguments + 1) + CmdLineSize)), TRUE, TRUE); Print(L"\t- Initrd: %s\n", DevicePathTxt); } if (ReadUnaligned16 (&OptionalData->Arguments.LinuxArguments.CmdLineSize) > 0) { Print(L"\t- Arguments: %a\n", (&OptionalData->Arguments.LinuxArguments + 1)); } } switch (LoaderType) { case BDS_LOADER_EFI_APPLICATION: Print(L"\t- LoaderType: EFI Application\n"); break; case BDS_LOADER_KERNEL_LINUX_ATAG: Print(L"\t- LoaderType: Linux kernel with ATAG support\n"); break; case BDS_LOADER_KERNEL_LINUX_FDT: Print(L"\t- LoaderType: Linux kernel with FDT support\n"); break; default: Print(L"\t- LoaderType: Not recognized (%d)\n", LoaderType); } } else if (BootOption->OptionalData != NULL) { if (IsPrintableString (BootOption->OptionalData, &IsUnicode)) { if (IsUnicode) { Print (L"\t- Arguments: %s\n", BootOption->OptionalData); } else { AsciiPrint ("\t- Arguments: %a\n", BootOption->OptionalData); } } } FreePool(DevicePathTxt); DEBUG_CODE_END(); OptionCount++; } BootOptionCount = OptionCount-1; // Display the hardcoded Boot entries for (Index = 0; Index < BootMainEntryCount; Index++) { Print(L"[%d] %s\n",OptionCount,BootMainEntries[Index]); OptionCount++; } // Request the boot entry from the user BootOptionSelected = 0; while (BootOptionSelected == 0) { Print(L"Start: "); Status = GetHIInputInteger (&BootOptionSelected); if (EFI_ERROR(Status) || (BootOptionSelected == 0) || (BootOptionSelected > OptionCount)) { Print(L"Invalid input (max %d)\n",(OptionCount-1)); BootOptionSelected = 0; } } // Start the selected entry if (BootOptionSelected > BootOptionCount) { // Start the hardcoded entry Status = BootMainEntries[BootOptionSelected - BootOptionCount - 1].Callback (&BootOptionsList); } else { // Find the selected entry from the Boot#### list Index = 1; for (Entry = GetFirstNode (&BootOptionsList); !IsNull (&BootOptionsList,Entry); Entry = GetNextNode (&BootOptionsList,Entry) ) { if (Index == BootOptionSelected) { BootOption = LOAD_OPTION_FROM_LINK(Entry); break; } Index++; } Status = BootOptionStart (BootOption); } } // Should never go here }
/** Stops a device controller or a bus controller. The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). As a result, much of the error checking on the parameters to Stop() has been moved into this common boot service. It is legal to call Stop() from other locations, but the following calling restrictions must be followed or the system behavior will not be deterministic. 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this same driver's Start() function. 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid EFI_HANDLE. In addition, all of these handles must have been created in this driver's Start() function, and the Start() function must have called OpenProtocol() on ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. @param[in] ControllerHandle A handle to the device being stopped. The handle must support a bus specific I/O protocol for the driver to use to stop the device. @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer. @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL if NumberOfChildren is 0. @retval EFI_SUCCESS The device was stopped. @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. **/ EFI_STATUS EFIAPI SdDxeDriverBindingStop ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer ) { EFI_STATUS Status; BOOLEAN AllChildrenStopped; UINTN Index; SD_DRIVER_PRIVATE_DATA *Private; SD_DEVICE *Device; EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru; EFI_BLOCK_IO2_PROTOCOL *BlockIo2; EFI_BLOCK_IO_PROTOCOL *BlockIo; LIST_ENTRY *Link; LIST_ENTRY *NextLink; SD_REQUEST *Request; EFI_TPL OldTpl; if (NumberOfChildren == 0) { Status = gBS->OpenProtocol ( Controller, &gEfiCallerIdGuid, (VOID **) &Private, This->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; } gBS->UninstallProtocolInterface ( Controller, &gEfiCallerIdGuid, Private ); gBS->CloseProtocol ( Controller, &gEfiSdMmcPassThruProtocolGuid, This->DriverBindingHandle, Controller ); FreePool (Private); return EFI_SUCCESS; } AllChildrenStopped = TRUE; for (Index = 0; Index < NumberOfChildren; Index++) { BlockIo = NULL; BlockIo2 = NULL; Status = gBS->OpenProtocol ( ChildHandleBuffer[Index], &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo, This->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { Status = gBS->OpenProtocol ( ChildHandleBuffer[Index], &gEfiBlockIo2ProtocolGuid, (VOID **) &BlockIo2, This->DriverBindingHandle, Controller, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { AllChildrenStopped = FALSE; continue; } } if (BlockIo != NULL) { Device = SD_DEVICE_DATA_FROM_BLKIO (BlockIo); } else { ASSERT (BlockIo2 != NULL); Device = SD_DEVICE_DATA_FROM_BLKIO2 (BlockIo2); } // // Free all on-going async tasks. // OldTpl = gBS->RaiseTPL (TPL_NOTIFY); for (Link = GetFirstNode (&Device->Queue); !IsNull (&Device->Queue, Link); Link = NextLink) { NextLink = GetNextNode (&Device->Queue, Link); RemoveEntryList (Link); Request = SD_REQUEST_FROM_LINK (Link); gBS->CloseEvent (Request->Event); Request->Token->TransactionStatus = EFI_ABORTED; if (Request->IsEnd) { gBS->SignalEvent (Request->Token->Event); } FreePool (Request); } gBS->RestoreTPL (OldTpl); // // Close the child handle // Status = gBS->CloseProtocol ( Controller, &gEfiSdMmcPassThruProtocolGuid, This->DriverBindingHandle, ChildHandleBuffer[Index] ); Status = gBS->UninstallMultipleProtocolInterfaces ( ChildHandleBuffer[Index], &gEfiDevicePathProtocolGuid, Device->DevicePath, &gEfiBlockIoProtocolGuid, &Device->BlockIo, &gEfiBlockIo2ProtocolGuid, &Device->BlockIo2, &gEfiEraseBlockProtocolGuid, &Device->EraseBlock, NULL ); if (EFI_ERROR (Status)) { AllChildrenStopped = FALSE; gBS->OpenProtocol ( Controller, &gEfiSdMmcPassThruProtocolGuid, (VOID **)&PassThru, This->DriverBindingHandle, ChildHandleBuffer[Index], EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER ); } else { FreePool (Device->DevicePath); FreeUnicodeStringTable (Device->ControllerNameTable); FreePool (Device); } } if (!AllChildrenStopped) { return EFI_DEVICE_ERROR; } return EFI_SUCCESS; }
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const { w.DrawRect(r, paper); if(!IsNull(q)) RichPara::DrawRuler(w, r.left, (r.top + r.bottom) / 2 - 1, r.Width(), 2, ink, q); }
ExternalProcess::ExternalProcess() : UIObject( (*API->ExternalProcess->CreateExternalProcess)( ModuleHandle(), this ) ) { if ( IsNull() ) throw APIFunctionError( "CreateExternalProcess" ); }
std::string PDFDate::ToString() { if(IsNull()) return scEmpty; char buffer[24]; bool wroteSomethingLater = false; // UTC info if(UTC != PDFDate::eUndefined) { if(PDFDate::eSame == UTC) { buffer[17] = '\0'; buffer[16] = 'Z'; } else { buffer[23] = '\0'; buffer[22] = '\''; buffer[21] = '0' + ((-1 == MinuteFromUTC ? 0:MinuteFromUTC) % 10); buffer[20] = '0' + ((-1 == MinuteFromUTC ? 0:MinuteFromUTC) / 10); buffer[19] = '\''; buffer[18] = '0' + ((-1 == HourFromUTC ? 0:HourFromUTC) % 10); buffer[17] = '0' + ((-1 == HourFromUTC ? 0:HourFromUTC) / 10); buffer[16] = (PDFDate::eLater == UTC )? '+':'-'; } wroteSomethingLater = true; } // Second if(Second != -1 || wroteSomethingLater) { if(!wroteSomethingLater) { wroteSomethingLater = true; buffer[16] = '\0'; } buffer[15] = '0' + ((-1 == Second ? 0:Second) % 10); buffer[14] = '0' + ((-1 == Second ? 0:Second) / 10); } // Minute if(Minute != -1 || wroteSomethingLater) { if(!wroteSomethingLater) { wroteSomethingLater = true; buffer[14] = '\0'; } buffer[13] = '0' + ((-1 == Minute ? 0:Minute) % 10); buffer[12] = '0' + ((-1 == Minute ? 0:Minute) / 10); } // Hour if(Hour != -1 || wroteSomethingLater) { if(!wroteSomethingLater) { wroteSomethingLater = true; buffer[12] = '\0'; } buffer[11] = '0' + ((-1 == Hour ? 0:Hour) % 10); buffer[10] = '0' + ((-1 == Hour ? 0:Hour) / 10); } // Day if(Day != -1 || wroteSomethingLater) { if(!wroteSomethingLater) { wroteSomethingLater = true; buffer[10] = '\0'; } buffer[9] = '0' + ((-1 == Day ? 1:Day) % 10); buffer[8] = '0' + ((-1 == Day ? 1:Day) / 10); } // Month if(Month != -1 || wroteSomethingLater) { if(!wroteSomethingLater) { wroteSomethingLater = true; buffer[8] = '\0'; } buffer[7] = '0' + ((-1 == Month ? 1:Month) % 10); buffer[6] = '0' + ((-1 == Month ? 1:Month) / 10); } // Year [bug 10K waiting to happen!!!!111] if(!wroteSomethingLater) buffer[6] = '\0'; buffer[5] = '0' + Year % 10; buffer[4] = '0' + (Year/10) % 10; buffer[3] = '0' + (Year/100) % 10; buffer[2] = '0' + (Year/1000) % 10; buffer[1] = ':'; buffer[0] = 'D'; return std::string(buffer); }
void DrawPolyPolyPolygon(Draw& draw, const Point *vertices, int vertex_count, const int *subpolygon_counts, int subpolygon_count_count, const int *disjunct_polygon_counts, int disjunct_polygon_count_count, Color color, int width, Color outline, uint64 pattern, Color doxor) { if(vertex_count == 0) return; #ifdef PLATFORM_WIN32_ //!!TODO if(PdfDraw *pdf = dynamic_cast<PdfDraw *>(&draw)) { pdf->DrawPolyPolyPolygon(vertices, vertex_count, subpolygon_counts, subpolygon_count_count, disjunct_polygon_counts, disjunct_polygon_count_count, color, width, outline, pattern, doxor); return; } #endif // LOG("DrawPolyPolyPolygon: drawing = " << (draw.IsDrawing() ? "yes" : "no") // << ", backdraw = " << (draw.IsBack() ? "yes" : "no") // << ", " << (draw.Dots() ? "dots" : "pixels") // << ", printer = " << (draw.IsPrinter() ? "yes" : "no")); // LOG("#vertices = " << vertex_count << ", #subpolygons = " << subpolygon_count_count // << ", #disjunct polygons = " << disjunct_polygon_count_count); // LOG("color = " << Dump(color) << ", width = " << width << ", outline = " << Dump(outline) // << ", pattern = " << Dump(pattern) << ", doxor = " << doxor); #ifdef _DEBUG // for(int v = 0; v < vertex_count; v++) // if(abs2(vertices[v] - vertices[(v ? v : vertex_count) - 1]) >= 500 * 500) // NEVER(); #endif if(!dynamic_cast<SystemDraw *>(&draw)) { draw.DrawPolyPolyPolygon(vertices, vertex_count, subpolygon_counts, subpolygon_count_count, disjunct_polygon_counts, disjunct_polygon_count_count, color, width, outline, pattern, doxor); return; } // TIMING("DrawPolyPolygon/hdc"); bool is_xor = !IsNull(doxor); #ifdef PLATFORM_X11 unsigned xor_pixel = (is_xor ? GetXPixel(doxor) : 0); XGCValues gcv; gcv.function = is_xor ? X11_ROP2_XOR : X11_ROP2_COPY; GC fill_gc = NULL; Image pattern_image; if(!IsNull(color)) { gcv.foreground = GetXPixel(color) ^ xor_pixel; int fmask = GCForeground | GCFunction; if(pattern) { pattern_image = GetPatternImage(pattern); gcv.stipple = pattern_image.GetMaskPixmap(); gcv.fill_style = FillStippled; fmask |= GCStipple | GCFillStyle; } fill_gc = XCreateGC(Xdisplay, draw.GetDrawable(), fmask, &gcv); } GC line_gc = NULL; if(!IsNull(outline)) { gcv.foreground = GetXPixel(outline) ^ xor_pixel; gcv.line_width = width; line_gc = XCreateGC(Xdisplay, draw.GetDrawable(), GCForeground | GCFunction | GCLineWidth, &gcv); Point offset = draw.GetOffset(); } #endif for(int i = 0; i < disjunct_polygon_count_count; i++, disjunct_polygon_counts++) { int poly = *disjunct_polygon_counts; int sub = 1; if(*subpolygon_counts < poly) if(disjunct_polygon_count_count > 1) { const int *se = subpolygon_counts; int total = 0; while(total < poly) total += *se++; sub = se - subpolygon_counts; } else sub = subpolygon_count_count; if(sub > poly) { vertices += poly; subpolygon_counts += sub; continue; } #if defined(PLATFORM_WIN32) #ifdef SYSTEMDRAW SystemDraw *w = dynamic_cast<SystemDraw *>(&draw); if(w) { SystemDraw& draw = *w; #endif if(pattern) { int old_rop = GetROP2(draw); HGDIOBJ old_brush = GetCurrentObject(draw, OBJ_BRUSH); word wpat[8] = { (byte)(pattern >> 56), (byte)(pattern >> 48), (byte)(pattern >> 40), (byte)(pattern >> 32), (byte)(pattern >> 24), (byte)(pattern >> 16), (byte)(pattern >> 8), (byte)(pattern >> 0), }; HBITMAP bitmap = CreateBitmap(8, 8, 1, 1, wpat); HBRUSH brush = ::CreatePatternBrush(bitmap); COLORREF old_bk = GetBkColor(draw); COLORREF old_fg = GetTextColor(draw); if(!is_xor) { SetROP2(draw, R2_MASKPEN); SelectObject(draw, brush); SetTextColor(draw, Black()); SetBkColor(draw, White()); DrawPolyPolygonRaw(draw, vertices, poly, subpolygon_counts, sub, true, PEN_NULL, Null); SetROP2(draw, R2_MERGEPEN); SetTextColor(draw, color); SetBkColor(draw, Black()); } else { // xor fill with pattern data SetROP2(draw, R2_XORPEN); SelectObject(draw, brush); } DrawPolyPolygonRaw(draw, vertices, poly, subpolygon_counts, sub, true, PEN_NULL, Null); SelectObject(draw, old_brush); SetTextColor(draw, old_fg); SetBkColor(draw, old_bk); SetROP2(draw, old_rop); DeleteObject(brush); DeleteObject(bitmap); if(!IsNull(outline)) { draw.SetColor(Null); draw.SetDrawPen(width, outline); ASSERT(sizeof(POINT) == sizeof(Point)); PolyPolygon(draw, (const POINT *)vertices, subpolygon_counts, sub); } } else { // simple fill // RTIMING("AreaTool::Fill(solid color)"); int out_wd = (IsNull(width) || IsNull(outline) ? PEN_NULL : width); Color out_co = Nvl(outline, Black); draw.SetDrawPen(out_wd, out_co); if(is_xor) { color = Color(color.GetR() ^ doxor.GetR(), color.GetG() ^ doxor.GetG(), color.GetB() ^ doxor.GetB()); SetROP2(draw, R2_XORPEN); } HGDIOBJ old_brush = 0; if(IsNull(color)) { static HGDIOBJ null_brush = GetStockObject(NULL_BRUSH); old_brush = SelectObject(draw, null_brush); } else draw.SetColor(color); DrawPolyPolygonRaw(draw, vertices, poly, subpolygon_counts, sub, !IsNull(color), out_wd, out_co); if(old_brush) SelectObject(draw, old_brush); if(is_xor) SetROP2(draw, R2_COPYPEN); } #ifdef SYSTEMDRAW } #endif #elif defined(PLATFORM_X11) if(fill_gc) FillPolyPolygonRaw(fill_gc, draw.GetDrawable(), draw.GetClip(), draw.GetOffset(), vertices, poly, subpolygon_counts, sub); if(line_gc) DrawPolyPolygonRaw(line_gc, draw.GetDrawable(), draw.GetOffset(), vertices, poly, subpolygon_counts, sub); #else #error #endif vertices += poly; subpolygon_counts += sub; }
Size ParentCtrl::GetMinSize() const { return IsNull(minsize) ? Ctrl::GetMinSize() : minsize; }
Date Value::GetOtherDate() const { if(IsNull()) return Null; return GetSmall<Time>(); }