{"text":"\/*************************************************************************\n *\n * $RCSfile: FilterContainer.hxx,v $\n *\n * $Revision: 1.1 $\n *\n * last change: $Author: tra $ $Date: 2001-06-28 11:13:03 $\n *\n * The Contents of this file are made available subject to the terms of\n * either of the following licenses\n *\n * - GNU Lesser General Public License Version 2.1\n * - Sun Industry Standards Source License Version 1.1\n *\n * Sun Microsystems Inc., October, 2000\n *\n * GNU Lesser General Public License Version 2.1\n * =============================================\n * Copyright 2000 by Sun Microsystems, Inc.\n * 901 San Antonio Road, Palo Alto, CA 94303, USA\n *\n * This library is free software; you can redistribute it and\/or\n * modify it under the terms of the GNU Lesser General Public\n * License version 2.1, as published by the Free Software Foundation.\n *\n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this library; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place, Suite 330, Boston,\n * MA 02111-1307 USA\n *\n *\n * Sun Industry Standards Source License Version 1.1\n * =================================================\n * The contents of this file are subject to the Sun Industry Standards\n * Source License Version 1.1 (the \"License\"); You may not use this file\n * except in compliance with the License. You may obtain a copy of the\n * License at http:\/\/www.openoffice.org\/license.html.\n *\n * Software provided under this License is provided on an \"AS IS\" basis,\n * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,\n * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,\n * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.\n * See the License for the specific provisions governing your rights and\n * obligations concerning the Software.\n *\n * The Initial Developer of the Original Code is: Sun Microsystems, Inc.\n *\n * Copyright: 2000 by Sun Microsystems, Inc.\n *\n * All Rights Reserved.\n *\n * Contributor(s): _______________________________________\n *\n *\n ************************************************************************\/\n\n#ifndef _FILTER_CONTAINER_HXX_\n#define _FILTER_CONTAINER_HXX_\n\n#ifndef _SAL_TYPES_H_\n#include \n#endif\n\n#ifndef _RTL_USTRING_\n#include \n#endif\n\n#include \n\n\/\/------------------------------------------------------\n\/\/ helper class, only useable by OFilterContainer\n\/\/------------------------------------------------------\n\nclass CFilterContainer\n{\npublic:\n \/\/ defines a filter entry which is made of a name and a filter value\n \/\/ e.g. 'Text *.txt'\n typedef std::pair< rtl::OUString, rtl::OUString > FILTER_ENTRY_T;\n\npublic:\n explicit CFilterContainer( sal_Int32 initSize = 0 );\n\n \/\/ add a new filter\n \/\/ returns true if the filter was successfully added\n \/\/ returns false if duplicates are not allowed and\n \/\/ the filter is already in the container\n sal_Bool SAL_CALL addFilter(\n const ::rtl::OUString& aName,\n const ::rtl::OUString& aFilter,\n sal_Bool bAllowDuplicates = sal_False );\n\n \/\/ delete the specified filter returns true on\n \/\/ success and false if the filter was not found\n sal_Bool SAL_CALL delFilter( const ::rtl::OUString& aName );\n\n \/\/ the number of filter already added\n sal_Int32 SAL_CALL numFilter( );\n\n \/\/ clear all entries\n void SAL_CALL empty( );\n\n \/\/ retrieve a filter from the container both methods\n \/\/ return true on success and false if the specified\n \/\/ filter was not found\n sal_Bool SAL_CALL getFilter( const ::rtl::OUString& aName, ::rtl::OUString& theFilter ) const;\n sal_Bool SAL_CALL getFilter( sal_Int32 aIndex, ::rtl::OUString& theFilter ) const;\n\n \/\/ returns the position of the specified filter or -1\n \/\/ if the filter was not found\n sal_Int32 SAL_CALL getFilterPos( const ::rtl::OUString& aName ) const;\n\n \/\/ starts enumerating the filter in the container\n void SAL_CALL beginEnumFilter( );\n\n \/\/ returns true if another filter has been retrieved\n sal_Bool SAL_CALL getNextFilter( FILTER_ENTRY_T& nextFilterEntry );\n\nprotected:\n typedef std::vector< FILTER_ENTRY_T > FILTER_VECTOR_T;\n\nprivate:\n \/\/ prevent copy and assignment\n CFilterContainer( const CFilterContainer& );\n CFilterContainer& SAL_CALL operator=( const CFilterContainer& );\n\n sal_Int32 SAL_CALL getFilterTagPos( const ::rtl::OUString& aName ) const;\n\nprivate:\n FILTER_VECTOR_T m_vFilters;\n FILTER_VECTOR_T::const_iterator m_iter;\n sal_Bool m_bIterInitialized;\n};\n\n\/\/----------------------------------------------------------------\n\/\/ a helper function to create a filter buffer in the format\n\/\/ the Win32 API requires, e.g. \"Text\\0*.txt\\0Doc\\0*.doc;*xls\\0\\0\"\n\/\/----------------------------------------------------------------\n\nrtl::OUString SAL_CALL makeWinFilterBuffer( CFilterContainer& aFilterContainer );\n\n#endifINTEGRATION: CWS rt02 (1.1.72); FILE MERGED 2003\/10\/01 10:41:52 rt 1.1.72.1: #i19697# No newline at end of file\/*************************************************************************\n *\n * $RCSfile: FilterContainer.hxx,v $\n *\n * $Revision: 1.2 $\n *\n * last change: $Author: rt $ $Date: 2003-10-06 15:52:26 $\n *\n * The Contents of this file are made available subject to the terms of\n * either of the following licenses\n *\n * - GNU Lesser General Public License Version 2.1\n * - Sun Industry Standards Source License Version 1.1\n *\n * Sun Microsystems Inc., October, 2000\n *\n * GNU Lesser General Public License Version 2.1\n * =============================================\n * Copyright 2000 by Sun Microsystems, Inc.\n * 901 San Antonio Road, Palo Alto, CA 94303, USA\n *\n * This library is free software; you can redistribute it and\/or\n * modify it under the terms of the GNU Lesser General Public\n * License version 2.1, as published by the Free Software Foundation.\n *\n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this library; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place, Suite 330, Boston,\n * MA 02111-1307 USA\n *\n *\n * Sun Industry Standards Source License Version 1.1\n * =================================================\n * The contents of this file are subject to the Sun Industry Standards\n * Source License Version 1.1 (the \"License\"); You may not use this file\n * except in compliance with the License. You may obtain a copy of the\n * License at http:\/\/www.openoffice.org\/license.html.\n *\n * Software provided under this License is provided on an \"AS IS\" basis,\n * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,\n * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,\n * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.\n * See the License for the specific provisions governing your rights and\n * obligations concerning the Software.\n *\n * The Initial Developer of the Original Code is: Sun Microsystems, Inc.\n *\n * Copyright: 2000 by Sun Microsystems, Inc.\n *\n * All Rights Reserved.\n *\n * Contributor(s): _______________________________________\n *\n *\n ************************************************************************\/\n\n#ifndef _FILTER_CONTAINER_HXX_\n#define _FILTER_CONTAINER_HXX_\n\n#ifndef _SAL_TYPES_H_\n#include \n#endif\n\n#ifndef _RTL_USTRING_\n#include \n#endif\n\n#include \n\n\/\/------------------------------------------------------\n\/\/ helper class, only useable by OFilterContainer\n\/\/------------------------------------------------------\n\nclass CFilterContainer\n{\npublic:\n \/\/ defines a filter entry which is made of a name and a filter value\n \/\/ e.g. 'Text *.txt'\n typedef std::pair< rtl::OUString, rtl::OUString > FILTER_ENTRY_T;\n\npublic:\n explicit CFilterContainer( sal_Int32 initSize = 0 );\n\n \/\/ add a new filter\n \/\/ returns true if the filter was successfully added\n \/\/ returns false if duplicates are not allowed and\n \/\/ the filter is already in the container\n sal_Bool SAL_CALL addFilter(\n const ::rtl::OUString& aName,\n const ::rtl::OUString& aFilter,\n sal_Bool bAllowDuplicates = sal_False );\n\n \/\/ delete the specified filter returns true on\n \/\/ success and false if the filter was not found\n sal_Bool SAL_CALL delFilter( const ::rtl::OUString& aName );\n\n \/\/ the number of filter already added\n sal_Int32 SAL_CALL numFilter( );\n\n \/\/ clear all entries\n void SAL_CALL empty( );\n\n \/\/ retrieve a filter from the container both methods\n \/\/ return true on success and false if the specified\n \/\/ filter was not found\n sal_Bool SAL_CALL getFilter( const ::rtl::OUString& aName, ::rtl::OUString& theFilter ) const;\n sal_Bool SAL_CALL getFilter( sal_Int32 aIndex, ::rtl::OUString& theFilter ) const;\n\n \/\/ returns the position of the specified filter or -1\n \/\/ if the filter was not found\n sal_Int32 SAL_CALL getFilterPos( const ::rtl::OUString& aName ) const;\n\n \/\/ starts enumerating the filter in the container\n void SAL_CALL beginEnumFilter( );\n\n \/\/ returns true if another filter has been retrieved\n sal_Bool SAL_CALL getNextFilter( FILTER_ENTRY_T& nextFilterEntry );\n\nprotected:\n typedef std::vector< FILTER_ENTRY_T > FILTER_VECTOR_T;\n\nprivate:\n \/\/ prevent copy and assignment\n CFilterContainer( const CFilterContainer& );\n CFilterContainer& SAL_CALL operator=( const CFilterContainer& );\n\n sal_Int32 SAL_CALL getFilterTagPos( const ::rtl::OUString& aName ) const;\n\nprivate:\n FILTER_VECTOR_T m_vFilters;\n FILTER_VECTOR_T::const_iterator m_iter;\n sal_Bool m_bIterInitialized;\n};\n\n\/\/----------------------------------------------------------------\n\/\/ a helper function to create a filter buffer in the format\n\/\/ the Win32 API requires, e.g. \"Text\\0*.txt\\0Doc\\0*.doc;*xls\\0\\0\"\n\/\/----------------------------------------------------------------\n\nrtl::OUString SAL_CALL makeWinFilterBuffer( CFilterContainer& aFilterContainer );\n\n#endif\n<|endoftext|>"} {"text":"#include \n\nEngine::Engine(const int argc, const char** argv, const std::string& _name) :\n game(_name)\n{\n INFO(\"Initializing Engine with game data in '%s\", game.c_str());\n\n showBuildInfo(argv[0]);\n\n data_dir = game;\n\n readConfig();\n\n INFO(\"Creating %dx%d render target\", renderWidth, renderHeight);\n screen.create(renderWidth, renderHeight);\n\n createWindow(config.fullscreen);\n\n spritesMutex.lock();\n INFO(\"Creating entities\");\n player = std::make_shared(data_dir + \"\/player.yaml\");\n player->setPosition(renderWidth * 1 \/ 2, renderHeight * 3 \/ 4);\n sprites.push_back(player);\n INFO(\"Created player\");\n enemy = std::make_shared(data_dir + \"\/enemy.yaml\");\n enemy->setPosition(renderWidth * 1 \/ 2, renderHeight * 1 \/ 4);\n sprites.push_back(enemy);\n INFO(\"Created enemy\");\n spritesMutex.unlock();\n\n isReady = true;\n INFO(\"Initialization Complete\");\n}\n\nbool Engine::ready() {\n if (isReady) {\n INFO(\"Game of '%s' is ready\", config.name.c_str());\n } else {\n\n }\n return isReady;\n}\n\nbool Engine::run() {\n INFO(\"Starting a game of '%s'\", config.name.c_str());\n\n INFO(\"Creating Render thread\");\n releaseWindow();\n renderThread = std::make_unique(&Engine::renderLoop, this);\n\n INFO(\"Initializing event loop\");\n sf::Int32 updateHz = 60;\n sf::Int32 updateWaitTime = 1'000'000 \/ updateHz;\n sf::Clock gameClock;\n sf::Time elapsedTime;\n sf::Time lastUpdateTime;\n sf::Int64 totalUpdateTime = 0;\n sf::Int64 averageUpdateTime;\n sf::Int32 updateCount = 0;\n INFO(\"Starting event loop\");\n running = true;\n while (running) {\n elapsedTime = gameClock.restart();\n processEvents();\n update(elapsedTime);\n \/\/compute\n lastUpdateTime = gameClock.getElapsedTime();\n totalUpdateTime += lastUpdateTime.asMilliseconds();\n averageUpdateTime = totalUpdateTime \/ ++updateCount;\n \/\/ log the average time per update every 1 seconds\n if (updateCount % (60 * 1) == 0) {\n DBUG(\"Average update time: %d ms\", averageUpdateTime);\n }\n \/\/ update at approximately 60 Hz (16666us minus time taken by last update(\n sf::sleep(sf::microseconds(updateWaitTime - lastUpdateTime.asMicroseconds()));\n }\n INFO(\"Stopped event loop\");\n INFO(\"Joining render thread\");\n renderThread->join();\n INFO(\"Game of '%s' ended successfully\", config.name.c_str());\n return true;\n}\n\nvoid Engine::showBuildInfo(const char* name) {\n const uint32_t majorVersion = 0;\n const uint32_t minorVersion = 4;\n const uint32_t revision = 1;\n\n INFO(\"%s %d.%d.%d %s %s\", name, majorVersion, minorVersion, revision, __DATE__, __TIME__);\n\n INFO(\"SFML %d.%d\", SFML_VERSION_MAJOR, SFML_VERSION_MINOR);\n\n\/\/ what compiler are we using? just because\n#ifdef __MINGW32__\n#ifdef __MINGW64__\n INFO(\"MinGW-w64 %d.%d\", __MINGW64_VERSION_MAJOR, __MINGW64_VERSION_MINOR);\n#else\n INFO(\"MinGW %d.%d\", __MINGW32_MAJOR_VERSION, __MINGW32_MINOR_VERSION);\n#endif\n#endif\n\n#ifdef __clang__\n INFO(\"CLang %d.%d.%d\", __clang_major__, __clang_minor__, __clang_patchlevel__);\n#endif\n\n#ifdef __GNUG__\n INFO(\"GCC %s\", __VERSION__);\n#endif\n\n#ifdef MSC_VER\n INFO(\"Visual C++ %s\", _MCS_VER);\n#endif\n}\n\n\nvoid Engine::readConfig() {\n std::string configFilename = data_dir + \"\/config.yaml\";\n INFO(\"Reading config from '%s'\", configFilename.c_str());\n try {\n YAML::Node yamlConfig = YAML::LoadFile(configFilename);\n config.name = yamlConfig[\"name\"].as(game);\n config.width = yamlConfig[\"width\"].as(config.width);\n config.height = yamlConfig[\"height\"].as(config.height);\n config.fullscreen = yamlConfig[\"fullscreen\"].as(config.fullscreen);\n config.useDesktopSize = yamlConfig[\"useDesktopSize\"].as(config.useDesktopSize);\n config.vsync = yamlConfig[\"vsync\"].as(config.vsync);\n config.deadZone = yamlConfig[\"deadzone\"].as(config.deadZone);\n config.keySpeed = yamlConfig[\"keySpeed\"].as(config.keySpeed);\n } catch (YAML::Exception e) {\n ERR(\"YAML Exception: %s\", e.msg.c_str());\n ERR(\"Can't load '%s', using sane defaults\", configFilename.c_str());\n }\n INFO(\"Current settings:\");\n INFO(\"\\tname = %s\", config.name.c_str());\n INFO(\"\\twidth = %d\", config.width);\n INFO(\"\\theight = %d\", config.height);\n INFO(\"\\tfullscreen = %s\", (config.fullscreen ? \"true\" : \"false\"));\n INFO(\"\\tuseDesktopSize = %s\", (config.useDesktopSize ? \"true\" : \"false\"));\n INFO(\"\\tvsync = %s\", (config.vsync ? \"true\" : \"false\"));\n INFO(\"\\tdeadZone = %f\", config.deadZone);\n INFO(\"\\tkeySpeed = %f\", config.keySpeed);\n}\n\nvoid Engine::createWindow(bool shouldFullscreen) {\n unsigned int flags = 0;\n\n lockWindow();\n\n INFO(\"Reading config\");\n sf::VideoMode mode;\n config.fullscreen = shouldFullscreen;\n if (config.fullscreen) {\n INFO(\"Going fullscreen\");\n window.setMouseCursorVisible(false);\n if (config.useDesktopSize) {\n INFO(\"Setting fullscreen mode (using desktop size): %dx%d\",\n sf::VideoMode::getDesktopMode().width,\n sf::VideoMode::getDesktopMode().height);\n mode = sf::VideoMode::getDesktopMode();\n } else {\n INFO(\"Setting fullscreen mode: %dx%d\", config.width, config.height);\n mode = sf::VideoMode(config.width, config.height);\n }\n flags = sf::Style::Fullscreen;\n } else {\n INFO(\"Setting windowed mode: %dx%d\", config.width, config.height);\n window.setMouseCursorVisible(true);\n mode = sf::VideoMode(config.width, config.height);\n flags = sf::Style::Titlebar | sf::Style::Close | sf::Style::Resize;\n }\n INFO(\"Creating the main window\");\n window.create(mode, game, flags);\n if (!window.isOpen()) {\n ERR(\"Could not create main window\");\n exit(EXIT_FAILURE);\n }\n sf::ContextSettings settings = window.getSettings();\n INFO(\"Using OpenGL %d.%d\", settings.majorVersion, settings.minorVersion);\n\n \/\/ initialize the view\n INFO(\"Setting window view\");\n view = window.getDefaultView();\n view.setSize(renderWidth, renderHeight);\n view.setCenter(renderWidth \/ 2, renderHeight \/ 2);\n window.setView(view);\n if (config.vsync) {\n INFO(\"Enabling V-sync\");\n window.setVerticalSyncEnabled(true);\n }\n\n releaseWindow();\n\n \/\/ scale the viewport to maintain good aspect\n adjustAspect(window.getSize());\n}\n\nvoid Engine::adjustAspect(sf::Event::SizeEvent newSize) {\n \/\/ save the new window size since this came from a resize event\n \/\/ not from a window creation event (initialization or fullscreen toggle)\n config.width = newSize.width;\n config.height = newSize.height;\n INFO(\"Window resized to: %dx%d\", config.width, config.height);\n \/\/ do the calculation\n adjustAspect(sf::Vector2u(newSize.width, newSize.height));\n}\n\nvoid Engine::adjustAspect(sf::Vector2u newSize) {\n INFO(\"Adjusting aspect for window size \", newSize.x, newSize.y);\n \/\/ compute the current aspect\n float currentRatio = (float) newSize.x \/ (float) newSize.y;\n \/\/ used to offset and scale the viewport to maintain 16:9 aspect\n float widthScale = 1.0f;\n float widthOffset = 0.0f;\n float heightScale = 1.0f;\n float heightOffset = 0.0f;\n \/\/ used to compare and compute aspect ratios\n \/\/ for logging\n std::string isSixteenNine = \"16:9\";\n if (currentRatio > 16.0f \/ 9.0f) {\n \/\/ we are wider\n isSixteenNine = \"wide\";\n widthScale = newSize.y * (16.0f \/ 9.0f) \/ newSize.x;\n widthOffset = (1.0f - widthScale) \/ 2.0f;\n } else if (currentRatio < 16.0f \/ 9.0f) {\n \/\/ we are narrower\n isSixteenNine = \"narrow\";\n heightScale = newSize.x * (9.0f \/ 16.0f) \/ newSize.y;\n heightOffset = (1.0f - heightScale) \/ 2.0f;\n }\n lockWindow();\n INFO(\"Setting %s viewport (wo:%f, ho:%f; ws:%f, hs: %f\", isSixteenNine.c_str(),\n widthOffset, heightOffset, widthScale, heightScale);\n view.setViewport(sf::FloatRect(widthOffset, heightOffset, widthScale, heightScale));\n window.setView(view);\n releaseWindow();\n}\n\n\/\/#define LOG_WINDOW_MUTEX_LOCKS\nvoid inline Engine::lockWindow() {\n#ifdef LOG_WINDOW_MUTEX_LOCKS\n DBUG(\"Grabbing window lock\");\n#endif\n windowMutex.lock();\n window.setActive(true);\n}\n\nvoid inline Engine::releaseWindow() {\n#ifdef LOG_WINDOW_MUTEX_LOCKS\n DBUG(\"Releasing window lock\");\n#endif\n window.setActive(false);\n windowMutex.unlock();\n}\n\nvoid Engine::processEvents() {\n static sf::Event event;\n\n while (window.pollEvent(event)) {\n switch (event.type) {\n case sf::Event::Closed:\n INFO(\"Window closed\");\n running = false;\n break;\n case sf::Event::Resized:\n adjustAspect(event.size);\n break;\n case sf::Event::KeyPressed:\n handleKeyPress(event);\n break;\n case sf::Event::KeyReleased:\n handleKeyRelease(event);\n break;\n default:\n break;\n }\n }\n}\n\nvoid Engine::handleKeyPress(const sf::Event& event) {\n switch (event.key.code) {\n case sf::Keyboard::Escape:\n INFO(\"Key: Escape: exiting\");\n running = false;\n break;\n case sf::Keyboard::Return:\n if (event.key.alt) {\n createWindow(!config.fullscreen);\n }\n break;\n default:\n break;\n }\n}\n\nvoid Engine::handleKeyRelease(const sf::Event& event) {\n switch (event.key.code) {\n default:\n break;\n }\n}\n\nvoid Engine::update(sf::Time elapsed) {\n float x, y = 0;\n\n \/\/ get current state of controls\n float joy0_X = sf::Joystick::getAxisPosition(0, sf::Joystick::X);\n float joy0_y = sf::Joystick::getAxisPosition(0, sf::Joystick::Y);\n x = std::fabs(joy0_X) < config.deadZone ? 0 : joy0_X;\n y = std::fabs(joy0_y) < config.deadZone ? 0 : joy0_y;\n\n if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) {\n y += -config.keySpeed;\n }\n if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) {\n x += config.keySpeed;\n }\n if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) {\n y += config.keySpeed;\n }\n if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) {\n x += -config.keySpeed;\n }\n\n spritesMutex.lock();\n player->moveBy(x, y);\n\n const int millis = elapsed.asMilliseconds();\n for (auto sprite : sprites) {\n sprite->update(millis);\n }\n\n spritesMutex.unlock();\n}\n\nvoid Engine::renderLoop() {\n INFO(\"Initializing render loop\");\n sf::Clock frameClock;\n sf::Int32 lastFrameTime;\n sf::Int32 averageFrameTime;\n sf::Int32 totalFrameTime = 0;\n sf::Int32 frameCount = 0;\n INFO(\"Starting render loop\");\n while (running) {\n frameClock.restart();\n \/\/ blank the render target to black\n screen.clear(sf::Color::Black);\n \/\/ render all the normal sprites\n spritesMutex.lock();\n for (const auto sprite : sprites) {\n screen.draw(*sprite);\n }\n spritesMutex.unlock();\n \/\/ update the target\n screen.display();\n lockWindow();\n \/\/ blank the window to gray\n window.clear(sf::Color(128, 128, 128));\n \/\/ copy render target to window\n window.draw(sf::Sprite(screen.getTexture()));\n \/\/ update thw window\n window.display();\n releaseWindow();\n lastFrameTime = frameClock.getElapsedTime().asMilliseconds();\n totalFrameTime += lastFrameTime;\n averageFrameTime = totalFrameTime \/ ++frameCount;\n \/\/ log the time per frame every 60 frames (every second if at 60 Hz)\n if (frameCount % (60 * 1) == 0) {\n DBUG(\"Average frame time: %d ms\", averageFrameTime);\n }\n }\n spritesMutex.unlock();\n window.close();\n releaseWindow();\n INFO(\"Stopped render loop\");\n}\nClose the window after the render thread is completely done.#include \n\nEngine::Engine(const int argc, const char** argv, const std::string& _name) :\n game(_name)\n{\n INFO(\"Initializing Engine with game data in '%s\", game.c_str());\n\n showBuildInfo(argv[0]);\n\n data_dir = game;\n\n readConfig();\n\n INFO(\"Creating %dx%d render target\", renderWidth, renderHeight);\n screen.create(renderWidth, renderHeight);\n\n createWindow(config.fullscreen);\n\n spritesMutex.lock();\n INFO(\"Creating entities\");\n player = std::make_shared(data_dir + \"\/player.yaml\");\n player->setPosition(renderWidth * 1 \/ 2, renderHeight * 3 \/ 4);\n sprites.push_back(player);\n INFO(\"Created player\");\n enemy = std::make_shared(data_dir + \"\/enemy.yaml\");\n enemy->setPosition(renderWidth * 1 \/ 2, renderHeight * 1 \/ 4);\n sprites.push_back(enemy);\n INFO(\"Created enemy\");\n spritesMutex.unlock();\n\n isReady = true;\n INFO(\"Initialization Complete\");\n}\n\nbool Engine::ready() {\n if (isReady) {\n INFO(\"Game of '%s' is ready\", config.name.c_str());\n } else {\n\n }\n return isReady;\n}\n\nbool Engine::run() {\n INFO(\"Starting a game of '%s'\", config.name.c_str());\n\n INFO(\"Creating Render thread\");\n releaseWindow();\n renderThread = std::make_unique(&Engine::renderLoop, this);\n\n INFO(\"Initializing event loop\");\n sf::Int32 updateHz = 60;\n sf::Int32 updateWaitTime = 1'000'000 \/ updateHz;\n sf::Clock gameClock;\n sf::Time elapsedTime;\n sf::Time lastUpdateTime;\n sf::Int64 totalUpdateTime = 0;\n sf::Int64 averageUpdateTime;\n sf::Int32 updateCount = 0;\n INFO(\"Starting event loop\");\n running = true;\n while (running) {\n elapsedTime = gameClock.restart();\n processEvents();\n update(elapsedTime);\n \/\/compute\n lastUpdateTime = gameClock.getElapsedTime();\n totalUpdateTime += lastUpdateTime.asMilliseconds();\n averageUpdateTime = totalUpdateTime \/ ++updateCount;\n \/\/ log the average time per update every 1 seconds\n if (updateCount % (60 * 1) == 0) {\n DBUG(\"Average update time: %d ms\", averageUpdateTime);\n }\n \/\/ update at approximately 60 Hz (16666us minus time taken by last update(\n sf::sleep(sf::microseconds(updateWaitTime - lastUpdateTime.asMicroseconds()));\n }\n INFO(\"Stopped event loop\");\n renderThread->join();\n INFO(\"Closing window\");\n window.close();\n INFO(\"Game of '%s' ended successfully\", config.name.c_str());\n return true;\n}\n\nvoid Engine::showBuildInfo(const char* name) {\n const uint32_t majorVersion = 0;\n const uint32_t minorVersion = 4;\n const uint32_t revision = 1;\n\n INFO(\"%s %d.%d.%d %s %s\", name, majorVersion, minorVersion, revision, __DATE__, __TIME__);\n\n INFO(\"SFML %d.%d\", SFML_VERSION_MAJOR, SFML_VERSION_MINOR);\n\n\/\/ what compiler are we using? just because\n#ifdef __MINGW32__\n#ifdef __MINGW64__\n INFO(\"MinGW-w64 %d.%d\", __MINGW64_VERSION_MAJOR, __MINGW64_VERSION_MINOR);\n#else\n INFO(\"MinGW %d.%d\", __MINGW32_MAJOR_VERSION, __MINGW32_MINOR_VERSION);\n#endif\n#endif\n\n#ifdef __clang__\n INFO(\"CLang %d.%d.%d\", __clang_major__, __clang_minor__, __clang_patchlevel__);\n#endif\n\n#ifdef __GNUG__\n INFO(\"GCC %s\", __VERSION__);\n#endif\n\n#ifdef MSC_VER\n INFO(\"Visual C++ %s\", _MCS_VER);\n#endif\n}\n\n\nvoid Engine::readConfig() {\n std::string configFilename = data_dir + \"\/config.yaml\";\n INFO(\"Reading config from '%s'\", configFilename.c_str());\n try {\n YAML::Node yamlConfig = YAML::LoadFile(configFilename);\n config.name = yamlConfig[\"name\"].as(game);\n config.width = yamlConfig[\"width\"].as(config.width);\n config.height = yamlConfig[\"height\"].as(config.height);\n config.fullscreen = yamlConfig[\"fullscreen\"].as(config.fullscreen);\n config.useDesktopSize = yamlConfig[\"useDesktopSize\"].as(config.useDesktopSize);\n config.vsync = yamlConfig[\"vsync\"].as(config.vsync);\n config.deadZone = yamlConfig[\"deadzone\"].as(config.deadZone);\n config.keySpeed = yamlConfig[\"keySpeed\"].as(config.keySpeed);\n } catch (YAML::Exception e) {\n ERR(\"YAML Exception: %s\", e.msg.c_str());\n ERR(\"Can't load '%s', using sane defaults\", configFilename.c_str());\n }\n INFO(\"Current settings:\");\n INFO(\"\\tname = %s\", config.name.c_str());\n INFO(\"\\twidth = %d\", config.width);\n INFO(\"\\theight = %d\", config.height);\n INFO(\"\\tfullscreen = %s\", (config.fullscreen ? \"true\" : \"false\"));\n INFO(\"\\tuseDesktopSize = %s\", (config.useDesktopSize ? \"true\" : \"false\"));\n INFO(\"\\tvsync = %s\", (config.vsync ? \"true\" : \"false\"));\n INFO(\"\\tdeadZone = %f\", config.deadZone);\n INFO(\"\\tkeySpeed = %f\", config.keySpeed);\n}\n\nvoid Engine::createWindow(bool shouldFullscreen) {\n unsigned int flags = 0;\n\n lockWindow();\n\n INFO(\"Reading config\");\n sf::VideoMode mode;\n config.fullscreen = shouldFullscreen;\n if (config.fullscreen) {\n INFO(\"Going fullscreen\");\n window.setMouseCursorVisible(false);\n if (config.useDesktopSize) {\n INFO(\"Setting fullscreen mode (using desktop size): %dx%d\",\n sf::VideoMode::getDesktopMode().width,\n sf::VideoMode::getDesktopMode().height);\n mode = sf::VideoMode::getDesktopMode();\n } else {\n INFO(\"Setting fullscreen mode: %dx%d\", config.width, config.height);\n mode = sf::VideoMode(config.width, config.height);\n }\n flags = sf::Style::Fullscreen;\n } else {\n INFO(\"Setting windowed mode: %dx%d\", config.width, config.height);\n window.setMouseCursorVisible(true);\n mode = sf::VideoMode(config.width, config.height);\n flags = sf::Style::Titlebar | sf::Style::Close | sf::Style::Resize;\n }\n INFO(\"Creating the main window\");\n window.create(mode, game, flags);\n if (!window.isOpen()) {\n ERR(\"Could not create main window\");\n exit(EXIT_FAILURE);\n }\n sf::ContextSettings settings = window.getSettings();\n INFO(\"Using OpenGL %d.%d\", settings.majorVersion, settings.minorVersion);\n\n \/\/ initialize the view\n INFO(\"Setting window view\");\n view = window.getDefaultView();\n view.setSize(renderWidth, renderHeight);\n view.setCenter(renderWidth \/ 2, renderHeight \/ 2);\n window.setView(view);\n if (config.vsync) {\n INFO(\"Enabling V-sync\");\n window.setVerticalSyncEnabled(true);\n }\n\n releaseWindow();\n\n \/\/ scale the viewport to maintain good aspect\n adjustAspect(window.getSize());\n}\n\nvoid Engine::adjustAspect(sf::Event::SizeEvent newSize) {\n \/\/ save the new window size since this came from a resize event\n \/\/ not from a window creation event (initialization or fullscreen toggle)\n config.width = newSize.width;\n config.height = newSize.height;\n INFO(\"Window resized to: %dx%d\", config.width, config.height);\n \/\/ do the calculation\n adjustAspect(sf::Vector2u(newSize.width, newSize.height));\n}\n\nvoid Engine::adjustAspect(sf::Vector2u newSize) {\n INFO(\"Adjusting aspect for window size \", newSize.x, newSize.y);\n \/\/ compute the current aspect\n float currentRatio = (float) newSize.x \/ (float) newSize.y;\n \/\/ used to offset and scale the viewport to maintain 16:9 aspect\n float widthScale = 1.0f;\n float widthOffset = 0.0f;\n float heightScale = 1.0f;\n float heightOffset = 0.0f;\n \/\/ used to compare and compute aspect ratios\n \/\/ for logging\n std::string isSixteenNine = \"16:9\";\n if (currentRatio > 16.0f \/ 9.0f) {\n \/\/ we are wider\n isSixteenNine = \"wide\";\n widthScale = newSize.y * (16.0f \/ 9.0f) \/ newSize.x;\n widthOffset = (1.0f - widthScale) \/ 2.0f;\n } else if (currentRatio < 16.0f \/ 9.0f) {\n \/\/ we are narrower\n isSixteenNine = \"narrow\";\n heightScale = newSize.x * (9.0f \/ 16.0f) \/ newSize.y;\n heightOffset = (1.0f - heightScale) \/ 2.0f;\n }\n lockWindow();\n INFO(\"Setting %s viewport (wo:%f, ho:%f; ws:%f, hs: %f\", isSixteenNine.c_str(),\n widthOffset, heightOffset, widthScale, heightScale);\n view.setViewport(sf::FloatRect(widthOffset, heightOffset, widthScale, heightScale));\n window.setView(view);\n releaseWindow();\n}\n\n\/\/#define LOG_WINDOW_MUTEX_LOCKS\nvoid inline Engine::lockWindow() {\n#ifdef LOG_WINDOW_MUTEX_LOCKS\n DBUG(\"Grabbing window lock\");\n#endif\n windowMutex.lock();\n window.setActive(true);\n}\n\nvoid inline Engine::releaseWindow() {\n#ifdef LOG_WINDOW_MUTEX_LOCKS\n DBUG(\"Releasing window lock\");\n#endif\n window.setActive(false);\n windowMutex.unlock();\n}\n\nvoid Engine::processEvents() {\n static sf::Event event;\n\n while (window.pollEvent(event)) {\n switch (event.type) {\n case sf::Event::Closed:\n INFO(\"Window closed\");\n running = false;\n break;\n case sf::Event::Resized:\n adjustAspect(event.size);\n break;\n case sf::Event::KeyPressed:\n handleKeyPress(event);\n break;\n case sf::Event::KeyReleased:\n handleKeyRelease(event);\n break;\n default:\n break;\n }\n }\n}\n\nvoid Engine::handleKeyPress(const sf::Event& event) {\n switch (event.key.code) {\n case sf::Keyboard::Escape:\n INFO(\"Key: Escape: exiting\");\n running = false;\n break;\n case sf::Keyboard::Return:\n if (event.key.alt) {\n createWindow(!config.fullscreen);\n }\n break;\n default:\n break;\n }\n}\n\nvoid Engine::handleKeyRelease(const sf::Event& event) {\n switch (event.key.code) {\n default:\n break;\n }\n}\n\nvoid Engine::update(sf::Time elapsed) {\n float x, y = 0;\n\n \/\/ get current state of controls\n float joy0_X = sf::Joystick::getAxisPosition(0, sf::Joystick::X);\n float joy0_y = sf::Joystick::getAxisPosition(0, sf::Joystick::Y);\n x = std::fabs(joy0_X) < config.deadZone ? 0 : joy0_X;\n y = std::fabs(joy0_y) < config.deadZone ? 0 : joy0_y;\n\n if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) {\n y += -config.keySpeed;\n }\n if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) {\n x += config.keySpeed;\n }\n if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) {\n y += config.keySpeed;\n }\n if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) {\n x += -config.keySpeed;\n }\n\n spritesMutex.lock();\n player->moveBy(x, y);\n\n const int millis = elapsed.asMilliseconds();\n for (auto sprite : sprites) {\n sprite->update(millis);\n }\n\n spritesMutex.unlock();\n}\n\nvoid Engine::renderLoop() {\n INFO(\"Initializing render loop\");\n sf::Clock frameClock;\n sf::Int32 lastFrameTime;\n sf::Int32 averageFrameTime;\n sf::Int32 totalFrameTime = 0;\n sf::Int32 frameCount = 0;\n INFO(\"Starting render loop\");\n while (running) {\n frameClock.restart();\n \/\/ blank the render target to black\n screen.clear(sf::Color::Black);\n \/\/ render all the normal sprites\n spritesMutex.lock();\n for (const auto sprite : sprites) {\n screen.draw(*sprite);\n }\n spritesMutex.unlock();\n \/\/ update the target\n screen.display();\n lockWindow();\n \/\/ blank the window to gray\n window.clear(sf::Color(128, 128, 128));\n \/\/ copy render target to window\n window.draw(sf::Sprite(screen.getTexture()));\n \/\/ update thw window\n window.display();\n releaseWindow();\n lastFrameTime = frameClock.getElapsedTime().asMilliseconds();\n totalFrameTime += lastFrameTime;\n averageFrameTime = totalFrameTime \/ ++frameCount;\n \/\/ log the time per frame every 60 frames (every second if at 60 Hz)\n if (frameCount % (60 * 1) == 0) {\n DBUG(\"Average frame time: %d ms\", averageFrameTime);\n }\n }\n spritesMutex.unlock();\n releaseWindow();\n INFO(\"Stopped render loop\");\n}\n<|endoftext|>"} {"text":"\/*************************************************************************\n *\n * $RCSfile: svdem.cxx,v $\n *\n * $Revision: 1.11 $\n *\n * last change: $Author: obo $ $Date: 2003-11-05 12:39:54 $\n *\n * The Contents of this file are made available subject to the terms of\n * either of the following licenses\n *\n * - GNU Lesser General Public License Version 2.1\n * - Sun Industry Standards Source License Version 1.1\n *\n * Sun Microsystems Inc., October, 2000\n *\n * GNU Lesser General Public License Version 2.1\n * =============================================\n * Copyright 2000 by Sun Microsystems, Inc.\n * 901 San Antonio Road, Palo Alto, CA 94303, USA\n *\n * This library is free software; you can redistribute it and\/or\n * modify it under the terms of the GNU Lesser General Public\n * License version 2.1, as published by the Free Software Foundation.\n *\n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this library; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place, Suite 330, Boston,\n * MA 02111-1307 USA\n *\n *\n * Sun Industry Standards Source License Version 1.1\n * =================================================\n * The contents of this file are subject to the Sun Industry Standards\n * Source License Version 1.1 (the \"License\"); You may not use this file\n * except in compliance with the License. You may obtain a copy of the\n * License at http:\/\/www.openoffice.org\/license.html.\n *\n * Software provided under this License is provided on an \"AS IS\" basis,\n * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,\n * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,\n * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.\n * See the License for the specific provisions governing your rights and\n * obligations concerning the Software.\n *\n * The Initial Developer of the Original Code is: Sun Microsystems, Inc.\n *\n * Copyright: 2000 by Sun Microsystems, Inc.\n *\n * All Rights Reserved.\n *\n * Contributor(s): _______________________________________\n *\n *\n ************************************************************************\/\n\n#include \n#include \n\n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#ifdef REMOTE_APPSERVER\n#include \"officeacceptthread.hxx\"\n#endif\n\nusing namespace ::com::sun::star::uno;\nusing namespace ::com::sun::star::lang;\n\/\/ -----------------------------------------------------------------------\n\n\/\/ Forward declaration\nvoid Main();\n\n\/\/ -----------------------------------------------------------------------\n\nSAL_IMPLEMENT_MAIN()\n{\n Reference< XMultiServiceFactory > xMS;\n\n \/\/ for this to work make sure an .ini file is available, you can just copy soffice.ini\n Reference< XComponentContext > xComponentContext = ::cppu::defaultBootstrap_InitialComponentContext();\n xMS = cppu::createRegistryServiceFactory(\n rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( \"applicat.rdb\" ) ), sal_True );\n\n\n#ifdef REMOTE_APPSERVER\n \/\/ allow remote clients to connect from any host (0) on the given port\n ::desktop::OOfficeAcceptorThread *pOfficeAcceptThread = new ::desktop::OOfficeAcceptorThread( xMS,\n ::rtl::OUString::createFromAscii(\"socket,host=0,port=8081;urp;\"), false, ::rtl::OUString(), ::rtl::OUString() );\n pOfficeAcceptThread->create();\n#endif\n\n InitVCL( xMS );\n GetpApp()->WaitForClientConnect(); \/\/ is a no-op in local case\n ::Main();\n DeInitVCL();\n\n#ifdef REMOTE_APPSERVER\n if( pOfficeAcceptThread )\n {\n pOfficeAcceptThread->stopAccepting();\n#ifndef LINUX\n pOfficeAcceptThread->join();\n delete pOfficeAcceptThread;\n#endif\n pOfficeAcceptThread = 0;\n }\n#endif\n\n return 0;\n}\n\n\/\/ -----------------------------------------------------------------------\n\nclass MyWin : public WorkWindow\n{\npublic:\n MyWin( Window* pParent, WinBits nWinStyle );\n\n void MouseMove( const MouseEvent& rMEvt );\n void MouseButtonDown( const MouseEvent& rMEvt );\n void MouseButtonUp( const MouseEvent& rMEvt );\n void KeyInput( const KeyEvent& rKEvt );\n void KeyUp( const KeyEvent& rKEvt );\n void Paint( const Rectangle& rRect );\n void Resize();\n};\n\n\/\/ -----------------------------------------------------------------------\n\nvoid Main()\n{\n MyWin aMainWin( NULL, WB_APP | WB_STDWORK );\n aMainWin.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( \"VCL - Workbench\" ) ) );\n aMainWin.Show();\n\n Application::Execute();\n}\n\n\/\/ -----------------------------------------------------------------------\n\nMyWin::MyWin( Window* pParent, WinBits nWinStyle ) :\n WorkWindow( pParent, nWinStyle )\n{\n}\n\n\/\/ -----------------------------------------------------------------------\n\nvoid MyWin::MouseMove( const MouseEvent& rMEvt )\n{\n WorkWindow::MouseMove( rMEvt );\n}\n\n\/\/ -----------------------------------------------------------------------\n\nvoid MyWin::MouseButtonDown( const MouseEvent& rMEvt )\n{\n WorkWindow::MouseButtonDown( rMEvt );\n}\n\n\/\/ -----------------------------------------------------------------------\n\nvoid MyWin::MouseButtonUp( const MouseEvent& rMEvt )\n{\n WorkWindow::MouseButtonUp( rMEvt );\n}\n\n\/\/ -----------------------------------------------------------------------\n\nvoid MyWin::KeyInput( const KeyEvent& rKEvt )\n{\n WorkWindow::KeyInput( rKEvt );\n}\n\n\/\/ -----------------------------------------------------------------------\n\nvoid MyWin::KeyUp( const KeyEvent& rKEvt )\n{\n WorkWindow::KeyUp( rKEvt );\n}\n\n\/\/ -----------------------------------------------------------------------\n\nvoid MyWin::Paint( const Rectangle& rRect )\n{\n WorkWindow::Paint( rRect );\n}\n\n\/\/ -----------------------------------------------------------------------\n\nvoid MyWin::Resize()\n{\n WorkWindow::Resize();\n}\nINTEGRATION: CWS vclcleanup01 (1.11.22); FILE MERGED 2003\/11\/28 07:33:10 mt 1.11.22.1: #i22952# Removed App Server code\/*************************************************************************\n *\n * $RCSfile: svdem.cxx,v $\n *\n * $Revision: 1.12 $\n *\n * last change: $Author: rt $ $Date: 2003-12-01 13:43:32 $\n *\n * The Contents of this file are made available subject to the terms of\n * either of the following licenses\n *\n * - GNU Lesser General Public License Version 2.1\n * - Sun Industry Standards Source License Version 1.1\n *\n * Sun Microsystems Inc., October, 2000\n *\n * GNU Lesser General Public License Version 2.1\n * =============================================\n * Copyright 2000 by Sun Microsystems, Inc.\n * 901 San Antonio Road, Palo Alto, CA 94303, USA\n *\n * This library is free software; you can redistribute it and\/or\n * modify it under the terms of the GNU Lesser General Public\n * License version 2.1, as published by the Free Software Foundation.\n *\n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this library; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place, Suite 330, Boston,\n * MA 02111-1307 USA\n *\n *\n * Sun Industry Standards Source License Version 1.1\n * =================================================\n * The contents of this file are subject to the Sun Industry Standards\n * Source License Version 1.1 (the \"License\"); You may not use this file\n * except in compliance with the License. You may obtain a copy of the\n * License at http:\/\/www.openoffice.org\/license.html.\n *\n * Software provided under this License is provided on an \"AS IS\" basis,\n * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,\n * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,\n * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.\n * See the License for the specific provisions governing your rights and\n * obligations concerning the Software.\n *\n * The Initial Developer of the Original Code is: Sun Microsystems, Inc.\n *\n * Copyright: 2000 by Sun Microsystems, Inc.\n *\n * All Rights Reserved.\n *\n * Contributor(s): _______________________________________\n *\n *\n ************************************************************************\/\n\n#include \n#include \n\n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n\nusing namespace ::com::sun::star::uno;\nusing namespace ::com::sun::star::lang;\n\/\/ -----------------------------------------------------------------------\n\n\/\/ Forward declaration\nvoid Main();\n\n\/\/ -----------------------------------------------------------------------\n\nSAL_IMPLEMENT_MAIN()\n{\n Reference< XMultiServiceFactory > xMS;\n\n \/\/ for this to work make sure an .ini file is available, you can just copy soffice.ini\n Reference< XComponentContext > xComponentContext = ::cppu::defaultBootstrap_InitialComponentContext();\n xMS = cppu::createRegistryServiceFactory(\n rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( \"applicat.rdb\" ) ), sal_True );\n\n\n\n InitVCL( xMS );\n ::Main();\n DeInitVCL();\n\n return 0;\n}\n\n\/\/ -----------------------------------------------------------------------\n\nclass MyWin : public WorkWindow\n{\npublic:\n MyWin( Window* pParent, WinBits nWinStyle );\n\n void MouseMove( const MouseEvent& rMEvt );\n void MouseButtonDown( const MouseEvent& rMEvt );\n void MouseButtonUp( const MouseEvent& rMEvt );\n void KeyInput( const KeyEvent& rKEvt );\n void KeyUp( const KeyEvent& rKEvt );\n void Paint( const Rectangle& rRect );\n void Resize();\n};\n\n\/\/ -----------------------------------------------------------------------\n\nvoid Main()\n{\n MyWin aMainWin( NULL, WB_APP | WB_STDWORK );\n aMainWin.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( \"VCL - Workbench\" ) ) );\n aMainWin.Show();\n\n Application::Execute();\n}\n\n\/\/ -----------------------------------------------------------------------\n\nMyWin::MyWin( Window* pParent, WinBits nWinStyle ) :\n WorkWindow( pParent, nWinStyle )\n{\n}\n\n\/\/ -----------------------------------------------------------------------\n\nvoid MyWin::MouseMove( const MouseEvent& rMEvt )\n{\n WorkWindow::MouseMove( rMEvt );\n}\n\n\/\/ -----------------------------------------------------------------------\n\nvoid MyWin::MouseButtonDown( const MouseEvent& rMEvt )\n{\n WorkWindow::MouseButtonDown( rMEvt );\n}\n\n\/\/ -----------------------------------------------------------------------\n\nvoid MyWin::MouseButtonUp( const MouseEvent& rMEvt )\n{\n WorkWindow::MouseButtonUp( rMEvt );\n}\n\n\/\/ -----------------------------------------------------------------------\n\nvoid MyWin::KeyInput( const KeyEvent& rKEvt )\n{\n WorkWindow::KeyInput( rKEvt );\n}\n\n\/\/ -----------------------------------------------------------------------\n\nvoid MyWin::KeyUp( const KeyEvent& rKEvt )\n{\n WorkWindow::KeyUp( rKEvt );\n}\n\n\/\/ -----------------------------------------------------------------------\n\nvoid MyWin::Paint( const Rectangle& rRect )\n{\n WorkWindow::Paint( rRect );\n}\n\n\/\/ -----------------------------------------------------------------------\n\nvoid MyWin::Resize()\n{\n WorkWindow::Resize();\n}\n<|endoftext|>"} {"text":"\/* * This file is part of meego-im-framework *\n *\n * Copyright (C) 2010 Nokia Corporation and\/or its subsidiary(-ies).\n * All rights reserved.\n * Contact: Nokia Corporation (directui@nokia.com)\n *\n * If you have questions regarding the use of this file, please contact\n * Nokia at directui@nokia.com.\n *\n * This library is free software; you can redistribute it and\/or\n * modify it under the terms of the GNU Lesser General Public\n * License version 2.1 as published by the Free Software Foundation\n * and appearing in the file LICENSE.LGPL included in the packaging\n * of this file.\n *\/\n\n#include \"connectionfactory.h\"\n\n#ifndef MALIIT_DISABLE_DBUS\n#ifdef HAVE_GLIB_DBUS\n#include \"glibdbusimserverproxy.h\"\n#include \"minputcontextglibdbusconnection.h\"\n#else\n#include \"dbusserverconnection.h\"\n#include \"dbusinputcontextconnection.h\"\n#endif\n#endif\n#include \"mimdirectserverconnection.h\"\n\nnamespace Maliit {\n#ifndef MALIIT_DISABLE_DBUS\nnamespace DBus {\n\nMImServerConnection *createServerConnectionWithDynamicAddress()\n{\n const QSharedPointer address(new Maliit::InputContext::DBus::DynamicAddress);\n#ifdef HAVE_GLIB_DBUS\n return new GlibDBusIMServerProxy(address);\n#else\n return new DBusServerConnection(address);\n#endif\n}\n\nMImServerConnection *createServerConnectionWithFixedAddress(const QString &fixedAddress)\n{\n const QSharedPointer address(new Maliit::InputContext::DBus::FixedAddress(fixedAddress));\n#ifdef HAVE_GLIB_DBUS\n return new GlibDBusIMServerProxy(address);\n#else\n return new DBusServerConnection(address);\n#endif\n}\n\nMInputContextConnection *createInputContextConnectionWithDynamicAddress()\n{\n#ifdef HAVE_GLIB_DBUS\n std::tr1::shared_ptr address(new Maliit::Server::DBus::DynamicAddress);\n return new MInputContextGlibDBusConnection(address, false);\n#else\n QSharedPointer address(new Maliit::Server::DBus::DynamicAddress);\n return new DBusInputContextConnection(address);\n#endif\n}\n\nMInputContextConnection *createInputContextConnectionWithFixedAddress(const QString &fixedAddress, bool allowAnonymous)\n{\n#ifdef HAVE_GLIB_DBUS\n std::tr1::shared_ptr address(new Maliit::Server::DBus::FixedAddress(fixedAddress));\n return new MInputContextGlibDBusConnection(address, allowAnonymous);\n#else\n Q_UNUSED(allowAnonymous);\n QSharedPointer address(new Maliit::Server::DBus::FixedAddress(fixedAddress));\n return new DBusInputContextConnection(address);\n#endif\n}\n\n} \/\/ namespace DBus\n#endif \/\/ MALIIT_DISABLE_DBUS\n\nQSharedPointer createServerConnection(const QString &connectionType)\n{\n typedef QSharedPointer ConnectionPtr;\n static QWeakPointer cached_connection;\n\n if (ConnectionPtr connection = cached_connection.toStrongRef())\n return connection;\n\n if (connectionType == MALIIT_INPUTCONTEXT_NAME) {\n#ifndef MALIIT_DISABLE_DBUS\n const QByteArray overriddenAddress = qgetenv(\"MALIIT_SERVER_ADDRESS\");\n ConnectionPtr connection;\n\n if (overriddenAddress.isEmpty()) {\n cached_connection = connection = ConnectionPtr(Maliit::DBus::createServerConnectionWithDynamicAddress());\n } else {\n cached_connection = connection = ConnectionPtr(Maliit::DBus::createServerConnectionWithFixedAddress(overriddenAddress));\n }\n\n return connection;\n#else\n qCritical(\"This connection type to Maliit server is not available since DBus support is disabled\");\n#endif\n } else if (connectionType == MALIIT_INPUTCONTEXT_NAME\"Direct\") {\n ConnectionPtr connection(new MImDirectServerConnection);\n\n cached_connection = connection;\n\n return connection;\n } else {\n qCritical(\"Invalid connection type, unable to create connection to Maliit server\");\n\n return ConnectionPtr();\n }\n}\n\n} \/\/ namespace Maliit\nPrint a type of connection we failed to get.\/* * This file is part of meego-im-framework *\n *\n * Copyright (C) 2010 Nokia Corporation and\/or its subsidiary(-ies).\n * All rights reserved.\n * Contact: Nokia Corporation (directui@nokia.com)\n *\n * If you have questions regarding the use of this file, please contact\n * Nokia at directui@nokia.com.\n *\n * This library is free software; you can redistribute it and\/or\n * modify it under the terms of the GNU Lesser General Public\n * License version 2.1 as published by the Free Software Foundation\n * and appearing in the file LICENSE.LGPL included in the packaging\n * of this file.\n *\/\n\n#include \"connectionfactory.h\"\n\n#ifndef MALIIT_DISABLE_DBUS\n#ifdef HAVE_GLIB_DBUS\n#include \"glibdbusimserverproxy.h\"\n#include \"minputcontextglibdbusconnection.h\"\n#else\n#include \"dbusserverconnection.h\"\n#include \"dbusinputcontextconnection.h\"\n#endif\n#endif\n#include \"mimdirectserverconnection.h\"\n\nnamespace Maliit {\n#ifndef MALIIT_DISABLE_DBUS\nnamespace DBus {\n\nMImServerConnection *createServerConnectionWithDynamicAddress()\n{\n const QSharedPointer address(new Maliit::InputContext::DBus::DynamicAddress);\n#ifdef HAVE_GLIB_DBUS\n return new GlibDBusIMServerProxy(address);\n#else\n return new DBusServerConnection(address);\n#endif\n}\n\nMImServerConnection *createServerConnectionWithFixedAddress(const QString &fixedAddress)\n{\n const QSharedPointer address(new Maliit::InputContext::DBus::FixedAddress(fixedAddress));\n#ifdef HAVE_GLIB_DBUS\n return new GlibDBusIMServerProxy(address);\n#else\n return new DBusServerConnection(address);\n#endif\n}\n\nMInputContextConnection *createInputContextConnectionWithDynamicAddress()\n{\n#ifdef HAVE_GLIB_DBUS\n std::tr1::shared_ptr address(new Maliit::Server::DBus::DynamicAddress);\n return new MInputContextGlibDBusConnection(address, false);\n#else\n QSharedPointer address(new Maliit::Server::DBus::DynamicAddress);\n return new DBusInputContextConnection(address);\n#endif\n}\n\nMInputContextConnection *createInputContextConnectionWithFixedAddress(const QString &fixedAddress, bool allowAnonymous)\n{\n#ifdef HAVE_GLIB_DBUS\n std::tr1::shared_ptr address(new Maliit::Server::DBus::FixedAddress(fixedAddress));\n return new MInputContextGlibDBusConnection(address, allowAnonymous);\n#else\n Q_UNUSED(allowAnonymous);\n QSharedPointer address(new Maliit::Server::DBus::FixedAddress(fixedAddress));\n return new DBusInputContextConnection(address);\n#endif\n}\n\n} \/\/ namespace DBus\n#endif \/\/ MALIIT_DISABLE_DBUS\n\nQSharedPointer createServerConnection(const QString &connectionType)\n{\n typedef QSharedPointer ConnectionPtr;\n static QWeakPointer cached_connection;\n\n if (ConnectionPtr connection = cached_connection.toStrongRef())\n return connection;\n\n if (connectionType == MALIIT_INPUTCONTEXT_NAME) {\n#ifndef MALIIT_DISABLE_DBUS\n const QByteArray overriddenAddress = qgetenv(\"MALIIT_SERVER_ADDRESS\");\n ConnectionPtr connection;\n\n if (overriddenAddress.isEmpty()) {\n cached_connection = connection = ConnectionPtr(Maliit::DBus::createServerConnectionWithDynamicAddress());\n } else {\n cached_connection = connection = ConnectionPtr(Maliit::DBus::createServerConnectionWithFixedAddress(overriddenAddress));\n }\n\n return connection;\n#else\n qCritical(\"This connection type to Maliit server is not available since DBus support is disabled\");\n#endif\n } else if (connectionType == MALIIT_INPUTCONTEXT_NAME\"Direct\") {\n ConnectionPtr connection(new MImDirectServerConnection);\n\n cached_connection = connection;\n\n return connection;\n } else {\n qCritical() << __PRETTY_FUNCTION__ << \"Invalid connection type (\" + connectionType + \"), unable to create connection to Maliit server\";\n\n return ConnectionPtr();\n }\n}\n\n} \/\/ namespace Maliit\n<|endoftext|>"} {"text":"\/*\n * Copyright 2015 - 2021 gary@drinkingtea.net\n *\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http:\/\/mozilla.org\/MPL\/2.0\/.\n *\/\n\n#pragma once\n\n#include \n\nnamespace ox {\n\nenum class FileType: uint8_t {\n\tNone = 0,\n\tNormalFile = 1,\n\tDirectory = 2\n};\n\nconstexpr const char *toString(FileType t) {\n\tswitch (t) {\n\t\tcase FileType::NormalFile:\n\t\t\treturn \"Normal File\";\n\t\tcase FileType::Directory:\n\t\t\treturn \"Directory\";\n\t\tdefault:\n\t\t\treturn \"\";\n\t}\n}\n\nstruct FileStat {\n\tuint64_t inode = 0;\n\tuint64_t links = 0;\n\tuint64_t size = 0;\n\tFileType fileType = FileType::None;\n};\n\n}\n[ox\/fs] Make toString(FileType) noexcept\/*\n * Copyright 2015 - 2021 gary@drinkingtea.net\n *\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http:\/\/mozilla.org\/MPL\/2.0\/.\n *\/\n\n#pragma once\n\n#include \n\nnamespace ox {\n\nenum class FileType: uint8_t {\n\tNone = 0,\n\tNormalFile = 1,\n\tDirectory = 2\n};\n\nconstexpr const char *toString(FileType t) noexcept {\n\tswitch (t) {\n\t\tcase FileType::NormalFile:\n\t\t\treturn \"Normal File\";\n\t\tcase FileType::Directory:\n\t\t\treturn \"Directory\";\n\t\tdefault:\n\t\t\treturn \"\";\n\t}\n}\n\nstruct FileStat {\n\tuint64_t inode = 0;\n\tuint64_t links = 0;\n\tuint64_t size = 0;\n\tFileType fileType = FileType::None;\n};\n\n}\n<|endoftext|>"} {"text":"\/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- *\/\n\/*\n * This file is part of the LibreOffice project.\n *\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http:\/\/mozilla.org\/MPL\/2.0\/.\n *\n * This file incorporates work covered by the following license notice:\n *\n * Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed\n * with this work for additional information regarding copyright\n * ownership. The ASF licenses this file to you under the Apache\n * License, Version 2.0 (the \"License\"); you may not use this file\n * except in compliance with the License. You may obtain a copy of\n * the License at http:\/\/www.apache.org\/licenses\/LICENSE-2.0 .\n *\/\n\n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\nusing namespace com::sun::star::uno;\nusing namespace com::sun::star::lang;\nusing namespace com::sun::star::frame;\nusing namespace com::sun::star::beans;\nusing namespace com::sun::star::util;\nusing namespace ::com::sun::star::ui;\nusing namespace framework;\n\nnamespace {\n\nclass AddonsToolBarFactory : protected ThreadHelpBase, \/\/ Struct for right initalization of mutex member! Must be first of baseclasses.\n public ::cppu::WeakImplHelper2< css::lang::XServiceInfo ,\n css::ui::XUIElementFactory >\n{\npublic:\n AddonsToolBarFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext );\n virtual ~AddonsToolBarFactory();\n\n virtual OUString SAL_CALL getImplementationName()\n throw (css::uno::RuntimeException, std::exception)\n {\n return OUString(\"com.sun.star.comp.framework.AddonsToolBarFactory\");\n }\n\n virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)\n throw (css::uno::RuntimeException, std::exception)\n {\n return cppu::supportsService(this, ServiceName);\n }\n\n virtual css::uno::Sequence SAL_CALL getSupportedServiceNames()\n throw (css::uno::RuntimeException, std::exception)\n {\n css::uno::Sequence< OUString > aSeq(1);\n aSeq[0] = OUString(\"com.sun.star.ui.ToolBarFactory\");\n return aSeq;\n }\n\n \/\/ XUIElementFactory\n virtual css::uno::Reference< css::ui::XUIElement > SAL_CALL createUIElement( const OUString& ResourceURL, const css::uno::Sequence< css::beans::PropertyValue >& Args ) throw ( css::container::NoSuchElementException, css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception );\n\n sal_Bool hasButtonsInContext( const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& rPropSeq,\n const css::uno::Reference< css::frame::XFrame >& rFrame );\n\nprivate:\n css::uno::Reference< css::uno::XComponentContext > m_xContext;\n css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager;\n};\n\nAddonsToolBarFactory::AddonsToolBarFactory(\n const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ) :\n ThreadHelpBase( &Application::GetSolarMutex() )\n , m_xContext( xContext )\n , m_xModuleManager( ModuleManager::create( xContext ) )\n{\n}\n\nAddonsToolBarFactory::~AddonsToolBarFactory()\n{\n}\n\nstatic sal_Bool IsCorrectContext( const OUString& rModuleIdentifier, const OUString& aContextList )\n{\n if ( aContextList.isEmpty() )\n return sal_True;\n\n if ( !rModuleIdentifier.isEmpty() )\n {\n sal_Int32 nIndex = aContextList.indexOf( rModuleIdentifier );\n return ( nIndex >= 0 );\n }\n\n return sal_False;\n}\n\nsal_Bool AddonsToolBarFactory::hasButtonsInContext(\n const Sequence< Sequence< PropertyValue > >& rPropSeqSeq,\n const Reference< XFrame >& rFrame )\n{\n OUString aModuleIdentifier;\n try\n {\n aModuleIdentifier = m_xModuleManager->identify( rFrame );\n }\n catch ( const RuntimeException& )\n {\n throw;\n }\n catch ( const Exception& )\n {\n }\n\n \/\/ Check before we create a toolbar that we have at least one button in\n \/\/ the current frame context.\n for ( sal_uInt32 i = 0; i < (sal_uInt32)rPropSeqSeq.getLength(); i++ )\n {\n sal_Bool bIsButton( sal_True );\n sal_Bool bIsCorrectContext( sal_False );\n sal_uInt32 nPropChecked( 0 );\n\n const Sequence< PropertyValue >& rPropSeq = rPropSeqSeq[i];\n for ( sal_uInt32 j = 0; j < (sal_uInt32)rPropSeq.getLength(); j++ )\n {\n if ( rPropSeq[j].Name == \"Context\" )\n {\n OUString aContextList;\n if ( rPropSeq[j].Value >>= aContextList )\n bIsCorrectContext = IsCorrectContext( aModuleIdentifier, aContextList );\n nPropChecked++;\n }\n else if ( rPropSeq[j].Name == \"URL\" )\n {\n OUString aURL;\n rPropSeq[j].Value >>= aURL;\n bIsButton = aURL != \"private:separator\" ;\n nPropChecked++;\n }\n\n if ( nPropChecked == 2 )\n break;\n }\n\n if ( bIsButton && bIsCorrectContext )\n return sal_True;\n }\n\n return sal_False;\n}\n\n\/\/ XUIElementFactory\nReference< XUIElement > SAL_CALL AddonsToolBarFactory::createUIElement(\n const OUString& ResourceURL,\n const Sequence< PropertyValue >& Args )\nthrow ( ::com::sun::star::container::NoSuchElementException,\n ::com::sun::star::lang::IllegalArgumentException,\n ::com::sun::star::uno::RuntimeException, std::exception )\n{\n \/\/ SAFE\n Guard aLock( m_aLock );\n\n Sequence< Sequence< PropertyValue > > aConfigData;\n Reference< XFrame > xFrame;\n OUString aResourceURL( ResourceURL );\n\n for ( sal_Int32 n = 0; n < Args.getLength(); n++ )\n {\n if ( Args[n].Name == \"ConfigurationData\" )\n Args[n].Value >>= aConfigData;\n else if ( Args[n].Name == \"Frame\" )\n Args[n].Value >>= xFrame;\n else if ( Args[n].Name == \"ResourceURL\" )\n Args[n].Value >>= aResourceURL;\n }\n\n if ( !aResourceURL.startsWith(\"private:resource\/toolbar\/addon_\") )\n throw IllegalArgumentException();\n\n \/\/ Identify frame and determine module identifier to look for context based buttons\n Reference< ::com::sun::star::ui::XUIElement > xToolBar;\n if ( xFrame.is() &&\n ( aConfigData.getLength()> 0 ) &&\n hasButtonsInContext( aConfigData, xFrame ))\n {\n PropertyValue aPropValue;\n Sequence< Any > aPropSeq( 3 );\n aPropValue.Name = \"Frame\";\n aPropValue.Value <<= xFrame;\n aPropSeq[0] <<= aPropValue;\n aPropValue.Name = \"ConfigurationData\";\n aPropValue.Value <<= aConfigData;\n aPropSeq[1] <<= aPropValue;\n aPropValue.Name = \"ResourceURL\";\n aPropValue.Value <<= aResourceURL;\n aPropSeq[2] <<= aPropValue;\n\n SolarMutexGuard aGuard;\n AddonsToolBarWrapper* pToolBarWrapper = new AddonsToolBarWrapper( m_xContext );\n xToolBar = Reference< ::com::sun::star::ui::XUIElement >( (OWeakObject *)pToolBarWrapper, UNO_QUERY );\n Reference< XInitialization > xInit( xToolBar, UNO_QUERY );\n xInit->initialize( aPropSeq );\n }\n\n return xToolBar;\n}\n\n}\n\nextern \"C\" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL\ncom_sun_star_comp_framework_AddonsToolBarFactory_get_implementation(\n css::uno::XComponentContext *context,\n css::uno::Sequence const &)\n{\n return cppu::acquire(new AddonsToolBarFactory(context));\n}\n\n\/* vim:set shiftwidth=4 softtabstop=4 expandtab: *\/\nUse SolarMutexGuard directly\/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- *\/\n\/*\n * This file is part of the LibreOffice project.\n *\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http:\/\/mozilla.org\/MPL\/2.0\/.\n *\n * This file incorporates work covered by the following license notice:\n *\n * Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed\n * with this work for additional information regarding copyright\n * ownership. The ASF licenses this file to you under the Apache\n * License, Version 2.0 (the \"License\"); you may not use this file\n * except in compliance with the License. You may obtain a copy of\n * the License at http:\/\/www.apache.org\/licenses\/LICENSE-2.0 .\n *\/\n\n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\nusing namespace com::sun::star::uno;\nusing namespace com::sun::star::lang;\nusing namespace com::sun::star::frame;\nusing namespace com::sun::star::beans;\nusing namespace com::sun::star::util;\nusing namespace ::com::sun::star::ui;\nusing namespace framework;\n\nnamespace {\n\nclass AddonsToolBarFactory : public ::cppu::WeakImplHelper2< css::lang::XServiceInfo ,\n css::ui::XUIElementFactory >\n{\npublic:\n AddonsToolBarFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext );\n virtual ~AddonsToolBarFactory();\n\n virtual OUString SAL_CALL getImplementationName()\n throw (css::uno::RuntimeException, std::exception)\n {\n return OUString(\"com.sun.star.comp.framework.AddonsToolBarFactory\");\n }\n\n virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)\n throw (css::uno::RuntimeException, std::exception)\n {\n return cppu::supportsService(this, ServiceName);\n }\n\n virtual css::uno::Sequence SAL_CALL getSupportedServiceNames()\n throw (css::uno::RuntimeException, std::exception)\n {\n css::uno::Sequence< OUString > aSeq(1);\n aSeq[0] = OUString(\"com.sun.star.ui.ToolBarFactory\");\n return aSeq;\n }\n\n \/\/ XUIElementFactory\n virtual css::uno::Reference< css::ui::XUIElement > SAL_CALL createUIElement( const OUString& ResourceURL, const css::uno::Sequence< css::beans::PropertyValue >& Args ) throw ( css::container::NoSuchElementException, css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception );\n\n sal_Bool hasButtonsInContext( const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& rPropSeq,\n const css::uno::Reference< css::frame::XFrame >& rFrame );\n\nprivate:\n css::uno::Reference< css::uno::XComponentContext > m_xContext;\n css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager;\n};\n\nAddonsToolBarFactory::AddonsToolBarFactory(\n const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ) :\n m_xContext( xContext )\n , m_xModuleManager( ModuleManager::create( xContext ) )\n{\n}\n\nAddonsToolBarFactory::~AddonsToolBarFactory()\n{\n}\n\nstatic sal_Bool IsCorrectContext( const OUString& rModuleIdentifier, const OUString& aContextList )\n{\n if ( aContextList.isEmpty() )\n return sal_True;\n\n if ( !rModuleIdentifier.isEmpty() )\n {\n sal_Int32 nIndex = aContextList.indexOf( rModuleIdentifier );\n return ( nIndex >= 0 );\n }\n\n return sal_False;\n}\n\nsal_Bool AddonsToolBarFactory::hasButtonsInContext(\n const Sequence< Sequence< PropertyValue > >& rPropSeqSeq,\n const Reference< XFrame >& rFrame )\n{\n OUString aModuleIdentifier;\n try\n {\n aModuleIdentifier = m_xModuleManager->identify( rFrame );\n }\n catch ( const RuntimeException& )\n {\n throw;\n }\n catch ( const Exception& )\n {\n }\n\n \/\/ Check before we create a toolbar that we have at least one button in\n \/\/ the current frame context.\n for ( sal_uInt32 i = 0; i < (sal_uInt32)rPropSeqSeq.getLength(); i++ )\n {\n sal_Bool bIsButton( sal_True );\n sal_Bool bIsCorrectContext( sal_False );\n sal_uInt32 nPropChecked( 0 );\n\n const Sequence< PropertyValue >& rPropSeq = rPropSeqSeq[i];\n for ( sal_uInt32 j = 0; j < (sal_uInt32)rPropSeq.getLength(); j++ )\n {\n if ( rPropSeq[j].Name == \"Context\" )\n {\n OUString aContextList;\n if ( rPropSeq[j].Value >>= aContextList )\n bIsCorrectContext = IsCorrectContext( aModuleIdentifier, aContextList );\n nPropChecked++;\n }\n else if ( rPropSeq[j].Name == \"URL\" )\n {\n OUString aURL;\n rPropSeq[j].Value >>= aURL;\n bIsButton = aURL != \"private:separator\" ;\n nPropChecked++;\n }\n\n if ( nPropChecked == 2 )\n break;\n }\n\n if ( bIsButton && bIsCorrectContext )\n return sal_True;\n }\n\n return sal_False;\n}\n\n\/\/ XUIElementFactory\nReference< XUIElement > SAL_CALL AddonsToolBarFactory::createUIElement(\n const OUString& ResourceURL,\n const Sequence< PropertyValue >& Args )\nthrow ( ::com::sun::star::container::NoSuchElementException,\n ::com::sun::star::lang::IllegalArgumentException,\n ::com::sun::star::uno::RuntimeException, std::exception )\n{\n SolarMutexGuard g;\n\n Sequence< Sequence< PropertyValue > > aConfigData;\n Reference< XFrame > xFrame;\n OUString aResourceURL( ResourceURL );\n\n for ( sal_Int32 n = 0; n < Args.getLength(); n++ )\n {\n if ( Args[n].Name == \"ConfigurationData\" )\n Args[n].Value >>= aConfigData;\n else if ( Args[n].Name == \"Frame\" )\n Args[n].Value >>= xFrame;\n else if ( Args[n].Name == \"ResourceURL\" )\n Args[n].Value >>= aResourceURL;\n }\n\n if ( !aResourceURL.startsWith(\"private:resource\/toolbar\/addon_\") )\n throw IllegalArgumentException();\n\n \/\/ Identify frame and determine module identifier to look for context based buttons\n Reference< ::com::sun::star::ui::XUIElement > xToolBar;\n if ( xFrame.is() &&\n ( aConfigData.getLength()> 0 ) &&\n hasButtonsInContext( aConfigData, xFrame ))\n {\n PropertyValue aPropValue;\n Sequence< Any > aPropSeq( 3 );\n aPropValue.Name = \"Frame\";\n aPropValue.Value <<= xFrame;\n aPropSeq[0] <<= aPropValue;\n aPropValue.Name = \"ConfigurationData\";\n aPropValue.Value <<= aConfigData;\n aPropSeq[1] <<= aPropValue;\n aPropValue.Name = \"ResourceURL\";\n aPropValue.Value <<= aResourceURL;\n aPropSeq[2] <<= aPropValue;\n\n SolarMutexGuard aGuard;\n AddonsToolBarWrapper* pToolBarWrapper = new AddonsToolBarWrapper( m_xContext );\n xToolBar = Reference< ::com::sun::star::ui::XUIElement >( (OWeakObject *)pToolBarWrapper, UNO_QUERY );\n Reference< XInitialization > xInit( xToolBar, UNO_QUERY );\n xInit->initialize( aPropSeq );\n }\n\n return xToolBar;\n}\n\n}\n\nextern \"C\" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL\ncom_sun_star_comp_framework_AddonsToolBarFactory_get_implementation(\n css::uno::XComponentContext *context,\n css::uno::Sequence const &)\n{\n return cppu::acquire(new AddonsToolBarFactory(context));\n}\n\n\/* vim:set shiftwidth=4 softtabstop=4 expandtab: *\/\n<|endoftext|>"} {"text":"\/****************************************************************************\n**\n** Copyright (c) 2008-2009 Nokia Corporation and\/or its subsidiary(-ies).\n** Contact: Nokia Corporation (qt-info@nokia.com)\n**\n** This file is part of the Qt Mobility Components.\n**\n** $QT_BEGIN_LICENSE:LGPL$\n** No Commercial Usage\n** This file contains pre-release code and may not be distributed.\n** You may use this file in accordance with the terms and conditions\n** contained in Technology Preview License Agreement accompanying\n** this package.\n**\n** GNU Lesser General Public License Usage\n** Alternatively, this file may be used under the terms of the GNU Lesser\n** General Public License version 2.1 as published by the Free Software\n** Foundation and appearing in the file LICENSE.LGPL included in the\n** packaging of this file. Please review the following information to\n** ensure the GNU Lesser General Public License version 2.1 requirements\n** will be met: http:\/\/www.gnu.org\/licenses\/old-licenses\/lgpl-2.1.html.\n**\n** In addition, as a special exception, Nokia gives you certain\n** additional rights. These rights are described in the Nokia Qt LGPL\n** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this\n** package.\n**\n** If you have questions regarding the use of this file, please\n** contact Nokia at http:\/\/qt.nokia.com\/contact.\n** $QT_END_LICENSE$\n**\n****************************************************************************\/\n#include \"..\/qsfwtestutil.h\"\n\n#include \n#include \n#include \n#include \n\nclass TestSession : public QAbstractSecuritySession\n{\npublic:\n TestSession() {}\n virtual ~TestSession(){}\n\n virtual bool isAllowed(const QStringList& serviceCaps) \n {\n \/\/client must have at least service caps;\n QSet sub = serviceCaps.toSet() - clientCaps;;\n if (sub.isEmpty())\n return true;\n else\n return false;\n }\n \n void setClientCaps(const QStringList& capabilities)\n {\n clientCaps = capabilities.toSet();\n }\nprivate:\n QSet clientCaps;\n\n};\n\nclass tst_QAbstractSecuritySession: public QObject\n{\n Q_OBJECT\n \nprivate slots:\n void initTestCase();\n void cleanupTestCase();\n void testSecSessionHandling();\nprivate:\n QString path; \n};\n\nvoid tst_QAbstractSecuritySession::initTestCase()\n{\n path = QCoreApplication::applicationDirPath() + \"\/xmldata\/\";\n\n QSfwTestUtil::setupTempUserDb();\n QSfwTestUtil::setupTempSystemDb();\n\n QSfwTestUtil::removeTempUserDb();\n QSfwTestUtil::removeTempSystemDb();\n}\n\nvoid tst_QAbstractSecuritySession::testSecSessionHandling()\n{\n QFile file(path+\"testserviceplugin.xml\");\n QVERIFY(file.exists());\n\n QServiceManager mgr;\n QVERIFY(mgr.findServices().isEmpty());\n QVERIFY(mgr.addService(&file));\n QVERIFY(mgr.findServices() == (QStringList()<< \"TestService\"));\n\n QServiceFilter simpleFilter;\n simpleFilter.setInterface(\"com.nokia.qt.ISimpleTypeTest\");\n QList list = mgr.findInterfaces(simpleFilter);\n QVERIFY(list.count() == 1);\n QServiceInterfaceDescriptor simpleDesc = list.at(0);\n QVERIFY(simpleDesc.isValid());\n QVERIFY(simpleDesc.majorVersion() == 1);\n QVERIFY(simpleDesc.minorVersion() == 0);\n QVERIFY(simpleDesc.interfaceName() == QString(\"com.nokia.qt.ISimpleTypeTest\"));\n QCOMPARE(simpleDesc.property(QServiceInterfaceDescriptor::Capabilities).toStringList(),\n QStringList() << \"simple\");\n\n QServiceFilter complexFilter;\n complexFilter.setInterface(\"com.nokia.qt.IComplexTypeTest\");\n list = mgr.findInterfaces(complexFilter);\n QVERIFY(list.count() == 1);\n QServiceInterfaceDescriptor complexDesc = list.at(0);\n QVERIFY(complexDesc.isValid());\n QVERIFY(complexDesc.majorVersion() == 2);\n QVERIFY(complexDesc.minorVersion() == 3);\n QVERIFY(complexDesc.interfaceName() == QString(\"com.nokia.qt.IComplexTypeTest\"));\n QCOMPARE(complexDesc.property(QServiceInterfaceDescriptor::Capabilities).toStringList(),\n QStringList() << \"complex\" << \"simple\");\n\n \/\/no QAbstractSecuritySession object\n QObject* o = mgr.loadInterface(simpleDesc, 0, 0 );\n QVERIFY(o);\n delete o;\n o = mgr.loadInterface(complexDesc, 0, 0);\n QVERIFY(o);\n delete o;\n\n \/\/client does not have any permission\n TestSession* secSession = new TestSession();\n secSession->setClientCaps(QStringList());\n\n o = mgr.loadInterface(simpleDesc, 0, secSession );\n QVERIFY(!o);\n o = mgr.loadInterface(complexDesc, 0, secSession);\n QVERIFY(!o);\n\n \/\/client has simple permission\n secSession->setClientCaps(QStringList() << \"simple\");\n o = mgr.loadInterface(simpleDesc, 0, secSession );\n QVERIFY(o);\n o = mgr.loadInterface(complexDesc, 0, secSession);\n QVERIFY(!o);\n \n \/\/client has simple and complex permission\n secSession->setClientCaps(QStringList() << \"simple\" << \"complex\");\n o = mgr.loadInterface(simpleDesc, 0, secSession );\n QVERIFY(o);\n o = mgr.loadInterface(complexDesc, 0, secSession);\n QVERIFY(o);\n \n \/\/client has simple, complex and advanced permission\n secSession->setClientCaps(QStringList() << \"simple\" << \"complex\" << \"advanced\");\n o = mgr.loadInterface(simpleDesc, 0, secSession );\n QVERIFY(o);\n o = mgr.loadInterface(complexDesc, 0, secSession);\n QVERIFY(o);\n\n \/\/client has unknown capability\n secSession->setClientCaps(QStringList() << \"unknown\");\n o = mgr.loadInterface(simpleDesc, 0, secSession );\n QVERIFY(!o);\n o = mgr.loadInterface(complexDesc, 0, secSession);\n QVERIFY(!o);\n \n}\n\nvoid tst_QAbstractSecuritySession::cleanupTestCase()\n{\n QSfwTestUtil::removeTempUserDb();\n QSfwTestUtil::removeTempSystemDb();\n}\n\nQTEST_MAIN(tst_QAbstractSecuritySession)\n#include \"tst_qabstractsecuritysession.moc\"\nFix memory leaks in tests.\/****************************************************************************\n**\n** Copyright (c) 2008-2009 Nokia Corporation and\/or its subsidiary(-ies).\n** Contact: Nokia Corporation (qt-info@nokia.com)\n**\n** This file is part of the Qt Mobility Components.\n**\n** $QT_BEGIN_LICENSE:LGPL$\n** No Commercial Usage\n** This file contains pre-release code and may not be distributed.\n** You may use this file in accordance with the terms and conditions\n** contained in Technology Preview License Agreement accompanying\n** this package.\n**\n** GNU Lesser General Public License Usage\n** Alternatively, this file may be used under the terms of the GNU Lesser\n** General Public License version 2.1 as published by the Free Software\n** Foundation and appearing in the file LICENSE.LGPL included in the\n** packaging of this file. Please review the following information to\n** ensure the GNU Lesser General Public License version 2.1 requirements\n** will be met: http:\/\/www.gnu.org\/licenses\/old-licenses\/lgpl-2.1.html.\n**\n** In addition, as a special exception, Nokia gives you certain\n** additional rights. These rights are described in the Nokia Qt LGPL\n** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this\n** package.\n**\n** If you have questions regarding the use of this file, please\n** contact Nokia at http:\/\/qt.nokia.com\/contact.\n** $QT_END_LICENSE$\n**\n****************************************************************************\/\n#include \"..\/qsfwtestutil.h\"\n\n#include \n#include \n#include \n#include \n\nclass TestSession : public QAbstractSecuritySession\n{\npublic:\n TestSession() {}\n virtual ~TestSession(){}\n\n virtual bool isAllowed(const QStringList& serviceCaps) \n {\n \/\/client must have at least service caps;\n QSet sub = serviceCaps.toSet() - clientCaps;;\n if (sub.isEmpty())\n return true;\n else\n return false;\n }\n \n void setClientCaps(const QStringList& capabilities)\n {\n clientCaps = capabilities.toSet();\n }\nprivate:\n QSet clientCaps;\n\n};\n\nclass tst_QAbstractSecuritySession: public QObject\n{\n Q_OBJECT\n \nprivate slots:\n void initTestCase();\n void cleanupTestCase();\n void cleanup();\n void testSecSessionHandling();\nprivate:\n QString path; \n};\n\nvoid tst_QAbstractSecuritySession::initTestCase()\n{\n path = QCoreApplication::applicationDirPath() + \"\/xmldata\/\";\n\n QSfwTestUtil::setupTempUserDb();\n QSfwTestUtil::setupTempSystemDb();\n\n QSfwTestUtil::removeTempUserDb();\n QSfwTestUtil::removeTempSystemDb();\n}\n\nvoid tst_QAbstractSecuritySession::cleanup()\n{\n \/\/use QEventLopp::DeferredDeletion\n \/\/QServiceManager::loadInterface makes use of deleteLater() when\n \/\/cleaning up service objects and their respective QPluginLoader\n \/\/we want to force the testcase to run the cleanup code\n QCoreApplication::processEvents(QEventLoop::AllEvents|QEventLoop::DeferredDeletion);\n}\n\nvoid tst_QAbstractSecuritySession::testSecSessionHandling()\n{\n QFile file(path+\"testserviceplugin.xml\");\n QVERIFY(file.exists());\n\n QServiceManager mgr;\n QVERIFY(mgr.findServices().isEmpty());\n QVERIFY(mgr.addService(&file));\n QVERIFY(mgr.findServices() == (QStringList()<< \"TestService\"));\n\n QServiceFilter simpleFilter;\n simpleFilter.setInterface(\"com.nokia.qt.ISimpleTypeTest\");\n QList list = mgr.findInterfaces(simpleFilter);\n QVERIFY(list.count() == 1);\n QServiceInterfaceDescriptor simpleDesc = list.at(0);\n QVERIFY(simpleDesc.isValid());\n QVERIFY(simpleDesc.majorVersion() == 1);\n QVERIFY(simpleDesc.minorVersion() == 0);\n QVERIFY(simpleDesc.interfaceName() == QString(\"com.nokia.qt.ISimpleTypeTest\"));\n QCOMPARE(simpleDesc.property(QServiceInterfaceDescriptor::Capabilities).toStringList(),\n QStringList() << \"simple\");\n\n QServiceFilter complexFilter;\n complexFilter.setInterface(\"com.nokia.qt.IComplexTypeTest\");\n list = mgr.findInterfaces(complexFilter);\n QVERIFY(list.count() == 1);\n QServiceInterfaceDescriptor complexDesc = list.at(0);\n QVERIFY(complexDesc.isValid());\n QVERIFY(complexDesc.majorVersion() == 2);\n QVERIFY(complexDesc.minorVersion() == 3);\n QVERIFY(complexDesc.interfaceName() == QString(\"com.nokia.qt.IComplexTypeTest\"));\n QCOMPARE(complexDesc.property(QServiceInterfaceDescriptor::Capabilities).toStringList(),\n QStringList() << \"complex\" << \"simple\");\n\n \/\/no QAbstractSecuritySession object\n QObject* o = mgr.loadInterface(simpleDesc, 0, 0 );\n QVERIFY(o);\n delete o;\n o = mgr.loadInterface(complexDesc, 0, 0);\n QVERIFY(o);\n delete o;\n\n \/\/client does not have any permission\n TestSession* secSession = new TestSession();\n secSession->setClientCaps(QStringList());\n\n o = mgr.loadInterface(simpleDesc, 0, secSession );\n QVERIFY(!o);\n o = mgr.loadInterface(complexDesc, 0, secSession);\n QVERIFY(!o);\n\n \/\/client has simple permission\n secSession->setClientCaps(QStringList() << \"simple\");\n o = mgr.loadInterface(simpleDesc, 0, secSession );\n QVERIFY(o);\n delete o;\n o = mgr.loadInterface(complexDesc, 0, secSession);\n QVERIFY(!o);\n \n \/\/client has simple and complex permission\n secSession->setClientCaps(QStringList() << \"simple\" << \"complex\");\n o = mgr.loadInterface(simpleDesc, 0, secSession );\n QVERIFY(o);\n delete o;\n o = mgr.loadInterface(complexDesc, 0, secSession);\n QVERIFY(o);\n delete o;\n \n \/\/client has simple, complex and advanced permission\n secSession->setClientCaps(QStringList() << \"simple\" << \"complex\" << \"advanced\");\n o = mgr.loadInterface(simpleDesc, 0, secSession );\n QVERIFY(o);\n delete o;\n o = mgr.loadInterface(complexDesc, 0, secSession);\n QVERIFY(o);\n delete o;\n\n \/\/client has unknown capability\n secSession->setClientCaps(QStringList() << \"unknown\");\n o = mgr.loadInterface(simpleDesc, 0, secSession );\n QVERIFY(!o);\n o = mgr.loadInterface(complexDesc, 0, secSession);\n QVERIFY(!o);\n\n delete secSession;\n}\n\nvoid tst_QAbstractSecuritySession::cleanupTestCase()\n{\n QSfwTestUtil::removeTempUserDb();\n QSfwTestUtil::removeTempSystemDb();\n}\n\nQTEST_MAIN(tst_QAbstractSecuritySession)\n#include \"tst_qabstractsecuritysession.moc\"\n<|endoftext|>"} {"text":"\/*=========================================================================\n\n Program: Visualization Toolkit\n Module: Glyph3D.cc\n Language: C++\n Date: $Date$\n Version: $Revision$\n\nThis file is part of the Visualization Toolkit. No part of this file\nor its contents may be copied, reproduced or altered in any way\nwithout the express written consent of the authors.\n\nCopyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994 \n\n=========================================================================*\/\n#include \"Glyph3D.hh\"\n#include \"Trans.hh\"\n#include \"FVectors.hh\"\n#include \"FNormals.hh\"\n#include \"vtkMath.hh\"\n\n\/\/ Description\n\/\/ Construct object with scaling on, scaling mode is by scalar value, \n\/\/ scale factor = 1.0, the range is (0,1), orient geometry is on, and\n\/\/ orientation is by vector.\nvtkGlyph3D::vtkGlyph3D()\n{\n this->Source = NULL;\n this->Scaling = 1;\n this->ScaleMode = SCALE_BY_SCALAR;\n this->ScaleFactor = 1.0;\n this->Range[0] = 0.0;\n this->Range[1] = 1.0;\n this->Orient = 1;\n this->VectorMode = USE_VECTOR;\n}\n\nvtkGlyph3D::~vtkGlyph3D()\n{\n}\n\nvoid vtkGlyph3D::Execute()\n{\n vtkPointData *pd;\n vtkScalars *inScalars;\n vtkVectors *inVectors;\n vtkNormals *inNormals, *sourceNormals;\n int numPts, numSourcePts, numSourceCells;\n int inPtId, i;\n vtkPoints *sourcePts;\n vtkCellArray *sourceCells; \n vtkFloatPoints *newPts;\n vtkFloatScalars *newScalars=NULL;\n vtkFloatVectors *newVectors=NULL;\n vtkFloatNormals *newNormals=NULL;\n float *x, *v, vNew[3];\n vtkTransform trans;\n vtkCell *cell;\n vtkIdList *cellPts;\n int npts, pts[MAX_CELL_SIZE];\n int orient, scaleSource, ptIncr, cellId;\n float scale, den;\n vtkMath math;\n\n vtkDebugMacro(<<\"Generating glyphs\");\n this->Initialize();\n\n pd = this->Input->GetPointData();\n inScalars = pd->GetScalars();\n inVectors = pd->GetVectors();\n inNormals = pd->GetNormals();\n\n numPts = this->Input->GetNumberOfPoints();\n\/\/\n\/\/ Allocate storage for output PolyData\n\/\/\n sourcePts = this->Source->GetPoints();\n numSourcePts = sourcePts->GetNumberOfPoints();\n numSourceCells = this->Source->GetNumberOfCells();\n sourceNormals = this->Source->GetPointData()->GetNormals();\n\n newPts = new vtkFloatPoints(numPts*numSourcePts);\n if (inScalars != NULL) \n newScalars = new vtkFloatScalars(numPts*numSourcePts);\n if (inVectors != NULL || inNormals != NULL ) \n newVectors = new vtkFloatVectors(numPts*numSourcePts);\n if (sourceNormals != NULL) \n newNormals = new vtkFloatNormals(numPts*numSourcePts);\n\n \/\/ Setting up for calls to PolyData::InsertNextCell()\n if ( (sourceCells=this->Source->GetVerts())->GetNumberOfCells() > 0 )\n {\n this->SetVerts(new vtkCellArray(numPts*sourceCells->GetSize()));\n }\n if ( (sourceCells=this->Source->GetLines())->GetNumberOfCells() > 0 )\n {\n this->SetLines(new vtkCellArray(numPts*sourceCells->GetSize()));\n }\n if ( (sourceCells=this->Source->GetPolys())->GetNumberOfCells() > 0 )\n {\n this->SetPolys(new vtkCellArray(numPts*sourceCells->GetSize()));\n }\n if ( (sourceCells=this->Source->GetStrips())->GetNumberOfCells() > 0 )\n {\n this->SetStrips(new vtkCellArray(numPts*sourceCells->GetSize()));\n }\n\/\/\n\/\/ Copy (input scalars) to (output scalars) and either (input vectors or\n\/\/ normals) to (output vectors). All other point attributes are copied \n\/\/ from Source.\n\/\/\n pd = this->Source->GetPointData();\n this->PointData.CopyScalarsOff();\n this->PointData.CopyVectorsOff();\n this->PointData.CopyNormalsOff();\n this->PointData.CopyAllocate(pd,numPts*numSourcePts);\n\/\/\n\/\/ First copy all topology (transformation independent)\n\/\/\n for (inPtId=0; inPtId < numPts; inPtId++)\n {\n ptIncr = inPtId * numSourcePts;\n for (cellId=0; cellId < numSourceCells; cellId++)\n {\n cell = this->Source->GetCell(cellId);\n cellPts = cell->GetPointIds();\n npts = cellPts->GetNumberOfIds();\n for (i=0; i < npts; i++) pts[i] = cellPts->GetId(i) + ptIncr;\n this->InsertNextCell(cell->GetCellType(),npts,pts);\n }\n }\n\/\/\n\/\/ Traverse all Input points, transforming Source points and copying \n\/\/ point attributes.\n\/\/\n if ( (this->VectorMode == USE_VECTOR && inVectors != NULL) ||\n (this->VectorMode == USE_NORMAL && inNormals != NULL) )\n orient = 1;\n else\n orient = 0;\n \n if ( this->Scaling && \n ((this->ScaleMode == SCALE_BY_SCALAR && inScalars != NULL) ||\n (this->ScaleMode == SCALE_BY_VECTOR && (inVectors || inNormals))) )\n scaleSource = 1;\n else\n scaleSource = 0;\n\n for (inPtId=0; inPtId < numPts; inPtId++)\n {\n ptIncr = inPtId * numSourcePts;\n \n trans.Identity();\n\n \/\/ translate Source to Input point\n x = this->Input->GetPoint(inPtId);\n trans.Translate(x[0], x[1], x[2]);\n\n if ( orient )\n {\n if ( this->VectorMode == USE_NORMAL )\n v = inNormals->GetNormal(inPtId);\n else\n v = inVectors->GetVector(inPtId);\n scale = math.Norm(v);\n\n \/\/ Copy Input vector\n for (i=0; i < numSourcePts; i++) \n newVectors->InsertVector(ptIncr+i,v);\n \n if ( this->Orient ) \n {\n vNew[0] = (v[0]+scale) \/ 2.0;\n vNew[1] = v[1] \/ 2.0;\n vNew[2] = v[2] \/ 2.0;\n trans.RotateWXYZ(180.0,vNew[0],vNew[1],vNew[2]);\n }\n }\n\n \/\/ determine scale factor from scalars if appropriate\n if ( inScalars != NULL )\n {\n \/\/ Copy Input scalar\n for (i=0; i < numSourcePts; i++) \n newScalars->InsertScalar(ptIncr+i,scale);\n\n if ( this->ScaleMode == SCALE_BY_SCALAR )\n {\n if ( (den = this->Range[1] - this->Range[0]) == 0.0 ) den = 1.0;\n scale = inScalars->GetScalar(inPtId);\n\n\n scale = (scale < this->Range[0] ? this->Range[0] :\n (scale > this->Range[1] ? this->Range[1] : scale));\n scale = (scale - this->Range[0]) \/ den;\n\n }\n }\n\n \/\/ scale data if appropriate\n if ( scaleSource )\n {\n scale *= this->ScaleFactor;\n if ( scale == 0.0 ) scale = 1.0e-10;\n trans.Scale(scale,scale,scale);\n }\n\n \/\/ multiply points and normals by resulting matrix\n trans.MultiplyPoints(sourcePts,newPts);\n if ( sourceNormals != NULL ) \n trans.MultiplyNormals(sourceNormals,newNormals);\n\n \/\/ Copy point data from source\n for (i=0; i < numSourcePts; i++) \n this->PointData.CopyData(pd,i,ptIncr+i);\n }\n\/\/\n\/\/ Update ourselves\n\/\/\n this->SetPoints(newPts);\n this->PointData.SetScalars(newScalars);\n this->PointData.SetVectors(newVectors);\n this->PointData.SetNormals(newNormals);\n this->Squeeze();\n}\n\n\/\/ Description:\n\/\/ Override update method because execution can branch two ways (Input \n\/\/ and Source)\nvoid vtkGlyph3D::Update()\n{\n \/\/ make sure input is available\n if ( this->Input == NULL || this->Source == NULL )\n {\n vtkErrorMacro(<< \"No input!\");\n return;\n }\n\n \/\/ prevent chasing our tail\n if (this->Updating) return;\n\n this->Updating = 1;\n this->Input->Update();\n this->Source->Update();\n this->Updating = 0;\n\n if (this->Input->GetMTime() > this->GetMTime() || \n this->Source->GetMTime() > this->GetMTime() || \n this->GetMTime() > this->ExecuteTime || this->GetDataReleased() )\n {\n if ( this->StartMethod ) (*this->StartMethod)(this->StartMethodArg);\n this->Execute();\n this->ExecuteTime.Modified();\n this->SetDataReleased(0);\n if ( this->EndMethod ) (*this->EndMethod)(this->EndMethodArg);\n }\n\n if ( this->Input->ShouldIReleaseData() ) this->Input->ReleaseData();\n if ( this->Source->ShouldIReleaseData() ) this->Source->ReleaseData();\n}\n\nvoid vtkGlyph3D::PrintSelf(ostream& os, vtkIndent indent)\n{\n vtkDataSetToPolyFilter::PrintSelf(os,indent);\n\n os << indent << \"Source: \" << this->Source << \"\\n\";\n os << indent << \"Scaling: \" << (this->Scaling ? \"On\\n\" : \"Off\\n\");\n os << indent << \"Scale Mode: \" << (this->ScaleMode == SCALE_BY_SCALAR ? \"Scale by scalar\\n\" : \"Scale by vector\\n\");\n os << indent << \"Scale Factor: \" << this->ScaleFactor << \"\\n\";\n os << indent << \"Range: (\" << this->Range[0] << \", \" << this->Range[1] << \")\\n\";\n os << indent << \"Orient: \" << (this->Orient ? \"On\\n\" : \"Off\\n\");\n\n os << indent << \"Orient Mode: \" << (this->VectorMode == USE_VECTOR ? \"Orient by vector\\n\" : \"Orient by normal\\n\");\n}\n\nfixed scalar copying bug\/*=========================================================================\n\n Program: Visualization Toolkit\n Module: Glyph3D.cc\n Language: C++\n Date: $Date$\n Version: $Revision$\n\nThis file is part of the Visualization Toolkit. No part of this file\nor its contents may be copied, reproduced or altered in any way\nwithout the express written consent of the authors.\n\nCopyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994 \n\n=========================================================================*\/\n#include \"Glyph3D.hh\"\n#include \"Trans.hh\"\n#include \"FVectors.hh\"\n#include \"FNormals.hh\"\n#include \"vtkMath.hh\"\n\n\/\/ Description\n\/\/ Construct object with scaling on, scaling mode is by scalar value, \n\/\/ scale factor = 1.0, the range is (0,1), orient geometry is on, and\n\/\/ orientation is by vector.\nvtkGlyph3D::vtkGlyph3D()\n{\n this->Source = NULL;\n this->Scaling = 1;\n this->ScaleMode = SCALE_BY_SCALAR;\n this->ScaleFactor = 1.0;\n this->Range[0] = 0.0;\n this->Range[1] = 1.0;\n this->Orient = 1;\n this->VectorMode = USE_VECTOR;\n}\n\nvtkGlyph3D::~vtkGlyph3D()\n{\n}\n\nvoid vtkGlyph3D::Execute()\n{\n vtkPointData *pd;\n vtkScalars *inScalars;\n vtkVectors *inVectors;\n vtkNormals *inNormals, *sourceNormals;\n int numPts, numSourcePts, numSourceCells;\n int inPtId, i;\n vtkPoints *sourcePts;\n vtkCellArray *sourceCells; \n vtkFloatPoints *newPts;\n vtkFloatScalars *newScalars=NULL;\n vtkFloatVectors *newVectors=NULL;\n vtkFloatNormals *newNormals=NULL;\n float *x, *v, vNew[3];\n vtkTransform trans;\n vtkCell *cell;\n vtkIdList *cellPts;\n int npts, pts[MAX_CELL_SIZE];\n int orient, scaleSource, ptIncr, cellId;\n float scale, den;\n vtkMath math;\n\n vtkDebugMacro(<<\"Generating glyphs\");\n this->Initialize();\n\n pd = this->Input->GetPointData();\n inScalars = pd->GetScalars();\n inVectors = pd->GetVectors();\n inNormals = pd->GetNormals();\n\n numPts = this->Input->GetNumberOfPoints();\n\/\/\n\/\/ Allocate storage for output PolyData\n\/\/\n sourcePts = this->Source->GetPoints();\n numSourcePts = sourcePts->GetNumberOfPoints();\n numSourceCells = this->Source->GetNumberOfCells();\n sourceNormals = this->Source->GetPointData()->GetNormals();\n\n newPts = new vtkFloatPoints(numPts*numSourcePts);\n if (inScalars != NULL) \n newScalars = new vtkFloatScalars(numPts*numSourcePts);\n if (inVectors != NULL || inNormals != NULL ) \n newVectors = new vtkFloatVectors(numPts*numSourcePts);\n if (sourceNormals != NULL) \n newNormals = new vtkFloatNormals(numPts*numSourcePts);\n\n \/\/ Setting up for calls to PolyData::InsertNextCell()\n if ( (sourceCells=this->Source->GetVerts())->GetNumberOfCells() > 0 )\n {\n this->SetVerts(new vtkCellArray(numPts*sourceCells->GetSize()));\n }\n if ( (sourceCells=this->Source->GetLines())->GetNumberOfCells() > 0 )\n {\n this->SetLines(new vtkCellArray(numPts*sourceCells->GetSize()));\n }\n if ( (sourceCells=this->Source->GetPolys())->GetNumberOfCells() > 0 )\n {\n this->SetPolys(new vtkCellArray(numPts*sourceCells->GetSize()));\n }\n if ( (sourceCells=this->Source->GetStrips())->GetNumberOfCells() > 0 )\n {\n this->SetStrips(new vtkCellArray(numPts*sourceCells->GetSize()));\n }\n\/\/\n\/\/ Copy (input scalars) to (output scalars) and either (input vectors or\n\/\/ normals) to (output vectors). All other point attributes are copied \n\/\/ from Source.\n\/\/\n pd = this->Source->GetPointData();\n this->PointData.CopyScalarsOff();\n this->PointData.CopyVectorsOff();\n this->PointData.CopyNormalsOff();\n this->PointData.CopyAllocate(pd,numPts*numSourcePts);\n\/\/\n\/\/ First copy all topology (transformation independent)\n\/\/\n for (inPtId=0; inPtId < numPts; inPtId++)\n {\n ptIncr = inPtId * numSourcePts;\n for (cellId=0; cellId < numSourceCells; cellId++)\n {\n cell = this->Source->GetCell(cellId);\n cellPts = cell->GetPointIds();\n npts = cellPts->GetNumberOfIds();\n for (i=0; i < npts; i++) pts[i] = cellPts->GetId(i) + ptIncr;\n this->InsertNextCell(cell->GetCellType(),npts,pts);\n }\n }\n\/\/\n\/\/ Traverse all Input points, transforming Source points and copying \n\/\/ point attributes.\n\/\/\n if ( (this->VectorMode == USE_VECTOR && inVectors != NULL) ||\n (this->VectorMode == USE_NORMAL && inNormals != NULL) )\n orient = 1;\n else\n orient = 0;\n \n if ( this->Scaling && \n ((this->ScaleMode == SCALE_BY_SCALAR && inScalars != NULL) ||\n (this->ScaleMode == SCALE_BY_VECTOR && (inVectors || inNormals))) )\n scaleSource = 1;\n else\n scaleSource = 0;\n\n for (inPtId=0; inPtId < numPts; inPtId++)\n {\n ptIncr = inPtId * numSourcePts;\n \n trans.Identity();\n\n \/\/ translate Source to Input point\n x = this->Input->GetPoint(inPtId);\n trans.Translate(x[0], x[1], x[2]);\n\n if ( orient )\n {\n if ( this->VectorMode == USE_NORMAL )\n v = inNormals->GetNormal(inPtId);\n else\n v = inVectors->GetVector(inPtId);\n scale = math.Norm(v);\n\n \/\/ Copy Input vector\n for (i=0; i < numSourcePts; i++) \n newVectors->InsertVector(ptIncr+i,v);\n \n if ( this->Orient ) \n {\n vNew[0] = (v[0]+scale) \/ 2.0;\n vNew[1] = v[1] \/ 2.0;\n vNew[2] = v[2] \/ 2.0;\n trans.RotateWXYZ(180.0,vNew[0],vNew[1],vNew[2]);\n }\n }\n\n \/\/ determine scale factor from scalars if appropriate\n if ( inScalars != NULL )\n {\n \/\/ Copy Input scalar\n scale = inScalars->GetScalar(inPtId);\n if ( this->ScaleMode == SCALE_BY_SCALAR )\n {\n if ( (den = this->Range[1] - this->Range[0]) == 0.0 ) den = 1.0;\n\n scale = (scale < this->Range[0] ? this->Range[0] :\n (scale > this->Range[1] ? this->Range[1] : scale));\n scale = (scale - this->Range[0]) \/ den;\n\n }\n\n for (i=0; i < numSourcePts; i++) \n newScalars->InsertScalar(ptIncr+i,scale);\n }\n\n \/\/ scale data if appropriate\n if ( scaleSource )\n {\n scale *= this->ScaleFactor;\n if ( scale == 0.0 ) scale = 1.0e-10;\n trans.Scale(scale,scale,scale);\n }\n\n \/\/ multiply points and normals by resulting matrix\n trans.MultiplyPoints(sourcePts,newPts);\n if ( sourceNormals != NULL ) \n trans.MultiplyNormals(sourceNormals,newNormals);\n\n \/\/ Copy point data from source\n for (i=0; i < numSourcePts; i++) \n this->PointData.CopyData(pd,i,ptIncr+i);\n }\n\/\/\n\/\/ Update ourselves\n\/\/\n this->SetPoints(newPts);\n this->PointData.SetScalars(newScalars);\n this->PointData.SetVectors(newVectors);\n this->PointData.SetNormals(newNormals);\n this->Squeeze();\n}\n\n\/\/ Description:\n\/\/ Override update method because execution can branch two ways (Input \n\/\/ and Source)\nvoid vtkGlyph3D::Update()\n{\n \/\/ make sure input is available\n if ( this->Input == NULL || this->Source == NULL )\n {\n vtkErrorMacro(<< \"No input!\");\n return;\n }\n\n \/\/ prevent chasing our tail\n if (this->Updating) return;\n\n this->Updating = 1;\n this->Input->Update();\n this->Source->Update();\n this->Updating = 0;\n\n if (this->Input->GetMTime() > this->GetMTime() || \n this->Source->GetMTime() > this->GetMTime() || \n this->GetMTime() > this->ExecuteTime || this->GetDataReleased() )\n {\n if ( this->StartMethod ) (*this->StartMethod)(this->StartMethodArg);\n this->Execute();\n this->ExecuteTime.Modified();\n this->SetDataReleased(0);\n if ( this->EndMethod ) (*this->EndMethod)(this->EndMethodArg);\n }\n\n if ( this->Input->ShouldIReleaseData() ) this->Input->ReleaseData();\n if ( this->Source->ShouldIReleaseData() ) this->Source->ReleaseData();\n}\n\nvoid vtkGlyph3D::PrintSelf(ostream& os, vtkIndent indent)\n{\n vtkDataSetToPolyFilter::PrintSelf(os,indent);\n\n os << indent << \"Source: \" << this->Source << \"\\n\";\n os << indent << \"Scaling: \" << (this->Scaling ? \"On\\n\" : \"Off\\n\");\n os << indent << \"Scale Mode: \" << (this->ScaleMode == SCALE_BY_SCALAR ? \"Scale by scalar\\n\" : \"Scale by vector\\n\");\n os << indent << \"Scale Factor: \" << this->ScaleFactor << \"\\n\";\n os << indent << \"Range: (\" << this->Range[0] << \", \" << this->Range[1] << \")\\n\";\n os << indent << \"Orient: \" << (this->Orient ? \"On\\n\" : \"Off\\n\");\n\n os << indent << \"Orient Mode: \" << (this->VectorMode == USE_VECTOR ? \"Orient by vector\\n\" : \"Orient by normal\\n\");\n}\n\n<|endoftext|>"} {"text":"\/*\n * DIPlib 3.0 viewer\n * This file contains functionality for the status bar.\n *\n * (c)2017, Wouter Caarls\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http:\/\/www.apache.org\/licenses\/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\/\n\n#include \"diplib\/viewer\/include_gl.h\"\n#include \"diplib\/viewer\/status.h\"\n\nnamespace dip { namespace viewer {\n\nvoid StatusViewPort::render()\n{\n auto &o = viewer()->options();\n\n glMatrixMode(GL_PROJECTION);\n glLoadIdentity();\n glViewport(x_, viewer()->height()-y_-height_, width_, height_);\n glOrtho(0, width(), height(), 0, -1, 1);\n glMatrixMode(GL_MODELVIEW);\n\n glColor3f(.5, .5, .5);\n glBegin(GL_LINES);\n glVertex2f(0.f, 0.f);\n glVertex2f((GLfloat)width(), 0.f);\n glEnd();\n \n glColor3f(1., 1., 1.);\n glRasterPos2i(1, 12);\n \n size_t rx = 1;\n \n if (o.status_ != \"\")\n {\n viewer()->drawString(o.status_.c_str());\n }\n else\n {\n \/\/ Describe operating point\n auto op = o.operating_point_;\n auto te = (int)viewer()->image().TensorElements();\n auto opp = viewer()->image().PixelsToPhysical((FloatArray)op);\n \n rx += viewer()->drawString(\"(\");\n for (dip::uint ii=0; ii < op.size(); ++ii)\n {\n rx += viewer()->drawString(std::to_string(op[ii]).c_str());\n if (viewer()->image().PixelSize(ii) != PhysicalQuantity::Pixel() || o.offset_[ii])\n {\n std::ostringstream oss;\n PhysicalQuantity p = opp[ii] + o.offset_[ii];\n p.Normalize();\n oss << \"=\" << p;\n rx += viewer()->drawString(oss.str().c_str());\n }\n \n if (ii < op.size()-1)\n rx += viewer()->drawString(\", \");\n }\n rx += viewer()->drawString(\"): \");\n if (te > 1)\n rx += viewer()->drawString(\"[\");\n \n for (int ii=0; ii < te; ++ii)\n {\n if (o.lut_ == ViewingOptions::LookupTable::RGB)\n {\n if (ii == o.color_elements_[0])\n glColor3d(0.9, 0.17, 0.);\n else if (ii == o.color_elements_[1])\n glColor3d(0.0, 0.50, 0.);\n else if (ii == o.color_elements_[2])\n glColor3d(0.1, 0.33, 1.);\n else\n glColor3f(.5, .5, .5);\n }\n else\n {\n if ((size_t)ii == o.element_)\n glColor3f(1., 1., 1.);\n else\n glColor3f(.5, .5, .5);\n }\n \n glRasterPos2i((GLint)rx, 12);\n rx += viewer()->drawString(std::to_string((dip::sfloat)viewer()->image().At(op)[(size_t)ii]).c_str());\n \n glColor3f(1., 1., 1.);\n glRasterPos2i((GLint)rx, 12);\n \n if (ii < te-1)\n rx += viewer()->drawString(\", \");\n }\n if (te > 1)\n rx += viewer()->drawString(\"]\");\n }\n}\n\n}} \/\/ namespace dip::viewer\nFixed units display in viewer status bar\/*\n * DIPlib 3.0 viewer\n * This file contains functionality for the status bar.\n *\n * (c)2017, Wouter Caarls\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http:\/\/www.apache.org\/licenses\/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\/\n\n#include \"diplib\/viewer\/include_gl.h\"\n#include \"diplib\/viewer\/status.h\"\n\nnamespace dip { namespace viewer {\n\nvoid StatusViewPort::render()\n{\n auto &o = viewer()->options();\n\n glMatrixMode(GL_PROJECTION);\n glLoadIdentity();\n glViewport(x_, viewer()->height()-y_-height_, width_, height_);\n glOrtho(0, width(), height(), 0, -1, 1);\n glMatrixMode(GL_MODELVIEW);\n\n glColor3f(.5, .5, .5);\n glBegin(GL_LINES);\n glVertex2f(0.f, 0.f);\n glVertex2f((GLfloat)width(), 0.f);\n glEnd();\n \n glColor3f(1., 1., 1.);\n glRasterPos2i(1, 12);\n \n size_t rx = 1;\n \n if (o.status_ != \"\")\n {\n viewer()->drawString(o.status_.c_str());\n }\n else\n {\n \/\/ Describe operating point\n auto op = o.operating_point_;\n auto te = (int)viewer()->image().TensorElements();\n auto opp = viewer()->image().PixelsToPhysical((FloatArray)op);\n \n rx += viewer()->drawString(\"(\");\n for (dip::uint ii=0; ii < op.size(); ++ii)\n {\n rx += viewer()->drawString(std::to_string(op[ii]).c_str());\n if (viewer()->image().PixelSize(ii) != PhysicalQuantity::Pixel() || o.offset_[ii])\n {\n std::ostringstream oss;\n PhysicalQuantity p = opp[ii] + o.offset_[ii];\n p.Normalize();\n oss << \"=\" << p.magnitude << p.units.String();\n rx += viewer()->drawString(oss.str().c_str());\n }\n \n if (ii < op.size()-1)\n rx += viewer()->drawString(\", \");\n }\n rx += viewer()->drawString(\"): \");\n if (te > 1)\n rx += viewer()->drawString(\"[\");\n \n for (int ii=0; ii < te; ++ii)\n {\n if (o.lut_ == ViewingOptions::LookupTable::RGB)\n {\n if (ii == o.color_elements_[0])\n glColor3d(0.9, 0.17, 0.);\n else if (ii == o.color_elements_[1])\n glColor3d(0.0, 0.50, 0.);\n else if (ii == o.color_elements_[2])\n glColor3d(0.1, 0.33, 1.);\n else\n glColor3f(.5, .5, .5);\n }\n else\n {\n if ((size_t)ii == o.element_)\n glColor3f(1., 1., 1.);\n else\n glColor3f(.5, .5, .5);\n }\n \n glRasterPos2i((GLint)rx, 12);\n rx += viewer()->drawString(std::to_string((dip::sfloat)viewer()->image().At(op)[(size_t)ii]).c_str());\n \n glColor3f(1., 1., 1.);\n glRasterPos2i((GLint)rx, 12);\n \n if (ii < te-1)\n rx += viewer()->drawString(\", \");\n }\n if (te > 1)\n rx += viewer()->drawString(\"]\");\n }\n}\n\n}} \/\/ namespace dip::viewer\n<|endoftext|>"} {"text":"\/\/ SciTE - Scintilla based Text Editor\n\/** @file LexAVE.cxx\n ** Lexer for Avenue.\n **\n ** Written by Alexey Yutkin .\n **\/\n\/\/ Copyright 1998-2002 by Neil Hodgson \n\/\/ The License.txt file describes the conditions under which this software may be distributed.\n\n#include \n#include \n#include \n#include \n#include \n\n#include \"Platform.h\"\n\n#include \"PropSet.h\"\n#include \"Accessor.h\"\n#include \"StyleContext.h\"\n#include \"KeyWords.h\"\n#include \"Scintilla.h\"\n#include \"SciLexer.h\"\n\n\n\nstatic inline bool IsAWordChar(const int ch) {\n\treturn (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');\n}\nstatic inline bool IsEnumChar(const int ch) {\n\treturn (ch < 0x80) && (isalnum(ch)|| ch == '_');\n}\nstatic inline bool IsANumberChar(const int ch) {\n\treturn (ch < 0x80) && (isalnum(ch) || ch == '.' );\n}\n\ninline bool IsAWordStart(const int ch) {\n\treturn (ch < 0x80) && (isalnum(ch) || ch == '_');\n}\n\ninline bool isAveOperator(char ch) {\n\tif (isalnum(ch))\n\t\treturn false;\n\t\/\/ '.' left out as it is used to make up numbers\n\tif (ch == '*' || ch == '\/' || ch == '-' || ch == '+' ||\n\t\tch == '(' || ch == ')' || ch == '=' ||\n\t\tch == '{' || ch == '}' ||\n\t\tch == '[' || ch == ']' || ch == ';' ||\n\t\tch == '<' || ch == '>' || ch == ',' ||\n\t\tch == '.' )\n\t\treturn true;\n\treturn false;\n}\n\nstatic void ColouriseAveDoc(\n\tunsigned int startPos,\n\tint length,\n\tint initStyle,\n\tWordList *keywordlists[],\n\tAccessor &styler) {\n\n\tWordList &keywords = *keywordlists[0];\n\tWordList &keywords2 = *keywordlists[1];\n\tWordList &keywords3 = *keywordlists[2];\n\tWordList &keywords4 = *keywordlists[3];\n\tWordList &keywords5 = *keywordlists[4];\n\tWordList &keywords6 = *keywordlists[5];\n\n\t\/\/ Do not leak onto next line\n\tif (initStyle == SCE_AVE_STRINGEOL) {\n\t\tinitStyle = SCE_AVE_DEFAULT;\n\t}\n\n\tStyleContext sc(startPos, length, initStyle, styler);\n\n\tfor (; sc.More(); sc.Forward()) {\n\t\tif (sc.atLineEnd) {\n\t\t\t\/\/ Update the line state, so it can be seen by next line\n\t\t\tint currentLine = styler.GetLine(sc.currentPos);\n\t\t\tstyler.SetLineState(currentLine, 0);\n\t\t}\n\t\tif (sc.atLineStart && (sc.state == SCE_AVE_STRING)) {\n\t\t\t\/\/ Prevent SCE_AVE_STRINGEOL from leaking back to previous line\n\t\t\tsc.SetState(SCE_AVE_STRING);\n\t\t}\n\n\n\t\t\/\/ Determine if the current state should terminate.\n\t\tif (sc.state == SCE_AVE_OPERATOR) {\n\t\t\tsc.SetState(SCE_AVE_DEFAULT);\n\t\t} else if (sc.state == SCE_AVE_NUMBER) {\n\t\t\tif (!IsANumberChar(sc.ch)) {\n\t\t\t\tsc.SetState(SCE_AVE_DEFAULT);\n\t\t\t}\n\t\t} else if (sc.state == SCE_AVE_ENUM) {\n\t\t\tif (!IsEnumChar(sc.ch)) {\n\t\t\t\tsc.SetState(SCE_AVE_DEFAULT);\n\t\t\t}\n\t\t} else if (sc.state == SCE_AVE_IDENTIFIER) {\n\t\t\tif (!IsAWordChar(sc.ch) || (sc.ch == '.')) {\n\t\t\t\tchar s[100];\n\t\t\t\t\/\/sc.GetCurrent(s, sizeof(s));\n\t\t\t\tsc.GetCurrentLowered(s, sizeof(s));\n\t\t\t\tif (keywords.InList(s)) {\n\t\t\t\t\tsc.ChangeState(SCE_AVE_WORD);\n\t\t\t\t} else if (keywords2.InList(s)) {\n\t\t\t\t\tsc.ChangeState(SCE_AVE_WORD2);\n\t\t\t\t} else if (keywords3.InList(s)) {\n\t\t\t\t\tsc.ChangeState(SCE_AVE_WORD3);\n\t\t\t\t} else if (keywords4.InList(s)) {\n\t\t\t\t\tsc.ChangeState(SCE_AVE_WORD4);\n\t\t\t\t} else if (keywords5.InList(s)) {\n\t\t\t\t\tsc.ChangeState(SCE_AVE_WORD5);\n\t\t\t\t} else if (keywords6.InList(s)) {\n\t\t\t\t\tsc.ChangeState(SCE_AVE_WORD6);\n\t\t\t\t}\n\t\t\t\tsc.SetState(SCE_AVE_DEFAULT);\n\t\t\t}\n\t\t} else if (sc.state == SCE_AVE_COMMENT) {\n\t\t\tif (sc.atLineEnd) {\n\t\t\t\tsc.SetState(SCE_AVE_DEFAULT);\n\t\t\t}\n\t\t} else if (sc.state == SCE_AVE_STRING) {\n\t\t\t if (sc.ch == '\\\"') {\n\t\t\t\tsc.ForwardSetState(SCE_AVE_DEFAULT);\n\t\t\t} else if (sc.atLineEnd) {\n\t\t\t\tsc.ChangeState(SCE_AVE_STRINGEOL);\n\t\t\t\tsc.ForwardSetState(SCE_AVE_DEFAULT);\n\t\t\t}\n\t\t}\n\n\t\t\/\/ Determine if a new state should be entered.\n\t\tif (sc.state == SCE_AVE_DEFAULT) {\n\t\t\tif (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {\n\t\t\t\tsc.SetState(SCE_AVE_NUMBER);\n\t\t\t} else if (IsAWordStart(sc.ch)) {\n\t\t\t\tsc.SetState(SCE_AVE_IDENTIFIER);\n\t\t\t} else if (sc.Match('\\\"')) {\n\t\t\t\tsc.SetState(SCE_AVE_STRING);\n\t\t\t} else if (sc.Match('\\'')) {\n\t\t\t\tsc.SetState(SCE_AVE_COMMENT);\n\t\t\t\tsc.Forward();\n\t\t\t} else if (isAveOperator(static_cast(sc.ch))) {\n\t\t\t\tsc.SetState(SCE_AVE_OPERATOR);\n\t\t\t} else if (sc.Match('#')) {\n\t\t\t\tsc.SetState(SCE_AVE_ENUM);\n\t\t\t\tsc.Forward();\n\t\t\t}\n\t\t}\n\t}\n\tsc.Complete();\n}\n\nstatic void FoldAveDoc(unsigned int startPos, int length, int \/* initStyle *\/, WordList *[],\n Accessor &styler) {\n\tunsigned int lengthDoc = startPos + length;\n\tint visibleChars = 0;\n\tint lineCurrent = styler.GetLine(startPos);\n\tint levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;\n\tint levelCurrent = levelPrev;\n\tchar chNext = static_cast(tolower(styler[startPos]));\n\tbool foldCompact = styler.GetPropertyInt(\"fold.compact\", 1) != 0;\n\tint styleNext = styler.StyleAt(startPos);\n\tchar s[10];\n\n\tfor (unsigned int i = startPos; i < lengthDoc; i++) {\n\t\tchar ch = static_cast(tolower(chNext));\n\t\tchNext = static_cast(tolower(styler.SafeGetCharAt(i + 1)));\n\t\tint style = styleNext;\n\t\tstyleNext = styler.StyleAt(i + 1);\n\t\tbool atEOL = (ch == '\\r' && chNext != '\\n') || (ch == '\\n');\n\t\tif (style == SCE_AVE_WORD) {\n\t\t\tif (ch == 't' || ch == 'f' || ch == 'w' || ch == 'e') {\n\t\t\t\tfor (unsigned int j = 0; j < 6; j++) {\n\t\t\t\t\tif (!iswordchar(styler[i + j])) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\ts[j] = static_cast(tolower(styler[i + j]));\n\t\t\t\t\ts[j + 1] = '\\0';\n\t\t\t\t}\n\n\t\t\t\tif ((strcmp(s, \"then\") == 0) || (strcmp(s, \"for\") == 0) || (strcmp(s, \"while\") == 0)) {\n\t\t\t\t\tlevelCurrent++;\n\t\t\t\t}\n\t\t\t\tif ((strcmp(s, \"end\") == 0)) {\n\t\t\t\t\tlevelCurrent--;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (style == SCE_AVE_OPERATOR) {\n\t\t\tif (ch == '{' || ch == '(') {\n\t\t\t\tlevelCurrent++;\n\t\t\t} else if (ch == '}' || ch == ')') {\n\t\t\t\tlevelCurrent--;\n\t\t\t}\n\t\t}\n\n\t\tif (atEOL) {\n\t\t\tint lev = levelPrev;\n\t\t\tif (visibleChars == 0 && foldCompact) {\n\t\t\t\tlev |= SC_FOLDLEVELWHITEFLAG;\n\t\t\t}\n\t\t\tif ((levelCurrent > levelPrev) && (visibleChars > 0)) {\n\t\t\t\tlev |= SC_FOLDLEVELHEADERFLAG;\n\t\t\t}\n\t\t\tif (lev != styler.LevelAt(lineCurrent)) {\n\t\t\t\tstyler.SetLevel(lineCurrent, lev);\n\t\t\t}\n\t\t\tlineCurrent++;\n\t\t\tlevelPrev = levelCurrent;\n\t\t\tvisibleChars = 0;\n\t\t}\n\t\tif (!isspacechar(ch)) {\n\t\t\tvisibleChars++;\n\t\t}\n\t}\n\t\/\/ Fill in the real level of the next line, keeping the current flags as they will be filled in later\n\n\tint flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;\n\tstyler.SetLevel(lineCurrent, levelPrev | flagsNext);\n}\n\nLexerModule lmAVE(SCLEX_AVE, ColouriseAveDoc, \"ave\", FoldAveDoc);\n\nPatch from Bruce Doson fixes folding of elseif.\/\/ SciTE - Scintilla based Text Editor\n\/** @file LexAVE.cxx\n ** Lexer for Avenue.\n **\n ** Written by Alexey Yutkin .\n **\/\n\/\/ Copyright 1998-2002 by Neil Hodgson \n\/\/ The License.txt file describes the conditions under which this software may be distributed.\n\n#include \n#include \n#include \n#include \n#include \n\n#include \"Platform.h\"\n\n#include \"PropSet.h\"\n#include \"Accessor.h\"\n#include \"StyleContext.h\"\n#include \"KeyWords.h\"\n#include \"Scintilla.h\"\n#include \"SciLexer.h\"\n\n\n\nstatic inline bool IsAWordChar(const int ch) {\n\treturn (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');\n}\nstatic inline bool IsEnumChar(const int ch) {\n\treturn (ch < 0x80) && (isalnum(ch)|| ch == '_');\n}\nstatic inline bool IsANumberChar(const int ch) {\n\treturn (ch < 0x80) && (isalnum(ch) || ch == '.' );\n}\n\ninline bool IsAWordStart(const int ch) {\n\treturn (ch < 0x80) && (isalnum(ch) || ch == '_');\n}\n\ninline bool isAveOperator(char ch) {\n\tif (isalnum(ch))\n\t\treturn false;\n\t\/\/ '.' left out as it is used to make up numbers\n\tif (ch == '*' || ch == '\/' || ch == '-' || ch == '+' ||\n\t\tch == '(' || ch == ')' || ch == '=' ||\n\t\tch == '{' || ch == '}' ||\n\t\tch == '[' || ch == ']' || ch == ';' ||\n\t\tch == '<' || ch == '>' || ch == ',' ||\n\t\tch == '.' )\n\t\treturn true;\n\treturn false;\n}\n\nstatic void ColouriseAveDoc(\n\tunsigned int startPos,\n\tint length,\n\tint initStyle,\n\tWordList *keywordlists[],\n\tAccessor &styler) {\n\n\tWordList &keywords = *keywordlists[0];\n\tWordList &keywords2 = *keywordlists[1];\n\tWordList &keywords3 = *keywordlists[2];\n\tWordList &keywords4 = *keywordlists[3];\n\tWordList &keywords5 = *keywordlists[4];\n\tWordList &keywords6 = *keywordlists[5];\n\n\t\/\/ Do not leak onto next line\n\tif (initStyle == SCE_AVE_STRINGEOL) {\n\t\tinitStyle = SCE_AVE_DEFAULT;\n\t}\n\n\tStyleContext sc(startPos, length, initStyle, styler);\n\n\tfor (; sc.More(); sc.Forward()) {\n\t\tif (sc.atLineEnd) {\n\t\t\t\/\/ Update the line state, so it can be seen by next line\n\t\t\tint currentLine = styler.GetLine(sc.currentPos);\n\t\t\tstyler.SetLineState(currentLine, 0);\n\t\t}\n\t\tif (sc.atLineStart && (sc.state == SCE_AVE_STRING)) {\n\t\t\t\/\/ Prevent SCE_AVE_STRINGEOL from leaking back to previous line\n\t\t\tsc.SetState(SCE_AVE_STRING);\n\t\t}\n\n\n\t\t\/\/ Determine if the current state should terminate.\n\t\tif (sc.state == SCE_AVE_OPERATOR) {\n\t\t\tsc.SetState(SCE_AVE_DEFAULT);\n\t\t} else if (sc.state == SCE_AVE_NUMBER) {\n\t\t\tif (!IsANumberChar(sc.ch)) {\n\t\t\t\tsc.SetState(SCE_AVE_DEFAULT);\n\t\t\t}\n\t\t} else if (sc.state == SCE_AVE_ENUM) {\n\t\t\tif (!IsEnumChar(sc.ch)) {\n\t\t\t\tsc.SetState(SCE_AVE_DEFAULT);\n\t\t\t}\n\t\t} else if (sc.state == SCE_AVE_IDENTIFIER) {\n\t\t\tif (!IsAWordChar(sc.ch) || (sc.ch == '.')) {\n\t\t\t\tchar s[100];\n\t\t\t\t\/\/sc.GetCurrent(s, sizeof(s));\n\t\t\t\tsc.GetCurrentLowered(s, sizeof(s));\n\t\t\t\tif (keywords.InList(s)) {\n\t\t\t\t\tsc.ChangeState(SCE_AVE_WORD);\n\t\t\t\t} else if (keywords2.InList(s)) {\n\t\t\t\t\tsc.ChangeState(SCE_AVE_WORD2);\n\t\t\t\t} else if (keywords3.InList(s)) {\n\t\t\t\t\tsc.ChangeState(SCE_AVE_WORD3);\n\t\t\t\t} else if (keywords4.InList(s)) {\n\t\t\t\t\tsc.ChangeState(SCE_AVE_WORD4);\n\t\t\t\t} else if (keywords5.InList(s)) {\n\t\t\t\t\tsc.ChangeState(SCE_AVE_WORD5);\n\t\t\t\t} else if (keywords6.InList(s)) {\n\t\t\t\t\tsc.ChangeState(SCE_AVE_WORD6);\n\t\t\t\t}\n\t\t\t\tsc.SetState(SCE_AVE_DEFAULT);\n\t\t\t}\n\t\t} else if (sc.state == SCE_AVE_COMMENT) {\n\t\t\tif (sc.atLineEnd) {\n\t\t\t\tsc.SetState(SCE_AVE_DEFAULT);\n\t\t\t}\n\t\t} else if (sc.state == SCE_AVE_STRING) {\n\t\t\t if (sc.ch == '\\\"') {\n\t\t\t\tsc.ForwardSetState(SCE_AVE_DEFAULT);\n\t\t\t} else if (sc.atLineEnd) {\n\t\t\t\tsc.ChangeState(SCE_AVE_STRINGEOL);\n\t\t\t\tsc.ForwardSetState(SCE_AVE_DEFAULT);\n\t\t\t}\n\t\t}\n\n\t\t\/\/ Determine if a new state should be entered.\n\t\tif (sc.state == SCE_AVE_DEFAULT) {\n\t\t\tif (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {\n\t\t\t\tsc.SetState(SCE_AVE_NUMBER);\n\t\t\t} else if (IsAWordStart(sc.ch)) {\n\t\t\t\tsc.SetState(SCE_AVE_IDENTIFIER);\n\t\t\t} else if (sc.Match('\\\"')) {\n\t\t\t\tsc.SetState(SCE_AVE_STRING);\n\t\t\t} else if (sc.Match('\\'')) {\n\t\t\t\tsc.SetState(SCE_AVE_COMMENT);\n\t\t\t\tsc.Forward();\n\t\t\t} else if (isAveOperator(static_cast(sc.ch))) {\n\t\t\t\tsc.SetState(SCE_AVE_OPERATOR);\n\t\t\t} else if (sc.Match('#')) {\n\t\t\t\tsc.SetState(SCE_AVE_ENUM);\n\t\t\t\tsc.Forward();\n\t\t\t}\n\t\t}\n\t}\n\tsc.Complete();\n}\n\nstatic void FoldAveDoc(unsigned int startPos, int length, int \/* initStyle *\/, WordList *[],\n Accessor &styler) {\n\tunsigned int lengthDoc = startPos + length;\n\tint visibleChars = 0;\n\tint lineCurrent = styler.GetLine(startPos);\n\tint levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;\n\tint levelCurrent = levelPrev;\n\tchar chNext = static_cast(tolower(styler[startPos]));\n\tbool foldCompact = styler.GetPropertyInt(\"fold.compact\", 1) != 0;\n\tint styleNext = styler.StyleAt(startPos);\n\tchar s[10];\n\n\tfor (unsigned int i = startPos; i < lengthDoc; i++) {\n\t\tchar ch = static_cast(tolower(chNext));\n\t\tchNext = static_cast(tolower(styler.SafeGetCharAt(i + 1)));\n\t\tint style = styleNext;\n\t\tstyleNext = styler.StyleAt(i + 1);\n\t\tbool atEOL = (ch == '\\r' && chNext != '\\n') || (ch == '\\n');\n\t\tif (style == SCE_AVE_WORD) {\n\t\t\tif (ch == 't' || ch == 'f' || ch == 'w' || ch == 'e') {\n\t\t\t\tfor (unsigned int j = 0; j < 6; j++) {\n\t\t\t\t\tif (!iswordchar(styler[i + j])) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\ts[j] = static_cast(tolower(styler[i + j]));\n\t\t\t\t\ts[j + 1] = '\\0';\n\t\t\t\t}\n\n\t\t\t\tif ((strcmp(s, \"then\") == 0) || (strcmp(s, \"for\") == 0) || (strcmp(s, \"while\") == 0)) {\n\t\t\t\t\tlevelCurrent++;\n\t\t\t\t}\n\t\t\t\tif ((strcmp(s, \"end\") == 0) || (strcmp(s, \"elseif\") == 0)) {\n\t\t\t\t\t\/\/ Normally \"elseif\" and \"then\" will be on the same line and will cancel\n\t\t\t\t\t\/\/ each other out. \/\/ As implemented, this does not support fold.at.else.\n\t\t\t\t\tlevelCurrent--;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (style == SCE_AVE_OPERATOR) {\n\t\t\tif (ch == '{' || ch == '(') {\n\t\t\t\tlevelCurrent++;\n\t\t\t} else if (ch == '}' || ch == ')') {\n\t\t\t\tlevelCurrent--;\n\t\t\t}\n\t\t}\n\n\t\tif (atEOL) {\n\t\t\tint lev = levelPrev;\n\t\t\tif (visibleChars == 0 && foldCompact) {\n\t\t\t\tlev |= SC_FOLDLEVELWHITEFLAG;\n\t\t\t}\n\t\t\tif ((levelCurrent > levelPrev) && (visibleChars > 0)) {\n\t\t\t\tlev |= SC_FOLDLEVELHEADERFLAG;\n\t\t\t}\n\t\t\tif (lev != styler.LevelAt(lineCurrent)) {\n\t\t\t\tstyler.SetLevel(lineCurrent, lev);\n\t\t\t}\n\t\t\tlineCurrent++;\n\t\t\tlevelPrev = levelCurrent;\n\t\t\tvisibleChars = 0;\n\t\t}\n\t\tif (!isspacechar(ch)) {\n\t\t\tvisibleChars++;\n\t\t}\n\t}\n\t\/\/ Fill in the real level of the next line, keeping the current flags as they will be filled in later\n\n\tint flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;\n\tstyler.SetLevel(lineCurrent, levelPrev | flagsNext);\n}\n\nLexerModule lmAVE(SCLEX_AVE, ColouriseAveDoc, \"ave\", FoldAveDoc);\n\n<|endoftext|>"} {"text":"\/\/ Scintilla source code edit control\n\/** @file LexCSS.cxx\n ** Lexer for Cascade Style Sheets\n ** Written by Jakub Vrna\n **\/\n\/\/ Copyright 1998-2002 by Neil Hodgson \n\/\/ The License.txt file describes the conditions under which this software may be distributed.\n\n#include \n#include \n#include \n#include \n#include \n\n#include \"Platform.h\"\n\n#include \"PropSet.h\"\n#include \"Accessor.h\"\n#include \"StyleContext.h\"\n#include \"KeyWords.h\"\n#include \"Scintilla.h\"\n#include \"SciLexer.h\"\n\nstatic inline bool IsAWordChar(const unsigned int ch) {\n\treturn (isalnum(ch) || ch == '-' || ch == '_' || ch >= 161); \/\/ _ is not in fact correct CSS word-character\n}\n\ninline bool IsCssOperator(const char ch) {\n\tif (!isalnum(ch) && (ch == '{' || ch == '}' || ch == ':' || ch == ',' || ch == ';' || ch == '.' || ch == '#' || ch == '!' || ch == '@'))\n\t\treturn true;\n\treturn false;\n}\n\nstatic void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) {\n\tWordList &keywords = *keywordlists[0];\n\tWordList &pseudoClasses = *keywordlists[1];\n\n\tStyleContext sc(startPos, length, initStyle, styler);\n\n\tint lastState = -1; \/\/ before operator\n\tint lastStateC = -1; \/\/ before comment\n\tint op = ' '; \/\/ last operator\n\n\tfor (; sc.More(); sc.Forward()) {\n\t\tif (sc.state == SCE_CSS_COMMENT && sc.Match('*', '\/')) {\n\t\t\tif (lastStateC == -1) {\n\t\t\t\t\/\/ backtrack to get last state\n\t\t\t\tunsigned int i = startPos;\n\t\t\t\tfor (; i > 0; i--) {\n\t\t\t\t\tif ((lastStateC = styler.StyleAt(i-1)) != SCE_CSS_COMMENT) {\n\t\t\t\t\t\tif (lastStateC == SCE_CSS_OPERATOR) {\n\t\t\t\t\t\t\top = styler.SafeGetCharAt(i-1);\n\t\t\t\t\t\t\twhile (--i) {\n\t\t\t\t\t\t\t\tlastState = styler.StyleAt(i-1);\n\t\t\t\t\t\t\t\tif (lastState != SCE_CSS_OPERATOR && lastState != SCE_CSS_COMMENT)\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (i == 0)\n\t\t\t\t\t\t\t\tlastState = SCE_CSS_DEFAULT;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (i == 0)\n\t\t\t\t\tlastStateC = SCE_CSS_DEFAULT;\n\t\t\t}\n\t\t\tsc.Forward();\n\t\t\tsc.ForwardSetState(lastStateC);\n\t\t}\n\n\t\tif (sc.state == SCE_CSS_COMMENT)\n\t\t\tcontinue;\n\n\t\tif (sc.state == SCE_CSS_DOUBLESTRING || sc.state == SCE_CSS_SINGLESTRING) {\n\t\t\tif (sc.ch != (sc.state == SCE_CSS_DOUBLESTRING ? '\\\"' : '\\''))\n\t\t\t\tcontinue;\n\t\t\tunsigned int i = sc.currentPos;\n\t\t\twhile (i && styler[i-1] == '\\\\')\n\t\t\t\ti--;\n\t\t\tif ((sc.currentPos - i) % 2 == 1)\n\t\t\t\tcontinue;\n\t\t\tsc.ForwardSetState(SCE_CSS_VALUE);\n\t\t}\n\n\t\tif (sc.state == SCE_CSS_OPERATOR) {\n\t\t\tif (op == ' ') {\n\t\t\t\tunsigned int i = startPos;\n\t\t\t\top = styler.SafeGetCharAt(i-1);\n\t\t\t\twhile (--i) {\n\t\t\t\t\tlastState = styler.StyleAt(i-1);\n\t\t\t\t\tif (lastState != SCE_CSS_OPERATOR && lastState != SCE_CSS_COMMENT)\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tswitch (op) {\n\t\t\tcase '@':\n\t\t\t\tif (lastState == SCE_CSS_DEFAULT)\n\t\t\t\t\tsc.SetState(SCE_CSS_DIRECTIVE);\n\t\t\t\tbreak;\n\t\t\tcase '{':\n\t\t\t\tif (lastState == SCE_CSS_DIRECTIVE)\n\t\t\t\t\tsc.SetState(SCE_CSS_DEFAULT);\n\t\t\t\telse if (lastState == SCE_CSS_TAG)\n\t\t\t\t\tsc.SetState(SCE_CSS_IDENTIFIER);\n\t\t\t\tbreak;\n\t\t\tcase '}':\n\t\t\t\tif (lastState == SCE_CSS_DEFAULT || lastState == SCE_CSS_VALUE || lastState == SCE_CSS_IMPORTANT || lastState == SCE_CSS_IDENTIFIER)\n\t\t\t\t\tsc.SetState(SCE_CSS_DEFAULT);\n\t\t\t\tbreak;\n\t\t\tcase ':':\n\t\t\t\tif (lastState == SCE_CSS_TAG || lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_DEFAULT ||\n\t\t\t\t\tlastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS)\n\t\t\t\t\tsc.SetState(SCE_CSS_PSEUDOCLASS);\n\t\t\t\telse if (lastState == SCE_CSS_IDENTIFIER || lastState == SCE_CSS_UNKNOWN_IDENTIFIER)\n\t\t\t\t\tsc.SetState(SCE_CSS_VALUE);\n\t\t\t\tbreak;\n\t\t\tcase '.':\n\t\t\t\tif (lastState == SCE_CSS_TAG || lastState == SCE_CSS_DEFAULT)\n\t\t\t\t\tsc.SetState(SCE_CSS_CLASS);\n\t\t\t\tbreak;\n\t\t\tcase '#':\n\t\t\t\tif (lastState == SCE_CSS_TAG || lastState == SCE_CSS_DEFAULT)\n\t\t\t\t\tsc.SetState(SCE_CSS_ID);\n\t\t\t\tbreak;\n\t\t\tcase ',':\n\t\t\t\tif (lastState == SCE_CSS_TAG)\n\t\t\t\t\tsc.SetState(SCE_CSS_DEFAULT);\n\t\t\t\tbreak;\n\t\t\tcase ';':\n\t\t\t\tif (lastState == SCE_CSS_DIRECTIVE)\n\t\t\t\t\tsc.SetState(SCE_CSS_DEFAULT);\n\t\t\t\telse if (lastState == SCE_CSS_VALUE || lastState == SCE_CSS_IMPORTANT)\n\t\t\t\t\tsc.SetState(SCE_CSS_IDENTIFIER);\n\t\t\t\tbreak;\n\t\t\tcase '!':\n\t\t\t\tif (lastState == SCE_CSS_VALUE)\n\t\t\t\t\tsc.SetState(SCE_CSS_IMPORTANT);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (IsAWordChar(sc.ch)) {\n\t\t\tif (sc.state == SCE_CSS_DEFAULT)\n\t\t\t\tsc.SetState(SCE_CSS_TAG);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (IsAWordChar(sc.chPrev) && (\n\t\t\tsc.state == SCE_CSS_IDENTIFIER || sc.state == SCE_CSS_UNKNOWN_IDENTIFIER\n\t\t\t|| sc.state == SCE_CSS_PSEUDOCLASS || sc.state == SCE_CSS_UNKNOWN_PSEUDOCLASS\n\t\t\t|| sc.state == SCE_CSS_IMPORTANT\n\t\t)) {\n\t\t\tchar s[100];\n\t\t\tsc.GetCurrentLowered(s, sizeof(s));\n\t\t\tchar *s2 = s;\n\t\t\twhile (*s2 && !IsAWordChar(*s2))\n\t\t\t\ts2++;\n\t\t\tswitch (sc.state) {\n\t\t\tcase SCE_CSS_IDENTIFIER:\n\t\t\t\tif (!keywords.InList(s2))\n\t\t\t\t\tsc.ChangeState(SCE_CSS_UNKNOWN_IDENTIFIER);\n\t\t\t\tbreak;\n\t\t\tcase SCE_CSS_UNKNOWN_IDENTIFIER:\n\t\t\t\tif (keywords.InList(s2))\n\t\t\t\t\tsc.ChangeState(SCE_CSS_IDENTIFIER);\n\t\t\t\tbreak;\n\t\t\tcase SCE_CSS_PSEUDOCLASS:\n\t\t\t\tif (!pseudoClasses.InList(s2))\n\t\t\t\t\tsc.ChangeState(SCE_CSS_UNKNOWN_PSEUDOCLASS);\n\t\t\t\tbreak;\n\t\t\tcase SCE_CSS_UNKNOWN_PSEUDOCLASS:\n\t\t\t\tif (pseudoClasses.InList(s2))\n\t\t\t\t\tsc.ChangeState(SCE_CSS_PSEUDOCLASS);\n\t\t\t\tbreak;\n\t\t\tcase SCE_CSS_IMPORTANT:\n\t\t\t\tif (strcmp(s2, \"important\") != 0)\n\t\t\t\t\tsc.ChangeState(SCE_CSS_VALUE);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (sc.ch != '.' && sc.ch != ':' && sc.ch != '#' && (sc.state == SCE_CSS_CLASS || sc.state == SCE_CSS_PSEUDOCLASS || sc.state == SCE_CSS_UNKNOWN_PSEUDOCLASS || sc.state == SCE_CSS_ID))\n\t\t\tsc.SetState(SCE_CSS_TAG);\n\n\t\tif (sc.Match('\/', '*')) {\n\t\t\tlastStateC = sc.state;\n\t\t\tsc.SetState(SCE_CSS_COMMENT);\n\t\t\tsc.Forward();\n\t\t} else if (sc.state == SCE_CSS_VALUE && (sc.ch == '\\\"' || sc.ch == '\\'')) {\n\t\t\tsc.SetState((sc.ch == '\\\"' ? SCE_CSS_DOUBLESTRING : SCE_CSS_SINGLESTRING));\n\t\t} else if (IsCssOperator(static_cast(sc.ch))\n\t\t\t&& (sc.state != SCE_CSS_VALUE || sc.ch == ';' || sc.ch == '}' || sc.ch == '!')\n\t\t\t&& (sc.state != SCE_CSS_DIRECTIVE || sc.ch == ';' || sc.ch == '{')\n\t\t) {\n\t\t\tif (sc.state != SCE_CSS_OPERATOR)\n\t\t\t\tlastState = sc.state;\n\t\t\tsc.SetState(SCE_CSS_OPERATOR);\n\t\t\top = sc.ch;\n\t\t}\n\t}\n\n\tsc.Complete();\n}\n\nstatic void FoldCSSDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {\n\tbool foldComment = styler.GetPropertyInt(\"fold.comment\") != 0;\n\tbool foldCompact = styler.GetPropertyInt(\"fold.compact\", 1) != 0;\n\tunsigned int endPos = startPos + length;\n\tint visibleChars = 0;\n\tint lineCurrent = styler.GetLine(startPos);\n\tint levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;\n\tint levelCurrent = levelPrev;\n\tchar chNext = styler[startPos];\n\tbool inComment = (styler.StyleAt(startPos-1) == SCE_CSS_COMMENT);\n\tfor (unsigned int i = startPos; i < endPos; i++) {\n\t\tchar ch = chNext;\n\t\tchNext = styler.SafeGetCharAt(i + 1);\n\t\tint style = styler.StyleAt(i);\n\t\tbool atEOL = (ch == '\\r' && chNext != '\\n') || (ch == '\\n');\n\t\tif (foldComment) {\n\t\t\tif (!inComment && (style == SCE_CSS_COMMENT))\n\t\t\t\tlevelCurrent++;\n\t\t\telse if (inComment && (style != SCE_CSS_COMMENT))\n\t\t\t\tlevelCurrent--;\n\t\t\tinComment = (style == SCE_CSS_COMMENT);\n\t\t}\n\t\tif (style == SCE_CSS_OPERATOR) {\n\t\t\tif (ch == '{') {\n\t\t\t\tlevelCurrent++;\n\t\t\t} else if (ch == '}') {\n\t\t\t\tlevelCurrent--;\n\t\t\t}\n\t\t}\n\t\tif (atEOL) {\n\t\t\tint lev = levelPrev;\n\t\t\tif (visibleChars == 0 && foldCompact)\n\t\t\t\tlev |= SC_FOLDLEVELWHITEFLAG;\n\t\t\tif ((levelCurrent > levelPrev) && (visibleChars > 0))\n\t\t\t\tlev |= SC_FOLDLEVELHEADERFLAG;\n\t\t\tif (lev != styler.LevelAt(lineCurrent)) {\n\t\t\t\tstyler.SetLevel(lineCurrent, lev);\n\t\t\t}\n\t\t\tlineCurrent++;\n\t\t\tlevelPrev = levelCurrent;\n\t\t\tvisibleChars = 0;\n\t\t}\n\t\tif (!isspacechar(ch))\n\t\t\tvisibleChars++;\n\t}\n\t\/\/ Fill in the real level of the next line, keeping the current flags as they will be filled in later\n\tint flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;\n\tstyler.SetLevel(lineCurrent, levelPrev | flagsNext);\n}\n\nstatic const char * const cssWordListDesc[] = {\n\t\"Keywords\",\n\t\"Pseudo classes\",\n\t0\n};\n\nLexerModule lmCss(SCLEX_CSS, ColouriseCssDoc, \"css\", FoldCSSDoc, cssWordListDesc);\nUpdate from Philippe with some support for CSS 2.\/\/ Scintilla source code edit control\n\/** @file LexCSS.cxx\n ** Lexer for Cascading Style Sheets\n ** Written by Jakub Vrna\n **\/\n\/\/ Copyright 1998-2002 by Neil Hodgson \n\/\/ The License.txt file describes the conditions under which this software may be distributed.\n\n#include \n#include \n#include \n#include \n#include \n\n#include \"Platform.h\"\n\n#include \"PropSet.h\"\n#include \"Accessor.h\"\n#include \"StyleContext.h\"\n#include \"KeyWords.h\"\n#include \"Scintilla.h\"\n#include \"SciLexer.h\"\n\n\nstatic inline bool IsAWordChar(const unsigned int ch) {\n\treturn (isalnum(ch) || ch == '-' || ch == '_' || ch >= 161); \/\/ _ is not in fact correct CSS word-character\n}\n\ninline bool IsCssOperator(const char ch) {\n\tif (!isalnum(ch) &&\n\t\t(ch == '{' || ch == '}' || ch == ':' || ch == ',' || ch == ';' ||\n\t\t ch == '.' || ch == '#' || ch == '!' || ch == '@' ||\n\t\t \/* CSS2 *\/\n\t\t ch == '*' || ch == '>' || ch == '+' || ch == '=' || ch == '~' || ch == '|' ||\n\t\t ch == '[' || ch == ']' || ch == '(' || ch == ')')) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nstatic void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) {\n\tWordList &keywords = *keywordlists[0];\n\tWordList &pseudoClasses = *keywordlists[1];\n\tWordList &keywords2 = *keywordlists[2];\n\n\tStyleContext sc(startPos, length, initStyle, styler);\n\n\tint lastState = -1; \/\/ before operator\n\tint lastStateC = -1; \/\/ before comment\n\tint op = ' '; \/\/ last operator\n\n\tfor (; sc.More(); sc.Forward()) {\n\t\tif (sc.state == SCE_CSS_COMMENT && sc.Match('*', '\/')) {\n\t\t\tif (lastStateC == -1) {\n\t\t\t\t\/\/ backtrack to get last state:\n\t\t\t\t\/\/ comments are like whitespace, so we must return to the previous state\n\t\t\t\tunsigned int i = startPos;\n\t\t\t\tfor (; i > 0; i--) {\n\t\t\t\t\tif ((lastStateC = styler.StyleAt(i-1)) != SCE_CSS_COMMENT) {\n\t\t\t\t\t\tif (lastStateC == SCE_CSS_OPERATOR) {\n\t\t\t\t\t\t\top = styler.SafeGetCharAt(i-1);\n\t\t\t\t\t\t\twhile (--i) {\n\t\t\t\t\t\t\t\tlastState = styler.StyleAt(i-1);\n\t\t\t\t\t\t\t\tif (lastState != SCE_CSS_OPERATOR && lastState != SCE_CSS_COMMENT)\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (i == 0)\n\t\t\t\t\t\t\t\tlastState = SCE_CSS_DEFAULT;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (i == 0)\n\t\t\t\t\tlastStateC = SCE_CSS_DEFAULT;\n\t\t\t}\n\t\t\tsc.Forward();\n\t\t\tsc.ForwardSetState(lastStateC);\n\t\t}\n\n\t\tif (sc.state == SCE_CSS_COMMENT)\n\t\t\tcontinue;\n\n\t\tif (sc.state == SCE_CSS_DOUBLESTRING || sc.state == SCE_CSS_SINGLESTRING) {\n\t\t\tif (sc.ch != (sc.state == SCE_CSS_DOUBLESTRING ? '\\\"' : '\\''))\n\t\t\t\tcontinue;\n\t\t\tunsigned int i = sc.currentPos;\n\t\t\twhile (i && styler[i-1] == '\\\\')\n\t\t\t\ti--;\n\t\t\tif ((sc.currentPos - i) % 2 == 1)\n\t\t\t\tcontinue;\n\t\t\tsc.ForwardSetState(SCE_CSS_VALUE);\n\t\t}\n\n\t\tif (sc.state == SCE_CSS_OPERATOR) {\n\t\t\tif (op == ' ') {\n\t\t\t\tunsigned int i = startPos;\n\t\t\t\top = styler.SafeGetCharAt(i-1);\n\t\t\t\twhile (--i) {\n\t\t\t\t\tlastState = styler.StyleAt(i-1);\n\t\t\t\t\tif (lastState != SCE_CSS_OPERATOR && lastState != SCE_CSS_COMMENT)\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tswitch (op) {\n\t\t\tcase '@':\n\t\t\t\tif (lastState == SCE_CSS_DEFAULT)\n\t\t\t\t\tsc.SetState(SCE_CSS_DIRECTIVE);\n\t\t\t\tbreak;\n\t\t\tcase '{':\n\t\t\t\tif (lastState == SCE_CSS_DIRECTIVE)\n\t\t\t\t\tsc.SetState(SCE_CSS_DEFAULT);\n\t\t\t\telse if (lastState == SCE_CSS_TAG)\n\t\t\t\t\tsc.SetState(SCE_CSS_IDENTIFIER);\n\t\t\t\tbreak;\n\t\t\tcase '}':\n\t\t\t\tif (lastState == SCE_CSS_DEFAULT || lastState == SCE_CSS_VALUE || lastState == SCE_CSS_IMPORTANT || lastState == SCE_CSS_IDENTIFIER)\n\t\t\t\t\tsc.SetState(SCE_CSS_DEFAULT);\n\t\t\t\tbreak;\n\t\t\tcase ':':\n\t\t\t\tif (lastState == SCE_CSS_TAG || lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_DEFAULT ||\n\t\t\t\t\tlastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS)\n\t\t\t\t\tsc.SetState(SCE_CSS_PSEUDOCLASS);\n\t\t\t\telse if (lastState == SCE_CSS_IDENTIFIER || lastState == SCE_CSS_UNKNOWN_IDENTIFIER)\n\t\t\t\t\tsc.SetState(SCE_CSS_VALUE);\n\t\t\t\tbreak;\n\t\t\tcase '.':\n\t\t\t\tif (lastState == SCE_CSS_TAG || lastState == SCE_CSS_DEFAULT)\n\t\t\t\t\tsc.SetState(SCE_CSS_CLASS);\n\t\t\t\tbreak;\n\t\t\tcase '#':\n\t\t\t\tif (lastState == SCE_CSS_TAG || lastState == SCE_CSS_DEFAULT)\n\t\t\t\t\tsc.SetState(SCE_CSS_ID);\n\t\t\t\tbreak;\n\t\t\tcase ',':\n\t\t\t\tif (lastState == SCE_CSS_TAG)\n\t\t\t\t\tsc.SetState(SCE_CSS_DEFAULT);\n\t\t\t\tbreak;\n\t\t\tcase ';':\n\t\t\t\tif (lastState == SCE_CSS_DIRECTIVE)\n\t\t\t\t\tsc.SetState(SCE_CSS_DEFAULT);\n\t\t\t\telse if (lastState == SCE_CSS_VALUE || lastState == SCE_CSS_IMPORTANT)\n\t\t\t\t\tsc.SetState(SCE_CSS_IDENTIFIER);\n\t\t\t\tbreak;\n\t\t\tcase '!':\n\t\t\t\tif (lastState == SCE_CSS_VALUE)\n\t\t\t\t\tsc.SetState(SCE_CSS_IMPORTANT);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (IsAWordChar(sc.ch)) {\n\t\t\tif (sc.state == SCE_CSS_DEFAULT)\n\t\t\t\tsc.SetState(SCE_CSS_TAG);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (IsAWordChar(sc.chPrev) && (\n\t\t\tsc.state == SCE_CSS_IDENTIFIER || sc.state == SCE_CSS_UNKNOWN_IDENTIFIER\n\t\t\t|| sc.state == SCE_CSS_PSEUDOCLASS || sc.state == SCE_CSS_UNKNOWN_PSEUDOCLASS\n\t\t\t|| sc.state == SCE_CSS_IMPORTANT\n\t\t)) {\n\t\t\tchar s[100];\n\t\t\tsc.GetCurrentLowered(s, sizeof(s));\n\t\t\tchar *s2 = s;\n\t\t\twhile (*s2 && !IsAWordChar(*s2))\n\t\t\t\ts2++;\n\t\t\tswitch (sc.state) {\n\t\t\tcase SCE_CSS_IDENTIFIER:\n\t\t\t\tif (!keywords.InList(s2) && !keywords2.InList(s2))\n\t\t\t\t\tsc.ChangeState(SCE_CSS_UNKNOWN_IDENTIFIER);\n\t\t\t\tbreak;\n\t\t\tcase SCE_CSS_UNKNOWN_IDENTIFIER:\n\t\t\t\tif (keywords.InList(s2))\n\t\t\t\t\tsc.ChangeState(SCE_CSS_IDENTIFIER);\n\t\t\t\tbreak;\n\t\t\tcase SCE_CSS_PSEUDOCLASS:\n\t\t\t\tif (!pseudoClasses.InList(s2))\n\t\t\t\t\tsc.ChangeState(SCE_CSS_UNKNOWN_PSEUDOCLASS);\n\t\t\t\tbreak;\n\t\t\tcase SCE_CSS_UNKNOWN_PSEUDOCLASS:\n\t\t\t\tif (pseudoClasses.InList(s2))\n\t\t\t\t\tsc.ChangeState(SCE_CSS_PSEUDOCLASS);\n\t\t\t\tbreak;\n\t\t\tcase SCE_CSS_IMPORTANT:\n\t\t\t\tif (strcmp(s2, \"important\") != 0)\n\t\t\t\t\tsc.ChangeState(SCE_CSS_VALUE);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (sc.ch != '.' && sc.ch != ':' && sc.ch != '#' && (sc.state == SCE_CSS_CLASS || sc.state == SCE_CSS_PSEUDOCLASS || sc.state == SCE_CSS_UNKNOWN_PSEUDOCLASS || sc.state == SCE_CSS_ID))\n\t\t\tsc.SetState(SCE_CSS_TAG);\n\n\t\tif (sc.Match('\/', '*')) {\n\t\t\tlastStateC = sc.state;\n\t\t\tsc.SetState(SCE_CSS_COMMENT);\n\t\t\tsc.Forward();\n\t\t} else if (sc.state == SCE_CSS_VALUE && (sc.ch == '\\\"' || sc.ch == '\\'')) {\n\t\t\tsc.SetState((sc.ch == '\\\"' ? SCE_CSS_DOUBLESTRING : SCE_CSS_SINGLESTRING));\n\t\t} else if (IsCssOperator(static_cast(sc.ch))\n\t\t\t&& (sc.state != SCE_CSS_VALUE || sc.ch == ';' || sc.ch == '}' || sc.ch == '!')\n\t\t\t&& (sc.state != SCE_CSS_DIRECTIVE || sc.ch == ';' || sc.ch == '{')\n\t\t) {\n\t\t\tif (sc.state != SCE_CSS_OPERATOR)\n\t\t\t\tlastState = sc.state;\n\t\t\tsc.SetState(SCE_CSS_OPERATOR);\n\t\t\top = sc.ch;\n\t\t}\n\t}\n\n\tsc.Complete();\n}\n\nstatic void FoldCSSDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {\n\tbool foldComment = styler.GetPropertyInt(\"fold.comment\") != 0;\n\tbool foldCompact = styler.GetPropertyInt(\"fold.compact\", 1) != 0;\n\tunsigned int endPos = startPos + length;\n\tint visibleChars = 0;\n\tint lineCurrent = styler.GetLine(startPos);\n\tint levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;\n\tint levelCurrent = levelPrev;\n\tchar chNext = styler[startPos];\n\tbool inComment = (styler.StyleAt(startPos-1) == SCE_CSS_COMMENT);\n\tfor (unsigned int i = startPos; i < endPos; i++) {\n\t\tchar ch = chNext;\n\t\tchNext = styler.SafeGetCharAt(i + 1);\n\t\tint style = styler.StyleAt(i);\n\t\tbool atEOL = (ch == '\\r' && chNext != '\\n') || (ch == '\\n');\n\t\tif (foldComment) {\n\t\t\tif (!inComment && (style == SCE_CSS_COMMENT))\n\t\t\t\tlevelCurrent++;\n\t\t\telse if (inComment && (style != SCE_CSS_COMMENT))\n\t\t\t\tlevelCurrent--;\n\t\t\tinComment = (style == SCE_CSS_COMMENT);\n\t\t}\n\t\tif (style == SCE_CSS_OPERATOR) {\n\t\t\tif (ch == '{') {\n\t\t\t\tlevelCurrent++;\n\t\t\t} else if (ch == '}') {\n\t\t\t\tlevelCurrent--;\n\t\t\t}\n\t\t}\n\t\tif (atEOL) {\n\t\t\tint lev = levelPrev;\n\t\t\tif (visibleChars == 0 && foldCompact)\n\t\t\t\tlev |= SC_FOLDLEVELWHITEFLAG;\n\t\t\tif ((levelCurrent > levelPrev) && (visibleChars > 0))\n\t\t\t\tlev |= SC_FOLDLEVELHEADERFLAG;\n\t\t\tif (lev != styler.LevelAt(lineCurrent)) {\n\t\t\t\tstyler.SetLevel(lineCurrent, lev);\n\t\t\t}\n\t\t\tlineCurrent++;\n\t\t\tlevelPrev = levelCurrent;\n\t\t\tvisibleChars = 0;\n\t\t}\n\t\tif (!isspacechar(ch))\n\t\t\tvisibleChars++;\n\t}\n\t\/\/ Fill in the real level of the next line, keeping the current flags as they will be filled in later\n\tint flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;\n\tstyler.SetLevel(lineCurrent, levelPrev | flagsNext);\n}\n\nstatic const char * const cssWordListDesc[] = {\n\t\"Keywords\",\n\t\"Pseudo classes\",\n\t0\n};\n\nLexerModule lmCss(SCLEX_CSS, ColouriseCssDoc, \"css\", FoldCSSDoc, cssWordListDesc);\n<|endoftext|>"} {"text":"\/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:\n * \n * Libmemcached Client and Server \n *\n * Copyright (C) 2012 Data Differential, http:\/\/datadifferential.com\/\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n *\n * * Redistributions in binary form must reproduce the above\n * copyright notice, this list of conditions and the following disclaimer\n * in the documentation and\/or other materials provided with the\n * distribution.\n *\n * * The names of its contributors may not be used to endorse or\n * promote products derived from this software without specific prior\n * written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n *\/\n\n#define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT +10\n\n#include \n#include \n\n#include \"tests\/basic.h\"\n#include \"tests\/debug.h\"\n#include \"tests\/deprecated.h\"\n#include \"tests\/error_conditions.h\"\n#include \"tests\/exist.h\"\n#include \"tests\/ketama.h\"\n#include \"tests\/namespace.h\"\n#include \"tests\/parser.h\"\n#include \"tests\/libmemcached-1.0\/dump.h\"\n#include \"tests\/libmemcached-1.0\/generate.h\"\n#include \"tests\/libmemcached-1.0\/haldenbrand.h\"\n#include \"tests\/libmemcached-1.0\/stat.h\"\n#include \"tests\/touch.h\"\n#include \"tests\/callbacks.h\"\n#include \"tests\/pool.h\"\n#include \"tests\/print.h\"\n#include \"tests\/replication.h\"\n#include \"tests\/server_add.h\"\n#include \"tests\/virtual_buckets.h\"\n\n#include \"tests\/libmemcached-1.0\/setup_and_teardowns.h\"\n\n\n#include \"tests\/libmemcached-1.0\/mem_functions.h\"\n\n\/* Collections we are running *\/\n#include \"tests\/libmemcached-1.0\/all_tests.h\"\n\n#include \"tests\/libmemcached_world.h\"\n\nvoid get_world(Framework *world)\n{\n world->collections= collection;\n\n world->_create= (test_callback_create_fn*)world_create;\n world->_destroy= (test_callback_destroy_fn*)world_destroy;\n\n world->item._startup= (test_callback_fn*)world_test_startup;\n world->item.set_pre((test_callback_fn*)world_pre_run);\n world->item.set_flush((test_callback_fn*)world_flush);\n world->item.set_post((test_callback_fn*)world_post_run);\n world->_on_error= (test_callback_error_fn*)world_on_error;\n\n world->collection_startup= (test_callback_fn*)world_container_startup;\n world->collection_shutdown= (test_callback_fn*)world_container_shutdown;\n\n world->set_runner(&defualt_libmemcached_runner);\n\n world->set_socket();\n}\nMake the number of servers we test against more flexible.\/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:\n * \n * Libmemcached Client and Server \n *\n * Copyright (C) 2012 Data Differential, http:\/\/datadifferential.com\/\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n *\n * * Redistributions in binary form must reproduce the above\n * copyright notice, this list of conditions and the following disclaimer\n * in the documentation and\/or other materials provided with the\n * distribution.\n *\n * * The names of its contributors may not be used to endorse or\n * promote products derived from this software without specific prior\n * written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n *\/\n\n#define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT +10\n\n#include \n#include \n\n#include \"tests\/basic.h\"\n#include \"tests\/debug.h\"\n#include \"tests\/deprecated.h\"\n#include \"tests\/error_conditions.h\"\n#include \"tests\/exist.h\"\n#include \"tests\/ketama.h\"\n#include \"tests\/namespace.h\"\n#include \"tests\/parser.h\"\n#include \"tests\/libmemcached-1.0\/dump.h\"\n#include \"tests\/libmemcached-1.0\/generate.h\"\n#include \"tests\/libmemcached-1.0\/haldenbrand.h\"\n#include \"tests\/libmemcached-1.0\/stat.h\"\n#include \"tests\/touch.h\"\n#include \"tests\/callbacks.h\"\n#include \"tests\/pool.h\"\n#include \"tests\/print.h\"\n#include \"tests\/replication.h\"\n#include \"tests\/server_add.h\"\n#include \"tests\/virtual_buckets.h\"\n\n#include \"tests\/libmemcached-1.0\/setup_and_teardowns.h\"\n\n\n#include \"tests\/libmemcached-1.0\/mem_functions.h\"\n\n\/* Collections we are running *\/\n#include \"tests\/libmemcached-1.0\/all_tests.h\"\n\n#include \"tests\/libmemcached_world.h\"\n\nvoid get_world(Framework *world)\n{\n if (getenv(\"LIBMEMCACHED_SERVER_NUMBER\"))\n {\n int set_count= atoi(getenv(\"LIBMEMCACHED_SERVER_NUMBER\"));\n assert(set_count >= 0);\n world->servers().set_count(set_count);\n }\n else\n {\n world->servers().set_count(8);\n }\n\n world->collections= collection;\n\n world->_create= (test_callback_create_fn*)world_create;\n world->_destroy= (test_callback_destroy_fn*)world_destroy;\n\n world->item._startup= (test_callback_fn*)world_test_startup;\n world->item.set_pre((test_callback_fn*)world_pre_run);\n world->item.set_flush((test_callback_fn*)world_flush);\n world->item.set_post((test_callback_fn*)world_post_run);\n world->_on_error= (test_callback_error_fn*)world_on_error;\n\n world->collection_startup= (test_callback_fn*)world_container_startup;\n world->collection_shutdown= (test_callback_fn*)world_container_shutdown;\n\n world->set_runner(&defualt_libmemcached_runner);\n\n world->set_socket();\n}\n<|endoftext|>"} {"text":"#include \"Opcodes.hpp\"\n#include \"VMState.hpp\"\n\n\/\/ push reg\nMAKE_OPCODE(0x50)\n{\n state->Push(state->eax);\n}\nMAKE_OPCODE(0x51)\n{\n state->Push(state->ecx);\n}\nMAKE_OPCODE(0x52)\n{\n state->Push(state->edx);\n}\nMAKE_OPCODE(0x53)\n{\n state->Push(state->ebx);\n}\nMAKE_OPCODE(0x54)\n{\n state->Push(state->esp);\n}\nMAKE_OPCODE(0x55)\n{\n state->Push(state->ebp);\n}\nMAKE_OPCODE(0x56)\n{\n state->Push(state->esi);\n}\nMAKE_OPCODE(0x57)\n{\n state->Push(state->edi);\n}\n\n\/\/ pop reg\nMAKE_OPCODE(0x58)\n{\n state->eax = state->Pop();\n}\nMAKE_OPCODE(0x59)\n{\n state->ecx = state->Pop();\n}\nMAKE_OPCODE(0x5A)\n{\n state->edx = state->Pop();\n}\nMAKE_OPCODE(0x5B)\n{\n state->ebx = state->Pop();\n}\nMAKE_OPCODE(0x5C)\n{\n state->esp = state->Pop();\n}\nMAKE_OPCODE(0x5D)\n{\n state->ebp = state->Pop();\n}\nMAKE_OPCODE(0x5E)\n{\n state->esi = state->Pop();\n}\nMAKE_OPCODE(0x5F)\n{\n state->edi = state->Pop();\n}\n\n\/\/ mov reg, reg OR mov [reg+disp], reg\nMAKE_OPCODE(0x89)\n{\n ModRM mod(state->ReadIPRelative(1));\n\n switch (mod.mod)\n {\n case 1:\n {\n auto disp = static_cast(state->ReadIPRelative(2));\n Log << \"[\" << state->GetRegisterName(mod.reg1) << '+' << disp << \"], \"\n << state->GetRegisterName(mod.reg2);\n state->Write(state->ds * 16 + (state->general[mod.reg1] + disp), state->general[mod.reg2]);\n op.insnOffset++;\n break;\n }\n case 3:\n Log << state->GetRegisterName(mod.reg1) << \", \" << state->GetRegisterName(mod.reg2);\n state->general[mod.reg1] = state->general[mod.reg2];\n break;\n };\n}\n\n\/\/ mov reg8, reg8 or mov reg8, [reg]\nMAKE_OPCODE(0x8A)\n{\n ModRM mod(state->ReadIPRelative(1));\n\n switch (mod.mod)\n {\n case 0:\n Log << state->GetByteRegisterName(mod.reg2) << \", [\" << state->GetRegisterCombinationName(mod.reg1) << \"]\";\n GetRegister8(state, mod.reg2) =\n state->Read(state->ds, RegisterCombinationToMemoryAddress(state, mod.reg1));\n break;\n case 3:\n Log << state->GetByteRegisterName(mod.reg1) << \", \" << state->GetByteRegisterName(mod.reg2);\n GetRegister8(state, mod.reg1) = GetRegister8(state, mod.reg2);\n break;\n };\n}\n\n\/\/ mov reg, [reg+disp]\nMAKE_OPCODE(0x8B)\n{\n ModRM mod(state->ReadIPRelative(1));\n\n if (mod.mod == 1)\n {\n auto offset = state->general[mod.reg1] + (int8_t)state->ReadIPRelative(2);\n state->general[mod.reg2] = state->Read(state->ds, offset);\n }\n}\n\n\/\/ mov sreg, reg\nMAKE_OPCODE(0x8E)\n{\n ModRM mod(state->ReadIPRelative(1));\n if (mod.mod == 3)\n {\n Log << state->GetSegmentName(mod.reg2) << \", \" << state->GetRegisterName(mod.reg1);\n state->segment[mod.reg2] = state->general[mod.reg1];\n }\n}\n\n\/\/ mov reg8, imm8\nMAKE_OPCODE(0xB0)\n{\n Log << \"al, \" << PRINT_VALUE((uint32_t)state->ReadIPRelative(1));\n GetLowerByte(state->eax) = state->ReadIPRelative(1);\n}\nMAKE_OPCODE(0xB1)\n{\n Log << \"cl, \" << PRINT_VALUE((uint32_t)state->ReadIPRelative(1));\n GetLowerByte(state->ecx) = state->ReadIPRelative(1);\n}\nMAKE_OPCODE(0xB2)\n{\n Log << \"dl, \" << PRINT_VALUE((uint32_t)state->ReadIPRelative(1));\n GetLowerByte(state->edx) = state->ReadIPRelative(1);\n}\nMAKE_OPCODE(0xB3)\n{\n Log << \"bl, \" << PRINT_VALUE((uint32_t)state->ReadIPRelative(1));\n GetLowerByte(state->ebx) = state->ReadIPRelative(1);\n}\nMAKE_OPCODE(0xB4)\n{\n Log << \"ah, \" << PRINT_VALUE((uint32_t)state->ReadIPRelative(1));\n GetUpperByte(state->eax) = state->ReadIPRelative(1);\n}\nMAKE_OPCODE(0xB5)\n{\n Log << \"ch, \" << PRINT_VALUE((uint32_t)state->ReadIPRelative(1));\n GetUpperByte(state->ecx) = state->ReadIPRelative(1);\n}\nMAKE_OPCODE(0xB6)\n{\n Log << \"dh, \" << PRINT_VALUE((uint32_t)state->ReadIPRelative(1));\n GetUpperByte(state->edx) = state->ReadIPRelative(1);\n}\nMAKE_OPCODE(0xB7)\n{\n Log << \"bh, \" << PRINT_VALUE((uint32_t)state->ReadIPRelative(1));\n GetUpperByte(state->ebx) = state->ReadIPRelative(1);\n}\n\n\/\/ mov reg, immediate\nMAKE_OPCODE(0xB8)\n{\n auto value = state->ReadImmediate(state->eip + 1);\n state->eax = value;\n Log << state->GetRegisterName(0) << \", \" << PRINT_VALUE(value);\n}\n\nMAKE_OPCODE(0xB9)\n{\n auto value = state->ReadImmediate(state->eip + 1);\n state->ecx = value;\n Log << state->GetRegisterName(1) << \", \" << PRINT_VALUE(value);\n}\n\nMAKE_OPCODE(0xBA)\n{\n auto value = state->ReadImmediate(state->eip + 1);\n state->edx = value;\n Log << state->GetRegisterName(2) << \", \" << PRINT_VALUE(value);\n}\n\nMAKE_OPCODE(0xBB)\n{\n auto value = state->ReadImmediate(state->eip + 1);\n state->ebx = value;\n Log << state->GetRegisterName(3) << \", \" << PRINT_VALUE(value);\n}\n\nMAKE_OPCODE(0xBC)\n{\n auto value = state->ReadImmediate(state->eip + 1);\n state->esp = value;\n Log << state->GetRegisterName(4) << \", \" << PRINT_VALUE(value);\n}\n\nMAKE_OPCODE(0xBD)\n{\n auto value = state->ReadImmediate(state->eip + 1);\n state->ebp = value;\n Log << state->GetRegisterName(5) << \", \" << PRINT_VALUE(value);\n}\n\nMAKE_OPCODE(0xBE)\n{\n auto value = state->ReadImmediate(state->eip + 1);\n state->esi = value;\n Log << state->GetRegisterName(6) << \", \" << PRINT_VALUE(value);\n}\n\nMAKE_OPCODE(0xBF)\n{\n auto value = state->ReadImmediate(state->eip + 1);\n state->edi = value;\n Log << state->GetRegisterName(7) << \", \" << PRINT_VALUE(value);\n}\n\n\/\/ mov [reg], imm8\nMAKE_OPCODE(0xC6)\n{\n ModRM mod(state->ReadIPRelative(1));\n\n switch (mod.mod)\n {\n case 0:\n Log << \"[\" << state->general[mod.reg1] << \"], \" << PRINT_VALUE((uint32_t)state->ReadIPRelative(2))\n << std::endl;\n state->Write(state->general[mod.reg1], state->ReadIPRelative(2));\n break;\n case 3:\n Log << state->general[mod.reg1] << \", \" << PRINT_VALUE((uint32_t)state->ReadIPRelative(2));\n state->general[mod.reg1] = state->ReadIPRelative(2);\n break;\n };\n}\n\n\/\/ mov [reg+disp], imm16\/32\nMAKE_OPCODE(0xC7)\n{\n ModRM mod(state->ReadIPRelative(1));\n ModRM sib(state->ReadIPRelative(2));\n\n uint8_t displacement = 0;\n if (mod.mod == 1)\n {\n displacement = state->ReadIPRelative(3);\n op.insnOffset++;\n }\n\n uint32_t memAddress = state->general[sib.reg1] + static_cast(displacement);\n auto offset = op.GetOffset(state) - (state->CR0.protectedMode ? 4 : 2);\n auto immediate = state->ReadImmediate(offset);\n\n if (state->CR0.protectedMode)\n state->Write(memAddress, immediate);\n else\n state->Write(memAddress, immediate);\n}General cleanup in Memory.cpp#include \"Opcodes.hpp\"\n#include \"VMState.hpp\"\n\n\/\/ push reg\nMAKE_OPCODE(0x50)\n{\n state->Push(state->eax);\n}\nMAKE_OPCODE(0x51)\n{\n state->Push(state->ecx);\n}\nMAKE_OPCODE(0x52)\n{\n state->Push(state->edx);\n}\nMAKE_OPCODE(0x53)\n{\n state->Push(state->ebx);\n}\nMAKE_OPCODE(0x54)\n{\n state->Push(state->esp);\n}\nMAKE_OPCODE(0x55)\n{\n state->Push(state->ebp);\n}\nMAKE_OPCODE(0x56)\n{\n state->Push(state->esi);\n}\nMAKE_OPCODE(0x57)\n{\n state->Push(state->edi);\n}\n\n\/\/ pop reg\nMAKE_OPCODE(0x58)\n{\n state->eax = state->Pop();\n}\nMAKE_OPCODE(0x59)\n{\n state->ecx = state->Pop();\n}\nMAKE_OPCODE(0x5A)\n{\n state->edx = state->Pop();\n}\nMAKE_OPCODE(0x5B)\n{\n state->ebx = state->Pop();\n}\nMAKE_OPCODE(0x5C)\n{\n state->esp = state->Pop();\n}\nMAKE_OPCODE(0x5D)\n{\n state->ebp = state->Pop();\n}\nMAKE_OPCODE(0x5E)\n{\n state->esi = state->Pop();\n}\nMAKE_OPCODE(0x5F)\n{\n state->edi = state->Pop();\n}\n\n\/\/ mov reg, reg OR mov [reg+disp], reg\nMAKE_OPCODE(0x89)\n{\n ModRM mod(state->ReadIPRelative(1));\n\n switch (mod.mod)\n {\n case 1:\n {\n auto disp = static_cast(state->ReadIPRelative(2));\n Log << \"[\" << state->GetRegisterName(mod.reg1) << '+' << disp << \"], \"\n << state->GetRegisterName(mod.reg2);\n state->Write(state->ds * 16 + (state->general[mod.reg1] + disp), state->general[mod.reg2]);\n op.insnOffset++;\n break;\n }\n case 3:\n Log << state->GetRegisterName(mod.reg1) << \", \" << state->GetRegisterName(mod.reg2);\n state->general[mod.reg1] = state->general[mod.reg2];\n break;\n };\n}\n\n\/\/ mov reg8, reg8 or mov reg8, [reg]\nMAKE_OPCODE(0x8A)\n{\n ModRM mod(state->ReadIPRelative(1));\n\n switch (mod.mod)\n {\n case 0:\n Log << state->GetByteRegisterName(mod.reg2) << \", [\" << state->GetRegisterCombinationName(mod.reg1) << \"]\";\n GetRegister8(state, mod.reg2) =\n state->Read(state->ds, RegisterCombinationToMemoryAddress(state, mod.reg1));\n break;\n case 3:\n Log << state->GetByteRegisterName(mod.reg1) << \", \" << state->GetByteRegisterName(mod.reg2);\n GetRegister8(state, mod.reg1) = GetRegister8(state, mod.reg2);\n break;\n };\n}\n\n\/\/ mov reg, [reg+disp]\nMAKE_OPCODE(0x8B)\n{\n ModRM mod(state->ReadIPRelative(1));\n\n if (mod.mod == 1)\n {\n auto offset = state->general[mod.reg1] + (int8_t)state->ReadIPRelative(2);\n state->general[mod.reg2] = state->Read(state->ds, offset);\n }\n}\n\n\/\/ mov sreg, reg\nMAKE_OPCODE(0x8E)\n{\n ModRM mod(state->ReadIPRelative(1));\n if (mod.mod == 3)\n {\n Log << state->GetSegmentName(mod.reg2) << \", \" << state->GetRegisterName(mod.reg1);\n state->segment[mod.reg2] = state->general[mod.reg1];\n }\n}\n\n\/\/ mov reg8, imm8\nMAKE_OPCODE(0xB0)\n{\n Log << \"al, \" << PRINT_VALUE(static_cast(state->ReadIPRelative(1)));\n GetLowerByte(state->eax) = state->ReadIPRelative(1);\n}\nMAKE_OPCODE(0xB1)\n{\n Log << \"cl, \" << PRINT_VALUE(static_cast(state->ReadIPRelative(1)));\n GetLowerByte(state->ecx) = state->ReadIPRelative(1);\n}\nMAKE_OPCODE(0xB2)\n{\n Log << \"dl, \" << PRINT_VALUE(static_cast(state->ReadIPRelative(1)));\n GetLowerByte(state->edx) = state->ReadIPRelative(1);\n}\nMAKE_OPCODE(0xB3)\n{\n Log << \"bl, \" << PRINT_VALUE(static_cast(state->ReadIPRelative(1)));\n GetLowerByte(state->ebx) = state->ReadIPRelative(1);\n}\nMAKE_OPCODE(0xB4)\n{\n Log << \"ah, \" << PRINT_VALUE(static_cast(state->ReadIPRelative(1)));\n GetUpperByte(state->eax) = state->ReadIPRelative(1);\n}\nMAKE_OPCODE(0xB5)\n{\n Log << \"ch, \" << PRINT_VALUE(static_cast(state->ReadIPRelative(1)));\n GetUpperByte(state->ecx) = state->ReadIPRelative(1);\n}\nMAKE_OPCODE(0xB6)\n{\n Log << \"dh, \" << PRINT_VALUE(static_cast(state->ReadIPRelative(1)));\n GetUpperByte(state->edx) = state->ReadIPRelative(1);\n}\nMAKE_OPCODE(0xB7)\n{\n Log << \"bh, \" << PRINT_VALUE(static_cast(state->ReadIPRelative(1)));\n GetUpperByte(state->ebx) = state->ReadIPRelative(1);\n}\n\n\/\/ mov reg, immediate\nMAKE_OPCODE(0xB8)\n{\n auto value = state->ReadImmediate(state->eip + 1);\n state->eax = value;\n Log << state->GetRegisterName(0) << \", \" << PRINT_VALUE(value);\n}\n\nMAKE_OPCODE(0xB9)\n{\n auto value = state->ReadImmediate(state->eip + 1);\n state->ecx = value;\n Log << state->GetRegisterName(1) << \", \" << PRINT_VALUE(value);\n}\n\nMAKE_OPCODE(0xBA)\n{\n auto value = state->ReadImmediate(state->eip + 1);\n state->edx = value;\n Log << state->GetRegisterName(2) << \", \" << PRINT_VALUE(value);\n}\n\nMAKE_OPCODE(0xBB)\n{\n auto value = state->ReadImmediate(state->eip + 1);\n state->ebx = value;\n Log << state->GetRegisterName(3) << \", \" << PRINT_VALUE(value);\n}\n\nMAKE_OPCODE(0xBC)\n{\n auto value = state->ReadImmediate(state->eip + 1);\n state->esp = value;\n Log << state->GetRegisterName(4) << \", \" << PRINT_VALUE(value);\n}\n\nMAKE_OPCODE(0xBD)\n{\n auto value = state->ReadImmediate(state->eip + 1);\n state->ebp = value;\n Log << state->GetRegisterName(5) << \", \" << PRINT_VALUE(value);\n}\n\nMAKE_OPCODE(0xBE)\n{\n auto value = state->ReadImmediate(state->eip + 1);\n state->esi = value;\n Log << state->GetRegisterName(6) << \", \" << PRINT_VALUE(value);\n}\n\nMAKE_OPCODE(0xBF)\n{\n auto value = state->ReadImmediate(state->eip + 1);\n state->edi = value;\n Log << state->GetRegisterName(7) << \", \" << PRINT_VALUE(value);\n}\n\n\/\/ mov [reg], imm8\nMAKE_OPCODE(0xC6)\n{\n ModRM mod(state->ReadIPRelative(1));\n\n auto immediate = state->ReadIPRelative(2);\n\n switch (mod.mod)\n {\n case 0:\n Log << \"[\" << state->general[mod.reg1] << \"], \"\n << PRINT_VALUE(static_cast(immediate))\n << std::endl;\n\n state->Write(state->general[mod.reg1], immediate);\n break;\n case 3:\n Log << state->general[mod.reg1] << \", \"\n << PRINT_VALUE(static_cast(immediate))\n << std::endl;\n\n state->general[mod.reg1] = immediate;\n break;\n };\n}\n\n\/\/ mov [reg+disp], imm16\/32\nMAKE_OPCODE(0xC7)\n{\n ModRM mod(state->ReadIPRelative(1));\n ModRM sib(state->ReadIPRelative(2));\n\n uint8_t displacement = 0;\n if (mod.mod == 1)\n {\n displacement = state->ReadIPRelative(3);\n op.insnOffset++;\n }\n\n uint32_t memAddress = state->general[sib.reg1] + static_cast(displacement);\n auto offset = op.GetOffset(state) - (state->CR0.protectedMode ? 4 : 2);\n auto immediate = state->ReadImmediate(offset);\n\n if (state->CR0.protectedMode)\n state->Write(memAddress, immediate);\n else\n state->Write(memAddress, immediate);\n}<|endoftext|>"} {"text":"\/* Copyright 2019 Stanford University, NVIDIA Corporation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http:\/\/www.apache.org\/licenses\/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\/\n\n#include \"mappers\/null_mapper.h\"\n\nnamespace Legion {\n namespace Mapping {\n\n Logger log_null(\"null_mapper\");\n\n \/\/--------------------------------------------------------------------------\n NullMapper::NullMapper(MapperRuntime *rt, Machine m)\n : Mapper(rt), machine(m)\n \/\/--------------------------------------------------------------------------\n {\n }\n\n \/\/--------------------------------------------------------------------------\n NullMapper::NullMapper(const NullMapper &rhs)\n : Mapper(rhs.runtime), machine(rhs.machine)\n \/\/--------------------------------------------------------------------------\n {\n \/\/ should never be called\n assert(false);\n }\n\n \/\/--------------------------------------------------------------------------\n NullMapper::~NullMapper(void)\n \/\/--------------------------------------------------------------------------\n {\n }\n\n \/\/--------------------------------------------------------------------------\n NullMapper& NullMapper::operator=(const NullMapper &rhs)\n \/\/--------------------------------------------------------------------------\n {\n \/\/ should never be called\n assert(false);\n return *this;\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::report_unimplemented(const char *func_name,\n unsigned line) const\n \/\/--------------------------------------------------------------------------\n {\n log_null.error(\"Unimplemented mapper method \\\"%s\\\" in mapper %s \", \n \"on line %s of %s\", func_name, get_mapper_name(), line, __FILE__);\n assert(false);\n }\n\n \/\/--------------------------------------------------------------------------\n const char* NullMapper::get_mapper_name(void) const \n \/\/--------------------------------------------------------------------------\n {\n \/\/ Do this one explicitly to avoid infinite recursion\n log_null.error(\"Unimplemented mapper method \\\"get_mapper_name\\\"\");\n assert(false);\n return NULL;\n }\n\n \/\/--------------------------------------------------------------------------\n Mapper::MapperSyncModel NullMapper::get_mapper_sync_model(void) const\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n return SERIALIZED_REENTRANT_MAPPER_MODEL;\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_task_options(const MapperContext ctx,\n const Task& task,\n TaskOptions& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::premap_task(const MapperContext ctx,\n const Task& task, \n const PremapTaskInput& input,\n PremapTaskOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::slice_task(const MapperContext ctx,\n const Task& task, \n const SliceTaskInput& input,\n SliceTaskOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::map_task(const MapperContext ctx,\n const Task& task,\n const MapTaskInput& input,\n MapTaskOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_task_variant(const MapperContext ctx,\n const Task& task,\n const SelectVariantInput& input,\n SelectVariantOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::postmap_task(const MapperContext ctx,\n const Task& task,\n const PostMapInput& input,\n PostMapOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_task_sources(const MapperContext ctx,\n const Task& task,\n const SelectTaskSrcInput& input,\n SelectTaskSrcOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::create_task_temporary_instance(\n const MapperContext ctx,\n const Task& task,\n const CreateTaskTemporaryInput& input,\n CreateTaskTemporaryOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::speculate(const MapperContext ctx,\n const Task& task,\n SpeculativeOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::report_profiling(const MapperContext ctx,\n const Task& task,\n const TaskProfilingInfo& input)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::map_inline(const MapperContext ctx,\n const InlineMapping& inline_op,\n const MapInlineInput& input,\n MapInlineOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_inline_sources(const MapperContext ctx,\n const InlineMapping& inline_op,\n const SelectInlineSrcInput& input,\n SelectInlineSrcOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::create_inline_temporary_instance(\n const MapperContext ctx,\n const InlineMapping& inline_op,\n const CreateInlineTemporaryInput& input,\n CreateInlineTemporaryOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::report_profiling(const MapperContext ctx,\n const InlineMapping& inline_op,\n const InlineProfilingInfo& input)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::map_copy(const MapperContext ctx,\n const Copy& copy,\n const MapCopyInput& input,\n MapCopyOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_copy_sources(const MapperContext ctx,\n const Copy& copy,\n const SelectCopySrcInput& input,\n SelectCopySrcOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::create_copy_temporary_instance(\n const MapperContext ctx,\n const Copy& copy,\n const CreateCopyTemporaryInput& input,\n CreateCopyTemporaryOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::speculate(const MapperContext ctx,\n const Copy& copy,\n SpeculativeOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::report_profiling(const MapperContext ctx,\n const Copy& copy,\n const CopyProfilingInfo& input)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n \n \/\/--------------------------------------------------------------------------\n void NullMapper::map_close(const MapperContext ctx,\n const Close& close,\n const MapCloseInput& input,\n MapCloseOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_close_sources(const MapperContext ctx,\n const Close& close,\n const SelectCloseSrcInput& input,\n SelectCloseSrcOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::create_close_temporary_instance(\n const MapperContext ctx,\n const Close& close,\n const CreateCloseTemporaryInput& input,\n CreateCloseTemporaryOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::report_profiling(const MapperContext ctx,\n const Close& close,\n const CloseProfilingInfo& input)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::map_acquire(const MapperContext ctx,\n const Acquire& acquire,\n const MapAcquireInput& input,\n MapAcquireOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::speculate(const MapperContext ctx,\n const Acquire& acquire,\n SpeculativeOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::report_profiling(const MapperContext ctx,\n const Acquire& acquire,\n const AcquireProfilingInfo& input)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::map_release(const MapperContext ctx,\n const Release& release,\n const MapReleaseInput& input,\n MapReleaseOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_release_sources(const MapperContext ctx,\n const Release& release,\n const SelectReleaseSrcInput& input,\n SelectReleaseSrcOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::speculate(const MapperContext ctx,\n const Release& release,\n SpeculativeOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::create_release_temporary_instance(\n const MapperContext ctx,\n const Release& release,\n const CreateReleaseTemporaryInput& input,\n CreateReleaseTemporaryOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::report_profiling(const MapperContext ctx,\n const Release& release,\n const ReleaseProfilingInfo& input)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_partition_projection(const MapperContext ctx,\n const Partition& partition,\n const SelectPartitionProjectionInput& input,\n SelectPartitionProjectionOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::map_partition(const MapperContext ctx,\n const Partition& partition,\n const MapPartitionInput& input,\n MapPartitionOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_partition_sources(\n const MapperContext ctx,\n const Partition& partition,\n const SelectPartitionSrcInput& input,\n SelectPartitionSrcOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::create_partition_temporary_instance(\n const MapperContext ctx,\n const Partition& partition,\n const CreatePartitionTemporaryInput& input,\n CreatePartitionTemporaryOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::report_profiling(const MapperContext ctx,\n const Partition& partition,\n const PartitionProfilingInfo& input)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::configure_context(const MapperContext ctx,\n const Task& task,\n ContextConfigOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_tunable_value(const MapperContext ctx,\n const Task& task,\n const SelectTunableInput& input,\n SelectTunableOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::map_must_epoch(const MapperContext ctx,\n const MapMustEpochInput& input,\n MapMustEpochOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::map_dataflow_graph(const MapperContext ctx,\n const MapDataflowGraphInput& input,\n MapDataflowGraphOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::memoize_operation(const MapperContext ctx,\n const Mappable& mappable,\n const MemoizeInput& input,\n MemoizeOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_tasks_to_map(const MapperContext ctx,\n const SelectMappingInput& input,\n SelectMappingOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_steal_targets(const MapperContext ctx,\n const SelectStealingInput& input,\n SelectStealingOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::permit_steal_request(const MapperContext ctx,\n const StealRequestInput& input,\n StealRequestOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::handle_message(const MapperContext ctx,\n const MapperMessage& message)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::handle_task_result(const MapperContext ctx,\n const MapperTaskResult& result)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n }; \/\/ namespace Mapping \n}; \/\/ namespace Legion\n\n\/\/ EOF\n\nmappers: fix null mapper bug\/* Copyright 2019 Stanford University, NVIDIA Corporation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http:\/\/www.apache.org\/licenses\/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\/\n\n#include \"mappers\/null_mapper.h\"\n\nnamespace Legion {\n namespace Mapping {\n\n Logger log_null(\"null_mapper\");\n\n \/\/--------------------------------------------------------------------------\n NullMapper::NullMapper(MapperRuntime *rt, Machine m)\n : Mapper(rt), machine(m)\n \/\/--------------------------------------------------------------------------\n {\n }\n\n \/\/--------------------------------------------------------------------------\n NullMapper::NullMapper(const NullMapper &rhs)\n : Mapper(rhs.runtime), machine(rhs.machine)\n \/\/--------------------------------------------------------------------------\n {\n \/\/ should never be called\n assert(false);\n }\n\n \/\/--------------------------------------------------------------------------\n NullMapper::~NullMapper(void)\n \/\/--------------------------------------------------------------------------\n {\n }\n\n \/\/--------------------------------------------------------------------------\n NullMapper& NullMapper::operator=(const NullMapper &rhs)\n \/\/--------------------------------------------------------------------------\n {\n \/\/ should never be called\n assert(false);\n return *this;\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::report_unimplemented(const char *func_name,\n unsigned line) const\n \/\/--------------------------------------------------------------------------\n {\n log_null.error(\"Unimplemented mapper method \\\"%s\\\" in mapper %s \"\n \"on line %d of %s\", func_name, get_mapper_name(), line, __FILE__);\n assert(false);\n }\n\n \/\/--------------------------------------------------------------------------\n const char* NullMapper::get_mapper_name(void) const \n \/\/--------------------------------------------------------------------------\n {\n \/\/ Do this one explicitly to avoid infinite recursion\n log_null.error(\"Unimplemented mapper method \\\"get_mapper_name\\\"\");\n assert(false);\n return NULL;\n }\n\n \/\/--------------------------------------------------------------------------\n Mapper::MapperSyncModel NullMapper::get_mapper_sync_model(void) const\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n return SERIALIZED_REENTRANT_MAPPER_MODEL;\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_task_options(const MapperContext ctx,\n const Task& task,\n TaskOptions& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::premap_task(const MapperContext ctx,\n const Task& task, \n const PremapTaskInput& input,\n PremapTaskOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::slice_task(const MapperContext ctx,\n const Task& task, \n const SliceTaskInput& input,\n SliceTaskOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::map_task(const MapperContext ctx,\n const Task& task,\n const MapTaskInput& input,\n MapTaskOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_task_variant(const MapperContext ctx,\n const Task& task,\n const SelectVariantInput& input,\n SelectVariantOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::postmap_task(const MapperContext ctx,\n const Task& task,\n const PostMapInput& input,\n PostMapOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_task_sources(const MapperContext ctx,\n const Task& task,\n const SelectTaskSrcInput& input,\n SelectTaskSrcOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::create_task_temporary_instance(\n const MapperContext ctx,\n const Task& task,\n const CreateTaskTemporaryInput& input,\n CreateTaskTemporaryOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::speculate(const MapperContext ctx,\n const Task& task,\n SpeculativeOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::report_profiling(const MapperContext ctx,\n const Task& task,\n const TaskProfilingInfo& input)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::map_inline(const MapperContext ctx,\n const InlineMapping& inline_op,\n const MapInlineInput& input,\n MapInlineOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_inline_sources(const MapperContext ctx,\n const InlineMapping& inline_op,\n const SelectInlineSrcInput& input,\n SelectInlineSrcOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::create_inline_temporary_instance(\n const MapperContext ctx,\n const InlineMapping& inline_op,\n const CreateInlineTemporaryInput& input,\n CreateInlineTemporaryOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::report_profiling(const MapperContext ctx,\n const InlineMapping& inline_op,\n const InlineProfilingInfo& input)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::map_copy(const MapperContext ctx,\n const Copy& copy,\n const MapCopyInput& input,\n MapCopyOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_copy_sources(const MapperContext ctx,\n const Copy& copy,\n const SelectCopySrcInput& input,\n SelectCopySrcOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::create_copy_temporary_instance(\n const MapperContext ctx,\n const Copy& copy,\n const CreateCopyTemporaryInput& input,\n CreateCopyTemporaryOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::speculate(const MapperContext ctx,\n const Copy& copy,\n SpeculativeOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::report_profiling(const MapperContext ctx,\n const Copy& copy,\n const CopyProfilingInfo& input)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n \n \/\/--------------------------------------------------------------------------\n void NullMapper::map_close(const MapperContext ctx,\n const Close& close,\n const MapCloseInput& input,\n MapCloseOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_close_sources(const MapperContext ctx,\n const Close& close,\n const SelectCloseSrcInput& input,\n SelectCloseSrcOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::create_close_temporary_instance(\n const MapperContext ctx,\n const Close& close,\n const CreateCloseTemporaryInput& input,\n CreateCloseTemporaryOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::report_profiling(const MapperContext ctx,\n const Close& close,\n const CloseProfilingInfo& input)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::map_acquire(const MapperContext ctx,\n const Acquire& acquire,\n const MapAcquireInput& input,\n MapAcquireOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::speculate(const MapperContext ctx,\n const Acquire& acquire,\n SpeculativeOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::report_profiling(const MapperContext ctx,\n const Acquire& acquire,\n const AcquireProfilingInfo& input)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::map_release(const MapperContext ctx,\n const Release& release,\n const MapReleaseInput& input,\n MapReleaseOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_release_sources(const MapperContext ctx,\n const Release& release,\n const SelectReleaseSrcInput& input,\n SelectReleaseSrcOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::speculate(const MapperContext ctx,\n const Release& release,\n SpeculativeOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::create_release_temporary_instance(\n const MapperContext ctx,\n const Release& release,\n const CreateReleaseTemporaryInput& input,\n CreateReleaseTemporaryOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::report_profiling(const MapperContext ctx,\n const Release& release,\n const ReleaseProfilingInfo& input)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_partition_projection(const MapperContext ctx,\n const Partition& partition,\n const SelectPartitionProjectionInput& input,\n SelectPartitionProjectionOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::map_partition(const MapperContext ctx,\n const Partition& partition,\n const MapPartitionInput& input,\n MapPartitionOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_partition_sources(\n const MapperContext ctx,\n const Partition& partition,\n const SelectPartitionSrcInput& input,\n SelectPartitionSrcOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::create_partition_temporary_instance(\n const MapperContext ctx,\n const Partition& partition,\n const CreatePartitionTemporaryInput& input,\n CreatePartitionTemporaryOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::report_profiling(const MapperContext ctx,\n const Partition& partition,\n const PartitionProfilingInfo& input)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::configure_context(const MapperContext ctx,\n const Task& task,\n ContextConfigOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_tunable_value(const MapperContext ctx,\n const Task& task,\n const SelectTunableInput& input,\n SelectTunableOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::map_must_epoch(const MapperContext ctx,\n const MapMustEpochInput& input,\n MapMustEpochOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::map_dataflow_graph(const MapperContext ctx,\n const MapDataflowGraphInput& input,\n MapDataflowGraphOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::memoize_operation(const MapperContext ctx,\n const Mappable& mappable,\n const MemoizeInput& input,\n MemoizeOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_tasks_to_map(const MapperContext ctx,\n const SelectMappingInput& input,\n SelectMappingOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::select_steal_targets(const MapperContext ctx,\n const SelectStealingInput& input,\n SelectStealingOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::permit_steal_request(const MapperContext ctx,\n const StealRequestInput& input,\n StealRequestOutput& output)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::handle_message(const MapperContext ctx,\n const MapperMessage& message)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__); \n }\n\n \/\/--------------------------------------------------------------------------\n void NullMapper::handle_task_result(const MapperContext ctx,\n const MapperTaskResult& result)\n \/\/--------------------------------------------------------------------------\n {\n report_unimplemented(__func__, __LINE__);\n }\n\n }; \/\/ namespace Mapping \n}; \/\/ namespace Legion\n\n\/\/ EOF\n\n<|endoftext|>"} {"text":"\/*************************************************************************\n *\n * $RCSfile: linguprops.hxx,v $\n *\n * $Revision: 1.1 $\n *\n * last change: $Author: tl $ $Date: 2001-02-02 10:54:29 $\n *\n * The Contents of this file are made available subject to the terms of\n * either of the following licenses\n *\n * - GNU Lesser General Public License Version 2.1\n * - Sun Industry Standards Source License Version 1.1\n *\n * Sun Microsystems Inc., October, 2000\n *\n * GNU Lesser General Public License Version 2.1\n * =============================================\n * Copyright 2000 by Sun Microsystems, Inc.\n * 901 San Antonio Road, Palo Alto, CA 94303, USA\n *\n * This library is free software; you can redistribute it and\/or\n * modify it under the terms of the GNU Lesser General Public\n * License version 2.1, as published by the Free Software Foundation.\n *\n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this library; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place, Suite 330, Boston,\n * MA 02111-1307 USA\n *\n *\n * Sun Industry Standards Source License Version 1.1\n * =================================================\n * The contents of this file are subject to the Sun Industry Standards\n * Source License Version 1.1 (the \"License\"); You may not use this file\n * except in compliance with the License. You may obtain a copy of the\n * License at http:\/\/www.openoffice.org\/license.html.\n *\n * Software provided under this License is provided on an \"AS IS\" basis,\n * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,\n * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,\n * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.\n * See the License for the specific provisions governing your rights and\n * obligations concerning the Software.\n *\n * The Initial Developer of the Original Code is: Sun Microsystems, Inc.\n *\n * Copyright: 2000 by Sun Microsystems, Inc.\n *\n * All Rights Reserved.\n *\n * Contributor(s): _______________________________________\n *\n *\n ************************************************************************\/\n\n#ifndef _SVTOOLS_LINGUPROPS_HXX_\n#define _SVTOOLS_LINGUPROPS_HXX_\n\n\n\/\/ UNO property names for general options\n#define UPN_IS_GERMAN_PRE_REFORM \"IsGermanPreReform\"\n#define UPN_IS_USE_DICTIONARY_LIST \"IsUseDictionaryList\"\n#define UPN_IS_IGNORE_CONTROL_CHARACTERS \"IsIgnoreControlCharacters\"\n\n\/\/ UNO property names for SpellChecker\n#define UPN_IS_SPELL_UPPER_CASE \"IsSpellUpperCase\"\n#define UPN_IS_SPELL_WITH_DIGITS \"IsSpellWithDigits\"\n#define UPN_IS_SPELL_CAPITALIZATION \"IsSpellCapitalization\"\n\n\/\/ UNO property names for Hyphenator\n#define UPN_HYPH_MIN_LEADING \"HyphMinLeading\"\n#define UPN_HYPH_MIN_TRAILING \"HyphMinTrailing\"\n#define UPN_HYPH_MIN_WORD_LENGTH \"HyphMinWordLength\"\n\n\/\/ UNO property names for OtherLingu (foreign Linguistik)\n#define UPN_IS_STANDARD_HYPHENATOR \"IsStandardHyphenator\"\n#define UPN_IS_STANDARD_SPELL_CHECKER \"IsStandardSpellChecker\"\n#define UPN_IS_STANDARD_THESAURUS \"IsStandardThesaurus\"\n#define UPN_OTHER_LINGU_INDEX \"OtherLinguIndex\"\n\n\/\/ UNO property names for Lingu\n\/\/ (those not covered by the SpellChecker, Hyphenator and OtherLingu\n\/\/ properties and more likely to be used in other modules only)\n#define UPN_DEFAULT_LANGUAGE \"DefaultLanguage\"\n#define UPN_DEFAULT_LOCALE \"DefaultLocale\"\n#define UPN_DEFAULT_LOCALE_CJK \"DefaultLocale_CJK\"\n#define UPN_DEFAULT_LOCALE_CTL \"DefaultLocale_CTL\"\n#define UPN_IS_HYPH_AUTO \"IsHyphAuto\"\n#define UPN_IS_HYPH_SPECIAL \"IsHyphSpecial\"\n#define UPN_IS_SPELL_AUTO \"IsSpellAuto\"\n#define UPN_IS_SPELL_HIDE \"IsSpellHide\"\n#define UPN_IS_SPELL_IN_ALL_LANGUAGES \"IsSpellInAllLanguages\"\n#define UPN_IS_SPELL_SPECIAL \"IsSpellSpecial\"\n#define UPN_IS_WRAP_REVERSE \"IsWrapReverse\"\n\n\/\/ uno property handles\n#define UPH_IS_GERMAN_PRE_REFORM 0\n#define UPH_IS_USE_DICTIONARY_LIST 1\n#define UPH_IS_IGNORE_CONTROL_CHARACTERS 2\n#define UPH_IS_SPELL_UPPER_CASE 3\n#define UPH_IS_SPELL_WITH_DIGITS 4\n#define UPH_IS_SPELL_CAPITALIZATION 5\n#define UPH_HYPH_MIN_LEADING 6\n#define UPH_HYPH_MIN_TRAILING 7\n#define UPH_HYPH_MIN_WORD_LENGTH 8\n#define UPH_DEFAULT_LOCALE 9\n#define UPH_IS_SPELL_AUTO 10\n#define UPH_IS_SPELL_HIDE 11\n#define UPH_IS_SPELL_IN_ALL_LANGUAGES 12\n#define UPH_IS_SPELL_SPECIAL 13\n#define UPH_IS_HYPH_AUTO 14\n#define UPH_IS_HYPH_SPECIAL 15\n#define UPH_IS_WRAP_REVERSE 16\n#define UPH_IS_STANDARD_HYPHENATOR 17\n#define UPH_IS_STANDARD_SPELL_CHECKER 18\n#define UPH_IS_STANDARD_THESAURUS 19\n#define UPH_OTHER_LINGU_INDEX 20\n#define UPH_DEFAULT_LANGUAGE 21\n#define UPH_DEFAULT_LOCALE_CJK 22\n#define UPH_DEFAULT_LOCALE_CTL 23\n\n#endif\n\nproerty name and handle for active dictionaries added\/*************************************************************************\n *\n * $RCSfile: linguprops.hxx,v $\n *\n * $Revision: 1.2 $\n *\n * last change: $Author: tl $ $Date: 2001-02-02 15:34:06 $\n *\n * The Contents of this file are made available subject to the terms of\n * either of the following licenses\n *\n * - GNU Lesser General Public License Version 2.1\n * - Sun Industry Standards Source License Version 1.1\n *\n * Sun Microsystems Inc., October, 2000\n *\n * GNU Lesser General Public License Version 2.1\n * =============================================\n * Copyright 2000 by Sun Microsystems, Inc.\n * 901 San Antonio Road, Palo Alto, CA 94303, USA\n *\n * This library is free software; you can redistribute it and\/or\n * modify it under the terms of the GNU Lesser General Public\n * License version 2.1, as published by the Free Software Foundation.\n *\n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this library; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place, Suite 330, Boston,\n * MA 02111-1307 USA\n *\n *\n * Sun Industry Standards Source License Version 1.1\n * =================================================\n * The contents of this file are subject to the Sun Industry Standards\n * Source License Version 1.1 (the \"License\"); You may not use this file\n * except in compliance with the License. You may obtain a copy of the\n * License at http:\/\/www.openoffice.org\/license.html.\n *\n * Software provided under this License is provided on an \"AS IS\" basis,\n * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,\n * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,\n * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.\n * See the License for the specific provisions governing your rights and\n * obligations concerning the Software.\n *\n * The Initial Developer of the Original Code is: Sun Microsystems, Inc.\n *\n * Copyright: 2000 by Sun Microsystems, Inc.\n *\n * All Rights Reserved.\n *\n * Contributor(s): _______________________________________\n *\n *\n ************************************************************************\/\n\n#ifndef _SVTOOLS_LINGUPROPS_HXX_\n#define _SVTOOLS_LINGUPROPS_HXX_\n\n\n\/\/ UNO property names for general options\n#define UPN_IS_GERMAN_PRE_REFORM \"IsGermanPreReform\"\n#define UPN_IS_USE_DICTIONARY_LIST \"IsUseDictionaryList\"\n#define UPN_IS_IGNORE_CONTROL_CHARACTERS \"IsIgnoreControlCharacters\"\n#define UPN_ACTIVE_DICTIONARIES \"ActiveDictionaries\"\n\n\/\/ UNO property names for SpellChecker\n#define UPN_IS_SPELL_UPPER_CASE \"IsSpellUpperCase\"\n#define UPN_IS_SPELL_WITH_DIGITS \"IsSpellWithDigits\"\n#define UPN_IS_SPELL_CAPITALIZATION \"IsSpellCapitalization\"\n\n\/\/ UNO property names for Hyphenator\n#define UPN_HYPH_MIN_LEADING \"HyphMinLeading\"\n#define UPN_HYPH_MIN_TRAILING \"HyphMinTrailing\"\n#define UPN_HYPH_MIN_WORD_LENGTH \"HyphMinWordLength\"\n\n\/\/ UNO property names for OtherLingu (foreign Linguistik)\n#define UPN_IS_STANDARD_HYPHENATOR \"IsStandardHyphenator\"\n#define UPN_IS_STANDARD_SPELL_CHECKER \"IsStandardSpellChecker\"\n#define UPN_IS_STANDARD_THESAURUS \"IsStandardThesaurus\"\n#define UPN_OTHER_LINGU_INDEX \"OtherLinguIndex\"\n\n\/\/ UNO property names for Lingu\n\/\/ (those not covered by the SpellChecker, Hyphenator and OtherLingu\n\/\/ properties and more likely to be used in other modules only)\n#define UPN_DEFAULT_LANGUAGE \"DefaultLanguage\"\n#define UPN_DEFAULT_LOCALE \"DefaultLocale\"\n#define UPN_DEFAULT_LOCALE_CJK \"DefaultLocale_CJK\"\n#define UPN_DEFAULT_LOCALE_CTL \"DefaultLocale_CTL\"\n#define UPN_IS_HYPH_AUTO \"IsHyphAuto\"\n#define UPN_IS_HYPH_SPECIAL \"IsHyphSpecial\"\n#define UPN_IS_SPELL_AUTO \"IsSpellAuto\"\n#define UPN_IS_SPELL_HIDE \"IsSpellHide\"\n#define UPN_IS_SPELL_IN_ALL_LANGUAGES \"IsSpellInAllLanguages\"\n#define UPN_IS_SPELL_SPECIAL \"IsSpellSpecial\"\n#define UPN_IS_WRAP_REVERSE \"IsWrapReverse\"\n\n\/\/ uno property handles\n#define UPH_IS_GERMAN_PRE_REFORM 0\n#define UPH_IS_USE_DICTIONARY_LIST 1\n#define UPH_IS_IGNORE_CONTROL_CHARACTERS 2\n#define UPH_IS_SPELL_UPPER_CASE 3\n#define UPH_IS_SPELL_WITH_DIGITS 4\n#define UPH_IS_SPELL_CAPITALIZATION 5\n#define UPH_HYPH_MIN_LEADING 6\n#define UPH_HYPH_MIN_TRAILING 7\n#define UPH_HYPH_MIN_WORD_LENGTH 8\n#define UPH_DEFAULT_LOCALE 9\n#define UPH_IS_SPELL_AUTO 10\n#define UPH_IS_SPELL_HIDE 11\n#define UPH_IS_SPELL_IN_ALL_LANGUAGES 12\n#define UPH_IS_SPELL_SPECIAL 13\n#define UPH_IS_HYPH_AUTO 14\n#define UPH_IS_HYPH_SPECIAL 15\n#define UPH_IS_WRAP_REVERSE 16\n#define UPH_IS_STANDARD_HYPHENATOR 17\n#define UPH_IS_STANDARD_SPELL_CHECKER 18\n#define UPH_IS_STANDARD_THESAURUS 19\n#define UPH_OTHER_LINGU_INDEX 20\n#define UPH_DEFAULT_LANGUAGE 21\n#define UPH_DEFAULT_LOCALE_CJK 22\n#define UPH_DEFAULT_LOCALE_CTL 23\n#define UPH_ACTIVE_DICTIONARIES 24\n\n#endif\n\n<|endoftext|>"} {"text":"gcc-trunk: fix: unable to find string literal operator 'operator FOO'<|endoftext|>"} {"text":"Create network_opt_tests.cpp<|endoftext|>"} {"text":"\/*************************************************************************\n *\n * OpenOffice.org - a multi-platform office productivity suite\n *\n * $RCSfile: dynamicregister.cxx,v $\n *\n * $Revision: 1.8 $\n *\n * last change: $Author: obo $ $Date: 2006-09-17 03:41:24 $\n *\n * The Contents of this file are made available subject to\n * the terms of GNU Lesser General Public License Version 2.1.\n *\n *\n * GNU Lesser General Public License Version 2.1\n * =============================================\n * Copyright 2005 by Sun Microsystems, Inc.\n * 901 San Antonio Road, Palo Alto, CA 94303, USA\n *\n * This library is free software; you can redistribute it and\/or\n * modify it under the terms of the GNU Lesser General Public\n * License version 2.1, as published by the Free Software Foundation.\n *\n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this library; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place, Suite 330, Boston,\n * MA 02111-1307 USA\n *\n ************************************************************************\/\n\n\/\/ MARKER(update_precomp.py): autogen include statement, do not remove\n#include \"precompiled_testshl2.hxx\"\n\n#include \"dynamicregister.hxx\"\n#ifndef _OSL_PROCESS_H_\n#include \n#endif\n\/\/ #include \n#include \n#include \n#include \"filehelper.hxx\"\n\n\/\/ -----------------------------------------------------------------------------\n\nDynamicLibraryHelper::DynamicLibraryHelper(rtl::OUString const& _sDLLName, GetOpt & _aOptions)\n :m_pModule(new ::osl::Module()),\n m_suDLLName(_sDLLName),\n m_aOptions(_aOptions)\n{\n \/\/ create and load the module (shared library)\n rtl::OUString suFile = FileHelper::convertPath( _sDLLName );\n rtl::OString sDLLName = rtl::OUStringToOString(suFile, RTL_TEXTENCODING_ASCII_US);\n if (_aOptions.hasOpt(\"-verbose\"))\n {\n fprintf(stderr, \"Try to load '%s'.\\n\", sDLLName.getStr());\n }\n\n if (! m_pModule->load(suFile, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL))\n {\n sDLLName = rtl::OUStringToOString(_sDLLName, RTL_TEXTENCODING_ASCII_US);\n fprintf(stderr, \"warning: Can't load module '%s'.\\n\", sDLLName.getStr());\n }\n}\n\nDynamicLibraryHelper::~DynamicLibraryHelper()\n{\n delete m_pModule;\n}\n\nINTEGRATION: CWS changefileheader (1.8.52); FILE MERGED 2008\/04\/01 16:00:19 thb 1.8.52.2: #i85898# Stripping all external header guards 2008\/03\/31 13:06:07 rt 1.8.52.1: #i87441# Change license header to LPGL v3.\/*************************************************************************\n *\n * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.\n *\n * Copyright 2008 by Sun Microsystems, Inc.\n *\n * OpenOffice.org - a multi-platform office productivity suite\n *\n * $RCSfile: dynamicregister.cxx,v $\n * $Revision: 1.9 $\n *\n * This file is part of OpenOffice.org.\n *\n * OpenOffice.org is free software: you can redistribute it and\/or modify\n * it under the terms of the GNU Lesser General Public License version 3\n * only, as published by the Free Software Foundation.\n *\n * OpenOffice.org is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Lesser General Public License version 3 for more details\n * (a copy is included in the LICENSE file that accompanied this code).\n *\n * You should have received a copy of the GNU Lesser General Public License\n * version 3 along with OpenOffice.org. If not, see\n * \n * for a copy of the LGPLv3 License.\n *\n ************************************************************************\/\n\n\/\/ MARKER(update_precomp.py): autogen include statement, do not remove\n#include \"precompiled_testshl2.hxx\"\n\n#include \"dynamicregister.hxx\"\n#include \n\/\/ #include \n#include \n#include \n#include \"filehelper.hxx\"\n\n\/\/ -----------------------------------------------------------------------------\n\nDynamicLibraryHelper::DynamicLibraryHelper(rtl::OUString const& _sDLLName, GetOpt & _aOptions)\n :m_pModule(new ::osl::Module()),\n m_suDLLName(_sDLLName),\n m_aOptions(_aOptions)\n{\n \/\/ create and load the module (shared library)\n rtl::OUString suFile = FileHelper::convertPath( _sDLLName );\n rtl::OString sDLLName = rtl::OUStringToOString(suFile, RTL_TEXTENCODING_ASCII_US);\n if (_aOptions.hasOpt(\"-verbose\"))\n {\n fprintf(stderr, \"Try to load '%s'.\\n\", sDLLName.getStr());\n }\n\n if (! m_pModule->load(suFile, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL))\n {\n sDLLName = rtl::OUStringToOString(_sDLLName, RTL_TEXTENCODING_ASCII_US);\n fprintf(stderr, \"warning: Can't load module '%s'.\\n\", sDLLName.getStr());\n }\n}\n\nDynamicLibraryHelper::~DynamicLibraryHelper()\n{\n delete m_pModule;\n}\n\n<|endoftext|>"} {"text":"\/\/ Copyright 2010-2013 RethinkDB, all rights reserved.\n#include \n\n#include \"errors.hpp\"\n#include \n\n#include \"http\/http.hpp\"\n#include \"clustering\/administration\/http\/json_adapters.hpp\"\n#include \"clustering\/administration\/http\/semilattice_app.hpp\"\n#include \"clustering\/administration\/suggester.hpp\"\n#include \"stl_utils.hpp\"\n\ntemplate \nsemilattice_http_app_t::semilattice_http_app_t(\n metadata_change_handler_t *_metadata_change_handler,\n const clone_ptr_t > > &_directory_metadata,\n uuid_u _us) :\n directory_metadata(_directory_metadata),\n us(_us),\n metadata_change_handler(_metadata_change_handler) {\n \/\/ Do nothing\n}\n\ntemplate \nsemilattice_http_app_t::~semilattice_http_app_t() {\n \/\/ Do nothing\n}\n\ntemplate \nvoid semilattice_http_app_t::get_root(scoped_cJSON_t *json_out) {\n \/\/ keep this in sync with handle's behavior for getting the root\n metadata_t metadata = metadata_change_handler->get();\n vclock_ctx_t json_ctx(us);\n json_ctx_adapter_t json_adapter(&metadata, json_ctx);\n json_out->reset(json_adapter.render());\n}\n\ntemplate \nhttp_res_t semilattice_http_app_t::handle(const http_req_t &req) {\n try {\n metadata_t metadata = metadata_change_handler->get();\n\n \/\/as we traverse the json sub directories this will keep track of where we are\n vclock_ctx_t json_ctx(us);\n boost::shared_ptr json_adapter_head(new json_ctx_adapter_t(&metadata, json_ctx));\n\n http_req_t::resource_t::iterator it = req.resource.begin();\n\n \/\/Traverse through the subfields until we're done with the url\n while (it != req.resource.end()) {\n json_adapter_if_t::json_adapter_map_t subfields = json_adapter_head->get_subfields();\n if (subfields.find(*it) == subfields.end()) {\n return http_res_t(HTTP_NOT_FOUND); \/\/someone tried to walk off the edge of the world\n }\n json_adapter_head = subfields[*it];\n it++;\n }\n\n \/\/json_adapter_head now points to the correct part of the metadata time to build a response and be on our way\n switch (req.method) {\n case GET:\n {\n scoped_cJSON_t json_repr(json_adapter_head->render());\n return http_json_res(json_repr.get());\n }\n break;\n case POST:\n {\n \/\/ TODO: Get rid of this release mode wrapper, make Michael unhappy.\n#ifdef NDEBUG\n if (!verify_content_type(req, \"application\/json\")) {\n return http_res_t(HTTP_UNSUPPORTED_MEDIA_TYPE);\n }\n#endif\n scoped_cJSON_t change(cJSON_Parse(req.body.c_str()));\n if (!change.get()) { \/\/A null value indicates that parsing failed\n logINF(\"Json body failed to parse. Here's the data that failed: %s\",\n req.get_sanitized_body().c_str());\n return http_res_t(HTTP_BAD_REQUEST);\n }\n\n json_adapter_head->apply(change.get());\n\n {\n scoped_cJSON_t absolute_change(change.release());\n std::vector parts(req.resource.begin(), req.resource.end());\n for (std::vector::reverse_iterator jt = parts.rbegin(); jt != parts.rend(); ++jt) {\n scoped_cJSON_t inner(absolute_change.release());\n absolute_change.reset(cJSON_CreateObject());\n absolute_change.AddItemToObject(jt->c_str(), inner.release());\n }\n logINF(\"Applying data %s\", absolute_change.PrintUnformatted().c_str());\n }\n\n \/\/ Determine for which namespaces we should prioritize distribution\n \/\/ Default: none\n defaulting_map_t prioritize_distr_for_ns(false);\n const boost::optional prefer_distribution_param =\n req.find_query_param(\"prefer_distribution\");\n if (prefer_distribution_param) {\n if (prefer_distribution_param.get() == \"none\") {\n } else if (prefer_distribution_param.get() == \"all\") {\n prioritize_distr_for_ns =\n defaulting_map_t(true);\n } else if (prefer_distribution_param.get() == \"changed_only\") {\n \/\/ TODO!\n prioritize_distr_for_ns =\n defaulting_map_t(true);\n }\n }\n\n metadata_change_callback(&metadata, prioritize_distr_for_ns);\n metadata_change_handler->update(metadata);\n\n scoped_cJSON_t json_repr(json_adapter_head->render());\n return http_json_res(json_repr.get());\n }\n break;\n case DELETE:\n {\n json_adapter_head->erase();\n\n logINF(\"Deleting %s\", req.resource.as_string().c_str());\n\n metadata_change_callback(&metadata,\n defaulting_map_t(false));\n metadata_change_handler->update(metadata);\n\n scoped_cJSON_t json_repr(json_adapter_head->render());\n return http_json_res(json_repr.get());\n }\n break;\n case PUT:\n {\n \/\/ TODO: Get rid of this release mode wrapper, make Michael unhappy.\n#ifdef NDEBUG\n if (!verify_content_type(req, \"application\/json\")) {\n return http_res_t(HTTP_UNSUPPORTED_MEDIA_TYPE);\n }\n#endif\n scoped_cJSON_t change(cJSON_Parse(req.body.c_str()));\n if (!change.get()) { \/\/A null value indicates that parsing failed\n logINF(\"Json body failed to parse. Here's the data that failed: %s\",\n req.get_sanitized_body().c_str());\n return http_res_t(HTTP_BAD_REQUEST);\n }\n\n {\n scoped_cJSON_t absolute_change(change.release());\n std::vector parts(req.resource.begin(), req.resource.end());\n for (std::vector::reverse_iterator jt = parts.rbegin(); jt != parts.rend(); ++jt) {\n scoped_cJSON_t inner(absolute_change.release());\n absolute_change.reset(cJSON_CreateObject());\n absolute_change.AddItemToObject(jt->c_str(), inner.release());\n }\n logINF(\"Applying data %s\", absolute_change.PrintUnformatted().c_str());\n }\n\n json_adapter_head->reset();\n json_adapter_head->apply(change.get());\n\n metadata_change_callback(&metadata,\n defaulting_map_t(false));\n metadata_change_handler->update(metadata);\n\n scoped_cJSON_t json_repr(json_adapter_head->render());\n return http_json_res(json_repr.get());\n }\n break;\n case HEAD:\n case TRACE:\n case OPTIONS:\n case CONNECT:\n case PATCH:\n default:\n return http_res_t(HTTP_METHOD_NOT_ALLOWED);\n break;\n }\n } catch (const schema_mismatch_exc_t &e) {\n logINF(\"HTTP request throw a schema_mismatch_exc_t with what = %s\", e.what());\n return http_error_res(e.what());\n } catch (const permission_denied_exc_t &e) {\n logINF(\"HTTP request throw a permission_denied_exc_t with what = %s\", e.what());\n return http_error_res(e.what());\n } catch (const cannot_satisfy_goals_exc_t &e) {\n logINF(\"The server was given a set of goals for which it couldn't find a valid blueprint. %s\", e.what());\n return http_error_res(e.what(), HTTP_INTERNAL_SERVER_ERROR);\n } catch (const gone_exc_t & e) {\n logINF(\"HTTP request throw a gone_exc_t with what = %s\", e.what());\n return http_error_res(e.what(), HTTP_GONE);\n }\n unreachable();\n}\n\ntemplate \nbool semilattice_http_app_t::verify_content_type(const http_req_t &req,\n const std::string &expected_content_type) const {\n boost::optional content_type = req.find_header_line(\"Content-Type\");\n \/\/ Only compare the beginning of the content-type. Some browsers may add additional\n \/\/ information, and e.g. send \"application\/json; charset=UTF-8\" instead of \"application\/json\"\n if (!content_type || !boost::istarts_with(content_type.get(), expected_content_type)) {\n std::string actual_content_type = (content_type ? content_type.get() : \"\");\n logINF(\"Bad request, Content-Type should be %s, but is %s.\", expected_content_type.c_str(), actual_content_type.c_str());\n return false;\n }\n\n return true;\n}\n\ncluster_semilattice_http_app_t::cluster_semilattice_http_app_t(\n metadata_change_handler_t *_metadata_change_handler,\n const clone_ptr_t > > &_directory_metadata,\n uuid_u _us) :\n semilattice_http_app_t(_metadata_change_handler, _directory_metadata, _us) {\n \/\/ Do nothing\n}\n\ncluster_semilattice_http_app_t::~cluster_semilattice_http_app_t() {\n \/\/ Do nothing\n}\n\nvoid cluster_semilattice_http_app_t::metadata_change_callback(cluster_semilattice_metadata_t *new_metadata,\n const defaulting_map_t &prioritize_distr_for_ns) {\n\n try {\n fill_in_blueprints(new_metadata,\n directory_metadata->get().get_inner(),\n us,\n prioritize_distr_for_ns);\n } catch (const missing_machine_exc_t &e) { }\n}\n\nauth_semilattice_http_app_t::auth_semilattice_http_app_t(\n metadata_change_handler_t *_metadata_change_handler,\n const clone_ptr_t > > &_directory_metadata,\n uuid_u _us) :\n semilattice_http_app_t(_metadata_change_handler, _directory_metadata, _us) {\n \/\/ Do nothing\n}\n\nauth_semilattice_http_app_t::~auth_semilattice_http_app_t() {\n \/\/ Do nothing\n}\n\nvoid auth_semilattice_http_app_t::metadata_change_callback(auth_semilattice_metadata_t *,\n const defaulting_map_t &) {\n\n \/\/ Do nothing\n}\n\ntemplate class semilattice_http_app_t;\ntemplate class semilattice_http_app_t;\nExtract the affected name spaces in the semilattice app.\/\/ Copyright 2010-2013 RethinkDB, all rights reserved.\n#include \n#include \n\n#include \"errors.hpp\"\n#include \n\n#include \"http\/http.hpp\"\n#include \"clustering\/administration\/http\/json_adapters.hpp\"\n#include \"clustering\/administration\/http\/semilattice_app.hpp\"\n#include \"clustering\/administration\/suggester.hpp\"\n#include \"stl_utils.hpp\"\n\ntemplate \nsemilattice_http_app_t::semilattice_http_app_t(\n metadata_change_handler_t *_metadata_change_handler,\n const clone_ptr_t > > &_directory_metadata,\n uuid_u _us) :\n directory_metadata(_directory_metadata),\n us(_us),\n metadata_change_handler(_metadata_change_handler) {\n \/\/ Do nothing\n}\n\ntemplate \nsemilattice_http_app_t::~semilattice_http_app_t() {\n \/\/ Do nothing\n}\n\ntemplate \nvoid semilattice_http_app_t::get_root(scoped_cJSON_t *json_out) {\n \/\/ keep this in sync with handle's behavior for getting the root\n metadata_t metadata = metadata_change_handler->get();\n vclock_ctx_t json_ctx(us);\n json_ctx_adapter_t json_adapter(&metadata, json_ctx);\n json_out->reset(json_adapter.render());\n}\n\n\/\/ Small helper to extract the changed namespace ids from a JSON change request\nclass collect_namespaces_exc_t {\npublic:\n collect_namespaces_exc_t(const std::string &_msg) : msg(_msg) { }\n std::string get_msg() const { return msg; }\nprivate:\n std::string msg;\n};\nstd::vector collect_affected_namespaces(const cJSON *change_request)\n THROWS_ONLY(collect_namespaces_exc_t) {\n\n if (change_request == NULL) {\n throw collect_namespaces_exc_t(\"Missing change request\");\n }\n if (change_request->type != cJSON_Object ) {\n throw collect_namespaces_exc_t(\"Unhandled change_request type\");\n }\n std::vector result;\n const cJSON *entry = change_request->next;\n while (entry) {\n if (entry->string == NULL) throw collect_namespaces_exc_t(\"Missing field name\");\n try {\n const namespace_id_t ns_id = str_to_uuid(std::string(entry->string));\n result.push_back(ns_id);\n } catch (...) {\n throw collect_namespaces_exc_t(\"Unable to decode UUID: \"\n + std::string(entry->string));\n }\n entry = entry->next;\n }\n return result;\n}\n\ntemplate \nhttp_res_t semilattice_http_app_t::handle(const http_req_t &req) {\n try {\n metadata_t metadata = metadata_change_handler->get();\n\n \/\/as we traverse the json sub directories this will keep track of where we are\n vclock_ctx_t json_ctx(us);\n boost::shared_ptr json_adapter_head(new json_ctx_adapter_t(&metadata, json_ctx));\n\n http_req_t::resource_t::iterator it = req.resource.begin();\n\n \/\/Traverse through the subfields until we're done with the url\n while (it != req.resource.end()) {\n json_adapter_if_t::json_adapter_map_t subfields = json_adapter_head->get_subfields();\n if (subfields.find(*it) == subfields.end()) {\n return http_res_t(HTTP_NOT_FOUND); \/\/someone tried to walk off the edge of the world\n }\n json_adapter_head = subfields[*it];\n it++;\n }\n\n \/\/json_adapter_head now points to the correct part of the metadata time to build a response and be on our way\n switch (req.method) {\n case GET:\n {\n scoped_cJSON_t json_repr(json_adapter_head->render());\n return http_json_res(json_repr.get());\n }\n break;\n case POST:\n {\n \/\/ TODO: Get rid of this release mode wrapper, make Michael unhappy.\n#ifdef NDEBUG\n if (!verify_content_type(req, \"application\/json\")) {\n return http_res_t(HTTP_UNSUPPORTED_MEDIA_TYPE);\n }\n#endif\n scoped_cJSON_t change(cJSON_Parse(req.body.c_str()));\n if (!change.get()) { \/\/A null value indicates that parsing failed\n logINF(\"Json body failed to parse. Here's the data that failed: %s\",\n req.get_sanitized_body().c_str());\n return http_res_t(HTTP_BAD_REQUEST);\n }\n\n \/\/ Determine for which namespaces we should prioritize distribution\n \/\/ Default: none\n defaulting_map_t prioritize_distr_for_ns(false);\n const boost::optional prefer_distribution_param =\n req.find_query_param(\"prefer_distribution\");\n if (prefer_distribution_param) {\n if (prefer_distribution_param.get() == \"none\") {\n } else if (prefer_distribution_param.get() == \"all\") {\n prioritize_distr_for_ns =\n defaulting_map_t(true);\n } else if (prefer_distribution_param.get() == \"changed_only\") {\n try {\n const std::vector changed_ns =\n collect_affected_namespaces(change.get());\n for (auto jt = changed_ns.begin();\n jt != changed_ns.end();\n ++jt) {\n prioritize_distr_for_ns.set(*jt, true);\n }\n } catch (const collect_namespaces_exc_t &e) {\n logINF(\"Unable to extract affected namespaces from request: %s\",\n e.get_msg().c_str());\n return http_res_t(HTTP_BAD_REQUEST);\n }\n } else {\n logINF(\"Invalid value for prefer_distribution argument: %s\",\n prefer_distribution_param.get().c_str());\n return http_res_t(HTTP_BAD_REQUEST);\n }\n }\n\n json_adapter_head->apply(change.get());\n\n {\n scoped_cJSON_t absolute_change(change.release());\n std::vector parts(req.resource.begin(), req.resource.end());\n for (std::vector::reverse_iterator jt = parts.rbegin(); jt != parts.rend(); ++jt) {\n scoped_cJSON_t inner(absolute_change.release());\n absolute_change.reset(cJSON_CreateObject());\n absolute_change.AddItemToObject(jt->c_str(), inner.release());\n }\n logINF(\"Applying data %s\", absolute_change.PrintUnformatted().c_str());\n }\n\n metadata_change_callback(&metadata, prioritize_distr_for_ns);\n metadata_change_handler->update(metadata);\n\n scoped_cJSON_t json_repr(json_adapter_head->render());\n return http_json_res(json_repr.get());\n }\n break;\n case DELETE:\n {\n json_adapter_head->erase();\n\n logINF(\"Deleting %s\", req.resource.as_string().c_str());\n\n metadata_change_callback(&metadata,\n defaulting_map_t(false));\n metadata_change_handler->update(metadata);\n\n scoped_cJSON_t json_repr(json_adapter_head->render());\n return http_json_res(json_repr.get());\n }\n break;\n case PUT:\n {\n \/\/ TODO: Get rid of this release mode wrapper, make Michael unhappy.\n#ifdef NDEBUG\n if (!verify_content_type(req, \"application\/json\")) {\n return http_res_t(HTTP_UNSUPPORTED_MEDIA_TYPE);\n }\n#endif\n scoped_cJSON_t change(cJSON_Parse(req.body.c_str()));\n if (!change.get()) { \/\/A null value indicates that parsing failed\n logINF(\"Json body failed to parse. Here's the data that failed: %s\",\n req.get_sanitized_body().c_str());\n return http_res_t(HTTP_BAD_REQUEST);\n }\n\n {\n scoped_cJSON_t absolute_change(change.release());\n std::vector parts(req.resource.begin(), req.resource.end());\n for (std::vector::reverse_iterator jt = parts.rbegin(); jt != parts.rend(); ++jt) {\n scoped_cJSON_t inner(absolute_change.release());\n absolute_change.reset(cJSON_CreateObject());\n absolute_change.AddItemToObject(jt->c_str(), inner.release());\n }\n logINF(\"Applying data %s\", absolute_change.PrintUnformatted().c_str());\n }\n\n json_adapter_head->reset();\n json_adapter_head->apply(change.get());\n\n metadata_change_callback(&metadata,\n defaulting_map_t(false));\n metadata_change_handler->update(metadata);\n\n scoped_cJSON_t json_repr(json_adapter_head->render());\n return http_json_res(json_repr.get());\n }\n break;\n case HEAD:\n case TRACE:\n case OPTIONS:\n case CONNECT:\n case PATCH:\n default:\n return http_res_t(HTTP_METHOD_NOT_ALLOWED);\n break;\n }\n } catch (const schema_mismatch_exc_t &e) {\n logINF(\"HTTP request throw a schema_mismatch_exc_t with what = %s\", e.what());\n return http_error_res(e.what());\n } catch (const permission_denied_exc_t &e) {\n logINF(\"HTTP request throw a permission_denied_exc_t with what = %s\", e.what());\n return http_error_res(e.what());\n } catch (const cannot_satisfy_goals_exc_t &e) {\n logINF(\"The server was given a set of goals for which it couldn't find a valid blueprint. %s\", e.what());\n return http_error_res(e.what(), HTTP_INTERNAL_SERVER_ERROR);\n } catch (const gone_exc_t & e) {\n logINF(\"HTTP request throw a gone_exc_t with what = %s\", e.what());\n return http_error_res(e.what(), HTTP_GONE);\n }\n unreachable();\n}\n\ntemplate \nbool semilattice_http_app_t::verify_content_type(const http_req_t &req,\n const std::string &expected_content_type) const {\n boost::optional content_type = req.find_header_line(\"Content-Type\");\n \/\/ Only compare the beginning of the content-type. Some browsers may add additional\n \/\/ information, and e.g. send \"application\/json; charset=UTF-8\" instead of \"application\/json\"\n if (!content_type || !boost::istarts_with(content_type.get(), expected_content_type)) {\n std::string actual_content_type = (content_type ? content_type.get() : \"\");\n logINF(\"Bad request, Content-Type should be %s, but is %s.\", expected_content_type.c_str(), actual_content_type.c_str());\n return false;\n }\n\n return true;\n}\n\ncluster_semilattice_http_app_t::cluster_semilattice_http_app_t(\n metadata_change_handler_t *_metadata_change_handler,\n const clone_ptr_t > > &_directory_metadata,\n uuid_u _us) :\n semilattice_http_app_t(_metadata_change_handler, _directory_metadata, _us) {\n \/\/ Do nothing\n}\n\ncluster_semilattice_http_app_t::~cluster_semilattice_http_app_t() {\n \/\/ Do nothing\n}\n\nvoid cluster_semilattice_http_app_t::metadata_change_callback(cluster_semilattice_metadata_t *new_metadata,\n const defaulting_map_t &prioritize_distr_for_ns) {\n\n try {\n fill_in_blueprints(new_metadata,\n directory_metadata->get().get_inner(),\n us,\n prioritize_distr_for_ns);\n } catch (const missing_machine_exc_t &e) { }\n}\n\nauth_semilattice_http_app_t::auth_semilattice_http_app_t(\n metadata_change_handler_t *_metadata_change_handler,\n const clone_ptr_t > > &_directory_metadata,\n uuid_u _us) :\n semilattice_http_app_t(_metadata_change_handler, _directory_metadata, _us) {\n \/\/ Do nothing\n}\n\nauth_semilattice_http_app_t::~auth_semilattice_http_app_t() {\n \/\/ Do nothing\n}\n\nvoid auth_semilattice_http_app_t::metadata_change_callback(auth_semilattice_metadata_t *,\n const defaulting_map_t &) {\n\n \/\/ Do nothing\n}\n\ntemplate class semilattice_http_app_t;\ntemplate class semilattice_http_app_t;\n<|endoftext|>"} {"text":"#include \"clustering\/administration\/issues\/name_conflict.hpp\"\n\nname_conflict_issue_t::name_conflict_issue_t(\n const std::string &_type,\n const std::string &_contested_name,\n const std::set &_contestants) :\n type(_type), contested_name(_contested_name), contestants(_contestants) { }\n\nstd::string name_conflict_issue_t::get_description() const {\n std::string message = \"The following \" + type + \"s are all named '\" + contested_name + \"': \";\n for (std::set::iterator it = contestants.begin(); it != contestants.end(); it++) {\n message += uuid_to_str(*it) + \"; \";\n }\n return message;\n}\n\ncJSON *name_conflict_issue_t::get_json_description() {\n issue_json_t json;\n json.critical = false;\n json.description = \"The following \" + type + \"s are all named '\" + contested_name + \"': \";\n for (std::set::iterator it = contestants.begin(); it != contestants.end(); it++) {\n json.description += uuid_to_str(*it) + \"; \";\n }\n json.type = \"NAME_CONFLICT_ISSUE\";\n json.time = get_secs();\n\n cJSON *res = render_as_json(&json);\n\n cJSON_AddItemToObject(res, \"contested_type\", render_as_json(&type));\n cJSON_AddItemToObject(res, \"contested_name\", render_as_json(&contested_name));\n cJSON_AddItemToObject(res, \"contestants\", render_as_json(&contestants));\n\n return res;\n}\n\nname_conflict_issue_t *name_conflict_issue_t::clone() const {\n return new name_conflict_issue_t(type, contested_name, contestants);\n}\n\nclass name_map_t {\npublic:\n template\n void file_away(const std::map > &map) {\n for (typename std::map >::const_iterator it = map.begin();\n it != map.end(); it++) {\n if (!it->second.is_deleted()) {\n if (!it->second.get().name.in_conflict()) {\n by_name[it->second.get().name.get()].insert(it->first);\n }\n }\n }\n }\n\n void report(const std::string &type,\n std::list > *out) {\n for (std::map, case_insensitive_less_t>::iterator it =\n by_name.begin(); it != by_name.end(); it++) {\n if (it->second.size() > 1) {\n out->push_back(clone_ptr_t(\n new name_conflict_issue_t(type, it->first, it->second)));\n }\n }\n }\n\nprivate:\n class case_insensitive_less_t : public std::binary_function {\n public:\n bool operator()(const std::string &a, const std::string &b) {\n return strcasecmp(a.c_str(), b.c_str()) < 0;\n }\n };\n\n std::map, case_insensitive_less_t> by_name;\n};\n\nclass namespace_map_t {\npublic:\nnamespace_map_t(const std::map > &_databases)\n : databases(_databases)\n{ }\n template\n void file_away(const std::map > &map) {\n for (typename std::map >::const_iterator it = map.begin();\n it != map.end(); it++) {\n if (!it->second.is_deleted()) {\n if (!it->second.get().name.in_conflict() &&\n !it->second.get().database.in_conflict()) {\n if (std_contains(databases, it->second.get().database.get())) {\n deletable_t db = databases[it->second.get().database.get()];\n if (!db.is_deleted() && !db.get().name.in_conflict()) {\n by_name[db.get().name.get() + \".\" + it->second.get().name.get()].insert(it->first);\n }\n }\n }\n }\n }\n }\n\n void report(const std::string &type,\n std::list > *out) {\n for (std::map, case_insensitive_less_t>::iterator it =\n by_name.begin(); it != by_name.end(); it++) {\n if (it->second.size() > 1) {\n out->push_back(clone_ptr_t(\n new name_conflict_issue_t(type, it->first, it->second)));\n }\n }\n }\n\nprivate:\n class case_insensitive_less_t : public std::binary_function {\n public:\n bool operator()(const std::string &a, const std::string &b) {\n return strcasecmp(a.c_str(), b.c_str()) < 0;\n }\n };\n\n std::map, case_insensitive_less_t> by_name;\n std::map > databases;\n};\n\nname_conflict_issue_tracker_t::name_conflict_issue_tracker_t(boost::shared_ptr > _semilattice_view)\n : semilattice_view(_semilattice_view) { }\n\nname_conflict_issue_tracker_t::~name_conflict_issue_tracker_t() { }\n\nstd::list > name_conflict_issue_tracker_t::get_issues() {\n cluster_semilattice_metadata_t metadata = semilattice_view->get();\n\n std::list > issues;\n\n namespace_map_t namespaces(metadata.databases.databases);\n namespaces.file_away(metadata.rdb_namespaces->namespaces);\n namespaces.file_away(metadata.dummy_namespaces->namespaces);\n namespaces.file_away(metadata.memcached_namespaces->namespaces);\n namespaces.report(\"table\", &issues);\n\n name_map_t datacenters;\n datacenters.file_away(metadata.datacenters.datacenters);\n datacenters.report(\"datacenter\", &issues);\n\n name_map_t machines;\n machines.file_away(metadata.machines.machines);\n machines.report(\"machine\", &issues);\n\n name_map_t databases;\n databases.file_away(metadata.databases.databases);\n machines.report(\"databases\", &issues);\n\n return issues;\n}\nFix a stupid copy and paste bug.#include \"clustering\/administration\/issues\/name_conflict.hpp\"\n\nname_conflict_issue_t::name_conflict_issue_t(\n const std::string &_type,\n const std::string &_contested_name,\n const std::set &_contestants) :\n type(_type), contested_name(_contested_name), contestants(_contestants) { }\n\nstd::string name_conflict_issue_t::get_description() const {\n std::string message = \"The following \" + type + \"s are all named '\" + contested_name + \"': \";\n for (std::set::iterator it = contestants.begin(); it != contestants.end(); it++) {\n message += uuid_to_str(*it) + \"; \";\n }\n return message;\n}\n\ncJSON *name_conflict_issue_t::get_json_description() {\n issue_json_t json;\n json.critical = false;\n json.description = \"The following \" + type + \"s are all named '\" + contested_name + \"': \";\n for (std::set::iterator it = contestants.begin(); it != contestants.end(); it++) {\n json.description += uuid_to_str(*it) + \"; \";\n }\n json.type = \"NAME_CONFLICT_ISSUE\";\n json.time = get_secs();\n\n cJSON *res = render_as_json(&json);\n\n cJSON_AddItemToObject(res, \"contested_type\", render_as_json(&type));\n cJSON_AddItemToObject(res, \"contested_name\", render_as_json(&contested_name));\n cJSON_AddItemToObject(res, \"contestants\", render_as_json(&contestants));\n\n return res;\n}\n\nname_conflict_issue_t *name_conflict_issue_t::clone() const {\n return new name_conflict_issue_t(type, contested_name, contestants);\n}\n\nclass name_map_t {\npublic:\n template\n void file_away(const std::map > &map) {\n for (typename std::map >::const_iterator it = map.begin();\n it != map.end(); it++) {\n if (!it->second.is_deleted()) {\n if (!it->second.get().name.in_conflict()) {\n by_name[it->second.get().name.get()].insert(it->first);\n }\n }\n }\n }\n\n void report(const std::string &type,\n std::list > *out) {\n for (std::map, case_insensitive_less_t>::iterator it =\n by_name.begin(); it != by_name.end(); it++) {\n if (it->second.size() > 1) {\n out->push_back(clone_ptr_t(\n new name_conflict_issue_t(type, it->first, it->second)));\n }\n }\n }\n\nprivate:\n class case_insensitive_less_t : public std::binary_function {\n public:\n bool operator()(const std::string &a, const std::string &b) {\n return strcasecmp(a.c_str(), b.c_str()) < 0;\n }\n };\n\n std::map, case_insensitive_less_t> by_name;\n};\n\nclass namespace_map_t {\npublic:\nnamespace_map_t(const std::map > &_databases)\n : databases(_databases)\n{ }\n template\n void file_away(const std::map > &map) {\n for (typename std::map >::const_iterator it = map.begin();\n it != map.end(); it++) {\n if (!it->second.is_deleted()) {\n if (!it->second.get().name.in_conflict() &&\n !it->second.get().database.in_conflict()) {\n if (std_contains(databases, it->second.get().database.get())) {\n deletable_t db = databases[it->second.get().database.get()];\n if (!db.is_deleted() && !db.get().name.in_conflict()) {\n by_name[db.get().name.get() + \".\" + it->second.get().name.get()].insert(it->first);\n }\n }\n }\n }\n }\n }\n\n void report(const std::string &type,\n std::list > *out) {\n for (std::map, case_insensitive_less_t>::iterator it =\n by_name.begin(); it != by_name.end(); it++) {\n if (it->second.size() > 1) {\n out->push_back(clone_ptr_t(\n new name_conflict_issue_t(type, it->first, it->second)));\n }\n }\n }\n\nprivate:\n class case_insensitive_less_t : public std::binary_function {\n public:\n bool operator()(const std::string &a, const std::string &b) {\n return strcasecmp(a.c_str(), b.c_str()) < 0;\n }\n };\n\n std::map, case_insensitive_less_t> by_name;\n std::map > databases;\n};\n\nname_conflict_issue_tracker_t::name_conflict_issue_tracker_t(boost::shared_ptr > _semilattice_view)\n : semilattice_view(_semilattice_view) { }\n\nname_conflict_issue_tracker_t::~name_conflict_issue_tracker_t() { }\n\nstd::list > name_conflict_issue_tracker_t::get_issues() {\n cluster_semilattice_metadata_t metadata = semilattice_view->get();\n\n std::list > issues;\n\n namespace_map_t namespaces(metadata.databases.databases);\n namespaces.file_away(metadata.rdb_namespaces->namespaces);\n namespaces.file_away(metadata.dummy_namespaces->namespaces);\n namespaces.file_away(metadata.memcached_namespaces->namespaces);\n namespaces.report(\"table\", &issues);\n\n name_map_t datacenters;\n datacenters.file_away(metadata.datacenters.datacenters);\n datacenters.report(\"datacenter\", &issues);\n\n name_map_t machines;\n machines.file_away(metadata.machines.machines);\n machines.report(\"machine\", &issues);\n\n name_map_t databases;\n databases.file_away(metadata.databases.databases);\n databases.report(\"databases\", &issues);\n\n return issues;\n}\n<|endoftext|>"} {"text":"#include \"gpcheckcloud.h\"\n\nbool hasHeader;\n\nchar eolString[EOL_CHARS_MAX_LEN + 1] = \"\\n\"; \/\/ LF by default\n\nstring s3extErrorMessage;\n\nvolatile sig_atomic_t QueryCancelPending = false;\n\nstatic bool uploadS3(const char *urlWithOptions, const char *fileToUpload);\nstatic bool downloadS3(const char *urlWithOptions);\nstatic bool checkConfig(const char *urlWithOptions);\nstatic void printBucketContents(const ListBucketResult &result);\nstatic void printTemplate();\nstatic void validateCommandLineArgs(map &optionPairs);\nstatic map parseCommandLineArgs(int argc, char *argv[]);\nstatic void registerSignalHandler();\nstatic void printUsage(FILE *stream);\n\n\/\/ As we can't catch 'IsAbortInProgress()' in UT, so here consider QueryCancelPending only\nbool S3QueryIsAbortInProgress(void) {\n return QueryCancelPending;\n}\n\nvoid MaskThreadSignals() {\n}\n\nvoid *S3Alloc(size_t size) {\n return malloc(size);\n}\n\nvoid S3Free(void *p) {\n free(p);\n}\n\nstatic void handleAbortSignal(int signum) {\n fprintf(stderr, \"Interrupted by user (%s), exiting...\\n\\n\", strsignal(signum));\n QueryCancelPending = true;\n}\n\nstatic void registerSignalHandler() {\n signal(SIGHUP, handleAbortSignal);\n signal(SIGABRT, handleAbortSignal);\n signal(SIGTERM, handleAbortSignal);\n signal(SIGINT, handleAbortSignal);\n signal(SIGTSTP, handleAbortSignal);\n}\n\nstatic void printUsage(FILE *stream) {\n fprintf(stream,\n \"Usage: gpcheckcloud -c \\\"s3:\/\/endpoint\/bucket\/prefix \"\n \"config=path_to_config_file [region=region_name]\\\", to check the configuration.\\n\"\n \" gpcheckcloud -d \\\"s3:\/\/endpoint\/bucket\/prefix \"\n \"config=path_to_config_file [region=region_name]\\\", to download and output to stdout.\\n\"\n \" gpcheckcloud -u \\\"\/path\/to\/file\\\" \\\"s3:\/\/endpoint\/bucket\/prefix \"\n \"config=path_to_config_file [region=region_name]\\\", to upload a file.\\n\"\n \" gpcheckcloud -t, to show the config template.\\n\"\n \" gpcheckcloud -h, to show this help.\\n\");\n}\n\n\/\/ parse the arguments into char-string value pairs\nstatic map parseCommandLineArgs(int argc, char *argv[]) {\n int opt = 0;\n map optionPairs;\n\n while ((opt = getopt(argc, argv, \"c:d:u:ht\")) != -1) {\n switch (opt) {\n case 'c':\n case 'd':\n case 'h':\n case 't':\n if (optarg == NULL) {\n optionPairs[opt] = \"\";\n } else if (optarg[0] == '-') {\n fprintf(stderr, \"Failed. Invalid argument for -%c: '%s'.\\n\\n\", opt, optarg);\n printUsage(stderr);\n exit(EXIT_FAILURE);\n } else {\n optionPairs[opt] = optarg;\n }\n\n break;\n case 'u':\n if (optarg == NULL) {\n optionPairs[opt] = \"\";\n } else if (optind + 1 == argc) { \/\/ has two option values\n optionPairs['f'] = optarg; \/\/ value of option file\n optionPairs['u'] = argv[optind]; \/\/ value of option url\n } else {\n fprintf(stderr, \"Failed. Invalid arguments for -u, please check.\\n\\n\");\n printUsage(stderr);\n exit(EXIT_FAILURE);\n }\n break;\n\n default: \/\/ '?'\n printUsage(stderr);\n exit(EXIT_FAILURE);\n }\n }\n\n return optionPairs;\n}\n\n\/\/ check if command line arguments are valid\nstatic void validateCommandLineArgs(map &optionPairs) {\n uint64_t count = optionPairs.count('f') + optionPairs.count('u');\n\n if ((count == 2) && (optionPairs.size() == 2)) {\n return;\n } else if (count == 1) {\n fprintf(stderr, \"Failed. Option \\'-u\\' must work with \\'-f\\'.\\n\\n\");\n printUsage(stderr);\n exit(EXIT_FAILURE);\n }\n\n if (optionPairs.size() > 1) {\n stringstream ss;\n\n ss << \"Failed. Can't set options \";\n\n \/\/ concatenate all option names\n \/\/ e.g. if we have -c and -d, insert \"-c, -d\" into the stream.\n for (map::iterator i = optionPairs.begin(); i != optionPairs.end(); i++) {\n ss << \"'-\" << i->first << \"' \";\n }\n\n ss << \"at the same time.\";\n\n \/\/ example message: \"Failed. Can't set options '-c' '-d' at the same time.\"\n fprintf(stderr, \"%s\\n\\n\", ss.str().c_str());\n printUsage(stderr);\n exit(EXIT_FAILURE);\n }\n}\n\nstatic void printTemplate() {\n printf(\n \"[default]\\n\"\n \"secret = \\\"aws secret\\\"\\n\"\n \"accessid = \\\"aws access id\\\"\\n\"\n \"threadnum = 4\\n\"\n \"chunksize = 67108864\\n\"\n \"low_speed_limit = 10240\\n\"\n \"low_speed_time = 60\\n\"\n \"encryption = true\\n\"\n \"version = 1\\n\"\n \"proxy = \\\"\\\"\\n\"\n \"autocompress = true\\n\"\n \"verifycert = true\\n\"\n \"server_side_encryption = \\\"\\\"\\n\"\n \"# gpcheckcloud config\\n\"\n \"gpcheckcloud_newline = \\\"\\\\n\\\"\\n\");\n}\n\nstatic void printBucketContents(const ListBucketResult &result) {\n char urlbuf[256];\n vector::const_iterator i;\n\n for (i = result.contents.begin(); i != result.contents.end(); i++) {\n snprintf(urlbuf, 256, \"%s\", i->getName().c_str());\n printf(\"File: %s, Size: %\" PRIu64 \"\\n\", urlbuf, i->getSize());\n }\n}\n\nstatic bool checkConfig(const char *urlWithOptions) {\n if (!urlWithOptions) {\n return false;\n }\n\n GPReader *reader = reader_init(urlWithOptions);\n if (!reader) {\n return false;\n }\n\n ListBucketResult result = reader->getKeyList();\n\n if (result.contents.empty()) {\n fprintf(stderr,\n \"\\nYour configuration works well, however there is no file matching your \"\n \"prefix.\\n\");\n } else {\n printBucketContents(result);\n fprintf(stderr, \"\\nYour configuration works well.\\n\");\n }\n\n reader_cleanup(&reader);\n\n return true;\n}\n\nstatic bool downloadS3(const char *urlWithOptions) {\n if (!urlWithOptions) {\n return false;\n }\n\n int data_len = BUF_SIZE;\n char data_buf[BUF_SIZE];\n bool ret = true;\n\n thread_setup();\n\n GPReader *reader = reader_init(urlWithOptions);\n if (!reader) {\n return false;\n }\n\n strncpy(eolString, reader->getParams().getGpcheckcloud_newline().c_str(), EOL_CHARS_MAX_LEN);\n eolString[EOL_CHARS_MAX_LEN] = '\\0';\n\n do {\n data_len = BUF_SIZE;\n\n if (!reader_transfer_data(reader, data_buf, data_len)) {\n fprintf(stderr, \"Failed to read data from Amazon S3\\n\");\n ret = false;\n break;\n }\n\n fwrite(data_buf, (size_t)data_len, 1, stdout);\n } while (data_len && !S3QueryIsAbortInProgress());\n\n reader_cleanup(&reader);\n\n thread_cleanup();\n\n return ret;\n}\n\nstatic bool uploadS3(const char *urlWithOptions, const char *fileToUpload) {\n if (!urlWithOptions) {\n return false;\n }\n\n size_t data_len = BUF_SIZE;\n char data_buf[BUF_SIZE];\n size_t read_len = 0;\n bool ret = true;\n\n thread_setup();\n\n GPWriter *writer = writer_init(urlWithOptions);\n if (!writer) {\n return false;\n }\n\n FILE *fd = fopen(fileToUpload, \"r\");\n if (fd == NULL) {\n fprintf(stderr, \"File does not exist\\n\");\n ret = false;\n } else {\n do {\n read_len = fread(data_buf, 1, data_len, fd);\n\n if (read_len == 0) {\n break;\n }\n\n if (!writer_transfer_data(writer, data_buf, (int)read_len)) {\n fprintf(stderr, \"Failed to write data to Amazon S3\\n\");\n ret = false;\n break;\n }\n } while (read_len == data_len && !S3QueryIsAbortInProgress());\n\n if (ferror(fd)) {\n ret = false;\n }\n\n fclose(fd);\n }\n\n writer_cleanup(&writer);\n\n thread_cleanup();\n\n return ret;\n}\n\nint main(int argc, char *argv[]) {\n bool ret = true;\n\n s3ext_loglevel = EXT_ERROR;\n s3ext_logtype = STDERR_LOG;\n\n if (argc == 1) {\n printUsage(stderr);\n exit(EXIT_FAILURE);\n }\n\n \/* Prepare to receive interrupts *\/\n registerSignalHandler();\n\n map optionPairs = parseCommandLineArgs(argc, argv);\n\n validateCommandLineArgs(optionPairs);\n\n if (!optionPairs.empty()) {\n const char *arg = optionPairs.begin()->second.c_str();\n\n switch (optionPairs.begin()->first) {\n case 'c':\n ret = checkConfig(arg);\n break;\n case 'd':\n ret = downloadS3(arg);\n break;\n case 'u':\n case 'f':\n ret = uploadS3(optionPairs['u'].c_str(), optionPairs['f'].c_str());\n break;\n case 'h':\n printUsage(stdout);\n break;\n case 't':\n printTemplate();\n break;\n default:\n printUsage(stderr);\n exit(EXIT_FAILURE);\n }\n }\n\n \/\/ Abort should not print the failed info\n if (ret || S3QueryIsAbortInProgress()) {\n exit(EXIT_SUCCESS);\n } else {\n fprintf(stderr, \"Failed. Please check the arguments and configuration file.\\n\\n\");\n printUsage(stderr);\n exit(EXIT_FAILURE);\n }\n}\nAdjust seq of accessid and secret in gpcheckcloud template example. #include \"gpcheckcloud.h\"\n\nbool hasHeader;\n\nchar eolString[EOL_CHARS_MAX_LEN + 1] = \"\\n\"; \/\/ LF by default\n\nstring s3extErrorMessage;\n\nvolatile sig_atomic_t QueryCancelPending = false;\n\nstatic bool uploadS3(const char *urlWithOptions, const char *fileToUpload);\nstatic bool downloadS3(const char *urlWithOptions);\nstatic bool checkConfig(const char *urlWithOptions);\nstatic void printBucketContents(const ListBucketResult &result);\nstatic void printTemplate();\nstatic void validateCommandLineArgs(map &optionPairs);\nstatic map parseCommandLineArgs(int argc, char *argv[]);\nstatic void registerSignalHandler();\nstatic void printUsage(FILE *stream);\n\n\/\/ As we can't catch 'IsAbortInProgress()' in UT, so here consider QueryCancelPending only\nbool S3QueryIsAbortInProgress(void) {\n return QueryCancelPending;\n}\n\nvoid MaskThreadSignals() {\n}\n\nvoid *S3Alloc(size_t size) {\n return malloc(size);\n}\n\nvoid S3Free(void *p) {\n free(p);\n}\n\nstatic void handleAbortSignal(int signum) {\n fprintf(stderr, \"Interrupted by user (%s), exiting...\\n\\n\", strsignal(signum));\n QueryCancelPending = true;\n}\n\nstatic void registerSignalHandler() {\n signal(SIGHUP, handleAbortSignal);\n signal(SIGABRT, handleAbortSignal);\n signal(SIGTERM, handleAbortSignal);\n signal(SIGINT, handleAbortSignal);\n signal(SIGTSTP, handleAbortSignal);\n}\n\nstatic void printUsage(FILE *stream) {\n fprintf(stream,\n \"Usage: gpcheckcloud -c \\\"s3:\/\/endpoint\/bucket\/prefix \"\n \"config=path_to_config_file [region=region_name]\\\", to check the configuration.\\n\"\n \" gpcheckcloud -d \\\"s3:\/\/endpoint\/bucket\/prefix \"\n \"config=path_to_config_file [region=region_name]\\\", to download and output to stdout.\\n\"\n \" gpcheckcloud -u \\\"\/path\/to\/file\\\" \\\"s3:\/\/endpoint\/bucket\/prefix \"\n \"config=path_to_config_file [region=region_name]\\\", to upload a file.\\n\"\n \" gpcheckcloud -t, to show the config template.\\n\"\n \" gpcheckcloud -h, to show this help.\\n\");\n}\n\n\/\/ parse the arguments into char-string value pairs\nstatic map parseCommandLineArgs(int argc, char *argv[]) {\n int opt = 0;\n map optionPairs;\n\n while ((opt = getopt(argc, argv, \"c:d:u:ht\")) != -1) {\n switch (opt) {\n case 'c':\n case 'd':\n case 'h':\n case 't':\n if (optarg == NULL) {\n optionPairs[opt] = \"\";\n } else if (optarg[0] == '-') {\n fprintf(stderr, \"Failed. Invalid argument for -%c: '%s'.\\n\\n\", opt, optarg);\n printUsage(stderr);\n exit(EXIT_FAILURE);\n } else {\n optionPairs[opt] = optarg;\n }\n\n break;\n case 'u':\n if (optarg == NULL) {\n optionPairs[opt] = \"\";\n } else if (optind + 1 == argc) { \/\/ has two option values\n optionPairs['f'] = optarg; \/\/ value of option file\n optionPairs['u'] = argv[optind]; \/\/ value of option url\n } else {\n fprintf(stderr, \"Failed. Invalid arguments for -u, please check.\\n\\n\");\n printUsage(stderr);\n exit(EXIT_FAILURE);\n }\n break;\n\n default: \/\/ '?'\n printUsage(stderr);\n exit(EXIT_FAILURE);\n }\n }\n\n return optionPairs;\n}\n\n\/\/ check if command line arguments are valid\nstatic void validateCommandLineArgs(map &optionPairs) {\n uint64_t count = optionPairs.count('f') + optionPairs.count('u');\n\n if ((count == 2) && (optionPairs.size() == 2)) {\n return;\n } else if (count == 1) {\n fprintf(stderr, \"Failed. Option \\'-u\\' must work with \\'-f\\'.\\n\\n\");\n printUsage(stderr);\n exit(EXIT_FAILURE);\n }\n\n if (optionPairs.size() > 1) {\n stringstream ss;\n\n ss << \"Failed. Can't set options \";\n\n \/\/ concatenate all option names\n \/\/ e.g. if we have -c and -d, insert \"-c, -d\" into the stream.\n for (map::iterator i = optionPairs.begin(); i != optionPairs.end(); i++) {\n ss << \"'-\" << i->first << \"' \";\n }\n\n ss << \"at the same time.\";\n\n \/\/ example message: \"Failed. Can't set options '-c' '-d' at the same time.\"\n fprintf(stderr, \"%s\\n\\n\", ss.str().c_str());\n printUsage(stderr);\n exit(EXIT_FAILURE);\n }\n}\n\nstatic void printTemplate() {\n printf(\n \"[default]\\n\"\n \"accessid = \\\"aws access id\\\"\\n\"\n \"secret = \\\"aws secret\\\"\\n\"\n \"threadnum = 4\\n\"\n \"chunksize = 67108864\\n\"\n \"low_speed_limit = 10240\\n\"\n \"low_speed_time = 60\\n\"\n \"encryption = true\\n\"\n \"version = 1\\n\"\n \"proxy = \\\"\\\"\\n\"\n \"autocompress = true\\n\"\n \"verifycert = true\\n\"\n \"server_side_encryption = \\\"\\\"\\n\"\n \"# gpcheckcloud config\\n\"\n \"gpcheckcloud_newline = \\\"\\\\n\\\"\\n\");\n}\n\nstatic void printBucketContents(const ListBucketResult &result) {\n char urlbuf[256];\n vector::const_iterator i;\n\n for (i = result.contents.begin(); i != result.contents.end(); i++) {\n snprintf(urlbuf, 256, \"%s\", i->getName().c_str());\n printf(\"File: %s, Size: %\" PRIu64 \"\\n\", urlbuf, i->getSize());\n }\n}\n\nstatic bool checkConfig(const char *urlWithOptions) {\n if (!urlWithOptions) {\n return false;\n }\n\n GPReader *reader = reader_init(urlWithOptions);\n if (!reader) {\n return false;\n }\n\n ListBucketResult result = reader->getKeyList();\n\n if (result.contents.empty()) {\n fprintf(stderr,\n \"\\nYour configuration works well, however there is no file matching your \"\n \"prefix.\\n\");\n } else {\n printBucketContents(result);\n fprintf(stderr, \"\\nYour configuration works well.\\n\");\n }\n\n reader_cleanup(&reader);\n\n return true;\n}\n\nstatic bool downloadS3(const char *urlWithOptions) {\n if (!urlWithOptions) {\n return false;\n }\n\n int data_len = BUF_SIZE;\n char data_buf[BUF_SIZE];\n bool ret = true;\n\n thread_setup();\n\n GPReader *reader = reader_init(urlWithOptions);\n if (!reader) {\n return false;\n }\n\n strncpy(eolString, reader->getParams().getGpcheckcloud_newline().c_str(), EOL_CHARS_MAX_LEN);\n eolString[EOL_CHARS_MAX_LEN] = '\\0';\n\n do {\n data_len = BUF_SIZE;\n\n if (!reader_transfer_data(reader, data_buf, data_len)) {\n fprintf(stderr, \"Failed to read data from Amazon S3\\n\");\n ret = false;\n break;\n }\n\n fwrite(data_buf, (size_t)data_len, 1, stdout);\n } while (data_len && !S3QueryIsAbortInProgress());\n\n reader_cleanup(&reader);\n\n thread_cleanup();\n\n return ret;\n}\n\nstatic bool uploadS3(const char *urlWithOptions, const char *fileToUpload) {\n if (!urlWithOptions) {\n return false;\n }\n\n size_t data_len = BUF_SIZE;\n char data_buf[BUF_SIZE];\n size_t read_len = 0;\n bool ret = true;\n\n thread_setup();\n\n GPWriter *writer = writer_init(urlWithOptions);\n if (!writer) {\n return false;\n }\n\n FILE *fd = fopen(fileToUpload, \"r\");\n if (fd == NULL) {\n fprintf(stderr, \"File does not exist\\n\");\n ret = false;\n } else {\n do {\n read_len = fread(data_buf, 1, data_len, fd);\n\n if (read_len == 0) {\n break;\n }\n\n if (!writer_transfer_data(writer, data_buf, (int)read_len)) {\n fprintf(stderr, \"Failed to write data to Amazon S3\\n\");\n ret = false;\n break;\n }\n } while (read_len == data_len && !S3QueryIsAbortInProgress());\n\n if (ferror(fd)) {\n ret = false;\n }\n\n fclose(fd);\n }\n\n writer_cleanup(&writer);\n\n thread_cleanup();\n\n return ret;\n}\n\nint main(int argc, char *argv[]) {\n bool ret = true;\n\n s3ext_loglevel = EXT_ERROR;\n s3ext_logtype = STDERR_LOG;\n\n if (argc == 1) {\n printUsage(stderr);\n exit(EXIT_FAILURE);\n }\n\n \/* Prepare to receive interrupts *\/\n registerSignalHandler();\n\n map optionPairs = parseCommandLineArgs(argc, argv);\n\n validateCommandLineArgs(optionPairs);\n\n if (!optionPairs.empty()) {\n const char *arg = optionPairs.begin()->second.c_str();\n\n switch (optionPairs.begin()->first) {\n case 'c':\n ret = checkConfig(arg);\n break;\n case 'd':\n ret = downloadS3(arg);\n break;\n case 'u':\n case 'f':\n ret = uploadS3(optionPairs['u'].c_str(), optionPairs['f'].c_str());\n break;\n case 'h':\n printUsage(stdout);\n break;\n case 't':\n printTemplate();\n break;\n default:\n printUsage(stderr);\n exit(EXIT_FAILURE);\n }\n }\n\n \/\/ Abort should not print the failed info\n if (ret || S3QueryIsAbortInProgress()) {\n exit(EXIT_SUCCESS);\n } else {\n fprintf(stderr, \"Failed. Please check the arguments and configuration file.\\n\\n\");\n printUsage(stderr);\n exit(EXIT_FAILURE);\n }\n}\n<|endoftext|>"} {"text":"\/\/ Copyright (c) 2018 Michael C. Heiber\n\/\/ This source file is part of the KMC_Lattice project, which is subject to the MIT License.\n\/\/ For more information, see the LICENSE file that accompanies this software.\n\/\/ The KMC_Lattice project can be found on Github at https:\/\/github.com\/MikeHeiber\/KMC_Lattice\n\n#include \"Object.h\"\n\nusing namespace std;\n\nconst string Object::object_type_base = \"Object\";\n\nObject::~Object(){\n \/\/dtor\n}\n\nObject::Object(){\n\n}\n\nObject::Object(const double time,const int tag_num,const Coords& start_coords){\n time_created = time;\n tag = tag_num;\n coords_current = start_coords;\n coords_initial = start_coords;\n}\n\ndouble Object::calculateDisplacement() const{\n return sqrt((double)(coords_current.x+dx-coords_initial.x)*(coords_current.x+dx-coords_initial.x)+(coords_current.y+dy-coords_initial.y)*(coords_current.y+dy-coords_initial.y)+(coords_current.z+dz-coords_initial.z)*(coords_current.z+dz-coords_initial.z));\n}\n\nCoords Object::getCoords() const{\n return coords_current;\n}\n\ndouble Object::getCreationTime() const{\n return time_created;\n}\n\nlist::iterator Object::getEventIt() const{\n return event_it;\n}\n\nstring Object::getObjectType() const{\n return object_type_base;\n}\n\nint Object::getTag() const{\n return tag;\n}\n\nvoid Object::incrementDX(const int num){\n dx += num;\n}\n\nvoid Object::incrementDY(const int num){\n dy += num;\n}\n\nvoid Object::incrementDZ(const int num){\n dz += num;\n}\n\nvoid Object::resetInitialCoords(const Coords& input_coords) {\n\tcoords_initial = input_coords;\n\tdx = 0;\n\tdy = 0;\n\tdz = 0;\n}\n\nvoid Object::setCoords(const Coords& input_coords){\n coords_current = input_coords;\n}\n\nvoid Object::setEventIt(const list::iterator input_it){\n event_it = input_it;\n}\n\nObject Class Update\/\/ Copyright (c) 2018 Michael C. Heiber\n\/\/ This source file is part of the KMC_Lattice project, which is subject to the MIT License.\n\/\/ For more information, see the LICENSE file that accompanies this software.\n\/\/ The KMC_Lattice project can be found on Github at https:\/\/github.com\/MikeHeiber\/KMC_Lattice\n\n#include \"Object.h\"\n\nusing namespace std;\n\nconst string Object::object_type_base = \"Object\";\n\nObject::~Object(){\n \/\/dtor\n}\n\nObject::Object(){\n\n}\n\nObject::Object(const double time,const int tag_num,const Coords& start_coords){\n time_created = time;\n tag = tag_num;\n coords_current = start_coords;\n coords_initial = start_coords;\n}\n\ndouble Object::calculateDisplacement() const{\n return sqrt((coords_current.x+dx-coords_initial.x)*(coords_current.x+dx-coords_initial.x)+(coords_current.y+dy-coords_initial.y)*(coords_current.y+dy-coords_initial.y)+(coords_current.z+dz-coords_initial.z)*(coords_current.z+dz-coords_initial.z));\n}\n\nCoords Object::getCoords() const{\n return coords_current;\n}\n\ndouble Object::getCreationTime() const{\n return time_created;\n}\n\nlist::iterator Object::getEventIt() const{\n return event_it;\n}\n\nstring Object::getObjectType() const{\n return object_type_base;\n}\n\nint Object::getTag() const{\n return tag;\n}\n\nvoid Object::incrementDX(const int num){\n dx += num;\n}\n\nvoid Object::incrementDY(const int num){\n dy += num;\n}\n\nvoid Object::incrementDZ(const int num){\n dz += num;\n}\n\nvoid Object::resetInitialCoords(const Coords& input_coords) {\n\tcoords_initial = input_coords;\n\tdx = 0;\n\tdy = 0;\n\tdz = 0;\n}\n\nvoid Object::setCoords(const Coords& input_coords){\n coords_current = input_coords;\n}\n\nvoid Object::setEventIt(const list::iterator input_it){\n event_it = input_it;\n}\n\n<|endoftext|>"} {"text":"\/\/ Copyright (c) 2011 The Chromium Authors. All rights reserved.\n\/\/ Use of this source code is governed by a BSD-style license that can be\n\/\/ found in the LICENSE file.\n\n#include \"ppapi\/c\/pp_errors.h\"\n#include \"ppapi\/thunk\/thunk.h\"\n#include \"ppapi\/thunk\/enter.h\"\n#include \"ppapi\/thunk\/ppb_input_event_api.h\"\n#include \"ppapi\/thunk\/ppb_instance_api.h\"\n#include \"ppapi\/thunk\/resource_creation_api.h\"\n\nnamespace ppapi {\nnamespace thunk {\n\nnamespace {\n\ntypedef EnterFunction EnterInstance;\ntypedef EnterResource EnterInputEvent;\n\n\/\/ InputEvent ------------------------------------------------------------------\n\nint32_t RequestInputEvents(PP_Instance instance, uint32_t event_classes) {\n EnterInstance enter(instance, true);\n if (enter.failed())\n return PP_ERROR_BADARGUMENT;\n return enter.functions()->RequestInputEvents(instance, event_classes);\n}\n\nint32_t RequestFilteringInputEvents(PP_Instance instance,\n uint32_t event_classes) {\n EnterInstance enter(instance, true);\n if (enter.failed())\n return PP_ERROR_BADARGUMENT;\n return enter.functions()->RequestFilteringInputEvents(instance,\n event_classes);\n}\n\nvoid ClearInputEventRequest(PP_Instance instance,\n uint32_t event_classes) {\n EnterInstance enter(instance, true);\n if (enter.succeeded())\n enter.functions()->ClearInputEventRequest(instance, event_classes);\n}\n\nPP_Bool IsInputEvent(PP_Resource resource) {\n EnterInputEvent enter(resource, false);\n return enter.succeeded() ? PP_TRUE : PP_FALSE;\n}\n\nPP_InputEvent_Type GetType(PP_Resource event) {\n EnterInputEvent enter(event, true);\n if (enter.failed())\n return PP_INPUTEVENT_TYPE_UNDEFINED;\n return enter.object()->GetType();\n}\n\nPP_TimeTicks GetTimeStamp(PP_Resource event) {\n EnterInputEvent enter(event, true);\n if (enter.failed())\n return 0.0;\n return enter.object()->GetTimeStamp();\n}\n\nuint32_t GetModifiers(PP_Resource event) {\n EnterInputEvent enter(event, true);\n if (enter.failed())\n return 0;\n return enter.object()->GetModifiers();\n}\n\nconst PPB_InputEvent g_ppb_input_event_thunk = {\n &RequestInputEvents,\n &RequestFilteringInputEvents,\n &ClearInputEventRequest,\n &IsInputEvent,\n &GetType,\n &GetTimeStamp,\n &GetModifiers\n};\n\n\/\/ Mouse -----------------------------------------------------------------------\n\nPP_Resource CreateMouseInputEvent(PP_Instance instance,\n PP_InputEvent_Type type,\n PP_TimeTicks time_stamp,\n uint32_t modifiers,\n PP_InputEvent_MouseButton mouse_button,\n const PP_Point* mouse_position,\n int32_t click_count) {\n EnterFunction enter(instance, true);\n if (enter.failed())\n return 0;\n return enter.functions()->CreateMouseInputEvent(instance, type, time_stamp,\n modifiers, mouse_button,\n mouse_position, click_count);\n}\n\nPP_Bool IsMouseInputEvent(PP_Resource resource) {\n if (!IsInputEvent(resource))\n return PP_FALSE; \/\/ Prevent warning log in GetType.\n PP_InputEvent_Type type = GetType(resource);\n return PP_FromBool(type == PP_INPUTEVENT_TYPE_MOUSEDOWN ||\n type == PP_INPUTEVENT_TYPE_MOUSEUP ||\n type == PP_INPUTEVENT_TYPE_MOUSEMOVE ||\n type == PP_INPUTEVENT_TYPE_MOUSEENTER ||\n type == PP_INPUTEVENT_TYPE_MOUSELEAVE ||\n type == PP_INPUTEVENT_TYPE_CONTEXTMENU);\n}\n\nPP_InputEvent_MouseButton GetMouseButton(PP_Resource mouse_event) {\n EnterInputEvent enter(mouse_event, true);\n if (enter.failed())\n return PP_INPUTEVENT_MOUSEBUTTON_NONE;\n return enter.object()->GetMouseButton();\n}\n\nPP_Point GetMousePosition(PP_Resource mouse_event) {\n EnterInputEvent enter(mouse_event, true);\n if (enter.failed())\n return PP_MakePoint(0, 0);\n return enter.object()->GetMousePosition();\n}\n\nint32_t GetMouseClickCount(PP_Resource mouse_event) {\n EnterInputEvent enter(mouse_event, true);\n if (enter.failed())\n return 0;\n return enter.object()->GetMouseClickCount();\n}\n\nconst PPB_MouseInputEvent g_ppb_mouse_input_event_thunk = {\n &CreateMouseInputEvent,\n &IsMouseInputEvent,\n &GetMouseButton,\n &GetMousePosition,\n &GetMouseClickCount\n};\n\n\/\/ Wheel -----------------------------------------------------------------------\n\nPP_Resource CreateWheelInputEvent(PP_Instance instance,\n PP_TimeTicks time_stamp,\n uint32_t modifiers,\n const PP_FloatPoint* wheel_delta,\n const PP_FloatPoint* wheel_ticks,\n PP_Bool scroll_by_page) {\n EnterFunction enter(instance, true);\n if (enter.failed())\n return 0;\n return enter.functions()->CreateWheelInputEvent(instance, time_stamp,\n modifiers, wheel_delta,\n wheel_ticks, scroll_by_page);\n}\n\nPP_Bool IsWheelInputEvent(PP_Resource resource) {\n if (!IsInputEvent(resource))\n return PP_FALSE; \/\/ Prevent warning log in GetType.\n PP_InputEvent_Type type = GetType(resource);\n return PP_FromBool(type == PP_INPUTEVENT_TYPE_WHEEL);\n}\n\nPP_FloatPoint GetWheelDelta(PP_Resource wheel_event) {\n EnterInputEvent enter(wheel_event, true);\n if (enter.failed())\n return PP_MakeFloatPoint(0.0f, 0.0f);\n return enter.object()->GetWheelDelta();\n}\n\nPP_FloatPoint GetWheelTicks(PP_Resource wheel_event) {\n EnterInputEvent enter(wheel_event, true);\n if (enter.failed())\n return PP_MakeFloatPoint(0.0f, 0.0f);\n return enter.object()->GetWheelTicks();\n}\n\nPP_Bool GetWheelScrollByPage(PP_Resource wheel_event) {\n EnterInputEvent enter(wheel_event, true);\n if (enter.failed())\n return PP_FALSE;\n return enter.object()->GetWheelScrollByPage();\n}\n\nconst PPB_WheelInputEvent g_ppb_wheel_input_event_thunk = {\n &CreateWheelInputEvent,\n &IsWheelInputEvent,\n &GetWheelDelta,\n &GetWheelTicks,\n &GetWheelScrollByPage\n};\n\n\/\/ Keyboard --------------------------------------------------------------------\n\nPP_Resource CreateKeyboardInputEvent(PP_Instance instance,\n PP_InputEvent_Type type,\n PP_TimeTicks time_stamp,\n uint32_t modifiers,\n uint32_t key_code,\n struct PP_Var character_text) {\n EnterFunction enter(instance, true);\n if (enter.failed())\n return 0;\n return enter.functions()->CreateKeyboardInputEvent(instance, type, time_stamp,\n modifiers, key_code,\n character_text);\n}\n\nPP_Bool IsKeyboardInputEvent(PP_Resource resource) {\n if (!IsInputEvent(resource))\n return PP_FALSE; \/\/ Prevent warning log in GetType.\n PP_InputEvent_Type type = GetType(resource);\n return PP_FromBool(type == PP_INPUTEVENT_TYPE_KEYDOWN ||\n type == PP_INPUTEVENT_TYPE_KEYUP ||\n type == PP_INPUTEVENT_TYPE_CHAR);\n}\n\nuint32_t GetKeyCode(PP_Resource key_event) {\n EnterInputEvent enter(key_event, true);\n if (enter.failed())\n return 0;\n return enter.object()->GetKeyCode();\n}\n\nPP_Var GetCharacterText(PP_Resource character_event) {\n EnterInputEvent enter(character_event, true);\n if (enter.failed())\n return PP_MakeUndefined();\n return enter.object()->GetCharacterText();\n}\n\nconst PPB_KeyboardInputEvent g_ppb_keyboard_input_event_thunk = {\n &CreateKeyboardInputEvent,\n &IsKeyboardInputEvent,\n &GetKeyCode,\n &GetCharacterText\n};\n\n} \/\/ namespace\n\nconst PPB_InputEvent* GetPPB_InputEvent_Thunk() {\n return &g_ppb_input_event_thunk;\n}\n\nconst PPB_MouseInputEvent* GetPPB_MouseInputEvent_Thunk() {\n return &g_ppb_mouse_input_event_thunk;\n}\n\nconst PPB_KeyboardInputEvent* GetPPB_KeyboardInputEvent_Thunk() {\n return &g_ppb_keyboard_input_event_thunk;\n}\n\nconst PPB_WheelInputEvent* GetPPB_WheelInputEvent_Thunk() {\n return &g_ppb_wheel_input_event_thunk;\n}\n\n} \/\/ namespace thunk\n} \/\/ namespace ppapi\nFix raw key down events in Pepper.\/\/ Copyright (c) 2011 The Chromium Authors. All rights reserved.\n\/\/ Use of this source code is governed by a BSD-style license that can be\n\/\/ found in the LICENSE file.\n\n#include \"ppapi\/c\/pp_errors.h\"\n#include \"ppapi\/thunk\/thunk.h\"\n#include \"ppapi\/thunk\/enter.h\"\n#include \"ppapi\/thunk\/ppb_input_event_api.h\"\n#include \"ppapi\/thunk\/ppb_instance_api.h\"\n#include \"ppapi\/thunk\/resource_creation_api.h\"\n\nnamespace ppapi {\nnamespace thunk {\n\nnamespace {\n\ntypedef EnterFunction EnterInstance;\ntypedef EnterResource EnterInputEvent;\n\n\/\/ InputEvent ------------------------------------------------------------------\n\nint32_t RequestInputEvents(PP_Instance instance, uint32_t event_classes) {\n EnterInstance enter(instance, true);\n if (enter.failed())\n return PP_ERROR_BADARGUMENT;\n return enter.functions()->RequestInputEvents(instance, event_classes);\n}\n\nint32_t RequestFilteringInputEvents(PP_Instance instance,\n uint32_t event_classes) {\n EnterInstance enter(instance, true);\n if (enter.failed())\n return PP_ERROR_BADARGUMENT;\n return enter.functions()->RequestFilteringInputEvents(instance,\n event_classes);\n}\n\nvoid ClearInputEventRequest(PP_Instance instance,\n uint32_t event_classes) {\n EnterInstance enter(instance, true);\n if (enter.succeeded())\n enter.functions()->ClearInputEventRequest(instance, event_classes);\n}\n\nPP_Bool IsInputEvent(PP_Resource resource) {\n EnterInputEvent enter(resource, false);\n return enter.succeeded() ? PP_TRUE : PP_FALSE;\n}\n\nPP_InputEvent_Type GetType(PP_Resource event) {\n EnterInputEvent enter(event, true);\n if (enter.failed())\n return PP_INPUTEVENT_TYPE_UNDEFINED;\n return enter.object()->GetType();\n}\n\nPP_TimeTicks GetTimeStamp(PP_Resource event) {\n EnterInputEvent enter(event, true);\n if (enter.failed())\n return 0.0;\n return enter.object()->GetTimeStamp();\n}\n\nuint32_t GetModifiers(PP_Resource event) {\n EnterInputEvent enter(event, true);\n if (enter.failed())\n return 0;\n return enter.object()->GetModifiers();\n}\n\nconst PPB_InputEvent g_ppb_input_event_thunk = {\n &RequestInputEvents,\n &RequestFilteringInputEvents,\n &ClearInputEventRequest,\n &IsInputEvent,\n &GetType,\n &GetTimeStamp,\n &GetModifiers\n};\n\n\/\/ Mouse -----------------------------------------------------------------------\n\nPP_Resource CreateMouseInputEvent(PP_Instance instance,\n PP_InputEvent_Type type,\n PP_TimeTicks time_stamp,\n uint32_t modifiers,\n PP_InputEvent_MouseButton mouse_button,\n const PP_Point* mouse_position,\n int32_t click_count) {\n EnterFunction enter(instance, true);\n if (enter.failed())\n return 0;\n return enter.functions()->CreateMouseInputEvent(instance, type, time_stamp,\n modifiers, mouse_button,\n mouse_position, click_count);\n}\n\nPP_Bool IsMouseInputEvent(PP_Resource resource) {\n if (!IsInputEvent(resource))\n return PP_FALSE; \/\/ Prevent warning log in GetType.\n PP_InputEvent_Type type = GetType(resource);\n return PP_FromBool(type == PP_INPUTEVENT_TYPE_MOUSEDOWN ||\n type == PP_INPUTEVENT_TYPE_MOUSEUP ||\n type == PP_INPUTEVENT_TYPE_MOUSEMOVE ||\n type == PP_INPUTEVENT_TYPE_MOUSEENTER ||\n type == PP_INPUTEVENT_TYPE_MOUSELEAVE ||\n type == PP_INPUTEVENT_TYPE_CONTEXTMENU);\n}\n\nPP_InputEvent_MouseButton GetMouseButton(PP_Resource mouse_event) {\n EnterInputEvent enter(mouse_event, true);\n if (enter.failed())\n return PP_INPUTEVENT_MOUSEBUTTON_NONE;\n return enter.object()->GetMouseButton();\n}\n\nPP_Point GetMousePosition(PP_Resource mouse_event) {\n EnterInputEvent enter(mouse_event, true);\n if (enter.failed())\n return PP_MakePoint(0, 0);\n return enter.object()->GetMousePosition();\n}\n\nint32_t GetMouseClickCount(PP_Resource mouse_event) {\n EnterInputEvent enter(mouse_event, true);\n if (enter.failed())\n return 0;\n return enter.object()->GetMouseClickCount();\n}\n\nconst PPB_MouseInputEvent g_ppb_mouse_input_event_thunk = {\n &CreateMouseInputEvent,\n &IsMouseInputEvent,\n &GetMouseButton,\n &GetMousePosition,\n &GetMouseClickCount\n};\n\n\/\/ Wheel -----------------------------------------------------------------------\n\nPP_Resource CreateWheelInputEvent(PP_Instance instance,\n PP_TimeTicks time_stamp,\n uint32_t modifiers,\n const PP_FloatPoint* wheel_delta,\n const PP_FloatPoint* wheel_ticks,\n PP_Bool scroll_by_page) {\n EnterFunction enter(instance, true);\n if (enter.failed())\n return 0;\n return enter.functions()->CreateWheelInputEvent(instance, time_stamp,\n modifiers, wheel_delta,\n wheel_ticks, scroll_by_page);\n}\n\nPP_Bool IsWheelInputEvent(PP_Resource resource) {\n if (!IsInputEvent(resource))\n return PP_FALSE; \/\/ Prevent warning log in GetType.\n PP_InputEvent_Type type = GetType(resource);\n return PP_FromBool(type == PP_INPUTEVENT_TYPE_WHEEL);\n}\n\nPP_FloatPoint GetWheelDelta(PP_Resource wheel_event) {\n EnterInputEvent enter(wheel_event, true);\n if (enter.failed())\n return PP_MakeFloatPoint(0.0f, 0.0f);\n return enter.object()->GetWheelDelta();\n}\n\nPP_FloatPoint GetWheelTicks(PP_Resource wheel_event) {\n EnterInputEvent enter(wheel_event, true);\n if (enter.failed())\n return PP_MakeFloatPoint(0.0f, 0.0f);\n return enter.object()->GetWheelTicks();\n}\n\nPP_Bool GetWheelScrollByPage(PP_Resource wheel_event) {\n EnterInputEvent enter(wheel_event, true);\n if (enter.failed())\n return PP_FALSE;\n return enter.object()->GetWheelScrollByPage();\n}\n\nconst PPB_WheelInputEvent g_ppb_wheel_input_event_thunk = {\n &CreateWheelInputEvent,\n &IsWheelInputEvent,\n &GetWheelDelta,\n &GetWheelTicks,\n &GetWheelScrollByPage\n};\n\n\/\/ Keyboard --------------------------------------------------------------------\n\nPP_Resource CreateKeyboardInputEvent(PP_Instance instance,\n PP_InputEvent_Type type,\n PP_TimeTicks time_stamp,\n uint32_t modifiers,\n uint32_t key_code,\n struct PP_Var character_text) {\n EnterFunction enter(instance, true);\n if (enter.failed())\n return 0;\n return enter.functions()->CreateKeyboardInputEvent(instance, type, time_stamp,\n modifiers, key_code,\n character_text);\n}\n\nPP_Bool IsKeyboardInputEvent(PP_Resource resource) {\n if (!IsInputEvent(resource))\n return PP_FALSE; \/\/ Prevent warning log in GetType.\n PP_InputEvent_Type type = GetType(resource);\n return PP_FromBool(type == PP_INPUTEVENT_TYPE_KEYDOWN ||\n type == PP_INPUTEVENT_TYPE_KEYUP ||\n type == PP_INPUTEVENT_TYPE_RAWKEYDOWN ||\n type == PP_INPUTEVENT_TYPE_CHAR);\n}\n\nuint32_t GetKeyCode(PP_Resource key_event) {\n EnterInputEvent enter(key_event, true);\n if (enter.failed())\n return 0;\n return enter.object()->GetKeyCode();\n}\n\nPP_Var GetCharacterText(PP_Resource character_event) {\n EnterInputEvent enter(character_event, true);\n if (enter.failed())\n return PP_MakeUndefined();\n return enter.object()->GetCharacterText();\n}\n\nconst PPB_KeyboardInputEvent g_ppb_keyboard_input_event_thunk = {\n &CreateKeyboardInputEvent,\n &IsKeyboardInputEvent,\n &GetKeyCode,\n &GetCharacterText\n};\n\n} \/\/ namespace\n\nconst PPB_InputEvent* GetPPB_InputEvent_Thunk() {\n return &g_ppb_input_event_thunk;\n}\n\nconst PPB_MouseInputEvent* GetPPB_MouseInputEvent_Thunk() {\n return &g_ppb_mouse_input_event_thunk;\n}\n\nconst PPB_KeyboardInputEvent* GetPPB_KeyboardInputEvent_Thunk() {\n return &g_ppb_keyboard_input_event_thunk;\n}\n\nconst PPB_WheelInputEvent* GetPPB_WheelInputEvent_Thunk() {\n return &g_ppb_wheel_input_event_thunk;\n}\n\n} \/\/ namespace thunk\n} \/\/ namespace ppapi\n<|endoftext|>"} {"text":"\/\/ Copyright (C) 2017 by Pedro Mendes, Virginia Tech Intellectual\n\/\/ Properties, Inc., University of Heidelberg, and University of\n\/\/ of Connecticut School of Medicine.\n\/\/ All rights reserved.\n\n\/\/ Copyright (C) 2010 - 2016 by Pedro Mendes, Virginia Tech Intellectual\n\/\/ Properties, Inc., University of Heidelberg, and The University\n\/\/ of Manchester.\n\/\/ All rights reserved.\n\n\/\/ Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual\n\/\/ Properties, Inc., EML Research, gGmbH, University of Heidelberg,\n\/\/ and The University of Manchester.\n\/\/ All rights reserved.\n\n\/\/ Copyright (C) 2007 by Pedro Mendes, Virginia Tech Intellectual\n\/\/ Properties, Inc. and EML Research, gGmbH.\n\/\/ All rights reserved.\n\n#include \"CQPreferenceDialog.h\"\n#include \"CQMessageBox.h\"\n\n#include \"copasi.h\"\n#include \"qtUtilities.h\"\n\n#include \"commandline\/CConfigurationFile.h\"\n#include \"copasi\/core\/CRootContainer.h\"\n\n#define COL_NAME 0\n#define COL_VALUE 1\n\n\/*\n * Constructs a CQPreferenceDialog as a child of 'parent', with the\n * name 'name' and widget flags set to 'f'.\n *\n * The dialog will by default be modeless, unless you set 'modal' to\n * true to construct a modal dialog.\n *\/\nCQPreferenceDialog::CQPreferenceDialog(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)\n : QDialog(parent, fl)\n , mpConfiguration(NULL)\n{\n setObjectName(QString::fromUtf8(name));\n setModal(modal);\n setupUi(this);\n\n init();\n}\n\n\/*\n * Destroys the object and frees any allocated resources\n *\/\nCQPreferenceDialog::~CQPreferenceDialog()\n{\n if (mpConfiguration != NULL)\n {\n delete mpConfiguration;\n mpConfiguration = NULL;\n }\n}\n\nvoid CQPreferenceDialog::init()\n{\n CConfigurationFile * pConfigFile = CRootContainer::getConfiguration();\n\n if (pConfigFile != NULL)\n {\n mpConfiguration = new CConfigurationFile(*pConfigFile, NO_PARENT);\n }\n\n mpTreeView->setAdvanced(false);\n mpTreeView->pushGroup(mpConfiguration);\n}\n\nvoid CQPreferenceDialog::slotBtnOk()\n{\n if (mpConfiguration != NULL)\n {\n *CRootContainer::getConfiguration() = *mpConfiguration;\n delete mpConfiguration;\n mpConfiguration = NULL;\n }\n\n done(1);\n}\n\n\/\/ virtual\nvoid CQPreferenceDialog::slotBtnCancel()\n{\n if (mpConfiguration != NULL)\n {\n delete mpConfiguration;\n mpConfiguration = NULL;\n }\n\n done(0);\n}\n- fix crash that occurs if Qt issues some operation on the treeview after the items have been deleted\/\/ Copyright (C) 2017 by Pedro Mendes, Virginia Tech Intellectual\n\/\/ Properties, Inc., University of Heidelberg, and University of\n\/\/ of Connecticut School of Medicine.\n\/\/ All rights reserved.\n\n\/\/ Copyright (C) 2010 - 2016 by Pedro Mendes, Virginia Tech Intellectual\n\/\/ Properties, Inc., University of Heidelberg, and The University\n\/\/ of Manchester.\n\/\/ All rights reserved.\n\n\/\/ Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual\n\/\/ Properties, Inc., EML Research, gGmbH, University of Heidelberg,\n\/\/ and The University of Manchester.\n\/\/ All rights reserved.\n\n\/\/ Copyright (C) 2007 by Pedro Mendes, Virginia Tech Intellectual\n\/\/ Properties, Inc. and EML Research, gGmbH.\n\/\/ All rights reserved.\n\n#include \"CQPreferenceDialog.h\"\n#include \"CQMessageBox.h\"\n\n#include \"copasi.h\"\n#include \"qtUtilities.h\"\n\n#include \"commandline\/CConfigurationFile.h\"\n#include \"copasi\/core\/CRootContainer.h\"\n\n#define COL_NAME 0\n#define COL_VALUE 1\n\n\/*\n * Constructs a CQPreferenceDialog as a child of 'parent', with the\n * name 'name' and widget flags set to 'f'.\n *\n * The dialog will by default be modeless, unless you set 'modal' to\n * true to construct a modal dialog.\n *\/\nCQPreferenceDialog::CQPreferenceDialog(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)\n : QDialog(parent, fl)\n , mpConfiguration(NULL)\n{\n setObjectName(QString::fromUtf8(name));\n setModal(modal);\n setupUi(this);\n\n init();\n}\n\n\/*\n * Destroys the object and frees any allocated resources\n *\/\nCQPreferenceDialog::~CQPreferenceDialog()\n{\n if (mpConfiguration != NULL)\n {\n delete mpConfiguration;\n mpConfiguration = NULL;\n }\n}\n\nvoid CQPreferenceDialog::init()\n{\n CConfigurationFile * pConfigFile = CRootContainer::getConfiguration();\n\n if (pConfigFile != NULL)\n {\n mpConfiguration = new CConfigurationFile(*pConfigFile, NO_PARENT);\n }\n\n mpTreeView->setAdvanced(false);\n mpTreeView->pushGroup(mpConfiguration);\n}\n\nvoid CQPreferenceDialog::slotBtnOk()\n{\n if (mpConfiguration != NULL)\n {\n *CRootContainer::getConfiguration() = *mpConfiguration;\n\n \/\/ remove items from tree, otherwise node pointers will become invalid\n mpTreeView->clearGroups();\n\n delete mpConfiguration;\n mpConfiguration = NULL;\n }\n\n done(1);\n}\n\n\/\/ virtual\nvoid CQPreferenceDialog::slotBtnCancel()\n{\n if (mpConfiguration != NULL)\n {\n \/\/ remove items from tree, otherwise node pointers will become invalid\n mpTreeView->clearGroups();\n\n delete mpConfiguration;\n mpConfiguration = NULL;\n }\n\n done(0);\n}\n<|endoftext|>"} {"text":"\/**\n * CMathSymbol class.\n * The class CMathSymbol associates a symbol with a CCopasiObject assuring\n * that the symbol name is unique.\n * Symbols are used to enhance redability of mathematical expresions.\n *\n * Created for Copasi by Stefan Hoops 2003\n *\/\n#include \n\n#include \"copasi.h\"\n#include \"CMathSymbol.h\"\n\nstd::map< std::string, CMathSymbol * > CMathSymbol::mList;\n\nstd::string & CMathSymbol::alternateName(std::string & name)\n{\n unsigned C_INT32 count = 1;\n stringstream tmpName;\n tmpName << name;\n\n while (mList.count(tmpName.str()))\n tmpName << name << \"_\" << count++;\n\n return name = tmpName.str();\n}\n\nCMathSymbol * CMathSymbol::find(const CCopasiObject * pObject)\n{\n std::map< std::string, CMathSymbol * >::iterator it = mList.begin();\n std::map< std::string, CMathSymbol * >::iterator end = mList.end();\n\n while (it != end && it->second->getObject() != pObject) it++;\n\n if (it == end) return NULL;\n else return it->second;\n}\n\nCMathSymbol::CMathSymbol():\n mName(),\n mCN(),\n mpObject(NULL)\n{}\n\nCMathSymbol::CMathSymbol(std::string & name):\n mName(alternateName(name)),\n mCN(),\n mpObject(NULL)\n{mList[mName] = this;}\n\nCMathSymbol::CMathSymbol(const CCopasiObject * pObject):\n mName(pObject->getObjectName()),\n mCN(pObject->getCN()),\n mpObject(const_cast< CCopasiObject * >(pObject))\n{\n alternateName(mName);\n mList[mName] = this;\n}\n\nCMathSymbol::CMathSymbol(const CMathSymbol & src):\n mName(\"copy of \" + src.mName),\n mCN(src.mCN),\n mpObject(src.mpObject)\n{\n alternateName(mName);\n mList[mName] = this;\n}\n\nCMathSymbol::~CMathSymbol() {mList.erase(mName);}\n\nbool CMathSymbol::setName(std::string & name)\n{\n mList.erase(mName);\n\n mName = name;\n if (alternateName(mName) == name)\n {\n mList[mName] = this;\n return true;\n }\n else\n {\n mList[mName] = this;\n return false;\n }\n}\n\nconst std::string & CMathSymbol::getName() const {return mName;}\n\nbool CMathSymbol::setCN(const CCopasiObjectName & cn,\n const CCopasiContainer * pContainer)\n{\n mCN = cn;\n mpObject = const_cast(pContainer)->getObject(mCN);\n if (mpObject)\n return true;\n else\n return false;\n}\n\nconst CCopasiObjectName & CMathSymbol::getCN() const {return mCN;}\n\nbool CMathSymbol::setObject(CCopasiObject * pObject)\n{\n mpObject = pObject;\n return true;\n}\n\nconst CCopasiObject * CMathSymbol::getObject() const {return mpObject;}\n\nCCopasiObject * CMathSymbol::getObject() {return mpObject;}\nFixes to work under Visual C++.\/**\n * CMathSymbol class.\n * The class CMathSymbol associates a symbol with a CCopasiObject assuring\n * that the symbol name is unique.\n * Symbols are used to enhance redability of mathematical expresions.\n *\n * Created for Copasi by Stefan Hoops 2003\n *\/\n#include \n\n#include \"copasi.h\"\n#include \"CMathSymbol.h\"\n\nstd::map< std::string, CMathSymbol * > CMathSymbol::mList;\n\nstd::string & CMathSymbol::alternateName(std::string & name)\n{\n unsigned C_INT32 count = 1;\n std::stringstream tmpName;\n tmpName << name;\n\n while (mList.count(tmpName.str()))\n tmpName << name << \"_\" << count++;\n\n return name = tmpName.str();\n}\n\nCMathSymbol * CMathSymbol::find(const CCopasiObject * pObject)\n{\n std::map< std::string, CMathSymbol * >::iterator it = mList.begin();\n std::map< std::string, CMathSymbol * >::iterator end = mList.end();\n\n while (it != end && it->second->getObject() != pObject) it++;\n\n if (it == end) return NULL;\n else return it->second;\n}\n\nCMathSymbol::CMathSymbol():\n mName(),\n mCN(),\n mpObject(NULL)\n{}\n\nCMathSymbol::CMathSymbol(std::string & name):\n mName(alternateName(name)),\n mCN(),\n mpObject(NULL)\n{mList[mName] = this;}\n\nCMathSymbol::CMathSymbol(const CCopasiObject * pObject):\n mName(pObject->getObjectName()),\n mCN(pObject->getCN()),\n mpObject(const_cast< CCopasiObject * >(pObject))\n{\n alternateName(mName);\n mList[mName] = this;\n}\n\nCMathSymbol::CMathSymbol(const CMathSymbol & src):\n mName(\"copy of \" + src.mName),\n mCN(src.mCN),\n mpObject(src.mpObject)\n{\n alternateName(mName);\n mList[mName] = this;\n}\n\nCMathSymbol::~CMathSymbol() {mList.erase(mName);}\n\nbool CMathSymbol::setName(std::string & name)\n{\n mList.erase(mName);\n\n mName = name;\n if (alternateName(mName) == name)\n {\n mList[mName] = this;\n return true;\n }\n else\n {\n mList[mName] = this;\n return false;\n }\n}\n\nconst std::string & CMathSymbol::getName() const {return mName;}\n\nbool CMathSymbol::setCN(const CCopasiObjectName & cn,\n const CCopasiContainer * pContainer)\n{\n mCN = cn;\n mpObject = const_cast(pContainer)->getObject(mCN);\n if (mpObject)\n return true;\n else\n return false;\n}\n\nconst CCopasiObjectName & CMathSymbol::getCN() const {return mCN;}\n\nbool CMathSymbol::setObject(CCopasiObject * pObject)\n{\n mpObject = pObject;\n return true;\n}\n\nconst CCopasiObject * CMathSymbol::getObject() const {return mpObject;}\n\nCCopasiObject * CMathSymbol::getObject() {return mpObject;}\n<|endoftext|>"} {"text":"#include \"browser\/views\/inspectable_web_contents_view_views.h\"\n\n#include \"browser\/inspectable_web_contents_impl.h\"\n\n#include \"base\/strings\/utf_string_conversions.h\"\n#include \"ui\/views\/controls\/webview\/webview.h\"\n#include \"ui\/views\/widget\/widget.h\"\n#include \"ui\/views\/widget\/widget_delegate.h\"\n#include \"ui\/views\/window\/client_view.h\"\n\nnamespace brightray {\n\nnamespace {\n\nclass DevToolsWindowDelegate : public views::ClientView,\n public views::WidgetDelegate {\n public:\n DevToolsWindowDelegate(InspectableWebContentsViewViews* shell,\n views::View* view,\n views::Widget* widget)\n : views::ClientView(widget_, view),\n shell_(shell),\n view_(view),\n widget_(widget),\n title_(base::ASCIIToUTF16(\"Developer Tools\")) {\n \/\/ A WidgetDelegate should be deleted on DeleteDelegate.\n set_owned_by_client();\n }\n virtual ~DevToolsWindowDelegate() {}\n\n \/\/ views::WidgetDelegate:\n virtual void DeleteDelegate() OVERRIDE { delete this; }\n virtual views::View* GetInitiallyFocusedView() OVERRIDE { return view_; }\n virtual bool CanResize() const OVERRIDE { return true; }\n virtual bool CanMaximize() const OVERRIDE { return false; }\n virtual base::string16 GetWindowTitle() const OVERRIDE { return title_; }\n virtual views::Widget* GetWidget() OVERRIDE { return widget_; }\n virtual const views::Widget* GetWidget() const OVERRIDE { return widget_; }\n virtual views::View* GetContentsView() OVERRIDE { return view_; }\n virtual views::ClientView* CreateClientView(views::Widget* widget) { return this; }\n\n \/\/ views::ClientView:\n virtual bool CanClose() OVERRIDE {\n shell_->inspectable_web_contents()->CloseDevTools();\n return false;\n }\n\n private:\n InspectableWebContentsViewViews* shell_;\n views::View* view_;\n views::Widget* widget_;\n base::string16 title_;\n\n DISALLOW_COPY_AND_ASSIGN(DevToolsWindowDelegate);\n};\n\n} \/\/ namespace\n\nInspectableWebContentsView* CreateInspectableContentsView(\n InspectableWebContentsImpl* inspectable_web_contents) {\n return new InspectableWebContentsViewViews(inspectable_web_contents);\n}\n\nInspectableWebContentsViewViews::InspectableWebContentsViewViews(\n InspectableWebContentsImpl* inspectable_web_contents)\n : inspectable_web_contents_(inspectable_web_contents),\n devtools_window_web_view_(NULL),\n contents_web_view_(new views::WebView(NULL)),\n devtools_web_view_(new views::WebView(NULL)),\n devtools_visible_(false) {\n set_owned_by_client();\n\n devtools_web_view_->SetVisible(false);\n contents_web_view_->SetWebContents(inspectable_web_contents_->GetWebContents());\n AddChildView(devtools_web_view_);\n AddChildView(contents_web_view_);\n}\n\nInspectableWebContentsViewViews::~InspectableWebContentsViewViews() {\n if (devtools_window_)\n inspectable_web_contents()->SaveDevToolsBounds(devtools_window_->GetWindowBoundsInScreen());\n}\n\nviews::View* InspectableWebContentsViewViews::GetView() {\n return this;\n}\n\nviews::View* InspectableWebContentsViewViews::GetWebView() {\n return contents_web_view_;\n}\n\nvoid InspectableWebContentsViewViews::ShowDevTools() {\n if (devtools_visible_)\n return;\n\n devtools_visible_ = true;\n if (devtools_window_) {\n devtools_window_web_view_->SetWebContents(inspectable_web_contents_->devtools_web_contents());\n devtools_window_->SetBounds(inspectable_web_contents()->GetDevToolsBounds());\n devtools_window_->Show();\n } else {\n devtools_web_view_->SetVisible(true);\n devtools_web_view_->SetWebContents(inspectable_web_contents_->devtools_web_contents());\n devtools_web_view_->RequestFocus();\n Layout();\n }\n}\n\nvoid InspectableWebContentsViewViews::CloseDevTools() {\n if (!devtools_visible_)\n return;\n\n devtools_visible_ = false;\n if (devtools_window_) {\n inspectable_web_contents()->SaveDevToolsBounds(devtools_window_->GetWindowBoundsInScreen());\n devtools_window_.reset();\n devtools_window_web_view_ = NULL;\n } else {\n devtools_web_view_->SetVisible(false);\n devtools_web_view_->SetWebContents(NULL);\n Layout();\n }\n}\n\nbool InspectableWebContentsViewViews::IsDevToolsViewShowing() {\n return devtools_visible_;\n}\n\nvoid InspectableWebContentsViewViews::SetIsDocked(bool docked) {\n CloseDevTools();\n\n if (!docked) {\n devtools_window_.reset(new views::Widget);\n devtools_window_web_view_ = new views::WebView(NULL);\n\n views::Widget::InitParams params;\n params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;\n params.delegate = new DevToolsWindowDelegate(this,\n devtools_window_web_view_,\n devtools_window_.get());\n params.top_level = true;\n params.bounds = inspectable_web_contents()->GetDevToolsBounds();\n#if defined(USE_X11)\n \/\/ In X11 the window frame is drawn by the application.\n params.remove_standard_frame = true;\n#endif\n devtools_window_->Init(params);\n }\n\n ShowDevTools();\n}\n\nvoid InspectableWebContentsViewViews::SetContentsResizingStrategy(\n const DevToolsContentsResizingStrategy& strategy) {\n strategy_.CopyFrom(strategy);\n Layout();\n}\n\nvoid InspectableWebContentsViewViews::Layout() {\n if (!devtools_web_view_->visible()) {\n contents_web_view_->SetBoundsRect(GetContentsBounds());\n return;\n }\n\n gfx::Size container_size(width(), height());\n gfx::Rect old_devtools_bounds(devtools_web_view_->bounds());\n gfx::Rect old_contents_bounds(contents_web_view_->bounds());\n gfx::Rect new_devtools_bounds;\n gfx::Rect new_contents_bounds;\n ApplyDevToolsContentsResizingStrategy(strategy_, container_size,\n old_devtools_bounds, old_contents_bounds,\n &new_devtools_bounds, &new_contents_bounds);\n\n \/\/ DevTools cares about the specific position, so we have to compensate RTL\n \/\/ layout here.\n new_devtools_bounds.set_x(GetMirroredXForRect(new_devtools_bounds));\n new_contents_bounds.set_x(GetMirroredXForRect(new_contents_bounds));\n\n devtools_web_view_->SetBoundsRect(new_devtools_bounds);\n contents_web_view_->SetBoundsRect(new_contents_bounds);\n}\n\n} \/\/ namespace brightray\nFix \"warning: field 'widget_' is uninitialized when used here\".#include \"browser\/views\/inspectable_web_contents_view_views.h\"\n\n#include \"browser\/inspectable_web_contents_impl.h\"\n\n#include \"base\/strings\/utf_string_conversions.h\"\n#include \"ui\/views\/controls\/webview\/webview.h\"\n#include \"ui\/views\/widget\/widget.h\"\n#include \"ui\/views\/widget\/widget_delegate.h\"\n#include \"ui\/views\/window\/client_view.h\"\n\nnamespace brightray {\n\nnamespace {\n\nclass DevToolsWindowDelegate : public views::ClientView,\n public views::WidgetDelegate {\n public:\n DevToolsWindowDelegate(InspectableWebContentsViewViews* shell,\n views::View* view,\n views::Widget* widget)\n : views::ClientView(widget, view),\n shell_(shell),\n view_(view),\n widget_(widget),\n title_(base::ASCIIToUTF16(\"Developer Tools\")) {\n \/\/ A WidgetDelegate should be deleted on DeleteDelegate.\n set_owned_by_client();\n }\n virtual ~DevToolsWindowDelegate() {}\n\n \/\/ views::WidgetDelegate:\n virtual void DeleteDelegate() OVERRIDE { delete this; }\n virtual views::View* GetInitiallyFocusedView() OVERRIDE { return view_; }\n virtual bool CanResize() const OVERRIDE { return true; }\n virtual bool CanMaximize() const OVERRIDE { return false; }\n virtual base::string16 GetWindowTitle() const OVERRIDE { return title_; }\n virtual views::Widget* GetWidget() OVERRIDE { return widget_; }\n virtual const views::Widget* GetWidget() const OVERRIDE { return widget_; }\n virtual views::View* GetContentsView() OVERRIDE { return view_; }\n virtual views::ClientView* CreateClientView(views::Widget* widget) { return this; }\n\n \/\/ views::ClientView:\n virtual bool CanClose() OVERRIDE {\n shell_->inspectable_web_contents()->CloseDevTools();\n return false;\n }\n\n private:\n InspectableWebContentsViewViews* shell_;\n views::View* view_;\n views::Widget* widget_;\n base::string16 title_;\n\n DISALLOW_COPY_AND_ASSIGN(DevToolsWindowDelegate);\n};\n\n} \/\/ namespace\n\nInspectableWebContentsView* CreateInspectableContentsView(\n InspectableWebContentsImpl* inspectable_web_contents) {\n return new InspectableWebContentsViewViews(inspectable_web_contents);\n}\n\nInspectableWebContentsViewViews::InspectableWebContentsViewViews(\n InspectableWebContentsImpl* inspectable_web_contents)\n : inspectable_web_contents_(inspectable_web_contents),\n devtools_window_web_view_(NULL),\n contents_web_view_(new views::WebView(NULL)),\n devtools_web_view_(new views::WebView(NULL)),\n devtools_visible_(false) {\n set_owned_by_client();\n\n devtools_web_view_->SetVisible(false);\n contents_web_view_->SetWebContents(inspectable_web_contents_->GetWebContents());\n AddChildView(devtools_web_view_);\n AddChildView(contents_web_view_);\n}\n\nInspectableWebContentsViewViews::~InspectableWebContentsViewViews() {\n if (devtools_window_)\n inspectable_web_contents()->SaveDevToolsBounds(devtools_window_->GetWindowBoundsInScreen());\n}\n\nviews::View* InspectableWebContentsViewViews::GetView() {\n return this;\n}\n\nviews::View* InspectableWebContentsViewViews::GetWebView() {\n return contents_web_view_;\n}\n\nvoid InspectableWebContentsViewViews::ShowDevTools() {\n if (devtools_visible_)\n return;\n\n devtools_visible_ = true;\n if (devtools_window_) {\n devtools_window_web_view_->SetWebContents(inspectable_web_contents_->devtools_web_contents());\n devtools_window_->SetBounds(inspectable_web_contents()->GetDevToolsBounds());\n devtools_window_->Show();\n } else {\n devtools_web_view_->SetVisible(true);\n devtools_web_view_->SetWebContents(inspectable_web_contents_->devtools_web_contents());\n devtools_web_view_->RequestFocus();\n Layout();\n }\n}\n\nvoid InspectableWebContentsViewViews::CloseDevTools() {\n if (!devtools_visible_)\n return;\n\n devtools_visible_ = false;\n if (devtools_window_) {\n inspectable_web_contents()->SaveDevToolsBounds(devtools_window_->GetWindowBoundsInScreen());\n devtools_window_.reset();\n devtools_window_web_view_ = NULL;\n } else {\n devtools_web_view_->SetVisible(false);\n devtools_web_view_->SetWebContents(NULL);\n Layout();\n }\n}\n\nbool InspectableWebContentsViewViews::IsDevToolsViewShowing() {\n return devtools_visible_;\n}\n\nvoid InspectableWebContentsViewViews::SetIsDocked(bool docked) {\n CloseDevTools();\n\n if (!docked) {\n devtools_window_.reset(new views::Widget);\n devtools_window_web_view_ = new views::WebView(NULL);\n\n views::Widget::InitParams params;\n params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;\n params.delegate = new DevToolsWindowDelegate(this,\n devtools_window_web_view_,\n devtools_window_.get());\n params.top_level = true;\n params.bounds = inspectable_web_contents()->GetDevToolsBounds();\n#if defined(USE_X11)\n \/\/ In X11 the window frame is drawn by the application.\n params.remove_standard_frame = true;\n#endif\n devtools_window_->Init(params);\n }\n\n ShowDevTools();\n}\n\nvoid InspectableWebContentsViewViews::SetContentsResizingStrategy(\n const DevToolsContentsResizingStrategy& strategy) {\n strategy_.CopyFrom(strategy);\n Layout();\n}\n\nvoid InspectableWebContentsViewViews::Layout() {\n if (!devtools_web_view_->visible()) {\n contents_web_view_->SetBoundsRect(GetContentsBounds());\n return;\n }\n\n gfx::Size container_size(width(), height());\n gfx::Rect old_devtools_bounds(devtools_web_view_->bounds());\n gfx::Rect old_contents_bounds(contents_web_view_->bounds());\n gfx::Rect new_devtools_bounds;\n gfx::Rect new_contents_bounds;\n ApplyDevToolsContentsResizingStrategy(strategy_, container_size,\n old_devtools_bounds, old_contents_bounds,\n &new_devtools_bounds, &new_contents_bounds);\n\n \/\/ DevTools cares about the specific position, so we have to compensate RTL\n \/\/ layout here.\n new_devtools_bounds.set_x(GetMirroredXForRect(new_devtools_bounds));\n new_contents_bounds.set_x(GetMirroredXForRect(new_contents_bounds));\n\n devtools_web_view_->SetBoundsRect(new_devtools_bounds);\n contents_web_view_->SetBoundsRect(new_contents_bounds);\n}\n\n} \/\/ namespace brightray\n<|endoftext|>"} {"text":"\/* IBM_PROLOG_BEGIN_TAG *\/\n\/* This is an automatically generated prolog. *\/\n\/* *\/\n\/* $Source: src\/import\/chips\/p9\/procedures\/hwp\/memory\/lib\/dimm\/kind.H $ *\/\n\/* *\/\n\/* OpenPOWER HostBoot Project *\/\n\/* *\/\n\/* Contributors Listed Below - COPYRIGHT 2016,2019 *\/\n\/* [+] International Business Machines Corp. *\/\n\/* *\/\n\/* *\/\n\/* Licensed under the Apache License, Version 2.0 (the \"License\"); *\/\n\/* you may not use this file except in compliance with the License. *\/\n\/* You may obtain a copy of the License at *\/\n\/* *\/\n\/* http:\/\/www.apache.org\/licenses\/LICENSE-2.0 *\/\n\/* *\/\n\/* Unless required by applicable law or agreed to in writing, software *\/\n\/* distributed under the License is distributed on an \"AS IS\" BASIS, *\/\n\/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *\/\n\/* implied. See the License for the specific language governing *\/\n\/* permissions and limitations under the License. *\/\n\/* *\/\n\/* IBM_PROLOG_END_TAG *\/\n\n\/\/\/\n\/\/\/ @file dimm.H\n\/\/\/ @brief Encapsulation for dimms of all types\n\/\/\/\n\/\/ *HWP HWP Owner: Brian Silver \n\/\/ *HWP HWP Backup: Craig Hamilton \n\/\/ *HWP Team: Memory\n\/\/ *HWP Level: 2\n\/\/ *HWP Consumed by: HB:FSP\n\n#ifndef _MSS_DIMM_H_\n#define _MSS_DIMM_H_\n\n#include \n\n#include \n#include \"..\/utils\/c_str.H\"\n\nnamespace mss\n{\n\nnamespace dimm\n{\n\n\/\/\/\n\/\/\/ @class mss::dimm::kind\n\/\/\/ @brief A class containing information about a dimm like ranks, density, configuration - what kind of dimm is it?\n\/\/\/\nclass kind\n{\n public:\n\n kind(const fapi2::Target& i_target):\n iv_target(i_target)\n {\n FAPI_TRY( mss::eff_dram_gen(i_target, iv_dram_generation) );\n FAPI_TRY( mss::eff_dimm_type(i_target, iv_dimm_type) );\n FAPI_TRY( mss::eff_dram_density(i_target, iv_dram_density) );\n FAPI_TRY( mss::eff_dram_width(i_target, iv_dram_width) );\n FAPI_TRY( mss::eff_num_master_ranks_per_dimm(i_target, iv_master_ranks) );\n FAPI_TRY( mss::eff_dram_row_bits(i_target, iv_rows) );\n FAPI_TRY( mss::eff_dimm_size(i_target, iv_size) );\n\n \/\/ TK: Attribute for slave ranks.\n iv_slave_ranks = 0;\n\n fapi_try_exit:\n \/\/ Not 100% sure what to do here ...\n FAPI_ERR(\"error initializing DIMM structure: %s 0x%016lx\", mss::c_str(i_target), uint64_t(fapi2::current_err));\n }\n\n const fapi2::Target iv_target;\n uint8_t iv_master_ranks;\n uint8_t iv_slave_ranks;\n uint8_t iv_dram_density;\n uint8_t iv_dram_width;\n uint8_t iv_dram_generation;\n uint8_t iv_dimm_type;\n uint8_t iv_rows;\n uint32_t iv_size;\n};\n\n}\n\n}\n#endif\nChange comments, return code for mcbist 2 port testing\/* IBM_PROLOG_BEGIN_TAG *\/\n\/* This is an automatically generated prolog. *\/\n\/* *\/\n\/* $Source: src\/import\/chips\/p9\/procedures\/hwp\/memory\/lib\/dimm\/kind.H $ *\/\n\/* *\/\n\/* OpenPOWER HostBoot Project *\/\n\/* *\/\n\/* Contributors Listed Below - COPYRIGHT 2016,2019 *\/\n\/* [+] International Business Machines Corp. *\/\n\/* *\/\n\/* *\/\n\/* Licensed under the Apache License, Version 2.0 (the \"License\"); *\/\n\/* you may not use this file except in compliance with the License. *\/\n\/* You may obtain a copy of the License at *\/\n\/* *\/\n\/* http:\/\/www.apache.org\/licenses\/LICENSE-2.0 *\/\n\/* *\/\n\/* Unless required by applicable law or agreed to in writing, software *\/\n\/* distributed under the License is distributed on an \"AS IS\" BASIS, *\/\n\/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *\/\n\/* implied. See the License for the specific language governing *\/\n\/* permissions and limitations under the License. *\/\n\/* *\/\n\/* IBM_PROLOG_END_TAG *\/\n\n\/\/\/\n\/\/\/ @file dimm.H\n\/\/\/ @brief Encapsulation for dimms of all types\n\/\/\/\n\/\/ *HWP HWP Owner: Brian Silver \n\/\/ *HWP HWP Backup: Craig Hamilton \n\/\/ *HWP Team: Memory\n\/\/ *HWP Level: 2\n\/\/ *HWP Consumed by: HB:FSP\n\n#ifndef _MSS_DIMM_H_\n#define _MSS_DIMM_H_\n\n#include \n\n#include \n#include \"..\/utils\/c_str.H\"\n\nnamespace mss\n{\n\nnamespace dimm\n{\n\n\/\/\/\n\/\/\/ @class mss::dimm::kind\n\/\/\/ @brief A class containing information about a dimm like ranks, density, configuration - what kind of dimm is it?\n\/\/\/\nclass kind\n{\n public:\n\n kind(const fapi2::Target& i_target):\n iv_target(i_target)\n {\n FAPI_TRY( mss::eff_dram_gen(i_target, iv_dram_generation) );\n FAPI_TRY( mss::eff_dimm_type(i_target, iv_dimm_type) );\n FAPI_TRY( mss::eff_dram_density(i_target, iv_dram_density) );\n FAPI_TRY( mss::eff_dram_width(i_target, iv_dram_width) );\n FAPI_TRY( mss::eff_num_master_ranks_per_dimm(i_target, iv_master_ranks) );\n FAPI_TRY( mss::eff_dram_row_bits(i_target, iv_rows) );\n FAPI_TRY( mss::eff_dimm_size(i_target, iv_size) );\n\n \/\/ TK: Attribute for slave ranks.\n iv_slave_ranks = 0;\n\n return;\n\n fapi_try_exit:\n \/\/ Not 100% sure what to do here ...\n FAPI_ERR(\"error initializing DIMM structure: %s 0x%016lx\", mss::c_str(i_target), uint64_t(fapi2::current_err));\n }\n\n const fapi2::Target iv_target;\n uint8_t iv_master_ranks;\n uint8_t iv_slave_ranks;\n uint8_t iv_dram_density;\n uint8_t iv_dram_width;\n uint8_t iv_dram_generation;\n uint8_t iv_dimm_type;\n uint8_t iv_rows;\n uint32_t iv_size;\n};\n\n}\n\n}\n#endif\n<|endoftext|>"} {"text":"\/\/ Copyright (C) 2013 by Pedro Mendes, Virginia Tech Intellectual\n\/\/ Properties, Inc., University of Heidelberg, and The University\n\/\/ of Manchester.\n\/\/ All rights reserved.\n\n#include \n\n#include \"copasi.h\"\n\n#include \"CLinkMatrix.h\"\n\n#include \"CCopasiVector.h\"\n\n#include \"blaswrap.h\"\n#include \"clapackwrap.h\"\n\n#define DEBUG_MATRIX\n\nCLinkMatrix::CLinkMatrix():\n CMatrix< C_FLOAT64 >(),\n mRowPivots(),\n mIndependent(0)\n{}\n\nCLinkMatrix::~CLinkMatrix()\n{}\n\nconst CVector< size_t > & CLinkMatrix::getRowPivots() const\n{\n return mRowPivots;\n}\n\nbool CLinkMatrix::build(const CMatrix< C_FLOAT64 > & matrix)\n{\n bool success = true;\n\n CMatrix< C_FLOAT64 > M(matrix);\n\n C_INT NumCols = (C_INT) M.numCols();\n C_INT NumRows = (C_INT) M.numRows();\n C_INT LDA = std::max(1, NumCols);\n\n CVector< C_INT > JPVT(NumRows);\n JPVT = 0;\n\n C_INT32 Dim = std::min(NumCols, NumRows);\n\n if (Dim == 0)\n {\n C_INT32 i;\n mRowPivots.resize(NumRows);\n\n for (i = 0; i < NumRows; i++)\n mRowPivots[i] = i;\n\n resize(NumRows, 0);\n\n return success;\n }\n\n CVector< C_FLOAT64 > TAU(Dim);\n\n CVector< C_FLOAT64 > WORK(1);\n C_INT LWORK = -1;\n C_INT INFO;\n\n \/\/ QR factorization of the stoichiometry matrix\n \/*\n * -- LAPACK routine (version 3.0) --\n * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,\n * Courant Institute, Argonne National Lab, and Rice University\n * June 30, 1999\n *\n * Purpose\n * =======\n *\n * DGEQP3 computes a QR factorization with column pivoting of a\n * matrix A: A*P = Q*R using Level 3 BLAS.\n *\n * Arguments\n * =========\n *\n * M (input) INTEGER\n * The number of rows of the matrix A. M >= 0.\n *\n * N (input) INTEGER\n * The number of columns of the matrix A. N >= 0.\n *\n * A (input\/output) DOUBLE PRECISION array, dimension (LDA,N)\n * On entry, the M-by-N matrix A.\n * On exit, the upper triangle of the array contains the\n * min(M,N)-by-N upper trapezoidal matrix R; the elements below\n * the diagonal, together with the array TAU, represent the\n * orthogonal matrix Q as a product of min(M,N) elementary\n * reflectors.\n *\n * LDA (input) INTEGER\n * The leading dimension of the array A. LDA >= max(1,M).\n *\n * JPVT (input\/output) INTEGER array, dimension (N)\n * On entry, if JPVT(J).ne.0, the J-th column of A is permuted\n * to the front of A*P (a leading column); if JPVT(J)=0,\n * the J-th column of A is a free column.\n * On exit, if JPVT(J)=K, then the J-th column of A*P was the\n * the K-th column of A.\n *\n * TAU (output) DOUBLE PRECISION array, dimension (min(M,N))\n * The scalar factors of the elementary reflectors.\n *\n * WORK (workspace\/output) DOUBLE PRECISION array, dimension (LWORK)\n * On exit, if INFO=0, WORK(1) returns the optimal LWORK.\n *\n * LWORK (input) INTEGER\n * The dimension of the array WORK. LWORK >= 3*N+1.\n * For optimal performance LWORK >= 2*N+(N+1)*NB, where NB\n * is the optimal blocksize.\n *\n * If LWORK = -1, then a workspace query is assumed; the routine\n * only calculates the optimal size of the WORK array, returns\n * this value as the first entry of the WORK array, and no error\n * message related to LWORK is issued by XERBLA.\n *\n * INFO (output) INTEGER\n * = 0: successful exit.\n * < 0: if INFO = -i, the i-th argument had an illegal value.\n *\n * Further Details\n * ===============\n *\n * The matrix Q is represented as a product of elementary reflectors\n *\n * Q = H(1) H(2) . . . H(k), where k = min(m,n).\n *\n * Each H(i) has the form\n *\n * H(i) = I - tau * v * v'\n *\n * where tau is a real\/complex scalar, and v is a real\/complex vector\n * with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in\n * A(i+1:m,i), and tau in TAU(i).\n *\n * Based on contributions by\n * G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain\n * X. Sun, Computer Science Dept., Duke University, USA\n *\n *\/\n\n#ifdef DEBUG_MATRIX\n std::cout << CTransposeView< CMatrix< C_FLOAT64 > >(M) << std::endl;\n#endif\n\n dgeqp3_(&NumCols, &NumRows, M.array(), &LDA,\n JPVT.array(), TAU.array(), WORK.array(), &LWORK, &INFO);\n\n if (INFO < 0) fatalError();\n\n LWORK = (C_INT) WORK[0];\n WORK.resize(LWORK);\n\n dgeqp3_(&NumCols, &NumRows, M.array(), &LDA,\n JPVT.array(), TAU.array(), WORK.array(), &LWORK, &INFO);\n\n if (INFO < 0) fatalError();\n\n C_INT32 i;\n mRowPivots.resize(NumRows);\n\n for (i = 0; i < NumRows; i++)\n mRowPivots[i] = JPVT[i] - 1;\n\n#ifdef DEBUG_MATRIX\n std::cout << \"QR Factorization:\" << std::endl;\n std::cout << \"Row permutation:\\t\" << mRowPivots << std::endl;\n std::cout << CTransposeView< CMatrix< C_FLOAT64 > >(M) << std::endl;\n#endif\n\n C_INT independent = 0;\n\n while (independent < Dim &&\n fabs(M(independent, independent)) > 100.0 * std::numeric_limits< C_FLOAT64 >::epsilon()) independent++;\n\n mIndependent = independent;\n\n \/\/ Resize mL\n resize(NumRows - independent, independent);\n\n if (NumRows == independent || independent == 0)\n {\n return success;\n }\n\n \/* to take care of differences between fortran's and c's memory access,\n we need to take the transpose, i.e.,the upper triangular *\/\n char cL = 'U';\n char cU = 'N'; \/* values in the diagonal of R *\/\n\n \/\/ Calculate Row Echelon form of R.\n \/\/ First invert R_1,1\n \/* int dtrtri_(char *uplo,\n * char *diag,\n * integer *n,\n * doublereal * A,\n * integer *lda,\n * integer *info);\n * -- LAPACK routine (version 3.0) --\n * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,\n * Courant Institute, Argonne National Lab, and Rice University\n * March 31, 1993\n *\n * Purpose\n * =======\n *\n * DTRTRI computes the inverse of a real upper or lower triangular\n * matrix A.\n *\n * This is the Level 3 BLAS version of the algorithm.\n *\n * Arguments\n * =========\n *\n * uplo (input) CHARACTER*1\n * = 'U': A is upper triangular;\n * = 'L': A is lower triangular.\n *\n * diag (input) CHARACTER*1\n * = 'N': A is non-unit triangular;\n * = 'U': A is unit triangular.\n *\n * n (input) INTEGER\n * The order of the matrix A. n >= 0.\n *\n * A (input\/output) DOUBLE PRECISION array, dimension (lda,n)\n * On entry, the triangular matrix A. If uplo = 'U', the\n * leading n-by-n upper triangular part of the array A contains\n * the upper triangular matrix, and the strictly lower\n * triangular part of A is not referenced. If uplo = 'L', the\n * leading n-by-n lower triangular part of the array A contains\n * the lower triangular matrix, and the strictly upper\n * triangular part of A is not referenced. If diag = 'U', the\n * diagonal elements of A are also not referenced and are\n * assumed to be 1.\n * On exit, the (triangular) inverse of the original matrix, in\n * the same storage format.\n *\n * lda (input) INTEGER\n * The leading dimension of the array A. lda >= max(1,n).\n *\n * info (output) INTEGER\n * = 0: successful exit\n * < 0: if info = -i, the i-th argument had an illegal value\n * > 0: if info = i, A(i,i) is exactly zero. The triangular\n * matrix is singular and its inverse can not be computed.\n *\/\n dtrtri_(&cL, &cU, &independent, M.array(), &LDA, &INFO);\n\n if (INFO < 0) fatalError();\n\n#ifdef DEBUG_MATRIX\n std::cout << \"Invert R_1,1:\" << std::endl;\n std::cout << CTransposeView< CMatrix< C_FLOAT64 > >(M) << std::endl;\n#endif\n\n C_INT32 j, k;\n\n \/\/ Compute Link_0 = inverse(R_1,1) * R_1,2\n \/\/ :TODO: Use dgemm\n C_FLOAT64 * pTmp1 = array();\n C_FLOAT64 * pTmp2;\n C_FLOAT64 * pTmp3;\n\n for (j = 0; j < NumRows - independent; j++)\n for (i = 0; i < independent; i++, pTmp1++)\n {\n pTmp2 = &M(j + independent, i);\n pTmp3 = &M(i, i);\n\n \/\/ assert(&mL(j, i) == pTmp3);\n *pTmp1 = 0.0;\n\n for (k = i; k < independent; k++, pTmp2++, pTmp3 += NumCols)\n {\n \/\/ assert(&M(j + independent, k) == pTmp2);\n \/\/ assert(&M(k, i) == pTmp3);\n\n *pTmp1 += *pTmp3 * *pTmp2;\n }\n\n if (fabs(*pTmp1) < 100.0 * std::numeric_limits< C_FLOAT64 >::epsilon()) *pTmp1 = 0.0;\n }\n\n#ifdef DEBUG_MATRIX\n std::cout << \"Link Zero Matrix:\" << std::endl;\n std::cout << *this << std::endl;\n#endif \/\/ DEBUG_MATRIX\n\n return success;\n}\n\nconst size_t & CLinkMatrix::getNumIndependent() const\n{\n return mIndependent;\n}\n\nconst size_t & CLinkMatrix::getNumDependent() const\n{\n return numRows();\n}\n\nbool CLinkMatrix::applyRowPivot(CMatrix< C_FLOAT64 > & matrix) const\n{\n if (matrix.numRows() < mRowPivots.size())\n {\n return false;\n }\n\n CVector< bool > Applied(mRowPivots.size());\n Applied = false;\n\n CVector< C_FLOAT64 > Tmp(matrix.numCols());\n\n size_t i, imax = mRowPivots.size();\n size_t to;\n size_t from;\n size_t numCols = matrix.numCols();\n\n for (i = 0; i < imax; i++)\n if (!Applied[i])\n {\n to = i;\n from = mRowPivots[to];\n\n if (from != i)\n {\n memcpy(Tmp.array(), matrix[to], sizeof(C_FLOAT64) * numCols);\n\n while (from != i)\n {\n memcpy(matrix[to], matrix[from], sizeof(C_FLOAT64) * numCols);\n Applied[to] = true;\n\n to = from;\n from = mRowPivots[to];\n }\n\n memcpy(matrix[to], Tmp.array(), sizeof(C_FLOAT64) * numCols);\n }\n\n Applied[to] = true;\n }\n\n return true;\n}\n\n\/\/**********************************************************************\n\/\/ CLinkMatrixView\n\/\/**********************************************************************\n\nconst C_FLOAT64 CLinkMatrixView::mZero = 0.0;\nconst C_FLOAT64 CLinkMatrixView::mUnit = 1.0;\n\nCLinkMatrixView::CLinkMatrixView(const CLinkMatrix & A,\n const size_t & numIndependent):\n mpA(&A),\n mpNumIndependent(&numIndependent)\n{CONSTRUCTOR_TRACE;}\n\nCLinkMatrixView::~CLinkMatrixView()\n{DESTRUCTOR_TRACE;}\n\nCLinkMatrixView &\nCLinkMatrixView::operator = (const CLinkMatrixView & rhs)\n{\n mpA = rhs.mpA;\n mpNumIndependent = rhs.mpNumIndependent;\n\n return *this;\n}\n\nsize_t CLinkMatrixView::numRows() const\n{\n return *mpNumIndependent + mpA->numRows();\n}\n\nsize_t CLinkMatrixView::numCols() const\n{\n return mpA->numCols();\n}\n\nstd::ostream &operator<<(std::ostream &os,\n const CLinkMatrixView & A)\n{\n size_t i, imax = A.numRows();\n size_t j, jmax = A.numCols();\n os << \"Matrix(\" << imax << \"x\" << jmax << \")\" << std::endl;\n\n for (i = 0; i < imax; i++)\n {\n for (j = 0; j < jmax; j++)\n os << \"\\t\" << A(i, j);\n\n os << std::endl;\n }\n\n return os;\n}\nDisabled debug output.\/\/ Copyright (C) 2013 by Pedro Mendes, Virginia Tech Intellectual\n\/\/ Properties, Inc., University of Heidelberg, and The University\n\/\/ of Manchester.\n\/\/ All rights reserved.\n\n#include \n\n#include \"copasi.h\"\n\n#include \"CLinkMatrix.h\"\n\n#include \"CCopasiVector.h\"\n\n#include \"blaswrap.h\"\n#include \"clapackwrap.h\"\n\n\/\/ Define to output debugging information\n\/\/ #define DEBUG_MATRIX\n\nCLinkMatrix::CLinkMatrix():\n CMatrix< C_FLOAT64 >(),\n mRowPivots(),\n mIndependent(0)\n{}\n\nCLinkMatrix::~CLinkMatrix()\n{}\n\nconst CVector< size_t > & CLinkMatrix::getRowPivots() const\n{\n return mRowPivots;\n}\n\nbool CLinkMatrix::build(const CMatrix< C_FLOAT64 > & matrix)\n{\n bool success = true;\n\n CMatrix< C_FLOAT64 > M(matrix);\n\n C_INT NumCols = (C_INT) M.numCols();\n C_INT NumRows = (C_INT) M.numRows();\n C_INT LDA = std::max(1, NumCols);\n\n CVector< C_INT > JPVT(NumRows);\n JPVT = 0;\n\n C_INT32 Dim = std::min(NumCols, NumRows);\n\n if (Dim == 0)\n {\n C_INT32 i;\n mRowPivots.resize(NumRows);\n\n for (i = 0; i < NumRows; i++)\n mRowPivots[i] = i;\n\n resize(NumRows, 0);\n\n return success;\n }\n\n CVector< C_FLOAT64 > TAU(Dim);\n\n CVector< C_FLOAT64 > WORK(1);\n C_INT LWORK = -1;\n C_INT INFO;\n\n \/\/ QR factorization of the stoichiometry matrix\n \/*\n * -- LAPACK routine (version 3.0) --\n * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,\n * Courant Institute, Argonne National Lab, and Rice University\n * June 30, 1999\n *\n * Purpose\n * =======\n *\n * DGEQP3 computes a QR factorization with column pivoting of a\n * matrix A: A*P = Q*R using Level 3 BLAS.\n *\n * Arguments\n * =========\n *\n * M (input) INTEGER\n * The number of rows of the matrix A. M >= 0.\n *\n * N (input) INTEGER\n * The number of columns of the matrix A. N >= 0.\n *\n * A (input\/output) DOUBLE PRECISION array, dimension (LDA,N)\n * On entry, the M-by-N matrix A.\n * On exit, the upper triangle of the array contains the\n * min(M,N)-by-N upper trapezoidal matrix R; the elements below\n * the diagonal, together with the array TAU, represent the\n * orthogonal matrix Q as a product of min(M,N) elementary\n * reflectors.\n *\n * LDA (input) INTEGER\n * The leading dimension of the array A. LDA >= max(1,M).\n *\n * JPVT (input\/output) INTEGER array, dimension (N)\n * On entry, if JPVT(J).ne.0, the J-th column of A is permuted\n * to the front of A*P (a leading column); if JPVT(J)=0,\n * the J-th column of A is a free column.\n * On exit, if JPVT(J)=K, then the J-th column of A*P was the\n * the K-th column of A.\n *\n * TAU (output) DOUBLE PRECISION array, dimension (min(M,N))\n * The scalar factors of the elementary reflectors.\n *\n * WORK (workspace\/output) DOUBLE PRECISION array, dimension (LWORK)\n * On exit, if INFO=0, WORK(1) returns the optimal LWORK.\n *\n * LWORK (input) INTEGER\n * The dimension of the array WORK. LWORK >= 3*N+1.\n * For optimal performance LWORK >= 2*N+(N+1)*NB, where NB\n * is the optimal blocksize.\n *\n * If LWORK = -1, then a workspace query is assumed; the routine\n * only calculates the optimal size of the WORK array, returns\n * this value as the first entry of the WORK array, and no error\n * message related to LWORK is issued by XERBLA.\n *\n * INFO (output) INTEGER\n * = 0: successful exit.\n * < 0: if INFO = -i, the i-th argument had an illegal value.\n *\n * Further Details\n * ===============\n *\n * The matrix Q is represented as a product of elementary reflectors\n *\n * Q = H(1) H(2) . . . H(k), where k = min(m,n).\n *\n * Each H(i) has the form\n *\n * H(i) = I - tau * v * v'\n *\n * where tau is a real\/complex scalar, and v is a real\/complex vector\n * with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in\n * A(i+1:m,i), and tau in TAU(i).\n *\n * Based on contributions by\n * G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain\n * X. Sun, Computer Science Dept., Duke University, USA\n *\n *\/\n\n#ifdef DEBUG_MATRIX\n std::cout << CTransposeView< CMatrix< C_FLOAT64 > >(M) << std::endl;\n#endif\n\n dgeqp3_(&NumCols, &NumRows, M.array(), &LDA,\n JPVT.array(), TAU.array(), WORK.array(), &LWORK, &INFO);\n\n if (INFO < 0) fatalError();\n\n LWORK = (C_INT) WORK[0];\n WORK.resize(LWORK);\n\n dgeqp3_(&NumCols, &NumRows, M.array(), &LDA,\n JPVT.array(), TAU.array(), WORK.array(), &LWORK, &INFO);\n\n if (INFO < 0) fatalError();\n\n C_INT32 i;\n mRowPivots.resize(NumRows);\n\n for (i = 0; i < NumRows; i++)\n mRowPivots[i] = JPVT[i] - 1;\n\n#ifdef DEBUG_MATRIX\n std::cout << \"QR Factorization:\" << std::endl;\n std::cout << \"Row permutation:\\t\" << mRowPivots << std::endl;\n std::cout << CTransposeView< CMatrix< C_FLOAT64 > >(M) << std::endl;\n#endif\n\n C_INT independent = 0;\n\n while (independent < Dim &&\n fabs(M(independent, independent)) > 100.0 * std::numeric_limits< C_FLOAT64 >::epsilon()) independent++;\n\n mIndependent = independent;\n\n \/\/ Resize mL\n resize(NumRows - independent, independent);\n\n if (NumRows == independent || independent == 0)\n {\n return success;\n }\n\n \/* to take care of differences between fortran's and c's memory access,\n we need to take the transpose, i.e.,the upper triangular *\/\n char cL = 'U';\n char cU = 'N'; \/* values in the diagonal of R *\/\n\n \/\/ Calculate Row Echelon form of R.\n \/\/ First invert R_1,1\n \/* int dtrtri_(char *uplo,\n * char *diag,\n * integer *n,\n * doublereal * A,\n * integer *lda,\n * integer *info);\n * -- LAPACK routine (version 3.0) --\n * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,\n * Courant Institute, Argonne National Lab, and Rice University\n * March 31, 1993\n *\n * Purpose\n * =======\n *\n * DTRTRI computes the inverse of a real upper or lower triangular\n * matrix A.\n *\n * This is the Level 3 BLAS version of the algorithm.\n *\n * Arguments\n * =========\n *\n * uplo (input) CHARACTER*1\n * = 'U': A is upper triangular;\n * = 'L': A is lower triangular.\n *\n * diag (input) CHARACTER*1\n * = 'N': A is non-unit triangular;\n * = 'U': A is unit triangular.\n *\n * n (input) INTEGER\n * The order of the matrix A. n >= 0.\n *\n * A (input\/output) DOUBLE PRECISION array, dimension (lda,n)\n * On entry, the triangular matrix A. If uplo = 'U', the\n * leading n-by-n upper triangular part of the array A contains\n * the upper triangular matrix, and the strictly lower\n * triangular part of A is not referenced. If uplo = 'L', the\n * leading n-by-n lower triangular part of the array A contains\n * the lower triangular matrix, and the strictly upper\n * triangular part of A is not referenced. If diag = 'U', the\n * diagonal elements of A are also not referenced and are\n * assumed to be 1.\n * On exit, the (triangular) inverse of the original matrix, in\n * the same storage format.\n *\n * lda (input) INTEGER\n * The leading dimension of the array A. lda >= max(1,n).\n *\n * info (output) INTEGER\n * = 0: successful exit\n * < 0: if info = -i, the i-th argument had an illegal value\n * > 0: if info = i, A(i,i) is exactly zero. The triangular\n * matrix is singular and its inverse can not be computed.\n *\/\n dtrtri_(&cL, &cU, &independent, M.array(), &LDA, &INFO);\n\n if (INFO < 0) fatalError();\n\n#ifdef DEBUG_MATRIX\n std::cout << \"Invert R_1,1:\" << std::endl;\n std::cout << CTransposeView< CMatrix< C_FLOAT64 > >(M) << std::endl;\n#endif\n\n C_INT32 j, k;\n\n \/\/ Compute Link_0 = inverse(R_1,1) * R_1,2\n \/\/ :TODO: Use dgemm\n C_FLOAT64 * pTmp1 = array();\n C_FLOAT64 * pTmp2;\n C_FLOAT64 * pTmp3;\n\n for (j = 0; j < NumRows - independent; j++)\n for (i = 0; i < independent; i++, pTmp1++)\n {\n pTmp2 = &M(j + independent, i);\n pTmp3 = &M(i, i);\n\n \/\/ assert(&mL(j, i) == pTmp3);\n *pTmp1 = 0.0;\n\n for (k = i; k < independent; k++, pTmp2++, pTmp3 += NumCols)\n {\n \/\/ assert(&M(j + independent, k) == pTmp2);\n \/\/ assert(&M(k, i) == pTmp3);\n\n *pTmp1 += *pTmp3 * *pTmp2;\n }\n\n if (fabs(*pTmp1) < 100.0 * std::numeric_limits< C_FLOAT64 >::epsilon()) *pTmp1 = 0.0;\n }\n\n#ifdef DEBUG_MATRIX\n std::cout << \"Link Zero Matrix:\" << std::endl;\n std::cout << *this << std::endl;\n#endif \/\/ DEBUG_MATRIX\n\n return success;\n}\n\nconst size_t & CLinkMatrix::getNumIndependent() const\n{\n return mIndependent;\n}\n\nconst size_t & CLinkMatrix::getNumDependent() const\n{\n return numRows();\n}\n\nbool CLinkMatrix::applyRowPivot(CMatrix< C_FLOAT64 > & matrix) const\n{\n if (matrix.numRows() < mRowPivots.size())\n {\n return false;\n }\n\n CVector< bool > Applied(mRowPivots.size());\n Applied = false;\n\n CVector< C_FLOAT64 > Tmp(matrix.numCols());\n\n size_t i, imax = mRowPivots.size();\n size_t to;\n size_t from;\n size_t numCols = matrix.numCols();\n\n for (i = 0; i < imax; i++)\n if (!Applied[i])\n {\n to = i;\n from = mRowPivots[to];\n\n if (from != i)\n {\n memcpy(Tmp.array(), matrix[to], sizeof(C_FLOAT64) * numCols);\n\n while (from != i)\n {\n memcpy(matrix[to], matrix[from], sizeof(C_FLOAT64) * numCols);\n Applied[to] = true;\n\n to = from;\n from = mRowPivots[to];\n }\n\n memcpy(matrix[to], Tmp.array(), sizeof(C_FLOAT64) * numCols);\n }\n\n Applied[to] = true;\n }\n\n return true;\n}\n\n\/\/**********************************************************************\n\/\/ CLinkMatrixView\n\/\/**********************************************************************\n\nconst C_FLOAT64 CLinkMatrixView::mZero = 0.0;\nconst C_FLOAT64 CLinkMatrixView::mUnit = 1.0;\n\nCLinkMatrixView::CLinkMatrixView(const CLinkMatrix & A,\n const size_t & numIndependent):\n mpA(&A),\n mpNumIndependent(&numIndependent)\n{CONSTRUCTOR_TRACE;}\n\nCLinkMatrixView::~CLinkMatrixView()\n{DESTRUCTOR_TRACE;}\n\nCLinkMatrixView &\nCLinkMatrixView::operator = (const CLinkMatrixView & rhs)\n{\n mpA = rhs.mpA;\n mpNumIndependent = rhs.mpNumIndependent;\n\n return *this;\n}\n\nsize_t CLinkMatrixView::numRows() const\n{\n return *mpNumIndependent + mpA->numRows();\n}\n\nsize_t CLinkMatrixView::numCols() const\n{\n return mpA->numCols();\n}\n\nstd::ostream &operator<<(std::ostream &os,\n const CLinkMatrixView & A)\n{\n size_t i, imax = A.numRows();\n size_t j, jmax = A.numCols();\n os << \"Matrix(\" << imax << \"x\" << jmax << \")\" << std::endl;\n\n for (i = 0; i < imax; i++)\n {\n for (j = 0; j < jmax; j++)\n os << \"\\t\" << A(i, j);\n\n os << std::endl;\n }\n\n return os;\n}\n<|endoftext|>"} {"text":"\/\/ Copyright (C) 2015 Elviss Strazdins\n\/\/ This file is part of the Ouzel engine.\n\n#include \"Application.h\"\n#include \n\nusing namespace std;\n\nnamespace ouzel\n{ \n Application::~Application()\n {\n Engine::getInstance()->getEventDispatcher()->removeEventHandler(_eventHandler);\n }\n \n Settings Application::getSettings()\n {\n Settings settings;\n settings.size = ouzel::Size2(800.0f, 600.0f);\n settings.resizable = true;\n \n return settings;\n }\n \n void Application::begin()\n {\n _eventHandler = make_shared();\n \n _eventHandler->keyDownHandler = std::bind(&Application::handleKeyDown, this, std::placeholders::_1, std::placeholders::_2);\n _eventHandler->mouseMoveHandler = std::bind(&Application::handleMouseMove, this, std::placeholders::_1, std::placeholders::_2);\n _eventHandler->touchBeginHandler = std::bind(&Application::handleTouch, this, std::placeholders::_1, std::placeholders::_2);\n _eventHandler->touchMoveHandler = std::bind(&Application::handleTouch, this, std::placeholders::_1, std::placeholders::_2);\n _eventHandler->touchEndHandler = std::bind(&Application::handleTouch, this, std::placeholders::_1, std::placeholders::_2);\n _eventHandler->gamepadButtonChangeHandler = std::bind(&Application::handleGamepadButtonChange, this, std::placeholders::_1, std::placeholders::_2);\n \n Engine::getInstance()->getEventDispatcher()->addEventHandler(_eventHandler);\n \n Engine::getInstance()->getRenderer()->setClearColor(Color(64, 0, 0));\n Engine::getInstance()->getRenderer()->setTitle(\"Sample\");\n \n ScenePtr scene = make_shared();\n Engine::getInstance()->getSceneManager()->setScene(scene);\n \n _layer = make_shared();\n scene->addLayer(_layer);\n \n _uiLayer = make_shared();\n scene->addLayer(_uiLayer);\n \n DrawNodePtr drawNode = std::make_shared();\n drawNode->rectangle(Rectangle(100.0f, 100.0f), Color(0, 128, 128, 255), true);\n drawNode->rectangle(Rectangle(100.0f, 100.0f), Color(255, 255, 255, 255), false);\n drawNode->line(Vector2(0.0f, 0.0f), Vector2(50.0f, 50.0f), Color(0, 255, 255, 255));\n drawNode->point(Vector2(75.0f, 75.0f), Color(255, 0, 0, 255));\n \n drawNode->circle(Vector2(75.0f, 75.0f), 20.0f, Color(0, 0, 255, 255));\n drawNode->circle(Vector2(25.0f, 75.0f), 20.0f, Color(0, 0, 255, 255), true);\n \n drawNode->setPosition(Vector2(-300, 0.0f));\n _layer->addChild(drawNode);\n \n _sprite = make_shared();\n _sprite->initFromFile(\"run.json\");\n _sprite->play(true);\n _layer->addChild(_sprite);\n _sprite->setPosition(Vector2(-300.0f, 0.0f));\n\n std::vector sequence = {\n make_shared(4.0f, Vector2(300.0f, 0.0f)),\n make_shared(2.0f, 0.4f)\n };\n\n _sprite->animate(make_shared(sequence));\n \n SpritePtr fire = make_shared();\n fire->initFromFile(\"fire.json\");\n fire->play(true);\n fire->setPosition(Vector2(-100.0f, -100.0f));\n _layer->addChild(fire);\n fire->animate(make_shared(5.0f, 0.5f));\n \n _flame = make_shared();\n _flame->initFromFile(\"flame.json\");\n _layer->addChild(_flame);\n \n _witch = make_shared();\n _witch->initFromFile(\"witch.png\");\n _witch->setPosition(Vector2(100.0f, 100.0f));\n _witch->setColor(Color(128, 0, 255, 255));\n _layer->addChild(_witch);\n _witch->animate(make_shared(make_shared(1.0f, TAU), 3));\n \n LabelPtr label = make_shared