void IPCQueueEvent(int argc, char** argv, PLSOBJECT Object) { char* Name = argv[0]; LSTypeDefinition* Type = pLSInterface->FindLSType(argv[1]); char* SubType = argv[2]; char* Method = argv[3]; LSOBJECT queueobject; if((queueobject.Ptr = FindQueue(Name)) == 0) { queueobject.Ptr = new LSQueue(Type, SubType); AddQueue(Name, (LSQueue*)queueobject.Ptr); } pQueueType->GetMethodEx(queueobject.GetObjectData(), Method, argc - 4, &argv[4]); }
/*@ XPrinterDevice::SetupPrinter(char *title, XFrameWindow * owner, XString * queueName, XString * fileName) @remarks Let the user select the printer-queue in a dialog. The dialog is loaded from OOLRES.DLL which must be installed. @parameters <t 'ø' c=2> øchar *title øthe title of the dialog øXFrameWindow * owner øowner window. If NULL, the dialog for the printer-setup is not opened and the queue given in parameter 3 is initialized directly øXString * queueName ødefault queue-name (can be null) øXString * fileName øbuffer for a fileName if the user wants to print to a file (if NULL no fiflename is stored) </t> @returns BOOL success */ BOOL XPrinterDevice::SetupPrinter(const char *title, const XFrameWindow * owner, XString * queueName, XString * fileName) { BOOL fOK; CHAR szDefaultQueue[196]; CHAR szSavedQueue[196]; CHAR szWork[196]; PCHAR pch; PPRQINFO3 pqi; SIZEL sizel; ULONG cReturned; ULONG cTotal; ULONG cbNeeded; ULONG ul; ULONG ulrc; // Caller must set these items before calling. if (!pSetup->hab || !pSetup->lWorldCoordinates) return FALSE; // no good unless I can open a PS pSetup->pDevOpenData = NULL; // Close the info DC's and PS's from any previous call. if (pSetup->hpsPrinterInfo) { GpiAssociate(pSetup->hpsPrinterInfo, (HDC) 0); GpiDestroyPS(pSetup->hpsPrinterInfo); pSetup->hpsPrinterInfo = (HPS) 0; } if (pSetup->hdcPrinterInfo) { DevCloseDC(pSetup->hdcPrinterInfo); pSetup->hdcPrinterInfo = (HDC) 0; } if (pSetup->pQueueInfo) { // Free the array of PRQINFO3 from previous call. free(pSetup->pQueueInfo); pSetup->pQueueInfo = NULL; } // Query how many queues exist on this computer and the // number of bytes needed to hold the array. ul = SplEnumQueue(NULL, 3, NULL, 0, &cReturned, &cTotal, &cbNeeded, NULL); if (cTotal == 0) { // There are no queues on this computer! pSetup->cQueues = 0; return FALSE; } // Allocate memory to store the newly enumerated queue information. pSetup->pQueueInfo = (PRQINFO3 *) malloc(cbNeeded); if (!pSetup->pQueueInfo) return FALSE; // Call system again to get the array of PRQINFO3 structures. ul = SplEnumQueue(NULL, 3, pSetup->pQueueInfo, cbNeeded, &cReturned, &cTotal, &cbNeeded, NULL); if (ul != 0 || cReturned != cTotal) return FALSE; pSetup->cQueues = cReturned; // Establish a default queue -- might need it. // Profiled queue name ends with a semicolon. ul = PrfQueryProfileString(HINI_PROFILE, (PSZ) "PM_SPOOLER", (PSZ) "QUEUE", NULL, szDefaultQueue, 196); if (ul > 1) { // Trim off semicolon. pch = strchr(szDefaultQueue, ';'); *pch = 0; } else { // Hmmmm. Use the first one queue from the enumeration. strcpy(szDefaultQueue, (char*) pSetup->pQueueInfo->pszName); } if (!strlen(szDefaultQueue)) return FALSE; if (0 == strlen(pSetup->szPreferredQueue)) { // No queue preference; use default. strcpy(pSetup->szPreferredQueue, szDefaultQueue); // Don't expect to see DRIVDATA without queue name. // if(! pSetup->pDriverData ) return FALSE; } if (queueName) { if (!queueName->IsEmpty()) { pSetup->fToFile = FALSE; strcpy(pSetup->szPreferredQueue, (char *) *queueName); } if (fileName) { if (!fileName->IsEmpty()) { pSetup->fToFile = TRUE; strcpy(pSetup->szFileName, (char *) *fileName); } } } pqi = FindQueue(pSetup); if (!pqi) { strcpy(pSetup->szPreferredQueue, szDefaultQueue); if (pSetup->pDriverData) { free(pSetup->pDriverData); pSetup->pDriverData = NULL; } } else { fOK = TRUE; if (pSetup->pDriverData) { fOK = fOK && (pqi->pDriverData->cb == pSetup->pDriverData->cb); fOK = fOK && (0 == strcmp(pqi->pDriverData->szDeviceName, pSetup->pDriverData->szDeviceName)); } if (!fOK) { free(pSetup->pDriverData); pSetup->pDriverData = NULL; } } pqi = FindQueue(pSetup); if (!pSetup->pDriverData) { pSetup->pDriverData = (DRIVDATA *) malloc(pqi->pDriverData->cb); if (!pSetup->pDriverData) { ulrc = FALSE; return ulrc; } memcpy(pSetup->pDriverData, pqi->pDriverData, pqi->pDriverData->cb); } if (!pSetup->pDriverData || pSetup->pDriverData->cb <= 0 || pSetup->pDriverData->cb != pqi->pDriverData->cb || strcmp(pqi->pDriverData->szDeviceName, pSetup->pDriverData->szDeviceName)) return FALSE; memcpy(pqi->pDriverData, pSetup->pDriverData, pSetup->pDriverData->cb); strcpy(szSavedQueue, pSetup->szPreferredQueue); if (owner) { XCountryInfo info; XResourceLibrary lib( "oolres"); LONG dlgID; switch (info.GetCountry()) { case 39: // italy dlgID = IDD_SELPRINT_ITA; break; case 2: // can francais case 33: // france case 32: // belgien dlgID = IDD_SELPRINT_FRA; break; case 49: // german dlgID = IDD_SELPRINT_GER; break; default: // english dlgID = IDD_SELPRINT_ENG; } XResource res(dlgID, &lib); PrinterDialog *printerDialog = new PrinterDialog(owner, pSetup, &res); // printerDialog->SetText((char*) title); LONG result = printerDialog->Start(); if (result == DID_CANCEL) return FALSE; } else { if (queueName) { pSetup->fToFile = FALSE; strcpy(pSetup->szPreferredQueue, (char *) *queueName); if (fileName) { pSetup->fToFile = TRUE; strcpy(pSetup->szFileName, (char *) *fileName); } } } *queueName = ""; *fileName = ""; pqi = FindQueue(pSetup); if (!pqi) return FALSE; if (0 != strcmp(szSavedQueue, pSetup->szPreferredQueue)) { if (!pSetup->pDriverData) return FALSE; free(pSetup->pDriverData); pSetup->pDriverData = (DRIVDATA *) malloc(pqi->pDriverData->cb); if (!pSetup->pDriverData) { ulrc = FALSE; return ulrc; } pSetup->pDriverData->cb = pqi->pDriverData->cb; } if (!pSetup->pDriverData || !pSetup->pDriverData->cb == pqi->pDriverData->cb) return FALSE; memcpy(pSetup->pDriverData, pqi->pDriverData, pqi->pDriverData->cb); if (pSetup->fToFile) { pSetup->lDCType = OD_DIRECT; pSetup->devopenstruc.pszLogAddress = (PSZ) pSetup->szFileName; } else { pSetup->lDCType = OD_QUEUED; pSetup->devopenstruc.pszLogAddress = (PSZ) pSetup->szPreferredQueue; } strcpy(szWork, (char*) pqi->pszDriverName); pch = strchr(szWork, '.'); if (pch) *pch = 0; if (pSetup->devopenstruc.pszDriverName) free(pSetup->devopenstruc.pszDriverName); pSetup->devopenstruc.pszDriverName = (PSZ) malloc(1 + strlen(szWork)); if (!pSetup->devopenstruc.pszDriverName) return FALSE; strcpy( (char*) pSetup->devopenstruc.pszDriverName, szWork); pSetup->devopenstruc.pdriv = pSetup->pDriverData; pSetup->devopenstruc.pszDataType = (PSZ) "PM_Q_STD"; pSetup->hdcPrinterInfo = DevOpenDC(pSetup->hab, OD_INFO, (PSZ) "*", 4, (PDEVOPENDATA) & pSetup->devopenstruc, (HDC) 0); if (!pSetup->hdcPrinterInfo) return FALSE; sizel.cx = 0; sizel.cy = 0; pSetup->hpsPrinterInfo = GpiCreatePS(pSetup->hab, pSetup->hdcPrinterInfo, &sizel, pSetup->lWorldCoordinates | GPIA_ASSOC); if (GPI_ERROR == pSetup->hpsPrinterInfo) { DevCloseDC(pSetup->hdcPrinterInfo); pSetup->hdcPrinterInfo = (HDC) 0; pSetup->hpsPrinterInfo = (HPS) 0; return FALSE; } pSetup->pDevOpenData = (PDEVOPENDATA) & pSetup->devopenstruc; *queueName = pSetup->szPreferredQueue; if (pSetup->fToFile) *fileName = pSetup->szFileName; return TRUE; }
bool IPCQueueType::GetMethod(LSOBJECTDATA &ObjectData, PLSTYPEMETHOD pMethod, int argc, char *argv[]) { /******************************************* * Parameters * * [in] LSOBJECTDATA ObjectData: ObjectData is a 32-bit value that can be accessed in any number of different ways * by way of union. Most commonly, ObjectData.Ptr, ObjectData.DWord, or ObjectData.CharPtr are useful. This * value is the representation of some object of this object type. "ipcfoo" works on IPCFoo* * so ObjectData is a IPCFoo* * * [in] PLSTYPEMETHOD pMethod: pMethod is a pointer to the information on the method to be retrieved, including its * Name and ID. We use the ID in a switch statement in order to quickly process the method, since the Name * has already been resolved by the LavishScript engine. * * [in] int argc, char *argv[]: argc and argv are *nearly* standard C console program parameters. The difference here * is that the name of the method is NOT given as the first argument (in contrast to LavishScript commands). * Therefore, argc is 0 unless arguments are specifically given to the method retrieval. */ /******************************************* * Return Value * * The return value for this function is very simple. If the method execution fails for any reason, OR the object * is destroyed during execution, return false. Otherwise, return true (indicating the object still exists AND * the method execution succeeded). * */ /* Validate the pointer */ if (!pQueue) return false; /* Perform the given member retrieval */ switch(pMethod->ID) { case Queue: pQueue->Queue->Queue(argc, argv); QueueRelay(pQueue->IPCName, pQueue->Type->GetName(), pQueue->SubType, "Queue", argc, argv); return true; case Dequeue: pQueue->Queue->Dequeue(); QueueRelay(pQueue->IPCName, pQueue->Type->GetName(), pQueue->SubType, "Dequeue", argc, argv); return true; case Clear: pQueue->Queue->Clear(); QueueRelay(pQueue->IPCName, pQueue->Type->GetName(), pQueue->SubType, "Clear", argc, argv); return true; case Set: case SetIPCName: if(argc) { LSQueue *newQueue; strncpy(pQueue->IPCName, argv[0], sizeof(pQueue->IPCName)); if((newQueue=FindQueue(pQueue->IPCName))==0) { newQueue = new LSQueue(pQueue->Type, pQueue->SubType); AddQueue(pQueue->IPCName, newQueue); } pQueue->Queue = newQueue; return true; } return false; case GetIterator: LSOBJECT iteratorobject; if(argc) { //printf("%s %s %d", argv[0], pQueue->IPCName, pQueue->Queue->GetContainerUsed()); if(pLSInterface->DataParse(argv[0], iteratorobject)) { return InitializeIterator(pQueue->Queue, 0, iteratorobject); } } return false; } return false; }
// コンテキスト作成 bool InitializeContext() { // Vulkanインスタンスを作成 { vk::ApplicationInfo appInfo; appInfo.pApplicationName = "VulkanSample"; appInfo.pEngineName = "VulkanSample"; appInfo.apiVersion = VK_API_VERSION_1_0; // Extension const char* extensions[] = { VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_WIN32_SURFACE_EXTENSION_NAME, // Windows用Extension #if defined(_DEBUG) VK_EXT_DEBUG_REPORT_EXTENSION_NAME, // デバッグレポート用Extension #endif }; // インスタンス生成情報 vk::InstanceCreateInfo createInfo; createInfo.pApplicationInfo = &appInfo; createInfo.enabledExtensionCount = ARRAYSIZE(extensions); createInfo.ppEnabledExtensionNames = extensions; #if defined(_DEBUG) // デバッグ関連 createInfo.enabledLayerCount = ARRAYSIZE(kDebugLayerNames); createInfo.ppEnabledLayerNames = kDebugLayerNames; #endif // インスタンス生成 g_VkInstance = vk::createInstance(createInfo); if (!g_VkInstance) { return false; } } // 物理デバイス g_VkPhysicalDevice = g_VkInstance.enumeratePhysicalDevices()[0]; { struct Version { uint32_t patch : 12; uint32_t minor : 10; uint32_t major : 10; } _version; vk::PhysicalDeviceProperties deviceProperties = g_VkPhysicalDevice.getProperties(); memcpy(&_version, &deviceProperties.apiVersion, sizeof(uint32_t)); vk::PhysicalDeviceFeatures deviceFeatures = g_VkPhysicalDevice.getFeatures(); vk::PhysicalDeviceMemoryProperties deviceMemoryProperties = g_VkPhysicalDevice.getMemoryProperties(); // プロパティやFeatureの確認はここで行う } // Vulkan device uint32_t graphicsQueueIndex = 0; { // グラフィクス用のキューを検索する graphicsQueueIndex = FindQueue(vk::QueueFlagBits::eGraphics); float queuePriorities[] = { 0.0f }; vk::DeviceQueueCreateInfo queueCreateInfo; queueCreateInfo.queueFamilyIndex = graphicsQueueIndex; queueCreateInfo.queueCount = 1; queueCreateInfo.pQueuePriorities = queuePriorities; vk::PhysicalDeviceFeatures deviceFeatures = g_VkPhysicalDevice.getFeatures(); const char* enabledExtensions[] = { VK_KHR_SWAPCHAIN_EXTENSION_NAME, #if defined(_DEBUG) //VK_EXT_DEBUG_MARKER_EXTENSION_NAME, #endif }; vk::DeviceCreateInfo deviceCreateInfo; deviceCreateInfo.queueCreateInfoCount = 1; deviceCreateInfo.pQueueCreateInfos = &queueCreateInfo; deviceCreateInfo.pEnabledFeatures = &deviceFeatures; deviceCreateInfo.enabledExtensionCount = (uint32_t)ARRAYSIZE(enabledExtensions); deviceCreateInfo.ppEnabledExtensionNames = enabledExtensions; deviceCreateInfo.enabledLayerCount = ARRAYSIZE(kDebugLayerNames); deviceCreateInfo.ppEnabledLayerNames = kDebugLayerNames; g_VkDevice = g_VkPhysicalDevice.createDevice(deviceCreateInfo); } #if defined(_DEBUG) // デバッグ用コールバック設定 { g_fCreateDebugReportCallback = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(g_VkInstance, "vkCreateDebugReportCallbackEXT"); g_fDestroyDebugReportCallback = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_VkInstance, "vkDestroyDebugReportCallbackEXT"); g_fDebugBreakCallback = (PFN_vkDebugReportMessageEXT)vkGetInstanceProcAddr(g_VkInstance, "vkDebugReportMessageEXT"); VkDebugReportCallbackCreateInfoEXT dbgCreateInfo = {}; vk::DebugReportFlagsEXT flags = vk::DebugReportFlagBitsEXT::eError | vk::DebugReportFlagBitsEXT::eWarning; dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; dbgCreateInfo.pfnCallback = (PFN_vkDebugReportCallbackEXT)DebugMessageCallback; dbgCreateInfo.flags = flags.operator VkSubpassDescriptionFlags(); VkResult err = g_fCreateDebugReportCallback(g_VkInstance, &dbgCreateInfo, nullptr, &g_fMsgCallback); assert(!err); } #endif g_VkPipelineCache = g_VkDevice.createPipelineCache(vk::PipelineCacheCreateInfo()); g_VkQueue = g_VkDevice.getQueue(graphicsQueueIndex, 0); // コマンドプール作成 vk::CommandPoolCreateInfo cmdPoolInfo; cmdPoolInfo.queueFamilyIndex = graphicsQueueIndex; cmdPoolInfo.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer; g_VkCmdPool = g_VkDevice.createCommandPool(cmdPoolInfo); return true; }