text
stringlengths
5
1.04M
///////////////////////////////////////////////////////////////////////////// // Name: src/common/rgncmn.cpp // Purpose: Methods of wxRegion that have a generic implementation // Author: Robin Dunn // Modified by: // Created: 27-Mar-2003 // RCS-ID: $Id$ // Copyright: (c) Robin Dunn // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ============================================================================ // declarations // ============================================================================ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #include "wx/region.h" #ifndef WX_PRECOMP #include "wx/dcmemory.h" #include "wx/bitmap.h" #include "wx/image.h" #endif //WX_PRECOMP // ============================================================================ // wxRegionBase implementation // ============================================================================ // ---------------------------------------------------------------------------- // region comparison // ---------------------------------------------------------------------------- bool wxRegionBase::IsEqual(const wxRegion& region) const { if ( m_refData == region.GetRefData() ) { // regions are identical, hence equal return true; } if ( !m_refData || !region.GetRefData() ) { // one, but not both, of the regions is invalid return false; } return DoIsEqual(region); } // ---------------------------------------------------------------------------- // region to/from bitmap conversions // ---------------------------------------------------------------------------- wxBitmap wxRegionBase::ConvertToBitmap() const { wxRect box = GetBox(); wxBitmap bmp(box.GetRight() + 1, box.GetBottom() + 1); wxMemoryDC dc; dc.SelectObject(bmp); dc.SetBackground(*wxBLACK_BRUSH); dc.Clear(); dc.SetDeviceClippingRegion(*static_cast<const wxRegion *>(this)); dc.SetBackground(*wxWHITE_BRUSH); dc.Clear(); dc.SelectObject(wxNullBitmap); return bmp; } #if wxUSE_IMAGE static bool DoRegionUnion(wxRegionBase& region, const wxImage& image, unsigned char loR, unsigned char loG, unsigned char loB, int tolerance) { unsigned char hiR, hiG, hiB; hiR = (unsigned char)wxMin(0xFF, loR + tolerance); hiG = (unsigned char)wxMin(0xFF, loG + tolerance); hiB = (unsigned char)wxMin(0xFF, loB + tolerance); // Loop through the image row by row, pixel by pixel, building up // rectangles to add to the region. int width = image.GetWidth(); int height = image.GetHeight(); for (int y=0; y < height; y++) { wxRect rect; rect.y = y; rect.height = 1; for (int x=0; x < width; x++) { // search for a continuous range of non-transparent pixels int x0 = x; while ( x < width) { unsigned char R = image.GetRed(x,y); unsigned char G = image.GetGreen(x,y); unsigned char B = image.GetBlue(x,y); if (( R >= loR && R <= hiR) && ( G >= loG && G <= hiG) && ( B >= loB && B <= hiB)) // It's transparent break; x++; } // Add the run of non-transparent pixels (if any) to the region if (x > x0) { rect.x = x0; rect.width = x - x0; region.Union(rect); } } } return true; } bool wxRegionBase::Union(const wxBitmap& bmp) { if (bmp.GetMask()) { wxImage image = bmp.ConvertToImage(); wxASSERT_MSG( image.HasMask(), wxT("wxBitmap::ConvertToImage doesn't preserve mask?") ); return DoRegionUnion(*this, image, image.GetMaskRed(), image.GetMaskGreen(), image.GetMaskBlue(), 0); } else { return Union(0, 0, bmp.GetWidth(), bmp.GetHeight()); } } bool wxRegionBase::Union(const wxBitmap& bmp, const wxColour& transColour, int tolerance) { wxImage image = bmp.ConvertToImage(); return DoRegionUnion(*this, image, transColour.Red(), transColour.Green(), transColour.Blue(), tolerance); } #endif // wxUSE_IMAGE #ifdef wxHAS_REGION_COMBINE // ============================================================================ // wxRegionWithCombine // ============================================================================ // implement some wxRegionBase pure virtuals in terms of Combine() bool wxRegionWithCombine::DoUnionWithRect(const wxRect& rect) { return Combine(rect, wxRGN_OR); } bool wxRegionWithCombine::DoUnionWithRegion(const wxRegion& region) { return DoCombine(region, wxRGN_OR); } bool wxRegionWithCombine::DoIntersect(const wxRegion& region) { return DoCombine(region, wxRGN_AND); } bool wxRegionWithCombine::DoSubtract(const wxRegion& region) { return DoCombine(region, wxRGN_DIFF); } bool wxRegionWithCombine::DoXor(const wxRegion& region) { return DoCombine(region, wxRGN_XOR); } #endif // wxHAS_REGION_COMBINE
/*** Copyright (c), The Regents of the University of California *** *** For more information please refer to files in the COPYRIGHT directory ***/ /* definitions for osauth routines */ #ifdef __cplusplus extern "C" { #endif #define OS_AUTH_FLAG "##OS_AUTH" #define OS_AUTH_CMD "genOSAuth" #define OS_AUTH_ENV_USER "OSAUTH_USERNAME" int osauthGetAuth( char *challenge, char *username, char *authenticator, int authenticator_buflen ); int osauthVerifyResponse( char *challenge, char *username, char *response ); int osauthGetKey( char **key, int *key_len ); int osauthGetUid( char *username ); int osauthGetUsername( char *username, int username_len ); int osauthGenerateAuthenticator( char *username, int uid, char *challenge, char *key, int key_len, char *authenticator, int authenticator_len ); #ifdef __cplusplus } #endif
// generate_table.cpp // // Copyright (c) 2009 // Steven Watanabe // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include <vector> #include <utility> #include <iostream> #include <cstring> #include <fstream> #include <boost/regex.hpp> #include <boost/tuple/tuple.hpp> #include <boost/lexical_cast.hpp> #include <boost/foreach.hpp> #include <boost/format.hpp> #include <boost/multi_index_container.hpp> #include <boost/multi_index/hashed_index.hpp> #include <boost/multi_index/sequenced_index.hpp> boost::regex generator_regex("(?:fixed-range )?([^:]+): (\\d+(?:\\.\\d+)?) nsec/loop = \\d+(?:\\.\\d+)? CPU cycles"); boost::regex distribution_regex("([^\\s]+)( virtual function)? ([^:]+): (\\d+(?:\\.\\d+)?) nsec/loop = \\d+(?:\\.\\d+)? CPU cycles"); std::string template_name(std::string arg) { return boost::regex_replace(arg, boost::regex("[^\\w]"), "_"); } struct compare_second { template<class Pair> bool operator()(const Pair& p1, const Pair& p2) const { return (p1.second < p2.second); } }; typedef boost::multi_index_container< std::string, boost::mpl::vector< boost::multi_index::sequenced<>, boost::multi_index::hashed_unique<boost::multi_index::identity<std::string> > > > unique_list; int main() { std::vector<std::pair<std::string, double> > generator_info; std::string line; while(std::getline(std::cin, line)) { boost::smatch match; if(std::strncmp(line.c_str(), "counting ", 9) == 0) break; if(boost::regex_match(line, match, generator_regex)) { std::string generator(match[1]); double time = boost::lexical_cast<double>(match[2]); if(generator != "counting") { generator_info.push_back(std::make_pair(generator, time)); } } else { std::cerr << "oops: " << line << std::endl; } } double min = std::min_element(generator_info.begin(), generator_info.end(), compare_second())->second; std::ofstream generator_defs("performance_data.qbk"); std::ofstream generator_performance("generator_performance.qbk"); generator_performance << "[table Basic Generators\n"; generator_performance << " [[generator] [M rn/sec] [time per random number \\[nsec\\]] " "[relative speed compared to fastest \\[percent\\]]]\n"; typedef std::pair<std::string, double> pair_type; BOOST_FOREACH(const pair_type& pair, generator_info) { generator_defs << boost::format("[template %s_speed[] %d%%]\n") % template_name(pair.first) % static_cast<int>(100*min/pair.second); generator_performance << boost::format(" [[%s][%g][%g][%d%%]]\n") % pair.first % (1000/pair.second) % pair.second % static_cast<int>(100*min/pair.second); } generator_performance << "]\n"; std::map<std::pair<std::string, std::string>, double> distribution_info; unique_list generator_names; unique_list distribution_names; do { boost::smatch match; if(boost::regex_match(line, match, distribution_regex)) { if(!match[2].matched && match[1] != "counting") { std::string generator(match[1]); std::string distribution(match[3]); double time = boost::lexical_cast<double>(match[4]); generator_names.push_back(generator); distribution_names.push_back(distribution); distribution_info.insert(std::make_pair(std::make_pair(distribution, generator), time)); } } else { std::cerr << "oops: " << line << std::endl; } } while(std::getline(std::cin, line)); std::ofstream distribution_performance("distribution_performance.qbk"); distribution_performance << "[table Distributions\n"; distribution_performance << " [[\\[M rn/sec\\]]"; BOOST_FOREACH(const std::string& generator, generator_names) { distribution_performance << boost::format("[%s]") % generator; } distribution_performance << "]\n"; BOOST_FOREACH(const std::string& distribution, distribution_names) { distribution_performance << boost::format(" [[%s]") % distribution; BOOST_FOREACH(const std::string& generator, generator_names) { std::map<std::pair<std::string, std::string>, double>::iterator pos = distribution_info.find(std::make_pair(distribution, generator)); if(pos != distribution_info.end()) { distribution_performance << boost::format("[%g]") % (1000/pos->second); } else { distribution_performance << "[-]"; } } distribution_performance << "]\n"; } distribution_performance << "]\n"; }
#include <array> #include <string> #include <pybind11/pybind11.h> #include <pybind11/stl.h> #include <pybind11/operators.h> #include <ruckig/ruckig.hpp> #ifdef WITH_REFLEXXES #include <ruckig/reflexxes_comparison.hpp> #endif namespace py = pybind11; using namespace pybind11::literals; // to bring in the `_a` literal using namespace ruckig; PYBIND11_MODULE(ruckig, m) { m.doc() = "Instantaneous Motion Generation for Robots and Machines. Real-time and time-optimal trajectory calculation \ given a target waypoint with position, velocity, and acceleration, starting from any initial state \ limited by velocity, acceleration, and jerk constraints."; py::enum_<ControlInterface>(m, "ControlInterface") .value("Position", ControlInterface::Position) .value("Velocity", ControlInterface::Velocity) .export_values(); py::enum_<Synchronization>(m, "Synchronization") .value("Phase", Synchronization::Phase) .value("Time", Synchronization::Time) .value("TimeIfNecessary", Synchronization::TimeIfNecessary) .value("No", Synchronization::None) .export_values(); py::enum_<DurationDiscretization>(m, "DurationDiscretization") .value("Continuous", DurationDiscretization::Continuous) .value("Discrete", DurationDiscretization::Discrete) .export_values(); py::enum_<Result>(m, "Result", py::arithmetic()) .value("Working", Result::Working) .value("Finished", Result::Finished) .value("Error", Result::Error) .value("ErrorInvalidInput", Result::ErrorInvalidInput) .value("ErrorPositionalLimits", Result::ErrorPositionalLimits) .value("ErrorExecutionTimeCalculation", Result::ErrorExecutionTimeCalculation) .value("ErrorSynchronizationCalculation", Result::ErrorSynchronizationCalculation) .export_values(); py::class_<PositionExtrema>(m, "PositionExtrema") .def_readonly("min", &PositionExtrema::min) .def_readonly("max", &PositionExtrema::max) .def_readonly("t_min", &PositionExtrema::t_min) .def_readonly("t_max", &PositionExtrema::t_max) .def("__repr__", [](const PositionExtrema& ext) { return "[" + std::to_string(ext.min) + ", " + std::to_string(ext.max) + "]"; }); py::class_<Trajectory<DynamicDOFs>>(m, "Trajectory") .def(py::init<size_t>(), "dofs"_a) .def_readonly("degrees_of_freedom", &Trajectory<DynamicDOFs>::degrees_of_freedom) .def_property_readonly("duration", &Trajectory<DynamicDOFs>::get_duration) .def_property_readonly("intermediate_durations", &Trajectory<DynamicDOFs>::get_intermediate_durations) .def_property_readonly("independent_min_durations", &Trajectory<DynamicDOFs>::get_independent_min_durations) .def_property_readonly("position_extrema", &Trajectory<DynamicDOFs>::get_position_extrema) .def("at_time", [](const Trajectory<DynamicDOFs>& traj, double time, bool return_section=false) { std::vector<double> new_position(traj.degrees_of_freedom), new_velocity(traj.degrees_of_freedom), new_acceleration(traj.degrees_of_freedom); size_t new_section; traj.at_time(time, new_position, new_velocity, new_acceleration, new_section); if (return_section) { return py::make_tuple(new_position, new_velocity, new_acceleration, new_section); } return py::make_tuple(new_position, new_velocity, new_acceleration); }, "time"_a, "return_section"_a=false) .def("get_first_time_at_position", [](const Trajectory<DynamicDOFs>& traj, size_t dof, double position) -> py::object { double time; if (traj.get_first_time_at_position(dof, position, time)) { return py::cast(time); } return py::none(); }, "dof"_a, "position"_a); py::class_<InputParameter<DynamicDOFs>>(m, "InputParameter") .def(py::init<size_t>(), "dofs"_a) .def_readonly("degrees_of_freedom", &InputParameter<DynamicDOFs>::degrees_of_freedom) .def_readwrite("current_position", &InputParameter<DynamicDOFs>::current_position) .def_readwrite("current_velocity", &InputParameter<DynamicDOFs>::current_velocity) .def_readwrite("current_acceleration", &InputParameter<DynamicDOFs>::current_acceleration) .def_readwrite("target_position", &InputParameter<DynamicDOFs>::target_position) .def_readwrite("target_velocity", &InputParameter<DynamicDOFs>::target_velocity) .def_readwrite("target_acceleration", &InputParameter<DynamicDOFs>::target_acceleration) .def_readwrite("max_velocity", &InputParameter<DynamicDOFs>::max_velocity) .def_readwrite("max_acceleration", &InputParameter<DynamicDOFs>::max_acceleration) .def_readwrite("max_jerk", &InputParameter<DynamicDOFs>::max_jerk) .def_readwrite("min_velocity", &InputParameter<DynamicDOFs>::min_velocity) .def_readwrite("min_acceleration", &InputParameter<DynamicDOFs>::min_acceleration) .def_readwrite("intermediate_positions", &InputParameter<DynamicDOFs>::intermediate_positions) .def_readwrite("per_section_max_velocity", &InputParameter<DynamicDOFs>::per_section_max_velocity) .def_readwrite("per_section_max_acceleration", &InputParameter<DynamicDOFs>::per_section_max_acceleration) .def_readwrite("per_section_max_jerk", &InputParameter<DynamicDOFs>::per_section_max_jerk) .def_readwrite("per_section_min_velocity", &InputParameter<DynamicDOFs>::per_section_min_velocity) .def_readwrite("per_section_min_acceleration", &InputParameter<DynamicDOFs>::per_section_min_acceleration) .def_readwrite("max_position", &InputParameter<DynamicDOFs>::max_position) .def_readwrite("min_position", &InputParameter<DynamicDOFs>::min_position) .def_readwrite("enabled", &InputParameter<DynamicDOFs>::enabled) .def_readwrite("control_interface", &InputParameter<DynamicDOFs>::control_interface) .def_readwrite("synchronization", &InputParameter<DynamicDOFs>::synchronization) .def_readwrite("duration_discretization", &InputParameter<DynamicDOFs>::duration_discretization) .def_readwrite("per_dof_control_interface", &InputParameter<DynamicDOFs>::per_dof_control_interface) .def_readwrite("per_dof_synchronization", &InputParameter<DynamicDOFs>::per_dof_synchronization) .def_readwrite("minimum_duration", &InputParameter<DynamicDOFs>::minimum_duration) .def_readwrite("interrupt_calculation_duration", &InputParameter<DynamicDOFs>::interrupt_calculation_duration) .def(py::self != py::self) .def("__repr__", &InputParameter<DynamicDOFs>::to_string); py::class_<OutputParameter<DynamicDOFs>>(m, "OutputParameter") .def(py::init<size_t>(), "dofs"_a) .def_readonly("degrees_of_freedom", &OutputParameter<DynamicDOFs>::degrees_of_freedom) .def_readonly("new_position", &OutputParameter<DynamicDOFs>::new_position) .def_readonly("new_velocity", &OutputParameter<DynamicDOFs>::new_velocity) .def_readonly("new_acceleration", &OutputParameter<DynamicDOFs>::new_acceleration) .def_readonly("new_section", &OutputParameter<DynamicDOFs>::new_section) .def_readonly("did_section_change", &OutputParameter<DynamicDOFs>::did_section_change) .def_readonly("trajectory", &OutputParameter<DynamicDOFs>::trajectory) .def_readonly("time", &OutputParameter<DynamicDOFs>::time) .def_readonly("new_calculation", &OutputParameter<DynamicDOFs>::new_calculation) .def_readonly("was_calculation_interrupted", &OutputParameter<DynamicDOFs>::was_calculation_interrupted) .def_readonly("calculation_duration", &OutputParameter<DynamicDOFs>::calculation_duration) .def("pass_to_input", &OutputParameter<DynamicDOFs>::pass_to_input, "input"_a) .def("__repr__", &OutputParameter<DynamicDOFs>::to_string) .def("__copy__", [](const OutputParameter<DynamicDOFs> &self) { return OutputParameter<DynamicDOFs>(self); }); py::class_<Ruckig<DynamicDOFs, true>>(m, "Ruckig") .def(py::init<size_t>(), "dofs"_a) .def(py::init<size_t, double>(), "dofs"_a, "delta_time"_a) .def_readonly("delta_time", &Ruckig<DynamicDOFs, true>::delta_time) .def_readonly("degrees_of_freedom", &Ruckig<DynamicDOFs, true>::degrees_of_freedom) .def("validate_input", &Ruckig<DynamicDOFs, true>::validate_input, "input"_a, "check_current_state_within_limits"_a=false, "check_target_state_within_limits"_a=true) .def("calculate", static_cast<Result (Ruckig<DynamicDOFs, true>::*)(const InputParameter<DynamicDOFs>&, Trajectory<DynamicDOFs>&)>(&Ruckig<DynamicDOFs, true>::calculate), "input"_a, "trajectory"_a) .def("calculate", static_cast<Result (Ruckig<DynamicDOFs, true>::*)(const InputParameter<DynamicDOFs>&, Trajectory<DynamicDOFs>&, bool&)>(&Ruckig<DynamicDOFs, true>::calculate), "input"_a, "trajectory"_a, "was_interrupted"_a) .def("update", &Ruckig<DynamicDOFs, true>::update, "input"_a, "output"_a); #ifdef WITH_REFLEXXES py::class_<Reflexxes<DynamicDOFs>>(m, "Reflexxes") .def(py::init<size_t, double>(), "dofs"_a, "delta_time"_a) .def_readonly("degrees_of_freedom", &Reflexxes<DynamicDOFs>::degrees_of_freedom) .def_readonly("delta_time", &Reflexxes<DynamicDOFs>::delta_time) .def("update", &Reflexxes<DynamicDOFs>::update); #endif }
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <fidl/fuchsia.input.report/cpp/wire.h> #include <lib/async-loop/cpp/loop.h> #include <lib/async-loop/default.h> #include <lib/ddk/device.h> #include <lib/fidl-async/cpp/bind.h> #include <lib/sync/completion.h> #include <string> #include <vector> #include <fbl/auto_lock.h> #include <fbl/mutex.h> #include <gtest/gtest.h> #include <hid/usages.h> #include "fuchsia/input/report/cpp/fidl.h" #include "src/ui/input/testing/fake_input_report_device/fake.h" #include "src/ui/tools/print-input-report/devices.h" #include "src/ui/tools/print-input-report/printer.h" namespace test { namespace fuchsia_input_report = fuchsia_input_report; class FakePrinter : public print_input_report::Printer { public: void RealPrint(const char* format, va_list argptr) override { char buf[kMaxBufLen]; vsprintf(buf, format, argptr); ASSERT_LT(current_string_index_, expected_strings_.size()); const std::string& expected = expected_strings_[current_string_index_]; current_string_index_++; // Check that we match the expected string. ASSERT_GT(expected.size(), indent_); int cmp = strcmp(buf, expected.c_str()); if (cmp != 0) { printf("Wanted string: '%s'\n", expected.c_str()); printf("Saw string: '%s'\n", buf); ASSERT_TRUE(false); } // Print the string for easy debugging. vprintf(format, argptr); va_end(argptr); } void SetExpectedStrings(const std::vector<std::string>& strings) { current_string_index_ = 0; expected_strings_ = strings; } void AssertSawAllStrings() { ASSERT_EQ(current_string_index_, expected_strings_.size()); } private: static constexpr size_t kMaxBufLen = 1024; size_t current_string_index_ = 0; std::vector<std::string> expected_strings_; }; class PrintInputReport : public testing::Test { protected: virtual void SetUp() { // Make the channels and the fake device. zx::channel token_server, token_client; ASSERT_EQ(zx::channel::create(0, &token_server, &token_client), ZX_OK); loop_ = std::make_unique<async::Loop>(&kAsyncLoopConfigAttachToCurrentThread); fake_device_ = std::make_unique<fake_input_report_device::FakeInputDevice>( fidl::InterfaceRequest<fuchsia::input::report::InputDevice>(std::move(token_server)), loop_->dispatcher()); client_.emplace(fidl::ClientEnd<fuchsia_input_report::InputDevice>(std::move(token_client)), loop_->dispatcher()); } virtual void TearDown() { loop_->Quit(); } std::unique_ptr<fake_input_report_device::FakeInputDevice> fake_device_; std::unique_ptr<async::Loop> loop_; std::optional<fidl::WireSharedClient<fuchsia_input_report::InputDevice>> client_; }; TEST_F(PrintInputReport, PrintMouseInputReport) { fuchsia::input::report::InputReport report; report.mutable_mouse()->set_movement_x(100); report.mutable_mouse()->set_movement_y(200); report.mutable_mouse()->set_position_x(300); report.mutable_mouse()->set_position_y(400); report.mutable_mouse()->set_scroll_v(100); report.mutable_mouse()->set_pressed_buttons({1, 10, 5}); std::vector<fuchsia::input::report::InputReport> reports; reports.push_back(std::move(report)); fake_device_->SetReports(std::move(reports)); FakePrinter printer; printer.SetExpectedStrings(std::vector<std::string>{ "Report from file: test\n", "Movement x: 00000100\n", "Movement y: 00000200\n", "Position x: 00000300\n", "Position y: 00000400\n", "Scroll v: 00000100\n", "Button 01 pressed\n", "Button 10 pressed\n", "Button 05 pressed\n", "\n", }); auto res = print_input_report::GetReaderClient(&client_.value(), loop_->dispatcher()); ASSERT_EQ(res.status_value(), ZX_OK); auto reader = std::move(res.value()); print_input_report::PrintInputReports("test", &printer, std::move(reader), 1); loop_->RunUntilIdle(); printer.AssertSawAllStrings(); } TEST_F(PrintInputReport, PrintMouseGetInputReport) { fuchsia::input::report::InputReport report; report.mutable_mouse()->set_movement_x(100); report.mutable_mouse()->set_movement_y(200); report.mutable_mouse()->set_position_x(300); report.mutable_mouse()->set_position_y(400); report.mutable_mouse()->set_scroll_v(100); report.mutable_mouse()->set_pressed_buttons({1, 10, 5}); std::vector<fuchsia::input::report::InputReport> reports; reports.push_back(std::move(report)); fake_device_->SetReports(std::move(reports)); FakePrinter printer; printer.SetExpectedStrings(std::vector<std::string>{ "Report from file: test\n", "Movement x: 00000100\n", "Movement y: 00000200\n", "Position x: 00000300\n", "Position y: 00000400\n", "Scroll v: 00000100\n", "Button 01 pressed\n", "Button 10 pressed\n", "Button 05 pressed\n", "\n", }); print_input_report::GetAndPrintInputReport("test", fuchsia_input_report::wire::DeviceType::kMouse, &printer, std::move(*client_)); loop_->RunUntilIdle(); printer.AssertSawAllStrings(); } TEST_F(PrintInputReport, PrintMouseInputDescriptor) { auto descriptor = std::make_unique<fuchsia::input::report::DeviceDescriptor>(); auto mouse = descriptor->mutable_mouse()->mutable_input(); fuchsia::input::report::Axis axis; axis.unit.type = fuchsia::input::report::UnitType::METERS; axis.unit.exponent = 0; axis.range.min = -100; axis.range.max = -100; mouse->set_movement_x(axis); axis.unit.type = fuchsia::input::report::UnitType::NONE; axis.range.min = -200; axis.range.max = -200; mouse->set_movement_y(axis); axis.range.min = 300; axis.range.max = 300; mouse->set_position_x(axis); axis.range.min = 400; axis.range.max = 400; mouse->set_position_y(axis); mouse->set_buttons({1, 10, 5}); fake_device_->SetDescriptor(std::move(descriptor)); FakePrinter printer; printer.SetExpectedStrings(std::vector<std::string>{ "Descriptor from file: test\n", "Mouse Descriptor:\n", " Movement X:\n", " Unit: METERS\n", " Min: -100\n", " Max: -100\n", " Movement Y:\n", " Unit: NONE\n", " Min: -200\n", " Max: -200\n", " Position X:\n", " Unit: NONE\n", " Min: 300\n", " Max: 300\n", " Position Y:\n", " Unit: NONE\n", " Min: 400\n", " Max: 400\n", " Button: 1\n", " Button: 10\n", " Button: 5\n", }); print_input_report::PrintInputDescriptor(std::string("test"), &printer, std::move(*client_)); loop_->RunUntilIdle(); printer.AssertSawAllStrings(); } TEST_F(PrintInputReport, PrintSensorInputDescriptor) { auto descriptor = std::make_unique<fuchsia::input::report::DeviceDescriptor>(); descriptor->mutable_sensor()->mutable_input()->emplace_back(); auto values = descriptor->mutable_sensor()->mutable_input()->back().mutable_values(); fuchsia::input::report::SensorAxis axis; axis.axis.unit.type = fuchsia::input::report::UnitType::SI_LINEAR_VELOCITY; axis.axis.unit.exponent = 0; axis.axis.range.min = 0; axis.axis.range.max = 1000; axis.type = fuchsia::input::report::SensorType::ACCELEROMETER_X; values->push_back(axis); axis.axis.unit.type = fuchsia::input::report::UnitType::LUX; axis.type = fuchsia::input::report::SensorType::LIGHT_ILLUMINANCE; values->push_back(axis); fake_device_->SetDescriptor(std::move(descriptor)); FakePrinter printer; printer.SetExpectedStrings(std::vector<std::string>{ "Descriptor from file: test\n", "Sensor Descriptor:\n", " Value 00:\n", " SensorType: ACCELEROMETER_X\n", " Unit: SI_LINEAR_VELOCITY\n", " Min: 0\n", " Max: 1000\n", " Value 01:\n", " SensorType: LIGHT_ILLUMINANCE\n", " Unit: LUX\n", " Min: 0\n", " Max: 1000\n", }); print_input_report::PrintInputDescriptor(std::string("test"), &printer, std::move(*client_)); loop_->RunUntilIdle(); } TEST_F(PrintInputReport, PrintSensorInputReport) { fuchsia::input::report::InputReport report; report.mutable_sensor()->set_values({100, -100}); std::vector<fuchsia::input::report::InputReport> reports; reports.push_back(std::move(report)); fake_device_->SetReports(std::move(reports)); FakePrinter printer; printer.SetExpectedStrings(std::vector<std::string>{ "Report from file: test\n", "Sensor[00]: 00000100\n", "Sensor[01]: -0000100\n", "\n", }); auto res = print_input_report::GetReaderClient(&client_.value(), loop_->dispatcher()); ASSERT_EQ(res.status_value(), ZX_OK); auto reader = std::move(res.value()); print_input_report::PrintInputReports("test", &printer, std::move(reader), 1); loop_->RunUntilIdle(); printer.AssertSawAllStrings(); } TEST_F(PrintInputReport, PrintSensorGetInputReport) { fuchsia::input::report::InputReport report; report.mutable_sensor()->set_values({100, -100}); std::vector<fuchsia::input::report::InputReport> reports; reports.push_back(std::move(report)); fake_device_->SetReports(std::move(reports)); FakePrinter printer; printer.SetExpectedStrings(std::vector<std::string>{ "Report from file: test\n", "Sensor[00]: 00000100\n", "Sensor[01]: -0000100\n", "\n", }); print_input_report::GetAndPrintInputReport( "test", fuchsia_input_report::wire::DeviceType::kSensor, &printer, std::move(*client_)); loop_->RunUntilIdle(); printer.AssertSawAllStrings(); } TEST_F(PrintInputReport, PrintTouchInputDescriptor) { auto descriptor = std::make_unique<fuchsia::input::report::DeviceDescriptor>(); auto touch = descriptor->mutable_touch()->mutable_input(); touch->set_touch_type(fuchsia::input::report::TouchType::TOUCHSCREEN); touch->set_max_contacts(100); fuchsia::input::report::Axis axis; axis.unit.type = fuchsia::input::report::UnitType::NONE; axis.unit.exponent = 0; axis.range.min = 0; axis.range.max = 300; fuchsia::input::report::ContactInputDescriptor contact; contact.set_position_x(axis); axis.range.max = 500; contact.set_position_y(axis); axis.range.max = 100; contact.set_pressure(axis); touch->mutable_contacts()->push_back(std::move(contact)); descriptor->mutable_touch()->mutable_feature()->set_supports_input_mode(true); descriptor->mutable_touch()->mutable_feature()->set_supports_selective_reporting(true); fake_device_->SetDescriptor(std::move(descriptor)); FakePrinter printer; printer.SetExpectedStrings(std::vector<std::string>{ "Descriptor from file: test\n", "Touch Descriptor:\n", " Input Report:\n", " Touch Type: TOUCHSCREEN\n", " Max Contacts: 100\n", " Contact: 00\n", " Position X:\n", " Unit: NONE\n", " Min: 0\n", " Max: 300\n", " Position Y:\n", " Unit: NONE\n", " Min: 0\n", " Max: 500\n", " Pressure:\n", " Unit: NONE\n", " Min: 0\n", " Max: 100\n", " Feature Report:\n", " Supports InputMode: 1\n", " Supports SelectiveReporting: 1\n", }); print_input_report::PrintInputDescriptor(std::string("test"), &printer, std::move(*client_)); loop_->RunUntilIdle(); } TEST_F(PrintInputReport, PrintTouchInputReport) { fuchsia::input::report::InputReport report; fuchsia::input::report::ContactInputReport contact; contact.set_contact_id(10); contact.set_position_x(123); contact.set_position_y(234); contact.set_pressure(345); contact.set_contact_width(678); contact.set_contact_height(789); report.mutable_touch()->mutable_contacts()->push_back(std::move(contact)); std::vector<fuchsia::input::report::InputReport> reports; reports.push_back(std::move(report)); fake_device_->SetReports(std::move(reports)); FakePrinter printer; printer.SetExpectedStrings(std::vector<std::string>{ "Report from file: test\n", "Contact ID: 10\n", " Position X: 00000123\n", " Position Y: 00000234\n", " Pressure: 00000345\n", " Contact Width: 00000678\n", " Contact Height: 00000789\n", "\n", }); auto res = print_input_report::GetReaderClient(&client_.value(), loop_->dispatcher()); ASSERT_EQ(res.status_value(), ZX_OK); auto reader = std::move(res.value()); print_input_report::PrintInputReports("test", &printer, std::move(reader), 1); loop_->RunUntilIdle(); printer.AssertSawAllStrings(); } TEST_F(PrintInputReport, PrintTouchGetInputReport) { fuchsia::input::report::InputReport report; fuchsia::input::report::ContactInputReport contact; contact.set_contact_id(10); contact.set_position_x(123); contact.set_position_y(234); contact.set_pressure(345); contact.set_contact_width(678); contact.set_contact_height(789); report.mutable_touch()->mutable_contacts()->push_back(std::move(contact)); std::vector<fuchsia::input::report::InputReport> reports; reports.push_back(std::move(report)); fake_device_->SetReports(std::move(reports)); FakePrinter printer; printer.SetExpectedStrings(std::vector<std::string>{ "Report from file: test\n", "Contact ID: 10\n", " Position X: 00000123\n", " Position Y: 00000234\n", " Pressure: 00000345\n", " Contact Width: 00000678\n", " Contact Height: 00000789\n", "\n", }); print_input_report::GetAndPrintInputReport("test", fuchsia_input_report::wire::DeviceType::kTouch, &printer, std::move(*client_)); loop_->RunUntilIdle(); printer.AssertSawAllStrings(); } TEST_F(PrintInputReport, PrintKeyboardDescriptor) { auto descriptor = std::make_unique<fuchsia::input::report::DeviceDescriptor>(); descriptor->mutable_keyboard()->mutable_input()->set_keys3( {fuchsia::input::Key::A, fuchsia::input::Key::UP, fuchsia::input::Key::LEFT_SHIFT}); descriptor->mutable_keyboard()->mutable_output()->set_leds( {fuchsia::input::report::LedType::CAPS_LOCK, fuchsia::input::report::LedType::SCROLL_LOCK}); fake_device_->SetDescriptor(std::move(descriptor)); FakePrinter printer; printer.SetExpectedStrings(std::vector<std::string>{ "Descriptor from file: test\n", "Keyboard Descriptor:\n", "Input Report:\n", " Key: 458756\n", // 0x70004 " Key: 458834\n", // 0x70052 " Key: 458977\n", // 0x700e1 "Output Report:\n", " Led: CAPS_LOCK\n", " Led: SCROLL_LOCK\n", }); print_input_report::PrintInputDescriptor(std::string("test"), &printer, std::move(*client_)); loop_->RunUntilIdle(); } TEST_F(PrintInputReport, PrintKeyboardInputReport) { fuchsia::input::report::InputReport report; report.mutable_keyboard()->set_pressed_keys3( {fuchsia::input::Key::A, fuchsia::input::Key::UP, fuchsia::input::Key::LEFT_SHIFT}); std::vector<fuchsia::input::report::InputReport> reports; reports.push_back(std::move(report)); fake_device_->SetReports(std::move(reports)); FakePrinter printer; printer.SetExpectedStrings(std::vector<std::string>{ "Report from file: test\n", "Keyboard Report\n", " Key: 458756\n", // 0x70004 " Key: 458834\n", // 0x70052 " Key: 458977\n", // 0x700e1 "\n", }); auto res = print_input_report::GetReaderClient(&client_.value(), loop_->dispatcher()); ASSERT_EQ(res.status_value(), ZX_OK); auto reader = std::move(res.value()); print_input_report::PrintInputReports("test", &printer, std::move(reader), 1); loop_->RunUntilIdle(); printer.AssertSawAllStrings(); } TEST_F(PrintInputReport, PrintKeyboardGetInputReport) { fuchsia::input::report::InputReport report; report.mutable_keyboard()->set_pressed_keys3( {fuchsia::input::Key::A, fuchsia::input::Key::UP, fuchsia::input::Key::LEFT_SHIFT}); std::vector<fuchsia::input::report::InputReport> reports; reports.push_back(std::move(report)); fake_device_->SetReports(std::move(reports)); FakePrinter printer; printer.SetExpectedStrings(std::vector<std::string>{ "Report from file: test\n", "Keyboard Report\n", " Key: 458756\n", // 0x70004 " Key: 458834\n", // 0x70052 " Key: 458977\n", // 0x700e1 "\n", }); print_input_report::GetAndPrintInputReport( "test", fuchsia_input_report::wire::DeviceType::kKeyboard, &printer, std::move(*client_)); loop_->RunUntilIdle(); printer.AssertSawAllStrings(); } TEST_F(PrintInputReport, PrintKeyboardInputReportNoKeys) { fuchsia::input::report::InputReport report; report.mutable_keyboard()->set_pressed_keys3({}); std::vector<fuchsia::input::report::InputReport> reports; reports.push_back(std::move(report)); fake_device_->SetReports(std::move(reports)); FakePrinter printer; printer.SetExpectedStrings(std::vector<std::string>{ "Report from file: test\n", "Keyboard Report\n", " No keys pressed\n", "\n", }); auto res = print_input_report::GetReaderClient(&client_.value(), loop_->dispatcher()); ASSERT_EQ(res.status_value(), ZX_OK); auto reader = std::move(res.value()); print_input_report::PrintInputReports("test", &printer, std::move(reader), 1); loop_->RunUntilIdle(); printer.AssertSawAllStrings(); } TEST_F(PrintInputReport, PrintConsumerControlDescriptor) { auto descriptor = std::make_unique<fuchsia::input::report::DeviceDescriptor>(); descriptor->mutable_consumer_control()->mutable_input()->set_buttons( {fuchsia::input::report::ConsumerControlButton::VOLUME_UP, fuchsia::input::report::ConsumerControlButton::VOLUME_DOWN, fuchsia::input::report::ConsumerControlButton::FACTORY_RESET}); fake_device_->SetDescriptor(std::move(descriptor)); FakePrinter printer; printer.SetExpectedStrings(std::vector<std::string>{ "Descriptor from file: test\n", "ConsumerControl Descriptor:\n", "Input Report:\n", " Button: VOLUME_UP\n", " Button: VOLUME_DOWN\n", " Button: FACTORY_RESET\n", }); print_input_report::PrintInputDescriptor(std::string("test"), &printer, std::move(*client_)); loop_->RunUntilIdle(); printer.AssertSawAllStrings(); } TEST_F(PrintInputReport, PrintConsumerControlReport) { fuchsia::input::report::InputReport report; report.mutable_consumer_control()->set_pressed_buttons( {fuchsia::input::report::ConsumerControlButton::VOLUME_UP, fuchsia::input::report::ConsumerControlButton::VOLUME_DOWN, fuchsia::input::report::ConsumerControlButton::FACTORY_RESET}); std::vector<fuchsia::input::report::InputReport> reports; reports.push_back(std::move(report)); fake_device_->SetReports(std::move(reports)); FakePrinter printer; printer.SetExpectedStrings(std::vector<std::string>{ "Report from file: test\n", "ConsumerControl Report\n", " Button: VOLUME_UP\n", " Button: VOLUME_DOWN\n", " Button: FACTORY_RESET\n", "\n", }); auto res = print_input_report::GetReaderClient(&client_.value(), loop_->dispatcher()); ASSERT_EQ(res.status_value(), ZX_OK); auto reader = std::move(res.value()); print_input_report::PrintInputReports("test", &printer, std::move(reader), 1); loop_->RunUntilIdle(); printer.AssertSawAllStrings(); } TEST_F(PrintInputReport, PrintInputDescriptorWithExponents) { auto descriptor = std::make_unique<fuchsia::input::report::DeviceDescriptor>(); descriptor->mutable_sensor()->mutable_input()->emplace_back(); auto values = descriptor->mutable_sensor()->mutable_input()->back().mutable_values(); fuchsia::input::report::SensorAxis axis; axis.axis.unit.type = fuchsia::input::report::UnitType::SI_LINEAR_VELOCITY; axis.axis.unit.exponent = -1; axis.axis.range.min = 0; axis.axis.range.max = 1000; axis.type = fuchsia::input::report::SensorType::ACCELEROMETER_X; values->push_back(axis); axis.axis.unit.type = fuchsia::input::report::UnitType::LUX; axis.axis.unit.exponent = -2; axis.type = fuchsia::input::report::SensorType::LIGHT_ILLUMINANCE; values->push_back(axis); fake_device_->SetDescriptor(std::move(descriptor)); FakePrinter printer; printer.SetExpectedStrings(std::vector<std::string>{ "Descriptor from file: test\n", "Sensor Descriptor:\n", " Value 00:\n", " SensorType: ACCELEROMETER_X\n", " Unit: SI_LINEAR_VELOCITY * 1e-1\n", " Min: 0\n", " Max: 1000\n", " Value 01:\n", " SensorType: LIGHT_ILLUMINANCE\n", " Unit: LUX * 1e-2\n", " Min: 0\n", " Max: 1000\n", }); print_input_report::PrintInputDescriptor(std::string("test"), &printer, std::move(*client_)); loop_->RunUntilIdle(); } TEST_F(PrintInputReport, PrintFeatureReport) { fuchsia::input::report::FeatureReport report; report.mutable_touch()->set_input_mode( fuchsia::input::report::TouchConfigurationInputMode::WINDOWS_PRECISION_TOUCHPAD_COLLECTION); report.mutable_touch()->mutable_selective_reporting()->set_surface_switch(true); report.mutable_touch()->mutable_selective_reporting()->set_button_switch(true); std::vector<fuchsia::input::report::FeatureReport> reports; reports.push_back(std::move(report)); fake_device_->SetReports(std::move(reports)); FakePrinter printer; printer.SetExpectedStrings(std::vector<std::string>{ "Feature Report from file: test\n", " Touch Feature Report:\n", " Input Mode: 3\n", " Selective Reporting:\n", " Surface Switch: 1\n", " Button Switch: 1\n", }); print_input_report::PrintFeatureReports("test", &printer, std::move(*client_)); loop_->RunUntilIdle(); printer.AssertSawAllStrings(); } } // namespace test
#include "../../TensorShaderAvxBackend.h" using namespace System; __forceinline __m128 _mm256d_sum(__m256d hi, __m256d lo) { __m256d u = _mm256_hadd_pd(lo, hi); __m256d v = _mm256_hadd_pd(u, _mm256_setzero_pd()); __m128d w = _mm_add_pd(_mm256_extractf128_pd(v, 1), _mm256_castpd256_pd128(v)); return _mm_cvtpd_ps(w); } void dense(unsigned int inchannels, unsigned int outchannels, unsigned int th, float* inmap_ptr, float* outmap_ptr, float* kernel_ptr) { const unsigned int inmap_offset = inchannels * th, outmap_offset = outchannels * th; const unsigned int inch_sep = inchannels & ~7u, inch_rem = inchannels - inch_sep; const __m256i mask = TensorShaderAvxBackend::masktable_m256(inch_rem); const __m128i mask1 = TensorShaderAvxBackend::masktable_m128(1); inmap_ptr += inmap_offset; outmap_ptr += outmap_offset; for (unsigned int outch = 0; outch < outchannels; outch++) { __m256d uv_hi = _mm256_setzero_pd(), uv_lo = _mm256_setzero_pd(); for (unsigned int inch = 0; inch < inch_sep; inch += 8) { __m256 u = _mm256_loadu_ps(inmap_ptr + inch); __m256 v = _mm256_loadu_ps(kernel_ptr + inch + inchannels * outch); __m256d u_hi = _mm256_cvtps_pd(_mm256_extractf128_ps(u, 1)); __m256d u_lo = _mm256_cvtps_pd(_mm256_castps256_ps128(u)); __m256d v_hi = _mm256_cvtps_pd(_mm256_extractf128_ps(v, 1)); __m256d v_lo = _mm256_cvtps_pd(_mm256_castps256_ps128(v)); uv_hi = _mm256_fmadd_pd(u_hi, v_hi, uv_hi); uv_lo = _mm256_fmadd_pd(u_lo, v_lo, uv_lo); } if (inch_rem > 0) { __m256 u = _mm256_maskload_ps(inmap_ptr + inch_sep, mask); __m256 v = _mm256_maskload_ps(kernel_ptr + inch_sep + inchannels * outch, mask); __m256d u_hi = _mm256_cvtps_pd(_mm256_extractf128_ps(u, 1)); __m256d u_lo = _mm256_cvtps_pd(_mm256_castps256_ps128(u)); __m256d v_hi = _mm256_cvtps_pd(_mm256_extractf128_ps(v, 1)); __m256d v_lo = _mm256_cvtps_pd(_mm256_castps256_ps128(v)); uv_hi = _mm256_fmadd_pd(u_hi, v_hi, uv_hi); uv_lo = _mm256_fmadd_pd(u_lo, v_lo, uv_lo); } _mm_maskstore_ps(outmap_ptr + outch, mask1, _mm256d_sum(uv_hi, uv_lo)); } } void TensorShaderAvxBackend::Convolution::Dense(unsigned int inchannels, unsigned int outchannels, unsigned int batch, unsigned int th, AvxArray<float>^ inmap, AvxArray<float>^ kernel, AvxArray<float>^ outmap){ Util::CheckDuplicateArray(inmap, kernel, outmap); if (th >= batch) { throw gcnew System::ArgumentException(); } Util::CheckLength(inchannels * batch, inmap); Util::CheckLength(outchannels * batch, outmap); Util::CheckLength(inchannels * outchannels, kernel); float* inmap_ptr = (float*)(inmap->Ptr.ToPointer()); float* outmap_ptr = (float*)(outmap->Ptr.ToPointer()); float* kernel_ptr = (float*)(kernel->Ptr.ToPointer()); dense(inchannels, outchannels, th, inmap_ptr, outmap_ptr, kernel_ptr); }
//===--- XRefs.cpp ----------------------------------------------*- C++-*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===---------------------------------------------------------------------===// #include "XRefs.h" #include "AST.h" #include "Logger.h" #include "SourceCode.h" #include "URI.h" #include "clang/AST/DeclTemplate.h" #include "clang/Index/IndexDataConsumer.h" #include "clang/Index/IndexingAction.h" #include "clang/Index/USRGeneration.h" #include "llvm/Support/Path.h" namespace clang { namespace clangd { using namespace llvm; namespace { // Get the definition from a given declaration `D`. // Return nullptr if no definition is found, or the declaration type of `D` is // not supported. const Decl *GetDefinition(const Decl *D) { assert(D); if (const auto *TD = dyn_cast<TagDecl>(D)) return TD->getDefinition(); else if (const auto *VD = dyn_cast<VarDecl>(D)) return VD->getDefinition(); else if (const auto *FD = dyn_cast<FunctionDecl>(D)) return FD->getDefinition(); return nullptr; } // Convert a SymbolLocation to LSP's Location. // HintPath is used to resolve the path of URI. // FIXME: figure out a good home for it, and share the implementation with // FindSymbols. llvm::Optional<Location> ToLSPLocation(const SymbolLocation &Loc, llvm::StringRef HintPath) { if (!Loc) return llvm::None; auto Uri = URI::parse(Loc.FileURI); if (!Uri) { log("Could not parse URI: " + Loc.FileURI); return llvm::None; } auto Path = URI::resolve(*Uri, HintPath); if (!Path) { log("Could not resolve URI: " + Loc.FileURI); return llvm::None; } Location LSPLoc; LSPLoc.uri = URIForFile(*Path); LSPLoc.range.start.line = Loc.Start.Line; LSPLoc.range.start.character = Loc.Start.Column; LSPLoc.range.end.line = Loc.End.Line; LSPLoc.range.end.character = Loc.End.Column; return LSPLoc; } struct MacroDecl { StringRef Name; const MacroInfo *Info; }; /// Finds declarations locations that a given source location refers to. class DeclarationAndMacrosFinder : public index::IndexDataConsumer { std::vector<const Decl *> Decls; std::vector<MacroDecl> MacroInfos; const SourceLocation &SearchedLocation; const ASTContext &AST; Preprocessor &PP; public: DeclarationAndMacrosFinder(raw_ostream &OS, const SourceLocation &SearchedLocation, ASTContext &AST, Preprocessor &PP) : SearchedLocation(SearchedLocation), AST(AST), PP(PP) {} std::vector<const Decl *> takeDecls() { // Don't keep the same declaration multiple times. // This can happen when nodes in the AST are visited twice. std::sort(Decls.begin(), Decls.end()); auto Last = std::unique(Decls.begin(), Decls.end()); Decls.erase(Last, Decls.end()); return std::move(Decls); } std::vector<MacroDecl> takeMacroInfos() { // Don't keep the same Macro info multiple times. std::sort(MacroInfos.begin(), MacroInfos.end(), [](const MacroDecl &Left, const MacroDecl &Right) { return Left.Info < Right.Info; }); auto Last = std::unique(MacroInfos.begin(), MacroInfos.end(), [](const MacroDecl &Left, const MacroDecl &Right) { return Left.Info == Right.Info; }); MacroInfos.erase(Last, MacroInfos.end()); return std::move(MacroInfos); } bool handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles, ArrayRef<index::SymbolRelation> Relations, SourceLocation Loc, index::IndexDataConsumer::ASTNodeInfo ASTNode) override { if (Loc == SearchedLocation) { // Find and add definition declarations (for GoToDefinition). // We don't use parameter `D`, as Parameter `D` is the canonical // declaration, which is the first declaration of a redeclarable // declaration, and it could be a forward declaration. if (const auto *Def = GetDefinition(D)) { Decls.push_back(Def); } else { // Couldn't find a definition, fall back to use `D`. Decls.push_back(D); } } return true; } private: void finish() override { // Also handle possible macro at the searched location. Token Result; auto &Mgr = AST.getSourceManager(); if (!Lexer::getRawToken(Mgr.getSpellingLoc(SearchedLocation), Result, Mgr, AST.getLangOpts(), false)) { if (Result.is(tok::raw_identifier)) { PP.LookUpIdentifierInfo(Result); } IdentifierInfo *IdentifierInfo = Result.getIdentifierInfo(); if (IdentifierInfo && IdentifierInfo->hadMacroDefinition()) { std::pair<FileID, unsigned int> DecLoc = Mgr.getDecomposedExpansionLoc(SearchedLocation); // Get the definition just before the searched location so that a macro // referenced in a '#undef MACRO' can still be found. SourceLocation BeforeSearchedLocation = Mgr.getMacroArgExpandedLocation( Mgr.getLocForStartOfFile(DecLoc.first) .getLocWithOffset(DecLoc.second - 1)); MacroDefinition MacroDef = PP.getMacroDefinitionAtLoc(IdentifierInfo, BeforeSearchedLocation); MacroInfo *MacroInf = MacroDef.getMacroInfo(); if (MacroInf) { MacroInfos.push_back(MacroDecl{IdentifierInfo->getName(), MacroInf}); assert(Decls.empty()); } } } } }; struct IdentifiedSymbol { std::vector<const Decl *> Decls; std::vector<MacroDecl> Macros; }; IdentifiedSymbol getSymbolAtPosition(ParsedAST &AST, SourceLocation Pos) { auto DeclMacrosFinder = DeclarationAndMacrosFinder( llvm::errs(), Pos, AST.getASTContext(), AST.getPreprocessor()); index::IndexingOptions IndexOpts; IndexOpts.SystemSymbolFilter = index::IndexingOptions::SystemSymbolFilterKind::All; IndexOpts.IndexFunctionLocals = true; indexTopLevelDecls(AST.getASTContext(), AST.getTopLevelDecls(), DeclMacrosFinder, IndexOpts); return {DeclMacrosFinder.takeDecls(), DeclMacrosFinder.takeMacroInfos()}; } llvm::Optional<std::string> getAbsoluteFilePath(const FileEntry *F, const SourceManager &SourceMgr) { SmallString<64> FilePath = F->tryGetRealPathName(); if (FilePath.empty()) FilePath = F->getName(); if (!llvm::sys::path::is_absolute(FilePath)) { if (!SourceMgr.getFileManager().makeAbsolutePath(FilePath)) { log("Could not turn relative path to absolute: " + FilePath); return llvm::None; } } return FilePath.str().str(); } llvm::Optional<Location> makeLocation(ParsedAST &AST, const SourceRange &ValSourceRange) { const SourceManager &SourceMgr = AST.getASTContext().getSourceManager(); const LangOptions &LangOpts = AST.getASTContext().getLangOpts(); SourceLocation LocStart = ValSourceRange.getBegin(); const FileEntry *F = SourceMgr.getFileEntryForID(SourceMgr.getFileID(LocStart)); if (!F) return llvm::None; SourceLocation LocEnd = Lexer::getLocForEndOfToken(ValSourceRange.getEnd(), 0, SourceMgr, LangOpts); Position Begin = sourceLocToPosition(SourceMgr, LocStart); Position End = sourceLocToPosition(SourceMgr, LocEnd); Range R = {Begin, End}; Location L; auto FilePath = getAbsoluteFilePath(F, SourceMgr); if (!FilePath) { log("failed to get path!"); return llvm::None; } L.uri = URIForFile(*FilePath); L.range = R; return L; } // Get the symbol ID for a declaration, if possible. llvm::Optional<SymbolID> getSymbolID(const Decl *D) { llvm::SmallString<128> USR; if (index::generateUSRForDecl(D, USR)) { return None; } return SymbolID(USR); } } // namespace std::vector<Location> findDefinitions(ParsedAST &AST, Position Pos, const SymbolIndex *Index) { const SourceManager &SourceMgr = AST.getASTContext().getSourceManager(); SourceLocation SourceLocationBeg = getBeginningOfIdentifier(AST, Pos, SourceMgr.getMainFileID()); std::vector<Location> Result; // Handle goto definition for #include. for (auto &IncludeLoc : AST.getInclusionLocations()) { Range R = IncludeLoc.first; Position Pos = sourceLocToPosition(SourceMgr, SourceLocationBeg); if (R.contains(Pos)) Result.push_back(Location{URIForFile{IncludeLoc.second}, {}}); } if (!Result.empty()) return Result; // Identified symbols at a specific position. auto Symbols = getSymbolAtPosition(AST, SourceLocationBeg); for (auto Item : Symbols.Macros) { auto Loc = Item.Info->getDefinitionLoc(); auto L = makeLocation(AST, SourceRange(Loc, Loc)); if (L) Result.push_back(*L); } // Declaration and definition are different terms in C-family languages, and // LSP only defines the "GoToDefinition" specification, so we try to perform // the "most sensible" GoTo operation: // // - We use the location from AST and index (if available) to provide the // final results. When there are duplicate results, we prefer AST over // index because AST is more up-to-date. // // - For each symbol, we will return a location of the canonical declaration // (e.g. function declaration in header), and a location of definition if // they are available. // // So the work flow: // // 1. Identify the symbols being search for by traversing the AST. // 2. Populate one of the locations with the AST location. // 3. Use the AST information to query the index, and populate the index // location (if available). // 4. Return all populated locations for all symbols, definition first ( // which we think is the users wants most often). struct CandidateLocation { llvm::Optional<Location> Def; llvm::Optional<Location> Decl; }; llvm::DenseMap<SymbolID, CandidateLocation> ResultCandidates; // Emit all symbol locations (declaration or definition) from AST. for (const auto *D : Symbols.Decls) { // Fake key for symbols don't have USR (no SymbolID). // Ideally, there should be a USR for each identified symbols. Symbols // without USR are rare and unimportant cases, we use the a fake holder to // minimize the invasiveness of these cases. SymbolID Key(""); if (auto ID = getSymbolID(D)) Key = *ID; auto &Candidate = ResultCandidates[Key]; auto Loc = findNameLoc(D); auto L = makeLocation(AST, SourceRange(Loc, Loc)); // The declaration in the identified symbols is a definition if possible // otherwise it is declaration. bool IsDef = GetDefinition(D) == D; // Populate one of the slots with location for the AST. if (!IsDef) Candidate.Decl = L; else Candidate.Def = L; } if (Index) { LookupRequest QueryRequest; // Build request for index query, using SymbolID. for (auto It : ResultCandidates) QueryRequest.IDs.insert(It.first); std::string HintPath; const FileEntry *FE = SourceMgr.getFileEntryForID(SourceMgr.getMainFileID()); if (auto Path = getAbsoluteFilePath(FE, SourceMgr)) HintPath = *Path; // Query the index and populate the empty slot. Index->lookup( QueryRequest, [&HintPath, &ResultCandidates](const Symbol &Sym) { auto It = ResultCandidates.find(Sym.ID); assert(It != ResultCandidates.end()); auto &Value = It->second; if (!Value.Def) Value.Def = ToLSPLocation(Sym.Definition, HintPath); if (!Value.Decl) Value.Decl = ToLSPLocation(Sym.CanonicalDeclaration, HintPath); }); } // Populate the results, definition first. for (auto It : ResultCandidates) { const auto &Candidate = It.second; if (Candidate.Def) Result.push_back(*Candidate.Def); if (Candidate.Decl && Candidate.Decl != Candidate.Def) // Decl and Def might be the same Result.push_back(*Candidate.Decl); } return Result; } namespace { /// Finds document highlights that a given list of declarations refers to. class DocumentHighlightsFinder : public index::IndexDataConsumer { std::vector<const Decl *> &Decls; std::vector<DocumentHighlight> DocumentHighlights; const ASTContext &AST; public: DocumentHighlightsFinder(raw_ostream &OS, ASTContext &AST, Preprocessor &PP, std::vector<const Decl *> &Decls) : Decls(Decls), AST(AST) {} std::vector<DocumentHighlight> takeHighlights() { // Don't keep the same highlight multiple times. // This can happen when nodes in the AST are visited twice. std::sort(DocumentHighlights.begin(), DocumentHighlights.end()); auto Last = std::unique(DocumentHighlights.begin(), DocumentHighlights.end()); DocumentHighlights.erase(Last, DocumentHighlights.end()); return std::move(DocumentHighlights); } bool handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles, ArrayRef<index::SymbolRelation> Relations, SourceLocation Loc, index::IndexDataConsumer::ASTNodeInfo ASTNode) override { const SourceManager &SourceMgr = AST.getSourceManager(); SourceLocation HighlightStartLoc = SourceMgr.getFileLoc(Loc); if (SourceMgr.getMainFileID() != SourceMgr.getFileID(HighlightStartLoc) || std::find(Decls.begin(), Decls.end(), D) == Decls.end()) { return true; } SourceLocation End; const LangOptions &LangOpts = AST.getLangOpts(); End = Lexer::getLocForEndOfToken(HighlightStartLoc, 0, SourceMgr, LangOpts); SourceRange SR(HighlightStartLoc, End); DocumentHighlightKind Kind = DocumentHighlightKind::Text; if (static_cast<index::SymbolRoleSet>(index::SymbolRole::Write) & Roles) Kind = DocumentHighlightKind::Write; else if (static_cast<index::SymbolRoleSet>(index::SymbolRole::Read) & Roles) Kind = DocumentHighlightKind::Read; DocumentHighlights.push_back(getDocumentHighlight(SR, Kind)); return true; } private: DocumentHighlight getDocumentHighlight(SourceRange SR, DocumentHighlightKind Kind) { const SourceManager &SourceMgr = AST.getSourceManager(); Position Begin = sourceLocToPosition(SourceMgr, SR.getBegin()); Position End = sourceLocToPosition(SourceMgr, SR.getEnd()); Range R = {Begin, End}; DocumentHighlight DH; DH.range = R; DH.kind = Kind; return DH; } }; } // namespace std::vector<DocumentHighlight> findDocumentHighlights(ParsedAST &AST, Position Pos) { const SourceManager &SourceMgr = AST.getASTContext().getSourceManager(); SourceLocation SourceLocationBeg = getBeginningOfIdentifier(AST, Pos, SourceMgr.getMainFileID()); auto Symbols = getSymbolAtPosition(AST, SourceLocationBeg); std::vector<const Decl *> SelectedDecls = Symbols.Decls; DocumentHighlightsFinder DocHighlightsFinder( llvm::errs(), AST.getASTContext(), AST.getPreprocessor(), SelectedDecls); index::IndexingOptions IndexOpts; IndexOpts.SystemSymbolFilter = index::IndexingOptions::SystemSymbolFilterKind::All; IndexOpts.IndexFunctionLocals = true; indexTopLevelDecls(AST.getASTContext(), AST.getTopLevelDecls(), DocHighlightsFinder, IndexOpts); return DocHighlightsFinder.takeHighlights(); } static PrintingPolicy PrintingPolicyForDecls(PrintingPolicy Base) { PrintingPolicy Policy(Base); Policy.AnonymousTagLocations = false; Policy.TerseOutput = true; Policy.PolishForDeclaration = true; Policy.ConstantsAsWritten = true; Policy.SuppressTagKeyword = false; return Policy; } /// Return a string representation (e.g. "class MyNamespace::MyClass") of /// the type declaration \p TD. static std::string TypeDeclToString(const TypeDecl *TD) { QualType Type = TD->getASTContext().getTypeDeclType(TD); PrintingPolicy Policy = PrintingPolicyForDecls(TD->getASTContext().getPrintingPolicy()); std::string Name; llvm::raw_string_ostream Stream(Name); Type.print(Stream, Policy); return Stream.str(); } /// Return a string representation (e.g. "namespace ns1::ns2") of /// the named declaration \p ND. static std::string NamedDeclQualifiedName(const NamedDecl *ND, StringRef Prefix) { PrintingPolicy Policy = PrintingPolicyForDecls(ND->getASTContext().getPrintingPolicy()); std::string Name; llvm::raw_string_ostream Stream(Name); Stream << Prefix << ' '; ND->printQualifiedName(Stream, Policy); return Stream.str(); } /// Given a declaration \p D, return a human-readable string representing the /// scope in which it is declared. If the declaration is in the global scope, /// return the string "global namespace". static llvm::Optional<std::string> getScopeName(const Decl *D) { const DeclContext *DC = D->getDeclContext(); if (isa<TranslationUnitDecl>(DC)) return std::string("global namespace"); if (const TypeDecl *TD = dyn_cast<TypeDecl>(DC)) return TypeDeclToString(TD); else if (const NamespaceDecl *ND = dyn_cast<NamespaceDecl>(DC)) return NamedDeclQualifiedName(ND, "namespace"); else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(DC)) return NamedDeclQualifiedName(FD, "function"); return llvm::None; } /// Generate a \p Hover object given the declaration \p D. static Hover getHoverContents(const Decl *D) { Hover H; llvm::Optional<std::string> NamedScope = getScopeName(D); // Generate the "Declared in" section. if (NamedScope) { assert(!NamedScope->empty()); H.contents.value += "Declared in "; H.contents.value += *NamedScope; H.contents.value += "\n\n"; } // We want to include the template in the Hover. if (TemplateDecl *TD = D->getDescribedTemplate()) D = TD; std::string DeclText; llvm::raw_string_ostream OS(DeclText); PrintingPolicy Policy = PrintingPolicyForDecls(D->getASTContext().getPrintingPolicy()); D->print(OS, Policy); OS.flush(); H.contents.value += DeclText; return H; } /// Generate a \p Hover object given the macro \p MacroInf. static Hover getHoverContents(StringRef MacroName) { Hover H; H.contents.value = "#define "; H.contents.value += MacroName; return H; } Hover getHover(ParsedAST &AST, Position Pos) { const SourceManager &SourceMgr = AST.getASTContext().getSourceManager(); SourceLocation SourceLocationBeg = getBeginningOfIdentifier(AST, Pos, SourceMgr.getMainFileID()); // Identified symbols at a specific position. auto Symbols = getSymbolAtPosition(AST, SourceLocationBeg); if (!Symbols.Macros.empty()) return getHoverContents(Symbols.Macros[0].Name); if (!Symbols.Decls.empty()) return getHoverContents(Symbols.Decls[0]); return Hover(); } } // namespace clangd } // namespace clang
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ #include "layers.h" CLayers::CLayers() { m_GroupsNum = 0; m_GroupsStart = 0; m_LayersNum = 0; m_LayersStart = 0; m_pGameGroup = 0; m_pGameLayer = 0; m_pMap = 0; } void CLayers::Init(class IKernel *pKernel, IMap *pMap) { m_pMap = pMap; m_pMap->GetType(MAPITEMTYPE_GROUP, &m_GroupsStart, &m_GroupsNum); m_pMap->GetType(MAPITEMTYPE_LAYER, &m_LayersStart, &m_LayersNum); for(int g = 0; g < NumGroups(); g++) { CMapItemGroup *pGroup = GetGroup(g); for(int l = 0; l < pGroup->m_NumLayers; l++) { CMapItemLayer *pLayer = GetLayer(pGroup->m_StartLayer+l); if(pLayer->m_Type == LAYERTYPE_TILES) { CMapItemLayerTilemap *pTilemap = reinterpret_cast<CMapItemLayerTilemap *>(pLayer); if(pTilemap->m_Flags&TILESLAYERFLAG_GAME) { m_pGameLayer = pTilemap; m_pGameGroup = pGroup; // make sure the game group has standard settings m_pGameGroup->m_OffsetX = 0; m_pGameGroup->m_OffsetY = 0; m_pGameGroup->m_ParallaxX = 100; m_pGameGroup->m_ParallaxY = 100; if(m_pGameGroup->m_Version >= 2) { m_pGameGroup->m_UseClipping = 0; m_pGameGroup->m_ClipX = 0; m_pGameGroup->m_ClipY = 0; m_pGameGroup->m_ClipW = 0; m_pGameGroup->m_ClipH = 0; } break; } } } } } CMapItemGroup *CLayers::GetGroup(int Index) const { return static_cast<CMapItemGroup *>(m_pMap->GetItem(m_GroupsStart+Index, 0, 0)); } CMapItemLayer *CLayers::GetLayer(int Index) const { return static_cast<CMapItemLayer *>(m_pMap->GetItem(m_LayersStart+Index, 0, 0)); }
// Copyright (c) 2011-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2017 The PIVX developers // Copyright (c) 2018 The XIM developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "editaddressdialog.h" #include "ui_editaddressdialog.h" #include "addresstablemodel.h" #include "guiutil.h" #include <QDataWidgetMapper> #include <QMessageBox> EditAddressDialog::EditAddressDialog(Mode mode, QWidget* parent) : QDialog(parent), ui(new Ui::EditAddressDialog), mapper(0), mode(mode), model(0) { ui->setupUi(this); GUIUtil::setupAddressWidget(ui->addressEdit, this); switch (mode) { case NewReceivingAddress: setWindowTitle(tr("New receiving address")); ui->addressEdit->setEnabled(false); break; case NewSendingAddress: setWindowTitle(tr("New sending address")); break; case EditReceivingAddress: setWindowTitle(tr("Edit receiving address")); ui->addressEdit->setEnabled(false); break; case EditSendingAddress: setWindowTitle(tr("Edit sending address")); break; } mapper = new QDataWidgetMapper(this); mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit); } EditAddressDialog::~EditAddressDialog() { delete ui; } void EditAddressDialog::setModel(AddressTableModel* model) { this->model = model; if (!model) return; mapper->setModel(model); mapper->addMapping(ui->labelEdit, AddressTableModel::Label); mapper->addMapping(ui->addressEdit, AddressTableModel::Address); } void EditAddressDialog::loadRow(int row) { mapper->setCurrentIndex(row); } bool EditAddressDialog::saveCurrentRow() { if (!model) return false; switch (mode) { case NewReceivingAddress: case NewSendingAddress: address = model->addRow( mode == NewSendingAddress ? AddressTableModel::Send : AddressTableModel::Receive, ui->labelEdit->text(), ui->addressEdit->text()); break; case EditReceivingAddress: case EditSendingAddress: if (mapper->submit()) { address = ui->addressEdit->text(); } break; } return !address.isEmpty(); } void EditAddressDialog::accept() { if (!model) return; if (!saveCurrentRow()) { switch (model->getEditStatus()) { case AddressTableModel::OK: // Failed with unknown reason. Just reject. break; case AddressTableModel::NO_CHANGES: // No changes were made during edit operation. Just reject. break; case AddressTableModel::INVALID_ADDRESS: QMessageBox::warning(this, windowTitle(), tr("The entered address \"%1\" is not a valid XIM address.").arg(ui->addressEdit->text()), QMessageBox::Ok, QMessageBox::Ok); break; case AddressTableModel::DUPLICATE_ADDRESS: QMessageBox::warning(this, windowTitle(), tr("The entered address \"%1\" is already in the address book.").arg(ui->addressEdit->text()), QMessageBox::Ok, QMessageBox::Ok); break; case AddressTableModel::WALLET_UNLOCK_FAILURE: QMessageBox::critical(this, windowTitle(), tr("Could not unlock wallet."), QMessageBox::Ok, QMessageBox::Ok); break; case AddressTableModel::KEY_GENERATION_FAILURE: QMessageBox::critical(this, windowTitle(), tr("New key generation failed."), QMessageBox::Ok, QMessageBox::Ok); break; } return; } QDialog::accept(); } QString EditAddressDialog::getAddress() const { return address; } void EditAddressDialog::setAddress(const QString& address) { this->address = address; ui->addressEdit->setText(address); }
// clientgame.cpp: core game related stuff #include "cube.h" int nextmode = 0; // nextmode becomes gamemode after next map load VAR(gamemode, 1, 0, 0); void mode(int n) { addmsg(1, 2, SV_GAMEMODE, nextmode = n); }; COMMAND(mode, ARG_1INT); bool intermission = false; dynent *player1 = newdynent(); // our client dvector players; // other clients VARP(sensitivity, 0, 10, 10000); VARP(sensitivityscale, 1, 1, 10000); VARP(invmouse, 0, 0, 1); int lastmillis = 0; int curtime = 10; string clientmap; extern int framesinmap; char *getclientmap() { return clientmap; }; void resetmovement(dynent *d) { d->k_left = false; d->k_right = false; d->k_up = false; d->k_down = false; d->jumpnext = false; d->strafe = 0; d->move = 0; }; void spawnstate(dynent *d) // reset player state not persistent accross spawns { resetmovement(d); d->vel.x = d->vel.y = d->vel.z = 0; d->onfloor = false; d->timeinair = 0; d->health = 100; d->armour = 50; d->armourtype = A_BLUE; d->quadmillis = 0; d->lastattackgun = d->gunselect = GUN_SG; d->gunwait = 0; d->attacking = false; d->lastaction = 0; loopi(NUMGUNS) d->ammo[i] = 0; d->ammo[GUN_FIST] = 1; if(m_noitems) { d->gunselect = GUN_RIFLE; d->armour = 0; if(m_noitemsrail) { d->health = 1; d->ammo[GUN_RIFLE] = 100; } else { if(gamemode==12) { d->gunselect = GUN_FIST; return; }; // eihrul's secret "instafist" mode d->health = 256; if(m_tarena) { int gun1 = rnd(4)+1; baseammo(d->gunselect = gun1); for(;;) { int gun2 = rnd(4)+1; if(gun1!=gun2) { baseammo(gun2); break; }; }; } else if(m_arena) // insta arena { d->ammo[GUN_RIFLE] = 100; } else // efficiency { loopi(4) baseammo(i+1); d->gunselect = GUN_CG; }; d->ammo[GUN_CG] /= 2; }; } else { d->ammo[GUN_SG] = 5; }; }; dynent *newdynent() // create a new blank player or monster { dynent *d = (dynent *)gp()->alloc(sizeof(dynent)); d->o.x = 0; d->o.y = 0; d->o.z = 0; d->yaw = 270; d->pitch = 0; d->roll = 0; d->maxspeed = 22; d->outsidemap = false; d->inwater = false; d->radius = 1.1f; d->eyeheight = 3.2f; d->aboveeye = 0.7f; d->frags = 0; d->plag = 0; d->ping = 0; d->lastupdate = lastmillis; d->enemy = NULL; d->monsterstate = 0; d->name[0] = d->team[0] = 0; d->blocked = false; d->lifesequence = 0; d->state = CS_ALIVE; spawnstate(d); return d; }; void respawnself() { spawnplayer(player1); showscores(false); }; void arenacount(dynent *d, int &alive, int &dead, char *&lastteam, bool &oneteam) { if(d->state!=CS_DEAD) { alive++; if(lastteam && strcmp(lastteam, d->team)) oneteam = false; lastteam = d->team; } else { dead++; }; }; int arenarespawnwait = 0; int arenadetectwait = 0; void arenarespawn() { if(arenarespawnwait) { if(arenarespawnwait<lastmillis) { arenarespawnwait = 0; conoutf("new round starting... fight!"); respawnself(); }; } else if(arenadetectwait==0 || arenadetectwait<lastmillis) { arenadetectwait = 0; int alive = 0, dead = 0; char *lastteam = NULL; bool oneteam = true; loopv(players) if(players[i]) arenacount(players[i], alive, dead, lastteam, oneteam); arenacount(player1, alive, dead, lastteam, oneteam); if(dead>0 && (alive<=1 || (m_teammode && oneteam))) { conoutf("arena round is over! next round in 5 seconds..."); if(alive) conoutf("team %s is last man standing", lastteam); else conoutf("everyone died!"); arenarespawnwait = lastmillis+5000; arenadetectwait = lastmillis+10000; player1->roll = 0; }; }; }; void zapdynent(dynent *&d) { if(d) gp()->dealloc(d, sizeof(dynent)); d = NULL; }; extern int democlientnum; void otherplayers() { loopv(players) if(players[i]) { const int lagtime = lastmillis-players[i]->lastupdate; if(lagtime>1000 && players[i]->state==CS_ALIVE) { players[i]->state = CS_LAGGED; continue; }; if(lagtime && players[i]->state != CS_DEAD && (!demoplayback || i!=democlientnum)) moveplayer(players[i], 2, false); // use physics to extrapolate player position }; }; void respawn() { if(player1->state==CS_DEAD) { player1->attacking = false; if(m_arena) { conoutf("waiting for new round to start..."); return; }; if(m_sp) { nextmode = gamemode; changemap(clientmap); return; }; // if we die in SP we try the same map again respawnself(); }; }; int sleepwait = 0; string sleepcmd; void sleepf(char *msec, char *cmd) { sleepwait = atoi(msec)+lastmillis; strcpy_s(sleepcmd, cmd); }; COMMANDN(sleep, sleepf, ARG_2STR); void updateworld(int millis) // main game update loop { if(lastmillis) { curtime = millis - lastmillis; if(sleepwait && lastmillis>sleepwait) { sleepwait = 0; execute(sleepcmd); }; physicsframe(); checkquad(curtime); if(m_arena) arenarespawn(); moveprojectiles((float)curtime); demoplaybackstep(); if(!demoplayback) { if(getclientnum()>=0) shoot(player1, worldpos); // only shoot when connected to server gets2c(); // do this first, so we have most accurate information when our player moves }; otherplayers(); if(!demoplayback) { monsterthink(); if(player1->state==CS_DEAD) { if(lastmillis-player1->lastaction<2000) { player1->move = player1->strafe = 0; moveplayer(player1, 10, false); } else if(!m_arena && !m_sp && lastmillis-player1->lastaction>10000) respawn(); } else if(!intermission) { moveplayer(player1, 20, true); checkitems(); }; c2sinfo(player1); // do this last, to reduce the effective frame lag }; }; lastmillis = millis; }; void entinmap(dynent *d) // brute force but effective way to find a free spawn spot in the map { loopi(100) // try max 100 times { float dx = (rnd(21)-10)/10.0f*i; // increasing distance float dy = (rnd(21)-10)/10.0f*i; d->o.x += dx; d->o.y += dy; if(collide(d, true, 0, 0)) return; d->o.x -= dx; d->o.y -= dy; }; conoutf("can't find entity spawn spot! (%d, %d)", (int)d->o.x, (int)d->o.y); // leave ent at original pos, possibly stuck }; int spawncycle = -1; int fixspawn = 2; void spawnplayer(dynent *d) // place at random spawn. also used by monsters! { int r = fixspawn-->0 ? 4 : rnd(10)+1; loopi(r) spawncycle = findentity(PLAYERSTART, spawncycle+1); if(spawncycle!=-1) { d->o.x = ents[spawncycle].x; d->o.y = ents[spawncycle].y; d->o.z = ents[spawncycle].z; d->yaw = ents[spawncycle].attr1; d->pitch = 0; d->roll = 0; } else { d->o.x = d->o.y = (float)ssize/2; d->o.z = 4; }; entinmap(d); spawnstate(d); d->state = CS_ALIVE; }; // movement input code #define dir(name,v,d,s,os) void name(bool isdown) { player1->s = isdown; player1->v = isdown ? d : (player1->os ? -(d) : 0); player1->lastmove = lastmillis; }; dir(backward, move, -1, k_down, k_up); dir(forward, move, 1, k_up, k_down); dir(left, strafe, 1, k_left, k_right); dir(right, strafe, -1, k_right, k_left); void attack(bool on) { if(intermission) return; if(editmode) editdrag(on); else if(player1->attacking = on) respawn(); }; void jumpn(bool on) { if(!intermission && (player1->jumpnext = on)) respawn(); }; COMMAND(backward, ARG_DOWN); COMMAND(forward, ARG_DOWN); COMMAND(left, ARG_DOWN); COMMAND(right, ARG_DOWN); COMMANDN(jump, jumpn, ARG_DOWN); COMMAND(attack, ARG_DOWN); COMMAND(showscores, ARG_DOWN); void fixplayer1range() { const float MAXPITCH = 90.0f; if(player1->pitch>MAXPITCH) player1->pitch = MAXPITCH; if(player1->pitch<-MAXPITCH) player1->pitch = -MAXPITCH; while(player1->yaw<0.0f) player1->yaw += 360.0f; while(player1->yaw>=360.0f) player1->yaw -= 360.0f; }; void mousemove(int dx, int dy) { if(player1->state==CS_DEAD || intermission) return; const float SENSF = 33.0f; // try match quake sens player1->yaw += (dx/SENSF)*(sensitivity/(float)sensitivityscale); player1->pitch -= (dy/SENSF)*(sensitivity/(float)sensitivityscale)*(invmouse ? -1 : 1); fixplayer1range(); }; // damage arriving from the network, monsters, yourself, all ends up here. void selfdamage(int damage, int actor, dynent *act) { if(player1->state!=CS_ALIVE || editmode || intermission) return; damageblend(damage); demoblend(damage); int ad = damage*(player1->armourtype+1)*20/100; // let armour absorb when possible if(ad>player1->armour) ad = player1->armour; player1->armour -= ad; damage -= ad; float droll = damage/0.5f; player1->roll += player1->roll>0 ? droll : (player1->roll<0 ? -droll : (rnd(2) ? droll : -droll)); // give player a kick depending on amount of damage if((player1->health -= damage)<=0) { if(actor==-2) { conoutf("you got killed by %s!", act->name); } else if(actor==-1) { actor = getclientnum(); conoutf("you suicided!"); addmsg(1, 2, SV_FRAGS, --player1->frags); } else { dynent *a = getclient(actor); if(a) { if(isteam(a->team, player1->team)) { conoutf("you got fragged by a teammate (%s)", a->name); } else { conoutf("you got fragged by %s", a->name); }; }; }; showscores(true); addmsg(1, 2, SV_DIED, actor); player1->lifesequence++; player1->attacking = false; player1->state = CS_DEAD; player1->pitch = 0; player1->roll = 60; playsound(S_DIE1+rnd(2)); spawnstate(player1); player1->lastaction = lastmillis; } else { playsound(S_PAIN6); }; }; void timeupdate(int timeremain) { if(!timeremain) { intermission = true; player1->attacking = false; conoutf("intermission:"); conoutf("game has ended!"); showscores(true); } else { conoutf("time remaining: %d minutes", timeremain); }; }; dynent *getclient(int cn) // ensure valid entity { if(cn<0 || cn>=MAXCLIENTS) { neterr("clientnum"); return NULL; }; while(cn>=players.length()) players.add(NULL); return players[cn] ? players[cn] : (players[cn] = newdynent()); }; void initclient() { clientmap[0] = 0; initclientnet(); }; void startmap(char *name) // called just after a map load { if(netmapstart() && m_sp) { gamemode = 0; conoutf("coop sp not supported yet"); }; sleepwait = 0; monsterclear(); projreset(); spawncycle = -1; spawnplayer(player1); player1->frags = 0; loopv(players) if(players[i]) players[i]->frags = 0; resetspawns(); strcpy_s(clientmap, name); if(editmode) toggleedit(); setvar("gamespeed", 100); setvar("fog", 180); setvar("fogcolour", 0x8099B3); showscores(false); intermission = false; framesinmap = 0; conoutf("game mode is %s", modestr(gamemode)); }; COMMANDN(map, changemap, ARG_1STR);
#include <Functions/FunctionFactory.h> namespace DB { void registerFunctionsArithmetic(FunctionFactory &); void registerFunctionsArray(FunctionFactory &); void registerFunctionsTuple(FunctionFactory &); void registerFunctionsBitmap(FunctionFactory &); void registerFunctionsCoding(FunctionFactory &); void registerFunctionsComparison(FunctionFactory &); void registerFunctionsConditional(FunctionFactory &); void registerFunctionsConversion(FunctionFactory &); void registerFunctionsDateTime(FunctionFactory &); void registerFunctionsEmbeddedDictionaries(FunctionFactory &); void registerFunctionsExternalDictionaries(FunctionFactory &); void registerFunctionsExternalModels(FunctionFactory &); void registerFunctionsFormatting(FunctionFactory &); void registerFunctionsHashing(FunctionFactory &); void registerFunctionsHigherOrder(FunctionFactory &); void registerFunctionsLogical(FunctionFactory &); void registerFunctionsMiscellaneous(FunctionFactory &); void registerFunctionsRandom(FunctionFactory &); void registerFunctionsReinterpret(FunctionFactory &); void registerFunctionsRound(FunctionFactory &); void registerFunctionsString(FunctionFactory &); void registerFunctionsStringArray(FunctionFactory &); void registerFunctionsStringSearch(FunctionFactory &); void registerFunctionsStringRegexp(FunctionFactory &); void registerFunctionsStringSimilarity(FunctionFactory &); void registerFunctionsURL(FunctionFactory &); void registerFunctionsVisitParam(FunctionFactory &); void registerFunctionsMath(FunctionFactory &); void registerFunctionsGeo(FunctionFactory &); void registerFunctionsIntrospection(FunctionFactory &); void registerFunctionsNull(FunctionFactory &); void registerFunctionsJSON(FunctionFactory &); void registerFunctionsConsistentHashing(FunctionFactory & factory); void registerFunctionsUnixTimestamp64(FunctionFactory & factory); #if !defined(ARCADIA_BUILD) void registerFunctionBayesAB(FunctionFactory &); #endif void registerFunctionTid(FunctionFactory & factory); void registerFunctionLogTrace(FunctionFactory & factory); void registerFunctions() { auto & factory = FunctionFactory::instance(); registerFunctionsArithmetic(factory); registerFunctionsArray(factory); registerFunctionsTuple(factory); #if !defined(ARCADIA_BUILD) registerFunctionsBitmap(factory); #endif registerFunctionsCoding(factory); registerFunctionsComparison(factory); registerFunctionsConditional(factory); registerFunctionsConversion(factory); registerFunctionsDateTime(factory); registerFunctionsEmbeddedDictionaries(factory); registerFunctionsExternalDictionaries(factory); registerFunctionsExternalModels(factory); registerFunctionsFormatting(factory); registerFunctionsHashing(factory); registerFunctionsHigherOrder(factory); registerFunctionsLogical(factory); registerFunctionsMiscellaneous(factory); registerFunctionsRandom(factory); registerFunctionsReinterpret(factory); registerFunctionsRound(factory); registerFunctionsString(factory); registerFunctionsStringArray(factory); registerFunctionsStringSearch(factory); registerFunctionsStringRegexp(factory); registerFunctionsStringSimilarity(factory); registerFunctionsURL(factory); registerFunctionsVisitParam(factory); registerFunctionsMath(factory); registerFunctionsGeo(factory); registerFunctionsNull(factory); registerFunctionsJSON(factory); registerFunctionsIntrospection(factory); registerFunctionsConsistentHashing(factory); registerFunctionsUnixTimestamp64(factory); #if !defined(ARCADIA_BUILD) registerFunctionBayesAB(factory); #endif registerFunctionTid(factory); registerFunctionLogTrace(factory); } }
// // Generic listener interface for monitoring, debugging and profiling. // #ifndef GRAPHLAB_IMONITOR_HPP #define GRAPHLAB_IMONITOR_HPP #include <graphlab/graph/graph.hpp> #include <graphlab/tasks/update_task.hpp> #include <graphlab/scope/iscope.hpp> namespace graphlab { // Predecleration template<typename Graph> class iengine; template<typename Graph> class imonitor { public: typedef Graph graph_type; typedef update_task<Graph> update_task_type; typedef iscope<Graph> iscope_type; typedef iengine<Graph> iengine_type; /* Initialization, called by the engine */ virtual void init(iengine_type* engine) { } /* Engine calls */ virtual void engine_task_execute_start(update_task_type task, iscope_type* scope, size_t cpuid) { } virtual void engine_task_execute_finished(update_task_type task, iscope_type* scope, size_t cpuid) { } virtual void engine_worker_starts(size_t cpuid) { } virtual void engine_worker_dies(size_t cpuid, int taskcount) { } /* Scheduler calls */ virtual void scheduler_task_added(update_task_type task, double priority) { } virtual void scheduler_task_promoted(update_task_type task, double diffpriority, double totalpriority) { } virtual void scheduler_task_scheduled(update_task_type task, double current_max_priority) { } virtual void scheduler_task_pruned(update_task_type task) { } /* Application calls */ virtual void app_set_vertex_value(vertex_id_t vid, double value) { } /* Called by application to help visualizers to scale values properly */ virtual void app_set_vertex_value_scale(double min, double max) { } }; } #endif
/* Meddly: Multi-terminal and Edge-valued Decision Diagram LibrarY. Copyright (C) 2009, Iowa State University Research Foundation, Inc. This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see <http://www.gnu.org/licenses/>. */ /** * rebuild_mdd.cc * * Rebuild a mdd forest with a different variable ordr. */ #include <stdlib.h> #include <iostream> #include <string.h> #include "../src/meddly.h" #include "../src/meddly_expert.h" #include "reorder.h" using namespace MEDDLY; // Only include this file if referring to operations that are not // available via the mddlib interface. // // Also, include this file if you would like to create a custom // operation by deriving one of the existing operations. // #include "operation_ext.h" // Timer class #include "../src/timer.h" #define USE_REALS 0 #if USE_REALS typedef float element_type; #else typedef long element_type; #endif // verbose: 0: minimum, 2: maximum const int verbose = 0; #if 0 // Given a forest and an op_code returns the corresponding op_info. // // This is only valid for operations of the form C = A op B, // where A, B and C belong to the same forest. op_info* getOp(forest* f, compute_manager::op_code op) { static const int nForests = 3; static op_param plist[nForests]; static expert_compute_manager* ecm = static_cast<expert_compute_manager*>(getComputeManager()); assert(ecm != 0); assert(f != 0); plist[0].set(f); plist[1].set(f); plist[2].set(f); return ecm->getOpInfo(op, plist, nForests); } // Given a forest and an instance of an operation returns // the corresponding op_info. // // This is only valid for operations of the form C = A op B, // where A, B and C belong to the same forest. op_info* getOp(forest* f, old_operation* op) { static const int nForests = 3; static op_param plist[nForests]; static expert_compute_manager* ecm = static_cast<expert_compute_manager*>(getComputeManager()); assert(ecm != 0); assert(f != 0); assert(op != 0); plist[0].set(f); plist[1].set(f); plist[2].set(f); return ecm->getOpInfo(op, plist, nForests); } #endif void printStats(const char* who, const forest* f) { printf("%s stats:\n", who); const expert_forest* ef = (expert_forest*) f; FILE_output mout(stdout); ef->reportStats(mout, "\t", expert_forest::HUMAN_READABLE_MEMORY | expert_forest::BASIC_STATS | expert_forest::EXTRA_STATS | expert_forest::STORAGE_STATS | expert_forest::HOLE_MANAGER_STATS | expert_forest::HOLE_MANAGER_DETAILED ); } // Tests a mtmdd operation on the elements provided. // This function assumes that each element[i] represents // an element in the given MTMDD. dd_edge test_mtmdd(forest* mtmdd, const binary_opname* opCode, int** element, element_type* terms, int nElements) { // A = first nElements/2 elements combined using +. // B = second nElements/2 elements combined using +. // C = A op B dd_edge A(mtmdd); dd_edge B(mtmdd); dd_edge C(mtmdd); int half = nElements/2; mtmdd->createEdge(element, terms, half, A); mtmdd->createEdge(element + half, terms + half, nElements - half, B); apply(opCode, A, B, C); if (verbose > 0) { FILE_output meddlyout(stdout); printf("A: "); A.show(meddlyout, 2); printf("\n\nB: "); B.show(meddlyout, 2); printf("\n\nC: "); C.show(meddlyout, 2); } return C; } bool test_conversion(dd_edge& A, dd_edge& B) { #if 0 return compute_manager::SUCCESS == ecm->apply(op, A, B)? true: false; #else try { apply(COPY, A, B); return true; } catch (MEDDLY::error err) { printf("Apply error:\n %s\n", err.getName()); return false; } #endif } void printUsage(FILE *outputStream) { fprintf(outputStream, "Usage: test_union_mtmdd <#Variables> <VariableBound> <#Elements>\ [#terms]\n"); } void reorderVariablesByRebuilding(dd_edge &e) { printf("Initial: %ld\n", e.getForest()->getCurrentNumNodes()); expert_forest* f = (expert_forest*)e.getForest(); int num_var = f->getNumVariables(); int* level2var = new int[num_var + 1]; level2var[0] = 0; for(int i=1; i<=num_var; i++) { level2var[i] = i; } shuffle(level2var, 1, num_var); expert_forest* target = (expert_forest*)f->useDomain()->createForest(f->isForRelations(), f->getRangeType(), f->getEdgeLabeling() , f->getPolicies()); target->reorderVariables(level2var); delete[] level2var; dd_edge e2(target); { global_rebuilder gr(f, target); timer start; start.note_time(); e2 = gr.rebuild(e); start.note_time(); printf("Time interval: %.4e seconds\n", start.get_last_interval()/1000000.0); printf("Source: %d\n", e.getNodeCount()); printf("Final: %d\n", e2.getNodeCount()); } f->createEdge(long(0), e); printf("Source Discarded: %d\n", e.getNodeCount()); { global_rebuilder gr(target, f); timer start; start.note_time(); e = gr.rebuild(e2); start.note_time(); printf("Time interval: %.4e seconds\n", start.get_last_interval()/1000000.0); printf("Final: %d\n", e2.getNodeCount()); printf("Source: %d\n", e.getNodeCount()); } } int main(int argc, char *argv[]) { if (argc != 4 && argc != 5) { printUsage(stdout); exit(1); } srand(time(NULL)); // initialize number of variables, their bounds and the number of elements // to create int nVariables = 0; int variableBound = 0; int nElements = 0; int nTerms = 0; sscanf(argv[1], "%d", &nVariables); assert(nVariables > 0); sscanf(argv[2], "%d", &variableBound); assert(variableBound > 0); sscanf(argv[3], "%d", &nElements); assert(nElements > 0); if (argc == 5) { sscanf(argv[4], "%d", &nTerms); assert(nTerms > 0); } else { nTerms = variableBound; } printf("#variables: %d, variable bound: %d, #elements: %d\n", nVariables, variableBound, nElements); // create the elements randomly int** element = (int **) malloc(nElements * sizeof(int *)); element_type* terms = (element_type *) malloc(nElements * sizeof(element_type)); for (int i = 0; i < nElements; ++i) { element[i] = (int *) malloc((nVariables + 1) * sizeof(int)); element[i][0] = 0; for (int j = nVariables; j > 0; --j) { element[i][j] = int(float(variableBound) * rand() / (RAND_MAX + 1.0)); assert(element[i][j] >= 0 && element[i][j] < variableBound); } terms[i] = element_type(float(nTerms) * rand() / (RAND_MAX + 1.0)); } // initialize the variable bounds array to provide to the domain int* bounds = (int *) malloc(nVariables * sizeof(int)); assert(bounds != 0); for (int i = 0; i < nVariables; ++i) { bounds[i] = variableBound; } initialize(); // Create a domain domain *d = createDomainBottomUp(bounds, nVariables); assert(d != 0); // Create a MTMDD forest in this domain forest::policies p(false); p.setPessimistic(); #if USE_REALS forest* mtmdd = d->createForest(false, forest::REAL, forest::MULTI_TERMINAL, p); #else forest* mtmdd = d->createForest(false, forest::INTEGER, forest::MULTI_TERMINAL, p); #endif assert(mtmdd != 0); // print elements if (verbose > 0) { for (int i = 0; i < nElements; ++i) { printf("Element %d: [%d", i, element[i][0]); for (int j = 1; j <= nVariables; ++j) { printf(" %d", element[i][j]); } #if USE_REALS printf(": %f]\n", terms[i]); #else printf(": %ld]\n", terms[i]); #endif } } timer start; start.note_time(); dd_edge result = test_mtmdd(mtmdd, PLUS, element, terms, nElements); start.note_time(); printf("Time interval: %.4e seconds\n", start.get_last_interval()/1000000.0); printf("Peak Nodes in MDD: %ld\n", mtmdd->getPeakNumNodes()); reorderVariablesByRebuilding(result); #if 0 // Convert mtmdd to mdd forest* mdd = d->createForest(false, forest::BOOLEAN, forest::MULTI_TERMINAL); dd_edge toMdd(mdd); printf("\n\nConversion MTMDD to MDD: "); if (test_conversion(result, toMdd)) { printf("Success!\n"); if (verbose > 0) { printf("toMdd: "); if (verbose > 1) toMdd.show(stdout, 3); else toMdd.show(stdout, 2); } } else { printf("Fail!\n"); } printf("\n\nMTMDD Forest Info:\n"); mtmdd->showInfo(stdout); printf("\n\nMDD Forest Info:\n"); mdd->showInfo(stdout); // Convert mtmdd to ev+mdd forest* evmdd = d->createForest(false, forest::INTEGER, forest::EVPLUS); assert(evmdd != 0); assert(forest::SUCCESS == // evmdd->setNodeDeletion(forest::PESSIMISTIC_DELETION)); evmdd->setNodeDeletion(forest::OPTIMISTIC_DELETION)); dd_edge toEvMdd(evmdd); printf("\n\nConversion MTMDD to EV+MDD: "); if (test_conversion(result, toEvMdd)) { printf("Success!\n"); if (verbose > 0) { printf("MtMdd: "); result.show(stdout, verbose > 1? 3: 2); printf("toEvMdd: "); toEvMdd.show(stdout, verbose > 1? 3: 2); } } else { printf("Fail!\n"); } printf("\n\nMTMDD Forest Info:\n"); mtmdd->showInfo(stdout); printf("\n\nEVMDD Forest Info:\n"); evmdd->showInfo(stdout); #endif // if (true) { // dd_edge reachableStates(result); // start.note_time(); // unsigned counter = 0; // for (enumerator iter(reachableStates); // iter; ++iter, ++counter) // { // const int* element = iter.getAssignments(); // const int* curr = element + nVariables; // const int* end = element - 1; // printf("%d: [%d", counter, *curr--); // while (curr != end) { printf(" %d", *curr--); } // printf("]\n"); // } // start.note_time(); // printf("Iterator traversal time (%0.4e elements): %0.4e seconds\n", // double(counter), start.get_last_interval()/double(1000000.0)); // double c; // apply(CARDINALITY, reachableStates, c); // printf("Cardinality: %0.4e\n", c); // } // Cleanup; in this case simply delete the domain destroyDomain(d); free(bounds); for (int i = 0; i < nElements; ++i) { free(element[i]); } free(element); cleanup(); return 0; }
//------------------------------------------------------------------------------ /* This file is part of rippled: https://github.com/ripple/rippled Copyright (c) 2018 Ripple Labs Inc. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== #include <ripple/app/ledger/BuildLedger.h> #include <ripple/app/ledger/Ledger.h> #include <ripple/app/ledger/LedgerReplay.h> #include <ripple/app/ledger/OpenLedger.h> #include <ripple/app/main/Application.h> #include <ripple/app/misc/CanonicalTXSet.h> #include <ripple/app/tx/apply.h> #include <ripple/protocol/Feature.h> namespace ripple { /* Generic buildLedgerImpl that dispatches to ApplyTxs invocable with signature void(OpenView&, std::shared_ptr<Ledger> const&) It is responsible for adding transactions to the open view to generate the new ledger. It is generic since the mechanics differ for consensus generated ledgers versus replayed ledgers. */ template <class ApplyTxs> std::shared_ptr<Ledger> buildLedgerImpl( std::shared_ptr<Ledger const> const& parent, NetClock::time_point closeTime, const bool closeTimeCorrect, NetClock::duration closeResolution, Application& app, beast::Journal j, ApplyTxs&& applyTxs) { auto built = std::make_shared<Ledger>(*parent, closeTime); if (built->isFlagLedger() && built->rules().enabled(featureNegativeUNL)) { built->updateNegativeUNL(); } // Set up to write SHAMap changes to our database, // perform updates, extract changes { OpenView accum(&*built); assert(!accum.open()); applyTxs(accum, built); accum.apply(*built); } built->updateSkipList(); { // Write the final version of all modified SHAMap // nodes to the node store to preserve the new LCL int const asf = built->stateMap().flushDirty(hotACCOUNT_NODE); int const tmf = built->txMap().flushDirty(hotTRANSACTION_NODE); JLOG(j.debug()) << "Flushed " << asf << " accounts and " << tmf << " transaction nodes"; } built->unshare(); // Accept ledger built->setAccepted( closeTime, closeResolution, closeTimeCorrect, app.config()); return built; } /** Apply a set of consensus transactions to a ledger. @param app Handle to application @param txns the set of transactions to apply, @param failed set of transactions that failed to apply @param view ledger to apply to @param j Journal for logging @return number of transactions applied; transactions to retry left in txns */ std::size_t applyTransactions( Application& app, std::shared_ptr<Ledger const> const& built, CanonicalTXSet& txns, std::set<TxID>& failed, OpenView& view, beast::Journal j) { bool certainRetry = true; std::size_t count = 0; // Attempt to apply all of the retriable transactions for (int pass = 0; pass < LEDGER_TOTAL_PASSES; ++pass) { JLOG(j.debug()) << (certainRetry ? "Pass: " : "Final pass: ") << pass << " begins (" << txns.size() << " transactions)"; int changes = 0; auto it = txns.begin(); while (it != txns.end()) { auto const txid = it->first.getTXID(); try { if (pass == 0 && built->txExists(txid)) { it = txns.erase(it); continue; } switch (applyTransaction( app, view, *it->second, certainRetry, tapNONE, j)) { case ApplyResult::Success: it = txns.erase(it); ++changes; break; case ApplyResult::Fail: failed.insert(txid); it = txns.erase(it); break; case ApplyResult::Retry: ++it; } } catch (std::exception const&) { JLOG(j.warn()) << "Transaction " << txid << " throws"; failed.insert(txid); it = txns.erase(it); } } JLOG(j.debug()) << (certainRetry ? "Pass: " : "Final pass: ") << pass << " completed (" << changes << " changes)"; // Accumulate changes. count += changes; // A non-retry pass made no changes if (!changes && !certainRetry) break; // Stop retriable passes if (!changes || (pass >= LEDGER_RETRY_PASSES)) certainRetry = false; } // If there are any transactions left, we must have // tried them in at least one final pass assert(txns.empty() || !certainRetry); return count; } // Build a ledger from consensus transactions std::shared_ptr<Ledger> buildLedger( std::shared_ptr<Ledger const> const& parent, NetClock::time_point closeTime, const bool closeTimeCorrect, NetClock::duration closeResolution, Application& app, CanonicalTXSet& txns, std::set<TxID>& failedTxns, beast::Journal j) { JLOG(j.debug()) << "Report: Transaction Set = " << txns.key() << ", close " << closeTime.time_since_epoch().count() << (closeTimeCorrect ? "" : " (incorrect)"); return buildLedgerImpl( parent, closeTime, closeTimeCorrect, closeResolution, app, j, [&](OpenView& accum, std::shared_ptr<Ledger> const& built) { JLOG(j.debug()) << "Attempting to apply " << txns.size() << " transactions"; auto const applied = applyTransactions(app, built, txns, failedTxns, accum, j); if (!txns.empty() || !failedTxns.empty()) JLOG(j.debug()) << "Applied " << applied << " transactions; " << failedTxns.size() << " failed and " << txns.size() << " will be retried."; else JLOG(j.debug()) << "Applied " << applied << " transactions."; }); } // Build a ledger by replaying std::shared_ptr<Ledger> buildLedger( LedgerReplay const& replayData, ApplyFlags applyFlags, Application& app, beast::Journal j) { auto const& replayLedger = replayData.replay(); JLOG(j.debug()) << "Report: Replay Ledger " << replayLedger->info().hash; return buildLedgerImpl( replayData.parent(), replayLedger->info().closeTime, ((replayLedger->info().closeFlags & sLCF_NoConsensusTime) == 0), replayLedger->info().closeTimeResolution, app, j, [&](OpenView& accum, std::shared_ptr<Ledger> const& built) { for (auto& tx : replayData.orderedTxns()) applyTransaction(app, accum, *tx.second, false, applyFlags, j); }); } } // namespace ripple
/*========================================================================= * * Copyright NumFOCUS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * *=========================================================================*/ #include "itkMath.h" #include "itkImage.h" #include "itkImageFileReader.h" #include "itkScalarImageToHistogramGenerator.h" #include "itkOtsuThresholdCalculator.h" #include "itkOtsuMultipleThresholdsCalculator.h" #include "itkTestingMacros.h" int itkOtsuThresholdCalculatorVersusOtsuMultipleThresholdsCalculatorTest(int argc, char * argv[]) { if (argc < 2) { std::cerr << "Missing parameters." << std::endl; std::cerr << "Usage:" << itkNameOfTestExecutableMacro(argv) << std::endl; std::cerr << " inputImageFile" << std::endl; return EXIT_FAILURE; } // Set up an OtsuThresholdCalculator and an OtsuMultipleThresholdsCalculator. // Set the OtsuMultipleThresholdsCalculator to have only one threshold. // Then test the computed thresholds for the two filters for various numbers of // histogram bins. // The two algorithms should output the same result. constexpr unsigned int ImageDimension = 2; using InputImageType = itk::Image<unsigned short, ImageDimension>; using ReaderType = itk::ImageFileReader<InputImageType>; int numberOfThresholds = 1; ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName(argv[1]); reader->Update(); using HistogramGeneratorType = itk::Statistics::ScalarImageToHistogramGenerator<InputImageType>; using HistogramType = HistogramGeneratorType::HistogramType; HistogramGeneratorType::Pointer histogramGenerator = HistogramGeneratorType::New(); histogramGenerator->SetInput(reader->GetOutput()); // Compute the OtsuThreshold for the input image. using OtsuCalculatorType = itk::OtsuThresholdCalculator<HistogramType>; OtsuCalculatorType::Pointer otsuCalculator = OtsuCalculatorType::New(); otsuCalculator->SetInput(histogramGenerator->GetOutput()); // Compute the OtsuMultipleThresholds for the input image using OtsuMultipleCalculatorType = itk::OtsuMultipleThresholdsCalculator<HistogramType>; OtsuMultipleCalculatorType::Pointer otsuMultipleCalculator = OtsuMultipleCalculatorType::New(); otsuMultipleCalculator->SetInputHistogram(histogramGenerator->GetOutput()); otsuMultipleCalculator->SetNumberOfThresholds(numberOfThresholds); static constexpr int binsArray[] = { 4, 8, 16, 32, 64, 128, 256, 512, 1024 }; std::vector<int> binsVector(binsArray, binsArray + sizeof(binsArray) / sizeof(binsArray[0])); for (const auto & binsIterator : binsVector) { histogramGenerator->SetNumberOfBins(binsIterator); histogramGenerator->Compute(); otsuCalculator->Compute(); if (itk::Math::NotAlmostEquals(otsuCalculator->GetThreshold(), otsuMultipleCalculator->GetOutput()[0])) { std::cerr << "Test failed!" << std::endl; std::cerr << "Error in itk::OtsuThresholdCalculator::GetThreshold() or \ itk::OtsuMultipleThresholdsCalculator::GetOutput()" << std::endl; std::cout << "Computed Otsu threshold: " << otsuCalculator->GetThreshold() << " is different from computed Otsu multiple threshold: " << otsuMultipleCalculator->GetOutput()[0] << std::endl; return EXIT_FAILURE; } } std::cout << "Test finished" << std::endl; return EXIT_SUCCESS; }
// Classic Shell (c) 2009-2017, Ivo Beltchev // Open-Shell (c) 2017-2018, The Open-Shell Team // Confidential information of Ivo Beltchev. Not for disclosure or distribution without prior written consent from the author #include "stdafx.h" #include "ExplorerBand.h" #include "ExplorerBHO.h" #include "SettingsUI.h" #include "Settings.h" #include "SettingsUIHelper.h" #include "LanguageSettingsHelper.h" #include "ResourceHelper.h" #include "Translations.h" #include "resource.h" #include "dllmain.h" #include <dwmapi.h> enum { SETTINGS_STYLE_WIN7=1, SETTINGS_STYLE_WIN8=2, SETTINGS_STYLE_MASK=SETTINGS_STYLE_WIN7|SETTINGS_STYLE_WIN8, }; static const CStdCommand g_StdCommands[]={ {L"SEPARATOR",IDS_SEPARATOR_ITEM,IDS_SEPARATOR_TIP}, {L"up",IDS_UP_ITEM,IDS_UP_TIP,L"UpItem",NULL,L"$Toolbar.GoUp",L",2",NULL,0,L",3"}, {L"cut",IDS_CUT_ITEM,IDS_CUT_TIP,L"CutItem",NULL,L"$Toolbar.Cut",L"shell32.dll,16762"}, {L"copy",IDS_COPY_ITEM,IDS_COPY_TIP,L"CopyItem",NULL,L"$Toolbar.Copy",L"shell32.dll,243"}, {L"paste",IDS_PASTE_ITEM,IDS_PASTE_TIP,L"PasteItem",NULL,L"$Toolbar.Paste",L"shell32.dll,16763"}, {L"paste_shortcut",IDS_PASTE_LNK_ITEM,IDS_PASTE_SHORTCUT_TIP,L"PasteShortcutItem",NULL,L"$Toolbar.PasteShortcut",L"shell32.dll,16763",NULL,SETTINGS_STYLE_WIN7}, {L"paste_shortcut",IDS_PASTE_LNK_ITEM,IDS_PASTE_SHORTCUT_TIP,L"PasteShortcutItem",NULL,L"$Toolbar.PasteShortcut",L"imageres.dll,5301",NULL,SETTINGS_STYLE_WIN8}, {L"delete",IDS_DELETE_ITEM,IDS_DELETE_TIP,L"DeleteItem",NULL,L"$Toolbar.Delete",L"shell32.dll,240"}, {L"properties",IDS_PROPERTIES_ITEM,IDS_PROPERTIES_TIP,L"PropertiesItem",NULL,L"$Toolbar.Properties",L"shell32.dll,253"}, {L"email",IDS_EMAIL_ITEM,IDS_EMAIL_TIP,L"EmailItem",NULL,L"$Toolbar.Email",L"shell32.dll,265"}, {L"settings",IDS_SETTINGS_ITEM,IDS_SETTINGS_TIP,L"SettingsItem",NULL,L"$Toolbar.Settings",L",1"}, {L"refresh",IDS_REFRESH_ITEM,IDS_REFRESH_TIP,L"RefreshItem",NULL,L"$Toolbar.Refresh",L"shell32.dll,16739"}, {L"stop",IDS_STOP_ITEM,IDS_STOP_TIP,L"StopItem",NULL,L"$Toolbar.Stop",L"imageres.dll,98"}, {L"rename",IDS_RENAME_ITEM,IDS_RENAME_TIP,L"RenameItem",NULL,L"$Toolbar.Rename",L"shell32.dll,242"}, {L"customizefolder",IDS_CUSTOMIZE_ITEM,IDS_CUSTOMIZEFOLDER_TIP,L"CustomizeFolderItem",NULL,L"$Toolbar.CustomizeFolder",L"shell32.dll,274"}, {L"folderoptions",IDS_FOLDEROPTIONS,IDS_FOLDEROPTIONS_TIP,L"FolderOptionsItem",NULL,L"$Toolbar.FolderOptions",L"imageres.dll,166"}, {L"newfolder",IDS_NEWFOLDER_ITEM,IDS_NEWFOLDER_TIP,L"NewFolderItem",NULL,L"$Toolbar.NewFolder",L"shell32.dll,319"}, {L"zipfolder",IDS_ZIP_ITEM,IDS_ZIP_TIP,L"ZipItem",NULL,L"$Toolbar.ZipFolder",L"imageres.dll,174"}, {L"nav_pane",IDS_NAVPANE_ITEM,IDS_NAVPANE_TIP,L"NavPaneItem",NULL,L"$Toolbar.NavigationPane",L"shell32.dll,16755"}, {L"details_pane",IDS_DETAILSPANE_ITEM,IDS_DETAILSPANE_TIP,L"DetailsPaneItem",NULL,L"$Toolbar.DetailsPane",L"shell32.dll,16759",NULL,SETTINGS_STYLE_WIN7}, {L"details_pane",IDS_DETAILSPANE_ITEM,IDS_DETAILSPANE_TIP,L"DetailsPaneItem",NULL,L"$Toolbar.DetailsPane",L"shell32.dll,16814",NULL,SETTINGS_STYLE_WIN8}, {L"preview_pane",IDS_PREVIEWPANE_ITEM,IDS_PREVIEWPANE_TIP,L"PreviewPaneItem",NULL,L"$Toolbar.PreviewPane",L"shell32.dll,16757"}, {L"mapdrive",IDS_MAP_DRIVE_ITEM,IDS_MAP_DRIVE_TIP,L"MapDriveItem",NULL,L"$Toolbar.MapDrive",L"shell32.dll,16779"}, {L"disconnect",IDS_DISCONNECT_ITEM,IDS_DISCONNECT_DRIVE_TIP,L"DisconnectItem",NULL,L"$Toolbar.DisconnectDrive",L"shell32.dll,11"}, {L"viewtiles",IDS_VIEWTILES_ITEM,IDS_VIEWTILES_TIP,L"TilesItem",NULL,L"$Toolbar.Tiles",L"shell32.dll,62999"}, {L"viewdetails",IDS_VIEWDETAILS_ITEM,IDS_VIEWDEATAILS_TIP,L"DetailsItem",NULL,L"$Toolbar.Details",L"shell32.dll,62998"}, {L"viewlist",IDS_VIEWLIST_ITEM,IDS_VIEWLIST_TIP,L"ListItem",NULL,L"$Toolbar.List",L"shell32.dll,63000"}, {L"viewcontent",IDS_VIEWCONTENT_ITEM,IDS_VIEWCONTENT_TIP,L"ContentItem",NULL,L"$Toolbar.Content",L"shell32.dll,63011"}, {L"viewicons_small",IDS_VIEWICONS1_ITEM,IDS_VIEWICONS1_TIP,L"Icons1Item",NULL,L"$Toolbar.Small",L"shell32.dll,63010"}, {L"viewicons_medium",IDS_VIEWICONS2_ITEM,IDS_VIEWICONS2_TIP,L"Icons2Item",NULL,L"$Toolbar.Medium",L"shell32.dll,63009"}, {L"viewicons_large",IDS_VIEWICONS3_ITEM,IDS_VIEWICONS3_TIP,L"Icons3Item",NULL,L"$Toolbar.Large",L"shell32.dll,63008"}, {L"viewicons_extralarge",IDS_VIEWICONS4_ITEM,IDS_VIEWICONS4_TIP,L"Icons4Item",NULL,L"$Toolbar.ExtraLarge",L"shell32.dll,63001"}, {L"moveto",IDS_MOVETO_ITEM,IDS_MOVETO_TIP,L"MoveToItem",NULL,L"$Toolbar.MoveTo",L"",NULL,SETTINGS_STYLE_WIN7}, {L"moveto",IDS_MOVETO_ITEM,IDS_MOVETO_TIP,L"MoveToItem",NULL,L"$Toolbar.MoveTo",L"imageres.dll,5303",NULL,SETTINGS_STYLE_WIN8}, {L"copyto",IDS_COPYTO_ITEM,IDS_COPYTO_TIP,L"CopyToItem",NULL,L"$Toolbar.CopyTo",L"",NULL,SETTINGS_STYLE_WIN7}, {L"copyto",IDS_COPYTO_ITEM,IDS_COPYTO_TIP,L"CopyToItem",NULL,L"$Toolbar.CopyTo",L"imageres.dll,5304",NULL,SETTINGS_STYLE_WIN8}, {L"undo",IDS_UNDO_ITEM,IDS_UNDO_TIP,L"UndoItem",NULL,L"$Toolbar.Undo",L"",NULL,SETTINGS_STYLE_WIN7}, {L"undo",IDS_UNDO_ITEM,IDS_UNDO_TIP,L"UndoItem",NULL,L"$Toolbar.Undo",L"imageres.dll,5315",NULL,SETTINGS_STYLE_WIN8}, {L"redo",IDS_REDO_ITEM,IDS_REDO_TIP,L"RedoItem",NULL,L"$Toolbar.Redo",L"",NULL,SETTINGS_STYLE_WIN7}, {L"redo",IDS_REDO_ITEM,IDS_REDO_TIP,L"RedoItem",NULL,L"$Toolbar.Redo",L"imageres.dll,5311",NULL,SETTINGS_STYLE_WIN8}, {L"selectall",IDS_SELECTALL_ITEM,IDS_SELECTALL_TIP,L"SelectAllItem",NULL,L"$Toolbar.SelectAll",L"",NULL,SETTINGS_STYLE_WIN7}, {L"selectall",IDS_SELECTALL_ITEM,IDS_SELECTALL_TIP,L"SelectAllItem",NULL,L"$Toolbar.SelectAll",L"imageres.dll,5308",NULL,SETTINGS_STYLE_WIN8}, {L"deselect",IDS_DESELECT_ITEM,IDS_DESELECT_TIP,L"DeselectItem",NULL,L"$Toolbar.Deselect",L"",NULL,SETTINGS_STYLE_WIN7}, {L"deselect",IDS_DESELECT_ITEM,IDS_DESELECT_TIP,L"DeselectItem",NULL,L"$Toolbar.Deselect",L"imageres.dll,5309",NULL,SETTINGS_STYLE_WIN8}, {L"invertselection",IDS_INVERT_ITEM,IDS_INVERT_TIP,L"InvertItem",NULL,L"$Toolbar.InvertSelection",L"",NULL,SETTINGS_STYLE_WIN7}, {L"invertselection",IDS_INVERT_ITEM,IDS_INVERT_TIP,L"InvertItem",NULL,L"$Toolbar.InvertSelection",L"imageres.dll,5310",NULL,SETTINGS_STYLE_WIN8}, {L"back",IDS_BACK_ITEM,IDS_BACK_TIP,L"BackItem",NULL,L"$Toolbar.Back",L""}, {L"forward",IDS_FORWARD_ITEM,IDS_FORWARD_TIP,L"ForwardItem",NULL,L"$Toolbar.Forward",L""}, {L"show_extensions",IDS_SHOW_EXTENSIONS,IDS_SHOW_EXTENSIONS_TIP,L"ShowExtensionsItem",NULL,L"$Toolbar.ShowExtensions"}, {L"hidden_files",IDS_HIDDEN_FILES,IDS_HIDDEN_FILES_TIP,L"HiddenFilesItem",NULL,L"$Toolbar.ShowHiddenFiles"}, {L"system_files",IDS_SYSTEM_FILES,IDS_SYSTEM_FILES_TIP,L"SystemFilesItem",NULL,L"$Toolbar.ShowSystemFiles"}, {L"open <folder name>",IDS_OPEN_ITEM,IDS_OPEN_TIP,L"OpenFolderItem",NULL,NULL,L""}, {L"sortby <property>",IDS_SORYBY_ITEM,IDS_SORT_TIP,L"SortFolderItem",NULL,NULL,L""}, {L"groupby <property>",IDS_GROUPBY_ITEM,IDS_GROUP_TIP,L"GroupFolderItem",NULL,NULL,L""}, {L"",IDS_CUSTOM_ITEM,IDS_CUSTOM_TIP,L"CustomItem",NULL,NULL,L""}, {NULL}, }; static const KNOWNFOLDERID *g_CommonLinks[]= { &FOLDERID_ComputerFolder, &FOLDERID_DesktopRoot, &FOLDERID_Desktop, &FOLDERID_Documents, &FOLDERID_Downloads, &FOLDERID_Favorites, &FOLDERID_Games, &FOLDERID_Links, &FOLDERID_Music, &FOLDERID_Pictures, &FOLDERID_Videos, &FOLDERID_Profile, &FOLDERID_HomeGroup, &FOLDERID_Libraries, &FOLDERID_DocumentsLibrary, &FOLDERID_MusicLibrary, &FOLDERID_PicturesLibrary, &FOLDERID_VideosLibrary, &FOLDERID_NetworkFolder, NULL, }; const wchar_t *g_DefaultToolbar= L"Items=UpItem, NavPaneItem, FolderOptionsItem, CutItem, CopyItem, PasteItem, DeleteItem, PropertiesItem, EmailItem, SEPARATOR, SettingsItem\n" L"UpItem.Command=up\n" L"UpItem.Tip=$Toolbar.GoUp\n" L"UpItem.Icon=,2\n" L"UpItem.IconDisabled=,3\n" L"NavPaneItem.Command=nav_pane\n" L"NavPaneItem.Tip=$Toolbar.NavigationPane\n" L"NavPaneItem.Icon=shell32.dll,16755\n" L"FolderOptionsItem.Command=folderoptions\n" L"FolderOptionsItem.Tip=$Toolbar.FolderOptions\n" L"FolderOptionsItem.Icon=imageres.dll,166\n" L"FolderOptionsItem.Items=ShowExtensionsItem, HiddenFilesItem, SystemFilesItem\n" L"ShowExtensionsItem.Command=show_extensions\n" L"ShowExtensionsItem.Label=$Toolbar.ShowExtensions\n" L"ShowExtensionsItem.Icon=none\n" L"HiddenFilesItem.Command=hidden_files\n" L"HiddenFilesItem.Label=$Toolbar.ShowHiddenFiles\n" L"HiddenFilesItem.Icon=none\n" L"SystemFilesItem.Command=system_files\n" L"SystemFilesItem.Label=$Toolbar.ShowSystemFiles\n" L"SystemFilesItem.Icon=none\n" L"CutItem.Command=cut\n" L"CutItem.Tip=$Toolbar.Cut\n" L"CutItem.Icon=shell32.dll,16762\n" L"CopyItem.Command=copy\n" L"CopyItem.Tip=$Toolbar.Copy\n" L"CopyItem.Icon=shell32.dll,243\n" L"PasteItem.Command=paste\n" L"PasteItem.Tip=$Toolbar.Paste\n" L"PasteItem.Icon=shell32.dll,16763\n" L"DeleteItem.Command=delete\n" L"DeleteItem.Tip=$Toolbar.Delete\n" L"DeleteItem.Icon=shell32.dll,240\n" L"PropertiesItem.Command=properties\n" L"PropertiesItem.Tip=$Toolbar.Properties\n" L"PropertiesItem.Icon=shell32.dll,253\n" L"EmailItem.Command=email\n" L"EmailItem.Tip=$Toolbar.Email\n" L"EmailItem.Icon=shell32.dll,265\n" L"SettingsItem.Command=settings\n" L"SettingsItem.Tip=$Toolbar.Settings\n" L"SettingsItem.Icon=,1\n"; const wchar_t *g_DefaultToolbar2= L"Items=NavPaneItem, FolderOptionsItem, CutItem, CopyItem, PasteItem, DeleteItem, PropertiesItem, EmailItem, SEPARATOR, SettingsItem\n" L"NavPaneItem.Command=nav_pane\n" L"NavPaneItem.Tip=$Toolbar.NavigationPane\n" L"NavPaneItem.Icon=shell32.dll,16755\n" L"FolderOptionsItem.Command=folderoptions\n" L"FolderOptionsItem.Tip=$Toolbar.FolderOptions\n" L"FolderOptionsItem.Icon=imageres.dll,166\n" L"FolderOptionsItem.Items=ShowExtensionsItem, HiddenFilesItem, SystemFilesItem\n" L"ShowExtensionsItem.Command=show_extensions\n" L"ShowExtensionsItem.Label=$Toolbar.ShowExtensions\n" L"ShowExtensionsItem.Icon=none\n" L"HiddenFilesItem.Command=hidden_files\n" L"HiddenFilesItem.Label=$Toolbar.ShowHiddenFiles\n" L"HiddenFilesItem.Icon=none\n" L"SystemFilesItem.Command=system_files\n" L"SystemFilesItem.Label=$Toolbar.ShowSystemFiles\n" L"SystemFilesItem.Icon=none\n" L"CutItem.Command=cut\n" L"CutItem.Tip=$Toolbar.Cut\n" L"CutItem.Icon=shell32.dll,16762\n" L"CopyItem.Command=copy\n" L"CopyItem.Tip=$Toolbar.Copy\n" L"CopyItem.Icon=shell32.dll,243\n" L"PasteItem.Command=paste\n" L"PasteItem.Tip=$Toolbar.Paste\n" L"PasteItem.Icon=shell32.dll,16763\n" L"DeleteItem.Command=delete\n" L"DeleteItem.Tip=$Toolbar.Delete\n" L"DeleteItem.Icon=shell32.dll,240\n" L"PropertiesItem.Command=properties\n" L"PropertiesItem.Tip=$Toolbar.Properties\n" L"PropertiesItem.Icon=shell32.dll,253\n" L"EmailItem.Command=email\n" L"EmailItem.Tip=$Toolbar.Email\n" L"EmailItem.Icon=shell32.dll,265\n" L"SettingsItem.Command=settings\n" L"SettingsItem.Tip=$Toolbar.Settings\n" L"SettingsItem.Icon=,1\n"; /////////////////////////////////////////////////////////////////////////////// class CEditToolbarDlg: public CEditCustomItemDlg { public: CEditToolbarDlg( CTreeItem *pItem, bool bNoLinks, std::vector<HMODULE> &modules ): CEditCustomItemDlg(pItem,modules) { m_bNoLinks=bNoLinks; } BEGIN_MSG_MAP( CEditToolbarDlg ) MESSAGE_HANDLER( WM_INITDIALOG, OnInitDialog ) COMMAND_ID_HANDLER( IDOK, OnOK ) COMMAND_ID_HANDLER( IDCANCEL, OnCancel ) COMMAND_HANDLER( IDC_COMBOCOMMAND, CBN_KILLFOCUS, OnCommandChanged ) COMMAND_HANDLER( IDC_COMBOCOMMAND, CBN_SELENDOK, OnCommandChanged ) COMMAND_HANDLER( IDC_BUTTONCOMMAND, BN_CLICKED, OnBrowseCommand ) COMMAND_HANDLER( IDC_BUTTONLINK, BN_CLICKED, OnBrowseLink ) COMMAND_HANDLER( IDC_BUTTONICON, BN_CLICKED, OnBrowseIcon ) COMMAND_HANDLER( IDC_BUTTONICOND, BN_CLICKED, OnBrowseIcon ) COMMAND_HANDLER( IDC_COMBOLINK, CBN_KILLFOCUS, OnLinkChanged ) COMMAND_HANDLER( IDC_COMBOLINK, CBN_SELENDOK, OnLinkChanged ) COMMAND_HANDLER( IDC_EDITICON, EN_KILLFOCUS, OnIconChanged ) COMMAND_HANDLER( IDC_EDITICOND, EN_KILLFOCUS, OnIconDChanged ) COMMAND_HANDLER( IDC_BUTTONRESET, BN_CLICKED, OnReset ) CHAIN_MSG_MAP( CEditCustomItemDlg ) END_MSG_MAP() virtual BEGIN_RESIZE_MAP RESIZE_CONTROL(IDC_COMBOCOMMAND,MOVE_SIZE_X) RESIZE_CONTROL(IDC_COMBOLINK,MOVE_SIZE_X) RESIZE_CONTROL(IDC_BUTTONCOMMAND,MOVE_MOVE_X) RESIZE_CONTROL(IDC_BUTTONLINK,MOVE_MOVE_X) RESIZE_CONTROL(IDC_EDITLABEL,MOVE_SIZE_X) RESIZE_CONTROL(IDC_EDITTIP,MOVE_SIZE_X) RESIZE_CONTROL(IDC_EDITICON,MOVE_SIZE_X) RESIZE_CONTROL(IDC_BUTTONICON,MOVE_MOVE_X) RESIZE_CONTROL(IDC_EDITICOND,MOVE_SIZE_X) RESIZE_CONTROL(IDC_BUTTONICOND,MOVE_MOVE_X) RESIZE_CONTROL(IDOK,MOVE_MOVE_X) RESIZE_CONTROL(IDCANCEL,MOVE_MOVE_X) END_RESIZE_MAP protected: // Handler prototypes: // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); LRESULT OnInitDialog( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled ); LRESULT OnOK( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled ); LRESULT OnCommandChanged( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled ); LRESULT OnLinkChanged( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled ); LRESULT OnIconChanged( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled ); LRESULT OnIconDChanged( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled ); LRESULT OnBrowseCommand( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled ); LRESULT OnBrowseLink( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled ); LRESULT OnBrowseIcon( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled ); LRESULT OnReset( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled ); private: bool m_bNoLinks; int m_Style; }; LRESULT CEditToolbarDlg::OnInitDialog( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled ) { m_Style=GetWinVersion()>=WIN_VER_WIN8?SETTINGS_STYLE_WIN8:SETTINGS_STYLE_WIN7; CWindow commands=GetDlgItem(IDC_COMBOCOMMAND); CWindow links=GetDlgItem(IDC_COMBOLINK); InitDialog(commands,g_StdCommands,m_Style,SETTINGS_STYLE_MASK,links,g_CommonLinks); SetDlgItemText(IDC_EDITLABEL,m_pItem->label); SetDlgItemText(IDC_EDITTIP,m_pItem->tip); SetDlgItemText(IDC_EDITICON,m_pItem->icon); SetDlgItemText(IDC_EDITICOND,m_pItem->iconD); GetDlgItem(IDC_BUTTONRESET).EnableWindow(m_pItem->pStdCommand && *m_pItem->pStdCommand->name); UpdateIcons(IDC_ICONN,IDC_ICOND); CWindow tooltip=CreateWindowEx(WS_EX_TOPMOST|WS_EX_TOOLWINDOW|WS_EX_TRANSPARENT,TOOLTIPS_CLASS,NULL,WS_POPUP|TTS_NOPREFIX|TTS_ALWAYSTIP,0,0,0,0,m_hWnd,NULL,g_Instance,NULL); tooltip.SendMessage(TTM_SETMAXTIPWIDTH,0,GetSystemMetrics(SM_CXSCREEN)/2); TOOLINFO tool={sizeof(tool),TTF_SUBCLASS|TTF_IDISHWND,m_hWnd,(UINT_PTR)(HWND)commands}; CString str=LoadStringEx(IDS_COMMAND_TIP); tool.lpszText=(LPWSTR)(LPCWSTR)str; tooltip.SendMessage(TTM_ADDTOOL,0,(LPARAM)&tool); tool.uId=(UINT_PTR)(HWND)commands.GetWindow(GW_CHILD); tooltip.SendMessage(TTM_ADDTOOL,0,(LPARAM)&tool); str=LoadStringEx(IDS_LINK_TIP); tool.lpszText=(LPWSTR)(LPCWSTR)str; tool.uId=(UINT_PTR)(HWND)links; tooltip.SendMessage(TTM_ADDTOOL,0,(LPARAM)&tool); tool.uId=(UINT_PTR)(HWND)links.GetWindow(GW_CHILD); tooltip.SendMessage(TTM_ADDTOOL,0,(LPARAM)&tool); str=LoadStringEx(IDS_TEXT_TIP); tool.lpszText=(LPWSTR)(LPCWSTR)str; tool.uId=(UINT_PTR)(HWND)GetDlgItem(IDC_EDITLABEL); tooltip.SendMessage(TTM_ADDTOOL,0,(LPARAM)&tool); str=LoadStringEx(IDS_TIP_TIP); tool.lpszText=(LPWSTR)(LPCWSTR)str; tool.uId=(UINT_PTR)(HWND)GetDlgItem(IDC_EDITTIP); tooltip.SendMessage(TTM_ADDTOOL,0,(LPARAM)&tool); str=LoadStringEx(IDS_ICON_TIP); tool.lpszText=(LPWSTR)(LPCWSTR)str; tool.uId=(UINT_PTR)(HWND)GetDlgItem(IDC_EDITICON); tooltip.SendMessage(TTM_ADDTOOL,0,(LPARAM)&tool); str=LoadStringEx(IDS_ICOND_TIP); tool.lpszText=(LPWSTR)(LPCWSTR)str; tool.uId=(UINT_PTR)(HWND)GetDlgItem(IDC_EDITICOND); tooltip.SendMessage(TTM_ADDTOOL,0,(LPARAM)&tool); str=LoadStringEx(IDS_RESTORE_TIP); tool.lpszText=(LPWSTR)(LPCWSTR)str; tool.uId=(UINT_PTR)(HWND)GetDlgItem(IDC_BUTTONRESET); tooltip.SendMessage(TTM_ADDTOOL,0,(LPARAM)&tool); return TRUE; } LRESULT CEditToolbarDlg::OnOK( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled ) { GetDlgItemText(IDC_EDITLABEL,m_pItem->label); m_pItem->label.TrimLeft(); m_pItem->label.TrimRight(); GetDlgItemText(IDC_EDITTIP,m_pItem->tip); m_pItem->tip.TrimLeft(); m_pItem->tip.TrimRight(); return CEditCustomItemDlg::OnOK(wNotifyCode,wID,hWndCtl,bHandled); } LRESULT CEditToolbarDlg::OnCommandChanged( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled ) { CString text=GetComboText(wNotifyCode,wID); if (text==m_pItem->command) return 0; m_pItem->SetCommand(text,g_StdCommands,m_Style,SETTINGS_STYLE_MASK); GetDlgItem(IDC_BUTTONRESET).EnableWindow(m_pItem->pStdCommand && *m_pItem->pStdCommand->name); UpdateIcons(IDC_ICONN,IDC_ICOND); return 0; } LRESULT CEditToolbarDlg::OnLinkChanged( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled ) { CString text=GetComboText(wNotifyCode,wID); if (text==m_pItem->link) return 0; m_pItem->link=text; UpdateIcons(IDC_ICONN,IDC_ICOND); return 0; } LRESULT CEditToolbarDlg::OnIconChanged( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled ) { CString text; GetDlgItemText(IDC_EDITICON,text); text.TrimLeft(); text.TrimRight(); if (text==m_pItem->icon) return 0; m_pItem->icon=text; UpdateIcons(IDC_ICONN,IDC_ICOND); return 0; } LRESULT CEditToolbarDlg::OnIconDChanged( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled ) { CString text; GetDlgItemText(IDC_EDITICOND,text); text.TrimLeft(); text.TrimRight(); if (text==m_pItem->iconD) return 0; m_pItem->iconD=text; UpdateIcons(IDC_ICONN,IDC_ICOND); return 0; } LRESULT CEditToolbarDlg::OnBrowseCommand( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled ) { wchar_t text[_MAX_PATH]; GetDlgItemText(IDC_COMBOCOMMAND,text,_countof(text)); if (BrowseCommandHelper(m_hWnd,text)) { SetDlgItemText(IDC_COMBOCOMMAND,text); SendMessage(WM_COMMAND,MAKEWPARAM(IDC_COMBOCOMMAND,CBN_KILLFOCUS)); } return 0; } LRESULT CEditToolbarDlg::OnBrowseLink( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled ) { wchar_t text[_MAX_PATH]; GetDlgItemText(IDC_COMBOLINK,text,_countof(text)); if (BrowseLinkHelper(m_hWnd,text)) { SetDlgItemText(IDC_COMBOLINK,text); SendMessage(WM_COMMAND,MAKEWPARAM(IDC_COMBOLINK,CBN_KILLFOCUS)); } return 0; } LRESULT CEditToolbarDlg::OnBrowseIcon( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled ) { wchar_t text[_MAX_PATH]; if (wID==IDC_BUTTONICON) wID=IDC_EDITICON; if (wID==IDC_BUTTONICOND) wID=IDC_EDITICOND; GetDlgItemText(wID,text,_countof(text)); if (wID==IDC_EDITICOND && !*text) GetDlgItemText(IDC_EDITICON,text,_countof(text)); if (BrowseIconHelper(m_hWnd,text)) { SetDlgItemText(wID,text); SendMessage(WM_COMMAND,MAKEWPARAM(wID,EN_KILLFOCUS)); } return 0; } LRESULT CEditToolbarDlg::OnReset( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled ) { if (!m_pItem->pStdCommand || !*m_pItem->pStdCommand->name) return 0; m_pItem->link.Empty(); m_pItem->label=m_pItem->pStdCommand->label; m_pItem->tip=m_pItem->pStdCommand->tip; m_pItem->icon=m_pItem->pStdCommand->icon; m_pItem->iconD=m_pItem->pStdCommand->iconD; SendDlgItemMessage(IDC_COMBOLINK,CB_SETCURSEL,-1); SetDlgItemText(IDC_EDITLABEL,m_pItem->label); SetDlgItemText(IDC_EDITTIP,m_pItem->tip); SetDlgItemText(IDC_EDITICON,m_pItem->icon); SetDlgItemText(IDC_EDITICOND,m_pItem->iconD); UpdateIcons(IDC_ICONN,IDC_ICOND); return 0; } /////////////////////////////////////////////////////////////////////////////// class CCustomToolbarDlg: public CCustomTreeDlg { public: CCustomToolbarDlg( void ): CCustomTreeDlg(false,g_StdCommands,GetWinVersion()>=WIN_VER_WIN8?SETTINGS_STYLE_WIN8:SETTINGS_STYLE_WIN7,SETTINGS_STYLE_MASK) {} protected: virtual void ParseTreeItemExtra( CTreeItem *pItem, CSettingsParser &parser ); virtual void SerializeItemExtra( CTreeItem *pItem, std::vector<wchar_t> &stringBuilder ); virtual bool EditItem( CTreeItem *pItem, HWND tree, HTREEITEM hItem, std::vector<HMODULE> &modules ); }; void CCustomToolbarDlg::ParseTreeItemExtra( CTreeItem *pItem, CSettingsParser &parser ) { wchar_t text[256]; Sprintf(text,_countof(text),L"%s.IconDisabled",pItem->name); pItem->iconD=parser.FindSetting(text,L""); } void CCustomToolbarDlg::SerializeItemExtra( CTreeItem *pItem, std::vector<wchar_t> &stringBuilder ) { if (!pItem->iconD.IsEmpty()) { wchar_t text[2048]; Sprintf(text,_countof(text),L"%s.IconDisabled=%s\n",pItem->name,pItem->iconD); AppendString(stringBuilder,text); } } bool CCustomToolbarDlg::EditItem( CTreeItem *pItem, HWND tree, HTREEITEM hItem, std::vector<HMODULE> &modules ) { bool bNoLinks=(TreeView_GetParent(tree,hItem) || TreeView_GetChild(tree,hItem)); return CEditToolbarDlg(pItem,bNoLinks,modules).Run(m_hWnd,IDD_CUSTOMTOOLBAR); } class CCustomToolbarPanel: public ISettingsPanel { public: virtual HWND Create( HWND parent ); virtual HWND Activate( CSetting *pGroup, const RECT &rect, bool bReset ); virtual bool Validate( HWND parent ) { return true; } private: static CCustomToolbarDlg s_Dialog; }; CCustomToolbarDlg CCustomToolbarPanel::s_Dialog; HWND CCustomToolbarPanel::Create( HWND parent ) { if (!s_Dialog.m_hWnd) s_Dialog.Create(parent,LoadDialogEx(IDD_CUSTOMTREE)); return s_Dialog.m_hWnd; } HWND CCustomToolbarPanel::Activate( CSetting *pGroup, const RECT &rect, bool bReset ) { s_Dialog.SetGroup(pGroup,bReset); s_Dialog.SetWindowPos(HWND_TOP,&rect,SWP_SHOWWINDOW); return s_Dialog.m_hWnd; } static CCustomToolbarPanel g_CustomToolbarPanel; /////////////////////////////////////////////////////////////////////////////// static CSetting g_Settings[]={ {L"Basic",CSetting::TYPE_GROUP,IDS_BASIC_SETTINGS}, {L"EnableSettings",CSetting::TYPE_BOOL,0,0,1,CSetting::FLAG_HIDDEN|CSetting::FLAG_NOSAVE}, {L"ProcessWhiteList",CSetting::TYPE_STRING,0,0,L"",CSetting::FLAG_HIDDEN|CSetting::FLAG_NOSAVE}, {L"ProcessBlackList",CSetting::TYPE_STRING,0,0,L"",CSetting::FLAG_HIDDEN|CSetting::FLAG_NOSAVE}, {L"NoInitialToolbar",CSetting::TYPE_BOOL,0,0,0,CSetting::FLAG_HIDDEN|CSetting::FLAG_NOSAVE}, {L"NavigationPane",CSetting::TYPE_GROUP,IDS_NAVIGATION_SETTINGS}, {L"TreeStyle",CSetting::TYPE_INT,IDS_TREE_STYLE,IDS_TREE_STYLE_TIP,2,CSetting::FLAG_WARM|CSetting::FLAG_BASIC}, {L"XPClassic",CSetting::TYPE_RADIO,IDS_XPCLASSIC,IDS_XPCLASSIC_TIP}, {L"XPSimple",CSetting::TYPE_RADIO,IDS_XPSIMPLE,IDS_XPSIMPLE_TIP}, {L"Vista",CSetting::TYPE_RADIO,IDS_VISTA,IDS_VISTA_TIP}, {L"HScrollbar",CSetting::TYPE_INT,IDS_SCROLLBAR,IDS_SCROLLBAR_TIP,0,CSetting::FLAG_WARM}, {L"Default",CSetting::TYPE_RADIO,IDS_SCROLLBAR_DEFAULT,IDS_SCROLLBAR_DEFAULT_TIP}, {L"Off",CSetting::TYPE_RADIO,IDS_SCROLLBAR_OFF,IDS_SCROLLBAR_OFF_TIP}, {L"On",CSetting::TYPE_RADIO,IDS_SCROLLBAR_ON,IDS_SCROLLBAR_ON_TIP}, {L"NoFadeButtons",CSetting::TYPE_BOOL,IDS_NO_FADE,IDS_NO_FADE_TIP,0,CSetting::FLAG_WARM,L"TreeStyle"}, {L"TreeItemSpacing",CSetting::TYPE_INT,IDS_TREE_SPACING,IDS_TREE_SPACING_TIP,0,CSetting::FLAG_WARM}, {L"FullIndent",CSetting::TYPE_BOOL,IDS_FULL_INDENT,IDS_FULL_INDENT_TIP,0,CSetting::FLAG_WARM,L"TreeStyle"}, {L"AutoNavigate",CSetting::TYPE_INT,IDS_NAVIGATE,IDS_NAVIGATE_TIP,0,CSetting::FLAG_WARM|CSetting::FLAG_BASIC}, {L"Default",CSetting::TYPE_RADIO,IDS_NAV_DEFAULT,IDS_NAV_DEFAULT_TIP}, {L"KeyboardOnly",CSetting::TYPE_RADIO,IDS_NAV_KBD,IDS_NAV_KBD_TIP}, {L"Always",CSetting::TYPE_RADIO,IDS_NAV_ALWAYS,IDS_NAV_ALWAYS_TIP}, {L"AutoNavDelay",CSetting::TYPE_INT,IDS_NAV_DELAY,IDS_NAV_DELAY_TIP,100,CSetting::FLAG_WARM,L"AutoNavigate"}, {L"AltEnter",CSetting::TYPE_BOOL,IDS_ALT_ENTER,IDS_ALT_ENTER_TIP,1,CSetting::FLAG_WARM|CSetting::FLAG_BASIC}, {L"FixFolderScroll",CSetting::TYPE_BOOL,IDS_FIX_SCROLL,IDS_FIX_SCROLL_TIP,1,CSetting::FLAG_WARM}, {L"TitleBar",CSetting::TYPE_GROUP,IDS_TITLE_SETTINGS}, {L"ShowCaption",CSetting::TYPE_BOOL,IDS_SHOW_CAPTION,IDS_SHOW_CAPTION_TIP,0,CSetting::FLAG_WARM}, {L"ShowIcon",CSetting::TYPE_BOOL,IDS_SHOW_ICON,IDS_SHOW_ICON_TIP,0,CSetting::FLAG_WARM}, {L"DisableBreadcrumbs",CSetting::TYPE_BOOL,IDS_NO_BREADCRUMBS,IDS_NO_BREADCRUMBS_TIP,0,CSetting::FLAG_WARM|CSetting::FLAG_BASIC}, {L"AddressBarHistory",CSetting::TYPE_INT,IDS_ADDRESS_HISTORY,IDS_ADDRESS_HISTORY_TIP,0,CSetting::FLAG_WARM}, {L"NormalHistory",CSetting::TYPE_RADIO,IDS_NORMAL_HISTORY,IDS_NORMAL_HISTORY_TIP}, {L"SimplePath",CSetting::TYPE_RADIO,IDS_SIMPLE_PATH,IDS_SIMPLE_PATH_TIP}, {L"ExtendedPath",CSetting::TYPE_RADIO,IDS_EXTENDED_PATH,IDS_EXTENDED_PATH_TIP}, {L"HideSearch",CSetting::TYPE_BOOL,IDS_HIDE_SEARCH,IDS_HIDE_SEARCH_TIP,0,CSetting::FLAG_WARM}, {L"AddressAltD",CSetting::TYPE_STRING,IDS_ALT_D,IDS_ALT_D_TIP,L"",CSetting::FLAG_WARM}, {L"UpHotkey2",CSetting::TYPE_HOTKEY_ANY,IDS_UP_HOTKEY,IDS_UP_HOTKEY_TIP,0,CSetting::FLAG_WARM}, {L"UpButton",CSetting::TYPE_GROUP,IDS_UP_SETTINGS}, {L"ShowUpButton",CSetting::TYPE_INT,IDS_SHOW_UP,IDS_SHOW_UP_TIP,2,CSetting::FLAG_WARM|CSetting::FLAG_BASIC}, {L"DontShow",CSetting::TYPE_RADIO,IDS_DONT_SHOW,IDS_DONT_SHOW_TIP}, {L"BeforeBack",CSetting::TYPE_RADIO,IDS_BEFORE_BACK,IDS_BEFORE_BACK_TIP}, {L"AfterBack",CSetting::TYPE_RADIO,IDS_AFTER_BACK,IDS_AFTER_BACK_TIP}, {L"UpIconNormal",CSetting::TYPE_ICON,IDS_UP_NORMAL,IDS_UP_NORMAL_TIP,L",4",CSetting::FLAG_WARM,L"ShowUpButton"}, {L"UpIconPressed",CSetting::TYPE_ICON,IDS_UP_PRESSED,IDS_UP_PRESSED_TIP,L",5",CSetting::FLAG_WARM,L"ShowUpButton"}, {L"UpIconHot",CSetting::TYPE_ICON,IDS_UP_HOT,IDS_UP_HOT_TIP,L",6",CSetting::FLAG_WARM,L"ShowUpButton"}, {L"UpIconDisabled",CSetting::TYPE_ICON,IDS_UP_DISABLED,IDS_UP_DISABLED_TIP,L",7",CSetting::FLAG_WARM,L"ShowUpButton"}, {L"UpIconSize",CSetting::TYPE_INT,IDS_UP_SIZE,IDS_UP_SIZE_TIP,0,CSetting::FLAG_WARM,L"ShowUpButton"}, // 30 for DPI<120 and 36 for DPI>=120 {L"UpHotkey",CSetting::TYPE_HOTKEY_ANY,IDS_UP_HOTKEY,IDS_UP_HOTKEY_TIP,0,CSetting::FLAG_WARM}, {L"Toolbar",CSetting::TYPE_GROUP,IDS_TOOLBAR_SETTINGS}, {L"UseBigButtons",CSetting::TYPE_BOOL,IDS_BIG_BUTTONS,IDS_BIG_BUTTONS_TIP,1,CSetting::FLAG_WARM}, {L"SmallIconSize",CSetting::TYPE_INT,IDS_SMALL_SIZE,IDS_SMALL_SIZE_TIP,-1,CSetting::FLAG_WARM}, // 16 for DPI<120 and 24 for DPI>=120 {L"LargeIconSize",CSetting::TYPE_INT,IDS_LARGE_SIZE,IDS_LARGE_SIZE_TIP,-1,CSetting::FLAG_WARM}, // 24 for DPI<120 and 32 for DPI>=120 {L"MenuIconSize",CSetting::TYPE_INT,IDS_MENU_SIZE,IDS_MENU_SIZE_TIP,16,CSetting::FLAG_WARM}, {L"ToolbarListMode",CSetting::TYPE_BOOL,IDS_LIST_MODE,IDS_LIST_MODE_TIP,0,CSetting::FLAG_WARM}, {L"SameSizeButtons",CSetting::TYPE_BOOL,IDS_SAME_SIZE,IDS_SAME_SIZE_TIP,0,CSetting::FLAG_WARM,L"ToolbarListMode=0"}, {L"ResizeableToolbar",CSetting::TYPE_BOOL,IDS_RESIZEABLE,IDS_RESIZEABLE_TIP,0,CSetting::FLAG_WARM}, {L"CustomToolbar",CSetting::TYPE_GROUP,IDS_BUTTONS_SETTINGS,0,0,0,NULL,NULL,&g_CustomToolbarPanel}, {L"ToolbarItems",CSetting::TYPE_MULTISTRING,0,0,g_DefaultToolbar,CSetting::FLAG_WARM}, {L"StatusBar",CSetting::TYPE_GROUP,IDS_STATUS_SETTINGS}, {L"ShowFreeSpace",CSetting::TYPE_BOOL,IDS_FREE_SPACE,IDS_FREE_SPACE_TIP,1,CSetting::FLAG_WARM|CSetting::FLAG_BASIC}, {L"ShowInfoTip",CSetting::TYPE_BOOL,IDS_INFO_TIP,IDS_INFO_TIP_TIP,1,CSetting::FLAG_WARM,L"ShowFreeSpace"}, {L"ForceRefreshWin7",CSetting::TYPE_BOOL,IDS_FORCE_REFRESH,IDS_FORCE_REFRESH_TIP,1,CSetting::FLAG_WARM,L"ShowFreeSpace"}, {L"StatusBar8",CSetting::TYPE_GROUP,IDS_STATUS_SETTINGS}, {L"ShowStatusBar",CSetting::TYPE_BOOL,IDS_SHOWSTATUSBAR,IDS_SHOWSTATUSBAR_TIP,1,CSetting::FLAG_WARM|CSetting::FLAG_BASIC}, {L"ShowFreeSpace2",CSetting::TYPE_BOOL,IDS_FREE_SPACE,IDS_FREE_SPACE_TIP,1,CSetting::FLAG_WARM,L"ShowStatusBar",L"ShowStatusBar"}, {L"ShowZone",CSetting::TYPE_BOOL,IDS_SHOW_ZONE,IDS_SHOW_ZONE_TIP,1,CSetting::FLAG_WARM,L"ShowStatusBar",L"ShowStatusBar"}, {L"ShowInfoTip2",CSetting::TYPE_BOOL,IDS_INFO_TIP,IDS_INFO_TIP_TIP,1,CSetting::FLAG_WARM,L"ShowStatusBar",L"ShowStatusBar"}, {L"StatusBarFont",CSetting::TYPE_FONT,IDS_STATUS_FONT,IDS_STATUS_FONT_TIP,L"Segoe UI, normal, 9",CSetting::FLAG_WARM,L"ShowStatusBar",L"ShowStatusBar"}, {L"FilePane",CSetting::TYPE_GROUP,IDS_FILEPANE_SETTINGS}, {L"ShareOverlay",CSetting::TYPE_BOOL,IDS_SHARE,IDS_SHARE_TIP,0,CSetting::FLAG_COLD|CSetting::FLAG_BASIC}, {L"ShareOverlayIcon",CSetting::TYPE_ICON,IDS_SHARE_ICON,IDS_SHARE_ICON_TIP,L"%windir%\\system32\\imageres.dll,164",CSetting::FLAG_COLD,L"ShareOverlay",L"ShareOverlay"}, {L"ShareOverlayHidden",CSetting::TYPE_BOOL,IDS_SHARE_HIDDEN,IDS_SHARE_HIDDEN_TIP,0,CSetting::FLAG_COLD,L"ShareOverlay",L"ShareOverlay"}, {L"ShareExplorer",CSetting::TYPE_BOOL,IDS_SHARE_EXPLORER,IDS_SHARE_EXPLORER_TIP,1,CSetting::FLAG_COLD,L"ShareOverlay",L"ShareOverlay"}, {L"ShowHeaders",CSetting::TYPE_BOOL,IDS_HEADERS,IDS_HEADERS_TIP,0,CSetting::FLAG_WARM}, {L"HideScrollTip",CSetting::TYPE_BOOL,IDS_SCROLLTIP,IDS_SCROLLTIP_TIP,0,CSetting::FLAG_WARM}, {L"FileOperation",CSetting::TYPE_GROUP,IDS_FILE_SETTINGS}, {L"ReplaceFileUI",CSetting::TYPE_BOOL,IDS_FILE_UI,IDS_FILE_UI_TIP,1,CSetting::FLAG_WARM|CSetting::FLAG_BASIC}, {L"ReplaceFolderUI",CSetting::TYPE_BOOL,IDS_FOLDER_UI,IDS_FOLDER_UI_TIP,1,CSetting::FLAG_WARM|CSetting::FLAG_BASIC}, {L"OverwriteAlertLevel",CSetting::TYPE_INT,IDS_ALERT_LEVEL,IDS_ALERT_LEVEL_TIP,0,CSetting::FLAG_WARM,L"ReplaceFileUI",L"ReplaceFileUI"}, {L"NoAlert",CSetting::TYPE_RADIO,IDS_NO_ALERT,IDS_NO_ALERT_TIP}, {L"SystemFiles",CSetting::TYPE_RADIO,IDS_SYS_FILES,IDS_SYS_FILES_TIP}, {L"ReadOnlyFiles",CSetting::TYPE_RADIO,IDS_RO_FILES,IDS_RO_FILES_TIP}, {L"EnableMore",CSetting::TYPE_BOOL,IDS_MORE,IDS_MORE_TIP,0,CSetting::FLAG_WARM}, {L"MoreProgressDelay",CSetting::TYPE_INT,IDS_MORE_DELAY,IDS_MORE_DELAY_TIP,-1,CSetting::FLAG_WARM,L"EnableMore",L"EnableMore"}, // 500 for Windows 7 Aero, and 0 otherwise {L"FileExplorer",CSetting::TYPE_BOOL,IDS_FILE_EXPLORER,IDS_FILE_EXPLORER_TIP,1,CSetting::FLAG_COLD}, {L"Language",CSetting::TYPE_GROUP,IDS_LANGUAGE_SETTINGS,0,0,0,NULL,NULL,GetLanguageSettings(COMPONENT_EXPLORER)}, {L"Language",CSetting::TYPE_STRING,0,0,L"",CSetting::FLAG_COLD|CSetting::FLAG_SHARED}, {NULL} }; void UpgradeSettings( bool bShared ) { } void UpdateSettings( void ) { HDC hdc=GetDC(NULL); int dpi=GetDeviceCaps(hdc,LOGPIXELSY); ReleaseDC(NULL,hdc); UpdateSetting(L"SmallIconSize",CComVariant((dpi>=120)?24:16),false); UpdateSetting(L"LargeIconSize",CComVariant((dpi>=120)?32:24),false); UpdateSetting(L"UpIconSize",CComVariant((dpi>=120)?36:30),false); FindSetting(L"UpHotkey2")->pLinkTo=FindSetting(L"UpHotkey"); if (GetWinVersion()>=WIN_VER_WIN8) { // Windows 8 HideSettingGroup(L"StatusBar",true); HideSetting(L"ShowFreeSpace",true); FindSetting(L"ShowFreeSpace2")->pLinkTo=FindSetting(L"ShowFreeSpace"); FindSetting(L"ShowInfoTip2")->pLinkTo=FindSetting(L"ShowInfoTip"); HideSettingGroup(L"UpButton",true); UpdateSetting(L"ShowUpButton",CComVariant(0),false); HideSetting(L"ShowUpButton",true); HideSettingGroup(L"FileOperation",true); UpdateSetting(L"ReplaceFileUI",CComVariant(0),false); HideSetting(L"ReplaceFileUI",true); UpdateSetting(L"ReplaceFolderUI",CComVariant(0),false); HideSetting(L"ReplaceFolderUI",true); UpdateSetting(L"ShowCaption",CComVariant(0),false); HideSetting(L"ShowCaption",true); UpdateSetting(L"ShowIcon",CComVariant(0),false); HideSetting(L"ShowIcon",true); UpdateSetting(L"FixFolderScroll",CComVariant(0),false); HideSetting(L"FixFolderScroll",true); UpdateSetting(L"ToolbarItems",CComVariant(g_DefaultToolbar2),false); if (GetWinVersion()>=WIN_VER_WIN10) { FindSetting(L"TreeStyle")[1].flags|=CSetting::FLAG_HIDDEN; } } else { // Windows 7 int delay=0; BOOL comp; if (SUCCEEDED(DwmIsCompositionEnabled(&comp)) && comp) delay=500; UpdateSetting(L"MoreProgressDelay",CComVariant(delay),false); HideSetting(L"UpHotkey2",true); HideSettingGroup(L"StatusBar8",true); } CRegKey regKey; wchar_t language[100]=L""; if (regKey.Open(HKEY_LOCAL_MACHINE,L"Software\\OpenShell\\OpenShell",KEY_READ|KEY_WOW64_64KEY)==ERROR_SUCCESS) { ULONG size=_countof(language); if (regKey.QueryStringValue(L"DefaultLanguage",language,&size)!=ERROR_SUCCESS) language[0]=0; } UpdateSetting(L"Language",language,false); } static bool g_bCopyHook0; // initial state of the copy hook before the settings are edited void InitSettings( void ) { InitSettings(g_Settings,COMPONENT_EXPLORER,NULL); g_bCopyHook0=GetWinVersion()<WIN_VER_WIN8 && (GetSettingBool(L"ReplaceFileUI") || GetSettingBool(L"ReplaceFolderUI") || GetSettingBool(L"EnableMore")); } void ClosingSettings( HWND hWnd, int flags, int command ) { if (command==IDOK) { bool bCopyHook=GetWinVersion()<WIN_VER_WIN8 && (GetSettingBool(L"ReplaceFileUI") || GetSettingBool(L"ReplaceFolderUI") || GetSettingBool(L"EnableMore")); if ((flags&CSetting::FLAG_COLD) || (bCopyHook && !g_bCopyHook0)) MessageBox(hWnd,LoadStringEx(IDS_NEW_SETTINGS2),LoadStringEx(IDS_APP_TITLE),MB_OK|MB_ICONWARNING); else if (flags&CSetting::FLAG_WARM) MessageBox(hWnd,LoadStringEx(IDS_NEW_SETTINGS1),LoadStringEx(IDS_APP_TITLE),MB_OK|MB_ICONINFORMATION); } } void SettingChangedCallback( const CSetting *pSetting ) { } void EditSettings( void ) { STARTUPINFO startupInfo={sizeof(startupInfo)}; PROCESS_INFORMATION processInfo; memset(&processInfo,0,sizeof(processInfo)); wchar_t path[_MAX_PATH]; GetModuleFileName(g_Instance,path,_countof(path)); wchar_t *end=PathFindFileName(path); *end=0; Strcpy(end,(int)(path+_countof(path)-end),L"ClassicExplorerSettings.exe"); if (CreateProcess(NULL,path,NULL,NULL,TRUE,0,NULL,NULL,&startupInfo,&processInfo)) { CloseHandle(processInfo.hProcess); CloseHandle(processInfo.hThread); } } void ShowSettingsMenu( HWND parent, int x, int y ) { HMENU menu=CreatePopupMenu(); AppendMenu(menu,MF_STRING,CBandWindow::ID_SETTINGS,FindTranslation(L"Toolbar.Settings",L"Classic Explorer Settings")); int size=16; HBITMAP shellBmp=NULL; HICON icon=(HICON)LoadImage(g_Instance,MAKEINTRESOURCE(IDI_APPICON),IMAGE_ICON,size,size,LR_DEFAULTCOLOR); if (icon) { shellBmp=BitmapFromIcon(icon,size,NULL,true); MENUITEMINFO mii={sizeof(mii)}; mii.fMask=MIIM_BITMAP; mii.hbmpItem=shellBmp; SetMenuItemInfo(menu,CBandWindow::ID_SETTINGS,FALSE,&mii); } MENUINFO info={sizeof(info),MIM_STYLE,MNS_CHECKORBMP}; SetMenuInfo(menu,&info); DWORD pos=GetMessagePos(); if (!GetSettingBool(L"EnableSettings")) EnableMenuItem(menu,0,MF_BYPOSITION|MF_GRAYED); int res=TrackPopupMenu(menu,TPM_RIGHTBUTTON|TPM_RETURNCMD,x,y,0,parent,NULL); DestroyMenu(menu); if (shellBmp) DeleteObject(shellBmp); if (res==CBandWindow::ID_SETTINGS) EditSettings(); } void ShowExplorerSettings( void ) { WaitDllInitThread(); if (!GetSettingBool(L"EnableSettings")) return; wchar_t title[100]; DWORD ver=GetVersionEx(g_Instance); if (ver) Sprintf(title,_countof(title),LoadStringEx(IDS_SETTINGS_TITLE_VER),ver>>24,(ver>>16)&0xFF,ver&0xFFFF); else Sprintf(title,_countof(title),LoadStringEx(IDS_SETTINGS_TITLE)); EditSettings(title,true,0); } bool DllImportSettingsXml( const wchar_t *fname ) { return ImportSettingsXml(fname); } bool DllExportSettingsXml( const wchar_t *fname ) { return ExportSettingsXml(fname); } #ifndef _WIN64 bool DllSaveAdmx( const char *admxFile, const char *admlFile, const char *docFile, const wchar_t *language ) { WaitDllInitThread(); HMODULE dll=NULL; if (language[0]) { wchar_t path[_MAX_PATH]; GetCurrentDirectory(_countof(path),path); PathAppend(path,language); PathAddExtension(path,L".dll"); dll=LoadLibraryEx(path,NULL,LOAD_LIBRARY_AS_DATAFILE|LOAD_LIBRARY_AS_IMAGE_RESOURCE); } LoadTranslationResources(dll,NULL); return SaveAdmx(COMPONENT_EXPLORER,admxFile,admlFile,docFile); } #endif
// Copyright (c) 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "quiche/quic/core/frames/quic_stop_sending_frame.h" #include "quiche/quic/core/quic_error_codes.h" namespace quic { QuicStopSendingFrame::QuicStopSendingFrame() : QuicInlinedFrame(STOP_SENDING_FRAME) {} QuicStopSendingFrame::QuicStopSendingFrame(QuicControlFrameId control_frame_id, QuicStreamId stream_id, QuicRstStreamErrorCode error_code) : QuicStopSendingFrame(control_frame_id, stream_id, QuicResetStreamError::FromInternal(error_code)) {} QuicStopSendingFrame::QuicStopSendingFrame(QuicControlFrameId control_frame_id, QuicStreamId stream_id, QuicResetStreamError error) : QuicInlinedFrame(STOP_SENDING_FRAME), control_frame_id(control_frame_id), stream_id(stream_id), error_code(error.internal_code()), ietf_error_code(error.ietf_application_code()) {} std::ostream& operator<<(std::ostream& os, const QuicStopSendingFrame& frame) { os << "{ control_frame_id: " << frame.control_frame_id << ", stream_id: " << frame.stream_id << ", error_code: " << frame.error_code << ", ietf_error_code: " << frame.ietf_error_code << " }\n"; return os; } } // namespace quic
#include <consumers/spectrum.h> #include <core/util/logger.h> namespace DAQuiri { Spectrum::Spectrum() : Consumer() { Setting base_options = metadata_.attributes(); SettingMeta name("name", SettingType::text, "Name"); base_options.branches.add(name); SettingMeta vis("visible", SettingType::boolean, "Visible"); base_options.branches.add(vis); SettingMeta sca("preferred_scale", SettingType::menu, "Plot scale for counts"); sca.set_enum(0, "Linear"); sca.set_enum(1, "Logarithmic"); base_options.branches.add(sca); SettingMeta totalcount("total_count", SettingType::precise, "Total count"); totalcount.set_flag("readonly"); totalcount.set_val("min", 0); base_options.branches.add(totalcount); SettingMeta start_time("start_time", SettingType::time, "Start time"); start_time.set_flag("readonly"); base_options.branches.add(start_time); SettingMeta live_time("live_time", SettingType::duration, "Live time"); live_time.set_flag("readonly"); base_options.branches.add(live_time); SettingMeta real_time("real_time", SettingType::duration, "Real time"); real_time.set_flag("readonly"); base_options.branches.add(real_time); base_options.branches.add(recent_rate_.update(Status(), 0)); base_options.branches.add(periodic_trigger_.settings(-1, "Clear periodically")); base_options.branches.add(filters_.settings()); metadata_.overwrite_all_attributes(base_options); } void Spectrum::_apply_attributes() { try { Consumer::_apply_attributes(); filters_.settings(metadata_.get_attribute("filters")); metadata_.replace_attribute(filters_.settings()); periodic_trigger_.settings(metadata_.get_attribute(periodic_trigger_.settings())); metadata_.replace_attribute(periodic_trigger_.settings(-1, "Clear periodically")); } catch (...) { std::throw_with_nested(std::runtime_error("<Spectrum> Failed _apply_attributes")); } } bool Spectrum::_accept_spill(const Spill& spill) { return (Consumer::_accept_spill(spill) && (spill.type != Spill::Type::daq_status)); } void Spectrum::_push_stats_pre(const Spill& spill) { if (!this->_accept_spill(spill)) return; filters_.configure(spill); if (metadata_.get_attribute("start_time").time() == hr_time_t()) metadata_.set_attribute(Setting("start_time", spill.time)); if (periodic_trigger_.triggered) { if (data_) { data_->clear(); recent_rate_.update(recent_rate_.previous_status, data_->total_count()); } periodic_trigger_.triggered = false; } } void Spectrum::update_cumulative(const Status& new_status) { if (stats_.size() && (stats_.back().type == Spill::Type::running)) stats_.pop_back(); stats_.push_back(new_status); auto live_time = Status::total_elapsed(stats_, "live_time"); auto real_time = Status::total_elapsed(stats_, "native_time"); if (live_time == hr_duration_t()) live_time = real_time; metadata_.set_attribute(Setting("live_time", live_time)); metadata_.set_attribute(Setting("real_time", real_time)); } void Spectrum::_push_stats_post(const Spill& spill) { if (!this->_accept_spill(spill)) return; this->_recalc_axes(); auto new_status = Status::extract(spill); periodic_trigger_.update(new_status); update_cumulative(new_status); if (data_) { metadata_.set_attribute(Setting::precise("total_count", data_->total_count())); metadata_.set_attribute(recent_rate_.update(new_status, data_->total_count())); } } void Spectrum::_flush() { if (!data_) return; metadata_.set_attribute(Setting::precise("total_count", data_->total_count())); metadata_.set_attribute( recent_rate_.update(recent_rate_.previous_status, data_->total_count())); } }
/* * Copyright (c) 2010, 2012-2013, 2017-2018 ARM Limited * Copyright (c) 2013 Advanced Micro Devices, Inc. * All rights reserved * * The license below extends only to copyright in the software and shall * not be construed as granting a license to any other intellectual * property including but not limited to intellectual property relating * to a hardware implementation of the functionality of the software * licensed hereunder. You may use the software subject to the license * terms below provided that you ensure that this notice is replicated * unmodified and in its entirety in all distributions of the software, * modified or unmodified, in source code or in binary form. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer; * redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution; * neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "arch/arm/insts/misc.hh" #include "cpu/reg_class.hh" using namespace ArmISA; std::string MrsOp::generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; printMnemonic(ss); printIntReg(ss, dest); ss << ", "; bool foundPsr = false; for (unsigned i = 0; i < numSrcRegs(); i++) { const RegId& reg = srcRegIdx(i); if (!reg.isMiscReg()) { continue; } if (reg.index() == MISCREG_CPSR) { ss << "cpsr"; foundPsr = true; break; } if (reg.index() == MISCREG_SPSR) { ss << "spsr"; foundPsr = true; break; } } if (!foundPsr) { ss << "????"; } return ss.str(); } void MsrBase::printMsrBase(std::ostream &os) const { printMnemonic(os); bool apsr = false; bool foundPsr = false; for (unsigned i = 0; i < numDestRegs(); i++) { const RegId& reg = destRegIdx(i); if (!reg.isMiscReg()) { continue; } if (reg.index() == MISCREG_CPSR) { os << "cpsr_"; foundPsr = true; break; } if (reg.index() == MISCREG_SPSR) { if (bits(byteMask, 1, 0)) { os << "spsr_"; } else { os << "apsr_"; apsr = true; } foundPsr = true; break; } } if (!foundPsr) { os << "????"; return; } if (bits(byteMask, 3)) { if (apsr) { os << "nzcvq"; } else { os << "f"; } } if (bits(byteMask, 2)) { if (apsr) { os << "g"; } else { os << "s"; } } if (bits(byteMask, 1)) { os << "x"; } if (bits(byteMask, 0)) { os << "c"; } } std::string MsrImmOp::generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; printMsrBase(ss); ccprintf(ss, ", #%#x", imm); return ss.str(); } std::string MsrRegOp::generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; printMsrBase(ss); ss << ", "; printIntReg(ss, op1); return ss.str(); } std::string MrrcOp::generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; printMnemonic(ss); printIntReg(ss, dest); ss << ", "; printIntReg(ss, dest2); ss << ", "; printMiscReg(ss, op1); return ss.str(); } std::string McrrOp::generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; printMnemonic(ss); printMiscReg(ss, dest); ss << ", "; printIntReg(ss, op1); ss << ", "; printIntReg(ss, op2); return ss.str(); } std::string ImmOp::generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; printMnemonic(ss); ccprintf(ss, "#%d", imm); return ss.str(); } std::string RegImmOp::generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; printMnemonic(ss); printIntReg(ss, dest); ccprintf(ss, ", #%d", imm); return ss.str(); } std::string RegRegOp::generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; printMnemonic(ss); printIntReg(ss, dest); ss << ", "; printIntReg(ss, op1); return ss.str(); } std::string RegOp::generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; printMnemonic(ss); printIntReg(ss, dest); return ss.str(); } std::string RegRegRegImmOp::generateDisassembly( Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; printMnemonic(ss); printIntReg(ss, dest); ss << ", "; printIntReg(ss, op1); ss << ", "; printIntReg(ss, op2); ccprintf(ss, ", #%d", imm); return ss.str(); } std::string RegRegRegRegOp::generateDisassembly( Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; printMnemonic(ss); printIntReg(ss, dest); ss << ", "; printIntReg(ss, op1); ss << ", "; printIntReg(ss, op2); ss << ", "; printIntReg(ss, op3); return ss.str(); } std::string RegRegRegOp::generateDisassembly( Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; printMnemonic(ss); printIntReg(ss, dest); ss << ", "; printIntReg(ss, op1); ss << ", "; printIntReg(ss, op2); return ss.str(); } std::string RegRegImmOp::generateDisassembly( Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; printMnemonic(ss); printIntReg(ss, dest); ss << ", "; printIntReg(ss, op1); ccprintf(ss, ", #%d", imm); return ss.str(); } std::string MiscRegRegImmOp::generateDisassembly( Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; printMnemonic(ss); printMiscReg(ss, dest); ss << ", "; printIntReg(ss, op1); return ss.str(); } std::string RegMiscRegImmOp::generateDisassembly( Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; printMnemonic(ss); printIntReg(ss, dest); ss << ", "; printMiscReg(ss, op1); return ss.str(); } std::string RegImmImmOp::generateDisassembly( Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; printMnemonic(ss); printIntReg(ss, dest); ccprintf(ss, ", #%d, #%d", imm1, imm2); return ss.str(); } std::string RegRegImmImmOp::generateDisassembly( Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; printMnemonic(ss); printIntReg(ss, dest); ss << ", "; printIntReg(ss, op1); ccprintf(ss, ", #%d, #%d", imm1, imm2); return ss.str(); } std::string RegImmRegOp::generateDisassembly( Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; printMnemonic(ss); printIntReg(ss, dest); ccprintf(ss, ", #%d, ", imm); printIntReg(ss, op1); return ss.str(); } std::string RegImmRegShiftOp::generateDisassembly( Addr pc, const Loader::SymbolTable *symtab) const { std::stringstream ss; printMnemonic(ss); printIntReg(ss, dest); ccprintf(ss, ", #%d, ", imm); printShiftOperand(ss, op1, true, shiftAmt, INTREG_ZERO, shiftType); printIntReg(ss, op1); return ss.str(); } std::string UnknownOp::generateDisassembly( Addr pc, const Loader::SymbolTable *symtab) const { return csprintf("%-10s (inst %#08x)", "unknown", encoding()); } McrMrcMiscInst::McrMrcMiscInst(const char *_mnemonic, ExtMachInst _machInst, uint64_t _iss, MiscRegIndex _miscReg) : ArmStaticInst(_mnemonic, _machInst, No_OpClass) { flags[IsNonSpeculative] = true; iss = _iss; miscReg = _miscReg; } Fault McrMrcMiscInst::execute(ExecContext *xc, Trace::InstRecord *traceData) const { bool hypTrap = mcrMrc15TrapToHyp(miscReg, xc->tcBase(), iss); if (hypTrap) { return std::make_shared<HypervisorTrap>(machInst, iss, EC_TRAPPED_CP15_MCR_MRC); } else { return NoFault; } } std::string McrMrcMiscInst::generateDisassembly( Addr pc, const Loader::SymbolTable *symtab) const { return csprintf("%-10s (pipe flush)", mnemonic); } McrMrcImplDefined::McrMrcImplDefined(const char *_mnemonic, ExtMachInst _machInst, uint64_t _iss, MiscRegIndex _miscReg) : McrMrcMiscInst(_mnemonic, _machInst, _iss, _miscReg) {} Fault McrMrcImplDefined::execute(ExecContext *xc, Trace::InstRecord *traceData) const { bool hypTrap = mcrMrc15TrapToHyp(miscReg, xc->tcBase(), iss); if (hypTrap) { return std::make_shared<HypervisorTrap>(machInst, iss, EC_TRAPPED_CP15_MCR_MRC); } else { return std::make_shared<UndefinedInstruction>(machInst, false, mnemonic); } } std::string McrMrcImplDefined::generateDisassembly( Addr pc, const Loader::SymbolTable *symtab) const { return csprintf("%-10s (implementation defined)", mnemonic); }
//============================================================================== // Copyright 2003 - 2012 LASMEA UMR 6602 CNRS/Univ. Clermont II // Copyright 2009 - 2012 LRI UMR 8623 CNRS/Univ Paris Sud XI // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE.txt or copy at // http://www.boost.org/LICENSE_1_0.txt //============================================================================== #define NT2_BENCH_MODULE "nt2 trigonometric toolbox - acot/scalar Mode" ////////////////////////////////////////////////////////////////////////////// // timing Test behavior of trigonometric components in scalar mode ////////////////////////////////////////////////////////////////////////////// #include <nt2/toolbox/trigonometric/include/functions/acot.hpp> #include <nt2/sdk/bench/benchmark.hpp> #include <nt2/sdk/bench/timing.hpp> #include <boost/dispatch/meta/as_integer.hpp> #include <cmath> ////////////////////////////////////////////////////////////////////////////// // scalar runtime benchmark for functor<acot_> from trigonometric ////////////////////////////////////////////////////////////////////////////// using nt2::tag::acot_; ////////////////////////////////////////////////////////////////////////////// // range macro ////////////////////////////////////////////////////////////////////////////// #define RS(T,V1,V2) (T, T(V1) ,T(V2)) namespace n1 { typedef float T; typedef boost::dispatch::meta::as_integer<T>::type iT; NT2_TIMING(acot_,(RS(T,nt2::Mone<T>(),nt2::One<T>()))) } namespace n2 { typedef double T; typedef boost::dispatch::meta::as_integer<T>::type iT; NT2_TIMING(acot_,(RS(T,nt2::Mone<T>(),nt2::One<T>()))) } namespace n3 { typedef nt2::uint8_t T; typedef boost::dispatch::meta::as_integer<T>::type iT; NT2_TIMING(acot_,(RS(T,nt2::Zero<T>(),nt2::One<T>()))) } namespace n4 { typedef nt2::uint16_t T; typedef boost::dispatch::meta::as_integer<T>::type iT; NT2_TIMING(acot_,(RS(T,nt2::Zero<T>(),nt2::One<T>()))) } namespace n5 { typedef nt2::uint32_t T; typedef boost::dispatch::meta::as_integer<T>::type iT; NT2_TIMING(acot_,(RS(T,nt2::Zero<T>(),nt2::One<T>()))) } namespace n6 { typedef nt2::uint64_t T; typedef boost::dispatch::meta::as_integer<T>::type iT; NT2_TIMING(acot_,(RS(T,nt2::Zero<T>(),nt2::One<T>()))) } namespace n7 { typedef nt2::int8_t T; typedef boost::dispatch::meta::as_integer<T>::type iT; NT2_TIMING(acot_,(RS(T,T(-1),T(1)))) } namespace n8 { typedef nt2::int16_t T; typedef boost::dispatch::meta::as_integer<T>::type iT; NT2_TIMING(acot_,(RS(T,T(-1),T(1)))) } namespace n9 { typedef nt2::int32_t T; typedef boost::dispatch::meta::as_integer<T>::type iT; NT2_TIMING(acot_,(RS(T,T(-1),T(1)))) } namespace n10 { typedef nt2::int64_t T; typedef boost::dispatch::meta::as_integer<T>::type iT; NT2_TIMING(acot_,(RS(T,T(-1),T(1)))) } #undef RS
#pragma once #include <memory> #include "ResourceManager.hpp" namespace creamyLib::engine::resource { template<class T> class ResourcePrefab { private: std::shared_ptr<T> resource_; public: ResourcePrefab(const std::shared_ptr<Resource>& resource): resource_(std::dynamic_pointer_cast<T>(resource)) {} ResourcePrefab(const Asset& asset): ResourcePrefab(ResourceManager::getInstance()->getAssetResource(asset)) {} const std::shared_ptr<T>& operator->() const { return resource_; } operator bool() const { return static_cast<bool>(resource_); } }; }
// Copyright (c) 2014-2019 Coin Sciences Ltd // FFF_Core code distributed under the GPLv3 license, see COPYING file. #include "v8/v8ubjson.h" #include "utils/define.h" #include "v8/v8blob.h" #include "v8/v8utils.h" #include <cstring> const int MAX_FORMATTED_DATA_DEPTH = 100; extern void _v8_internal_Print_Object(void *object); namespace mc_v8 { #define UBJ_UNDEFINED 0 #define UBJ_NULLTYPE 1 #define UBJ_NOOP 2 #define UBJ_BOOL_TRUE 3 #define UBJ_BOOL_FALSE 4 #define UBJ_CHAR 5 #define UBJ_STRING 6 #define UBJ_HIGH_PRECISION 7 #define UBJ_INT8 8 #define UBJ_UINT8 9 #define UBJ_INT16 10 #define UBJ_INT32 11 #define UBJ_INT64 12 #define UBJ_FLOAT32 13 #define UBJ_FLOAT64 14 #define UBJ_ARRAY 15 #define UBJ_OBJECT 16 #define UBJ_STRONG_TYPE 17 #define UBJ_COUNT 18 static char UBJ_TYPE[19] = {'?', 'Z', 'N', 'T', 'F', 'C', 'S', 'H', 'i', 'U', 'I', 'l', 'L', 'd', 'D', '[', '{', '$', '#'}; static int UBJ_SIZE[19] = {0, 0, 0, 0, 0, 1, -1, -1, 1, 1, 2, 4, 8, 4, 8, -2, -3, -4, -5}; static char UBJ_ISINT[19] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}; // clang-format off static int UBJ_INTERNAL_TYPE[256] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, UBJ_COUNT, UBJ_STRONG_TYPE, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, UBJ_CHAR, UBJ_FLOAT64, -1, UBJ_BOOL_FALSE, -1, UBJ_HIGH_PRECISION, UBJ_INT16, -1, -1, UBJ_INT64, -1, UBJ_NOOP, -1, -1, -1, -1, UBJ_STRING, UBJ_BOOL_TRUE, UBJ_UINT8, -1, -1, -1, -1, UBJ_NULLTYPE, UBJ_ARRAY, -1, -1, -1, -1, -1, -1, -1, -1, UBJ_FLOAT32, -1, -1, -1, -1, UBJ_INT8, -1, -1, UBJ_INT32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, UBJ_OBJECT, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; // clang-format on const size_t size_t_max = std::numeric_limits<size_t>::max(); static void swap_bytes(void *ptrDst, void *ptrSrc, int size) { int i; unsigned char *pDst; unsigned char *pSrc; pDst = static_cast<unsigned char *>(ptrDst); pSrc = static_cast<unsigned char *>(ptrSrc) + size - 1; for (i = 0; i < size; i++) { *pDst = *pSrc; pDst++; pSrc--; } } int ubjson_best_negative_int_type(int64_t int64_value) { char type; type = UBJ_INT8; if (int64_value + 0x80 < 0) { if (int64_value + 0x8000 >= 0) { type = UBJ_INT16; } else { if (int64_value + 0x80000000 >= 0) { type = UBJ_INT32; } else { type = UBJ_INT64; } } } return type; } static int ubjson_best_int_type(int64_t int64_value, int *not_uint8) { char type; uint64_t uint64_value; if (int64_value < 0) { if (not_uint8) { *not_uint8 = 1; } return ubjson_best_negative_int_type(int64_value); } uint64_value = *reinterpret_cast<uint64_t *>(&int64_value); if (uint64_value < 0x80) { type = UBJ_INT8; } else { if (uint64_value < 0x100) { type = UBJ_UINT8; } else { if (not_uint8) { *not_uint8 = 1; } if (uint64_value < 0x8000) { type = UBJ_INT16; } else { if (uint64_value < 0x80000000) { type = UBJ_INT32; } else { type = UBJ_INT64; } } } } return type; } static int ubjson_best_type(v8::Isolate *isolate, v8::Local<v8::Value> value, int last_type, int *not_uint8, int64_t *usize, int64_t *ssize) { v8::Isolate::Scope isolateScope(isolate); v8::EscapableHandleScope handleScope(isolate); v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::Context::Scope contextScope(context); int64_t int64_value; int size; int type = UBJ_UNDEFINED; if (value->IsNullOrUndefined()) { type = UBJ_NULLTYPE; } else if (value->IsBoolean()) { type = UBJ_BOOL_FALSE; if (value->BooleanValue(context).FromJust()) { type = UBJ_BOOL_TRUE; } } else if (value->IsInt32()) { int64_value = value->Int32Value(context).FromJust(); type = ubjson_best_int_type(int64_value, not_uint8); } else if (value->IsNumber()) { type = UBJ_FLOAT64; } else if (value->IsString()) { type = UBJ_STRING; } else if (value->IsArray()) { type = UBJ_ARRAY; } else if (value->IsObject()) { type = UBJ_OBJECT; } // else // { // // non-covertible type // } size = UBJ_SIZE[type]; if (usize) { if (size >= 0) { *usize += size; if (ssize) { *ssize += size; if (type == UBJ_UINT8) { *ssize += 1; } } } } if (last_type != UBJ_UNDEFINED) { if (type != last_type) { if (UBJ_ISINT[last_type] & UBJ_ISINT[type]) { if (type < last_type) { type = last_type; } } else { type = -1; } } } return type; } static int64_t ubjson_int64_read(const unsigned char *ptrStart, const unsigned char *ptrEnd, int known_type, size_t *offset, int *err) { int ubj_type = known_type; int n, c; int64_t v; const unsigned char *ptr = ptrStart; unsigned char *ptrOut; v = 0; *err = MC_ERR_NOERROR; // ptr = const_cast<unsigned char *>(ptrStart); if (ubj_type == UBJ_UNDEFINED) { if (ptr + 1 > ptrEnd) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } ubj_type = UBJ_INTERNAL_TYPE[*ptr]; if (ubj_type < 0) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } ptr++; } if (UBJ_ISINT[ubj_type] == 0) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } n = UBJ_SIZE[ubj_type]; if (ptr + n > ptrEnd) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } if (ubj_type != UBJ_UINT8) { if (*ptr & 0x80) { v = -1; } } ptrOut = static_cast<unsigned char *>(static_cast<void *>(&v)) + n - 1; for (c = 0; c < n; c++) { *ptrOut = *ptr; ptr++; ptrOut--; } exitlbl: *offset = static_cast<size_t>(ptr - ptrStart); return v; } union Number { int64_t int64_value; float_t float_value; double_t double_value; }; static v8::Local<v8::Value> ubjson_read_internal(v8::Isolate *isolate, const unsigned char *ptrStart, size_t bytes, int known_type, int max_depth, size_t *offset, int *err) { v8::Isolate::Scope isolateScope(isolate); v8::EscapableHandleScope handleScope(isolate); v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::Context::Scope contextScope(context); int ubj_type; unsigned char *ptr; unsigned char *ptrEnd; size_t size, i, sh; union Number number; v8::Local<v8::Value> result = v8::Null(isolate); *err = MC_ERR_NOERROR; if (max_depth == 0) { *err = MC_ERR_NOT_SUPPORTED; goto exitlbl; } ptr = const_cast<unsigned char *>(ptrStart); ptrEnd = ptr + bytes; ubj_type = known_type; if (ubj_type == UBJ_UNDEFINED) { if (ptr + 1 > ptrEnd) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } ubj_type = UBJ_INTERNAL_TYPE[*ptr]; if (ubj_type < 0) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } ptr++; } if (UBJ_ISINT[ubj_type]) { int64_t int64_value = ubjson_int64_read(ptr, ptrEnd, ubj_type, &sh, err); if (sh <= sizeof(int32_t) + 1) { result = v8::Integer::New(isolate, static_cast<int32_t>(int64_value)); } else { result = v8::BigInt::New(isolate, int64_value); } ptr += sh; } else { switch (ubj_type) { case UBJ_NULLTYPE: result = v8::Null(isolate); break; case UBJ_BOOL_FALSE: result = v8::Boolean::New(isolate, false); break; case UBJ_BOOL_TRUE: result = v8::Boolean::New(isolate, true); break; case UBJ_FLOAT32: if (ptr + UBJ_SIZE[ubj_type] > ptrEnd) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } swap_bytes(&number.int64_value, ptr, sizeof(float)); result = v8::Number::New(isolate, static_cast<double>(number.float_value)); ptr += UBJ_SIZE[ubj_type]; break; case UBJ_FLOAT64: if (ptr + UBJ_SIZE[ubj_type] > ptrEnd) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } swap_bytes(&number.int64_value, ptr, sizeof(double)); result = v8::Number::New(isolate, number.double_value); ptr += UBJ_SIZE[ubj_type]; break; case UBJ_CHAR: if (ptr + UBJ_SIZE[ubj_type] > ptrEnd) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } result = String2V8(isolate, std::string(ptr[0], 1)); ptr += UBJ_SIZE[ubj_type]; break; case UBJ_STRING: case UBJ_HIGH_PRECISION: size = static_cast<size_t>(ubjson_int64_read(ptr, ptrEnd, UBJ_UNDEFINED, &sh, err)); if (*err) { goto exitlbl; } ptr += sh; if (ptr + size > ptrEnd) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } if (size) { auto str_value = std::string(reinterpret_cast<char *>(ptr), size); result = String2V8(isolate, str_value); } else { result = String2V8(isolate, ""); } ptr += size; break; case UBJ_ARRAY: if (max_depth <= 1) { *err = MC_ERR_NOT_SUPPORTED; goto exitlbl; } ubj_type = UBJ_UNDEFINED; if (ptr + 1 > ptrEnd) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } size = size_t_max; if (*ptr == UBJ_TYPE[UBJ_STRONG_TYPE]) { ptr++; if (ptr + 1 > ptrEnd) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } ubj_type = UBJ_INTERNAL_TYPE[*ptr]; if (ubj_type < 0) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } ptr++; if (ptr + 1 > ptrEnd) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } if (*ptr != UBJ_TYPE[UBJ_COUNT]) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } } if (*ptr == UBJ_TYPE[UBJ_COUNT]) { ptr++; size = static_cast<size_t>(ubjson_int64_read(ptr, ptrEnd, UBJ_UNDEFINED, &sh, err)); if (*err) { goto exitlbl; } ptr += sh; } { auto array_value = v8::Array::New(isolate, (size < size_t_max) ? static_cast<int>(size) : 0); if (size < size_t_max) { i = 0; while (i < size) { array_value->Set(static_cast<unsigned>(i), ubjson_read_internal(isolate, ptr, static_cast<size_t>(ptrEnd - ptr), ubj_type, max_depth - 1, &sh, err)); if (*err) { goto exitlbl; } ptr += sh; i++; } } else { if (ptr + 1 > ptrEnd) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } i = 0; while (*ptr != ']') { array_value->Set(static_cast<unsigned>(i++), ubjson_read_internal(isolate, ptr, static_cast<size_t>(ptrEnd - ptr), ubj_type, max_depth - 1, &sh, err)); if (*err) { goto exitlbl; } ptr += sh; if (ptr + 1 > ptrEnd) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } } ptr++; } result = array_value; } break; case UBJ_OBJECT: if (max_depth <= 1) { *err = MC_ERR_NOT_SUPPORTED; goto exitlbl; } ubj_type = UBJ_UNDEFINED; if (ptr + 1 > ptrEnd) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } size = size_t_max; if (*ptr == UBJ_TYPE[UBJ_STRONG_TYPE]) { ptr++; if (ptr + 1 > ptrEnd) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } ubj_type = UBJ_INTERNAL_TYPE[*ptr]; if (ubj_type < 0) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } ptr++; if (ptr + 1 > ptrEnd) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } if (*ptr != UBJ_TYPE[UBJ_COUNT]) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } } if (*ptr == UBJ_TYPE[UBJ_COUNT]) { ptr++; size = static_cast<size_t>(ubjson_int64_read(ptr, ptrEnd, UBJ_UNDEFINED, &sh, err)); if (*err) { goto exitlbl; } ptr += sh; } auto obj_value = v8::Object::New(isolate); if (size < size_t_max) { i = 0; while (i < size) { v8::Local<v8::Value> string_value = ubjson_read_internal( isolate, ptr, static_cast<size_t>(ptrEnd - ptr), UBJ_STRING, max_depth - 1, &sh, err); if (*err) { goto exitlbl; } ptr += sh; v8::Local<v8::Value> value_value = ubjson_read_internal( isolate, ptr, static_cast<size_t>(ptrEnd - ptr), ubj_type, max_depth - 1, &sh, err); obj_value->Set(string_value, value_value); if (*err) { goto exitlbl; } ptr += sh; i++; } } else { if (ptr + 1 > ptrEnd) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } while (*ptr != '}') { v8::Local<v8::Value> string_value = ubjson_read_internal( isolate, ptr, static_cast<size_t>(ptrEnd - ptr), UBJ_STRING, max_depth - 1, &sh, err); // std::cout << "ubjson_read_internal UBJ_OBJECT key=" << V82String(isolate, // string_value) // << std::endl; if (*err) { goto exitlbl; } ptr += sh; v8::Local<v8::Value> value_value = ubjson_read_internal( isolate, ptr, static_cast<size_t>(ptrEnd - ptr), ubj_type, max_depth - 1, &sh, err); // std::cout << "ubjson_read_internal UBJ_OBJECT value="; // _v8_internal_Print_Object(*((v8::internal::Object **)(*value_value))); // std::cout << std::endl; obj_value->Set(string_value, value_value); // std::cout << "ubjson_read_internal UBJ_OBJECT object="; // _v8_internal_Print_Object(*((v8::internal::Object **)(*obj_value))); // std::cout << std::endl; if (*err) { goto exitlbl; } ptr += sh; if (ptr + 1 > ptrEnd) { *err = MC_ERR_ERROR_IN_SCRIPT; goto exitlbl; } } ptr++; } result = obj_value; break; } } exitlbl: if (*err) { return handleScope.Escape(v8::Null(isolate)); } if (offset) { *offset = static_cast<unsigned>(ptr - ptrStart); } return handleScope.Escape(result); } <<<<<<< HEAD static int ubjson_int64_write(int64_t int64_value, int known_type, Blob *blob) ======= static int ubjson_int64_write(int64_t int64_value, int known_type, BlobPtr blob) >>>>>>> local/2.0-dev { int type = known_type; size_t n, sh; uint64_t v; unsigned char buf[9]; unsigned char *ptr; sh = 1; if (type == UBJ_UNDEFINED) { type = ubjson_best_int_type(int64_value, nullptr); sh = 0; } buf[0] = static_cast<unsigned char>(UBJ_TYPE[type]); n = static_cast<size_t>(UBJ_SIZE[type]); v = *reinterpret_cast<uint64_t *>(&int64_value); ptr = buf + n; while (ptr > buf) { *ptr = static_cast<unsigned char>(v % 256); v = v >> 8; ptr--; } blob->Append(buf + sh, n + 1 - sh); return MC_ERR_NOERROR; } static int ubjson_write_internal(v8::Isolate *isolate, v8::Local<v8::Value> value, int known_type, BlobPtr blob, int max_depth) { v8::Isolate::Scope isolateScope(isolate); v8::EscapableHandleScope handleScope(isolate); v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::Context::Scope contextScope(context); int err = MC_ERR_NOERROR; if (max_depth == 0) { return MC_ERR_NOT_SUPPORTED; } int ubj_type = known_type; if (ubj_type == UBJ_UNDEFINED) { ubj_type = ubjson_best_type(isolate, value, 0, nullptr, nullptr, nullptr); char type = UBJ_TYPE[ubj_type]; blob->Append(&type, 1); } if (UBJ_ISINT[ubj_type]) { ubjson_int64_write(value->Int32Value(context).FromJust(), ubj_type, blob); } else { switch (ubj_type) { case UBJ_NULLTYPE: // fall through case UBJ_BOOL_FALSE: // fall through case UBJ_BOOL_TRUE: break; case UBJ_FLOAT64: { int64_t int64_value; double double_value = value->NumberValue(context).FromJust(); swap_bytes(&int64_value, &double_value, sizeof(double)); blob->Append(&int64_value, sizeof(double)); break; } case UBJ_CHAR: // fall through case UBJ_STRING: { std::string string_value = V82String(isolate, value); ubjson_int64_write(static_cast<int64_t>(string_value.size()), UBJ_UNDEFINED, blob); char *c_string = const_cast<char *>(string_value.c_str()); blob->Append(c_string, static_cast<unsigned>(string_value.size())); break; } case UBJ_ARRAY: { if (max_depth <= 1) { err = MC_ERR_NOT_SUPPORTED; goto exitlbl; } int optimized = 1; int last_type = UBJ_UNDEFINED; int not_uint8 = 0; int64_t usize = 0; int64_t ssize = 0; unsigned i = 0; auto array_value = v8::Local<v8::Array>::Cast(value); while (i < array_value->Length()) { ubj_type = ubjson_best_type(isolate, array_value->Get(context, i).ToLocalChecked(), last_type, &not_uint8, &usize, &ssize); if (ubj_type > 0) { last_type = ubj_type; i++; } else { optimized = 0; i = array_value->Length(); } } if (last_type == UBJ_UNDEFINED) { optimized = 0; } if (optimized) { if (last_type == UBJ_UINT8) { if (not_uint8) { last_type = UBJ_INT16; } else { ssize = usize; } } v8::Local<v8::Integer> length_value = v8::Integer::New(isolate, static_cast<int32_t>(array_value->Length())); ubj_type = ubjson_best_type(isolate, length_value, 0, nullptr, nullptr, nullptr); int64_t length = static_cast<int64_t>(array_value->Length()); if (ssize + length + 1 <= length * UBJ_SIZE[last_type] + UBJ_SIZE[ubj_type] + 4) { optimized = 0; } } i = 0; if (optimized) { char type = '$'; blob->Append(&type, 1); type = UBJ_TYPE[last_type]; blob->Append(&type, 1); type = '#'; blob->Append(&type, 1); ubjson_int64_write(static_cast<int64_t>(array_value->Length()), UBJ_UNDEFINED, blob); } else { last_type = UBJ_UNDEFINED; } while (i < array_value->Length()) { if (optimized && UBJ_ISINT[last_type]) { ubjson_int64_write(array_value->Get(context, i).ToLocalChecked()->IntegerValue(context).FromJust(), last_type, blob); } else { err = ubjson_write_internal(isolate, array_value->Get(context, i).ToLocalChecked(), last_type, blob, max_depth - 1); if (err) { goto exitlbl; } } i++; } if (!optimized) { char type = ']'; blob->Append(&type, 1); } break; } case UBJ_OBJECT: { if (max_depth <= 1) { err = MC_ERR_NOT_SUPPORTED; goto exitlbl; } int optimized = 1; int last_type = UBJ_UNDEFINED; int not_uint8 = 0; int64_t usize = 0; int64_t ssize = 0; unsigned i = 0; auto obj_value = v8::Local<v8::Object>::Cast(value); v8::Local<v8::Array> prop_names = obj_value->GetOwnPropertyNames(context).ToLocalChecked(); while (i < prop_names->Length()) { v8::Local<v8::String> name_ = prop_names->Get(context, i).ToLocalChecked()->ToString(); v8::Local<v8::Value> value_ = obj_value->Get(context, name_).ToLocalChecked(); ubj_type = ubjson_best_type(isolate, value_, last_type, &not_uint8, &usize, &ssize); if (ubj_type > 0) { last_type = ubj_type; i++; } else { optimized = 0; i = prop_names->Length(); } } if (last_type == UBJ_UNDEFINED) { optimized = 0; } if (optimized) { if (last_type == UBJ_UINT8) { if (not_uint8) { last_type = UBJ_INT16; } else { ssize = usize; } } v8::Local<v8::Integer> length_value = v8::Integer::New(isolate, static_cast<int32_t>(prop_names->Length())); ubj_type = ubjson_best_type(isolate, length_value, 0, nullptr, nullptr, nullptr); int64_t length = static_cast<int64_t>(prop_names->Length()); if (ssize + length + 1 <= length * UBJ_SIZE[last_type] + UBJ_SIZE[ubj_type] + 4) { optimized = 0; } } i = 0; if (optimized) { char type = '$'; blob->Append(&type, 1); type = UBJ_TYPE[last_type]; blob->Append(&type, 1); type = '#'; blob->Append(&type, 1); ubjson_int64_write(static_cast<int64_t>(prop_names->Length()), UBJ_UNDEFINED, blob); } else { last_type = UBJ_UNDEFINED; } while (i < prop_names->Length()) { v8::Local<v8::String> name_ = prop_names->Get(context, i).ToLocalChecked()->ToString(); v8::Local<v8::Value> value_ = obj_value->Get(context, name_).ToLocalChecked(); err = ubjson_write_internal(isolate, name_, UBJ_STRING, blob, max_depth - 1); if (err) { goto exitlbl; } if (optimized && UBJ_ISINT[last_type]) { ubjson_int64_write(value_->IntegerValue(context).FromJust(), last_type, blob); } else { err = ubjson_write_internal(isolate, value_, last_type, blob, max_depth - 1); if (err) { goto exitlbl; } } i++; } if (!optimized) { char type = '}'; blob->Append(&type, 1); } break; } default: return MC_ERR_NOT_SUPPORTED; } } exitlbl: return err; } int V82Ubj(v8::Isolate *isolate, v8::Local<v8::Value> value, BlobPtr blob) { blob->Reset(); return ubjson_write_internal(isolate, value, UBJ_UNDEFINED, blob, MAX_FORMATTED_DATA_DEPTH); } v8::Local<v8::Value> Ubj2V8(v8::Isolate *isolate, BlobPtr blob, int *err) { size_t offset = 0; return ubjson_read_internal(isolate, blob->Data(), blob->DataSize(), UBJ_UNDEFINED, MAX_FORMATTED_DATA_DEPTH, &offset, err); } } // namespace mc_v8
/*! \class VSpectralFitter \brief fitter class for energy spectra */ #include "VSpectralFitter.h" ClassImp( VSpectralFitter ) VSpectralFitter::VSpectralFitter( string fitname ) { fFitFunction = 0; fFitFunction_lin = 0; fFitFunction_CovarianceMatrix = 0; fFitName = fitname; setSpectralFitFunction(); setSpectralFitFluxNormalisationEnergy(); setSpectralFitRangeLin(); setPlottingStyle(); } /* fit the current function (note the fit options) print out covariance matrix and correlation coefficient (for dim=2) */ TF1* VSpectralFitter::fit( TGraph* g, string fitname ) { if( !g ) { cout << "VSpectralFitter::fit warning: no graph" << endl; return 0; } if( fitname.size() > 0 ) { fFitName = fitname; } // define fit function defineFitFunction(); // fit if( fSpectralFitFunction == 2 ) // i.e. for the broken power law { g->Fit( fFitFunction, "0MNREV" ); // more verbose } else { g->Fit( fFitFunction, "0MNER" ); } // gets the current default fitter TVirtualFitter* fitter = TVirtualFitter::GetFitter(); if( fSpectralFitFunction == 2 ) // i.e. for the broken power law { // Change the tolerance of the EDM, and loosen the convergence condition, since BPL has more free parameters fitter->SetPrecision( 1E-1 ); // Note the EDM is 0.001 * 1E-2 * (some constant), otherwise there is problem with convergence cout << "Setting default tolerance EDM to ~ 1.E-4" << endl; cout << "Coder's WARNING: Use this with care, and check the output of the fitter and the Error Matrix is not from MINOS" << endl; } // covariance matrix if( fitter && fitter->GetCovarianceMatrix() ) { int nPars = fitter->GetNumberFreeParameters(); TMatrixD* COV = new TMatrixD( nPars, nPars, fitter->GetCovarianceMatrix() ); if( COV ) { fFitFunction_CovarianceMatrix = COV->GetMatrixArray(); cout << "Fitter: " << endl; cout << "\tCovariance matrix "; cout << "(nxn=" << fitter->GetNumberTotalParameters() << "x" << fitter->GetNumberTotalParameters() << "): " << endl; for( int i = 0; i < fitter->GetNumberTotalParameters(); i++ ) { for( int j = 0; j < fitter->GetNumberTotalParameters(); j++ ) { cout << "\t" << fitter->GetCovarianceMatrixElement( i, j ); } cout << endl; } // calculate correlation coefficient if( fitter->GetNumberTotalParameters() == 2 ) { if( fitter->GetCovarianceMatrixElement( 0, 0 ) > 0. && fitter->GetCovarianceMatrixElement( 1, 1 ) > 0. ) { double rho = TMath::Abs( fitter->GetCovarianceMatrixElement( 0, 1 ) ); rho /= sqrt( fitter->GetCovarianceMatrixElement( 0, 0 ) * fitter->GetCovarianceMatrixElement( 1, 1 ) ); cout << "\tCorrelation coefficient: " << rho << endl; double i_decorr = fSpectralFitFluxNormalisationEnergy ; i_decorr *= TMath::Exp( fitter->GetCovarianceMatrixElement( 0, 1 ) / fFitFunction->GetParameter(0) / fitter->GetCovarianceMatrixElement( 1, 1 ) ); cout << "\tDecorrelation Energy: " << i_decorr << " " << fSpectralFitFluxNormalisationEnergy << endl; } } } } else { cout << "VSpectralFitter::fit: no covariance matrix" << endl; } updateFitFunction_lin(); return fFitFunction; } /* define fit function These are predifined and can be set with a function ID: fSpectralFitFunction == 0 : power law fSpectralFitFunction == 1 : power law with exponential cutoff fSpectralFitFunction == 2 : broken power law fSpectralFitFunction == 3 : curved power law */ bool VSpectralFitter::defineFitFunction() { char hname[2000]; string iFitName_lin = fFitName + "_lin"; ///////////////////////////////////////////////////////// // power law if( fSpectralFitFunction == 0 ) { cout << "Fitfunction: power law" << endl; sprintf( hname, "[0] * TMath::Power( TMath::Power( 10, x ) / %f, [1] )", fSpectralFitFluxNormalisationEnergy ); fFitFunction = new TF1( fFitName.c_str(), hname, log10( fSpectralFitEnergy_min ), log10( fSpectralFitEnergy_max ) ); fFitFunction->SetParameter( 0, 1.e-7 ); fFitFunction->SetParameter( 1, -2.5 ); // linear axis sprintf( hname, "[0] * TMath::Power( x/ %f, [1] )", fSpectralFitFluxNormalisationEnergy ); fFitFunction_lin = new TF1( iFitName_lin.c_str(), hname, fSpectralFitEnergy_min, fSpectralFitEnergy_max ); } ///////////////////////////////////////////////////////// // power law with exponential cutoff else if( fSpectralFitFunction == 1 ) { cout << "Fitfunction: power law with exponential cutoff" << endl; sprintf( hname, "[0] * TMath::Power( TMath::Power( 10, x ) / %f, [1] ) * TMath::Exp( -1. * TMath::Power( 10, x ) / [2] )", fSpectralFitFluxNormalisationEnergy ); fFitFunction = new TF1( fFitName.c_str(), hname, log10( fSpectralFitEnergy_min ), log10( fSpectralFitEnergy_max ) ); fFitFunction->SetParameter( 0, 1.e-7 ); fFitFunction->SetParameter( 1, -2. ); fFitFunction->SetParameter( 2, 10. ); sprintf( hname, "[0] * TMath::Power( x / %f, [1] ) * TMath::Exp( -1. * x / [2] )", fSpectralFitFluxNormalisationEnergy ); fFitFunction_lin = new TF1( iFitName_lin.c_str(), hname, fSpectralFitEnergy_min, fSpectralFitEnergy_max ); } // broken power law fit else if( fSpectralFitFunction == 2 ) { cout << "Fitfunction: broken power law" << endl; sprintf( hname, "((TMath::Power( 10, x )<[3]) * [0] * TMath::Power( TMath::Power( 10, x ) / [3], [1] )) + ((TMath::Power( 10, x )>=[3]) * [0] * TMath::Power( TMath::Power( 10, x ) / [3], [2] ))" ); fFitFunction = new TF1( fFitName.c_str(), hname, log10( fSpectralFitEnergy_min ), log10( fSpectralFitEnergy_max ) ); fFitFunction->SetParameter( 0, 2.e-10 ); fFitFunction->SetParameter( 1, -1.5 ); fFitFunction->SetParameter( 2, -3.0 ); fFitFunction->SetParameter( 3, 0.7 ); //fFitFunction->SetParLimits( 1, -10., 10. ); //fFitFunction->SetParLimits( 2, -10., 10. ); //fFitFunction->SetParLimits( 3, 0.05, 100. ); // linear axis sprintf( hname, "((x<[3]) * [0] * TMath::Power( x/ [3], [1] )) + ((x>=[3]) * [0] * TMath::Power( x/ [3], [2] ))" ); fFitFunction_lin = new TF1( iFitName_lin.c_str(), hname, fSpectralFitEnergy_min, fSpectralFitEnergy_max ); } // curved power law fit else if( fSpectralFitFunction == 3 ) { cout << "Fitfunction: curved power law fit" << endl; sprintf( hname, "[0] * TMath::Power( TMath::Power( 10, x ) / %f, [1]+[2]*TMath::Power( 10, x ) / %f )", fSpectralFitFluxNormalisationEnergy, fSpectralFitFluxNormalisationEnergy ); fFitFunction = new TF1( fFitName.c_str(), hname, log10( fSpectralFitEnergy_min ), log10( fSpectralFitEnergy_max ) ); fFitFunction->SetParameter( 0, 1.e-7 ); fFitFunction->SetParameter( 1, -2. ); fFitFunction->SetParameter( 2, -0.01 ); fFitFunction->SetParLimits( 2, -0.3, 0. ); } // curved power law fit (e.g. ApJ 674, 1037 (2008)) else if( fSpectralFitFunction == 4 ) { cout << "Fitfunction: curved power law fit (4)" << endl; sprintf( hname, "[0] * TMath::Power( TMath::Power( 10, x ) / %f, [1]+[2]*log10( TMath::Power( 10, x ) / %f ) )", fSpectralFitFluxNormalisationEnergy, fSpectralFitFluxNormalisationEnergy ); fFitFunction = new TF1( fFitName.c_str(), hname, log10( fSpectralFitEnergy_min ), log10( fSpectralFitEnergy_max ) ); fFitFunction->SetParameter( 0, 1.e-7 ); fFitFunction->SetParameter( 1, -2. ); fFitFunction->SetParameter( 2, -0.01 ); fFitFunction->SetParLimits( 2, -0.3, 0. ); } else { cout << "VSpectralFitter::defineFitFunction: unknown spectral fit function: " << fSpectralFitFunction << endl; return false; } // set all parameters for the function with linear energy axis updateFitFunction_lin(); // set plotting style if( fFitFunction ) { fFitFunction->SetLineStyle( fPlottingEnergySpectrumLineStyle ); fFitFunction->SetLineColor( fPlottingEnergySpectrumLineColor ); fFitFunction->SetLineWidth( ( Width_t )fPlottingEnergySpectrumLineWidth ); } return true; } void VSpectralFitter::updateFitFunction_lin() { if( !fFitFunction || !fFitFunction_lin ) { return; } for( int i = 0; i < fFitFunction->GetNpar(); i++ ) { fFitFunction_lin->SetParameter( i, fFitFunction->GetParameter( i ) ); fFitFunction_lin->SetParError( i, fFitFunction->GetParError( i ) ); } } void VSpectralFitter::print() { if( !fFitFunction ) { return; } cout << endl; if( fSpectralFitFunction == 0 ) { cout << "Results for power law fit: " << endl; cout << "--------------------------" << endl; cout << "dN/dE = I x (E/" << fSpectralFitFluxNormalisationEnergy << " TeV)^{-Gamma}" << endl; cout << "I = " << scientific << setprecision( 2 ) << fFitFunction->GetParameter( 0 ); cout << " +- " << fFitFunction->GetParError( 0 ) << " cm^-2s^-1TeV^-1" << endl; cout << "Gamma = " << fixed << setprecision( 2 ) << fFitFunction->GetParameter( 1 ); cout << " +- " << fFitFunction->GetParError( 1 ) << endl; cout << "Chi2 " << setprecision( 2 ) << fFitFunction->GetChisquare(); cout << ", N = " << fFitFunction->GetNDF(); if( fFitFunction->GetNDF() > 0. ) { cout << " (Chi2/N=" << fFitFunction->GetChisquare() / fFitFunction->GetNDF() << ")" << endl; } cout << endl; } } /* get integral flux from fit function iMinEnergy_TeV: threshold for integral flux in TeV (lin axis) */ double VSpectralFitter::getIntegralFlux( double iMinEnergy_TeV, double iMaxEnergy_TeV ) { if( !fFitFunction_lin ) { cout << "VSpectralFitter::getIntegralFlux(): error: no fit function" << endl; return -99999.; } // analytical calculation for power law (fSpectralFitFunction == 0) /* if( fSpectralFitFunction == 0 ) { if( fFitFunction_lin->GetParameter( 1 ) != -1. ) { double iFL = -1.* fFitFunction_lin->GetParameter( 0 ) / (fFitFunction_lin->GetParameter( 1 ) + 1.) / fSpectralFitFluxNormalisationEnergy; iFL *= TMath::Power( iMinEnergy_TeV / fSpectralFitFluxNormalisationEnergy, fFitFunction_lin->GetParameter( 1 ) + 1. ); return iFL; } } */ return fFitFunction_lin->Integral( iMinEnergy_TeV, iMaxEnergy_TeV, 1.e-30 ); } /* get integral flux error from fit function iMinEnergy_TeV: threshold for integral flux in TeV (lin axis) */ double VSpectralFitter::getIntegralFluxError( double iMinEnergy_TeV, double iMaxEnergy_TeV ) { if( !fFitFunction_lin || !fFitFunction ) { cout << "VSpectralFitter::getIntegralFlux(): error: no fit function" << endl; return -99999.; } return fFitFunction_lin->IntegralError( iMinEnergy_TeV, iMaxEnergy_TeV, fFitFunction_lin->GetParameters(), fFitFunction_CovarianceMatrix ); }
/** @file cones_inexact.cpp * A test application that computes the cone boundaries inexactly given the number of cones * and the initial direction. * * Authors: Weisheng Si and Quincy Tse, University of Western Sydney */ #include <cstdlib> #include <iostream> #include <iterator> #include <vector> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Compute_cone_boundaries_2.h> // select the kernel type typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef Kernel::Point_2 Point_2; typedef Kernel::Direction_2 Direction_2; int main(int argc, char ** argv) { if (argc < 2) { std::cout << "Usage: " << argv[0] << " <no. of cones> [<direction-x> <direction-y>]" << std::endl; return 1; } unsigned int k = atoi(argv[1]); if (k<2) { std::cout << "The number of cones should be larger than 1!" << std::endl; return 1; } Direction_2 initial_direction; if (argc == 2) initial_direction = Direction_2(1, 0); // default initial_direction else if (argc == 4) initial_direction = Direction_2(atof(argv[2]), atof(argv[3])); else { std::cout << "Usage: " << argv[0] << " <no. of cones> [<direction-x> <direction-y>]" << std::endl; return 1; } // construct the functor CGAL::Compute_cone_boundaries_2<Kernel> cones; // create the vector rays to store the results std::vector<Direction_2> rays(k); // compute the cone boundaries and store them in rays cones(k, initial_direction, rays.begin()); // display the computed rays, starting from the initial direction, ccw order for (unsigned int i=0; i<k; i++) std::cout << "Ray " << i << ": " << rays[i] << std::endl; return 0; }
/************************************************************** * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * *************************************************************/ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sd.hxx" #include "AccessiblePageShape.hxx" #include <svx/AccessibleShapeInfo.hxx> #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLE_ROLE_HPP_ #include <com/sun/star/accessibility/AccessibleRole.hpp> #endif #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLE_STATE_TYPE_HPP_ #include <com/sun/star/accessibility/AccessibleStateType.hpp> #endif #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/drawing/XShapeDescriptor.hpp> #include <com/sun/star/drawing/XMasterPageTarget.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::accessibility; using ::com::sun::star::uno::Reference; using ::rtl::OUString; #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) namespace accessibility { //===== internal ============================================================ AccessiblePageShape::AccessiblePageShape ( const uno::Reference<drawing::XDrawPage>& rxPage, const uno::Reference<XAccessible>& rxParent, const AccessibleShapeTreeInfo& rShapeTreeInfo, long nIndex) : AccessibleShape (AccessibleShapeInfo (NULL, rxParent, nIndex), rShapeTreeInfo), mxPage (rxPage) { // The main part of the initialization is done in the init method which // has to be called from this constructor's caller. } AccessiblePageShape::~AccessiblePageShape (void) { OSL_TRACE ("~AccessiblePageShape"); } void AccessiblePageShape::Init (void) { AccessibleShape::Init (); } //===== XAccessibleContext ================================================== sal_Int32 SAL_CALL AccessiblePageShape::getAccessibleChildCount (void) throw () { return 0; } /** Forward the request to the shape. Return the requested shape or throw an exception for a wrong index. */ uno::Reference<XAccessible> SAL_CALL AccessiblePageShape::getAccessibleChild( sal_Int32 ) throw (::com::sun::star::uno::RuntimeException) { throw lang::IndexOutOfBoundsException ( ::rtl::OUString::createFromAscii ("page shape has no children"), static_cast<uno::XWeak*>(this)); } //===== XAccessibleComponent ================================================ awt::Rectangle SAL_CALL AccessiblePageShape::getBounds (void) throw (::com::sun::star::uno::RuntimeException) { ThrowIfDisposed (); awt::Rectangle aBoundingBox; if (maShapeTreeInfo.GetViewForwarder() != NULL) { uno::Reference<beans::XPropertySet> xSet (mxPage, uno::UNO_QUERY); if (xSet.is()) { uno::Any aValue; awt::Point aPosition; awt::Size aSize; aValue = xSet->getPropertyValue ( ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("BorderLeft"))); aValue >>= aBoundingBox.X; aValue = xSet->getPropertyValue ( ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("BorderTop"))); aValue >>= aBoundingBox.Y; aValue = xSet->getPropertyValue ( ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("Width"))); aValue >>= aBoundingBox.Width; aValue = xSet->getPropertyValue ( ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("Height"))); aValue >>= aBoundingBox.Height; } // Transform coordinates from internal to pixel. ::Size aPixelSize = maShapeTreeInfo.GetViewForwarder()->LogicToPixel ( ::Size (aBoundingBox.Width, aBoundingBox.Height)); ::Point aPixelPosition = maShapeTreeInfo.GetViewForwarder()->LogicToPixel ( ::Point (aBoundingBox.X, aBoundingBox.Y)); // Clip the shape's bounding box with the bounding box of its parent. Reference<XAccessibleComponent> xParentComponent ( getAccessibleParent(), uno::UNO_QUERY); if (xParentComponent.is()) { // Make the coordinates relative to the parent. awt::Point aParentLocation (xParentComponent->getLocationOnScreen()); int x = aPixelPosition.getX() - aParentLocation.X; int y = aPixelPosition.getY() - aParentLocation.Y; // Clip with parent (with coordinates relative to itself). ::Rectangle aBBox ( x, y, x + aPixelSize.getWidth(), y + aPixelSize.getHeight()); awt::Size aParentSize (xParentComponent->getSize()); ::Rectangle aParentBBox (0,0, aParentSize.Width, aParentSize.Height); aBBox = aBBox.GetIntersection (aParentBBox); aBoundingBox = awt::Rectangle ( aBBox.getX(), aBBox.getY(), aBBox.getWidth(), aBBox.getHeight()); } else aBoundingBox = awt::Rectangle ( aPixelPosition.getX(), aPixelPosition.getY(), aPixelSize.getWidth(), aPixelSize.getHeight()); } return aBoundingBox; } sal_Int32 SAL_CALL AccessiblePageShape::getForeground (void) throw (::com::sun::star::uno::RuntimeException) { ThrowIfDisposed (); sal_Int32 nColor (0x0ffffffL); try { uno::Reference<beans::XPropertySet> aSet (mxPage, uno::UNO_QUERY); if (aSet.is()) { uno::Any aColor; aColor = aSet->getPropertyValue (::rtl::OUString::createFromAscii ("LineColor")); aColor >>= nColor; } } catch (::com::sun::star::beans::UnknownPropertyException) { // Ignore exception and return default color. } return nColor; } /** Extract the background color from the Background property of eithe the draw page or its master page. */ sal_Int32 SAL_CALL AccessiblePageShape::getBackground (void) throw (::com::sun::star::uno::RuntimeException) { ThrowIfDisposed (); sal_Int32 nColor (0x01020ffL); try { uno::Reference<beans::XPropertySet> xSet (mxPage, uno::UNO_QUERY); if (xSet.is()) { uno::Any aBGSet; aBGSet = xSet->getPropertyValue ( ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("Background"))); Reference<beans::XPropertySet> xBGSet (aBGSet, uno::UNO_QUERY); if ( ! xBGSet.is()) { // Draw page has no Background property. Try the master // page instead. Reference<drawing::XMasterPageTarget> xTarget (mxPage, uno::UNO_QUERY); if (xTarget.is()) { xSet = Reference<beans::XPropertySet> (xTarget->getMasterPage(), uno::UNO_QUERY); aBGSet = xSet->getPropertyValue ( ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("Background"))); xBGSet = Reference<beans::XPropertySet> (aBGSet, uno::UNO_QUERY); } } // Fetch the fill color. Has to be extended to cope with // gradients, hashes, and bitmaps. if (xBGSet.is()) { uno::Any aColor; aColor = xBGSet->getPropertyValue (::rtl::OUString::createFromAscii ("FillColor")); aColor >>= nColor; } else OSL_TRACE ("no Background property in page"); } } catch (::com::sun::star::beans::UnknownPropertyException) { OSL_TRACE ("caught excption due to unknown property"); // Ignore exception and return default color. } return nColor; } //===== XServiceInfo ======================================================== ::rtl::OUString SAL_CALL AccessiblePageShape::getImplementationName (void) throw (::com::sun::star::uno::RuntimeException) { ThrowIfDisposed (); return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessiblePageShape")); } ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL AccessiblePageShape::getSupportedServiceNames (void) throw (::com::sun::star::uno::RuntimeException) { ThrowIfDisposed (); return AccessibleShape::getSupportedServiceNames(); } //===== lang::XEventListener ================================================ void SAL_CALL AccessiblePageShape::disposing (const ::com::sun::star::lang::EventObject& aEvent) throw (::com::sun::star::uno::RuntimeException) { ThrowIfDisposed (); AccessibleShape::disposing (aEvent); } //===== XComponent ========================================================== void AccessiblePageShape::dispose (void) throw (::com::sun::star::uno::RuntimeException) { OSL_TRACE ("AccessiblePageShape::dispose"); // Unregister listeners. Reference<lang::XComponent> xComponent (mxShape, uno::UNO_QUERY); if (xComponent.is()) xComponent->removeEventListener (this); // Cleanup. mxShape = NULL; // Call base classes. AccessibleContextBase::dispose (); } //===== protected internal ================================================== ::rtl::OUString AccessiblePageShape::CreateAccessibleBaseName (void) throw (::com::sun::star::uno::RuntimeException) { return ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("PageShape")); } ::rtl::OUString AccessiblePageShape::CreateAccessibleName (void) throw (::com::sun::star::uno::RuntimeException) { Reference<beans::XPropertySet> xPageProperties (mxPage, UNO_QUERY); // Get name of the current slide. OUString sCurrentSlideName; try { if (xPageProperties.is()) { xPageProperties->getPropertyValue(A2S("LinkDisplayName")) >>= sCurrentSlideName; } } catch (beans::UnknownPropertyException&) { } return CreateAccessibleBaseName()+A2S(": ")+sCurrentSlideName; } ::rtl::OUString AccessiblePageShape::CreateAccessibleDescription (void) throw (::com::sun::star::uno::RuntimeException) { return ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("Page Shape")); } } // end of namespace accessibility
/*============================================================================= Library: CppMicroServices Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =============================================================================*/ //! [Activator] #include "IDictionaryService.h" #include "ISpellCheckService.h" #include <usModuleActivator.h> #include <usModuleContext.h> #include <usServiceProperties.h> #include <usServiceTracker.h> #include <usServiceTrackerCustomizer.h> #include <map> #include <cstring> #include <memory> US_USE_NAMESPACE namespace { /** * This class implements a module that implements a spell * checker service. The spell checker service uses all available * dictionary services to check for the existence of words in * a given sentence. This module uses a ServiceTracker to * monitors the dynamic availability of dictionary services, * and to aggregate all available dictionary services as they * arrive and depart. The spell checker service is only registered * if there are dictionary services available, thus the spell * checker service will appear and disappear as dictionary * services appear and disappear, respectively. **/ class US_ABI_LOCAL Activator : public ModuleActivator, public ServiceTrackerCustomizer<IDictionaryService> { private: /** * A private inner class that implements a spell check service; see * ISpellCheckService for details of the service. */ class SpellCheckImpl : public ISpellCheckService { private: typedef std::map<ServiceReference<IDictionaryService>, IDictionaryService*> RefToServiceType; RefToServiceType m_refToSvcMap; public: /** * Implements ISpellCheckService::Check(). Checks the given passage for * misspelled words. * * @param passage the passage to spell check. * @return A list of misspelled words. */ std::vector<std::string> Check(const std::string& passage) { std::vector<std::string> errorList; // No misspelled words for an empty string. if (passage.empty()) { return errorList; } // Tokenize the passage using spaces and punctuation. const char* delimiters = " ,.!?;:"; char* passageCopy = new char[passage.size()+1]; std::memcpy(passageCopy, passage.c_str(), passage.size()+1); char* pch = std::strtok(passageCopy, delimiters); { // Lock the m_refToSvcMap member using your favorite thread library here... // MutexLocker lock(&m_refToSvcMapMutex) // Loop through each word in the passage. while (pch) { std::string word(pch); bool correct = false; // Check each available dictionary for the current word. for (RefToServiceType::const_iterator i = m_refToSvcMap.begin(); (!correct) && (i != m_refToSvcMap.end()); ++i) { IDictionaryService* dictionary = i->second; if (dictionary->CheckWord(word)) { correct = true; } } // If the word is not correct, then add it // to the incorrect word list. if (!correct) { errorList.push_back(word); } pch = std::strtok(nullptr, delimiters); } } delete[] passageCopy; return errorList; } std::size_t AddDictionary(const ServiceReference<IDictionaryService>& ref, IDictionaryService* dictionary) { // Lock the m_refToSvcMap member using your favorite thread library here... // MutexLocker lock(&m_refToSvcMapMutex) m_refToSvcMap.insert(std::make_pair(ref, dictionary)); return m_refToSvcMap.size(); } std::size_t RemoveDictionary(const ServiceReference<IDictionaryService>& ref) { // Lock the m_refToSvcMap member using your favorite thread library here... // MutexLocker lock(&m_refToSvcMapMutex) m_refToSvcMap.erase(ref); return m_refToSvcMap.size(); } }; virtual IDictionaryService* AddingService(const ServiceReference<IDictionaryService>& reference) { IDictionaryService* dictionary = m_context->GetService(reference); std::size_t count = m_spellCheckService->AddDictionary(reference, dictionary); if (!m_spellCheckReg && count > 1) { m_spellCheckReg = m_context->RegisterService<ISpellCheckService>(m_spellCheckService.get()); } return dictionary; } virtual void ModifiedService(const ServiceReference<IDictionaryService>& /*reference*/, IDictionaryService* /*service*/) { // do nothing } virtual void RemovedService(const ServiceReference<IDictionaryService>& reference, IDictionaryService* /*service*/) { if (m_spellCheckService->RemoveDictionary(reference) < 2 && m_spellCheckReg) { m_spellCheckReg.Unregister(); m_spellCheckReg = 0; } } std::unique_ptr<SpellCheckImpl> m_spellCheckService; ServiceRegistration<ISpellCheckService> m_spellCheckReg; ModuleContext* m_context; std::unique_ptr<ServiceTracker<IDictionaryService> > m_tracker; public: Activator() : m_context(nullptr) {} /** * Implements ModuleActivator::Load(). Registers an * instance of a dictionary service using the module context; * attaches properties to the service that can be queried * when performing a service look-up. * * @param context the context for the module. */ void Load(ModuleContext* context) { m_context = context; m_spellCheckService.reset(new SpellCheckImpl); m_tracker.reset(new ServiceTracker<IDictionaryService>(context, this)); m_tracker->Open(); } /** * Implements ModuleActivator::Unload(). Does nothing since * the C++ Micro Services library will automatically unregister any registered services * and release any used services. * * @param context the context for the module. */ void Unload(ModuleContext* /*context*/) { // NOTE: The service is automatically unregistered m_tracker->Close(); } }; } US_EXPORT_MODULE_ACTIVATOR(Activator) //![Activator]
#include "litesql-gen-xml.hpp" #include <fstream> using namespace std; using namespace xml; using namespace litesql; void XmlGenerator::setOutputFilename(const std::string& filename) { m_outputFilename=filename; } bool generate(xml::Field* const field, ostream& os,size_t indent) { string indent_string(indent,' '); os << indent_string << "<field " << attribute("name",field->name) << attribute("type",toString(field->type)) << (field->default_.empty() ? "":attribute("default",field->default_)) << (field->isIndexed() ? attribute("indexed","true") : "") << (field->isUnique() ? attribute("unique","true") : "") ; if (field->values.empty()) { os << "/>" <<endl; } else { os << ">" <<endl; for (std::vector<xml::Value >::const_iterator it = field->values.begin(); it != field->values.end(); it++) { os << indent_string << ' ' << ' ' << "<value " << attribute("name", it->name) << attribute("value", it->value) << "/>" <<endl; } os << indent_string << endtag("field") <<endl; } return true; } void generate(xml::Method* const pMethod,ostream& os,size_t indent) { string indent_string(indent,' '); os << indent_string << "<method " << attribute("name",pMethod->name ); if (pMethod->params.empty()) { os << "/>" <<endl; } else { os << ">" <<endl; for (std::vector<xml::Param >::const_iterator it = pMethod->params.begin(); it != pMethod->params.end(); it++) { os << indent_string << " " << "<param " << attribute("type",(*it).type) << attribute("name",(*it).name) << "/>" << endl; } os << endtag("method") <<endl; } } bool XmlGenerator::generate(xml::Object* const object,ostream& os,size_t indent) { string indent_string(indent,' '); os << indent_string << "<object " << attribute("name",object->name) << (object->inheritsFromDefault() ? "": attribute("inherits",object->inherits)) << ">" <<endl; for (vector<xml::Field*>::const_iterator field_it = object->fields.begin(); field_it != object->fields.end(); field_it++) { if (((*field_it)->name!="id") && ((*field_it)->name!="type")) { ::generate(*field_it,os,indent+2); } } for (vector<xml::Method*>::const_iterator method_it = object->methods.begin(); method_it != object->methods.end(); method_it++) { ::generate(*method_it,os,indent+2); } os << indent_string << endtag("object") <<endl; return true; } bool XmlGenerator::generate(Relation* const relation,ostream& os,size_t indent) { string indent_string(indent,' '); os << indent_string << "<relation " << attribute("name",relation->name) << attribute("id",relation->id) << (relation->isUnidir() ? attribute("unidir","true"):""); if (relation->related.empty()) { os << "/>" ; } else { os << ">" << endl; for(vector<xml::Relate*>::const_iterator it = relation->related.begin(); it != relation->related.end(); it++) { os << indent_string << " " << "<relate " << attribute("object",(*it)->objectName) << ((*it)->hasLimit() ? attribute("limit",toString((*it)->limit)):"") << attribute("handle",(*it)->handle) << ((*it)->isUnique() ? attribute("unique","true"):"") << "/>" <<endl; } os << indent_string << endtag("relation"); } os << endl; return true; /*<relation id="Mother" unidir="true"> <relate object="Person" limit="many" handle="mother"/> <relate object="Person" limit="one"/> </relation> <relation id="Father" unidir="true"> <relate object="Person" limit="many" handle="father"/> <relate object="Person" limit="one"/> </relation> <relation id="Siblings"> <relate object="Person" handle="siblings"/> <relate object="Person"/> </relation> <relation id="Children" unidir="true"> <relate object="Person" handle="children"/> <relate object="Person"/> </relation> <object name="Role"/> <object name="Student" inherits="Role"/> <object name="Employee" inherits="Role"/> <relation id="Roles" name="RoleRelation"> <relate object="Person" handle="roles" limit="one"/> <relate object="Role" handle="person"/> </relation> */ } bool XmlGenerator::generateDatabase(ostream& os,const ObjectModel* model) { os << "<" << Database::TAG << " " << attribute("name",model->db.name) << attribute("namespace", model->db.nspace) << ">" << endl; CodeGenerator::generate(model->objects,os,2); CodeGenerator::generate(model->relations,os,2); os << "</"<< Database::TAG <<">" << endl; return true; } bool XmlGenerator::generateCode(const ObjectModel* model) { bool success; ofstream ofs(getOutputFilename(m_outputFilename).c_str()); ofs << "<?xml version=\"1.0\"?>" << endl << "<!DOCTYPE database SYSTEM \"litesql.dtd\">" << endl; success = generateDatabase(ofs,model); ofs.close(); return success; }
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QFileDialog> #include <QStandardPaths> #include <QDir> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); QIcon play, rec; QPixmap qpm; //Inizializzazione dei pulsanti e delle icone if (qpm.load(":/icons/play.png")) { play.addPixmap(qpm); ui->play->setIcon(play); ui->play->setIconSize(QSize(100,100)); } else { ui->play->setText("Play"); } if (qpm.load(":/icons/record.png")) { rec.addPixmap(qpm); ui->record->setIcon(rec); ui->record->setIconSize(QSize(100,100)); } else { ui->record->setText("Start\nRecord"); } m_theController = controller::GetInstance(); m_recAnim = new QMovie(":/anims/recording.gif"); m_recAnim->setScaledSize(QSize(ui->statusbar->height() - 5, ui->statusbar->height() - 5)); m_playAnim = new QMovie(":/anims/playing.gif"); m_playAnim->setScaledSize(QSize(ui->statusbar->height() + 15, ui->statusbar->height() + 15)); m_recordLabel = new QLabel(this); m_recordLabel->setMovie(m_recAnim); ui->statusbar->addWidget(m_recordLabel); m_recAnim->start(); m_recAnim->stop(); m_playProgress = new QProgressBar(this); ui->statusbar->addWidget(m_playProgress); connect(ui->play,&QPushButton::clicked,this,&MainWindow::PlayBtnPressed); connect(ui->record,&QPushButton::clicked,this,&MainWindow::RecordBtnPressed); connect(m_theController,&controller::NotifyStatusChange,this,&MainWindow::HandleStatusChange); connect(m_theController,&controller::UpdatePlayProgress,this,&MainWindow::SetProgress); connect(m_theController,&controller::OpenFile,this,&MainWindow::OpenFile); } MainWindow::~MainWindow() { delete ui; } void MainWindow::SetIcon(QPushButton* tgt, QString url, QString bk) { QIcon icon; QPixmap qpm; if (qpm.load(url)) { icon.addPixmap(qpm); tgt->setIcon(icon); } else { tgt->setText(bk); } } void MainWindow::HandleStatusChange(State newState) { switch(newState) { case Stopped: { SetIcon(ui->record,":/icons/record.png","Record"); SetIcon(ui->play,":/icons/play.png","Play"); ui->play->setEnabled(true); ui->record->setEnabled(true); m_playProgress->setEnabled(false); m_recAnim->stop(); } break; case Playing: { SetIcon(ui->play,":/icons/stop.png","Play"); ui->record->setEnabled(false); m_playProgress->setRange(0,1000); m_playProgress->setEnabled(true); } break; case Recording: { SetIcon(ui->record,":/icons/stop.png","Record"); ui->play->setEnabled(false); m_recAnim->start(); } break; } } void MainWindow::SetProgress(int value) { m_playProgress->setValue(value); } QString MainWindow::OpenFile(openMode mode) { QString fileName; switch(mode) { case Save: fileName = QFileDialog::getSaveFileName(this,tr("Save wav file."), QDir::homePath(), "Audio Files (*.wav)"); break; case Open: fileName = QFileDialog::getOpenFileName(this,tr("Open wav file."), QDir::homePath(), "Audio Files (*.wav)"); break; } return fileName; } void MainWindow::PlayBtnPressed() { if (m_theController->GetStatus() == Stopped) m_theController->Play(); else m_theController->Stop(); } void MainWindow::RecordBtnPressed() { if (m_theController->GetStatus() == Stopped) m_theController->Rec(); else m_theController->Stop(); }
#include "WaterControle.hpp" WaterControle::WaterControle() { thermo = new Thermo(tPIN, tType, tVCC, tGND); //pin, DHT Version [DHT11, DHT22], pinVCC, pinGND lcd = new Display(dAddress, dCol, dRow); //Address, colomn, row dt = new DateTime(dt_DataPin, dt_SclkPin); //SDA, SCL pins to = new ThermoOut(to_OneWireBus, to_pinVCC, to_pinGND); //Data Pin DS18B20, pinVCC, pinGND klapan = new Klapan(k_pinOpen, k_pinClose, k_pinGND); //uint8_t pinOpen, uint8_t pinClose, pinGND sensor = new CapasitiveSoilSensor(s_pinVCC, s_pinGND, s_AOut); //pinVCC, pinGND, pinAOut isOpen = false; //Klapan. Open = true, Close = false Serial.begin(115200); } WaterControle::~WaterControle() { delete sensor; delete klapan; delete to; delete dt; delete lcd; delete thermo; } void WaterControle::printTempAndHum() { count = 5; while (count) { lcd->setStr(0, 0); lcd->printOnLCD("T = ", thermo->getTemp()); Serial.print("T = "); Serial.print(thermo->getTemp()); Serial.print("\n"); lcd->setStr(0, 1); lcd->printOnLCD("H = ", thermo->getHum()); lcd->printOnLCD(" %"); Serial.print("H = "); Serial.print(thermo->getHum()); Serial.print("\n"); count--; delay(1000); lcd->lcdClear(); } } void WaterControle::printDateAndTime() { count = 5; while (count) { lcd->setStr(0, 0); lcd->printOnLCD(dt->getDate().c_str()); Serial.print(dt->getDate().c_str()); Serial.print("\n"); lcd->setStr(0, 1); lcd->printOnLCD(dt->getTime().c_str()); Serial.print(dt->getTime().c_str()); Serial.print("\n"); count--; delay(1000); lcd->lcdClear(); } } void WaterControle::printTempOnOut() { count = 5; while (count) { lcd->setStr(0, 0); lcd->printOnLCD("Temp on Out:"); Serial.print("Temp on Out:"); Serial.print(to->getTemp()); Serial.print("\n"); lcd->setStr(0, 1); lcd->printOnLCD(to->getTemp()); lcd->printOnLCD(" C"); Serial.print(to->getTemp()); count--; delay(1000); lcd->lcdClear(); } } void WaterControle::printInform() { if (isOpen == false) { lcd->setStr(0, 0); lcd->printOnLCD("Water Close"); lcd->setStr(0, 1); lcd->printOnLCD("by Danilka =)"); } else if (isOpen == true) { lcd->setStr(0, 0); lcd->printOnLCD("Water Open"); lcd->setStr(0, 1); lcd->printOnLCD("by Danilka =)"); } delay(5000); lcd->lcdClear(); } void WaterControle::setupDateAndTime(uint8_t date, uint8_t mon, uint16_t year, uint8_t hour, uint8_t min, uint8_t sec) { dt->setDate(date, mon, year); dt->setTime(hour, min, sec); // Установить время 16:29:00 (формат 24 часа) } void WaterControle::setupLimits(float aMaxTemp, float aMinTemp, float aMaxHum, float aMinHum) { MaxTemp = aMaxTemp; MinTemp = aMinTemp; MaxHum = aMaxHum; MinHum = aMinHum; } void WaterControle::setupHumLimit(int MIN, int MAX) { MinGr = MIN; MaxGr = MAX; } void WaterControle::onUpdate() { if (sensor->getData(s_AOut) <= MinGr) { if (isOpen == false) { klapan->Open(); delay(15000); } else if (isOpen == true) { delay(1000); } } else if (sensor->getData(s_AOut) >= MaxGr) { if (isOpen == false) { delay(1000); } else if (isOpen == true) { klapan->Close(); delay(15000); } } } void WaterControle::test() { lcd->setStr(0, 0); lcd->printOnLCD("Max Ground:", MaxGr); lcd->setStr(0, 1); lcd->printOnLCD("Min Ground:", MinGr); Serial.print("Max Ground: "); Serial.print(MaxGr); Serial.print("\n"); Serial.print("Min Ground:"); Serial.print(MinGr); Serial.print("\n"); delay(5000); lcd->lcdClear(); lcd->setStr(0, 0); lcd->printOnLCD("Current Data"); lcd->setStr(0, 1); lcd->printOnLCD(sensor->getData(s_AOut)); Serial.print("Current Data: "); Serial.print(sensor->getData(s_AOut)); Serial.print("\n"); delay(5000); lcd->lcdClear(); }
// mojo/public/cpp/bindings/tests/flush_async_unittest.test-mojom-blink.cc is auto generated by mojom_bindings_generator.py, do not edit // Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-private-field" #endif #include "mojo/public/cpp/bindings/tests/flush_async_unittest.test-mojom-blink.h" #include <math.h> #include <stdint.h> #include <utility> #include "base/hash/md5_constexpr.h" #include "base/run_loop.h" #include "base/strings/string_number_conversions.h" #include "base/task/common/task_annotator.h" #include "base/trace_event/trace_event.h" #include "mojo/public/cpp/bindings/lib/generated_code_util.h" #include "mojo/public/cpp/bindings/lib/message_internal.h" #include "mojo/public/cpp/bindings/lib/serialization_util.h" #include "mojo/public/cpp/bindings/lib/unserialized_message_context.h" #include "mojo/public/cpp/bindings/lib/validate_params.h" #include "mojo/public/cpp/bindings/lib/validation_context.h" #include "mojo/public/cpp/bindings/lib/validation_errors.h" #include "mojo/public/cpp/bindings/mojo_buildflags.h" #include "mojo/public/interfaces/bindings/interface_control_messages.mojom.h" #include "third_party/perfetto/include/perfetto/tracing/traced_value.h" #include "mojo/public/cpp/bindings/tests/flush_async_unittest.test-mojom-params-data.h" #include "mojo/public/cpp/bindings/tests/flush_async_unittest.test-mojom-shared-message-ids.h" #include "mojo/public/cpp/bindings/tests/flush_async_unittest.test-mojom-blink-import-headers.h" #include "mojo/public/cpp/bindings/lib/wtf_serialization.h" #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_FLUSH_ASYNC_UNITTEST_TEST_MOJOM_BLINK_JUMBO_H_ #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_FLUSH_ASYNC_UNITTEST_TEST_MOJOM_BLINK_JUMBO_H_ #endif namespace mojo { namespace test { namespace flush_async_unittest { namespace mojom { namespace blink { const char Writer::Name_[] = "mojo.test.flush_async_unittest.mojom.Writer"; WriterProxy::WriterProxy(mojo::MessageReceiverWithResponder* receiver) : receiver_(receiver) { } class WriterProxy_Put_Message : public mojo::internal::UnserializedMessageContext { public: static const mojo::internal::UnserializedMessageContext::Tag kMessageTag; explicit WriterProxy_Put_Message( uint32_t message_flags , const WTF::String& param_key , const WTF::String& param_value ) : mojo::internal::UnserializedMessageContext( &kMessageTag, internal::kWriter_Put_Name, message_flags) , param_key_(std::move(param_key)) , param_value_(std::move(param_value)){} ~WriterProxy_Put_Message() override = default; static mojo::Message Build( bool serialize, bool expects_response, bool is_sync, const WTF::String& param_key, const WTF::String& param_value) { const uint32_t kFlags = ((expects_response) ? mojo::Message::kFlagExpectsResponse : 0) | ((is_sync) ? mojo::Message::kFlagIsSync : 0); if (!serialize) { return mojo::Message(std::make_unique<WriterProxy_Put_Message>( kFlags , std::move(param_key) , std::move(param_value) ), MOJO_CREATE_MESSAGE_FLAG_NONE); } DCHECK(serialize); mojo::Message message( internal::kWriter_Put_Name, kFlags, 0, 0, nullptr); mojo::internal::MessageFragment< ::mojo::test::flush_async_unittest::mojom::internal::Writer_Put_Params_Data> params( message); params.Allocate(); mojo::internal::MessageFragment< typename decltype(params->key)::BaseType> key_fragment( params.message()); mojo::internal::Serialize<mojo::StringDataView>( param_key, key_fragment); params->key.Set( key_fragment.is_null() ? nullptr : key_fragment.data()); MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( params->key.is_null(), mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, "null key in Writer.Put request"); mojo::internal::MessageFragment< typename decltype(params->value)::BaseType> value_fragment( params.message()); mojo::internal::Serialize<mojo::StringDataView>( param_value, value_fragment); params->value.Set( value_fragment.is_null() ? nullptr : value_fragment.data()); MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( params->value.is_null(), mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, "null value in Writer.Put request"); return message; } void Dispatch( mojo::Message* message, Writer* impl) { if (message->receiver_connection_group()) { } impl->Put( std::move(param_key_), std::move(param_value_)); } private: // mojo::internal::UnserializedMessageContext: void Serialize(mojo::Message& message) override { mojo::internal::MessageFragment< ::mojo::test::flush_async_unittest::mojom::internal::Writer_Put_Params_Data> params( message); params.Allocate(); mojo::internal::MessageFragment< typename decltype(params->key)::BaseType> key_fragment( params.message()); mojo::internal::Serialize<mojo::StringDataView>( param_key_, key_fragment); params->key.Set( key_fragment.is_null() ? nullptr : key_fragment.data()); MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( params->key.is_null(), mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, "null key in Writer.Put request"); mojo::internal::MessageFragment< typename decltype(params->value)::BaseType> value_fragment( params.message()); mojo::internal::Serialize<mojo::StringDataView>( param_value_, value_fragment); params->value.Set( value_fragment.is_null() ? nullptr : value_fragment.data()); MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( params->value.is_null(), mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, "null value in Writer.Put request"); } WTF::String param_key_; WTF::String param_value_; DISALLOW_COPY_AND_ASSIGN(WriterProxy_Put_Message); }; const mojo::internal::UnserializedMessageContext::Tag WriterProxy_Put_Message::kMessageTag = {}; void WriterProxy::Put( const WTF::String& in_key, const WTF::String& in_value) { #if BUILDFLAG(MOJO_TRACE_ENABLED) TRACE_EVENT1( "mojom", "mojo::test::flush_async_unittest::mojom::Writer::Put", "input_parameters", [&](perfetto::TracedValue context){ auto dict = std::move(context).WriteDictionary(); perfetto::WriteIntoTracedValueWithFallback( dict.AddItem("key"), in_key, "<value of type const WTF::String&>"); perfetto::WriteIntoTracedValueWithFallback( dict.AddItem("value"), in_value, "<value of type const WTF::String&>"); }); #endif const bool kExpectsResponse = false; const bool kIsSync = false; const bool kSerialize = receiver_->PrefersSerializedMessages(); auto message = WriterProxy_Put_Message::Build( kSerialize, kExpectsResponse, kIsSync, std::move(in_key), std::move(in_value)); #if defined(ENABLE_IPC_FUZZER) message.set_interface_name(Writer::Name_); message.set_method_name("Put"); #endif // This return value may be ignored as false implies the Connector has // encountered an error, which will be visible through other means. ignore_result(receiver_->Accept(&message)); } // static bool WriterStubDispatch::Accept( Writer* impl, mojo::Message* message) { switch (message->header()->name) { case internal::kWriter_Put_Name: { #if BUILDFLAG(MOJO_TRACE_ENABLED) TRACE_EVENT1( "mojom", "(Impl)mojo::test::flush_async_unittest::mojom::Writer::Put", "message", message->name()); #endif static constexpr uint32_t kMessageHash = base::MD5Hash32Constexpr( "(Impl)mojo::test::flush_async_unittest::mojom::Writer::Put"); base::TaskAnnotator::ScopedSetIpcHash scoped_ipc_hash(kMessageHash); if (!message->is_serialized()) { auto context = message->TakeUnserializedContext< WriterProxy_Put_Message>(); if (!context) { // The Message was not of the expected type. It may be a valid message // which was serialized using a different variant of these bindings. // Force serialization before dispatch in this case. message->SerializeIfNecessary(); } else { context->Dispatch(message, impl); return true; } } DCHECK(message->is_serialized()); internal::Writer_Put_Params_Data* params = reinterpret_cast<internal::Writer_Put_Params_Data*>( message->mutable_payload()); bool success = true; WTF::String p_key{}; WTF::String p_value{}; Writer_Put_ParamsDataView input_data_view(params, message); if (success && !input_data_view.ReadKey(&p_key)) success = false; if (success && !input_data_view.ReadValue(&p_value)) success = false; if (!success) { ReportValidationErrorForMessage( message, mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, Writer::Name_, 0, false); return false; } // A null |impl| means no implementation was bound. DCHECK(impl); impl->Put( std::move(p_key), std::move(p_value)); return true; } } return false; } // static bool WriterStubDispatch::AcceptWithResponder( Writer* impl, mojo::Message* message, std::unique_ptr<mojo::MessageReceiverWithStatus> responder) { const bool message_is_sync = message->has_flag(mojo::Message::kFlagIsSync); const uint64_t request_id = message->request_id(); ALLOW_UNUSED_LOCAL(message_is_sync); ALLOW_UNUSED_LOCAL(request_id); switch (message->header()->name) { case internal::kWriter_Put_Name: { break; } } return false; } static const std::pair<uint32_t, mojo::internal::GenericValidationInfo> kWriterValidationInfo[] = { {internal::kWriter_Put_Name, {&internal::Writer_Put_Params_Data::Validate, nullptr /* no response */}}, }; bool WriterRequestValidator::Accept(mojo::Message* message) { const char* name = ::mojo::test::flush_async_unittest::mojom::blink::Writer::Name_; return mojo::internal::ValidateRequestGeneric(message, name, kWriterValidationInfo); } const char KeyValueStoreClient::Name_[] = "mojo.test.flush_async_unittest.mojom.KeyValueStoreClient"; KeyValueStoreClientProxy::KeyValueStoreClientProxy(mojo::MessageReceiverWithResponder* receiver) : receiver_(receiver) { } class KeyValueStoreClientProxy_OnSnapshotTaken_Message : public mojo::internal::UnserializedMessageContext { public: static const mojo::internal::UnserializedMessageContext::Tag kMessageTag; explicit KeyValueStoreClientProxy_OnSnapshotTaken_Message( uint32_t message_flags ) : mojo::internal::UnserializedMessageContext( &kMessageTag, internal::kKeyValueStoreClient_OnSnapshotTaken_Name, message_flags){} ~KeyValueStoreClientProxy_OnSnapshotTaken_Message() override = default; static mojo::Message Build( bool serialize, bool expects_response, bool is_sync) { const uint32_t kFlags = ((expects_response) ? mojo::Message::kFlagExpectsResponse : 0) | ((is_sync) ? mojo::Message::kFlagIsSync : 0); if (!serialize) { return mojo::Message(std::make_unique<KeyValueStoreClientProxy_OnSnapshotTaken_Message>( kFlags ), MOJO_CREATE_MESSAGE_FLAG_NONE); } DCHECK(serialize); mojo::Message message( internal::kKeyValueStoreClient_OnSnapshotTaken_Name, kFlags, 0, 0, nullptr); mojo::internal::MessageFragment< ::mojo::test::flush_async_unittest::mojom::internal::KeyValueStoreClient_OnSnapshotTaken_Params_Data> params( message); params.Allocate(); return message; } void Dispatch( mojo::Message* message, KeyValueStoreClient* impl) { if (message->receiver_connection_group()) { } impl->OnSnapshotTaken(); } private: // mojo::internal::UnserializedMessageContext: void Serialize(mojo::Message& message) override { mojo::internal::MessageFragment< ::mojo::test::flush_async_unittest::mojom::internal::KeyValueStoreClient_OnSnapshotTaken_Params_Data> params( message); params.Allocate(); } DISALLOW_COPY_AND_ASSIGN(KeyValueStoreClientProxy_OnSnapshotTaken_Message); }; const mojo::internal::UnserializedMessageContext::Tag KeyValueStoreClientProxy_OnSnapshotTaken_Message::kMessageTag = {}; void KeyValueStoreClientProxy::OnSnapshotTaken( ) { #if BUILDFLAG(MOJO_TRACE_ENABLED) TRACE_EVENT0("mojom", "mojo::test::flush_async_unittest::mojom::KeyValueStoreClient::OnSnapshotTaken"); #endif const bool kExpectsResponse = false; const bool kIsSync = false; const bool kSerialize = receiver_->PrefersSerializedMessages(); auto message = KeyValueStoreClientProxy_OnSnapshotTaken_Message::Build( kSerialize, kExpectsResponse, kIsSync); #if defined(ENABLE_IPC_FUZZER) message.set_interface_name(KeyValueStoreClient::Name_); message.set_method_name("OnSnapshotTaken"); #endif // This return value may be ignored as false implies the Connector has // encountered an error, which will be visible through other means. ignore_result(receiver_->Accept(&message)); } // static bool KeyValueStoreClientStubDispatch::Accept( KeyValueStoreClient* impl, mojo::Message* message) { switch (message->header()->name) { case internal::kKeyValueStoreClient_OnSnapshotTaken_Name: { #if BUILDFLAG(MOJO_TRACE_ENABLED) TRACE_EVENT1( "mojom", "(Impl)mojo::test::flush_async_unittest::mojom::KeyValueStoreClient::OnSnapshotTaken", "message", message->name()); #endif static constexpr uint32_t kMessageHash = base::MD5Hash32Constexpr( "(Impl)mojo::test::flush_async_unittest::mojom::KeyValueStoreClient::OnSnapshotTaken"); base::TaskAnnotator::ScopedSetIpcHash scoped_ipc_hash(kMessageHash); if (!message->is_serialized()) { auto context = message->TakeUnserializedContext< KeyValueStoreClientProxy_OnSnapshotTaken_Message>(); if (!context) { // The Message was not of the expected type. It may be a valid message // which was serialized using a different variant of these bindings. // Force serialization before dispatch in this case. message->SerializeIfNecessary(); } else { context->Dispatch(message, impl); return true; } } DCHECK(message->is_serialized()); internal::KeyValueStoreClient_OnSnapshotTaken_Params_Data* params = reinterpret_cast<internal::KeyValueStoreClient_OnSnapshotTaken_Params_Data*>( message->mutable_payload()); bool success = true; KeyValueStoreClient_OnSnapshotTaken_ParamsDataView input_data_view(params, message); if (!success) { ReportValidationErrorForMessage( message, mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, KeyValueStoreClient::Name_, 0, false); return false; } // A null |impl| means no implementation was bound. DCHECK(impl); impl->OnSnapshotTaken(); return true; } } return false; } // static bool KeyValueStoreClientStubDispatch::AcceptWithResponder( KeyValueStoreClient* impl, mojo::Message* message, std::unique_ptr<mojo::MessageReceiverWithStatus> responder) { const bool message_is_sync = message->has_flag(mojo::Message::kFlagIsSync); const uint64_t request_id = message->request_id(); ALLOW_UNUSED_LOCAL(message_is_sync); ALLOW_UNUSED_LOCAL(request_id); switch (message->header()->name) { case internal::kKeyValueStoreClient_OnSnapshotTaken_Name: { break; } } return false; } static const std::pair<uint32_t, mojo::internal::GenericValidationInfo> kKeyValueStoreClientValidationInfo[] = { {internal::kKeyValueStoreClient_OnSnapshotTaken_Name, {&internal::KeyValueStoreClient_OnSnapshotTaken_Params_Data::Validate, nullptr /* no response */}}, }; bool KeyValueStoreClientRequestValidator::Accept(mojo::Message* message) { const char* name = ::mojo::test::flush_async_unittest::mojom::blink::KeyValueStoreClient::Name_; return mojo::internal::ValidateRequestGeneric(message, name, kKeyValueStoreClientValidationInfo); } const char KeyValueStore::Name_[] = "mojo.test.flush_async_unittest.mojom.KeyValueStore"; class KeyValueStore_GetSnapshot_ForwardToCallback : public mojo::MessageReceiver { public: KeyValueStore_GetSnapshot_ForwardToCallback( KeyValueStore::GetSnapshotCallback callback ) : callback_(std::move(callback)) { } bool Accept(mojo::Message* message) override; private: KeyValueStore::GetSnapshotCallback callback_; DISALLOW_COPY_AND_ASSIGN(KeyValueStore_GetSnapshot_ForwardToCallback); }; KeyValueStoreProxy::KeyValueStoreProxy(mojo::MessageReceiverWithResponder* receiver) : receiver_(receiver) { } class KeyValueStoreProxy_SetClient_Message : public mojo::internal::UnserializedMessageContext { public: static const mojo::internal::UnserializedMessageContext::Tag kMessageTag; explicit KeyValueStoreProxy_SetClient_Message( uint32_t message_flags , ::mojo::PendingRemote<KeyValueStoreClient> param_client ) : mojo::internal::UnserializedMessageContext( &kMessageTag, internal::kKeyValueStore_SetClient_Name, message_flags) , param_client_(std::move(param_client)){} ~KeyValueStoreProxy_SetClient_Message() override = default; static mojo::Message Build( bool serialize, bool expects_response, bool is_sync, ::mojo::PendingRemote<KeyValueStoreClient> param_client) { const uint32_t kFlags = ((expects_response) ? mojo::Message::kFlagExpectsResponse : 0) | ((is_sync) ? mojo::Message::kFlagIsSync : 0); if (!serialize) { return mojo::Message(std::make_unique<KeyValueStoreProxy_SetClient_Message>( kFlags , std::move(param_client) ), MOJO_CREATE_MESSAGE_FLAG_NONE); } DCHECK(serialize); mojo::Message message( internal::kKeyValueStore_SetClient_Name, kFlags, 0, 0, nullptr); mojo::internal::MessageFragment< ::mojo::test::flush_async_unittest::mojom::internal::KeyValueStore_SetClient_Params_Data> params( message); params.Allocate(); mojo::internal::Serialize<mojo::InterfacePtrDataView<::mojo::test::flush_async_unittest::mojom::KeyValueStoreClientInterfaceBase>>( param_client, &params->client, &params.message()); MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( !mojo::internal::IsHandleOrInterfaceValid(params->client), mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE, "invalid client in KeyValueStore.SetClient request"); return message; } void Dispatch( mojo::Message* message, KeyValueStore* impl) { if (message->receiver_connection_group()) { } impl->SetClient( std::move(param_client_)); } private: // mojo::internal::UnserializedMessageContext: void Serialize(mojo::Message& message) override { mojo::internal::MessageFragment< ::mojo::test::flush_async_unittest::mojom::internal::KeyValueStore_SetClient_Params_Data> params( message); params.Allocate(); mojo::internal::Serialize<mojo::InterfacePtrDataView<::mojo::test::flush_async_unittest::mojom::KeyValueStoreClientInterfaceBase>>( param_client_, &params->client, &params.message()); MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( !mojo::internal::IsHandleOrInterfaceValid(params->client), mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE, "invalid client in KeyValueStore.SetClient request"); } ::mojo::PendingRemote<KeyValueStoreClient> param_client_; DISALLOW_COPY_AND_ASSIGN(KeyValueStoreProxy_SetClient_Message); }; const mojo::internal::UnserializedMessageContext::Tag KeyValueStoreProxy_SetClient_Message::kMessageTag = {}; void KeyValueStoreProxy::SetClient( ::mojo::PendingRemote<KeyValueStoreClient> in_client) { #if BUILDFLAG(MOJO_TRACE_ENABLED) TRACE_EVENT1( "mojom", "mojo::test::flush_async_unittest::mojom::KeyValueStore::SetClient", "input_parameters", [&](perfetto::TracedValue context){ auto dict = std::move(context).WriteDictionary(); perfetto::WriteIntoTracedValueWithFallback( dict.AddItem("client"), in_client, "<value of type ::mojo::PendingRemote<KeyValueStoreClient>>"); }); #endif const bool kExpectsResponse = false; const bool kIsSync = false; const bool kSerialize = receiver_->PrefersSerializedMessages(); auto message = KeyValueStoreProxy_SetClient_Message::Build( kSerialize, kExpectsResponse, kIsSync, std::move(in_client)); #if defined(ENABLE_IPC_FUZZER) message.set_interface_name(KeyValueStore::Name_); message.set_method_name("SetClient"); #endif // This return value may be ignored as false implies the Connector has // encountered an error, which will be visible through other means. ignore_result(receiver_->Accept(&message)); } class KeyValueStoreProxy_BindWriter_Message : public mojo::internal::UnserializedMessageContext { public: static const mojo::internal::UnserializedMessageContext::Tag kMessageTag; explicit KeyValueStoreProxy_BindWriter_Message( uint32_t message_flags , ::mojo::PendingReceiver<Writer> param_receiver ) : mojo::internal::UnserializedMessageContext( &kMessageTag, internal::kKeyValueStore_BindWriter_Name, message_flags) , param_receiver_(std::move(param_receiver)){} ~KeyValueStoreProxy_BindWriter_Message() override = default; static mojo::Message Build( bool serialize, bool expects_response, bool is_sync, ::mojo::PendingReceiver<Writer> param_receiver) { const uint32_t kFlags = ((expects_response) ? mojo::Message::kFlagExpectsResponse : 0) | ((is_sync) ? mojo::Message::kFlagIsSync : 0); if (!serialize) { return mojo::Message(std::make_unique<KeyValueStoreProxy_BindWriter_Message>( kFlags , std::move(param_receiver) ), MOJO_CREATE_MESSAGE_FLAG_NONE); } DCHECK(serialize); mojo::Message message( internal::kKeyValueStore_BindWriter_Name, kFlags, 0, 0, nullptr); mojo::internal::MessageFragment< ::mojo::test::flush_async_unittest::mojom::internal::KeyValueStore_BindWriter_Params_Data> params( message); params.Allocate(); mojo::internal::Serialize<mojo::InterfaceRequestDataView<::mojo::test::flush_async_unittest::mojom::WriterInterfaceBase>>( param_receiver, &params->receiver, &params.message()); MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( !mojo::internal::IsHandleOrInterfaceValid(params->receiver), mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE, "invalid receiver in KeyValueStore.BindWriter request"); return message; } void Dispatch( mojo::Message* message, KeyValueStore* impl) { if (message->receiver_connection_group()) { param_receiver_.set_connection_group( *message->receiver_connection_group()); } impl->BindWriter( std::move(param_receiver_)); } private: // mojo::internal::UnserializedMessageContext: void Serialize(mojo::Message& message) override { mojo::internal::MessageFragment< ::mojo::test::flush_async_unittest::mojom::internal::KeyValueStore_BindWriter_Params_Data> params( message); params.Allocate(); mojo::internal::Serialize<mojo::InterfaceRequestDataView<::mojo::test::flush_async_unittest::mojom::WriterInterfaceBase>>( param_receiver_, &params->receiver, &params.message()); MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( !mojo::internal::IsHandleOrInterfaceValid(params->receiver), mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE, "invalid receiver in KeyValueStore.BindWriter request"); } ::mojo::PendingReceiver<Writer> param_receiver_; DISALLOW_COPY_AND_ASSIGN(KeyValueStoreProxy_BindWriter_Message); }; const mojo::internal::UnserializedMessageContext::Tag KeyValueStoreProxy_BindWriter_Message::kMessageTag = {}; void KeyValueStoreProxy::BindWriter( ::mojo::PendingReceiver<Writer> in_receiver) { #if BUILDFLAG(MOJO_TRACE_ENABLED) TRACE_EVENT1( "mojom", "mojo::test::flush_async_unittest::mojom::KeyValueStore::BindWriter", "input_parameters", [&](perfetto::TracedValue context){ auto dict = std::move(context).WriteDictionary(); perfetto::WriteIntoTracedValueWithFallback( dict.AddItem("receiver"), in_receiver, "<value of type ::mojo::PendingReceiver<Writer>>"); }); #endif const bool kExpectsResponse = false; const bool kIsSync = false; const bool kSerialize = receiver_->PrefersSerializedMessages(); auto message = KeyValueStoreProxy_BindWriter_Message::Build( kSerialize, kExpectsResponse, kIsSync, std::move(in_receiver)); #if defined(ENABLE_IPC_FUZZER) message.set_interface_name(KeyValueStore::Name_); message.set_method_name("BindWriter"); #endif // This return value may be ignored as false implies the Connector has // encountered an error, which will be visible through other means. ignore_result(receiver_->Accept(&message)); } class KeyValueStoreProxy_GetSnapshot_Message : public mojo::internal::UnserializedMessageContext { public: static const mojo::internal::UnserializedMessageContext::Tag kMessageTag; explicit KeyValueStoreProxy_GetSnapshot_Message( uint32_t message_flags ) : mojo::internal::UnserializedMessageContext( &kMessageTag, internal::kKeyValueStore_GetSnapshot_Name, message_flags){} ~KeyValueStoreProxy_GetSnapshot_Message() override = default; static mojo::Message Build( bool serialize, bool expects_response, bool is_sync) { const uint32_t kFlags = ((expects_response) ? mojo::Message::kFlagExpectsResponse : 0) | ((is_sync) ? mojo::Message::kFlagIsSync : 0); if (!serialize) { return mojo::Message(std::make_unique<KeyValueStoreProxy_GetSnapshot_Message>( kFlags ), MOJO_CREATE_MESSAGE_FLAG_NONE); } DCHECK(serialize); mojo::Message message( internal::kKeyValueStore_GetSnapshot_Name, kFlags, 0, 0, nullptr); mojo::internal::MessageFragment< ::mojo::test::flush_async_unittest::mojom::internal::KeyValueStore_GetSnapshot_Params_Data> params( message); params.Allocate(); return message; } void Dispatch( mojo::Message* message, KeyValueStore* impl, KeyValueStore::GetSnapshotCallback callback) { if (message->receiver_connection_group()) { } impl->GetSnapshot(std::move(callback)); } private: // mojo::internal::UnserializedMessageContext: void Serialize(mojo::Message& message) override { mojo::internal::MessageFragment< ::mojo::test::flush_async_unittest::mojom::internal::KeyValueStore_GetSnapshot_Params_Data> params( message); params.Allocate(); } DISALLOW_COPY_AND_ASSIGN(KeyValueStoreProxy_GetSnapshot_Message); }; const mojo::internal::UnserializedMessageContext::Tag KeyValueStoreProxy_GetSnapshot_Message::kMessageTag = {}; void KeyValueStoreProxy::GetSnapshot( GetSnapshotCallback callback) { #if BUILDFLAG(MOJO_TRACE_ENABLED) TRACE_EVENT0("mojom", "mojo::test::flush_async_unittest::mojom::KeyValueStore::GetSnapshot"); #endif const bool kExpectsResponse = true; const bool kIsSync = false; const bool kSerialize = receiver_->PrefersSerializedMessages(); auto message = KeyValueStoreProxy_GetSnapshot_Message::Build( kSerialize, kExpectsResponse, kIsSync); #if defined(ENABLE_IPC_FUZZER) message.set_interface_name(KeyValueStore::Name_); message.set_method_name("GetSnapshot"); #endif std::unique_ptr<mojo::MessageReceiver> responder( new KeyValueStore_GetSnapshot_ForwardToCallback( std::move(callback))); ignore_result(receiver_->AcceptWithResponder(&message, std::move(responder))); } class KeyValueStore_GetSnapshot_ProxyToResponder { public: static KeyValueStore::GetSnapshotCallback CreateCallback( uint64_t request_id, bool is_sync, std::unique_ptr<mojo::MessageReceiverWithStatus>* responder) { std::unique_ptr<KeyValueStore_GetSnapshot_ProxyToResponder> proxy( new KeyValueStore_GetSnapshot_ProxyToResponder( request_id, is_sync, responder)); return base::BindOnce(&KeyValueStore_GetSnapshot_ProxyToResponder::Run, std::move(proxy)); } ~KeyValueStore_GetSnapshot_ProxyToResponder() { #if DCHECK_IS_ON() if (responder_) { // If we're being destroyed without being run, we want to ensure the // binding endpoint has been closed. This checks for that asynchronously. // We pass a bound generated callback to handle the response so that any // resulting DCHECK stack will have useful interface type information. responder_->IsConnectedAsync(base::BindOnce(&OnIsConnectedComplete)); } #endif // If the Callback was dropped then deleting the responder will close // the pipe so the calling application knows to stop waiting for a reply. responder_ = nullptr; } private: KeyValueStore_GetSnapshot_ProxyToResponder( uint64_t request_id, bool is_sync, std::unique_ptr<mojo::MessageReceiverWithStatus>* responder) : request_id_(request_id), is_sync_(is_sync), responder_(std::move(*responder)) { } #if DCHECK_IS_ON() static void OnIsConnectedComplete(bool connected) { DCHECK(!connected) << "KeyValueStore::GetSnapshotCallback was destroyed without " << "first either being run or its corresponding binding being closed. " << "It is an error to drop response callbacks which still correspond " << "to an open interface pipe."; } #endif void Run( const WTF::HashMap<WTF::String, WTF::String>& in_entries); uint64_t request_id_; bool is_sync_; std::unique_ptr<mojo::MessageReceiverWithStatus> responder_; DISALLOW_COPY_AND_ASSIGN(KeyValueStore_GetSnapshot_ProxyToResponder); }; class KeyValueStore_GetSnapshot_Response_Message : public mojo::internal::UnserializedMessageContext { public: static const mojo::internal::UnserializedMessageContext::Tag kMessageTag; explicit KeyValueStore_GetSnapshot_Response_Message( uint32_t message_flags , const WTF::HashMap<WTF::String, WTF::String>& param_entries ) : mojo::internal::UnserializedMessageContext( &kMessageTag, internal::kKeyValueStore_GetSnapshot_Name, message_flags) , param_entries_(std::move(param_entries)){} ~KeyValueStore_GetSnapshot_Response_Message() override = default; static mojo::Message Build( bool serialize, bool is_sync, const WTF::HashMap<WTF::String, WTF::String>& param_entries) { const uint32_t kFlags = mojo::Message::kFlagIsResponse | ((is_sync) ? mojo::Message::kFlagIsSync : 0); if (!serialize) { return mojo::Message(std::make_unique<KeyValueStore_GetSnapshot_Response_Message>( kFlags , std::move(param_entries) ), MOJO_CREATE_MESSAGE_FLAG_NONE); } DCHECK(serialize); mojo::Message message( internal::kKeyValueStore_GetSnapshot_Name, kFlags, 0, 0, nullptr); mojo::internal::MessageFragment< ::mojo::test::flush_async_unittest::mojom::internal::KeyValueStore_GetSnapshot_ResponseParams_Data> params( message); params.Allocate(); mojo::internal::MessageFragment< typename decltype(params->entries)::BaseType> entries_fragment(params.message()); const mojo::internal::ContainerValidateParams entries_validate_params( new mojo::internal::ContainerValidateParams(0, false, new mojo::internal::ContainerValidateParams(0, false, nullptr)), new mojo::internal::ContainerValidateParams(0, false, new mojo::internal::ContainerValidateParams(0, false, nullptr))); mojo::internal::Serialize<mojo::MapDataView<mojo::StringDataView, mojo::StringDataView>>( param_entries, entries_fragment, &entries_validate_params); params->entries.Set( entries_fragment.is_null() ? nullptr : entries_fragment.data()); MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( params->entries.is_null(), mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, "null entries in KeyValueStore.GetSnapshot response"); return message; } void Dispatch(mojo::Message* message, KeyValueStore::GetSnapshotCallback* callback) { if (message->receiver_connection_group()) { } std::move(*callback).Run( std::move(param_entries_)); } private: // mojo::internal::UnserializedMessageContext: void Serialize(mojo::Message& message) override { mojo::internal::MessageFragment< ::mojo::test::flush_async_unittest::mojom::internal::KeyValueStore_GetSnapshot_ResponseParams_Data> params( message); params.Allocate(); mojo::internal::MessageFragment< typename decltype(params->entries)::BaseType> entries_fragment(params.message()); const mojo::internal::ContainerValidateParams entries_validate_params( new mojo::internal::ContainerValidateParams(0, false, new mojo::internal::ContainerValidateParams(0, false, nullptr)), new mojo::internal::ContainerValidateParams(0, false, new mojo::internal::ContainerValidateParams(0, false, nullptr))); mojo::internal::Serialize<mojo::MapDataView<mojo::StringDataView, mojo::StringDataView>>( param_entries_, entries_fragment, &entries_validate_params); params->entries.Set( entries_fragment.is_null() ? nullptr : entries_fragment.data()); MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( params->entries.is_null(), mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, "null entries in KeyValueStore.GetSnapshot response"); } WTF::HashMap<WTF::String, WTF::String> param_entries_; DISALLOW_COPY_AND_ASSIGN(KeyValueStore_GetSnapshot_Response_Message); }; const mojo::internal::UnserializedMessageContext::Tag KeyValueStore_GetSnapshot_Response_Message::kMessageTag = {}; bool KeyValueStore_GetSnapshot_ForwardToCallback::Accept( mojo::Message* message) { #if BUILDFLAG(MOJO_TRACE_ENABLED) TRACE_EVENT1("mojom", "mojo::test::flush_async_unittest::mojom::KeyValueStore::GetSnapshotCallback", "message", message->name()); #endif if (!message->is_serialized()) { auto context = message->TakeUnserializedContext<KeyValueStore_GetSnapshot_Response_Message>(); if (!context) { // The Message was not of the expected type. It may be a valid message // which was build using a different variant of these bindings. Force // serialization before dispatch in this case. message->SerializeIfNecessary(); } else { if (!callback_.is_null()) context->Dispatch(message, &callback_); return true; } } DCHECK(message->is_serialized()); internal::KeyValueStore_GetSnapshot_ResponseParams_Data* params = reinterpret_cast< internal::KeyValueStore_GetSnapshot_ResponseParams_Data*>( message->mutable_payload()); bool success = true; WTF::HashMap<WTF::String, WTF::String> p_entries{}; KeyValueStore_GetSnapshot_ResponseParamsDataView input_data_view(params, message); if (success && !input_data_view.ReadEntries(&p_entries)) success = false; if (!success) { ReportValidationErrorForMessage( message, mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, KeyValueStore::Name_, 2, true); return false; } if (!callback_.is_null()) std::move(callback_).Run( std::move(p_entries)); return true; } void KeyValueStore_GetSnapshot_ProxyToResponder::Run( const WTF::HashMap<WTF::String, WTF::String>& in_entries) { #if BUILDFLAG(MOJO_TRACE_ENABLED) TRACE_EVENT_BEGIN1( "mojom", "(Impl)mojo::test::flush_async_unittest::mojom::KeyValueStore::GetSnapshotCallback", "async_response_parameters", [&](perfetto::TracedValue context){ auto dict = std::move(context).WriteDictionary(); perfetto::WriteIntoTracedValueWithFallback( dict.AddItem("entries"), in_entries, "<value of type const WTF::HashMap<WTF::String, WTF::String>&>"); }); #endif const bool kSerialize = responder_->PrefersSerializedMessages(); auto message = KeyValueStore_GetSnapshot_Response_Message::Build(kSerialize, is_sync_, std::move(in_entries)); #if BUILDFLAG(MOJO_TRACE_ENABLED) TRACE_EVENT_END1("mojom", "(Impl)mojo::test::flush_async_unittest::mojom::KeyValueStore::GetSnapshotCallback", "message", message.name()); #endif #if defined(ENABLE_IPC_FUZZER) message.set_interface_name(KeyValueStore::Name_); message.set_method_name("GetSnapshot"); #endif message.set_request_id(request_id_); ignore_result(responder_->Accept(&message)); // TODO(darin): Accept() returning false indicates a malformed message, and // that may be good reason to close the connection. However, we don't have a // way to do that from here. We should add a way. responder_ = nullptr; } // static bool KeyValueStoreStubDispatch::Accept( KeyValueStore* impl, mojo::Message* message) { switch (message->header()->name) { case internal::kKeyValueStore_SetClient_Name: { #if BUILDFLAG(MOJO_TRACE_ENABLED) TRACE_EVENT1( "mojom", "(Impl)mojo::test::flush_async_unittest::mojom::KeyValueStore::SetClient", "message", message->name()); #endif static constexpr uint32_t kMessageHash = base::MD5Hash32Constexpr( "(Impl)mojo::test::flush_async_unittest::mojom::KeyValueStore::SetClient"); base::TaskAnnotator::ScopedSetIpcHash scoped_ipc_hash(kMessageHash); if (!message->is_serialized()) { auto context = message->TakeUnserializedContext< KeyValueStoreProxy_SetClient_Message>(); if (!context) { // The Message was not of the expected type. It may be a valid message // which was serialized using a different variant of these bindings. // Force serialization before dispatch in this case. message->SerializeIfNecessary(); } else { context->Dispatch(message, impl); return true; } } DCHECK(message->is_serialized()); internal::KeyValueStore_SetClient_Params_Data* params = reinterpret_cast<internal::KeyValueStore_SetClient_Params_Data*>( message->mutable_payload()); bool success = true; ::mojo::PendingRemote<KeyValueStoreClient> p_client{}; KeyValueStore_SetClient_ParamsDataView input_data_view(params, message); if (success) { p_client = input_data_view.TakeClient<decltype(p_client)>(); } if (!success) { ReportValidationErrorForMessage( message, mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, KeyValueStore::Name_, 0, false); return false; } // A null |impl| means no implementation was bound. DCHECK(impl); impl->SetClient( std::move(p_client)); return true; } case internal::kKeyValueStore_BindWriter_Name: { #if BUILDFLAG(MOJO_TRACE_ENABLED) TRACE_EVENT1( "mojom", "(Impl)mojo::test::flush_async_unittest::mojom::KeyValueStore::BindWriter", "message", message->name()); #endif static constexpr uint32_t kMessageHash = base::MD5Hash32Constexpr( "(Impl)mojo::test::flush_async_unittest::mojom::KeyValueStore::BindWriter"); base::TaskAnnotator::ScopedSetIpcHash scoped_ipc_hash(kMessageHash); if (!message->is_serialized()) { auto context = message->TakeUnserializedContext< KeyValueStoreProxy_BindWriter_Message>(); if (!context) { // The Message was not of the expected type. It may be a valid message // which was serialized using a different variant of these bindings. // Force serialization before dispatch in this case. message->SerializeIfNecessary(); } else { context->Dispatch(message, impl); return true; } } DCHECK(message->is_serialized()); internal::KeyValueStore_BindWriter_Params_Data* params = reinterpret_cast<internal::KeyValueStore_BindWriter_Params_Data*>( message->mutable_payload()); bool success = true; ::mojo::PendingReceiver<Writer> p_receiver{}; KeyValueStore_BindWriter_ParamsDataView input_data_view(params, message); if (success) { p_receiver = input_data_view.TakeReceiver<decltype(p_receiver)>(); } if (!success) { ReportValidationErrorForMessage( message, mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, KeyValueStore::Name_, 1, false); return false; } // A null |impl| means no implementation was bound. DCHECK(impl); impl->BindWriter( std::move(p_receiver)); return true; } case internal::kKeyValueStore_GetSnapshot_Name: { break; } } return false; } // static bool KeyValueStoreStubDispatch::AcceptWithResponder( KeyValueStore* impl, mojo::Message* message, std::unique_ptr<mojo::MessageReceiverWithStatus> responder) { const bool message_is_sync = message->has_flag(mojo::Message::kFlagIsSync); const uint64_t request_id = message->request_id(); ALLOW_UNUSED_LOCAL(message_is_sync); ALLOW_UNUSED_LOCAL(request_id); switch (message->header()->name) { case internal::kKeyValueStore_SetClient_Name: { break; } case internal::kKeyValueStore_BindWriter_Name: { break; } case internal::kKeyValueStore_GetSnapshot_Name: { #if BUILDFLAG(MOJO_TRACE_ENABLED) TRACE_EVENT1( "mojom", "(Impl)mojo::test::flush_async_unittest::mojom::KeyValueStore::GetSnapshot", "message", message->name()); #endif static constexpr uint32_t kMessageHash = base::MD5Hash32Constexpr( "(Impl)mojo::test::flush_async_unittest::mojom::KeyValueStore::GetSnapshot"); base::TaskAnnotator::ScopedSetIpcHash scoped_ipc_hash(kMessageHash); if (!message->is_serialized()) { auto context = message->TakeUnserializedContext< KeyValueStoreProxy_GetSnapshot_Message>(); if (!context) { // The Message was not of the expected type. It may be a valid message // which was built using a different variant of these bindings. Force // serialization before dispatch in this case. message->SerializeIfNecessary(); } else { KeyValueStore::GetSnapshotCallback callback = KeyValueStore_GetSnapshot_ProxyToResponder::CreateCallback( message->request_id(), message_is_sync, &responder); context->Dispatch(message, impl, std::move(callback)); return true; } } internal::KeyValueStore_GetSnapshot_Params_Data* params = reinterpret_cast< internal::KeyValueStore_GetSnapshot_Params_Data*>( message->mutable_payload()); bool success = true; KeyValueStore_GetSnapshot_ParamsDataView input_data_view(params, message); if (!success) { ReportValidationErrorForMessage( message, mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, KeyValueStore::Name_, 2, false); return false; } KeyValueStore::GetSnapshotCallback callback = KeyValueStore_GetSnapshot_ProxyToResponder::CreateCallback( message->request_id(), message_is_sync, &responder); // A null |impl| means no implementation was bound. DCHECK(impl); impl->GetSnapshot(std::move(callback)); return true; } } return false; } static const std::pair<uint32_t, mojo::internal::GenericValidationInfo> kKeyValueStoreValidationInfo[] = { {internal::kKeyValueStore_SetClient_Name, {&internal::KeyValueStore_SetClient_Params_Data::Validate, nullptr /* no response */}}, {internal::kKeyValueStore_BindWriter_Name, {&internal::KeyValueStore_BindWriter_Params_Data::Validate, nullptr /* no response */}}, {internal::kKeyValueStore_GetSnapshot_Name, {&internal::KeyValueStore_GetSnapshot_Params_Data::Validate, &internal::KeyValueStore_GetSnapshot_ResponseParams_Data::Validate}}, }; bool KeyValueStoreRequestValidator::Accept(mojo::Message* message) { const char* name = ::mojo::test::flush_async_unittest::mojom::blink::KeyValueStore::Name_; return mojo::internal::ValidateRequestGeneric(message, name, kKeyValueStoreValidationInfo); } bool KeyValueStoreResponseValidator::Accept(mojo::Message* message) { const char* name = ::mojo::test::flush_async_unittest::mojom::blink::KeyValueStore::Name_; return mojo::internal::ValidateResponseGeneric(message, name, kKeyValueStoreValidationInfo); } const char Pinger::Name_[] = "mojo.test.flush_async_unittest.mojom.Pinger"; class Pinger_Ping_ForwardToCallback : public mojo::MessageReceiver { public: Pinger_Ping_ForwardToCallback( Pinger::PingCallback callback ) : callback_(std::move(callback)) { } bool Accept(mojo::Message* message) override; private: Pinger::PingCallback callback_; DISALLOW_COPY_AND_ASSIGN(Pinger_Ping_ForwardToCallback); }; PingerProxy::PingerProxy(mojo::MessageReceiverWithResponder* receiver) : receiver_(receiver) { } class PingerProxy_Ping_Message : public mojo::internal::UnserializedMessageContext { public: static const mojo::internal::UnserializedMessageContext::Tag kMessageTag; explicit PingerProxy_Ping_Message( uint32_t message_flags ) : mojo::internal::UnserializedMessageContext( &kMessageTag, internal::kPinger_Ping_Name, message_flags){} ~PingerProxy_Ping_Message() override = default; static mojo::Message Build( bool serialize, bool expects_response, bool is_sync) { const uint32_t kFlags = ((expects_response) ? mojo::Message::kFlagExpectsResponse : 0) | ((is_sync) ? mojo::Message::kFlagIsSync : 0); if (!serialize) { return mojo::Message(std::make_unique<PingerProxy_Ping_Message>( kFlags ), MOJO_CREATE_MESSAGE_FLAG_NONE); } DCHECK(serialize); mojo::Message message( internal::kPinger_Ping_Name, kFlags, 0, 0, nullptr); mojo::internal::MessageFragment< ::mojo::test::flush_async_unittest::mojom::internal::Pinger_Ping_Params_Data> params( message); params.Allocate(); return message; } void Dispatch( mojo::Message* message, Pinger* impl, Pinger::PingCallback callback) { if (message->receiver_connection_group()) { } impl->Ping(std::move(callback)); } private: // mojo::internal::UnserializedMessageContext: void Serialize(mojo::Message& message) override { mojo::internal::MessageFragment< ::mojo::test::flush_async_unittest::mojom::internal::Pinger_Ping_Params_Data> params( message); params.Allocate(); } DISALLOW_COPY_AND_ASSIGN(PingerProxy_Ping_Message); }; const mojo::internal::UnserializedMessageContext::Tag PingerProxy_Ping_Message::kMessageTag = {}; void PingerProxy::Ping( PingCallback callback) { #if BUILDFLAG(MOJO_TRACE_ENABLED) TRACE_EVENT0("mojom", "mojo::test::flush_async_unittest::mojom::Pinger::Ping"); #endif const bool kExpectsResponse = true; const bool kIsSync = false; const bool kSerialize = receiver_->PrefersSerializedMessages(); auto message = PingerProxy_Ping_Message::Build( kSerialize, kExpectsResponse, kIsSync); #if defined(ENABLE_IPC_FUZZER) message.set_interface_name(Pinger::Name_); message.set_method_name("Ping"); #endif std::unique_ptr<mojo::MessageReceiver> responder( new Pinger_Ping_ForwardToCallback( std::move(callback))); ignore_result(receiver_->AcceptWithResponder(&message, std::move(responder))); } class Pinger_Ping_ProxyToResponder { public: static Pinger::PingCallback CreateCallback( uint64_t request_id, bool is_sync, std::unique_ptr<mojo::MessageReceiverWithStatus>* responder) { std::unique_ptr<Pinger_Ping_ProxyToResponder> proxy( new Pinger_Ping_ProxyToResponder( request_id, is_sync, responder)); return base::BindOnce(&Pinger_Ping_ProxyToResponder::Run, std::move(proxy)); } ~Pinger_Ping_ProxyToResponder() { #if DCHECK_IS_ON() if (responder_) { // If we're being destroyed without being run, we want to ensure the // binding endpoint has been closed. This checks for that asynchronously. // We pass a bound generated callback to handle the response so that any // resulting DCHECK stack will have useful interface type information. responder_->IsConnectedAsync(base::BindOnce(&OnIsConnectedComplete)); } #endif // If the Callback was dropped then deleting the responder will close // the pipe so the calling application knows to stop waiting for a reply. responder_ = nullptr; } private: Pinger_Ping_ProxyToResponder( uint64_t request_id, bool is_sync, std::unique_ptr<mojo::MessageReceiverWithStatus>* responder) : request_id_(request_id), is_sync_(is_sync), responder_(std::move(*responder)) { } #if DCHECK_IS_ON() static void OnIsConnectedComplete(bool connected) { DCHECK(!connected) << "Pinger::PingCallback was destroyed without " << "first either being run or its corresponding binding being closed. " << "It is an error to drop response callbacks which still correspond " << "to an open interface pipe."; } #endif void Run( ); uint64_t request_id_; bool is_sync_; std::unique_ptr<mojo::MessageReceiverWithStatus> responder_; DISALLOW_COPY_AND_ASSIGN(Pinger_Ping_ProxyToResponder); }; class Pinger_Ping_Response_Message : public mojo::internal::UnserializedMessageContext { public: static const mojo::internal::UnserializedMessageContext::Tag kMessageTag; explicit Pinger_Ping_Response_Message( uint32_t message_flags ) : mojo::internal::UnserializedMessageContext( &kMessageTag, internal::kPinger_Ping_Name, message_flags){} ~Pinger_Ping_Response_Message() override = default; static mojo::Message Build( bool serialize, bool is_sync) { const uint32_t kFlags = mojo::Message::kFlagIsResponse | ((is_sync) ? mojo::Message::kFlagIsSync : 0); if (!serialize) { return mojo::Message(std::make_unique<Pinger_Ping_Response_Message>( kFlags ), MOJO_CREATE_MESSAGE_FLAG_NONE); } DCHECK(serialize); mojo::Message message( internal::kPinger_Ping_Name, kFlags, 0, 0, nullptr); mojo::internal::MessageFragment< ::mojo::test::flush_async_unittest::mojom::internal::Pinger_Ping_ResponseParams_Data> params( message); params.Allocate(); return message; } void Dispatch(mojo::Message* message, Pinger::PingCallback* callback) { if (message->receiver_connection_group()) { } std::move(*callback).Run(); } private: // mojo::internal::UnserializedMessageContext: void Serialize(mojo::Message& message) override { mojo::internal::MessageFragment< ::mojo::test::flush_async_unittest::mojom::internal::Pinger_Ping_ResponseParams_Data> params( message); params.Allocate(); } DISALLOW_COPY_AND_ASSIGN(Pinger_Ping_Response_Message); }; const mojo::internal::UnserializedMessageContext::Tag Pinger_Ping_Response_Message::kMessageTag = {}; bool Pinger_Ping_ForwardToCallback::Accept( mojo::Message* message) { #if BUILDFLAG(MOJO_TRACE_ENABLED) TRACE_EVENT1("mojom", "mojo::test::flush_async_unittest::mojom::Pinger::PingCallback", "message", message->name()); #endif if (!message->is_serialized()) { auto context = message->TakeUnserializedContext<Pinger_Ping_Response_Message>(); if (!context) { // The Message was not of the expected type. It may be a valid message // which was build using a different variant of these bindings. Force // serialization before dispatch in this case. message->SerializeIfNecessary(); } else { if (!callback_.is_null()) context->Dispatch(message, &callback_); return true; } } DCHECK(message->is_serialized()); internal::Pinger_Ping_ResponseParams_Data* params = reinterpret_cast< internal::Pinger_Ping_ResponseParams_Data*>( message->mutable_payload()); bool success = true; Pinger_Ping_ResponseParamsDataView input_data_view(params, message); if (!success) { ReportValidationErrorForMessage( message, mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, Pinger::Name_, 0, true); return false; } if (!callback_.is_null()) std::move(callback_).Run(); return true; } void Pinger_Ping_ProxyToResponder::Run( ) { #if BUILDFLAG(MOJO_TRACE_ENABLED) TRACE_EVENT_BEGIN0("mojom", "(Impl)mojo::test::flush_async_unittest::mojom::Pinger::PingCallback"); #endif const bool kSerialize = responder_->PrefersSerializedMessages(); auto message = Pinger_Ping_Response_Message::Build(kSerialize, is_sync_); #if BUILDFLAG(MOJO_TRACE_ENABLED) TRACE_EVENT_END1("mojom", "(Impl)mojo::test::flush_async_unittest::mojom::Pinger::PingCallback", "message", message.name()); #endif #if defined(ENABLE_IPC_FUZZER) message.set_interface_name(Pinger::Name_); message.set_method_name("Ping"); #endif message.set_request_id(request_id_); ignore_result(responder_->Accept(&message)); // TODO(darin): Accept() returning false indicates a malformed message, and // that may be good reason to close the connection. However, we don't have a // way to do that from here. We should add a way. responder_ = nullptr; } // static bool PingerStubDispatch::Accept( Pinger* impl, mojo::Message* message) { switch (message->header()->name) { case internal::kPinger_Ping_Name: { break; } } return false; } // static bool PingerStubDispatch::AcceptWithResponder( Pinger* impl, mojo::Message* message, std::unique_ptr<mojo::MessageReceiverWithStatus> responder) { const bool message_is_sync = message->has_flag(mojo::Message::kFlagIsSync); const uint64_t request_id = message->request_id(); ALLOW_UNUSED_LOCAL(message_is_sync); ALLOW_UNUSED_LOCAL(request_id); switch (message->header()->name) { case internal::kPinger_Ping_Name: { #if BUILDFLAG(MOJO_TRACE_ENABLED) TRACE_EVENT1( "mojom", "(Impl)mojo::test::flush_async_unittest::mojom::Pinger::Ping", "message", message->name()); #endif static constexpr uint32_t kMessageHash = base::MD5Hash32Constexpr( "(Impl)mojo::test::flush_async_unittest::mojom::Pinger::Ping"); base::TaskAnnotator::ScopedSetIpcHash scoped_ipc_hash(kMessageHash); if (!message->is_serialized()) { auto context = message->TakeUnserializedContext< PingerProxy_Ping_Message>(); if (!context) { // The Message was not of the expected type. It may be a valid message // which was built using a different variant of these bindings. Force // serialization before dispatch in this case. message->SerializeIfNecessary(); } else { Pinger::PingCallback callback = Pinger_Ping_ProxyToResponder::CreateCallback( message->request_id(), message_is_sync, &responder); context->Dispatch(message, impl, std::move(callback)); return true; } } internal::Pinger_Ping_Params_Data* params = reinterpret_cast< internal::Pinger_Ping_Params_Data*>( message->mutable_payload()); bool success = true; Pinger_Ping_ParamsDataView input_data_view(params, message); if (!success) { ReportValidationErrorForMessage( message, mojo::internal::VALIDATION_ERROR_DESERIALIZATION_FAILED, Pinger::Name_, 0, false); return false; } Pinger::PingCallback callback = Pinger_Ping_ProxyToResponder::CreateCallback( message->request_id(), message_is_sync, &responder); // A null |impl| means no implementation was bound. DCHECK(impl); impl->Ping(std::move(callback)); return true; } } return false; } static const std::pair<uint32_t, mojo::internal::GenericValidationInfo> kPingerValidationInfo[] = { {internal::kPinger_Ping_Name, {&internal::Pinger_Ping_Params_Data::Validate, &internal::Pinger_Ping_ResponseParams_Data::Validate}}, }; bool PingerRequestValidator::Accept(mojo::Message* message) { const char* name = ::mojo::test::flush_async_unittest::mojom::blink::Pinger::Name_; return mojo::internal::ValidateRequestGeneric(message, name, kPingerValidationInfo); } bool PingerResponseValidator::Accept(mojo::Message* message) { const char* name = ::mojo::test::flush_async_unittest::mojom::blink::Pinger::Name_; return mojo::internal::ValidateResponseGeneric(message, name, kPingerValidationInfo); } } // namespace blink } // namespace mojom } // namespace flush_async_unittest } // namespace test } // namespace mojo namespace mojo { } // namespace mojo #if defined(__clang__) #pragma clang diagnostic pop #endif
// Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "libzerocoin/Params.h" #include "chainparams.h" #include "random.h" #include "util.h" #include "utilstrencodings.h" #include <assert.h> #include <boost/assign/list_of.hpp> using namespace std; using namespace boost::assign; struct SeedSpec6 { uint8_t addr[16]; uint16_t port; }; #include "chainparamsseeds.h" #include "net.h" /** * Main network */ //! Convert the pnSeeds6 array into usable address objects. static void convertSeed6(std::vector<CAddress>& vSeedsOut, const SeedSpec6* data, unsigned int count) { // It'll only connect to one or two seed nodes because once it connects, // it'll get a pile of addresses with newer timestamps. // Seed nodes are given a random 'last seen time' of between one and two // weeks ago. const int64_t nOneWeek = 7 * 24 * 60 * 60; for (unsigned int i = 0; i < count; i++) { struct in6_addr ip; memcpy(&ip, data[i].addr, sizeof(ip)); CAddress addr(CService(ip, data[i].port)); addr.nTime = GetTime() - GetRand(nOneWeek) - nOneWeek; vSeedsOut.push_back(addr); } } // What makes a good checkpoint block? // + Is surrounded by blocks with reasonable timestamps // (no blocks before with a timestamp after, none after with // timestamp before) // + Contains no strange transactions static Checkpoints::MapCheckpoints mapCheckpoints = boost::assign::map_list_of(0, uint256("0x001")); static const Checkpoints::CCheckpointData data = { &mapCheckpoints, 1543593600, // * UNIX timestamp of last checkpoint block 0, // * total number of transactions between genesis and last checkpoint // (the tx=... number in the SetBestChain debug.log lines) 500 // * estimated number of transactions per day after checkpoint }; static Checkpoints::MapCheckpoints mapCheckpointsTestnet = boost::assign::map_list_of(0, uint256("0x001")); static const Checkpoints::CCheckpointData dataTestnet = { &mapCheckpointsTestnet, 1543593601, 0, 250}; static Checkpoints::MapCheckpoints mapCheckpointsRegtest = boost::assign::map_list_of(0, uint256("0x001")); static const Checkpoints::CCheckpointData dataRegtest = { &mapCheckpointsRegtest, 1543593602, 0, 100}; libzerocoin::ZerocoinParams* CChainParams::Zerocoin_Params() const { assert(this); static CBigNum bnTrustedModulus(zerocoinModulus); static libzerocoin::ZerocoinParams ZCParams = libzerocoin::ZerocoinParams(bnTrustedModulus); return &ZCParams; } class CMainParams : public CChainParams { public: CMainParams() { networkID = CBaseChainParams::MAIN; strNetworkID = "main"; /** * The message start string is designed to be unlikely to occur in normal data. * The characters are rarely used upper ASCII, not valid as UTF-8, and produce * a large 4-byte int at any alignment. */ pchMessageStart[0] = 0x90; pchMessageStart[1] = 0xc4; pchMessageStart[2] = 0xfd; pchMessageStart[3] = 0xe9; vAlertPubKey = ParseHex("047c8d3eaf61275a344f2272d6c1dbe036906b917f39920ea223bbcc76664b56fd8a5e21fe62c7b906e1c60e2cf697025da3c58d013a5e55394860d81799e2a0d5"); nDefaultPort = 45022; bnProofOfWorkLimit = ~uint256(0) >> 20; // TICO starting difficulty is 1 / 2^12 nSubsidyHalvingInterval = 210000; nMaxReorganizationDepth = 100; nEnforceBlockUpgradeMajority = 750; nRejectBlockOutdatedMajority = 950; nToCheckBlockUpgradeMajority = 1000; nMinerThreads = 0; nTargetTimespan = 60 * 1; // TICO: 1 day nTargetSpacing = 60 * 1; // TICO: 1 minute nMaturity = 1; nMasternodeCountDrift = 20; nMaxMoneyOut = 28000000 * COIN; nMasternodeHoldCoins = 5000 * COIN; /** Height or Time Based Activations **/ nLastPOWBlock = 61; nModifierUpdateBlock = 615800; nZerocoinStartHeight = 61; nZerocoinStartTime = 1543593600; // October 17, 2017 4:30:00 AM nBlockEnforceSerialRange = 895400; //Enforce serial range starting this block nBlockRecalculateAccumulators = 908000; //Trigger a recalculation of accumulators nBlockFirstFraudulent = 891737; //First block that bad serials emerged nBlockLastGoodCheckpoint = 891730; //Last valid accumulator checkpoint nBlockEnforceInvalidUTXO = 902850; //Start enforcing the invalid UTXO's /** * Build the genesis block. Note that the output of the genesis coinbase cannot * be spent as it did not originally exist in the database. * * CBlock(hash=00000ffd590b14, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=e0028e, nTime=1390095618, nBits=1e0ffff0, nNonce=28917698, vtx=1) * CTransaction(hash=e0028e, ver=1, vin.size=1, vout.size=1, nLockTime=0) * CTxIn(COutPoint(000000, -1), coinbase 04ffff001d01044c5957697265642030392f4a616e2f3230313420546865204772616e64204578706572696d656e7420476f6573204c6976653a204f76657273746f636b2e636f6d204973204e6f7720416363657074696e6720426974636f696e73) * CTxOut(nValue=50.00000000, scriptPubKey=0xA9037BAC7050C479B121CF) * vMerkleTree: e0028e */ const char* pszTimestamp = "11/11/2018 - HOTEL BOOKING IN YOUR HANDS - Ticoin"; CMutableTransaction txNew; txNew.vin.resize(1); txNew.vout.resize(1); txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp)); txNew.vout[0].nValue = 50 * COIN; txNew.vout[0].scriptPubKey = CScript() << ParseHex("04ed7f57be5be9fd21f8fbdaee11104c46318bd2e12c24cd722adf4c8720c0799db54903c24d46491b3b83a4fb41836db81cbd506c663e30c32d632ef2ec1fedd8") << OP_CHECKSIG; genesis.vtx.push_back(txNew); genesis.hashPrevBlock = 0; genesis.hashMerkleRoot = genesis.BuildMerkleTree(); genesis.nTime = 1543593600; genesis.nBits = 0x1e0ffff0; genesis.nVersion = 1; genesis.nNonce = 2994456; hashGenesisBlock = genesis.GetHash(); assert(hashGenesisBlock == uint256("0x000002c9aa0bbe5fa38167272c28572d8fe503865b7307b24a9aab51a1c05fd2")); assert(genesis.hashMerkleRoot == uint256("0x4ac304201084cd922a9a5554053f1c0856bfedc75623114ef39b8cf8ecb65391")); base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, 30); base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, 13); base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1, 212); base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x02)(0x2D)(0x25)(0x33).convert_to_container<std::vector<unsigned char> >(); base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x02)(0x21)(0x31)(0x2B).convert_to_container<std::vector<unsigned char> >(); // BIP44 coin type is from https://github.com/satoshilabs/slips/blob/master/slip-0044.md base58Prefixes[EXT_COIN_TYPE] = boost::assign::list_of(0x80)(0x00)(0x00)(0x77).convert_to_container<std::vector<unsigned char> >(); vFixedSeeds.clear(); vSeeds.clear(); convertSeed6(vFixedSeeds, pnSeed6_main, ARRAYLEN(pnSeed6_main)); vSeeds.push_back(CDNSSeedData("seeder", "seeder.ticoin.cc")); fRequireRPCPassword = true; fMiningRequiresPeers = true; fAllowMinDifficultyBlocks = false; fDefaultConsistencyChecks = false; fRequireStandard = true; fMineBlocksOnDemand = false; fSkipProofOfWorkCheck = false; fTestnetToBeDeprecatedFieldRPC = false; fHeadersFirstSyncingActive = false; nPoolMaxTransactions = 20; strSporkKey = "04c3d3bd7dc03b841e303d7338fa7d138e8983b0dde69c8965e9a6a54093f1be28b42f0941786a5da411993b0488e40b6f9b091e203911c4ce5fbbd679fc632586"; strObfuscationPoolDummyAddress = "D12q1119j6nNrnzCsg4aY6bHMLsT9nUhEw"; nStartMasternodePayments = 1543593600; //Wed, 25 Jun 2014 20:36:16 GMT /** Zerocoin */ zerocoinModulus = "25195908475657893494027183240048398571429282126204032027777137836043662020707595556264018525880784" "4069182906412495150821892985591491761845028084891200728449926873928072877767359714183472702618963750149718246911" "6507761337985909570009733045974880842840179742910064245869181719511874612151517265463228221686998754918242243363" "7259085141865462043576798423387184774447920739934236584823824281198163815010674810451660377306056201619676256133" "8441436038339044149526344321901146575444541784240209246165157233507787077498171257724679629263863563732899121548" "31438167899885040445364023527381951378636564391212010397122822120720357"; nMaxZerocoinSpendsPerTransaction = 7; // Assume about 20kb each nMinZerocoinMintFee = 1 * CENT; //high fee required for zerocoin mints nMintRequiredConfirmations = 1; //the maximum amount of confirmations until accumulated in 19 nRequiredAccumulation = 2; nDefaultSecurityLevel = 100; //full security level for accumulators nZerocoinHeaderVersion = 4; //Block headers must be this version once zerocoin is active nBudget_Fee_Confirmations = 6; // Number of confirmations for the finalization fee } const Checkpoints::CCheckpointData& Checkpoints() const { return data; } }; static CMainParams mainParams;/**/ // /** // * Testnet (v3) // */ // class CTestNetParams : public CMainParams // { // public: // CTestNetParams() // { // networkID = CBaseChainParams::TESTNET; // strNetworkID = "test"; // pchMessageStart[0] = 0x45; // pchMessageStart[1] = 0x76; // pchMessageStart[2] = 0x65; // pchMessageStart[3] = 0xba; // vAlertPubKey = ParseHex("000010e83b2703ccf322f7dbd62dd5855ac7c10bd055814ce121ba32607d573b8810c02c0582aed05b4deb9c4b77b26d92428c61256cd42774babea0a073b2ed0c9"); // nDefaultPort = 39034; // nEnforceBlockUpgradeMajority = 51; // nRejectBlockOutdatedMajority = 75; // nToCheckBlockUpgradeMajority = 100; // nMinerThreads = 0; // nTargetTimespan = 1 * 60; // TICO: 1 day // nTargetSpacing = 1 * 60; // TICO: 1 minute // nLastPOWBlock = 200; // nMaturity = 15; // nMasternodeCountDrift = 4; // nModifierUpdateBlock = 51197; //approx Mon, 17 Apr 2017 04:00:00 GMT // nMaxMoneyOut = 43199500 * COIN; // nZerocoinStartHeight = 201576; // nZerocoinStartTime = 1501776000; // nBlockEnforceSerialRange = 1; //Enforce serial range starting this block // nBlockRecalculateAccumulators = 9908000; //Trigger a recalculation of accumulators // nBlockFirstFraudulent = 9891737; //First block that bad serials emerged // nBlockLastGoodCheckpoint = 9891730; //Last valid accumulator checkpoint // nBlockEnforceInvalidUTXO = 9902850; //Start enforcing the invalid UTXO's // // //! Modify the testnet genesis block so the timestamp is valid for a later start. // genesis.nTime = 1454124731; // genesis.nNonce = 2402015; // // hashGenesisBlock = genesis.GetHash(); // assert(hashGenesisBlock == uint256("0x0000041e482b9b9691d98eefb48473405c0b8ec31b76df3797c74a78680ef818")); // // vFixedSeeds.clear(); // vSeeds.clear(); // vSeeds.push_back(CDNSSeedData("fuzzbawls.pw", "ticoin-testnet.seed.fuzzbawls.pw")); // vSeeds.push_back(CDNSSeedData("fuzzbawls.pw", "ticoin-testnet.seed2.fuzzbawls.pw")); // vSeeds.push_back(CDNSSeedData("s3v3nh4cks.ddns.net", "s3v3nh4cks.ddns.net")); // vSeeds.push_back(CDNSSeedData("88.198.192.110", "88.198.192.110")); // // base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, 139); // Testnet ticoin addresses start with 'x' or 'y' // base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, 19); // Testnet ticoin script addresses start with '8' or '9' // base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1, 239); // Testnet private keys start with '9' or 'c' (Bitcoin defaults) // // Testnet ticoin BIP32 pubkeys start with 'DRKV' // base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x3a)(0x80)(0x61)(0xa0).convert_to_container<std::vector<unsigned char> >(); // // Testnet ticoin BIP32 prvkeys start with 'DRKP' // base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x3a)(0x80)(0x58)(0x37).convert_to_container<std::vector<unsigned char> >(); // // Testnet ticoin BIP44 coin type is '1' (All coin's testnet default) // base58Prefixes[EXT_COIN_TYPE] = boost::assign::list_of(0x80)(0x00)(0x00)(0x01).convert_to_container<std::vector<unsigned char> >(); // // convertSeed6(vFixedSeeds, pnSeed6_test, ARRAYLEN(pnSeed6_test)); // // fRequireRPCPassword = true; // fMiningRequiresPeers = true; // fAllowMinDifficultyBlocks = true; // fDefaultConsistencyChecks = false; // fRequireStandard = false; // fMineBlocksOnDemand = false; // fTestnetToBeDeprecatedFieldRPC = true; // // nPoolMaxTransactions = 2; // strSporkKey = "04348C2F50F90267E64FACC65BFDC9D0EB147D090872FB97ABAE92E9A36E6CA60983E28E741F8E7277B11A7479B626AC115BA31463AC48178A5075C5A9319D4A38"; // strObfuscationPoolDummyAddress = "y57cqfGRkekRyDRNeJiLtYVEbvhXrNbmox"; // nStartMasternodePayments = 1420837558; //Fri, 09 Jan 2015 21:05:58 GMT // nBudget_Fee_Confirmations = 3; // Number of confirmations for the finalization fee. We have to make this very short // // here because we only have a 8 block finalization window on testnet // } // const Checkpoints::CCheckpointData& Checkpoints() const // { // return dataTestnet; // } // }; // // static CTestNetParams testNetParams; // // /** // * Regression test // */ // class CRegTestParams : public CTestNetParams // { // public: // CRegTestParams() // { // networkID = CBaseChainParams::REGTEST; // strNetworkID = "regtest"; // strNetworkID = "regtest"; // pchMessageStart[0] = 0xa1; // pchMessageStart[1] = 0xcf; // pchMessageStart[2] = 0x7e; // pchMessageStart[3] = 0xac; // nSubsidyHalvingInterval = 150; // nEnforceBlockUpgradeMajority = 750; // nRejectBlockOutdatedMajority = 950; // nToCheckBlockUpgradeMajority = 1000; // nMinerThreads = 1; // nTargetTimespan = 24 * 60 * 60; // Ticoin: 1 day // nTargetSpacing = 1 * 60; // Ticoin: 1 minutes // bnProofOfWorkLimit = ~uint256(0) >> 1; // genesis.nTime = 1454124731; // genesis.nBits = 0x207fffff; // genesis.nNonce = 12345; // // hashGenesisBlock = genesis.GetHash(); // nDefaultPort = 39036; // assert(hashGenesisBlock == uint256("0x4f023a2120d9127b21bbad01724fdb79b519f593f2a85b60d3d79160ec5f29df")); // // vFixedSeeds.clear(); //! Testnet mode doesn't have any fixed seeds. // vSeeds.clear(); //! Testnet mode doesn't have any DNS seeds. // // fRequireRPCPassword = false; // fMiningRequiresPeers = false; // fAllowMinDifficultyBlocks = true; // fDefaultConsistencyChecks = true; // fRequireStandard = false; // fMineBlocksOnDemand = true; // fTestnetToBeDeprecatedFieldRPC = false; // } // const Checkpoints::CCheckpointData& Checkpoints() const // { // return dataRegtest; // } // }; // // static CRegTestParams regTestParams; /** * Unit test */ class CUnitTestParams : public CMainParams, public CModifiableParams { public: CUnitTestParams() { networkID = CBaseChainParams::UNITTEST; strNetworkID = "unittest"; nDefaultPort = 39038; vFixedSeeds.clear(); //! Unit test mode doesn't have any fixed seeds. vSeeds.clear(); //! Unit test mode doesn't have any DNS seeds. fRequireRPCPassword = false; fMiningRequiresPeers = false; fDefaultConsistencyChecks = true; fAllowMinDifficultyBlocks = false; fMineBlocksOnDemand = true; } const Checkpoints::CCheckpointData& Checkpoints() const { // UnitTest share the same checkpoints as MAIN return data; } //! Published setters to allow changing values in unit test cases virtual void setSubsidyHalvingInterval(int anSubsidyHalvingInterval) { nSubsidyHalvingInterval = anSubsidyHalvingInterval; } virtual void setEnforceBlockUpgradeMajority(int anEnforceBlockUpgradeMajority) { nEnforceBlockUpgradeMajority = anEnforceBlockUpgradeMajority; } virtual void setRejectBlockOutdatedMajority(int anRejectBlockOutdatedMajority) { nRejectBlockOutdatedMajority = anRejectBlockOutdatedMajority; } virtual void setToCheckBlockUpgradeMajority(int anToCheckBlockUpgradeMajority) { nToCheckBlockUpgradeMajority = anToCheckBlockUpgradeMajority; } virtual void setDefaultConsistencyChecks(bool afDefaultConsistencyChecks) { fDefaultConsistencyChecks = afDefaultConsistencyChecks; } virtual void setAllowMinDifficultyBlocks(bool afAllowMinDifficultyBlocks) { fAllowMinDifficultyBlocks = afAllowMinDifficultyBlocks; } virtual void setSkipProofOfWorkCheck(bool afSkipProofOfWorkCheck) { fSkipProofOfWorkCheck = afSkipProofOfWorkCheck; } }; static CUnitTestParams unitTestParams; static CChainParams* pCurrentParams = 0; CModifiableParams* ModifiableParams() { assert(pCurrentParams); assert(pCurrentParams == &unitTestParams); return (CModifiableParams*)&unitTestParams; } const CChainParams& Params() { assert(pCurrentParams); return *pCurrentParams; } CChainParams& Params(CBaseChainParams::Network network) { switch (network) { case CBaseChainParams::MAIN: return mainParams; // case CBaseChainParams::TESTNET: // return testNetParams; // case CBaseChainParams::REGTEST: // return regTestParams; case CBaseChainParams::UNITTEST: return unitTestParams; default: assert(false && "Unimplemented network"); return mainParams; } } void SelectParams(CBaseChainParams::Network network) { SelectBaseParams(network); pCurrentParams = &Params(network); } bool SelectParamsFromCommandLine() { CBaseChainParams::Network network = NetworkIdFromCommandLine(); if (network == CBaseChainParams::MAX_NETWORK_TYPES) return false; SelectParams(network); return true; }
#include "mull/Parallelization/Tasks/FunctionFilterTask.h" #include "mull/Filters/FunctionFilter.h" #include "mull/Parallelization/Progress.h" using namespace mull; FunctionFilterTask::FunctionFilterTask(FunctionFilter &filter) : filter(filter) {} void FunctionFilterTask::operator()(iterator begin, iterator end, Out &storage, progress_counter &counter) { for (auto it = begin; it != end; ++it, counter.increment()) { FunctionUnderTest &functionUnderTest = *it; assert(functionUnderTest.getFunction()); if (!filter.shouldSkip(functionUnderTest.getFunction())) { storage.push_back(std::move(functionUnderTest)); } } }
/*------------------------------------------------------------------------- * Vulkan Conformance Tests * ------------------------ * * Copyright (c) 2015 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * *//*! * \file * \brief Api Feature Query tests *//*--------------------------------------------------------------------*/ #include "vktApiFeatureInfo.hpp" #include "vktTestCaseUtil.hpp" #include "vktTestGroupUtil.hpp" #include "vkPlatform.hpp" #include "vkStrUtil.hpp" #include "vkRef.hpp" #include "vkDeviceUtil.hpp" #include "vkQueryUtil.hpp" #include "vkImageUtil.hpp" #include "vkApiVersion.hpp" #include "tcuTestLog.hpp" #include "tcuFormatUtil.hpp" #include "tcuTextureUtil.hpp" #include "tcuResultCollector.hpp" #include "deUniquePtr.hpp" #include "deString.h" #include "deStringUtil.hpp" #include "deSTLUtil.hpp" #include "deMemory.h" #include "deMath.h" #include <vector> #include <set> #include <string> namespace vkt { namespace api { namespace { using namespace vk; using std::vector; using std::set; using std::string; using tcu::TestLog; using tcu::ScopedLogSection; enum { GUARD_SIZE = 0x20, //!< Number of bytes to check GUARD_VALUE = 0xcd, //!< Data pattern }; static const VkDeviceSize MINIMUM_REQUIRED_IMAGE_RESOURCE_SIZE = (1LLU<<31); //!< Minimum value for VkImageFormatProperties::maxResourceSize (2GiB) enum LimitFormat { LIMIT_FORMAT_SIGNED_INT, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_FORMAT_FLOAT, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_FORMAT_BITMASK, LIMIT_FORMAT_LAST }; enum LimitType { LIMIT_TYPE_MIN, LIMIT_TYPE_MAX, LIMIT_TYPE_NONE, LIMIT_TYPE_LAST }; #define LIMIT(_X_) DE_OFFSET_OF(VkPhysicalDeviceLimits, _X_), (const char*)(#_X_) #define FEATURE(_X_) DE_OFFSET_OF(VkPhysicalDeviceFeatures, _X_) inline bool isExtensionSupported (const vector<string>& extensionStrings, const string& extensionName) { return de::contains(extensionStrings.begin(), extensionStrings.end(), extensionName); } bool validateFeatureLimits(VkPhysicalDeviceProperties* properties, VkPhysicalDeviceFeatures* features, TestLog& log) { bool limitsOk = true; VkPhysicalDeviceLimits* limits = &properties->limits; deUint32 shaderStages = 3; if (features->tessellationShader) { shaderStages += 2; } if (features->geometryShader) { shaderStages++; } struct FeatureLimitTable { deUint32 offset; const char* name; deUint32 uintVal; //!< Format is UNSIGNED_INT deInt32 intVal; //!< Format is SIGNED_INT deUint64 deviceSizeVal; //!< Format is DEVICE_SIZE float floatVal; //!< Format is FLOAT LimitFormat format; LimitType type; deInt32 unsuppTableNdx; } featureLimitTable[] = //!< Based on 1.0.28 Vulkan spec { { LIMIT(maxImageDimension1D), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxImageDimension2D), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxImageDimension3D), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxImageDimensionCube), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxImageArrayLayers), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxTexelBufferElements), 65536, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxUniformBufferRange), 16384, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxStorageBufferRange), 0, 0, 0, 0, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 }, { LIMIT(maxPushConstantsSize), 128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxMemoryAllocationCount), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxSamplerAllocationCount), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE , -1 }, { LIMIT(bufferImageGranularity), 0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 }, { LIMIT(bufferImageGranularity), 0, 0, 131072, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 }, { LIMIT(sparseAddressSpaceSize), 0, 0, 2UL*1024*1024*1024, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxBoundDescriptorSets), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxPerStageDescriptorSamplers), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxPerStageDescriptorUniformBuffers), 12, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxPerStageDescriptorStorageBuffers), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxPerStageDescriptorSampledImages), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxPerStageDescriptorStorageImages), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxPerStageDescriptorInputAttachments), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxPerStageResources), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE , -1 }, { LIMIT(maxDescriptorSetSamplers), shaderStages * 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxDescriptorSetUniformBuffers), shaderStages * 12, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxDescriptorSetUniformBuffersDynamic), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxDescriptorSetStorageBuffers), shaderStages * 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxDescriptorSetStorageBuffersDynamic), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxDescriptorSetSampledImages), shaderStages * 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxDescriptorSetStorageImages), shaderStages * 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxDescriptorSetInputAttachments), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE , -1 }, { LIMIT(maxVertexInputAttributes), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxVertexInputBindings), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxVertexInputAttributeOffset), 2047, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxVertexInputBindingStride), 2048, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxVertexOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxTessellationGenerationLevel), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxTessellationPatchSize), 32, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxTessellationControlPerVertexInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxTessellationControlPerVertexOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxTessellationControlPerPatchOutputComponents), 120, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxTessellationControlTotalOutputComponents), 2048, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxTessellationEvaluationInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxTessellationEvaluationOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxGeometryShaderInvocations), 32, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxGeometryInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxGeometryOutputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxGeometryOutputVertices), 256, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxGeometryTotalOutputComponents), 1024, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxFragmentInputComponents), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxFragmentOutputAttachments), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxFragmentDualSrcAttachments), 1, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxFragmentCombinedOutputResources), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxComputeSharedMemorySize), 16384, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxComputeWorkGroupCount[0]), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxComputeWorkGroupCount[1]), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxComputeWorkGroupCount[2]), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxComputeWorkGroupInvocations), 128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxComputeWorkGroupSize[0]), 128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxComputeWorkGroupSize[1]), 128, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxComputeWorkGroupSize[2]), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(subPixelPrecisionBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(subTexelPrecisionBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(mipmapPrecisionBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxDrawIndexedIndexValue), (deUint32)~0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxDrawIndirectCount), 65535, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxSamplerLodBias), 0, 0, 0, 2.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxSamplerAnisotropy), 0, 0, 0, 16.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxViewports), 16, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxViewportDimensions[0]), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(maxViewportDimensions[1]), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN , -1 }, { LIMIT(viewportBoundsRange[0]), 0, 0, 0, -8192.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 }, { LIMIT(viewportBoundsRange[1]), 0, 0, 0, 8191.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 }, { LIMIT(viewportSubPixelBits), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(minMemoryMapAlignment), 64, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(minTexelBufferOffsetAlignment), 0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 }, { LIMIT(minTexelBufferOffsetAlignment), 0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 }, { LIMIT(minUniformBufferOffsetAlignment), 0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 }, { LIMIT(minUniformBufferOffsetAlignment), 0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 }, { LIMIT(minStorageBufferOffsetAlignment), 0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 }, { LIMIT(minStorageBufferOffsetAlignment), 0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 }, { LIMIT(minTexelOffset), 0, -8, 0, 0.0f, LIMIT_FORMAT_SIGNED_INT, LIMIT_TYPE_MAX, -1 }, { LIMIT(maxTexelOffset), 7, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(minTexelGatherOffset), 0, -8, 0, 0.0f, LIMIT_FORMAT_SIGNED_INT, LIMIT_TYPE_MAX, -1 }, { LIMIT(maxTexelGatherOffset), 7, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(minInterpolationOffset), 0, 0, 0, -0.5f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 }, { LIMIT(maxInterpolationOffset), 0, 0, 0, 0.5f - (1.0f/deFloatPow(2.0f, (float)limits->subPixelInterpolationOffsetBits)), LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 }, { LIMIT(subPixelInterpolationOffsetBits), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxFramebufferWidth), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxFramebufferHeight), 4096, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxFramebufferLayers), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(framebufferColorSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 }, { LIMIT(framebufferDepthSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 }, { LIMIT(framebufferStencilSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 }, { LIMIT(framebufferNoAttachmentsSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxColorAttachments), 4, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(sampledImageColorSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 }, { LIMIT(sampledImageIntegerSampleCounts), VK_SAMPLE_COUNT_1_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 }, { LIMIT(sampledImageDepthSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 }, { LIMIT(sampledImageStencilSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 }, { LIMIT(storageImageSampleCounts), VK_SAMPLE_COUNT_1_BIT|VK_SAMPLE_COUNT_4_BIT, 0, 0, 0.0f, LIMIT_FORMAT_BITMASK, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxSampleMaskWords), 1, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(timestampComputeAndGraphics), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 }, { LIMIT(timestampPeriod), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 }, { LIMIT(maxClipDistances), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxCullDistances), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(maxCombinedClipAndCullDistances), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_MIN, -1 }, { LIMIT(discreteQueuePriorities), 8, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 }, { LIMIT(pointSizeRange[0]), 0, 0, 0, 0.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 }, { LIMIT(pointSizeRange[0]), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 }, { LIMIT(pointSizeRange[1]), 0, 0, 0, 64.0f - limits->pointSizeGranularity , LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 }, { LIMIT(lineWidthRange[0]), 0, 0, 0, 0.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 }, { LIMIT(lineWidthRange[0]), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 }, { LIMIT(lineWidthRange[1]), 0, 0, 0, 8.0f - limits->lineWidthGranularity, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MIN, -1 }, { LIMIT(pointSizeGranularity), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 }, { LIMIT(lineWidthGranularity), 0, 0, 0, 1.0f, LIMIT_FORMAT_FLOAT, LIMIT_TYPE_MAX, -1 }, { LIMIT(strictLines), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 }, { LIMIT(standardSampleLocations), 0, 0, 0, 0.0f, LIMIT_FORMAT_UNSIGNED_INT, LIMIT_TYPE_NONE, -1 }, { LIMIT(optimalBufferCopyOffsetAlignment), 0, 0, 0, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_NONE, -1 }, { LIMIT(optimalBufferCopyRowPitchAlignment), 0, 0, 0, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_NONE, -1 }, { LIMIT(nonCoherentAtomSize), 0, 0, 1, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MIN, -1 }, { LIMIT(nonCoherentAtomSize), 0, 0, 256, 0.0f, LIMIT_FORMAT_DEVICE_SIZE, LIMIT_TYPE_MAX, -1 }, }; const struct UnsupportedFeatureLimitTable { deUint32 limitOffset; const char* name; deUint32 featureOffset; deUint32 uintVal; //!< Format is UNSIGNED_INT deInt32 intVal; //!< Format is SIGNED_INT deUint64 deviceSizeVal; //!< Format is DEVICE_SIZE float floatVal; //!< Format is FLOAT } unsupportedFeatureTable[] = { { LIMIT(sparseAddressSpaceSize), FEATURE(sparseBinding), 0, 0, 0, 0.0f }, { LIMIT(maxTessellationGenerationLevel), FEATURE(tessellationShader), 0, 0, 0, 0.0f }, { LIMIT(maxTessellationPatchSize), FEATURE(tessellationShader), 0, 0, 0, 0.0f }, { LIMIT(maxTessellationControlPerVertexInputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f }, { LIMIT(maxTessellationControlPerVertexOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f }, { LIMIT(maxTessellationControlPerPatchOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f }, { LIMIT(maxTessellationControlTotalOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f }, { LIMIT(maxTessellationEvaluationInputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f }, { LIMIT(maxTessellationEvaluationOutputComponents), FEATURE(tessellationShader), 0, 0, 0, 0.0f }, { LIMIT(maxGeometryShaderInvocations), FEATURE(geometryShader), 0, 0, 0, 0.0f }, { LIMIT(maxGeometryInputComponents), FEATURE(geometryShader), 0, 0, 0, 0.0f }, { LIMIT(maxGeometryOutputComponents), FEATURE(geometryShader), 0, 0, 0, 0.0f }, { LIMIT(maxGeometryOutputVertices), FEATURE(geometryShader), 0, 0, 0, 0.0f }, { LIMIT(maxGeometryTotalOutputComponents), FEATURE(geometryShader), 0, 0, 0, 0.0f }, { LIMIT(maxFragmentDualSrcAttachments), FEATURE(dualSrcBlend), 0, 0, 0, 0.0f }, { LIMIT(maxDrawIndexedIndexValue), FEATURE(fullDrawIndexUint32), (1<<24)-1, 0, 0, 0.0f }, { LIMIT(maxDrawIndirectCount), FEATURE(multiDrawIndirect), 1, 0, 0, 0.0f }, { LIMIT(maxSamplerAnisotropy), FEATURE(samplerAnisotropy), 1, 0, 0, 0.0f }, { LIMIT(maxViewports), FEATURE(multiViewport), 1, 0, 0, 0.0f }, { LIMIT(minTexelGatherOffset), FEATURE(shaderImageGatherExtended), 0, 0, 0, 0.0f }, { LIMIT(maxTexelGatherOffset), FEATURE(shaderImageGatherExtended), 0, 0, 0, 0.0f }, { LIMIT(minInterpolationOffset), FEATURE(sampleRateShading), 0, 0, 0, 0.0f }, { LIMIT(maxInterpolationOffset), FEATURE(sampleRateShading), 0, 0, 0, 0.0f }, { LIMIT(subPixelInterpolationOffsetBits), FEATURE(sampleRateShading), 0, 0, 0, 0.0f }, { LIMIT(storageImageSampleCounts), FEATURE(shaderStorageImageMultisample), VK_SAMPLE_COUNT_1_BIT, 0, 0, 0.0f }, { LIMIT(maxClipDistances), FEATURE(shaderClipDistance), 0, 0, 0, 0.0f }, { LIMIT(maxCullDistances), FEATURE(shaderClipDistance), 0, 0, 0, 0.0f }, { LIMIT(maxCombinedClipAndCullDistances), FEATURE(shaderClipDistance), 0, 0, 0, 0.0f }, { LIMIT(pointSizeRange[0]), FEATURE(largePoints), 0, 0, 0, 1.0f }, { LIMIT(pointSizeRange[1]), FEATURE(largePoints), 0, 0, 0, 1.0f }, { LIMIT(lineWidthRange[0]), FEATURE(wideLines), 0, 0, 0, 1.0f }, { LIMIT(lineWidthRange[1]), FEATURE(wideLines), 0, 0, 0, 1.0f }, { LIMIT(pointSizeGranularity), FEATURE(largePoints), 0, 0, 0, 0.0f }, { LIMIT(lineWidthGranularity), FEATURE(wideLines), 0, 0, 0, 0.0f } }; log << TestLog::Message << *limits << TestLog::EndMessage; //!< First build a map from limit to unsupported table index for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++) { for (deUint32 unsuppNdx = 0; unsuppNdx < DE_LENGTH_OF_ARRAY(unsupportedFeatureTable); unsuppNdx++) { if (unsupportedFeatureTable[unsuppNdx].limitOffset == featureLimitTable[ndx].offset) { featureLimitTable[ndx].unsuppTableNdx = unsuppNdx; break; } } } for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(featureLimitTable); ndx++) { switch (featureLimitTable[ndx].format) { case LIMIT_FORMAT_UNSIGNED_INT: { deUint32 limitToCheck = featureLimitTable[ndx].uintVal; if (featureLimitTable[ndx].unsuppTableNdx != -1) { if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE) limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].uintVal; } if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN) { if (*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck) { log << TestLog::Message << "limit Validation failed " << featureLimitTable[ndx].name << " not valid-limit type MIN - actual is " << *((deUint32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage; limitsOk = false; } } else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX) { if (*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck) { log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name << " not valid-limit type MAX - actual is " << *((deUint32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage; limitsOk = false; } } break; } case LIMIT_FORMAT_FLOAT: { float limitToCheck = featureLimitTable[ndx].floatVal; if (featureLimitTable[ndx].unsuppTableNdx != -1) { if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE) limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].floatVal; } if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN) { if (*((float*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck) { log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name << " not valid-limit type MIN - actual is " << *((float*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage; limitsOk = false; } } else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX) { if (*((float*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck) { log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name << " not valid-limit type MAX actual is " << *((float*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage; limitsOk = false; } } break; } case LIMIT_FORMAT_SIGNED_INT: { deInt32 limitToCheck = featureLimitTable[ndx].intVal; if (featureLimitTable[ndx].unsuppTableNdx != -1) { if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE) limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].intVal; } if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN) { if (*((deInt32*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck) { log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name << " not valid-limit type MIN actual is " << *((deInt32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage; limitsOk = false; } } else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX) { if (*((deInt32*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck) { log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name << " not valid-limit type MAX actual is " << *((deInt32*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage; limitsOk = false; } } break; } case LIMIT_FORMAT_DEVICE_SIZE: { deUint64 limitToCheck = featureLimitTable[ndx].deviceSizeVal; if (featureLimitTable[ndx].unsuppTableNdx != -1) { if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE) limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].deviceSizeVal; } if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN) { if (*((deUint64*)((deUint8*)limits+featureLimitTable[ndx].offset)) < limitToCheck) { log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name << " not valid-limit type MIN actual is " << *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage; limitsOk = false; } } else if (featureLimitTable[ndx].type == LIMIT_TYPE_MAX) { if (*((deUint64*)((deUint8*)limits+featureLimitTable[ndx].offset)) > limitToCheck) { log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name << " not valid-limit type MAX actual is " << *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage; limitsOk = false; } } break; } case LIMIT_FORMAT_BITMASK: { deUint32 limitToCheck = featureLimitTable[ndx].uintVal; if (featureLimitTable[ndx].unsuppTableNdx != -1) { if (*((VkBool32*)((deUint8*)features+unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].featureOffset)) == VK_FALSE) limitToCheck = unsupportedFeatureTable[featureLimitTable[ndx].unsuppTableNdx].uintVal; } if (featureLimitTable[ndx].type == LIMIT_TYPE_MIN) { if ((*((deUint32*)((deUint8*)limits+featureLimitTable[ndx].offset)) & limitToCheck) != limitToCheck) { log << TestLog::Message << "limit validation failed, " << featureLimitTable[ndx].name << " not valid-limit type bitmask actual is " << *((deUint64*)((deUint8*)limits + featureLimitTable[ndx].offset)) << TestLog::EndMessage; limitsOk = false; } } break; } default: DE_ASSERT(0); limitsOk = false; } } for (deUint32 ndx = 0; ndx < DE_LENGTH_OF_ARRAY(limits->maxViewportDimensions); ndx++) { if (limits->maxImageDimension2D > limits->maxViewportDimensions[ndx]) { log << TestLog::Message << "limit validation failed, maxImageDimension2D of " << limits->maxImageDimension2D << "is larger than maxViewportDimension[" << ndx << "] of " << limits->maxViewportDimensions[ndx] << TestLog::EndMessage; limitsOk = false; } } if (limits->viewportBoundsRange[0] > float(-2 * limits->maxViewportDimensions[0])) { log << TestLog::Message << "limit validation failed, viewPortBoundsRange[0] of " << limits->viewportBoundsRange[0] << "is larger than -2*maxViewportDimension[0] of " << -2*limits->maxViewportDimensions[0] << TestLog::EndMessage; limitsOk = false; } if (limits->viewportBoundsRange[1] < float(2 * limits->maxViewportDimensions[1] - 1)) { log << TestLog::Message << "limit validation failed, viewportBoundsRange[1] of " << limits->viewportBoundsRange[1] << "is less than 2*maxViewportDimension[1] of " << 2*limits->maxViewportDimensions[1] << TestLog::EndMessage; limitsOk = false; } return limitsOk; } template<typename T> class CheckIncompleteResult { public: virtual ~CheckIncompleteResult (void) {} virtual void getResult (Context& context, T* data) = 0; void operator() (Context& context, tcu::ResultCollector& results, const std::size_t expectedCompleteSize) { if (expectedCompleteSize == 0) return; vector<T> outputData (expectedCompleteSize); const deUint32 usedSize = static_cast<deUint32>(expectedCompleteSize / 3); ValidateQueryBits::fillBits(outputData.begin(), outputData.end()); // unused entries should have this pattern intact m_count = usedSize; m_result = VK_SUCCESS; getResult(context, &outputData[0]); // update m_count and m_result if (m_count != usedSize || m_result != VK_INCOMPLETE || !ValidateQueryBits::checkBits(outputData.begin() + m_count, outputData.end())) results.fail("Query didn't return VK_INCOMPLETE"); } protected: deUint32 m_count; VkResult m_result; }; struct CheckEnumeratePhysicalDevicesIncompleteResult : public CheckIncompleteResult<VkPhysicalDevice> { void getResult (Context& context, VkPhysicalDevice* data) { m_result = context.getInstanceInterface().enumeratePhysicalDevices(context.getInstance(), &m_count, data); } }; struct CheckEnumerateInstanceLayerPropertiesIncompleteResult : public CheckIncompleteResult<VkLayerProperties> { void getResult (Context& context, VkLayerProperties* data) { m_result = context.getPlatformInterface().enumerateInstanceLayerProperties(&m_count, data); } }; struct CheckEnumerateDeviceLayerPropertiesIncompleteResult : public CheckIncompleteResult<VkLayerProperties> { void getResult (Context& context, VkLayerProperties* data) { m_result = context.getInstanceInterface().enumerateDeviceLayerProperties(context.getPhysicalDevice(), &m_count, data); } }; struct CheckEnumerateInstanceExtensionPropertiesIncompleteResult : public CheckIncompleteResult<VkExtensionProperties> { CheckEnumerateInstanceExtensionPropertiesIncompleteResult (std::string layerName = std::string()) : m_layerName(layerName) {} void getResult (Context& context, VkExtensionProperties* data) { const char* pLayerName = (m_layerName.length() != 0 ? m_layerName.c_str() : DE_NULL); m_result = context.getPlatformInterface().enumerateInstanceExtensionProperties(pLayerName, &m_count, data); } private: const std::string m_layerName; }; struct CheckEnumerateDeviceExtensionPropertiesIncompleteResult : public CheckIncompleteResult<VkExtensionProperties> { CheckEnumerateDeviceExtensionPropertiesIncompleteResult (std::string layerName = std::string()) : m_layerName(layerName) {} void getResult (Context& context, VkExtensionProperties* data) { const char* pLayerName = (m_layerName.length() != 0 ? m_layerName.c_str() : DE_NULL); m_result = context.getInstanceInterface().enumerateDeviceExtensionProperties(context.getPhysicalDevice(), pLayerName, &m_count, data); } private: const std::string m_layerName; }; tcu::TestStatus enumeratePhysicalDevices (Context& context) { TestLog& log = context.getTestContext().getLog(); tcu::ResultCollector results (log); const vector<VkPhysicalDevice> devices = enumeratePhysicalDevices(context.getInstanceInterface(), context.getInstance()); log << TestLog::Integer("NumDevices", "Number of devices", "", QP_KEY_TAG_NONE, deInt64(devices.size())); for (size_t ndx = 0; ndx < devices.size(); ndx++) log << TestLog::Message << ndx << ": " << devices[ndx] << TestLog::EndMessage; CheckEnumeratePhysicalDevicesIncompleteResult()(context, results, devices.size()); return tcu::TestStatus(results.getResult(), results.getMessage()); } template<typename T> void collectDuplicates (set<T>& duplicates, const vector<T>& values) { set<T> seen; for (size_t ndx = 0; ndx < values.size(); ndx++) { const T& value = values[ndx]; if (!seen.insert(value).second) duplicates.insert(value); } } void checkDuplicates (tcu::ResultCollector& results, const char* what, const vector<string>& values) { set<string> duplicates; collectDuplicates(duplicates, values); for (set<string>::const_iterator iter = duplicates.begin(); iter != duplicates.end(); ++iter) { std::ostringstream msg; msg << "Duplicate " << what << ": " << *iter; results.fail(msg.str()); } } void checkDuplicateExtensions (tcu::ResultCollector& results, const vector<string>& extensions) { checkDuplicates(results, "extension", extensions); } void checkDuplicateLayers (tcu::ResultCollector& results, const vector<string>& layers) { checkDuplicates(results, "layer", layers); } void checkKhrExtensions (tcu::ResultCollector& results, const vector<string>& extensions, const int numAllowedKhrExtensions, const char* const* allowedKhrExtensions) { const set<string> allowedExtSet (allowedKhrExtensions, allowedKhrExtensions+numAllowedKhrExtensions); for (vector<string>::const_iterator extIter = extensions.begin(); extIter != extensions.end(); ++extIter) { // Only Khronos-controlled extensions are checked if (de::beginsWith(*extIter, "VK_KHR_") && !de::contains(allowedExtSet, *extIter)) { results.fail("Unknown KHR extension " + *extIter); } } } void checkInstanceExtensions (tcu::ResultCollector& results, const vector<string>& extensions) { static const char* s_allowedInstanceKhrExtensions[] = { "VK_KHR_surface", "VK_KHR_display", "VK_KHR_android_surface", "VK_KHR_mir_surface", "VK_KHR_wayland_surface", "VK_KHR_win32_surface", "VK_KHR_xcb_surface", "VK_KHR_xlib_surface", "VK_KHR_get_physical_device_properties2", "VK_KHR_get_surface_capabilities2", "VK_KHR_external_memory_capabilities", "VK_KHR_external_semaphore_capabilities", "VK_KHR_external_fence_capabilities", }; checkKhrExtensions(results, extensions, DE_LENGTH_OF_ARRAY(s_allowedInstanceKhrExtensions), s_allowedInstanceKhrExtensions); checkDuplicateExtensions(results, extensions); } void checkDeviceExtensions (tcu::ResultCollector& results, const vector<string>& extensions) { static const char* s_allowedDeviceKhrExtensions[] = { "VK_KHR_swapchain", "VK_KHR_display_swapchain", "VK_KHR_sampler_mirror_clamp_to_edge", "VK_KHR_shader_draw_parameters", "VK_KHR_maintenance1", "VK_KHR_push_descriptor", "VK_KHR_descriptor_update_template", "VK_KHR_incremental_present", "VK_KHR_shared_presentable_image", "VK_KHR_storage_buffer_storage_class", "VK_KHR_16bit_storage", "VK_KHR_get_memory_requirements2", "VK_KHR_external_memory", "VK_KHR_external_memory_fd", "VK_KHR_external_memory_win32", "VK_KHR_external_semaphore", "VK_KHR_external_semaphore_fd", "VK_KHR_external_semaphore_win32", "VK_KHR_external_fence", "VK_KHR_external_fence_fd", "VK_KHR_external_fence_win32", "VK_KHR_win32_keyed_mutex", "VK_KHR_dedicated_allocation", "VK_KHR_variable_pointers", "VK_KHR_relaxed_block_layout", "VK_KHR_bind_memory2", "VK_KHR_maintenance2", "VK_KHR_image_format_list", "VK_KHR_sampler_ycbcr_conversion", }; checkKhrExtensions(results, extensions, DE_LENGTH_OF_ARRAY(s_allowedDeviceKhrExtensions), s_allowedDeviceKhrExtensions); checkDuplicateExtensions(results, extensions); } tcu::TestStatus enumerateInstanceLayers (Context& context) { TestLog& log = context.getTestContext().getLog(); tcu::ResultCollector results (log); const vector<VkLayerProperties> properties = enumerateInstanceLayerProperties(context.getPlatformInterface()); vector<string> layerNames; for (size_t ndx = 0; ndx < properties.size(); ndx++) { log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage; layerNames.push_back(properties[ndx].layerName); } checkDuplicateLayers(results, layerNames); CheckEnumerateInstanceLayerPropertiesIncompleteResult()(context, results, layerNames.size()); return tcu::TestStatus(results.getResult(), results.getMessage()); } tcu::TestStatus enumerateInstanceExtensions (Context& context) { TestLog& log = context.getTestContext().getLog(); tcu::ResultCollector results (log); { const ScopedLogSection section (log, "Global", "Global Extensions"); const vector<VkExtensionProperties> properties = enumerateInstanceExtensionProperties(context.getPlatformInterface(), DE_NULL); vector<string> extensionNames; for (size_t ndx = 0; ndx < properties.size(); ndx++) { log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage; extensionNames.push_back(properties[ndx].extensionName); } checkInstanceExtensions(results, extensionNames); CheckEnumerateInstanceExtensionPropertiesIncompleteResult()(context, results, properties.size()); } { const vector<VkLayerProperties> layers = enumerateInstanceLayerProperties(context.getPlatformInterface()); for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer) { const ScopedLogSection section (log, layer->layerName, string("Layer: ") + layer->layerName); const vector<VkExtensionProperties> properties = enumerateInstanceExtensionProperties(context.getPlatformInterface(), layer->layerName); vector<string> extensionNames; for (size_t extNdx = 0; extNdx < properties.size(); extNdx++) { log << TestLog::Message << extNdx << ": " << properties[extNdx] << TestLog::EndMessage; extensionNames.push_back(properties[extNdx].extensionName); } checkInstanceExtensions(results, extensionNames); CheckEnumerateInstanceExtensionPropertiesIncompleteResult(layer->layerName)(context, results, properties.size()); } } return tcu::TestStatus(results.getResult(), results.getMessage()); } tcu::TestStatus enumerateDeviceLayers (Context& context) { TestLog& log = context.getTestContext().getLog(); tcu::ResultCollector results (log); const vector<VkLayerProperties> properties = enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice()); vector<string> layerNames; for (size_t ndx = 0; ndx < properties.size(); ndx++) { log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage; layerNames.push_back(properties[ndx].layerName); } checkDuplicateLayers(results, layerNames); CheckEnumerateDeviceLayerPropertiesIncompleteResult()(context, results, layerNames.size()); return tcu::TestStatus(results.getResult(), results.getMessage()); } tcu::TestStatus enumerateDeviceExtensions (Context& context) { TestLog& log = context.getTestContext().getLog(); tcu::ResultCollector results (log); { const ScopedLogSection section (log, "Global", "Global Extensions"); const vector<VkExtensionProperties> properties = enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), DE_NULL); vector<string> extensionNames; for (size_t ndx = 0; ndx < properties.size(); ndx++) { log << TestLog::Message << ndx << ": " << properties[ndx] << TestLog::EndMessage; extensionNames.push_back(properties[ndx].extensionName); } checkDeviceExtensions(results, extensionNames); CheckEnumerateDeviceExtensionPropertiesIncompleteResult()(context, results, properties.size()); } { const vector<VkLayerProperties> layers = enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice()); for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer) { const ScopedLogSection section (log, layer->layerName, string("Layer: ") + layer->layerName); const vector<VkExtensionProperties> properties = enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), layer->layerName); vector<string> extensionNames; for (size_t extNdx = 0; extNdx < properties.size(); extNdx++) { log << TestLog::Message << extNdx << ": " << properties[extNdx] << TestLog::EndMessage; extensionNames.push_back(properties[extNdx].extensionName); } checkDeviceExtensions(results, extensionNames); CheckEnumerateDeviceExtensionPropertiesIncompleteResult(layer->layerName)(context, results, properties.size()); } } return tcu::TestStatus(results.getResult(), results.getMessage()); } #define VK_SIZE_OF(STRUCT, MEMBER) (sizeof(((STRUCT*)0)->MEMBER)) #define OFFSET_TABLE_ENTRY(STRUCT, MEMBER) { (size_t)DE_OFFSET_OF(STRUCT, MEMBER), VK_SIZE_OF(STRUCT, MEMBER) } tcu::TestStatus deviceFeatures (Context& context) { using namespace ValidateQueryBits; TestLog& log = context.getTestContext().getLog(); VkPhysicalDeviceFeatures* features; deUint8 buffer[sizeof(VkPhysicalDeviceFeatures) + GUARD_SIZE]; const QueryMemberTableEntry featureOffsetTable[] = { OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, robustBufferAccess), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fullDrawIndexUint32), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, imageCubeArray), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, independentBlend), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, geometryShader), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, tessellationShader), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sampleRateShading), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, dualSrcBlend), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, logicOp), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, multiDrawIndirect), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, drawIndirectFirstInstance), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthClamp), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthBiasClamp), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fillModeNonSolid), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, depthBounds), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, wideLines), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, largePoints), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, alphaToOne), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, multiViewport), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, samplerAnisotropy), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionETC2), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionASTC_LDR), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, textureCompressionBC), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, occlusionQueryPrecise), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, pipelineStatisticsQuery), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, vertexPipelineStoresAndAtomics), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, fragmentStoresAndAtomics), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderTessellationAndGeometryPointSize), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderImageGatherExtended), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageExtendedFormats), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageMultisample), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageReadWithoutFormat), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageWriteWithoutFormat), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderUniformBufferArrayDynamicIndexing), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderSampledImageArrayDynamicIndexing), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageBufferArrayDynamicIndexing), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderStorageImageArrayDynamicIndexing), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderClipDistance), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderCullDistance), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderFloat64), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderInt64), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderInt16), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderResourceResidency), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, shaderResourceMinLod), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseBinding), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyBuffer), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyImage2D), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyImage3D), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency2Samples), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency4Samples), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency8Samples), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidency16Samples), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, sparseResidencyAliased), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, variableMultisampleRate), OFFSET_TABLE_ENTRY(VkPhysicalDeviceFeatures, inheritedQueries), { 0, 0 } }; deMemset(buffer, GUARD_VALUE, sizeof(buffer)); features = reinterpret_cast<VkPhysicalDeviceFeatures*>(buffer); context.getInstanceInterface().getPhysicalDeviceFeatures(context.getPhysicalDevice(), features); log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage << TestLog::Message << *features << TestLog::EndMessage; // Requirements and dependencies { if (!features->robustBufferAccess) return tcu::TestStatus::fail("robustBufferAccess is not supported"); // multiViewport requires MultiViewport (SPIR-V capability) support, which depends on Geometry if (features->multiViewport && !features->geometryShader) return tcu::TestStatus::fail("multiViewport is supported but geometryShader is not"); } for (int ndx = 0; ndx < GUARD_SIZE; ndx++) { if (buffer[ndx + sizeof(VkPhysicalDeviceFeatures)] != GUARD_VALUE) { log << TestLog::Message << "deviceFeatures - Guard offset " << ndx << " not valid" << TestLog::EndMessage; return tcu::TestStatus::fail("deviceFeatures buffer overflow"); } } if (!validateInitComplete(context.getPhysicalDevice(), &InstanceInterface::getPhysicalDeviceFeatures, context.getInstanceInterface(), featureOffsetTable)) { log << TestLog::Message << "deviceFeatures - VkPhysicalDeviceFeatures not completely initialized" << TestLog::EndMessage; return tcu::TestStatus::fail("deviceFeatures incomplete initialization"); } return tcu::TestStatus::pass("Query succeeded"); } static const ValidateQueryBits::QueryMemberTableEntry s_physicalDevicePropertiesOffsetTable[] = { OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, apiVersion), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, driverVersion), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, vendorID), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, deviceID), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, deviceType), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, pipelineCacheUUID), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension1D), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension2D), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimension3D), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageDimensionCube), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxImageArrayLayers), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelBufferElements), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxUniformBufferRange), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxStorageBufferRange), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPushConstantsSize), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxMemoryAllocationCount), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerAllocationCount), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.bufferImageGranularity), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sparseAddressSpaceSize), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxBoundDescriptorSets), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorSamplers), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorUniformBuffers), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorStorageBuffers), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorSampledImages), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorStorageImages), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageDescriptorInputAttachments), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxPerStageResources), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetSamplers), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetUniformBuffers), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetUniformBuffersDynamic), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageBuffers), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageBuffersDynamic), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetSampledImages), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetStorageImages), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDescriptorSetInputAttachments), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputAttributes), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputBindings), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputAttributeOffset), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexInputBindingStride), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxVertexOutputComponents), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationGenerationLevel), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationPatchSize), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerVertexInputComponents), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerVertexOutputComponents), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlPerPatchOutputComponents), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationControlTotalOutputComponents), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationEvaluationInputComponents), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTessellationEvaluationOutputComponents), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryShaderInvocations), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryInputComponents), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryOutputComponents), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryOutputVertices), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxGeometryTotalOutputComponents), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentInputComponents), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentOutputAttachments), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentDualSrcAttachments), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFragmentCombinedOutputResources), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeSharedMemorySize), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupCount[3]), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupInvocations), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxComputeWorkGroupSize[3]), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subPixelPrecisionBits), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subTexelPrecisionBits), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.mipmapPrecisionBits), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDrawIndexedIndexValue), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxDrawIndirectCount), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerLodBias), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSamplerAnisotropy), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxViewports), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxViewportDimensions[2]), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.viewportBoundsRange[2]), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.viewportSubPixelBits), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minMemoryMapAlignment), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelBufferOffsetAlignment), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minUniformBufferOffsetAlignment), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minStorageBufferOffsetAlignment), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelOffset), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelOffset), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minTexelGatherOffset), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxTexelGatherOffset), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.minInterpolationOffset), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxInterpolationOffset), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.subPixelInterpolationOffsetBits), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferWidth), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferHeight), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxFramebufferLayers), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferColorSampleCounts), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferDepthSampleCounts), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferStencilSampleCounts), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.framebufferNoAttachmentsSampleCounts), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxColorAttachments), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageColorSampleCounts), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageIntegerSampleCounts), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageDepthSampleCounts), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.sampledImageStencilSampleCounts), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.storageImageSampleCounts), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxSampleMaskWords), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.timestampComputeAndGraphics), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.timestampPeriod), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxClipDistances), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxCullDistances), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.maxCombinedClipAndCullDistances), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.discreteQueuePriorities), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.pointSizeRange[2]), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.lineWidthRange[2]), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.pointSizeGranularity), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.lineWidthGranularity), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.strictLines), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.standardSampleLocations), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.optimalBufferCopyOffsetAlignment), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.optimalBufferCopyRowPitchAlignment), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, limits.nonCoherentAtomSize), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard2DBlockShape), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard2DMultisampleBlockShape), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyStandard3DBlockShape), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyAlignedMipSize), OFFSET_TABLE_ENTRY(VkPhysicalDeviceProperties, sparseProperties.residencyNonResidentStrict), { 0, 0 } }; tcu::TestStatus deviceProperties (Context& context) { using namespace ValidateQueryBits; TestLog& log = context.getTestContext().getLog(); VkPhysicalDeviceProperties* props; VkPhysicalDeviceFeatures features; deUint8 buffer[sizeof(VkPhysicalDeviceProperties) + GUARD_SIZE]; props = reinterpret_cast<VkPhysicalDeviceProperties*>(buffer); deMemset(props, GUARD_VALUE, sizeof(buffer)); context.getInstanceInterface().getPhysicalDeviceProperties(context.getPhysicalDevice(), props); context.getInstanceInterface().getPhysicalDeviceFeatures(context.getPhysicalDevice(), &features); log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage << TestLog::Message << *props << TestLog::EndMessage; if (!validateFeatureLimits(props, &features, log)) return tcu::TestStatus::fail("deviceProperties - feature limits failed"); for (int ndx = 0; ndx < GUARD_SIZE; ndx++) { if (buffer[ndx + sizeof(VkPhysicalDeviceProperties)] != GUARD_VALUE) { log << TestLog::Message << "deviceProperties - Guard offset " << ndx << " not valid" << TestLog::EndMessage; return tcu::TestStatus::fail("deviceProperties buffer overflow"); } } if (!validateInitComplete(context.getPhysicalDevice(), &InstanceInterface::getPhysicalDeviceProperties, context.getInstanceInterface(), s_physicalDevicePropertiesOffsetTable)) { log << TestLog::Message << "deviceProperties - VkPhysicalDeviceProperties not completely initialized" << TestLog::EndMessage; return tcu::TestStatus::fail("deviceProperties incomplete initialization"); } // Check if deviceName string is properly terminated. if (deStrnlen(props->deviceName, VK_MAX_PHYSICAL_DEVICE_NAME_SIZE) == VK_MAX_PHYSICAL_DEVICE_NAME_SIZE) { log << TestLog::Message << "deviceProperties - VkPhysicalDeviceProperties deviceName not properly initialized" << TestLog::EndMessage; return tcu::TestStatus::fail("deviceProperties incomplete initialization"); } { const ApiVersion deviceVersion = unpackVersion(props->apiVersion); const ApiVersion deqpVersion = unpackVersion(VK_API_VERSION); if (deviceVersion.majorNum != deqpVersion.majorNum) { log << TestLog::Message << "deviceProperties - API Major Version " << deviceVersion.majorNum << " is not valid" << TestLog::EndMessage; return tcu::TestStatus::fail("deviceProperties apiVersion not valid"); } if (deviceVersion.minorNum > deqpVersion.minorNum) { log << TestLog::Message << "deviceProperties - API Minor Version " << deviceVersion.minorNum << " is not valid for this version of dEQP" << TestLog::EndMessage; return tcu::TestStatus::fail("deviceProperties apiVersion not valid"); } } return tcu::TestStatus::pass("DeviceProperites query succeeded"); } tcu::TestStatus deviceQueueFamilyProperties (Context& context) { TestLog& log = context.getTestContext().getLog(); const vector<VkQueueFamilyProperties> queueProperties = getPhysicalDeviceQueueFamilyProperties(context.getInstanceInterface(), context.getPhysicalDevice()); log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage; for (size_t queueNdx = 0; queueNdx < queueProperties.size(); queueNdx++) log << TestLog::Message << queueNdx << ": " << queueProperties[queueNdx] << TestLog::EndMessage; return tcu::TestStatus::pass("Querying queue properties succeeded"); } tcu::TestStatus deviceMemoryProperties (Context& context) { TestLog& log = context.getTestContext().getLog(); VkPhysicalDeviceMemoryProperties* memProps; deUint8 buffer[sizeof(VkPhysicalDeviceMemoryProperties) + GUARD_SIZE]; memProps = reinterpret_cast<VkPhysicalDeviceMemoryProperties*>(buffer); deMemset(buffer, GUARD_VALUE, sizeof(buffer)); context.getInstanceInterface().getPhysicalDeviceMemoryProperties(context.getPhysicalDevice(), memProps); log << TestLog::Message << "device = " << context.getPhysicalDevice() << TestLog::EndMessage << TestLog::Message << *memProps << TestLog::EndMessage; for (deInt32 ndx = 0; ndx < GUARD_SIZE; ndx++) { if (buffer[ndx + sizeof(VkPhysicalDeviceMemoryProperties)] != GUARD_VALUE) { log << TestLog::Message << "deviceMemoryProperties - Guard offset " << ndx << " not valid" << TestLog::EndMessage; return tcu::TestStatus::fail("deviceMemoryProperties buffer overflow"); } } if (memProps->memoryHeapCount >= VK_MAX_MEMORY_HEAPS) { log << TestLog::Message << "deviceMemoryProperties - HeapCount larger than " << (deUint32)VK_MAX_MEMORY_HEAPS << TestLog::EndMessage; return tcu::TestStatus::fail("deviceMemoryProperties HeapCount too large"); } if (memProps->memoryHeapCount == 1) { if ((memProps->memoryHeaps[0].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) == 0) { log << TestLog::Message << "deviceMemoryProperties - Single heap is not marked DEVICE_LOCAL" << TestLog::EndMessage; return tcu::TestStatus::fail("deviceMemoryProperties invalid HeapFlags"); } } const VkMemoryPropertyFlags validPropertyFlags[] = { 0, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT }; const VkMemoryPropertyFlags requiredPropertyFlags[] = { VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT }; bool requiredFlagsFound[DE_LENGTH_OF_ARRAY(requiredPropertyFlags)]; std::fill(DE_ARRAY_BEGIN(requiredFlagsFound), DE_ARRAY_END(requiredFlagsFound), false); for (deUint32 memoryNdx = 0; memoryNdx < memProps->memoryTypeCount; memoryNdx++) { bool validPropTypeFound = false; if (memProps->memoryTypes[memoryNdx].heapIndex >= memProps->memoryHeapCount) { log << TestLog::Message << "deviceMemoryProperties - heapIndex " << memProps->memoryTypes[memoryNdx].heapIndex << " larger than heapCount" << TestLog::EndMessage; return tcu::TestStatus::fail("deviceMemoryProperties - invalid heapIndex"); } const VkMemoryPropertyFlags bitsToCheck = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|VK_MEMORY_PROPERTY_HOST_COHERENT_BIT|VK_MEMORY_PROPERTY_HOST_CACHED_BIT|VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT; for (const VkMemoryPropertyFlags* requiredFlagsIterator = DE_ARRAY_BEGIN(requiredPropertyFlags); requiredFlagsIterator != DE_ARRAY_END(requiredPropertyFlags); requiredFlagsIterator++) if ((memProps->memoryTypes[memoryNdx].propertyFlags & *requiredFlagsIterator) == *requiredFlagsIterator) requiredFlagsFound[requiredFlagsIterator - DE_ARRAY_BEGIN(requiredPropertyFlags)] = true; if (de::contains(DE_ARRAY_BEGIN(validPropertyFlags), DE_ARRAY_END(validPropertyFlags), memProps->memoryTypes[memoryNdx].propertyFlags & bitsToCheck)) validPropTypeFound = true; if (!validPropTypeFound) { log << TestLog::Message << "deviceMemoryProperties - propertyFlags " << memProps->memoryTypes[memoryNdx].propertyFlags << " not valid" << TestLog::EndMessage; return tcu::TestStatus::fail("deviceMemoryProperties propertyFlags not valid"); } if (memProps->memoryTypes[memoryNdx].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) { if ((memProps->memoryHeaps[memProps->memoryTypes[memoryNdx].heapIndex].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) == 0) { log << TestLog::Message << "deviceMemoryProperties - DEVICE_LOCAL memory type references heap which is not DEVICE_LOCAL" << TestLog::EndMessage; return tcu::TestStatus::fail("deviceMemoryProperties inconsistent memoryType and HeapFlags"); } } else { if (memProps->memoryHeaps[memProps->memoryTypes[memoryNdx].heapIndex].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) { log << TestLog::Message << "deviceMemoryProperties - non-DEVICE_LOCAL memory type references heap with is DEVICE_LOCAL" << TestLog::EndMessage; return tcu::TestStatus::fail("deviceMemoryProperties inconsistent memoryType and HeapFlags"); } } } bool* requiredFlagsFoundIterator = std::find(DE_ARRAY_BEGIN(requiredFlagsFound), DE_ARRAY_END(requiredFlagsFound), false); if (requiredFlagsFoundIterator != DE_ARRAY_END(requiredFlagsFound)) { DE_ASSERT(requiredFlagsFoundIterator - DE_ARRAY_BEGIN(requiredFlagsFound) <= DE_LENGTH_OF_ARRAY(requiredPropertyFlags)); log << TestLog::Message << "deviceMemoryProperties - required property flags " << getMemoryPropertyFlagsStr(requiredPropertyFlags[requiredFlagsFoundIterator - DE_ARRAY_BEGIN(requiredFlagsFound)]) << " not found" << TestLog::EndMessage; return tcu::TestStatus::fail("deviceMemoryProperties propertyFlags not valid"); } return tcu::TestStatus::pass("Querying memory properties succeeded"); } // \todo [2016-01-22 pyry] Optimize by doing format -> flags mapping instead VkFormatFeatureFlags getRequiredOptimalTilingFeatures (VkFormat format) { static const VkFormat s_requiredSampledImageBlitSrcFormats[] = { VK_FORMAT_B4G4R4A4_UNORM_PACK16, VK_FORMAT_R5G6B5_UNORM_PACK16, VK_FORMAT_A1R5G5B5_UNORM_PACK16, VK_FORMAT_R8_UNORM, VK_FORMAT_R8_SNORM, VK_FORMAT_R8_UINT, VK_FORMAT_R8_SINT, VK_FORMAT_R8G8_UNORM, VK_FORMAT_R8G8_SNORM, VK_FORMAT_R8G8_UINT, VK_FORMAT_R8G8_SINT, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_SNORM, VK_FORMAT_R8G8B8A8_UINT, VK_FORMAT_R8G8B8A8_SINT, VK_FORMAT_R8G8B8A8_SRGB, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_SRGB, VK_FORMAT_A8B8G8R8_UNORM_PACK32, VK_FORMAT_A8B8G8R8_SNORM_PACK32, VK_FORMAT_A8B8G8R8_UINT_PACK32, VK_FORMAT_A8B8G8R8_SINT_PACK32, VK_FORMAT_A8B8G8R8_SRGB_PACK32, VK_FORMAT_A2B10G10R10_UNORM_PACK32, VK_FORMAT_A2B10G10R10_UINT_PACK32, VK_FORMAT_R16_UINT, VK_FORMAT_R16_SINT, VK_FORMAT_R16_SFLOAT, VK_FORMAT_R16G16_UINT, VK_FORMAT_R16G16_SINT, VK_FORMAT_R16G16_SFLOAT, VK_FORMAT_R16G16B16A16_UINT, VK_FORMAT_R16G16B16A16_SINT, VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R32_UINT, VK_FORMAT_R32_SINT, VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32G32_UINT, VK_FORMAT_R32G32_SINT, VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R32G32B32A32_UINT, VK_FORMAT_R32G32B32A32_SINT, VK_FORMAT_R32G32B32A32_SFLOAT, VK_FORMAT_B10G11R11_UFLOAT_PACK32, VK_FORMAT_E5B9G9R9_UFLOAT_PACK32, VK_FORMAT_D16_UNORM, VK_FORMAT_D32_SFLOAT }; static const VkFormat s_requiredSampledImageFilterLinearFormats[] = { VK_FORMAT_B4G4R4A4_UNORM_PACK16, VK_FORMAT_R5G6B5_UNORM_PACK16, VK_FORMAT_A1R5G5B5_UNORM_PACK16, VK_FORMAT_R8_UNORM, VK_FORMAT_R8_SNORM, VK_FORMAT_R8G8_UNORM, VK_FORMAT_R8G8_SNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_SNORM, VK_FORMAT_R8G8B8A8_SRGB, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_SRGB, VK_FORMAT_A8B8G8R8_UNORM_PACK32, VK_FORMAT_A8B8G8R8_SNORM_PACK32, VK_FORMAT_A8B8G8R8_SRGB_PACK32, VK_FORMAT_A2B10G10R10_UNORM_PACK32, VK_FORMAT_R16_SFLOAT, VK_FORMAT_R16G16_SFLOAT, VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_B10G11R11_UFLOAT_PACK32, VK_FORMAT_E5B9G9R9_UFLOAT_PACK32, }; static const VkFormat s_requiredStorageImageFormats[] = { VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_SNORM, VK_FORMAT_R8G8B8A8_UINT, VK_FORMAT_R8G8B8A8_SINT, VK_FORMAT_R16G16B16A16_UINT, VK_FORMAT_R16G16B16A16_SINT, VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R32_UINT, VK_FORMAT_R32_SINT, VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32G32_UINT, VK_FORMAT_R32G32_SINT, VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R32G32B32A32_UINT, VK_FORMAT_R32G32B32A32_SINT, VK_FORMAT_R32G32B32A32_SFLOAT }; static const VkFormat s_requiredStorageImageAtomicFormats[] = { VK_FORMAT_R32_UINT, VK_FORMAT_R32_SINT }; static const VkFormat s_requiredColorAttachmentBlitDstFormats[] = { VK_FORMAT_R5G6B5_UNORM_PACK16, VK_FORMAT_A1R5G5B5_UNORM_PACK16, VK_FORMAT_R8_UNORM, VK_FORMAT_R8_UINT, VK_FORMAT_R8_SINT, VK_FORMAT_R8G8_UNORM, VK_FORMAT_R8G8_UINT, VK_FORMAT_R8G8_SINT, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_UINT, VK_FORMAT_R8G8B8A8_SINT, VK_FORMAT_R8G8B8A8_SRGB, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_SRGB, VK_FORMAT_A8B8G8R8_UNORM_PACK32, VK_FORMAT_A8B8G8R8_UINT_PACK32, VK_FORMAT_A8B8G8R8_SINT_PACK32, VK_FORMAT_A8B8G8R8_SRGB_PACK32, VK_FORMAT_A2B10G10R10_UNORM_PACK32, VK_FORMAT_A2B10G10R10_UINT_PACK32, VK_FORMAT_R16_UINT, VK_FORMAT_R16_SINT, VK_FORMAT_R16_SFLOAT, VK_FORMAT_R16G16_UINT, VK_FORMAT_R16G16_SINT, VK_FORMAT_R16G16_SFLOAT, VK_FORMAT_R16G16B16A16_UINT, VK_FORMAT_R16G16B16A16_SINT, VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R32_UINT, VK_FORMAT_R32_SINT, VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32G32_UINT, VK_FORMAT_R32G32_SINT, VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R32G32B32A32_UINT, VK_FORMAT_R32G32B32A32_SINT, VK_FORMAT_R32G32B32A32_SFLOAT }; static const VkFormat s_requiredColorAttachmentBlendFormats[] = { VK_FORMAT_R5G6B5_UNORM_PACK16, VK_FORMAT_A1R5G5B5_UNORM_PACK16, VK_FORMAT_R8_UNORM, VK_FORMAT_R8G8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_SRGB, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_SRGB, VK_FORMAT_A8B8G8R8_UNORM_PACK32, VK_FORMAT_A8B8G8R8_SRGB_PACK32, VK_FORMAT_A2B10G10R10_UNORM_PACK32, VK_FORMAT_R16_SFLOAT, VK_FORMAT_R16G16_SFLOAT, VK_FORMAT_R16G16B16A16_SFLOAT }; static const VkFormat s_requiredDepthStencilAttachmentFormats[] = { VK_FORMAT_D16_UNORM }; VkFormatFeatureFlags flags = (VkFormatFeatureFlags)0; if (de::contains(DE_ARRAY_BEGIN(s_requiredSampledImageBlitSrcFormats), DE_ARRAY_END(s_requiredSampledImageBlitSrcFormats), format)) flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT|VK_FORMAT_FEATURE_BLIT_SRC_BIT; if (de::contains(DE_ARRAY_BEGIN(s_requiredSampledImageFilterLinearFormats), DE_ARRAY_END(s_requiredSampledImageFilterLinearFormats), format)) flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT; if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageImageFormats), DE_ARRAY_END(s_requiredStorageImageFormats), format)) flags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT; if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageImageAtomicFormats), DE_ARRAY_END(s_requiredStorageImageAtomicFormats), format)) flags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT; if (de::contains(DE_ARRAY_BEGIN(s_requiredColorAttachmentBlitDstFormats), DE_ARRAY_END(s_requiredColorAttachmentBlitDstFormats), format)) flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT|VK_FORMAT_FEATURE_BLIT_DST_BIT; if (de::contains(DE_ARRAY_BEGIN(s_requiredColorAttachmentBlendFormats), DE_ARRAY_END(s_requiredColorAttachmentBlendFormats), format)) flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT; if (de::contains(DE_ARRAY_BEGIN(s_requiredDepthStencilAttachmentFormats), DE_ARRAY_END(s_requiredDepthStencilAttachmentFormats), format)) flags |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT; return flags; } VkFormatFeatureFlags getRequiredBufferFeatures (VkFormat format) { static const VkFormat s_requiredVertexBufferFormats[] = { VK_FORMAT_R8_UNORM, VK_FORMAT_R8_SNORM, VK_FORMAT_R8_UINT, VK_FORMAT_R8_SINT, VK_FORMAT_R8G8_UNORM, VK_FORMAT_R8G8_SNORM, VK_FORMAT_R8G8_UINT, VK_FORMAT_R8G8_SINT, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_SNORM, VK_FORMAT_R8G8B8A8_UINT, VK_FORMAT_R8G8B8A8_SINT, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_A8B8G8R8_UNORM_PACK32, VK_FORMAT_A8B8G8R8_SNORM_PACK32, VK_FORMAT_A8B8G8R8_UINT_PACK32, VK_FORMAT_A8B8G8R8_SINT_PACK32, VK_FORMAT_A2B10G10R10_UNORM_PACK32, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_SNORM, VK_FORMAT_R16_UINT, VK_FORMAT_R16_SINT, VK_FORMAT_R16_SFLOAT, VK_FORMAT_R16G16_UNORM, VK_FORMAT_R16G16_SNORM, VK_FORMAT_R16G16_UINT, VK_FORMAT_R16G16_SINT, VK_FORMAT_R16G16_SFLOAT, VK_FORMAT_R16G16B16A16_UNORM, VK_FORMAT_R16G16B16A16_SNORM, VK_FORMAT_R16G16B16A16_UINT, VK_FORMAT_R16G16B16A16_SINT, VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R32_UINT, VK_FORMAT_R32_SINT, VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32G32_UINT, VK_FORMAT_R32G32_SINT, VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R32G32B32_UINT, VK_FORMAT_R32G32B32_SINT, VK_FORMAT_R32G32B32_SFLOAT, VK_FORMAT_R32G32B32A32_UINT, VK_FORMAT_R32G32B32A32_SINT, VK_FORMAT_R32G32B32A32_SFLOAT }; static const VkFormat s_requiredUniformTexelBufferFormats[] = { VK_FORMAT_R8_UNORM, VK_FORMAT_R8_SNORM, VK_FORMAT_R8_UINT, VK_FORMAT_R8_SINT, VK_FORMAT_R8G8_UNORM, VK_FORMAT_R8G8_SNORM, VK_FORMAT_R8G8_UINT, VK_FORMAT_R8G8_SINT, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_SNORM, VK_FORMAT_R8G8B8A8_UINT, VK_FORMAT_R8G8B8A8_SINT, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_A8B8G8R8_UNORM_PACK32, VK_FORMAT_A8B8G8R8_SNORM_PACK32, VK_FORMAT_A8B8G8R8_UINT_PACK32, VK_FORMAT_A8B8G8R8_SINT_PACK32, VK_FORMAT_A2B10G10R10_UNORM_PACK32, VK_FORMAT_A2B10G10R10_UINT_PACK32, VK_FORMAT_R16_UINT, VK_FORMAT_R16_SINT, VK_FORMAT_R16_SFLOAT, VK_FORMAT_R16G16_UINT, VK_FORMAT_R16G16_SINT, VK_FORMAT_R16G16_SFLOAT, VK_FORMAT_R16G16B16A16_UINT, VK_FORMAT_R16G16B16A16_SINT, VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R32_UINT, VK_FORMAT_R32_SINT, VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32G32_UINT, VK_FORMAT_R32G32_SINT, VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R32G32B32A32_UINT, VK_FORMAT_R32G32B32A32_SINT, VK_FORMAT_R32G32B32A32_SFLOAT, VK_FORMAT_B10G11R11_UFLOAT_PACK32 }; static const VkFormat s_requiredStorageTexelBufferFormats[] = { VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_SNORM, VK_FORMAT_R8G8B8A8_UINT, VK_FORMAT_R8G8B8A8_SINT, VK_FORMAT_A8B8G8R8_UNORM_PACK32, VK_FORMAT_A8B8G8R8_SNORM_PACK32, VK_FORMAT_A8B8G8R8_UINT_PACK32, VK_FORMAT_A8B8G8R8_SINT_PACK32, VK_FORMAT_R16G16B16A16_UINT, VK_FORMAT_R16G16B16A16_SINT, VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R32_UINT, VK_FORMAT_R32_SINT, VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32G32_UINT, VK_FORMAT_R32G32_SINT, VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R32G32B32A32_UINT, VK_FORMAT_R32G32B32A32_SINT, VK_FORMAT_R32G32B32A32_SFLOAT }; static const VkFormat s_requiredStorageTexelBufferAtomicFormats[] = { VK_FORMAT_R32_UINT, VK_FORMAT_R32_SINT }; VkFormatFeatureFlags flags = (VkFormatFeatureFlags)0; if (de::contains(DE_ARRAY_BEGIN(s_requiredVertexBufferFormats), DE_ARRAY_END(s_requiredVertexBufferFormats), format)) flags |= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT; if (de::contains(DE_ARRAY_BEGIN(s_requiredUniformTexelBufferFormats), DE_ARRAY_END(s_requiredUniformTexelBufferFormats), format)) flags |= VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT; if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageTexelBufferFormats), DE_ARRAY_END(s_requiredStorageTexelBufferFormats), format)) flags |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT; if (de::contains(DE_ARRAY_BEGIN(s_requiredStorageTexelBufferAtomicFormats), DE_ARRAY_END(s_requiredStorageTexelBufferAtomicFormats), format)) flags |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT; return flags; } tcu::TestStatus formatProperties (Context& context, VkFormat format) { TestLog& log = context.getTestContext().getLog(); const VkFormatProperties properties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format); bool allOk = true; // \todo [2017-05-16 pyry] This should be extended to cover for example COLOR_ATTACHMENT for depth formats etc. // \todo [2017-05-18 pyry] Any other color conversion related features that can't be supported by regular formats? const VkFormatFeatureFlags notAllowedFeatures = VK_FORMAT_FEATURE_DISJOINT_BIT_KHR; const struct { VkFormatFeatureFlags VkFormatProperties::* field; const char* fieldName; VkFormatFeatureFlags requiredFeatures; } fields[] = { { &VkFormatProperties::linearTilingFeatures, "linearTilingFeatures", (VkFormatFeatureFlags)0 }, { &VkFormatProperties::optimalTilingFeatures, "optimalTilingFeatures", getRequiredOptimalTilingFeatures(format) }, { &VkFormatProperties::bufferFeatures, "bufferFeatures", getRequiredBufferFeatures(format) } }; log << TestLog::Message << properties << TestLog::EndMessage; for (int fieldNdx = 0; fieldNdx < DE_LENGTH_OF_ARRAY(fields); fieldNdx++) { const char* const fieldName = fields[fieldNdx].fieldName; const VkFormatFeatureFlags supported = properties.*fields[fieldNdx].field; const VkFormatFeatureFlags required = fields[fieldNdx].requiredFeatures; if ((supported & required) != required) { log << TestLog::Message << "ERROR in " << fieldName << ":\n" << " required: " << getFormatFeatureFlagsStr(required) << "\n " << " missing: " << getFormatFeatureFlagsStr(~supported & required) << TestLog::EndMessage; allOk = false; } if ((supported & notAllowedFeatures) != 0) { log << TestLog::Message << "ERROR in " << fieldName << ":\n" << " has: " << getFormatFeatureFlagsStr(supported & notAllowedFeatures) << TestLog::EndMessage; allOk = false; } } if (allOk) return tcu::TestStatus::pass("Query and validation passed"); else return tcu::TestStatus::fail("Required features not supported"); } VkPhysicalDeviceSamplerYcbcrConversionFeaturesKHR getPhysicalDeviceSamplerYcbcrConversionFeatures (const InstanceInterface& vk, VkPhysicalDevice physicalDevice) { VkPhysicalDeviceFeatures2KHR coreFeatures; VkPhysicalDeviceSamplerYcbcrConversionFeaturesKHR ycbcrFeatures; deMemset(&coreFeatures, 0, sizeof(coreFeatures)); deMemset(&ycbcrFeatures, 0, sizeof(ycbcrFeatures)); coreFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR; coreFeatures.pNext = &ycbcrFeatures; ycbcrFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES_KHR; vk.getPhysicalDeviceFeatures2KHR(physicalDevice, &coreFeatures); return ycbcrFeatures; } void checkYcbcrConversionSupport (Context& context) { if (!de::contains(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), "VK_KHR_sampler_ycbcr_conversion")) TCU_THROW(NotSupportedError, "VK_KHR_sampler_ycbcr_conversion is not supported"); // Hard dependency for ycbcr TCU_CHECK(de::contains(context.getInstanceExtensions().begin(), context.getInstanceExtensions().end(), "VK_KHR_get_physical_device_properties2")); { const VkPhysicalDeviceSamplerYcbcrConversionFeaturesKHR ycbcrFeatures = getPhysicalDeviceSamplerYcbcrConversionFeatures(context.getInstanceInterface(), context.getPhysicalDevice()); if (ycbcrFeatures.samplerYcbcrConversion == VK_FALSE) TCU_THROW(NotSupportedError, "samplerYcbcrConversion is not supported"); } } VkFormatFeatureFlags getAllowedYcbcrFormatFeatures (VkFormat format) { DE_ASSERT(isYCbCrFormat(format)); VkFormatFeatureFlags flags = (VkFormatFeatureFlags)0; // all formats *may* support these flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT; flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT; flags |= VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR; flags |= VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR; flags |= VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT_KHR; flags |= VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT_KHR; flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT_KHR; flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT_KHR; flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT_KHR; flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT_KHR; flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT_KHR; // multi-plane formats *may* support DISJOINT_BIT_KHR if (getPlaneCount(format) >= 2) flags |= VK_FORMAT_FEATURE_DISJOINT_BIT_KHR; if (isChromaSubsampled(format)) flags |= VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT_KHR; return flags; } tcu::TestStatus ycbcrFormatProperties (Context& context, VkFormat format) { DE_ASSERT(isYCbCrFormat(format)); checkYcbcrConversionSupport(context); TestLog& log = context.getTestContext().getLog(); const VkFormatProperties properties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format); bool allOk = true; const VkFormatFeatureFlags allowedImageFeatures = getAllowedYcbcrFormatFeatures(format); const struct { VkFormatFeatureFlags VkFormatProperties::* field; const char* fieldName; bool requiredFeatures; VkFormatFeatureFlags allowedFeatures; } fields[] = { { &VkFormatProperties::linearTilingFeatures, "linearTilingFeatures", false, allowedImageFeatures }, { &VkFormatProperties::optimalTilingFeatures, "optimalTilingFeatures", true, allowedImageFeatures }, { &VkFormatProperties::bufferFeatures, "bufferFeatures", false, (VkFormatFeatureFlags)0 } }; static const VkFormat s_requiredBaseFormats[] = { VK_FORMAT_G8_B8R8_2PLANE_420_UNORM_KHR, VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM_KHR }; const bool isRequiredBaseFormat (de::contains(DE_ARRAY_BEGIN(s_requiredBaseFormats), DE_ARRAY_END(s_requiredBaseFormats), format)); log << TestLog::Message << properties << TestLog::EndMessage; for (int fieldNdx = 0; fieldNdx < DE_LENGTH_OF_ARRAY(fields); fieldNdx++) { const char* const fieldName = fields[fieldNdx].fieldName; const VkFormatFeatureFlags supported = properties.*fields[fieldNdx].field; const VkFormatFeatureFlags allowed = fields[fieldNdx].allowedFeatures; if (isRequiredBaseFormat && fields[fieldNdx].requiredFeatures) { const VkFormatFeatureFlags required = VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR | VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR | VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT_KHR; if ((supported & required) != required) { log << TestLog::Message << "ERROR in " << fieldName << ":\n" << " required: " << getFormatFeatureFlagsStr(required) << "\n " << " missing: " << getFormatFeatureFlagsStr(~supported & required) << TestLog::EndMessage; allOk = false; } if ((supported & (VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT_KHR | VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT_KHR)) == 0) { log << TestLog::Message << "ERROR in " << fieldName << ":\n" << " Either VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT_KHR or VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT_KHR required" << TestLog::EndMessage; allOk = false; } } if ((supported & ~allowed) != 0) { log << TestLog::Message << "ERROR in " << fieldName << ":\n" << " has: " << getFormatFeatureFlagsStr(supported & ~allowed) << TestLog::EndMessage; allOk = false; } } if (allOk) return tcu::TestStatus::pass("Query and validation passed"); else return tcu::TestStatus::fail("Required features not supported"); } bool optimalTilingFeaturesSupported (Context& context, VkFormat format, VkFormatFeatureFlags features) { const VkFormatProperties properties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format); return (properties.optimalTilingFeatures & features) == features; } bool optimalTilingFeaturesSupportedForAll (Context& context, const VkFormat* begin, const VkFormat* end, VkFormatFeatureFlags features) { for (const VkFormat* cur = begin; cur != end; ++cur) { if (!optimalTilingFeaturesSupported(context, *cur, features)) return false; } return true; } tcu::TestStatus testDepthStencilSupported (Context& context) { if (!optimalTilingFeaturesSupported(context, VK_FORMAT_X8_D24_UNORM_PACK32, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) && !optimalTilingFeaturesSupported(context, VK_FORMAT_D32_SFLOAT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) return tcu::TestStatus::fail("Doesn't support one of VK_FORMAT_X8_D24_UNORM_PACK32 or VK_FORMAT_D32_SFLOAT"); if (!optimalTilingFeaturesSupported(context, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) && !optimalTilingFeaturesSupported(context, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) return tcu::TestStatus::fail("Doesn't support one of VK_FORMAT_D24_UNORM_S8_UINT or VK_FORMAT_D32_SFLOAT_S8_UINT"); return tcu::TestStatus::pass("Required depth/stencil formats supported"); } tcu::TestStatus testCompressedFormatsSupported (Context& context) { static const VkFormat s_allBcFormats[] = { VK_FORMAT_BC1_RGB_UNORM_BLOCK, VK_FORMAT_BC1_RGB_SRGB_BLOCK, VK_FORMAT_BC1_RGBA_UNORM_BLOCK, VK_FORMAT_BC1_RGBA_SRGB_BLOCK, VK_FORMAT_BC2_UNORM_BLOCK, VK_FORMAT_BC2_SRGB_BLOCK, VK_FORMAT_BC3_UNORM_BLOCK, VK_FORMAT_BC3_SRGB_BLOCK, VK_FORMAT_BC4_UNORM_BLOCK, VK_FORMAT_BC4_SNORM_BLOCK, VK_FORMAT_BC5_UNORM_BLOCK, VK_FORMAT_BC5_SNORM_BLOCK, VK_FORMAT_BC6H_UFLOAT_BLOCK, VK_FORMAT_BC6H_SFLOAT_BLOCK, VK_FORMAT_BC7_UNORM_BLOCK, VK_FORMAT_BC7_SRGB_BLOCK, }; static const VkFormat s_allEtc2Formats[] = { VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK, VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK, VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK, VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK, VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK, VK_FORMAT_EAC_R11_UNORM_BLOCK, VK_FORMAT_EAC_R11_SNORM_BLOCK, VK_FORMAT_EAC_R11G11_UNORM_BLOCK, VK_FORMAT_EAC_R11G11_SNORM_BLOCK, }; static const VkFormat s_allAstcLdrFormats[] = { VK_FORMAT_ASTC_4x4_UNORM_BLOCK, VK_FORMAT_ASTC_4x4_SRGB_BLOCK, VK_FORMAT_ASTC_5x4_UNORM_BLOCK, VK_FORMAT_ASTC_5x4_SRGB_BLOCK, VK_FORMAT_ASTC_5x5_UNORM_BLOCK, VK_FORMAT_ASTC_5x5_SRGB_BLOCK, VK_FORMAT_ASTC_6x5_UNORM_BLOCK, VK_FORMAT_ASTC_6x5_SRGB_BLOCK, VK_FORMAT_ASTC_6x6_UNORM_BLOCK, VK_FORMAT_ASTC_6x6_SRGB_BLOCK, VK_FORMAT_ASTC_8x5_UNORM_BLOCK, VK_FORMAT_ASTC_8x5_SRGB_BLOCK, VK_FORMAT_ASTC_8x6_UNORM_BLOCK, VK_FORMAT_ASTC_8x6_SRGB_BLOCK, VK_FORMAT_ASTC_8x8_UNORM_BLOCK, VK_FORMAT_ASTC_8x8_SRGB_BLOCK, VK_FORMAT_ASTC_10x5_UNORM_BLOCK, VK_FORMAT_ASTC_10x5_SRGB_BLOCK, VK_FORMAT_ASTC_10x6_UNORM_BLOCK, VK_FORMAT_ASTC_10x6_SRGB_BLOCK, VK_FORMAT_ASTC_10x8_UNORM_BLOCK, VK_FORMAT_ASTC_10x8_SRGB_BLOCK, VK_FORMAT_ASTC_10x10_UNORM_BLOCK, VK_FORMAT_ASTC_10x10_SRGB_BLOCK, VK_FORMAT_ASTC_12x10_UNORM_BLOCK, VK_FORMAT_ASTC_12x10_SRGB_BLOCK, VK_FORMAT_ASTC_12x12_UNORM_BLOCK, VK_FORMAT_ASTC_12x12_SRGB_BLOCK, }; static const struct { const char* setName; const char* featureName; const VkBool32 VkPhysicalDeviceFeatures::* feature; const VkFormat* formatsBegin; const VkFormat* formatsEnd; } s_compressedFormatSets[] = { { "BC", "textureCompressionBC", &VkPhysicalDeviceFeatures::textureCompressionBC, DE_ARRAY_BEGIN(s_allBcFormats), DE_ARRAY_END(s_allBcFormats) }, { "ETC2", "textureCompressionETC2", &VkPhysicalDeviceFeatures::textureCompressionETC2, DE_ARRAY_BEGIN(s_allEtc2Formats), DE_ARRAY_END(s_allEtc2Formats) }, { "ASTC LDR", "textureCompressionASTC_LDR", &VkPhysicalDeviceFeatures::textureCompressionASTC_LDR, DE_ARRAY_BEGIN(s_allAstcLdrFormats), DE_ARRAY_END(s_allAstcLdrFormats) }, }; TestLog& log = context.getTestContext().getLog(); const VkPhysicalDeviceFeatures& features = context.getDeviceFeatures(); int numSupportedSets = 0; int numErrors = 0; int numWarnings = 0; for (int setNdx = 0; setNdx < DE_LENGTH_OF_ARRAY(s_compressedFormatSets); ++setNdx) { const char* const setName = s_compressedFormatSets[setNdx].setName; const char* const featureName = s_compressedFormatSets[setNdx].featureName; const bool featureBitSet = features.*s_compressedFormatSets[setNdx].feature == VK_TRUE; const bool allSupported = optimalTilingFeaturesSupportedForAll(context, s_compressedFormatSets[setNdx].formatsBegin, s_compressedFormatSets[setNdx].formatsEnd, VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT); if (featureBitSet && !allSupported) { log << TestLog::Message << "ERROR: " << featureName << " = VK_TRUE but " << setName << " formats not supported" << TestLog::EndMessage; numErrors += 1; } else if (allSupported && !featureBitSet) { log << TestLog::Message << "WARNING: " << setName << " formats supported but " << featureName << " = VK_FALSE" << TestLog::EndMessage; numWarnings += 1; } if (featureBitSet) { log << TestLog::Message << "All " << setName << " formats are supported" << TestLog::EndMessage; numSupportedSets += 1; } else log << TestLog::Message << setName << " formats are not supported" << TestLog::EndMessage; } if (numSupportedSets == 0) { log << TestLog::Message << "No compressed format sets supported" << TestLog::EndMessage; numErrors += 1; } if (numErrors > 0) return tcu::TestStatus::fail("Compressed format support not valid"); else if (numWarnings > 0) return tcu::TestStatus(QP_TEST_RESULT_QUALITY_WARNING, "Found inconsistencies in compressed format support"); else return tcu::TestStatus::pass("Compressed texture format support is valid"); } void createFormatTests (tcu::TestCaseGroup* testGroup) { DE_STATIC_ASSERT(VK_FORMAT_UNDEFINED == 0); static const struct { VkFormat begin; VkFormat end; FunctionInstance1<VkFormat>::Function testFunction; } s_formatRanges[] = { // core formats { (VkFormat)(VK_FORMAT_UNDEFINED+1), VK_CORE_FORMAT_LAST, formatProperties }, // YCbCr formats { VK_FORMAT_G8B8G8R8_422_UNORM_KHR, (VkFormat)(VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM_KHR+1), ycbcrFormatProperties }, }; for (int rangeNdx = 0; rangeNdx < DE_LENGTH_OF_ARRAY(s_formatRanges); ++rangeNdx) { const VkFormat rangeBegin = s_formatRanges[rangeNdx].begin; const VkFormat rangeEnd = s_formatRanges[rangeNdx].end; const FunctionInstance1<VkFormat>::Function testFunction = s_formatRanges[rangeNdx].testFunction; for (VkFormat format = rangeBegin; format != rangeEnd; format = (VkFormat)(format+1)) { const char* const enumName = getFormatName(format); const string caseName = de::toLower(string(enumName).substr(10)); addFunctionCase(testGroup, caseName, enumName, testFunction, format); } } addFunctionCase(testGroup, "depth_stencil", "", testDepthStencilSupported); addFunctionCase(testGroup, "compressed_formats", "", testCompressedFormatsSupported); } VkImageUsageFlags getValidImageUsageFlags (const VkFormatFeatureFlags supportedFeatures, const bool useKhrMaintenance1Semantics) { VkImageUsageFlags flags = (VkImageUsageFlags)0; if (useKhrMaintenance1Semantics) { if ((supportedFeatures & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR) != 0) flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT; if ((supportedFeatures & VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR) != 0) flags |= VK_IMAGE_USAGE_TRANSFER_DST_BIT; } else { // If format is supported at all, it must be valid transfer src+dst if (supportedFeatures != 0) flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT; } if ((supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0) flags |= VK_IMAGE_USAGE_SAMPLED_BIT; if ((supportedFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) != 0) flags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT|VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT; if ((supportedFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) flags |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; if ((supportedFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0) flags |= VK_IMAGE_USAGE_STORAGE_BIT; return flags; } bool isValidImageUsageFlagCombination (VkImageUsageFlags usage) { if ((usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) { const VkImageUsageFlags allowedFlags = VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT; // Only *_ATTACHMENT_BIT flags can be combined with TRANSIENT_ATTACHMENT_BIT if ((usage & ~allowedFlags) != 0) return false; // TRANSIENT_ATTACHMENT_BIT is not valid without COLOR_ or DEPTH_STENCIL_ATTACHMENT_BIT if ((usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)) == 0) return false; } return usage != 0; } VkImageCreateFlags getValidImageCreateFlags (const VkPhysicalDeviceFeatures& deviceFeatures, VkFormat, VkFormatFeatureFlags, VkImageType type, VkImageUsageFlags usage) { VkImageCreateFlags flags = (VkImageCreateFlags)0; if ((usage & VK_IMAGE_USAGE_SAMPLED_BIT) != 0) { flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; if (type == VK_IMAGE_TYPE_2D) flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT; } if ((usage & (VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_STORAGE_BIT)) != 0 && (usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) { if (deviceFeatures.sparseBinding) flags |= VK_IMAGE_CREATE_SPARSE_BINDING_BIT|VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT; if (deviceFeatures.sparseResidencyAliased) flags |= VK_IMAGE_CREATE_SPARSE_ALIASED_BIT; } return flags; } bool isValidImageCreateFlagCombination (VkImageCreateFlags) { return true; } bool isRequiredImageParameterCombination (const VkPhysicalDeviceFeatures& deviceFeatures, const VkFormat format, const VkFormatProperties& formatProperties, const VkImageType imageType, const VkImageTiling imageTiling, const VkImageUsageFlags usageFlags, const VkImageCreateFlags createFlags) { DE_UNREF(deviceFeatures); DE_UNREF(formatProperties); DE_UNREF(createFlags); // Linear images can have arbitrary limitations if (imageTiling == VK_IMAGE_TILING_LINEAR) return false; // Support for other usages for compressed formats is optional if (isCompressedFormat(format) && (usageFlags & ~(VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT)) != 0) return false; // Support for 1D, and sliced 3D compressed formats is optional if (isCompressedFormat(format) && (imageType == VK_IMAGE_TYPE_1D || imageType == VK_IMAGE_TYPE_3D)) return false; // Support for 1D and 3D depth/stencil textures is optional if (isDepthStencilFormat(format) && (imageType == VK_IMAGE_TYPE_1D || imageType == VK_IMAGE_TYPE_3D)) return false; DE_ASSERT(deviceFeatures.sparseBinding || (createFlags & (VK_IMAGE_CREATE_SPARSE_BINDING_BIT|VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT)) == 0); DE_ASSERT(deviceFeatures.sparseResidencyAliased || (createFlags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) == 0); if (createFlags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) { if (isCompressedFormat(format)) return false; if (isDepthStencilFormat(format)) return false; if (!deIsPowerOfTwo32(mapVkFormat(format).getPixelSize())) return false; switch (imageType) { case VK_IMAGE_TYPE_2D: return (deviceFeatures.sparseResidencyImage2D == VK_TRUE); case VK_IMAGE_TYPE_3D: return (deviceFeatures.sparseResidencyImage3D == VK_TRUE); default: return false; } } return true; } VkSampleCountFlags getRequiredOptimalTilingSampleCounts (const VkPhysicalDeviceLimits& deviceLimits, const VkFormat format, const VkImageUsageFlags usageFlags) { if (!isCompressedFormat(format)) { const tcu::TextureFormat tcuFormat = mapVkFormat(format); const bool hasDepthComp = (tcuFormat.order == tcu::TextureFormat::D || tcuFormat.order == tcu::TextureFormat::DS); const bool hasStencilComp = (tcuFormat.order == tcu::TextureFormat::S || tcuFormat.order == tcu::TextureFormat::DS); const bool isColorFormat = !hasDepthComp && !hasStencilComp; VkSampleCountFlags sampleCounts = ~(VkSampleCountFlags)0; DE_ASSERT((hasDepthComp || hasStencilComp) != isColorFormat); if ((usageFlags & VK_IMAGE_USAGE_STORAGE_BIT) != 0) sampleCounts &= deviceLimits.storageImageSampleCounts; if ((usageFlags & VK_IMAGE_USAGE_SAMPLED_BIT) != 0) { if (hasDepthComp) sampleCounts &= deviceLimits.sampledImageDepthSampleCounts; if (hasStencilComp) sampleCounts &= deviceLimits.sampledImageStencilSampleCounts; if (isColorFormat) { const tcu::TextureChannelClass chnClass = tcu::getTextureChannelClass(tcuFormat.type); if (chnClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER || chnClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER) sampleCounts &= deviceLimits.sampledImageIntegerSampleCounts; else sampleCounts &= deviceLimits.sampledImageColorSampleCounts; } } if ((usageFlags & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) != 0) sampleCounts &= deviceLimits.framebufferColorSampleCounts; if ((usageFlags & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) { if (hasDepthComp) sampleCounts &= deviceLimits.framebufferDepthSampleCounts; if (hasStencilComp) sampleCounts &= deviceLimits.framebufferStencilSampleCounts; } // If there is no usage flag set that would have corresponding device limit, // only VK_SAMPLE_COUNT_1_BIT is required. if (sampleCounts == ~(VkSampleCountFlags)0) sampleCounts &= VK_SAMPLE_COUNT_1_BIT; return sampleCounts; } else return VK_SAMPLE_COUNT_1_BIT; } struct ImageFormatPropertyCase { typedef tcu::TestStatus (*Function) (Context& context, const VkFormat format, const VkImageType imageType, const VkImageTiling tiling); Function testFunction; VkFormat format; VkImageType imageType; VkImageTiling tiling; ImageFormatPropertyCase (Function testFunction_, VkFormat format_, VkImageType imageType_, VkImageTiling tiling_) : testFunction (testFunction_) , format (format_) , imageType (imageType_) , tiling (tiling_) {} ImageFormatPropertyCase (void) : testFunction ((Function)DE_NULL) , format (VK_FORMAT_UNDEFINED) , imageType (VK_IMAGE_TYPE_LAST) , tiling (VK_IMAGE_TILING_LAST) {} }; tcu::TestStatus execImageFormatTest (Context& context, ImageFormatPropertyCase testCase) { return testCase.testFunction(context, testCase.format, testCase.imageType, testCase.tiling); } void createImageFormatTypeTilingTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase params) { DE_ASSERT(params.format == VK_FORMAT_UNDEFINED); for (deUint32 formatNdx = VK_FORMAT_UNDEFINED+1; formatNdx < VK_CORE_FORMAT_LAST; ++formatNdx) { const VkFormat format = (VkFormat)formatNdx; const char* const enumName = getFormatName(format); const string caseName = de::toLower(string(enumName).substr(10)); params.format = format; addFunctionCase(testGroup, caseName, enumName, execImageFormatTest, params); } } void createImageFormatTypeTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase params) { DE_ASSERT(params.tiling == VK_IMAGE_TILING_LAST); testGroup->addChild(createTestGroup(testGroup->getTestContext(), "optimal", "", createImageFormatTypeTilingTests, ImageFormatPropertyCase(params.testFunction, VK_FORMAT_UNDEFINED, params.imageType, VK_IMAGE_TILING_OPTIMAL))); testGroup->addChild(createTestGroup(testGroup->getTestContext(), "linear", "", createImageFormatTypeTilingTests, ImageFormatPropertyCase(params.testFunction, VK_FORMAT_UNDEFINED, params.imageType, VK_IMAGE_TILING_LINEAR))); } void createImageFormatTests (tcu::TestCaseGroup* testGroup, ImageFormatPropertyCase::Function testFunction) { testGroup->addChild(createTestGroup(testGroup->getTestContext(), "1d", "", createImageFormatTypeTests, ImageFormatPropertyCase(testFunction, VK_FORMAT_UNDEFINED, VK_IMAGE_TYPE_1D, VK_IMAGE_TILING_LAST))); testGroup->addChild(createTestGroup(testGroup->getTestContext(), "2d", "", createImageFormatTypeTests, ImageFormatPropertyCase(testFunction, VK_FORMAT_UNDEFINED, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_LAST))); testGroup->addChild(createTestGroup(testGroup->getTestContext(), "3d", "", createImageFormatTypeTests, ImageFormatPropertyCase(testFunction, VK_FORMAT_UNDEFINED, VK_IMAGE_TYPE_3D, VK_IMAGE_TILING_LAST))); } tcu::TestStatus imageFormatProperties (Context& context, const VkFormat format, const VkImageType imageType, const VkImageTiling tiling) { TestLog& log = context.getTestContext().getLog(); const VkPhysicalDeviceFeatures& deviceFeatures = context.getDeviceFeatures(); const VkPhysicalDeviceLimits& deviceLimits = context.getDeviceProperties().limits; const VkFormatProperties formatProperties = getPhysicalDeviceFormatProperties(context.getInstanceInterface(), context.getPhysicalDevice(), format); const bool hasKhrMaintenance1 = isExtensionSupported(context.getDeviceExtensions(), "VK_KHR_maintenance1"); const VkFormatFeatureFlags supportedFeatures = tiling == VK_IMAGE_TILING_LINEAR ? formatProperties.linearTilingFeatures : formatProperties.optimalTilingFeatures; const VkImageUsageFlags usageFlagSet = getValidImageUsageFlags(supportedFeatures, hasKhrMaintenance1); tcu::ResultCollector results (log, "ERROR: "); if (hasKhrMaintenance1 && (supportedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0) { results.check((supportedFeatures & (VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR | VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR)) != 0, "A sampled image format must have VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR and VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR format feature flags set"); } for (VkImageUsageFlags curUsageFlags = 0; curUsageFlags <= usageFlagSet; curUsageFlags++) { if ((curUsageFlags & ~usageFlagSet) != 0 || !isValidImageUsageFlagCombination(curUsageFlags)) continue; const VkImageCreateFlags createFlagSet = getValidImageCreateFlags(deviceFeatures, format, supportedFeatures, imageType, curUsageFlags); for (VkImageCreateFlags curCreateFlags = 0; curCreateFlags <= createFlagSet; curCreateFlags++) { if ((curCreateFlags & ~createFlagSet) != 0 || !isValidImageCreateFlagCombination(curCreateFlags)) continue; const bool isRequiredCombination = isRequiredImageParameterCombination(deviceFeatures, format, formatProperties, imageType, tiling, curUsageFlags, curCreateFlags); VkImageFormatProperties properties; VkResult queryResult; log << TestLog::Message << "Testing " << getImageTypeStr(imageType) << ", " << getImageTilingStr(tiling) << ", " << getImageUsageFlagsStr(curUsageFlags) << ", " << getImageCreateFlagsStr(curCreateFlags) << TestLog::EndMessage; // Set return value to known garbage deMemset(&properties, 0xcd, sizeof(properties)); queryResult = context.getInstanceInterface().getPhysicalDeviceImageFormatProperties(context.getPhysicalDevice(), format, imageType, tiling, curUsageFlags, curCreateFlags, &properties); if (queryResult == VK_SUCCESS) { const deUint32 fullMipPyramidSize = de::max(de::max(deLog2Ceil32(properties.maxExtent.width), deLog2Ceil32(properties.maxExtent.height)), deLog2Ceil32(properties.maxExtent.depth)) + 1; log << TestLog::Message << properties << "\n" << TestLog::EndMessage; results.check(imageType != VK_IMAGE_TYPE_1D || (properties.maxExtent.width >= 1 && properties.maxExtent.height == 1 && properties.maxExtent.depth == 1), "Invalid dimensions for 1D image"); results.check(imageType != VK_IMAGE_TYPE_2D || (properties.maxExtent.width >= 1 && properties.maxExtent.height >= 1 && properties.maxExtent.depth == 1), "Invalid dimensions for 2D image"); results.check(imageType != VK_IMAGE_TYPE_3D || (properties.maxExtent.width >= 1 && properties.maxExtent.height >= 1 && properties.maxExtent.depth >= 1), "Invalid dimensions for 3D image"); results.check(imageType != VK_IMAGE_TYPE_3D || properties.maxArrayLayers == 1, "Invalid maxArrayLayers for 3D image"); if (tiling == VK_IMAGE_TILING_OPTIMAL && imageType == VK_IMAGE_TYPE_2D && !(curCreateFlags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) && (supportedFeatures & (VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))) { const VkSampleCountFlags requiredSampleCounts = getRequiredOptimalTilingSampleCounts(deviceLimits, format, curUsageFlags); results.check((properties.sampleCounts & requiredSampleCounts) == requiredSampleCounts, "Required sample counts not supported"); } else results.check(properties.sampleCounts == VK_SAMPLE_COUNT_1_BIT, "sampleCounts != VK_SAMPLE_COUNT_1_BIT"); if (isRequiredCombination) { results.check(imageType != VK_IMAGE_TYPE_1D || (properties.maxExtent.width >= deviceLimits.maxImageDimension1D), "Reported dimensions smaller than device limits"); results.check(imageType != VK_IMAGE_TYPE_2D || (properties.maxExtent.width >= deviceLimits.maxImageDimension2D && properties.maxExtent.height >= deviceLimits.maxImageDimension2D), "Reported dimensions smaller than device limits"); results.check(imageType != VK_IMAGE_TYPE_3D || (properties.maxExtent.width >= deviceLimits.maxImageDimension3D && properties.maxExtent.height >= deviceLimits.maxImageDimension3D && properties.maxExtent.depth >= deviceLimits.maxImageDimension3D), "Reported dimensions smaller than device limits"); results.check(properties.maxMipLevels == fullMipPyramidSize, "maxMipLevels is not full mip pyramid size"); results.check(imageType == VK_IMAGE_TYPE_3D || properties.maxArrayLayers >= deviceLimits.maxImageArrayLayers, "maxArrayLayers smaller than device limits"); } else { results.check(properties.maxMipLevels == 1 || properties.maxMipLevels == fullMipPyramidSize, "Invalid mip pyramid size"); results.check(properties.maxArrayLayers >= 1, "Invalid maxArrayLayers"); } results.check(properties.maxResourceSize >= (VkDeviceSize)MINIMUM_REQUIRED_IMAGE_RESOURCE_SIZE, "maxResourceSize smaller than minimum required size"); } else if (queryResult == VK_ERROR_FORMAT_NOT_SUPPORTED) { log << TestLog::Message << "Got VK_ERROR_FORMAT_NOT_SUPPORTED" << TestLog::EndMessage; if (isRequiredCombination) results.fail("VK_ERROR_FORMAT_NOT_SUPPORTED returned for required image parameter combination"); // Specification requires that all fields are set to 0 results.check(properties.maxExtent.width == 0, "maxExtent.width != 0"); results.check(properties.maxExtent.height == 0, "maxExtent.height != 0"); results.check(properties.maxExtent.depth == 0, "maxExtent.depth != 0"); results.check(properties.maxMipLevels == 0, "maxMipLevels != 0"); results.check(properties.maxArrayLayers == 0, "maxArrayLayers != 0"); results.check(properties.sampleCounts == 0, "sampleCounts != 0"); results.check(properties.maxResourceSize == 0, "maxResourceSize != 0"); } else { results.fail("Got unexpected error" + de::toString(queryResult)); } } } return tcu::TestStatus(results.getResult(), results.getMessage()); } // VK_KHR_get_physical_device_properties2 Move<VkInstance> createInstanceWithExtension (const PlatformInterface& vkp, const char* extensionName) { const vector<VkExtensionProperties> instanceExts = enumerateInstanceExtensionProperties(vkp, DE_NULL); vector<string> enabledExts; if (!isExtensionSupported(instanceExts, RequiredExtension(extensionName))) TCU_THROW(NotSupportedError, (string(extensionName) + " is not supported").c_str()); enabledExts.push_back(extensionName); return createDefaultInstance(vkp, vector<string>() /* layers */, enabledExts); } tcu::TestStatus deviceFeatures2 (Context& context) { const PlatformInterface& vkp = context.getPlatformInterface(); const Unique<VkInstance> instance (createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2")); const InstanceDriver vki (vkp, *instance); const vector<VkPhysicalDevice> devices = enumeratePhysicalDevices(vki, *instance); for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx) { VkPhysicalDeviceFeatures coreFeatures; VkPhysicalDeviceFeatures2KHR extFeatures; deMemset(&coreFeatures, 0xcd, sizeof(coreFeatures)); deMemset(&extFeatures.features, 0xcd, sizeof(extFeatures.features)); extFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR; extFeatures.pNext = DE_NULL; vki.getPhysicalDeviceFeatures(devices[deviceNdx], &coreFeatures); vki.getPhysicalDeviceFeatures2KHR(devices[deviceNdx], &extFeatures); TCU_CHECK(extFeatures.sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR); TCU_CHECK(extFeatures.pNext == DE_NULL); if (deMemCmp(&coreFeatures, &extFeatures.features, sizeof(VkPhysicalDeviceFeatures)) != 0) TCU_FAIL("Mismatch between features reported by vkGetPhysicalDeviceFeatures and vkGetPhysicalDeviceFeatures2KHR"); } return tcu::TestStatus::pass("Querying device features succeeded"); } tcu::TestStatus deviceProperties2 (Context& context) { const PlatformInterface& vkp = context.getPlatformInterface(); const Unique<VkInstance> instance (createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2")); const InstanceDriver vki (vkp, *instance); const vector<VkPhysicalDevice> devices = enumeratePhysicalDevices(vki, *instance); for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx) { VkPhysicalDeviceProperties coreProperties; VkPhysicalDeviceProperties2KHR extProperties; extProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR; extProperties.pNext = DE_NULL; vki.getPhysicalDeviceProperties(devices[deviceNdx], &coreProperties); vki.getPhysicalDeviceProperties2KHR(devices[deviceNdx], &extProperties); TCU_CHECK(extProperties.sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR); TCU_CHECK(extProperties.pNext == DE_NULL); // We can't use memcmp() here because the structs may contain padding bytes that drivers may or may not // have written while writing the data and memcmp will compare them anyway, so we iterate through the // valid bytes for each field in the struct and compare only the valid bytes for each one. for (int propNdx = 0; propNdx < DE_LENGTH_OF_ARRAY(s_physicalDevicePropertiesOffsetTable); propNdx++) { const size_t offset = s_physicalDevicePropertiesOffsetTable[propNdx].offset; const size_t size = s_physicalDevicePropertiesOffsetTable[propNdx].size; const deUint8* corePropertyBytes = reinterpret_cast<deUint8*>(&coreProperties) + offset; const deUint8* extPropertyBytes = reinterpret_cast<deUint8*>(&extProperties.properties) + offset; if (deMemCmp(corePropertyBytes, extPropertyBytes, size) != 0) TCU_FAIL("Mismatch between properties reported by vkGetPhysicalDeviceProperties and vkGetPhysicalDeviceProperties2KHR"); } } return tcu::TestStatus::pass("Querying device properties succeeded"); } tcu::TestStatus deviceFormatProperties2 (Context& context) { const PlatformInterface& vkp = context.getPlatformInterface(); const Unique<VkInstance> instance (createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2")); const InstanceDriver vki (vkp, *instance); const vector<VkPhysicalDevice> devices = enumeratePhysicalDevices(vki, *instance); for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx) { const VkPhysicalDevice physicalDevice = devices[deviceNdx]; for (int formatNdx = 0; formatNdx < VK_CORE_FORMAT_LAST; ++formatNdx) { const VkFormat format = (VkFormat)formatNdx; VkFormatProperties coreProperties; VkFormatProperties2KHR extProperties; deMemset(&coreProperties, 0xcd, sizeof(VkFormatProperties)); deMemset(&extProperties, 0xcd, sizeof(VkFormatProperties2KHR)); extProperties.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2_KHR; extProperties.pNext = DE_NULL; vki.getPhysicalDeviceFormatProperties(physicalDevice, format, &coreProperties); vki.getPhysicalDeviceFormatProperties2KHR(physicalDevice, format, &extProperties); TCU_CHECK(extProperties.sType == VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2_KHR); TCU_CHECK(extProperties.pNext == DE_NULL); if (deMemCmp(&coreProperties, &extProperties.formatProperties, sizeof(VkFormatProperties)) != 0) TCU_FAIL("Mismatch between format properties reported by vkGetPhysicalDeviceFormatProperties and vkGetPhysicalDeviceFormatProperties2KHR"); } } return tcu::TestStatus::pass("Querying device format properties succeeded"); } tcu::TestStatus deviceQueueFamilyProperties2 (Context& context) { const PlatformInterface& vkp = context.getPlatformInterface(); const Unique<VkInstance> instance (createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2")); const InstanceDriver vki (vkp, *instance); const vector<VkPhysicalDevice> devices = enumeratePhysicalDevices(vki, *instance); for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx) { const VkPhysicalDevice physicalDevice = devices[deviceNdx]; deUint32 numCoreQueueFamilies = ~0u; deUint32 numExtQueueFamilies = ~0u; vki.getPhysicalDeviceQueueFamilyProperties(physicalDevice, &numCoreQueueFamilies, DE_NULL); vki.getPhysicalDeviceQueueFamilyProperties2KHR(physicalDevice, &numExtQueueFamilies, DE_NULL); TCU_CHECK_MSG(numCoreQueueFamilies == numExtQueueFamilies, "Different number of queue family properties reported"); TCU_CHECK(numCoreQueueFamilies > 0); { std::vector<VkQueueFamilyProperties> coreProperties (numCoreQueueFamilies); std::vector<VkQueueFamilyProperties2KHR> extProperties (numExtQueueFamilies); deMemset(&coreProperties[0], 0xcd, sizeof(VkQueueFamilyProperties)*numCoreQueueFamilies); deMemset(&extProperties[0], 0xcd, sizeof(VkQueueFamilyProperties2KHR)*numExtQueueFamilies); for (size_t ndx = 0; ndx < extProperties.size(); ++ndx) { extProperties[ndx].sType = VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2_KHR; extProperties[ndx].pNext = DE_NULL; } vki.getPhysicalDeviceQueueFamilyProperties(physicalDevice, &numCoreQueueFamilies, &coreProperties[0]); vki.getPhysicalDeviceQueueFamilyProperties2KHR(physicalDevice, &numExtQueueFamilies, &extProperties[0]); TCU_CHECK((size_t)numCoreQueueFamilies == coreProperties.size()); TCU_CHECK((size_t)numExtQueueFamilies == extProperties.size()); DE_ASSERT(numCoreQueueFamilies == numExtQueueFamilies); for (size_t ndx = 0; ndx < extProperties.size(); ++ndx) { TCU_CHECK(extProperties[ndx].sType == VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2_KHR); TCU_CHECK(extProperties[ndx].pNext == DE_NULL); if (deMemCmp(&coreProperties[ndx], &extProperties[ndx].queueFamilyProperties, sizeof(VkQueueFamilyProperties)) != 0) TCU_FAIL("Mismatch between format properties reported by vkGetPhysicalDeviceQueueFamilyProperties and vkGetPhysicalDeviceQueueFamilyProperties2KHR"); } } } return tcu::TestStatus::pass("Querying device queue family properties succeeded"); } tcu::TestStatus deviceMemoryProperties2 (Context& context) { const PlatformInterface& vkp = context.getPlatformInterface(); const Unique<VkInstance> instance (createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2")); const InstanceDriver vki (vkp, *instance); const vector<VkPhysicalDevice> devices = enumeratePhysicalDevices(vki, *instance); for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx) { VkPhysicalDeviceMemoryProperties coreProperties; VkPhysicalDeviceMemoryProperties2KHR extProperties; deMemset(&coreProperties, 0xcd, sizeof(VkPhysicalDeviceMemoryProperties)); deMemset(&extProperties, 0xcd, sizeof(VkPhysicalDeviceMemoryProperties2KHR)); extProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR; extProperties.pNext = DE_NULL; vki.getPhysicalDeviceMemoryProperties(devices[deviceNdx], &coreProperties); vki.getPhysicalDeviceMemoryProperties2KHR(devices[deviceNdx], &extProperties); TCU_CHECK(extProperties.sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR); TCU_CHECK(extProperties.pNext == DE_NULL); if (deMemCmp(&coreProperties, &extProperties.memoryProperties, sizeof(VkPhysicalDeviceMemoryProperties)) != 0) TCU_FAIL("Mismatch between properties reported by vkGetPhysicalDeviceMemoryProperties and vkGetPhysicalDeviceMemoryProperties2KHR"); } return tcu::TestStatus::pass("Querying device memory properties succeeded"); } tcu::TestStatus imageFormatProperties2 (Context& context, const VkFormat format, const VkImageType imageType, const VkImageTiling tiling) { TestLog& log = context.getTestContext().getLog(); const PlatformInterface& vkp = context.getPlatformInterface(); const Unique<VkInstance> instance (createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2")); const InstanceDriver vki (vkp, *instance); const vector<VkPhysicalDevice> devices = enumeratePhysicalDevices(vki, *instance); const VkImageUsageFlags allUsageFlags = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT; const VkImageCreateFlags allCreateFlags = VK_IMAGE_CREATE_SPARSE_BINDING_BIT | VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT | VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT; for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx) { const VkPhysicalDevice physicalDevice = devices[deviceNdx]; for (VkImageUsageFlags curUsageFlags = (VkImageUsageFlags)1; curUsageFlags <= allUsageFlags; curUsageFlags++) { for (VkImageCreateFlags curCreateFlags = 0; curCreateFlags <= allCreateFlags; curCreateFlags++) { const VkPhysicalDeviceImageFormatInfo2KHR imageFormatInfo = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2_KHR, DE_NULL, format, imageType, tiling, curUsageFlags, curCreateFlags }; VkImageFormatProperties coreProperties; VkImageFormatProperties2KHR extProperties; VkResult coreResult; VkResult extResult; deMemset(&coreProperties, 0xcd, sizeof(VkImageFormatProperties)); deMemset(&extProperties, 0xcd, sizeof(VkImageFormatProperties2KHR)); extProperties.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2_KHR; extProperties.pNext = DE_NULL; coreResult = vki.getPhysicalDeviceImageFormatProperties(physicalDevice, imageFormatInfo.format, imageFormatInfo.type, imageFormatInfo.tiling, imageFormatInfo.usage, imageFormatInfo.flags, &coreProperties); extResult = vki.getPhysicalDeviceImageFormatProperties2KHR(physicalDevice, &imageFormatInfo, &extProperties); TCU_CHECK(extProperties.sType == VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2_KHR); TCU_CHECK(extProperties.pNext == DE_NULL); if ((coreResult != extResult) || (deMemCmp(&coreProperties, &extProperties.imageFormatProperties, sizeof(VkImageFormatProperties)) != 0)) { log << TestLog::Message << "ERROR: device " << deviceNdx << ": mismatch with query " << imageFormatInfo << TestLog::EndMessage << TestLog::Message << "vkGetPhysicalDeviceImageFormatProperties() returned " << coreResult << ", " << coreProperties << TestLog::EndMessage << TestLog::Message << "vkGetPhysicalDeviceImageFormatProperties2KHR() returned " << extResult << ", " << extProperties << TestLog::EndMessage; TCU_FAIL("Mismatch between image format properties reported by vkGetPhysicalDeviceImageFormatProperties and vkGetPhysicalDeviceImageFormatProperties2KHR"); } } } } return tcu::TestStatus::pass("Querying image format properties succeeded"); } tcu::TestStatus sparseImageFormatProperties2 (Context& context, const VkFormat format, const VkImageType imageType, const VkImageTiling tiling) { TestLog& log = context.getTestContext().getLog(); const PlatformInterface& vkp = context.getPlatformInterface(); const Unique<VkInstance> instance (createInstanceWithExtension(vkp, "VK_KHR_get_physical_device_properties2")); const InstanceDriver vki (vkp, *instance); const vector<VkPhysicalDevice> devices = enumeratePhysicalDevices(vki, *instance); const VkImageUsageFlags allUsageFlags = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT; for (size_t deviceNdx = 0; deviceNdx < devices.size(); ++deviceNdx) { const VkPhysicalDevice physicalDevice = devices[deviceNdx]; for (deUint32 sampleCountBit = VK_SAMPLE_COUNT_1_BIT; sampleCountBit <= VK_SAMPLE_COUNT_64_BIT; sampleCountBit = (sampleCountBit << 1u)) { for (VkImageUsageFlags curUsageFlags = (VkImageUsageFlags)1; curUsageFlags <= allUsageFlags; curUsageFlags++) { const VkPhysicalDeviceSparseImageFormatInfo2KHR imageFormatInfo = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2_KHR, DE_NULL, format, imageType, (VkSampleCountFlagBits)sampleCountBit, curUsageFlags, tiling, }; deUint32 numCoreProperties = ~0u; deUint32 numExtProperties = ~0u; // Query count vki.getPhysicalDeviceSparseImageFormatProperties(physicalDevice, imageFormatInfo.format, imageFormatInfo.type, imageFormatInfo.samples, imageFormatInfo.usage, imageFormatInfo.tiling, &numCoreProperties, DE_NULL); vki.getPhysicalDeviceSparseImageFormatProperties2KHR(physicalDevice, &imageFormatInfo, &numExtProperties, DE_NULL); if (numCoreProperties != numExtProperties) { log << TestLog::Message << "ERROR: device " << deviceNdx << ": different number of properties reported for " << imageFormatInfo << TestLog::EndMessage; TCU_FAIL("Mismatch in reported property count"); } if (numCoreProperties > 0) { std::vector<VkSparseImageFormatProperties> coreProperties (numCoreProperties); std::vector<VkSparseImageFormatProperties2KHR> extProperties (numExtProperties); deMemset(&coreProperties[0], 0xcd, sizeof(VkSparseImageFormatProperties)*numCoreProperties); deMemset(&extProperties[0], 0xcd, sizeof(VkSparseImageFormatProperties2KHR)*numExtProperties); for (deUint32 ndx = 0; ndx < numExtProperties; ++ndx) { extProperties[ndx].sType = VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2_KHR; extProperties[ndx].pNext = DE_NULL; } vki.getPhysicalDeviceSparseImageFormatProperties(physicalDevice, imageFormatInfo.format, imageFormatInfo.type, imageFormatInfo.samples, imageFormatInfo.usage, imageFormatInfo.tiling, &numCoreProperties, &coreProperties[0]); vki.getPhysicalDeviceSparseImageFormatProperties2KHR(physicalDevice, &imageFormatInfo, &numExtProperties, &extProperties[0]); TCU_CHECK((size_t)numCoreProperties == coreProperties.size()); TCU_CHECK((size_t)numExtProperties == extProperties.size()); for (deUint32 ndx = 0; ndx < numCoreProperties; ++ndx) { TCU_CHECK(extProperties[ndx].sType == VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2_KHR); TCU_CHECK(extProperties[ndx].pNext == DE_NULL); if ((deMemCmp(&coreProperties[ndx], &extProperties[ndx].properties, sizeof(VkSparseImageFormatProperties)) != 0)) { log << TestLog::Message << "ERROR: device " << deviceNdx << ": mismatch with query " << imageFormatInfo << " property " << ndx << TestLog::EndMessage << TestLog::Message << "vkGetPhysicalDeviceSparseImageFormatProperties() returned " << coreProperties[ndx] << TestLog::EndMessage << TestLog::Message << "vkGetPhysicalDeviceSparseImageFormatProperties2KHR() returned " << extProperties[ndx] << TestLog::EndMessage; TCU_FAIL("Mismatch between image format properties reported by vkGetPhysicalDeviceSparseImageFormatProperties and vkGetPhysicalDeviceSparseImageFormatProperties2KHR"); } } } } } } return tcu::TestStatus::pass("Querying sparse image format properties succeeded"); } // Android CTS -specific tests namespace android { void checkExtensions (tcu::ResultCollector& results, const set<string>& allowedExtensions, const vector<VkExtensionProperties>& reportedExtensions) { for (vector<VkExtensionProperties>::const_iterator extension = reportedExtensions.begin(); extension != reportedExtensions.end(); ++extension) { const string extensionName (extension->extensionName); const bool mustBeKnown = de::beginsWith(extensionName, "VK_KHX_") || de::beginsWith(extensionName, "VK_GOOGLE_") || de::beginsWith(extensionName, "VK_ANDROID_"); if (mustBeKnown && !de::contains(allowedExtensions, extensionName)) results.fail("Unknown extension: " + extensionName); } } tcu::TestStatus testNoUnknownExtensions (Context& context) { TestLog& log = context.getTestContext().getLog(); tcu::ResultCollector results (log); set<string> allowedInstanceExtensions; set<string> allowedDeviceExtensions; // All known extensions should be added to allowedExtensions: // allowedExtensions.insert("VK_GOOGLE_extension1"); allowedDeviceExtensions.insert("VK_GOOGLE_display_timing"); // Instance extensions checkExtensions(results, allowedInstanceExtensions, enumerateInstanceExtensionProperties(context.getPlatformInterface(), DE_NULL)); // Extensions exposed by instance layers { const vector<VkLayerProperties> layers = enumerateInstanceLayerProperties(context.getPlatformInterface()); for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer) { checkExtensions(results, allowedInstanceExtensions, enumerateInstanceExtensionProperties(context.getPlatformInterface(), layer->layerName)); } } // Device extensions checkExtensions(results, allowedDeviceExtensions, enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), DE_NULL)); // Extensions exposed by device layers { const vector<VkLayerProperties> layers = enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice()); for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer) { checkExtensions(results, allowedDeviceExtensions, enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), layer->layerName)); } } return tcu::TestStatus(results.getResult(), results.getMessage()); } tcu::TestStatus testNoLayers (Context& context) { TestLog& log = context.getTestContext().getLog(); tcu::ResultCollector results (log); { const vector<VkLayerProperties> layers = enumerateInstanceLayerProperties(context.getPlatformInterface()); for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer) results.fail(string("Instance layer enumerated: ") + layer->layerName); } { const vector<VkLayerProperties> layers = enumerateDeviceLayerProperties(context.getInstanceInterface(), context.getPhysicalDevice()); for (vector<VkLayerProperties>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer) results.fail(string("Device layer enumerated: ") + layer->layerName); } return tcu::TestStatus(results.getResult(), results.getMessage()); } tcu::TestStatus testMandatoryExtensions (Context& context) { TestLog& log = context.getTestContext().getLog(); tcu::ResultCollector results (log); // Instance extensions { static const char* mandatoryExtensions[] = { "VK_KHR_get_physical_device_properties2", }; const vector<VkExtensionProperties> extensions = enumerateInstanceExtensionProperties(context.getPlatformInterface(), DE_NULL); for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(mandatoryExtensions); ++ndx) { if (!isExtensionSupported(extensions, RequiredExtension(mandatoryExtensions[ndx]))) results.fail(string(mandatoryExtensions[ndx]) + " is not supported"); } } // Device extensions { static const char* mandatoryExtensions[] = { "VK_KHR_maintenance1", }; const vector<VkExtensionProperties> extensions = enumerateDeviceExtensionProperties(context.getInstanceInterface(), context.getPhysicalDevice(), DE_NULL); for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(mandatoryExtensions); ++ndx) { if (!isExtensionSupported(extensions, RequiredExtension(mandatoryExtensions[ndx]))) results.fail(string(mandatoryExtensions[ndx]) + " is not supported"); } } return tcu::TestStatus(results.getResult(), results.getMessage()); } } // android } // anonymous tcu::TestCaseGroup* createFeatureInfoTests (tcu::TestContext& testCtx) { de::MovePtr<tcu::TestCaseGroup> infoTests (new tcu::TestCaseGroup(testCtx, "info", "Platform Information Tests")); { de::MovePtr<tcu::TestCaseGroup> instanceInfoTests (new tcu::TestCaseGroup(testCtx, "instance", "Instance Information Tests")); addFunctionCase(instanceInfoTests.get(), "physical_devices", "Physical devices", enumeratePhysicalDevices); addFunctionCase(instanceInfoTests.get(), "layers", "Layers", enumerateInstanceLayers); addFunctionCase(instanceInfoTests.get(), "extensions", "Extensions", enumerateInstanceExtensions); infoTests->addChild(instanceInfoTests.release()); } { de::MovePtr<tcu::TestCaseGroup> deviceInfoTests (new tcu::TestCaseGroup(testCtx, "device", "Device Information Tests")); addFunctionCase(deviceInfoTests.get(), "features", "Device Features", deviceFeatures); addFunctionCase(deviceInfoTests.get(), "properties", "Device Properties", deviceProperties); addFunctionCase(deviceInfoTests.get(), "queue_family_properties", "Queue family properties", deviceQueueFamilyProperties); addFunctionCase(deviceInfoTests.get(), "memory_properties", "Memory properties", deviceMemoryProperties); addFunctionCase(deviceInfoTests.get(), "layers", "Layers", enumerateDeviceLayers); addFunctionCase(deviceInfoTests.get(), "extensions", "Extensions", enumerateDeviceExtensions); infoTests->addChild(deviceInfoTests.release()); } infoTests->addChild(createTestGroup(testCtx, "format_properties", "VkGetPhysicalDeviceFormatProperties() Tests", createFormatTests)); infoTests->addChild(createTestGroup(testCtx, "image_format_properties", "VkGetPhysicalDeviceImageFormatProperties() Tests", createImageFormatTests, imageFormatProperties)); // \todo [2017-05-16 pyry] Extend image_format_properties to cover ycbcr formats { de::MovePtr<tcu::TestCaseGroup> extendedPropertiesTests (new tcu::TestCaseGroup(testCtx, "get_physical_device_properties2", "VK_KHR_get_physical_device_properties2")); addFunctionCase(extendedPropertiesTests.get(), "features", "Extended Device Features", deviceFeatures2); addFunctionCase(extendedPropertiesTests.get(), "properties", "Extended Device Properties", deviceProperties2); addFunctionCase(extendedPropertiesTests.get(), "format_properties", "Extended Device Format Properties", deviceFormatProperties2); addFunctionCase(extendedPropertiesTests.get(), "queue_family_properties", "Extended Device Queue Family Properties", deviceQueueFamilyProperties2); addFunctionCase(extendedPropertiesTests.get(), "memory_properties", "Extended Device Memory Properties", deviceMemoryProperties2); infoTests->addChild(extendedPropertiesTests.release()); } infoTests->addChild(createTestGroup(testCtx, "image_format_properties2", "VkGetPhysicalDeviceImageFormatProperties2KHR() Tests", createImageFormatTests, imageFormatProperties2)); infoTests->addChild(createTestGroup(testCtx, "sparse_image_format_properties2", "VkGetPhysicalDeviceSparseImageFormatProperties2KHR() Tests", createImageFormatTests, sparseImageFormatProperties2)); // \todo [2017-05-16 pyry] Extend image_format_properties2 to cover ycbcr formats { de::MovePtr<tcu::TestCaseGroup> androidTests (new tcu::TestCaseGroup(testCtx, "android", "Android CTS Tests")); addFunctionCase(androidTests.get(), "mandatory_extensions", "Test that all mandatory extensions are supported", android::testMandatoryExtensions); addFunctionCase(androidTests.get(), "no_unknown_extensions", "Test for unknown device or instance extensions", android::testNoUnknownExtensions); addFunctionCase(androidTests.get(), "no_layers", "Test that no layers are enumerated", android::testNoLayers); infoTests->addChild(androidTests.release()); } return infoTests.release(); } } // api } // vkt
/*------------------------------------------------------------------------*/ /* Copyright 2010, 2011 Sandia Corporation. */ /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ /* license for use of this work by or on behalf of the U.S. Government. */ /* Export of this program may require a license from the */ /* United States Government. */ /*------------------------------------------------------------------------*/ #ifndef stk_mesh_BucketImpl_hpp #define stk_mesh_BucketImpl_hpp //---------------------------------------------------------------------- #include <stk_mesh/base/Types.hpp> #include <stk_mesh/base/Field.hpp> #include <stk_mesh/base/Entity.hpp> //---------------------------------------------------------------------- namespace stk { namespace mesh { namespace impl { class BucketImpl { public: ~BucketImpl(); struct DataMap { typedef FieldBase::Restriction::size_type size_type ; const size_type * m_stride ; size_type m_base ; size_type m_size ; }; BucketImpl( BulkData & arg_mesh , unsigned arg_entity_rank , const unsigned * arg_key , size_t arg_alloc_size , size_t arg_capacity , DataMap * arg_field_map , Entity ** arg_entity_array ); // // External interface: // BulkData & mesh() const { return m_mesh ; } unsigned entity_rank() const { return m_entity_rank ; } const unsigned * key() const { return m_key ; } std::pair<const unsigned *, const unsigned *> superset_part_ordinals() const { return std::pair<const unsigned *, const unsigned *> ( m_key + 1 , m_key + m_key[0] ); } unsigned allocation_size() const { return m_alloc_size ; } size_t capacity() const { return m_capacity ; } size_t size() const { return m_size ; } Entity & operator[] ( size_t i ) const { return *(m_entities[i]) ; } unsigned field_data_size(const FieldBase & field) const { return m_field_map[ field.mesh_meta_data_ordinal() ].m_size; } const FieldBase::Restriction::size_type * field_data_stride( const FieldBase & field ) const { return m_field_map[ field.mesh_meta_data_ordinal() ].m_stride; } unsigned char * field_data_location( const FieldBase & field, const Entity & entity ) const { return field_data_location_impl( field.mesh_meta_data_ordinal(), entity.bucket_ordinal() ); } unsigned char * field_data_location( const FieldBase & field ) const { unsigned int zero_ordinal = 0; return field_data_location_impl( field.mesh_meta_data_ordinal(), zero_ordinal ); } // // Internal interface: // void increment_size() { ++m_size ; } void decrement_size() { --m_size ; } void replace_entity(unsigned entity_ordinal, Entity * entity ) { m_entities[entity_ordinal] = entity ; } void update_state(); template< class field_type > typename FieldTraits< field_type >::data_type * field_data( const field_type & f , const unsigned & entity_ordinal ) const { typedef typename FieldTraits< field_type >::data_type * data_p ; return (data_p)(field_data_location_impl(f.mesh_meta_data_ordinal(),entity_ordinal)); } // BucketKey key = ( part-count , { part-ordinals } , counter ) // key[ key[0] ] == counter unsigned bucket_counter() const { return m_key[ *m_key ]; } Bucket * last_bucket_in_family(); Bucket * first_bucket_in_family(); void set_last_bucket_in_family( Bucket * last_bucket ); void set_first_bucket_in_family( Bucket * first_bucket ); DataMap * get_field_map(); void zero_fields( unsigned i_dst ); void replace_fields( unsigned i_dst , Bucket & k_src , unsigned i_src ); void set_bucket_family_pointer( Bucket * bucket ) { m_bucket = bucket; } const Bucket * get_bucket_family_pointer() const { return m_bucket; } bool equivalent( const BucketImpl& other_bucket ) const { return m_bucket == other_bucket.m_bucket; } private: BucketImpl(); BulkData & m_mesh ; // Where this bucket resides const unsigned m_entity_rank ; // Type of entities for this bucket const unsigned * const m_key ; // Unique key in the bulk data const size_t m_alloc_size ; // Allocation size of this bucket const size_t m_capacity ; // Capacity for entities size_t m_size ; // Number of entities Bucket * m_bucket ; // Pointer to head of bucket family, but head points to tail DataMap * const m_field_map ; // Field value data map, shared Entity ** const m_entities ; // Array of entity pointers, // beginning of field value memory. unsigned char * field_data_location_impl( const unsigned & field_ordinal, const unsigned & entity_ordinal ) const { typedef unsigned char * byte_p ; const DataMap & data_map = m_field_map[ field_ordinal ]; unsigned char * ptr = NULL; if ( data_map.m_size ) { ptr = ((byte_p)(m_entities) + data_map.m_base + data_map.m_size * entity_ordinal ); } return ptr ; } Bucket * last_bucket_in_family_impl(); }; } // namespace impl } // namespace mesh } // namespace stk #endif // stk_mesh_BucketImpl_hpp
// (C) Copyright Samuli-Petrus Korhonen 2017. // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // The author gratefully acknowleges the support of NMR Solutions, Inc., in // producing this work. // Revision History: // 15 Feb 17 Initial version #ifndef CONFIG_NUMPY20170215_H_ # define CONFIG_NUMPY20170215_H_ # include <boost/config.hpp> /***************************************************************************** * * Set up dll import/export options: * ****************************************************************************/ // backwards compatibility: #ifdef BOOST_NUMPY_STATIC_LIB # define BOOST_NUMPY_STATIC_LINK # elif !defined(BOOST_NUMPY_DYNAMIC_LIB) # define BOOST_NUMPY_DYNAMIC_LIB #endif #if defined(BOOST_NUMPY_DYNAMIC_LIB) # if defined(BOOST_SYMBOL_EXPORT) # if defined(BOOST_NUMPY_SOURCE) # define BOOST_NUMPY_DECL BOOST_SYMBOL_EXPORT # define BOOST_NUMPY_DECL_FORWARD BOOST_SYMBOL_FORWARD_EXPORT # define BOOST_NUMPY_DECL_EXCEPTION BOOST_EXCEPTION_EXPORT # define BOOST_NUMPY_BUILD_DLL # else # define BOOST_NUMPY_DECL BOOST_SYMBOL_IMPORT # define BOOST_NUMPY_DECL_FORWARD BOOST_SYMBOL_FORWARD_IMPORT # define BOOST_NUMPY_DECL_EXCEPTION BOOST_EXCEPTION_IMPORT # endif # endif #endif #ifndef BOOST_NUMPY_DECL # define BOOST_NUMPY_DECL #endif #ifndef BOOST_NUMPY_DECL_FORWARD # define BOOST_NUMPY_DECL_FORWARD #endif #ifndef BOOST_NUMPY_DECL_EXCEPTION # define BOOST_NUMPY_DECL_EXCEPTION #endif // enable automatic library variant selection ------------------------------// #if !defined(BOOST_NUMPY_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_NUMPY_NO_LIB) // // Set the name of our library, this will get undef'ed by auto_link.hpp // once it's done with it: // #define _BOOST_PYTHON_CONCAT(N, M, m) N ## M ## m #define BOOST_PYTHON_CONCAT(N, M, m) _BOOST_PYTHON_CONCAT(N, M, m) #define BOOST_LIB_NAME BOOST_PYTHON_CONCAT(boost_numpy, PY_MAJOR_VERSION, PY_MINOR_VERSION) // // If we're importing code from a dll, then tell auto_link.hpp about it: // #ifdef BOOST_NUMPY_DYNAMIC_LIB # define BOOST_DYN_LINK #endif // // And include the header that does the work: // #include <boost/config/auto_link.hpp> #endif // auto-linking disabled #undef BOOST_PYTHON_CONCAT #undef _BOOST_PYTHON_CONCAT #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #endif // CONFIG_NUMPY20170215_H_
// Copyright 2017 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/connectivity/network/mdns/service/transport/mdns_interface_transceiver_v6.h" #include <arpa/inet.h> #include <errno.h> #include <lib/syslog/cpp/macros.h> #include <sys/socket.h> #include "src/connectivity/network/mdns/service/common/mdns_addresses.h" namespace mdns { MdnsInterfaceTransceiverV6::MdnsInterfaceTransceiverV6(inet::IpAddress address, const std::string& name, uint32_t index, Media media) : MdnsInterfaceTransceiver(address, name, index, media) {} MdnsInterfaceTransceiverV6::~MdnsInterfaceTransceiverV6() {} int MdnsInterfaceTransceiverV6::SetOptionDisableMulticastLoop() { int param = 0; int result = setsockopt(socket_fd().get(), IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &param, sizeof(param)); if (result < 0) { if (errno == ENOPROTOOPT) { FX_LOGS(WARNING) << "fxbug.dev/20688 IPV6_MULTICAST_LOOP not supported " "(ENOPROTOOPT), continuing anyway"; result = 0; } else { FX_LOGS(ERROR) << "Failed to set socket option IPV6_MULTICAST_LOOP, " << strerror(errno); } } return result; } int MdnsInterfaceTransceiverV6::SetOptionJoinMulticastGroup() { ipv6_mreq param; param.ipv6mr_multiaddr = MdnsAddresses::v6_multicast().as_sockaddr_in6().sin6_addr; param.ipv6mr_interface = index(); int result = setsockopt(socket_fd().get(), IPPROTO_IPV6, IPV6_JOIN_GROUP, &param, sizeof(param)); if (result < 0) { if (errno == ENODEV) { FX_LOGS(WARNING) << "fxbug.dev/21173 IPV6_JOIN_GROUP returned ENODEV, mDNS will " "not communicate via IPV6"; } else { FX_LOGS(ERROR) << "Failed to set socket option IPV6_JOIN_GROUP, " << strerror(errno); } } return result; } int MdnsInterfaceTransceiverV6::SetOptionOutboundInterface() { uint32_t index = this->index(); int result = setsockopt(socket_fd().get(), IPPROTO_IPV6, IPV6_MULTICAST_IF, &index, sizeof(index)); if (result < 0) { if (errno == EADDRNOTAVAIL) { // This is expected when the interface is removed as we try to use it. We still return // result < 0, because we don't want to use this interface. FX_LOGS(WARNING) << "Failed to set socket option IPV6_MULTICAST_IF, " << strerror(errno); } else { FX_LOGS(ERROR) << "Failed to set socket option IPV6_MULTICAST_IF, " << strerror(errno); } } return result; } int MdnsInterfaceTransceiverV6::SetOptionUnicastTtl() { int param = kTimeToLive_; int result = setsockopt(socket_fd().get(), IPPROTO_IPV6, IPV6_UNICAST_HOPS, &param, sizeof(param)); if (result < 0) { if (errno == ENOPROTOOPT) { // TODO(fxbug.dev/41357): remove the bug reference when the bug is fixed. FX_LOGS(WARNING) << "fxbug.dev/41357: IPV6_UNICAST_HOPS not supported (ENOPROTOOPT), continuing anyway"; result = 0; } else { FX_LOGS(ERROR) << "Failed to set socket option IPV6_UNICAST_HOPS, " << strerror(errno); } } return result; } int MdnsInterfaceTransceiverV6::SetOptionMulticastTtl() { int param = kTimeToLive_; int result = setsockopt(socket_fd().get(), IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &param, sizeof(param)); if (result < 0) { if (errno == ENOPROTOOPT) { FX_LOGS(WARNING) << "IPV6_MULTICAST_HOPS not supported (ENOPROTOOPT), continuing anyway"; result = 0; } else { FX_LOGS(ERROR) << "Failed to set socket option IPV6_MULTICAST_HOPS, " << strerror(errno); } } return result; } int MdnsInterfaceTransceiverV6::SetOptionFamilySpecific() { // Set hop limit. int param = 1; int result = setsockopt(socket_fd().get(), IPPROTO_IPV6, IPV6_HOPLIMIT, &param, sizeof(param)); if (result < 0) { if (errno == ENOPROTOOPT) { // TODO(fxbug.dev/41358): remove the bug reference when the bug is fixed. FX_LOGS(WARNING) << "fxbug.dev/41358: IPV6_HOPLIMIT not supported (ENOPROTOOPT), continuing anyway"; result = 0; } else { FX_LOGS(ERROR) << "Failed to set socket option IPV6_HOPLIMIT, " << strerror(errno); } return result; } // Receive V6 packets only. param = 1; result = setsockopt(socket_fd().get(), IPPROTO_IPV6, IPV6_V6ONLY, &param, sizeof(param)); if (result < 0) { FX_LOGS(ERROR) << "Failed to set socket option IPV6_V6ONLY, " << strerror(errno); return false; } return result; } int MdnsInterfaceTransceiverV6::Bind() { int result = bind(socket_fd().get(), MdnsAddresses::v6_bind().as_sockaddr(), MdnsAddresses::v6_bind().socklen()); if (result < 0) { FX_LOGS(ERROR) << "Failed to bind socket to V6 address, " << strerror(errno); } return result; } ssize_t MdnsInterfaceTransceiverV6::SendTo(const void* buffer, size_t size, const inet::SocketAddress& address) { if (address == MdnsAddresses::v4_multicast()) { // |v4_multicast| indicates multicast, meaning V6 multicast in this case. return sendto(socket_fd().get(), buffer, size, 0, MdnsAddresses::v6_multicast().as_sockaddr(), MdnsAddresses::v6_multicast().socklen()); } return sendto(socket_fd().get(), buffer, size, 0, address.as_sockaddr(), address.socklen()); } } // namespace mdns
// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/chromeos/extensions/gfx_utils.h" #include "base/containers/cxx20_erase.h" #include "base/cxx17_backports.h" #include "base/lazy_instance.h" #include "chrome/browser/ash/profiles/profile_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/pref_names.h" #include "chrome/grit/app_icon_resources.h" #include "components/prefs/pref_service.h" #include "extensions/browser/extension_registry.h" #include "extensions/common/constants.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia_operations.h" namespace extensions { namespace { // The badge map between |arc_package_name| and |extension_id|. Note the mapping // from |extension_id| to |arc_package_name| is unique, but the mapping from // |arc_package_name| to |extension_id| is not. const struct { const char* arc_package_name; const char* extension_id; } kDualBadgeMap[] = { // Google Keep {"com.google.android.keep", "hmjkmjkepdijhoojdojkdfohbdgmmhki"}, {"com.google.android.keep", "dondgdlndnpianbklfnehgdhkickdjck"}, // GMail {"com.google.android.gm", extension_misc::kGmailAppId}, {"com.google.android.gm", "bjdhhokmhgelphffoafoejjmlfblpdha"}, // Google Drive {"com.google.android.apps.docs", extension_misc::kGoogleDriveAppId}, {"com.google.android.apps.docs", "mdhnphfgagkpdhndljccoackjjhghlif"}, // Google Maps {"com.google.android.apps.maps", "lneaknkopdijkpnocmklfnjbeapigfbh"}, // Calculator {"com.google.android.calculator", "joodangkbfjnajiiifokapkpmhfnpleo"}, // Google Calender {"com.google.android.calendar", "ejjicmeblgpmajnghnpcppodonldlgfn"}, {"com.google.android.calendar", "fpgfohogebplgnamlafljlcidjedbdeb"}, // Google Docs {"com.google.android.apps.docs.editors.docs", extension_misc::kGoogleDocsAppId}, {"com.google.android.apps.docs.editors.docs", "npnjdccdffhdndcbeappiamcehbhjibf"}, // Google Slides {"com.google.android.apps.docs.editors.slides", extension_misc::kGoogleSlidesAppId}, {"com.google.android.apps.docs.editors.slides", "hdmobeajeoanbanmdlabnbnlopepchip"}, // Google Sheets {"com.google.android.apps.docs.editors.sheets", extension_misc::kGoogleSheetsAppId}, {"com.google.android.apps.docs.editors.sheets", "nifkmgcdokhkjghdlgflonppnefddien"}, // YouTube {"com.google.android.youtube", extension_misc::kYoutubeAppId}, {"com.google.android.youtube", "pbdihpaifchmclcmkfdgffnnpfbobefh"}, // Google Play Books {"com.google.android.apps.books", extension_misc::kGooglePlayBooksAppId}, // Google+ {"com.google.android.apps.plus", "dlppkpafhbajpcmmoheippocdidnckmm"}, {"com.google.android.apps.plus", "fgjnkhlabjcaajddbaenilcmpcidahll"}, // Google Play Movies & TV {"com.google.android.videos", extension_misc::kGooglePlayMoviesAppId}, {"com.google.android.videos", "amfoiggnkefambnaaphodjdmdooiinna"}, // Google Play Music {"com.google.android.music", extension_misc::kGooglePlayMusicAppId}, {"com.google.android.music", "onbhgdmifjebcabplolilidlpgeknifi"}, // Google Now {"com.google.android.launcher", "mnfadmojomeniojkkikjpgjaegolkbpb"}, // Google Photos {"com.google.android.apps.photos", "hcglmfcclpfgljeaiahehebeoaiicbko"}, {"com.google.android.apps.photos", "efjnaogkjbogokcnohkmnjdojkikgobo"}, {"com.google.android.apps.photos", "ifpkhncdnjfipfjlhfidljjffdgklanh"}, // Google Classroom {"com.google.android.apps.classroom", "mfhehppjhmmnlfbbopchdfldgimhfhfk"}, // Google Hangouts {"com.google.android.talk", "knipolnnllmklapflnccelgolnpehhpl"}, {"com.google.android.talk", "cgmlfbhkckbedohgdepgbkflommbfkep"}, {"com.google.android.talk", "gldgpnmcpaogjlojhhpebkbbanacoglc"}, // Google Play Music {"com.google.android.music", "fahmaaghhglfmonjliepjlchgpgfmobi"}, // Google News {"com.google.android.apps.genie.geniewidget", "dllkocilcinkggkchnjgegijklcililc"}, // Used in unit tests. {"fake.package.name1", "emfkafnhnpcmabnnkckkchdilgeoekbo"}, }; // This class maintains the maps between the extension id and its equivalent // ARC package name. class AppDualBadgeMap { public: using ArcAppToExtensionsMap = std::unordered_map<std::string, std::vector<std::string>>; using ExtensionToArcAppMap = std::unordered_map<std::string, std::string>; AppDualBadgeMap() { for (size_t i = 0; i < base::size(kDualBadgeMap); ++i) { arc_app_to_extensions_map_[kDualBadgeMap[i].arc_package_name].push_back( kDualBadgeMap[i].extension_id); extension_to_arc_app_map_[kDualBadgeMap[i].extension_id] = kDualBadgeMap[i].arc_package_name; } } AppDualBadgeMap(const AppDualBadgeMap&) = delete; AppDualBadgeMap& operator=(const AppDualBadgeMap&) = delete; std::vector<std::string> GetExtensionIdsForArcPackageName( std::string arc_package_name) { const auto iter = arc_app_to_extensions_map_.find(arc_package_name); if (iter == arc_app_to_extensions_map_.end()) return std::vector<std::string>(); return iter->second; } std::string GetArcPackageNameFromExtensionId(std::string extension_id) { const auto iter = extension_to_arc_app_map_.find(extension_id); if (iter == extension_to_arc_app_map_.end()) return std::string(); return iter->second; } private: ArcAppToExtensionsMap arc_app_to_extensions_map_; ExtensionToArcAppMap extension_to_arc_app_map_; }; base::LazyInstance<AppDualBadgeMap>::DestructorAtExit g_dual_badge_map = LAZY_INSTANCE_INITIALIZER; } // namespace namespace util { bool HasEquivalentInstalledArcApp(content::BrowserContext* context, const std::string& extension_id) { std::unordered_set<std::string> arc_apps; return GetEquivalentInstalledArcApps(context, extension_id, &arc_apps); } bool GetEquivalentInstalledArcApps(content::BrowserContext* context, const std::string& extension_id, std::unordered_set<std::string>* arc_apps) { const std::string arc_package_name = g_dual_badge_map.Get().GetArcPackageNameFromExtensionId(extension_id); if (arc_package_name.empty()) return false; const ArcAppListPrefs* const prefs = ArcAppListPrefs::Get(context); if (!prefs) return false; // TODO(hidehiko): The icon is per launcher, so we should have more precise // check here. DCHECK(arc_apps); prefs->GetAppsForPackage(arc_package_name).swap(*arc_apps); return !arc_apps->empty(); } const std::vector<std::string> GetEquivalentInstalledAppIds( const std::string& arc_package_name) { return g_dual_badge_map.Get().GetExtensionIdsForArcPackageName( arc_package_name); } const std::vector<std::string> GetEquivalentInstalledExtensions( content::BrowserContext* context, const std::string& arc_package_name) { const ExtensionRegistry* registry = ExtensionRegistry::Get(context); if (!registry) return std::vector<std::string>(); std::vector<std::string> extension_ids = g_dual_badge_map.Get().GetExtensionIdsForArcPackageName(arc_package_name); if (extension_ids.empty()) return std::vector<std::string>(); base::EraseIf(extension_ids, [registry](std::string extension_id) { return !registry->GetInstalledExtension(extension_id); }); return extension_ids; } bool ShouldApplyChromeBadge(content::BrowserContext* context, const std::string& extension_id) { DCHECK(context); Profile* profile = Profile::FromBrowserContext(context); // Only apply Chrome badge for the primary profile. if (!chromeos::ProfileHelper::IsPrimaryProfile(profile) || !multi_user_util::IsProfileFromActiveUser(profile)) { return false; } const ExtensionRegistry* registry = ExtensionRegistry::Get(context); if (!registry || !registry->GetInstalledExtension(extension_id)) return false; if (!HasEquivalentInstalledArcApp(context, extension_id)) return false; return true; } bool ShouldApplyChromeBadgeToWebApp(content::BrowserContext* context, const std::string& web_app_id) { DCHECK(context); Profile* profile = Profile::FromBrowserContext(context); // Only apply Chrome badge for the primary profile. if (!chromeos::ProfileHelper::IsPrimaryProfile(profile) || !multi_user_util::IsProfileFromActiveUser(profile)) { return false; } if (!HasEquivalentInstalledArcApp(context, web_app_id)) return false; return true; } void ApplyBadge(gfx::ImageSkia* icon_out, ChromeAppIcon::Badge badge_type) { DCHECK(icon_out); DCHECK_NE(ChromeAppIcon::Badge::kNone, badge_type); int badge_res = 0; switch (badge_type) { case ChromeAppIcon::Badge::kChrome: badge_res = IDR_CHROME_ICON_BADGE; break; case ChromeAppIcon::Badge::kBlocked: badge_res = IDR_BLOCK_ICON_BADGE; break; case ChromeAppIcon::Badge::kPaused: badge_res = IDR_HOURGLASS_ICON_BADGE; break; default: NOTREACHED(); } const gfx::ImageSkia* badge_image = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(badge_res); DCHECK(badge_image); gfx::ImageSkia resized_badge_image = *badge_image; if (badge_image->size() != icon_out->size()) { resized_badge_image = gfx::ImageSkiaOperations::CreateResizedImage( *badge_image, skia::ImageOperations::RESIZE_BEST, icon_out->size()); } *icon_out = gfx::ImageSkiaOperations::CreateSuperimposedImage( *icon_out, resized_badge_image); } } // namespace util } // namespace extensions
// Copyright 2018 The Crashpad Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "snapshot/fuchsia/exception_snapshot_fuchsia.h" #include "base/numerics/safe_conversions.h" #include "snapshot/fuchsia/cpu_context_fuchsia.h" #include "snapshot/fuchsia/process_reader_fuchsia.h" namespace crashpad { namespace internal { ExceptionSnapshotFuchsia::ExceptionSnapshotFuchsia() = default; ExceptionSnapshotFuchsia::~ExceptionSnapshotFuchsia() = default; void ExceptionSnapshotFuchsia::Initialize( ProcessReaderFuchsia* process_reader, zx_koid_t thread_id, const zx_exception_report_t& exception_report) { INITIALIZATION_STATE_SET_INITIALIZING(initialized_); exception_ = exception_report.header.type; thread_id_ = thread_id; // TODO(scottmg): Not sure whether these values for exception_info_ are // helpful or correct. Other values in the structures are stored below into // Codes() in case they are useful. #if defined(ARCH_CPU_X86_64) DCHECK(base::IsValueInRangeForNumericType<uint32_t>( exception_report.context.arch.u.x86_64.err_code)); exception_info_ = exception_report.context.arch.u.x86_64.err_code; #elif defined(ARCH_CPU_ARM64) exception_info_ = exception_report.context.arch.u.arm_64.esr; #endif codes_.push_back(exception_); codes_.push_back(exception_info_); #if defined(ARCH_CPU_X86_64) codes_.push_back(exception_report.context.arch.u.x86_64.vector); codes_.push_back(exception_report.context.arch.u.x86_64.cr2); #elif defined(ARCH_CPU_ARM64) codes_.push_back(exception_report.context.arch.u.arm_64.far); #endif for (const auto& t : process_reader->Threads()) { if (t.id == thread_id) { #if defined(ARCH_CPU_X86_64) context_.architecture = kCPUArchitectureX86_64; context_.x86_64 = &context_arch_; // TODO(fuchsia/DX-642): Add float context once saved in |t|. InitializeCPUContextX86_64_NoFloatingPoint(t.general_registers, context_.x86_64); #elif defined(ARCH_CPU_ARM64) context_.architecture = kCPUArchitectureARM64; context_.arm64 = &context_arch_; InitializeCPUContextARM64( t.general_registers, t.vector_registers, context_.arm64); #else #error Port. #endif } } if (context_.InstructionPointer() != 0 && (exception_ == ZX_EXCP_UNDEFINED_INSTRUCTION || exception_ == ZX_EXCP_SW_BREAKPOINT || exception_ == ZX_EXCP_HW_BREAKPOINT)) { exception_address_ = context_.InstructionPointer(); } else { #if defined(ARCH_CPU_X86_64) exception_address_ = exception_report.context.arch.u.x86_64.cr2; #elif defined(ARCH_CPU_ARM64) exception_address_ = exception_report.context.arch.u.arm_64.far; #endif } INITIALIZATION_STATE_SET_VALID(initialized_); } const CPUContext* ExceptionSnapshotFuchsia::Context() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return &context_; } uint64_t ExceptionSnapshotFuchsia::ThreadID() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return thread_id_; } uint32_t ExceptionSnapshotFuchsia::Exception() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return exception_; } uint32_t ExceptionSnapshotFuchsia::ExceptionInfo() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return exception_info_; } uint64_t ExceptionSnapshotFuchsia::ExceptionAddress() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return exception_address_; } const std::vector<uint64_t>& ExceptionSnapshotFuchsia::Codes() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return codes_; } std::vector<const MemorySnapshot*> ExceptionSnapshotFuchsia::ExtraMemory() const { INITIALIZATION_STATE_DCHECK_VALID(initialized_); return std::vector<const MemorySnapshot*>(); } } // namespace internal } // namespace crashpad
// Copyright (C) 2018-2022 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "behavior/ov_infer_request/callback.hpp" using namespace ov::test::behavior; namespace { const std::vector<std::map<std::string, std::string>> configs = { {}, }; const std::vector<std::map<std::string, std::string>> multiConfigs = { {{MULTI_CONFIG_KEY(DEVICE_PRIORITIES) , CommonTestUtils::DEVICE_GNA}} }; INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, OVInferRequestCallbackTests, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::ValuesIn(configs)), OVInferRequestCallbackTests::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_Multi_BehaviorTests, OVInferRequestCallbackTests, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_MULTI), ::testing::ValuesIn(multiConfigs)), OVInferRequestCallbackTests::getTestCaseName); } // namespace
// syncclusterconnection.cpp /* * Copyright 2010 10gen Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * As a special exception, the copyright holders give permission to link the * code of portions of this program with the OpenSSL library under certain * conditions as described in each individual source file and distribute * linked combinations including the program with the OpenSSL library. You * must comply with the GNU Affero General Public License in all respects * for all of the code used other than as permitted herein. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you do not * wish to do so, delete this exception statement from your version. If you * delete this exception statement from all source files in the program, * then also delete it in the license file. */ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kNetwork #include "mongo/platform/basic.h" #include "mongo/client/syncclusterconnection.h" #include "mongo/client/dbclientcursor.h" #include "mongo/client/dbclientinterface.h" #include "mongo/db/dbmessage.h" #include "mongo/db/namespace_string.h" #include "mongo/util/log.h" // error codes 8000-8009 namespace mongo { using std::unique_ptr; using std::endl; using std::list; using std::map; using std::string; using std::stringstream; using std::vector; SyncClusterConnection::SyncClusterConnection( const list<HostAndPort> & L, double socketTimeout) : _socketTimeout(socketTimeout) { { stringstream s; int n=0; for( list<HostAndPort>::const_iterator i = L.begin(); i != L.end(); i++ ) { if( ++n > 1 ) s << ','; s << i->toString(); } _address = s.str(); } for( list<HostAndPort>::const_iterator i = L.begin(); i != L.end(); i++ ) _connect( i->toString() ); } SyncClusterConnection::SyncClusterConnection( string commaSeparated, double socketTimeout) : _socketTimeout( socketTimeout ) { _address = commaSeparated; string::size_type idx; while ( ( idx = commaSeparated.find( ',' ) ) != string::npos ) { string h = commaSeparated.substr( 0 , idx ); commaSeparated = commaSeparated.substr( idx + 1 ); _connect( h ); } _connect( commaSeparated ); uassert( 8004 , "SyncClusterConnection needs 3 servers" , _conns.size() == 3 ); } SyncClusterConnection::SyncClusterConnection( const std::string& a, const std::string& b, const std::string& c, double socketTimeout) : _socketTimeout( socketTimeout ) { _address = a + "," + b + "," + c; // connect to all even if not working _connect( a ); _connect( b ); _connect( c ); } SyncClusterConnection::SyncClusterConnection( SyncClusterConnection& prev, double socketTimeout) : _socketTimeout(socketTimeout) { verify(0); } SyncClusterConnection::~SyncClusterConnection() { for ( size_t i=0; i<_conns.size(); i++ ) delete _conns[i]; _conns.clear(); } bool SyncClusterConnection::prepare(string& errmsg) { _lastErrors.clear(); bool ok = true; errmsg = ""; for (size_t i = 0; i < _conns.size(); i++) { string singleErr; try { _conns[i]->simpleCommand("admin", NULL, "resetError"); singleErr = _conns[i]->getLastError(true); if (singleErr.size() == 0) continue; } catch (DBException& e) { singleErr = e.toString(); } ok = false; errmsg += " " + _conns[i]->toString() + ":" + singleErr; } return ok; } void SyncClusterConnection::_checkLast() { _lastErrors.clear(); vector<string> errors; for ( size_t i=0; i<_conns.size(); i++ ) { BSONObj res; string err; try { if ( ! _conns[i]->runCommand( "admin" , BSON( "getlasterror" << 1 << "fsync" << 1 ) , res ) ) err = "cmd failed: "; } catch ( std::exception& e ) { err += e.what(); } catch ( ... ) { err += "unknown failure"; } _lastErrors.push_back( res.getOwned() ); errors.push_back( err ); } verify( _lastErrors.size() == errors.size() && _lastErrors.size() == _conns.size() ); stringstream err; bool ok = true; for ( size_t i = 0; i<_conns.size(); i++ ) { BSONObj res = _lastErrors[i]; if ( res["ok"].trueValue() && (res["fsyncFiles"].numberInt() > 0 || res.hasElement("waited") || res["syncMillis"].numberInt() >= 0 ) ) continue; ok = false; err << _conns[i]->toString() << ": " << res << " " << errors[i]; } if ( ok ) return; throw UserException( 8001 , (string)"SyncClusterConnection write op failed: " + err.str() ); } BSONObj SyncClusterConnection::getLastErrorDetailed(bool fsync, bool j, int w, int wtimeout) { return getLastErrorDetailed("admin", fsync, j, w, wtimeout); } BSONObj SyncClusterConnection::getLastErrorDetailed(const std::string& db, bool fsync, bool j, int w, int wtimeout) { if ( _lastErrors.size() ) return _lastErrors[0]; return DBClientBase::getLastErrorDetailed(db,fsync,j,w,wtimeout); } void SyncClusterConnection::_connect( const std::string& host ) { log() << "SyncClusterConnection connecting to [" << host << "]" << endl; DBClientConnection * c = new DBClientConnection( true ); c->setRequestMetadataWriter(getRequestMetadataWriter()); c->setReplyMetadataReader(getReplyMetadataReader()); c->setSoTimeout( _socketTimeout ); string errmsg; if ( ! c->connect( HostAndPort(host), errmsg ) ) log() << "SyncClusterConnection connect fail to: " << host << " errmsg: " << errmsg << endl; _connAddresses.push_back( host ); _conns.push_back( c ); } bool SyncClusterConnection::callRead( Message& toSend , Message& response ) { // TODO: need to save state of which one to go back to somehow... return _conns[0]->callRead( toSend , response ); } bool SyncClusterConnection::runCommand(const std::string& dbname, const BSONObj& cmd, BSONObj& info, int options) { std::string ns = dbname + ".$cmd"; BSONObj interposedCmd = cmd; if (getRequestMetadataWriter()) { // We have a metadata writer. We need to upconvert the metadata, write to it, // Then downconvert it again. This unfortunate, but this code is going to be // removed anyway as part of CSRS. BSONObj upconvertedCommand; BSONObj upconvertedMetadata; std::tie(upconvertedCommand, upconvertedMetadata) = uassertStatusOK( rpc::upconvertRequestMetadata(cmd, options) ); BSONObjBuilder metadataBob; metadataBob.appendElements(upconvertedMetadata); uassertStatusOK(getRequestMetadataWriter()(&metadataBob)); std::tie(interposedCmd, options) = uassertStatusOK( rpc::downconvertRequestMetadata(std::move(upconvertedCommand), metadataBob.done()) ); } BSONObj legacyResult = findOne(ns, Query(interposedCmd), 0, options); BSONObj upconvertedMetadata; BSONObj upconvertedReply; std::tie(upconvertedReply, upconvertedMetadata) = uassertStatusOK( rpc::upconvertReplyMetadata(legacyResult) ); if (getReplyMetadataReader()) { // TODO: what does getServerAddress() actually mean here as this connection // represents a connection to 1 or 3 config servers... uassertStatusOK(getReplyMetadataReader()(upconvertedReply, getServerAddress())); } info = upconvertedReply; return isOk(info); } BSONObj SyncClusterConnection::findOne(const string &ns, const Query& query, const BSONObj *fieldsToReturn, int queryOptions) { if ( ns.find( ".$cmd" ) != string::npos ) { string cmdName = query.obj.firstElementFieldName(); int lockType = _lockType( cmdName ); if ( lockType > 0 ) { // write $cmd string errmsg; if ( ! prepare( errmsg ) ) throw UserException( PrepareConfigsFailedCode , (string)"SyncClusterConnection::findOne prepare failed: " + errmsg ); vector<BSONObj> all; for ( size_t i=0; i<_conns.size(); i++ ) { all.push_back( _conns[i]->findOne( ns , query , 0 , queryOptions ).getOwned() ); } _checkLast(); for ( size_t i=0; i<all.size(); i++ ) { BSONObj temp = all[i]; if ( isOk( temp ) ) continue; stringstream ss; ss << "write $cmd failed on a node: " << temp.jsonString(); ss << " " << _conns[i]->toString(); ss << " ns: " << ns; ss << " cmd: " << query.toString(); throw UserException( 13105 , ss.str() ); } return all[0]; } } return DBClientBase::findOne( ns , query , fieldsToReturn , queryOptions ); } void SyncClusterConnection::_auth(const BSONObj& params) { // A SCC is authenticated if any connection has been authenticated // Credentials are stored in the auto-reconnect connections. bool authedOnce = false; vector<string> errors; for ( vector<DBClientConnection*>::iterator it = _conns.begin(); it < _conns.end(); ++it ) { massert( 15848, "sync cluster of sync clusters?", (*it)->type() != ConnectionString::SYNC ); // Authenticate or collect the error message string lastErrmsg; bool authed; try { // Auth errors can manifest either as exceptions or as false results // TODO: Make this better (*it)->auth(params); authed = true; } catch ( const DBException& e ) { // auth will be retried on reconnect lastErrmsg = e.what(); authed = false; } if ( ! authed ) { // Since we're using auto-reconnect connections, we're sure the auth info has been // stored if needed for later lastErrmsg = str::stream() << "auth error on " << (*it)->getServerAddress() << causedBy( lastErrmsg ); LOG(1) << lastErrmsg << endl; errors.push_back( lastErrmsg ); } authedOnce = authedOnce || authed; } if( authedOnce ) return; // Assemble the error message str::stream errStream; for( vector<string>::iterator it = errors.begin(); it != errors.end(); ++it ){ if( it != errors.begin() ) errStream << " ::and:: "; errStream << *it; } uasserted(ErrorCodes::AuthenticationFailed, errStream); } // TODO: logout is required for use of this class outside of a cluster environment unique_ptr<DBClientCursor> SyncClusterConnection::query(const string &ns, Query query, int nToReturn, int nToSkip, const BSONObj *fieldsToReturn, int queryOptions, int batchSize ) { _lastErrors.clear(); if ( ns.find( ".$cmd" ) != string::npos ) { string cmdName = query.obj.firstElementFieldName(); int lockType = _lockType( cmdName ); uassert( 13054 , (string)"write $cmd not supported in SyncClusterConnection::query for:" + cmdName , lockType <= 0 ); } return _queryOnActive( ns , query , nToReturn , nToSkip , fieldsToReturn , queryOptions , batchSize ); } bool SyncClusterConnection::_commandOnActive(const string &dbname, const BSONObj& cmd, BSONObj &info, int options ) { unique_ptr<DBClientCursor> cursor = _queryOnActive(dbname + ".$cmd", cmd, 1, 0, 0, options, 0); if ( cursor->more() ) info = cursor->next().copy(); else info = BSONObj(); return isOk( info ); } void SyncClusterConnection::attachQueryHandler( QueryHandler* handler ) { _customQueryHandler.reset( handler ); } unique_ptr<DBClientCursor> SyncClusterConnection::_queryOnActive(const string &ns, Query query, int nToReturn, int nToSkip, const BSONObj *fieldsToReturn, int queryOptions, int batchSize ) { if ( _customQueryHandler && _customQueryHandler->canHandleQuery( ns, query ) ) { LOG( 2 ) << "custom query handler used for query on " << ns << ": " << query.toString() << endl; return _customQueryHandler->handleQuery( _connAddresses, ns, query, nToReturn, nToSkip, fieldsToReturn, queryOptions, batchSize ); } for ( size_t i=0; i<_conns.size(); i++ ) { try { unique_ptr<DBClientCursor> cursor = _conns[i]->query( ns , query , nToReturn , nToSkip , fieldsToReturn , queryOptions , batchSize ); if ( cursor.get() ) return cursor; log() << "query on " << ns << ": " << query.toString() << " failed to: " << _conns[i]->toString() << " no data" << endl; } catch ( std::exception& e ) { log() << "query on " << ns << ": " << query.toString() << " failed to: " << _conns[i]->toString() << " exception: " << e.what() << endl; } catch ( ... ) { log() << "query on " << ns << ": " << query.toString() << " failed to: " << _conns[i]->toString() << " exception" << endl; } } throw UserException( 8002 , str::stream() << "all servers down/unreachable when querying: " << _address ); } unique_ptr<DBClientCursor> SyncClusterConnection::getMore( const string &ns, long long cursorId, int nToReturn, int options ) { uassert( 10022 , "SyncClusterConnection::getMore not supported yet" , 0); unique_ptr<DBClientCursor> c; return c; } void SyncClusterConnection::insert( const string &ns, BSONObj obj , int flags) { uassert(13119, str::stream() << "SyncClusterConnection::insert obj has to have an _id: " << obj, nsToCollectionSubstring(ns) == "system.indexes" || obj["_id"].type()); string errmsg; if ( ! prepare( errmsg ) ) throw UserException( 8003 , (string)"SyncClusterConnection::insert prepare failed: " + errmsg ); for ( size_t i=0; i<_conns.size(); i++ ) { _conns[i]->insert( ns , obj , flags); } _checkLast(); } void SyncClusterConnection::insert( const string &ns, const vector< BSONObj >& v , int flags) { if (v.size() == 1){ insert(ns, v[0], flags); return; } for (vector<BSONObj>::const_iterator it = v.begin(); it != v.end(); ++it ) { BSONObj obj = *it; if ( obj["_id"].type() == EOO ) { string assertMsg = "SyncClusterConnection::insert (batched) obj misses an _id: "; uasserted( 16743, assertMsg + obj.jsonString() ); } } // fsync all connections before starting the batch. string errmsg; if ( ! prepare( errmsg ) ) { string assertMsg = "SyncClusterConnection::insert (batched) prepare failed: "; throw UserException( 16744, assertMsg + errmsg ); } // We still want one getlasterror per document, even if they're batched. for ( size_t i=0; i<_conns.size(); i++ ) { for ( vector<BSONObj>::const_iterator it = v.begin(); it != v.end(); ++it ) { _conns[i]->insert( ns, *it, flags ); _conns[i]->getLastErrorDetailed(); } } // We issue a final getlasterror, but this time with an fsync. _checkLast(); } void SyncClusterConnection::remove( const string &ns , Query query, int flags ) { string errmsg; if ( ! prepare( errmsg ) ) throw UserException( 8020 , (string)"SyncClusterConnection::remove prepare failed: " + errmsg ); for ( size_t i=0; i<_conns.size(); i++ ) { _conns[i]->remove( ns , query , flags ); } _checkLast(); } void SyncClusterConnection::update(const string &ns, Query query, BSONObj obj, int flags) { if ( flags & UpdateOption_Upsert ) { uassert(13120, "SyncClusterConnection::update upsert query needs _id", query.obj["_id"].type()); } string errmsg; if (!prepare(errmsg)) { throw UserException(8005, str::stream() << "SyncClusterConnection::update prepare failed: " << errmsg); } for (size_t i = 0; i < _conns.size(); i++) { _conns[i]->update(ns, query, obj, flags); } _checkLast(); invariant(_lastErrors.size() > 1); const int a = _lastErrors[0]["n"].numberInt(); for (unsigned i = 1; i < _lastErrors.size(); i++) { int b = _lastErrors[i]["n"].numberInt(); if (a == b) continue; throw UpdateNotTheSame(8017, str::stream() << "update not consistent " << " ns: " << ns << " query: " << query.toString() << " update: " << obj << " gle1: " << _lastErrors[0] << " gle2: " << _lastErrors[i], _connAddresses, _lastErrors); } } string SyncClusterConnection::_toString() const { stringstream ss; ss << "SyncClusterConnection "; ss << " ["; for ( size_t i = 0; i < _conns.size(); i++ ) { if ( i != 0 ) ss << ","; if ( _conns[i] ) { ss << _conns[i]->toString(); } else { ss << "(no conn)"; } } ss << "]"; return ss.str(); } bool SyncClusterConnection::call( Message &toSend, Message &response, bool assertOk , string * actualServer ) { uassert( 8006 , "SyncClusterConnection::call can only be used directly for dbQuery" , toSend.operation() == dbQuery ); DbMessage d( toSend ); uassert( 8007 , "SyncClusterConnection::call can't handle $cmd" , strstr( d.getns(), "$cmd" ) == 0 ); for ( size_t i=0; i<_conns.size(); i++ ) { try { bool ok = _conns[i]->call( toSend , response , assertOk ); if ( ok ) { if ( actualServer ) *actualServer = _connAddresses[i]; return ok; } log() << "call failed to: " << _conns[i]->toString() << " no data" << endl; } catch ( ... ) { log() << "call failed to: " << _conns[i]->toString() << " exception" << endl; } } throw UserException( 8008 , str::stream() << "all servers down/unreachable: " << _address ); } void SyncClusterConnection::say( Message &toSend, bool isRetry , string * actualServer ) { string errmsg; if ( ! prepare( errmsg ) ) throw UserException( 13397 , (string)"SyncClusterConnection::say prepare failed: " + errmsg ); for ( size_t i=0; i<_conns.size(); i++ ) { _conns[i]->say( toSend ); } // TODO: should we set actualServer?? _checkLast(); } void SyncClusterConnection::sayPiggyBack( Message &toSend ) { verify(0); } int SyncClusterConnection::_lockType( const string& name ) { { stdx::lock_guard<stdx::mutex> lk(_mutex); map<string,int>::iterator i = _lockTypes.find( name ); if ( i != _lockTypes.end() ) return i->second; } BSONObj info; uassert( 13053 , str::stream() << "help failed: " << info , _commandOnActive( "admin" , BSON( name << "1" << "help" << 1 ) , info ) ); int lockType = info["lockType"].numberInt(); stdx::lock_guard<stdx::mutex> lk(_mutex); _lockTypes[name] = lockType; return lockType; } void SyncClusterConnection::killCursor( long long cursorID ) { // should never need to do this verify(0); } // A SCC should be reused only if all the existing connections haven't been broken in the // background. // Note: an SCC may have missing connections if a config server is temporarily offline, // but reading from the others is still allowed. bool SyncClusterConnection::isStillConnected() { for ( size_t i = 0; i < _conns.size(); i++ ) { if ( _conns[i] && !_conns[i]->isStillConnected() ) return false; } return true; } void SyncClusterConnection::setAllSoTimeouts( double socketTimeout ){ _socketTimeout = socketTimeout; for ( size_t i=0; i<_conns.size(); i++ ) if( _conns[i] ) _conns[i]->setSoTimeout( socketTimeout ); } void SyncClusterConnection::setRequestMetadataWriter(rpc::RequestMetadataWriter writer) { // Set the hooks in both our sub-connections and in ourselves. for (size_t i = 0; i < _conns.size(); ++i) { if (_conns[i]) { _conns[i]->setRequestMetadataWriter(writer); } } DBClientWithCommands::setRequestMetadataWriter(std::move(writer)); } void SyncClusterConnection::setReplyMetadataReader(rpc::ReplyMetadataReader reader) { // Set the hooks in both our sub-connections and in ourselves. for (size_t i = 0; i < _conns.size(); ++i) { if (_conns[i]) { _conns[i]->setReplyMetadataReader(reader); } } DBClientWithCommands::setReplyMetadataReader(std::move(reader)); } }
/************************************************************** * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * *************************************************************/ #ifndef __FRAMEWORK_DISPATCH_CLOSEDISPATCHER_HXX_ #define __FRAMEWORK_DISPATCH_CLOSEDISPATCHER_HXX_ //_______________________________________________ // my own includes #include <threadhelp/threadhelpbase.hxx> #include <macros/xinterface.hxx> #include <macros/xtypeprovider.hxx> #include <macros/debug.hxx> #include <macros/generic.hxx> #include <stdtypes.h> #include <general.h> //_______________________________________________ // interface includes #include <com/sun/star/lang/XTypeProvider.hpp> #include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/frame/XStatusListener.hpp> #include <com/sun/star/frame/XNotifyingDispatch.hpp> #include <com/sun/star/frame/XDispatchInformationProvider.hpp> #include <com/sun/star/util/URL.hpp> #include <com/sun/star/frame/XDispatchResultListener.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/frame/DispatchResultState.hpp> //_______________________________________________ // other includes #include <cppuhelper/weak.hxx> #include <vcl/evntpost.hxx> //_______________________________________________ // namespace namespace framework{ //----------------------------------------------- /** @short helper to dispatch the URLs ".uno:CloseDoc"/".uno:CloseWin"/".uno:CloseFrame" to close a frame/document or the whole application implicitly in case it was the last frame @descr These URLs implements a special functionality to close a document or the whole frame ... and handle the state, it was the last frame or document. Then we create the default backing document which can be used to open new ones using the file open dialog or some other menu entries. Or we terminate the whole application in case this backing mode shouldn't be used. */ class CloseDispatcher : public css::lang::XTypeProvider , public css::frame::XNotifyingDispatch // => XDispatch , public css::frame::XDispatchInformationProvider // baseclasses ... order is necessary for right initialization! , private ThreadHelpBase , public ::cppu::OWeakObject { //------------------------------------------- // types private: //--------------------------------------- /** @short describe, which request must be done here. @descr The incoming URLs {.uno:CloseDoc/CloseWin and CloseFrame can be classified so and checked later performant.}*/ enum EOperation { E_CLOSE_DOC, E_CLOSE_FRAME, E_CLOSE_WIN }; //------------------------------------------- // member private: //--------------------------------------- /** @short reference to an uno service manager, which can be used to create own needed uno resources. */ css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; //--------------------------------------- /** @short reference to the target frame, which should be closed by this dispatch. */ css::uno::WeakReference< css::frame::XFrame > m_xCloseFrame; //--------------------------------------- /** @short used for asynchronous callbacks within the main thread. @descr Internaly we work asynchronous. Because our callis are not aware, that her request can kill its own environment ... */ ::vcl::EventPoster m_aAsyncCallback; //--------------------------------------- /** @short used inside asyncronous callback to decide, which operation must be executed. */ EOperation m_eOperation; //--------------------------------------- /** @short for asynchronous operations we must hold us self alive! */ css::uno::Reference< css::uno::XInterface > m_xSelfHold; //--------------------------------------- /** @short list of registered status listener */ ListenerHash m_lStatusListener; //--------------------------------------- /** @short holded alive for internaly asynchronous operations! */ css::uno::Reference< css::frame::XDispatchResultListener > m_xResultListener; //------------------------------------------- // native interface public: //--------------------------------------- /** @short connect a new CloseDispatcher instance to its frame. @descr One CloseDispatcher instance is bound to onw frame only. That makes an implementation (e.g. of listener support) much more easier .-) @param xSMGR an un oservice manager, which is needed to create uno resource internaly. @param xFrame the frame where the corresponding dispatch was started. @param sTarget help us to find the right target for this close operation. */ CloseDispatcher(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR , const css::uno::Reference< css::frame::XFrame >& xFrame , const ::rtl::OUString& sTarget); //--------------------------------------- /** @short does nothing real. */ virtual ~CloseDispatcher(); //------------------------------------------- // uno interface public: //--------------------------------------- FWK_DECLARE_XINTERFACE FWK_DECLARE_XTYPEPROVIDER //--------------------------------------- // XNotifyingDispatch virtual void SAL_CALL dispatchWithNotification( const css::util::URL& aURL , const css::uno::Sequence< css::beans::PropertyValue >& lArguments, const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw(css::uno::RuntimeException); //--------------------------------------- // XDispatch virtual void SAL_CALL dispatch ( const css::util::URL& aURL , const css::uno::Sequence< css::beans::PropertyValue >& lArguments) throw(css::uno::RuntimeException); virtual void SAL_CALL addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xListener , const css::util::URL& aURL ) throw(css::uno::RuntimeException); virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener , const css::util::URL& aURL ) throw(css::uno::RuntimeException); //--------------------------------------- // XDispatchInformationProvider virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSupportedCommandGroups ( ) throw (css::uno::RuntimeException); virtual css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL getConfigurableDispatchInformation( sal_Int16 nCommandGroup ) throw (css::uno::RuntimeException); //------------------------------------------- // internal helper private: //--------------------------------------- /** @short a callback for asynchronous started operations. @descr As already mentione, we make internaly all operations asynchronous. Otherwhise our callis kill its own environment during they call us ... */ DECL_LINK( impl_asyncCallback, void* ); //--------------------------------------- /** @short prepare m_xCloseFrame so it should be closeable without problems. @descr Thats needed to be sure, that the document can't disagree later with e.g. an office termination. The problem: Closing of documents can show UI. If the user ignores it and open/close other documents, we can't know which state the office has after closing of this frame. @param bAllowSuspend force calling of XController->suspend(). @param bCloseAllOtherViewsToo if there are other top level frames, which contains views to the same document then our m_xCloseFrame, they are forced to be closed too. We need it to implement the CLOSE_DOC semantic. @return [boolean] sal_True if closing was successfully. */ sal_Bool implts_prepareFrameForClosing(const css::uno::Reference< css::frame::XFrame >& xFrame , sal_Bool bAllowSuspend , sal_Bool bCloseAllOtherViewsToo, sal_Bool& bControllerSuspended ); //--------------------------------------- /** @short close the member m_xCloseFrame. @descr This method does not look for any document inside this frame. Such views must be cleared before (e.g. by calling implts_closeView()! Otherwhise e.g. the XController->suspend() call isn't made and no UI warn the user about losing document changes. Because the frame is closed .... @return [bool] sal_True if closing was successfully. */ sal_Bool implts_closeFrame(); //--------------------------------------- /** @short set the special BackingComponent (now StartModule) as new component of our m_xCloseFrame. @return [bool] sal_True if operation was successfully. */ sal_Bool implts_establishBackingMode(); //--------------------------------------- /** @short calls XDesktop->terminate(). @descr No office code has to be called afterwards! Because the process is dying ... The only exception is a might be registered listener at this instance here. Because he should know, that such things will happen :-) @return [bool] sal_True if termination of the application was started ... */ sal_Bool implts_terminateApplication(); //--------------------------------------- /** @short notify a DispatchResultListener. @descr We check the listener reference before we use it. So this method can be called everytimes! @parama xListener the listener, which should be notified. Can be null! @param nState directly used as css::frame::DispatchResultState value. @param aResult not used yet really ... */ void implts_notifyResultListener(const css::uno::Reference< css::frame::XDispatchResultListener >& xListener, sal_Int16 nState , const css::uno::Any& aResult ); //--------------------------------------- /** @short try to find the right target frame where this close request must be really done. @descr The problem behind: closing some resources depends sometimes from the context where its dispatched. Sometimes the start frame of the dispatch has to be closed itself (target=_self) ... sometimes it's parent frame has to be closed - BUT(!) it means a parent frame containing a top level window. _top can't be used then for dispatch - because it address TopFrames not frames containg top level windows. So normaly _magic (which btw does not exists at the moment .-) ) should be used. So we interpret target=<empty> as _magic ! @param xFrame start point for search of right dispatch frame. @param sTarget give us an idea how this target frame must be searched. */ static css::uno::Reference< css::frame::XFrame > static_impl_searchRightTargetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame , const ::rtl::OUString& sTarget); }; // class CloseDispatcher } // namespace framework #endif // #ifndef __FRAMEWORK_DISPATCH_CLOSEDISPATCHER_HXX_
#pragma once #include <cstdint> namespace NWNXLib { namespace API { struct FILE4LONG_EXTENDSt { char space[6]; }; } }
#include "Halide.h" using namespace Halide; using namespace Halide::ConciseCasts; using namespace Halide::Internal; Expr narrow(Expr a) { Type result_type = a.type().narrow(); return Cast::make(result_type, std::move(a)); } void check(Expr test, Expr expected, Type required_type) { // Some of the below tests assume the simplifier has run. test = simplify(test); Expr result = find_intrinsics(test); if (!equal(result, expected) || required_type != expected.type()) { std::cerr << "failure!\n"; std::cerr << "test: " << test << "\n"; std::cerr << "result: " << result << "\n"; std::cerr << "exepcted: " << expected << "\n"; abort(); } } void check(Expr test, Expr expected) { return check(test, expected, expected.type()); } template<typename T> int64_t mul_shift_right(int64_t a, int64_t b, int q) { const int64_t min_t = std::numeric_limits<T>::min(); const int64_t max_t = std::numeric_limits<T>::max(); return std::min<int64_t>(std::max<int64_t>((a * b) >> q, min_t), max_t); } template<typename T> int64_t rounding_mul_shift_right(int64_t a, int64_t b, int q) { const int64_t min_t = std::numeric_limits<T>::min(); const int64_t max_t = std::numeric_limits<T>::max(); return std::min<int64_t>(std::max<int64_t>((a * b + (1ll << (q - 1))) >> q, min_t), max_t); } template<typename T> void check_intrinsics_over_range() { const int64_t min_t = std::numeric_limits<T>::min(); const int64_t max_t = std::numeric_limits<T>::max(); const int N = 64; Type halide_t = type_of<T>(); const int t_bits = halide_t.bits(); for (int i = 0; i < N; i++) { int64_t a = min_t + ((max_t - min_t) * i) / N; for (int j = 0; j < N; j++) { int64_t b = min_t + ((max_t - min_t) * j) / N; Expr a_expr = make_const(halide_t, a); Expr b_expr = make_const(halide_t, b); std::pair<Expr, int64_t> intrinsics_with_reference_answer[] = { {saturating_add(a_expr, b_expr), std::min(std::max(a + b, min_t), max_t)}, {saturating_sub(a_expr, b_expr), std::min(std::max(a - b, min_t), max_t)}, {halving_add(a_expr, b_expr), (a + b) >> 1}, {rounding_halving_add(a_expr, b_expr), (a + b + 1) >> 1}, {halving_sub(a_expr, b_expr), (a - b) >> 1}, {rounding_halving_sub(a_expr, b_expr), (a - b + 1) >> 1}, }; for (const auto &p : intrinsics_with_reference_answer) { Expr test = lower_intrinsics(p.first); Expr result = simplify(test); if (!can_prove(result == make_const(halide_t, p.second))) { std::cerr << "failure!\n"; std::cerr << "test: " << p.first << "\n"; std::cerr << "result: " << result << "\n"; std::cerr << "expected: " << p.second << "\n"; abort(); } } std::pair<Expr, int64_t> multiply_intrinsics_with_reference_answer[] = { {mul_shift_right(a_expr, b_expr, t_bits - 1), mul_shift_right<T>(a, b, t_bits - 1)}, {mul_shift_right(a_expr, b_expr, t_bits), mul_shift_right<T>(a, b, t_bits)}, {rounding_mul_shift_right(a_expr, b_expr, t_bits - 1), rounding_mul_shift_right<T>(a, b, t_bits - 1)}, {rounding_mul_shift_right(a_expr, b_expr, t_bits), rounding_mul_shift_right<T>(a, b, t_bits)}, }; for (const auto &p : multiply_intrinsics_with_reference_answer) { if (a < std::numeric_limits<int>::min() || a > std::numeric_limits<int>::max() || b < std::numeric_limits<int>::min() || b > std::numeric_limits<int>::max()) { // Skip tests that would overflow the reference code. continue; } Expr test = lower_intrinsics(p.first); Expr result = simplify(test); if (!can_prove(result == make_const(halide_t, p.second))) { std::cerr << "failure!\n"; std::cerr << "test: " << p.first << "\n"; std::cerr << "result: " << result << "\n"; std::cerr << "expected: " << p.second << "\n"; abort(); } } } } } int main(int argc, char **argv) { Expr i8x = Variable::make(Int(8, 4), "i8x"); Expr i8y = Variable::make(Int(8, 4), "i8y"); Expr i8z = Variable::make(Int(8, 4), "i8w"); Expr i8w = Variable::make(Int(8, 4), "i8z"); Expr u8x = Variable::make(UInt(8, 4), "u8x"); Expr u8y = Variable::make(UInt(8, 4), "u8y"); Expr u8z = Variable::make(UInt(8, 4), "u8w"); Expr u8w = Variable::make(UInt(8, 4), "u8z"); Expr u32x = Variable::make(UInt(32, 4), "u32x"); Expr u32y = Variable::make(UInt(32, 4), "u32y"); Expr i32x = Variable::make(Int(32, 4), "i32x"); Expr i32y = Variable::make(Int(32, 4), "i32y"); Expr f16x = Variable::make(Float(16, 4), "f16x"); Expr f16y = Variable::make(Float(16, 4), "f16y"); Expr f32x = Variable::make(Float(32, 4), "f32x"); Expr f32y = Variable::make(Float(32, 4), "f32y"); // Check powers of two multiply/divide rewritten to shifts. check(i8x * 2, i8x << 1); check(u8x * 4, u8x << 2); check(i8x / 8, i8x >> 3); check(u8x / 4, u8x >> 2); check(i16(i8x) * 4096, widening_shift_left(i8x, 12)); check(u16(u8x) * 128, widening_shift_left(u8x, 7)); //check(u32(u8x) * 256, u32(widening_shift_left(u8x, u8(8)))); // Check widening arithmetic check(i16(i8x) + i8y, widening_add(i8x, i8y)); check(u16(u8x) + u8y, widening_add(u8x, u8y)); check(i16(u8x) + u8y, i16(widening_add(u8x, u8y))); check(f32(f16x) + f32(f16y), widening_add(f16x, f16y)); check(i16(i8x) - i8y, widening_sub(i8x, i8y)); check(i16(u8x) - u8y, widening_sub(u8x, u8y)); check(f32(f16x) - f32(f16y), widening_sub(f16x, f16y)); check(i16(i8x) * i8y, widening_mul(i8x, i8y)); check(u16(u8x) * u8y, widening_mul(u8x, u8y)); check(i32(i8x) * i8y, i32(widening_mul(i8x, i8y))); check(u32(u8x) * u8y, u32(widening_mul(u8x, u8y))); check(f32(f16x) * f32(f16y), widening_mul(f16x, f16y)); // Widening mul allows mixed signs check(i16(i8x) * u8y, widening_mul(i8x, u8y), Int(16, 4)); check(i32(i8x) * u8y, i32(widening_mul(i8x, u8y))); // Excessive widening should be moved outside the arithmetic. check(widening_mul(i16(i8x), i16(i8y)), i32(widening_mul(i8x, i8y))); check(widening_mul(u16(u8x), u16(u8y)), u32(widening_mul(u8x, u8y))); check(widening_mul(i16(i8x), i16(u8y)), i32(widening_mul(i8x, u8y))); check(widening_mul(i16(u8x), i16(i8y)), i32(widening_mul(u8x, i8y))); check(widening_mul(f32(f16x), f32(f16y)), f64(widening_mul(f16x, f16y))); check(widening_add(i16(i8x), i16(i8y)), i32(widening_add(i8x, i8y))); check(widening_add(u16(u8x), u16(u8y)), u32(widening_add(u8x, u8y))); check(widening_add(i16(u8x), i16(u8y)), i32(widening_add(u8x, u8y))); check(widening_add(f32(f16x), f32(f16y)), f64(widening_add(f16x, f16y))); check(widening_mul(i32(i8x), i32(i8y)), i64(widening_mul(i8x, i8y))); check(widening_mul(u32(u8x), u32(u8y)), u64(widening_mul(u8x, u8y))); check(widening_mul(i32(i8x), i32(u8y)), i64(widening_mul(i8x, u8y))); check(widening_mul(i32(u8x), i32(i8y)), i64(widening_mul(u8x, i8y))); check(widening_add(i32(i8x), i32(i8y)), i64(widening_add(i8x, i8y))); check(widening_add(u32(u8x), u32(u8y)), u64(widening_add(u8x, u8y))); check(widening_add(i32(u8x), i32(u8y)), i64(widening_add(u8x, u8y))); // Tricky case. check(i32(u8x) + 1, i32(widening_add(u8x, u8(1)))); // Check saturating arithmetic check(i8_sat(i16(i8x) + i8y), saturating_add(i8x, i8y)); check(u8_sat(u16(u8x) + u8y), saturating_add(u8x, u8y)); check(u8(min(u16(u8x) + u16(u8y), 255)), saturating_add(u8x, u8y)); check(u8(min(i16(u8x) + i16(u8y), 255)), saturating_add(u8x, u8y)); check(i8_sat(i16(i8x) - i8y), saturating_sub(i8x, i8y)); check(u8(max(i16(u8x) - i16(u8y), 0)), saturating_sub(u8x, u8y)); // Check halving arithmetic check(i8((i16(i8x) + i8y) / 2), halving_add(i8x, i8y)); check(u8((u16(u8x) + u8y) / 2), halving_add(u8x, u8y)); check(i8(widening_add(i8x, i8y) / 2), halving_add(i8x, i8y)); check(u8(widening_add(u8x, u8y) / 2), halving_add(u8x, u8y)); check((i32x + i32y) / 2, halving_add(i32x, i32y)); check((f32x + f32y) / 2, (f32x + f32y) * 0.5f); check(i8((i16(i8x) - i8y) / 2), halving_sub(i8x, i8y)); check(u8((u16(u8x) - u8y) / 2), halving_sub(u8x, u8y)); check(i8(widening_sub(i8x, i8y) / 2), halving_sub(i8x, i8y)); check(u8(widening_sub(u8x, u8y) / 2), halving_sub(u8x, u8y)); check((i32x - i32y) / 2, halving_sub(i32x, i32y)); check((f32x - f32y) / 2, (f32x - f32y) * 0.5f); check(i8((i16(i8x) + i8y + 1) / 2), rounding_halving_add(i8x, i8y)); check(u8((u16(u8x) + u8y + 1) / 2), rounding_halving_add(u8x, u8y)); check(i8((widening_add(i8x, i8y) + 1) / 2), rounding_halving_add(i8x, i8y)); check(u8((widening_add(u8x, u8y) + 1) / 2), rounding_halving_add(u8x, u8y)); check((i32x + i32y + 1) / 2, rounding_halving_add(i32x, i32y)); check(i8((i16(i8x) - i8y + 1) / 2), rounding_halving_sub(i8x, i8y)); check(u8((u16(u8x) - u8y + 1) / 2), rounding_halving_sub(u8x, u8y)); check(i8((widening_sub(i8x, i8y) + 1) / 2), rounding_halving_sub(i8x, i8y)); check(u8((widening_sub(u8x, u8y) + 1) / 2), rounding_halving_sub(u8x, u8y)); check((i32x - i32y + 1) / 2, rounding_halving_sub(i32x, i32y)); // Check absd check(abs(i16(i8x) - i16(i8y)), u16(absd(i8x, i8y))); check(abs(i16(u8x) - i16(u8y)), u16(absd(u8x, u8y))); check(abs(f16x - f16y), absd(f16x, f16y)); check(abs(f32x - f32y), absd(f32x, f32y)); check(abs(widening_sub(i8x, i8y)), u16(absd(i8x, i8y))); check(abs(widening_sub(u8x, u8y)), u16(absd(u8x, u8y))); check(abs(widening_sub(f16x, f16y)), f32(abs(f16x - f16y))); // Check rounding shifts // With constants check(narrow((i16(i8x) + 8) / 16), rounding_shift_right(i8x, 4)); check(narrow(widening_add(i8x, i8(4)) / 8), rounding_shift_right(i8x, 3)); check(i8(widening_add(i8x, i8(32)) / 64), rounding_shift_right(i8x, 6)); check((i8x + i8(32)) / 64, (i8x + i8(32)) >> 6); // Not a rounding_shift_right due to overflow. check((i32x + 16) / 32, rounding_shift_right(i32x, 5)); check((u64(u32x) + 8) / 16, u64(rounding_shift_right(u32x, 4))); check(u16(min((u64(u32x) + 8) / 16, 65535)), u16(min(rounding_shift_right(u32x, 4), 65535))); // And with variable shifts. check(i8(widening_add(i8x, (i8(1) << u8y) / 2) >> u8y), rounding_shift_right(i8x, u8y)); check((i32x + (i32(1) << u32y) / 2) >> u32y, rounding_shift_right(i32x, u32y)); check(i8(widening_add(i8x, (i8(1) << max(i8y, 0)) / 2) >> i8y), rounding_shift_right(i8x, i8y)); check((i32x + (i32(1) << max(i32y, 0)) / 2) >> i32y, rounding_shift_right(i32x, i32y)); check(i8(widening_add(i8x, (i8(1) >> min(i8y, 0)) / 2) << i8y), rounding_shift_left(i8x, i8y)); check((i32x + (i32(1) >> min(i32y, 0)) / 2) << i32y, rounding_shift_left(i32x, i32y)); check(i8(widening_add(i8x, (i8(1) << -min(i8y, 0)) / 2) << i8y), rounding_shift_left(i8x, i8y)); check((i32x + (i32(1) << -min(i32y, 0)) / 2) << i32y, rounding_shift_left(i32x, i32y)); check((i32x + (i32(1) << max(-i32y, 0)) / 2) << i32y, rounding_shift_left(i32x, i32y)); // Test combinations of multiplies and adds with widening // Same sign: check(i16(i8x) * i8y + i16(i8z) * i8w, widening_mul(i8x, i8y) + widening_mul(i8z, i8w)); check(u16(u8x) * u8y + u16(u8z) * u8w, widening_mul(u8x, u8y) + widening_mul(u8z, u8w)); check(i32(i8x) * i8y + i32(i8z) * i8w, widening_add(widening_mul(i8x, i8y), widening_mul(i8z, i8w))); check(u32(u8x) * u8y + u32(u8z) * u8w, widening_add(widening_mul(u8x, u8y), widening_mul(u8z, u8w)), UInt(32, 4)); // Mixed signs: check(i16(u8x) * i8y + i16(u8z) * i8w, widening_mul(u8x, i8y) + widening_mul(u8z, i8w), Int(16, 4)); // Widening multiply-adds involving constants should be rewritten to adds whenever possible: check(i16(i8x) * 3 + i16(i8y) * 5, widening_mul(i8x, i8(3)) + widening_mul(i8y, i8(5))); check(i16(i8x) * 5 - i16(i8y) * 127, widening_mul(i8x, i8(5)) + widening_mul(i8y, i8(-127))); check(i16(u8x) * 3 - i16(u8y) * 7, widening_mul(u8x, i8(3)) + widening_mul(u8y, i8(-7))); check(i32(i8x) * 3 + i32(i8y) * 5, widening_add(widening_mul(i8x, i8(3)), widening_mul(i8y, i8(5)))); check(i32(i8x) * 5 - i32(i8y) * 3, widening_add(widening_mul(i8x, i8(5)), widening_mul(i8y, i8(-3)))); check(i32(u8x) * 7 - i32(u8y) * 6, widening_add(widening_mul(u8x, i8(7)), widening_mul(u8y, i8(-6)))); check((i16(u8x) * 4 + i16(u8y)) * 3, widening_mul(u8x, i8(12)) + widening_mul(u8y, i8(3))); check((i16(i8y) * 7 + i16(i8x)) * 5, widening_mul(i8y, i8(35)) + widening_mul(i8x, i8(5))); check((i16(u8x) * 4 - i16(u8y)) * 3, widening_mul(u8x, i8(12)) + widening_mul(u8y, i8(-3))); check((i16(i8x) - i16(i8y) * 7) * 5, widening_mul(i8x, i8(5)) + widening_mul(i8y, i8(-35))); check((u16(u8x) + u16(u8y)) * 2, widening_shift_left(u8x, 1) + widening_shift_left(u8y, 1)); check((u16(u8x) - u16(u8y)) * 2, widening_shift_left(u8x, 1) - widening_shift_left(u8y, 1)); check((u16(u8x) * 4 + u16(u8y)) * 3, widening_mul(u8x, u8(12)) + widening_mul(u8y, u8(3))); check((u16(u8y) * 7 + u16(u8x)) * 5, widening_mul(u8y, u8(35)) + widening_mul(u8x, u8(5))); // TODO: Should these be rewritten to widening muls with mixed signs? check((u16(u8x) * 4 - u16(u8y)) * 3, widening_mul(u8x, u8(12)) - widening_mul(u8y, u8(3))); check((u16(u8x) - u16(u8y) * 7) * 5, widening_mul(u8x, u8(5)) - widening_mul(u8y, u8(35))); // Quantized multiplication. check(i8_sat(i16(i8x) * i16(i8y) >> 7), mul_shift_right(i8x, i8y, 7)); check(i8(min(i16(i8x) * i16(i8y) >> 7, 127)), mul_shift_right(i8x, i8y, 7)); check(i8_sat(i16(i8x) * i16(i8y) >> 8), mul_shift_right(i8x, i8y, 8)); check(u8_sat(u16(u8x) * u16(u8y) >> 8), mul_shift_right(u8x, u8y, 8)); check(i8(i16(i8x) * i16(i8y) >> 8), mul_shift_right(i8x, i8y, 8)); check(u8(u16(u8x) * u16(u8y) >> 8), mul_shift_right(u8x, u8y, 8)); check(i8_sat(rounding_shift_right(i16(i8x) * i16(i8y), 7)), rounding_mul_shift_right(i8x, i8y, 7)); check(i8(min(rounding_shift_right(i16(i8x) * i16(i8y), 7), 127)), rounding_mul_shift_right(i8x, i8y, 7)); check(i8_sat(rounding_shift_right(i16(i8x) * i16(i8y), 8)), rounding_mul_shift_right(i8x, i8y, 8)); check(u8_sat(rounding_shift_right(u16(u8x) * u16(u8y), 8)), rounding_mul_shift_right(u8x, u8y, 8)); check(i8(rounding_shift_right(i16(i8x) * i16(i8y), 8)), rounding_mul_shift_right(i8x, i8y, 8)); check(u8(rounding_shift_right(u16(u8x) * u16(u8y), 8)), rounding_mul_shift_right(u8x, u8y, 8)); check_intrinsics_over_range<int8_t>(); check_intrinsics_over_range<uint8_t>(); check_intrinsics_over_range<int16_t>(); check_intrinsics_over_range<uint16_t>(); check_intrinsics_over_range<int32_t>(); check_intrinsics_over_range<uint32_t>(); printf("Success!\n"); return 0; }
/** * spoonacular API * The spoonacular Nutrition, Recipe, and Food API allows you to access over 380,000 recipes, thousands of ingredients, 800,000 food products, and 100,000 menu items. Our food ontology and semantic recipe search engine makes it possible to search for recipes using natural language queries, such as \"gluten free brownies without sugar\" or \"low fat vegan cupcakes.\" You can automatically calculate the nutritional information for any recipe, analyze recipe costs, visualize ingredient lists, find recipes for what's in your fridge, find recipes based on special diets, nutritional requirements, or favorite ingredients, classify recipes into types and cuisines, convert ingredient amounts, or even compute an entire meal plan. With our powerful API, you can create many kinds of food and especially nutrition apps. Special diets/dietary requirements currently available include: vegan, vegetarian, pescetarian, gluten free, grain free, dairy free, high protein, whole 30, low sodium, low carb, Paleo, ketogenic, FODMAP, and Primal. * * The version of the OpenAPI document: 1.0 * Contact: mail@spoonacular.com * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ #include "OAIInline_response_200_41_days.h" #include "OAIHelpers.h" #include <QJsonDocument> #include <QJsonArray> #include <QObject> #include <QDebug> namespace OpenAPI { OAIInline_response_200_41_days::OAIInline_response_200_41_days(QString json) { this->init(); this->fromJson(json); } OAIInline_response_200_41_days::OAIInline_response_200_41_days() { this->init(); } OAIInline_response_200_41_days::~OAIInline_response_200_41_days() { } void OAIInline_response_200_41_days::init() { m_nutrition_summary_isSet = false; m_nutrition_summary_isValid = false; m_nutrition_summary_breakfast_isSet = false; m_nutrition_summary_breakfast_isValid = false; m_nutrition_summary_lunch_isSet = false; m_nutrition_summary_lunch_isValid = false; m_nutrition_summary_dinner_isSet = false; m_nutrition_summary_dinner_isValid = false; m_day_isSet = false; m_day_isValid = false; m_items_isSet = false; m_items_isValid = false; } void OAIInline_response_200_41_days::fromJson(QString jsonString) { QByteArray array (jsonString.toStdString().c_str()); QJsonDocument doc = QJsonDocument::fromJson(array); QJsonObject jsonObject = doc.object(); this->fromJsonObject(jsonObject); } void OAIInline_response_200_41_days::fromJsonObject(QJsonObject json) { m_nutrition_summary_isValid = ::OpenAPI::fromJsonValue(nutrition_summary, json[QString("nutritionSummary")]); m_nutrition_summary_breakfast_isValid = ::OpenAPI::fromJsonValue(nutrition_summary_breakfast, json[QString("nutritionSummaryBreakfast")]); m_nutrition_summary_lunch_isValid = ::OpenAPI::fromJsonValue(nutrition_summary_lunch, json[QString("nutritionSummaryLunch")]); m_nutrition_summary_dinner_isValid = ::OpenAPI::fromJsonValue(nutrition_summary_dinner, json[QString("nutritionSummaryDinner")]); m_day_isValid = ::OpenAPI::fromJsonValue(day, json[QString("day")]); m_items_isValid = ::OpenAPI::fromJsonValue(items, json[QString("items")]); } QString OAIInline_response_200_41_days::asJson () const { QJsonObject obj = this->asJsonObject(); QJsonDocument doc(obj); QByteArray bytes = doc.toJson(); return QString(bytes); } QJsonObject OAIInline_response_200_41_days::asJsonObject() const { QJsonObject obj; if(nutrition_summary.isSet()){ obj.insert(QString("nutritionSummary"), ::OpenAPI::toJsonValue(nutrition_summary)); } if(nutrition_summary_breakfast.isSet()){ obj.insert(QString("nutritionSummaryBreakfast"), ::OpenAPI::toJsonValue(nutrition_summary_breakfast)); } if(nutrition_summary_lunch.isSet()){ obj.insert(QString("nutritionSummaryLunch"), ::OpenAPI::toJsonValue(nutrition_summary_lunch)); } if(nutrition_summary_dinner.isSet()){ obj.insert(QString("nutritionSummaryDinner"), ::OpenAPI::toJsonValue(nutrition_summary_dinner)); } if(m_day_isSet){ obj.insert(QString("day"), ::OpenAPI::toJsonValue(day)); } if(items.size() > 0){ obj.insert(QString("items"), ::OpenAPI::toJsonValue(items)); } return obj; } OAIInline_response_200_38_nutritionSummary OAIInline_response_200_41_days::getNutritionSummary() const { return nutrition_summary; } void OAIInline_response_200_41_days::setNutritionSummary(const OAIInline_response_200_38_nutritionSummary &nutrition_summary) { this->nutrition_summary = nutrition_summary; this->m_nutrition_summary_isSet = true; } OAIInline_response_200_38_nutritionSummary OAIInline_response_200_41_days::getNutritionSummaryBreakfast() const { return nutrition_summary_breakfast; } void OAIInline_response_200_41_days::setNutritionSummaryBreakfast(const OAIInline_response_200_38_nutritionSummary &nutrition_summary_breakfast) { this->nutrition_summary_breakfast = nutrition_summary_breakfast; this->m_nutrition_summary_breakfast_isSet = true; } OAIInline_response_200_38_nutritionSummary OAIInline_response_200_41_days::getNutritionSummaryLunch() const { return nutrition_summary_lunch; } void OAIInline_response_200_41_days::setNutritionSummaryLunch(const OAIInline_response_200_38_nutritionSummary &nutrition_summary_lunch) { this->nutrition_summary_lunch = nutrition_summary_lunch; this->m_nutrition_summary_lunch_isSet = true; } OAIInline_response_200_38_nutritionSummary OAIInline_response_200_41_days::getNutritionSummaryDinner() const { return nutrition_summary_dinner; } void OAIInline_response_200_41_days::setNutritionSummaryDinner(const OAIInline_response_200_38_nutritionSummary &nutrition_summary_dinner) { this->nutrition_summary_dinner = nutrition_summary_dinner; this->m_nutrition_summary_dinner_isSet = true; } QString OAIInline_response_200_41_days::getDay() const { return day; } void OAIInline_response_200_41_days::setDay(const QString &day) { this->day = day; this->m_day_isSet = true; } QList<OAIInline_response_200_41_items> OAIInline_response_200_41_days::getItems() const { return items; } void OAIInline_response_200_41_days::setItems(const QList<OAIInline_response_200_41_items> &items) { this->items = items; this->m_items_isSet = true; } bool OAIInline_response_200_41_days::isSet() const { bool isObjectUpdated = false; do{ if(nutrition_summary.isSet()){ isObjectUpdated = true; break;} if(nutrition_summary_breakfast.isSet()){ isObjectUpdated = true; break;} if(nutrition_summary_lunch.isSet()){ isObjectUpdated = true; break;} if(nutrition_summary_dinner.isSet()){ isObjectUpdated = true; break;} if(m_day_isSet){ isObjectUpdated = true; break;} if(items.size() > 0){ isObjectUpdated = true; break;} }while(false); return isObjectUpdated; } bool OAIInline_response_200_41_days::isValid() const { // only required properties are required for the object to be considered valid return m_day_isValid && true; } }
#include <math.h> #include <uWS/uWS.h> #include <chrono> #include <iostream> #include <thread> #include <vector> #include "Eigen-3.3/Eigen/Core" #include "Eigen-3.3/Eigen/QR" #include "MPC.h" #include "json.hpp" using namespace Eigen; // for convenience using json = nlohmann::json; // For converting back and forth between radians and degrees. constexpr double pi() { return M_PI; } double deg2rad(double x) { return x * pi() / 180; } double rad2deg(double x) { return x * 180 / pi(); } // Checks if the SocketIO event has JSON data. // If there is data the JSON object in string format will be returned, // else the empty string "" will be returned. string hasData(string s) { auto found_null = s.find("null"); auto b1 = s.find_first_of("["); auto b2 = s.rfind("}]"); if (found_null != string::npos) { return ""; } else if (b1 != string::npos && b2 != string::npos) { return s.substr(b1, b2 - b1 + 2); } return ""; } // Evaluate a polynomial. double polyeval(Eigen::VectorXd coeffs, double x) { double result = 0.0; for (int i = 0; i < coeffs.size(); i++) { result += coeffs[i] * pow(x, i); } return result; } // Fit a polynomial. // Adapted from // https://github.com/JuliaMath/Polynomials.jl/blob/master/src/Polynomials.jl#L676-L716 Eigen::VectorXd polyfit(Eigen::VectorXd xvals, Eigen::VectorXd yvals, int order) { assert(xvals.size() == yvals.size()); assert(order >= 1 && order <= xvals.size() - 1); Eigen::MatrixXd A(xvals.size(), order + 1); for (int i = 0; i < xvals.size(); i++) { A(i, 0) = 1.0; } for (int j = 0; j < xvals.size(); j++) { for (int i = 0; i < order; i++) { A(j, i + 1) = A(j, i) * xvals(j); } } auto Q = A.householderQr(); auto result = Q.solve(yvals); return result; } int main() { uWS::Hub h; // MPC is initialized here! MPC mpc; h.onMessage([&mpc](uWS::WebSocket<uWS::SERVER> ws, char *data, size_t length, uWS::OpCode opCode) { // "42" at the start of the message means there's a websocket message event. // The 4 signifies a websocket message // The 2 signifies a websocket event string sdata = string(data).substr(0, length); cout << sdata << endl; if (sdata.size() > 2 && sdata[0] == '4' && sdata[1] == '2') { string s = hasData(sdata); if (s != "") { auto j = json::parse(s); string event = j[0].get<string>(); if (event == "telemetry") { // j[1] is the data JSON object vector<double> ptsx = j[1]["ptsx"]; vector<double> ptsy = j[1]["ptsy"]; double px = j[1]["x"]; double py = j[1]["y"]; double psi = j[1]["psi"]; double v = j[1]["speed"]; double delta = j[1]["steering_angle"]; double a = j[1]["throttle"]; Eigen::VectorXd ptsx_car(ptsx.size()); Eigen::VectorXd ptsy_car(ptsy.size()); for (int i = 0; i < ptsx.size(); i++) { double x_shift = ptsx[i] - px; double y_shift = ptsy[i] - py; ptsx_car[i] = x_shift * cos(0-psi) - y_shift * sin(0-psi); ptsy_car[i] = x_shift * sin(0-psi) + y_shift * cos(0-psi); } // Fits the x and y coordinates into 3rd-order polynomial auto coeffs = polyfit(ptsx_car, ptsy_car, 3); //calculating the cross track error (cte) double cte = polyeval(coeffs, 0); // calculating the orientation error double epsi = psi - atan(coeffs[1]); // define LF again for the prediction of a short latency state const double Lf = 2.67; // Latency for predicting time at actuation const double dt = 0.1; // Predict what values in later stage, to resolve latency double pred_px = 0.0 + v * dt; double pred_py = 0.0; double pred_psi = 0.0 + v * - delta / Lf * dt; double pred_v = v + a * dt; double pred_cte = cte + v * sin(epsi) * dt; double pred_epsi = epsi + v * -delta / Lf * dt; Eigen::VectorXd state(6); // new vector to hold the predicted states state << pred_px, pred_py, pred_psi, pred_v, pred_cte, pred_epsi; // calling the solve function, to solve and predicte x and y in the future auto vars = mpc.Solve(state, coeffs); // extracting the steering and throttel values from the solver return parameter double steer_value = vars[0]; //converting the angle to radian taking into consideration LF double throttle_value = vars[1]; json msgJson; // NOTE: Remember to divide by deg2rad(25) before you send the steering value back. // Otherwise the values will be in between [-deg2rad(25), deg2rad(25] instead of [-1, 1]. msgJson["steering_angle"] = steer_value; msgJson["throttle"] = throttle_value; //Display the MPC predicted trajectory vector<double> mpc_x_vals; vector<double> mpc_y_vals; // Get the predicted trajaectory from the MPC return for (int i = 2; i < vars.size(); i++) { if (i % 2 == 0) mpc_x_vals.push_back(vars[i]); else mpc_y_vals.push_back(vars[i]); } //.. add (x,y) points to list here, points are in reference to the vehicle's coordinate system // the points in the simulator are connected by a Green line msgJson["mpc_x"] = mpc_x_vals; msgJson["mpc_y"] = mpc_y_vals; //Display the waypoints/reference line vector<double> next_x_vals; vector<double> next_y_vals; //.. add (x,y) points to list here, points are in reference to the vehicle's coordinate system // the points in the simulator are connected by a Yellow line double poly_inc = 2.5; int num_points = 25; for (int i = 1; i < num_points; i++) { next_x_vals.push_back(poly_inc * i); next_y_vals.push_back(polyeval(coeffs, poly_inc * i)); } msgJson["next_x"] = next_x_vals; msgJson["next_y"] = next_y_vals; auto msg = "42[\"steer\"," + msgJson.dump() + "]"; std::cout << msg << std::endl; // Latency // The purpose is to mimic real driving conditions where // the car does actuate the commands instantly. // // Feel free to play around with this value but should be to drive // around the track with 100ms latency. // // NOTE: REMEMBER TO SET THIS TO 100 MILLISECONDS BEFORE // SUBMITTING. this_thread::sleep_for(chrono::milliseconds(100)); ws.send(msg.data(), msg.length(), uWS::OpCode::TEXT); } } else { // Manual driving std::string msg = "42[\"manual\",{}]"; ws.send(msg.data(), msg.length(), uWS::OpCode::TEXT); } } }); // We don't need this since we're not using HTTP but if it's removed the // program // doesn't compile :-( h.onHttpRequest([](uWS::HttpResponse *res, uWS::HttpRequest req, char *data, size_t, size_t) { const std::string s = "<h1>Hello world!</h1>"; if (req.getUrl().valueLength == 1) { res->end(s.data(), s.length()); } else { // i guess this should be done more gracefully? res->end(nullptr, 0); } }); h.onConnection([&h](uWS::WebSocket<uWS::SERVER> ws, uWS::HttpRequest req) { std::cout << "Connected!!!" << std::endl; }); h.onDisconnection([&h](uWS::WebSocket<uWS::SERVER> ws, int code, char *message, size_t length) { ws.close(); std::cout << "Disconnected" << std::endl; }); int port = 4567; if (h.listen(port)) { std::cout << "Listening to port " << port << std::endl; } else { std::cerr << "Failed to listen to port" << std::endl; return -1; } h.run(); }
// Copyright 2014 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "../../../include/fpdfapi/fpdf_module.h" #include "../../../include/fpdfapi/fpdf_page.h" #include "../../../include/fpdfapi/fpdf_resource.h" #include "../../../include/fxge/fx_freetype.h" #include "../../../include/fxge/fx_ge.h" #include "../fpdf_cmaps/cmap_int.h" #include "font_int.h" extern short TT2PDF(int m, FXFT_Face face); extern FX_BOOL FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id); CPDF_CMapManager::CPDF_CMapManager() { m_bPrompted = FALSE; FXSYS_memset(m_CID2UnicodeMaps, 0, sizeof m_CID2UnicodeMaps); } CPDF_CMapManager::~CPDF_CMapManager() { DropAll(FALSE); } CPDF_CMap* CPDF_CMapManager::GetPredefinedCMap(const CFX_ByteString& name, FX_BOOL bPromptCJK) { CPDF_CMap* pCMap; if (m_CMaps.Lookup(name, (void*&)pCMap)) { return pCMap; } pCMap = LoadPredefinedCMap(name, bPromptCJK); if (name.IsEmpty()) { return pCMap; } m_CMaps.SetAt(name, pCMap); return pCMap; } CPDF_CMap* CPDF_CMapManager::LoadPredefinedCMap(const CFX_ByteString& name, FX_BOOL bPromptCJK) { CPDF_CMap* pCMap = new CPDF_CMap; const FX_CHAR* pname = name; if (*pname == '/') { pname ++; } pCMap->LoadPredefined(this, pname, bPromptCJK); return pCMap; } static const FX_CHAR* const g_CharsetNames[NUMBER_OF_CIDSETS] = {NULL, "GB1", "CNS1", "Japan1", "Korea1", "UCS" }; static const int g_CharsetCPs[NUMBER_OF_CIDSETS] = {0, 936, 950, 932, 949, 1200 }; int _CharsetFromOrdering(const CFX_ByteString& Ordering) { for (int charset = 1; charset < NUMBER_OF_CIDSETS; charset++) { if (Ordering == CFX_ByteStringC(g_CharsetNames[charset])) return charset; } return CIDSET_UNKNOWN; } void CPDF_CMapManager::ReloadAll() { DropAll(TRUE); } void CPDF_CMapManager::DropAll(FX_BOOL bReload) { FX_POSITION pos = m_CMaps.GetStartPosition(); while (pos) { CFX_ByteString name; CPDF_CMap* pCMap; m_CMaps.GetNextAssoc(pos, name, (void*&)pCMap); if (pCMap == NULL) { continue; } if (bReload) { pCMap->LoadPredefined(this, name, FALSE); } else { delete pCMap; } } for (int i = 0; i < sizeof m_CID2UnicodeMaps / sizeof(CPDF_CID2UnicodeMap*); i ++) { CPDF_CID2UnicodeMap* pMap = m_CID2UnicodeMaps[i]; if (pMap == NULL) { continue; } if (bReload) { pMap->Load(this, i, FALSE); } else { delete pMap; } } } CPDF_CID2UnicodeMap* CPDF_CMapManager::GetCID2UnicodeMap(int charset, FX_BOOL bPromptCJK) { if (m_CID2UnicodeMaps[charset] == NULL) { m_CID2UnicodeMaps[charset] = LoadCID2UnicodeMap(charset, bPromptCJK); } return m_CID2UnicodeMaps[charset]; } CPDF_CID2UnicodeMap* CPDF_CMapManager::LoadCID2UnicodeMap(int charset, FX_BOOL bPromptCJK) { CPDF_CID2UnicodeMap* pMap = new CPDF_CID2UnicodeMap(); if (!pMap->Initialize()) { delete pMap; return NULL; } pMap->Load(this, charset, bPromptCJK); return pMap; } CPDF_CMapParser::CPDF_CMapParser() { m_pCMap = NULL; m_Status = 0; m_CodeSeq = 0; } FX_BOOL CPDF_CMapParser::Initialize(CPDF_CMap* pCMap) { m_pCMap = pCMap; m_Status = 0; m_CodeSeq = 0; m_AddMaps.EstimateSize(0, 10240); return TRUE; } static FX_DWORD CMap_GetCode(const CFX_ByteStringC& word) { int num = 0; if (word.GetAt(0) == '<') { for (int i = 1; i < word.GetLength(); i ++) { uint8_t digit = word.GetAt(i); if (digit >= '0' && digit <= '9') { digit = digit - '0'; } else if (digit >= 'a' && digit <= 'f') { digit = digit - 'a' + 10; } else if (digit >= 'A' && digit <= 'F') { digit = digit - 'A' + 10; } else { return num; } num = num * 16 + digit; } } else { for (int i = 0; i < word.GetLength(); i ++) { if (word.GetAt(i) < '0' || word.GetAt(i) > '9') { return num; } num = num * 10 + word.GetAt(i) - '0'; } } return num; } static FX_BOOL _CMap_GetCodeRange(_CMap_CodeRange& range, const CFX_ByteStringC& first, const CFX_ByteStringC& second) { if (first.GetLength() == 0 || first.GetAt(0) != '<') { return FALSE; } int i; for (i = 1; i < first.GetLength(); i ++) if (first.GetAt(i) == '>') { break; } range.m_CharSize = (i - 1) / 2; if (range.m_CharSize > 4) { return FALSE; } for (i = 0; i < range.m_CharSize; i ++) { uint8_t digit1 = first.GetAt(i * 2 + 1); uint8_t digit2 = first.GetAt(i * 2 + 2); uint8_t byte = (digit1 >= '0' && digit1 <= '9') ? (digit1 - '0') : ((digit1 & 0xdf) - 'A' + 10); byte = byte * 16 + ((digit2 >= '0' && digit2 <= '9') ? (digit2 - '0') : ((digit2 & 0xdf) - 'A' + 10)); range.m_Lower[i] = byte; } FX_DWORD size = second.GetLength(); for (i = 0; i < range.m_CharSize; i ++) { uint8_t digit1 = ((FX_DWORD)i * 2 + 1 < size) ? second.GetAt((FX_STRSIZE)i * 2 + 1) : 0; uint8_t digit2 = ((FX_DWORD)i * 2 + 2 < size) ? second.GetAt((FX_STRSIZE)i * 2 + 2) : 0; uint8_t byte = (digit1 >= '0' && digit1 <= '9') ? (digit1 - '0') : ((digit1 & 0xdf) - 'A' + 10); byte = byte * 16 + ((digit2 >= '0' && digit2 <= '9') ? (digit2 - '0') : ((digit2 & 0xdf) - 'A' + 10)); range.m_Upper[i] = byte; } return TRUE; } static CFX_ByteString CMap_GetString(const CFX_ByteStringC& word) { return word.Mid(1, word.GetLength() - 2); } void CPDF_CMapParser::ParseWord(const CFX_ByteStringC& word) { if (word.IsEmpty()) { return; } if (word == FX_BSTRC("begincidchar")) { m_Status = 1; m_CodeSeq = 0; } else if (word == FX_BSTRC("begincidrange")) { m_Status = 2; m_CodeSeq = 0; } else if (word == FX_BSTRC("endcidrange") || word == FX_BSTRC("endcidchar")) { m_Status = 0; } else if (word == FX_BSTRC("/WMode")) { m_Status = 6; } else if (word == FX_BSTRC("/Registry")) { m_Status = 3; } else if (word == FX_BSTRC("/Ordering")) { m_Status = 4; } else if (word == FX_BSTRC("/Supplement")) { m_Status = 5; } else if (word == FX_BSTRC("begincodespacerange")) { m_Status = 7; m_CodeSeq = 0; } else if (word == FX_BSTRC("usecmap")) { } else if (m_Status == 1 || m_Status == 2) { m_CodePoints[m_CodeSeq] = CMap_GetCode(word); m_CodeSeq ++; FX_DWORD StartCode, EndCode; FX_WORD StartCID; if (m_Status == 1) { if (m_CodeSeq < 2) { return; } EndCode = StartCode = m_CodePoints[0]; StartCID = (FX_WORD)m_CodePoints[1]; } else { if (m_CodeSeq < 3) { return; } StartCode = m_CodePoints[0]; EndCode = m_CodePoints[1]; StartCID = (FX_WORD)m_CodePoints[2]; } if (EndCode < 0x10000) { for (FX_DWORD code = StartCode; code <= EndCode; code ++) { m_pCMap->m_pMapping[code] = (FX_WORD)(StartCID + code - StartCode); } } else { FX_DWORD buf[2]; buf[0] = StartCode; buf[1] = ((EndCode - StartCode) << 16) + StartCID; m_AddMaps.AppendBlock(buf, sizeof buf); } m_CodeSeq = 0; } else if (m_Status == 3) { CMap_GetString(word); m_Status = 0; } else if (m_Status == 4) { m_pCMap->m_Charset = _CharsetFromOrdering(CMap_GetString(word)); m_Status = 0; } else if (m_Status == 5) { CMap_GetCode(word); m_Status = 0; } else if (m_Status == 6) { m_pCMap->m_bVertical = CMap_GetCode(word); m_Status = 0; } else if (m_Status == 7) { if (word == FX_BSTRC("endcodespacerange")) { int nSegs = m_CodeRanges.GetSize(); if (nSegs > 1) { m_pCMap->m_CodingScheme = CPDF_CMap::MixedFourBytes; m_pCMap->m_nCodeRanges = nSegs; m_pCMap->m_pLeadingBytes = FX_Alloc2D(uint8_t, nSegs, sizeof(_CMap_CodeRange)); FXSYS_memcpy(m_pCMap->m_pLeadingBytes, m_CodeRanges.GetData(), nSegs * sizeof(_CMap_CodeRange)); } else if (nSegs == 1) { m_pCMap->m_CodingScheme = (m_CodeRanges[0].m_CharSize == 2) ? CPDF_CMap::TwoBytes : CPDF_CMap::OneByte; } m_Status = 0; } else { if (word.GetLength() == 0 || word.GetAt(0) != '<') { return; } if (m_CodeSeq % 2) { _CMap_CodeRange range; if (_CMap_GetCodeRange(range, m_LastWord, word)) { m_CodeRanges.Add(range); } } m_CodeSeq ++; } } m_LastWord = word; } CPDF_CMap::CPDF_CMap() { m_Charset = CIDSET_UNKNOWN; m_Coding = CIDCODING_UNKNOWN; m_CodingScheme = TwoBytes; m_bVertical = 0; m_bLoaded = FALSE; m_pMapping = NULL; m_pLeadingBytes = NULL; m_pAddMapping = NULL; m_pEmbedMap = NULL; m_pUseMap = NULL; m_nCodeRanges = 0; } CPDF_CMap::~CPDF_CMap() { if (m_pMapping) { FX_Free(m_pMapping); } if (m_pAddMapping) { FX_Free(m_pAddMapping); } if (m_pLeadingBytes) { FX_Free(m_pLeadingBytes); } delete m_pUseMap; } void CPDF_CMap::Release() { if (m_PredefinedCMap.IsEmpty()) { delete this; } } const CPDF_PredefinedCMap g_PredefinedCMaps[] = { { "GB-EUC", CIDSET_GB1, CIDCODING_GB, CPDF_CMap::MixedTwoBytes, 1, {0xa1, 0xfe} }, { "GBpc-EUC", CIDSET_GB1, CIDCODING_GB, CPDF_CMap::MixedTwoBytes, 1, {0xa1, 0xfc} }, { "GBK-EUC", CIDSET_GB1, CIDCODING_GB, CPDF_CMap::MixedTwoBytes, 1, {0x81, 0xfe} }, { "GBKp-EUC", CIDSET_GB1, CIDCODING_GB, CPDF_CMap::MixedTwoBytes, 1, {0x81, 0xfe} }, { "GBK2K-EUC", CIDSET_GB1, CIDCODING_GB, CPDF_CMap::MixedTwoBytes, 1, {0x81, 0xfe} }, { "GBK2K", CIDSET_GB1, CIDCODING_GB, CPDF_CMap::MixedTwoBytes, 1, {0x81, 0xfe} }, { "UniGB-UCS2", CIDSET_GB1, CIDCODING_UCS2, CPDF_CMap::TwoBytes }, { "UniGB-UTF16", CIDSET_GB1, CIDCODING_UTF16, CPDF_CMap::TwoBytes }, { "B5pc", CIDSET_CNS1, CIDCODING_BIG5, CPDF_CMap::MixedTwoBytes, 1, {0xa1, 0xfc} }, { "HKscs-B5", CIDSET_CNS1, CIDCODING_BIG5, CPDF_CMap::MixedTwoBytes, 1, {0x88, 0xfe} }, { "ETen-B5", CIDSET_CNS1, CIDCODING_BIG5, CPDF_CMap::MixedTwoBytes, 1, {0xa1, 0xfe} }, { "ETenms-B5", CIDSET_CNS1, CIDCODING_BIG5, CPDF_CMap::MixedTwoBytes, 1, {0xa1, 0xfe} }, { "UniCNS-UCS2", CIDSET_CNS1, CIDCODING_UCS2, CPDF_CMap::TwoBytes }, { "UniCNS-UTF16", CIDSET_CNS1, CIDCODING_UTF16, CPDF_CMap::TwoBytes }, { "83pv-RKSJ", CIDSET_JAPAN1, CIDCODING_JIS, CPDF_CMap::MixedTwoBytes, 2, {0x81, 0x9f, 0xe0, 0xfc} }, { "90ms-RKSJ", CIDSET_JAPAN1, CIDCODING_JIS, CPDF_CMap::MixedTwoBytes, 2, {0x81, 0x9f, 0xe0, 0xfc} }, { "90msp-RKSJ", CIDSET_JAPAN1, CIDCODING_JIS, CPDF_CMap::MixedTwoBytes, 2, {0x81, 0x9f, 0xe0, 0xfc} }, { "90pv-RKSJ", CIDSET_JAPAN1, CIDCODING_JIS, CPDF_CMap::MixedTwoBytes, 2, {0x81, 0x9f, 0xe0, 0xfc} }, { "Add-RKSJ", CIDSET_JAPAN1, CIDCODING_JIS, CPDF_CMap::MixedTwoBytes, 2, {0x81, 0x9f, 0xe0, 0xfc} }, { "EUC", CIDSET_JAPAN1, CIDCODING_JIS, CPDF_CMap::MixedTwoBytes, 2, {0x8e, 0x8e, 0xa1, 0xfe} }, { "H", CIDSET_JAPAN1, CIDCODING_JIS, CPDF_CMap::TwoBytes, 1, {0x21, 0x7e} }, { "V", CIDSET_JAPAN1, CIDCODING_JIS, CPDF_CMap::TwoBytes, 1, {0x21, 0x7e} }, { "Ext-RKSJ", CIDSET_JAPAN1, CIDCODING_JIS, CPDF_CMap::MixedTwoBytes, 2, {0x81, 0x9f, 0xe0, 0xfc} }, { "UniJIS-UCS2", CIDSET_JAPAN1, CIDCODING_UCS2, CPDF_CMap::TwoBytes }, { "UniJIS-UCS2-HW", CIDSET_JAPAN1, CIDCODING_UCS2, CPDF_CMap::TwoBytes }, { "UniJIS-UTF16", CIDSET_JAPAN1, CIDCODING_UTF16, CPDF_CMap::TwoBytes }, { "KSC-EUC", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0xa1, 0xfe} }, { "KSCms-UHC", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0x81, 0xfe} }, { "KSCms-UHC-HW", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0x81, 0xfe} }, { "KSCpc-EUC", CIDSET_KOREA1, CIDCODING_KOREA, CPDF_CMap::MixedTwoBytes, 1, {0xa1, 0xfd} }, { "UniKS-UCS2", CIDSET_KOREA1, CIDCODING_UCS2, CPDF_CMap::TwoBytes }, { "UniKS-UTF16", CIDSET_KOREA1, CIDCODING_UTF16, CPDF_CMap::TwoBytes }, { NULL, 0, 0 } }; extern void FPDFAPI_FindEmbeddedCMap(const char* name, int charset, int coding, const FXCMAP_CMap*& pMap); extern FX_WORD FPDFAPI_CIDFromCharCode(const FXCMAP_CMap* pMap, FX_DWORD charcode); FX_BOOL CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr, const FX_CHAR* pName, FX_BOOL bPromptCJK) { m_PredefinedCMap = pName; if (m_PredefinedCMap == FX_BSTRC("Identity-H") || m_PredefinedCMap == FX_BSTRC("Identity-V")) { m_Coding = CIDCODING_CID; m_bVertical = pName[9] == 'V'; m_bLoaded = TRUE; return TRUE; } CFX_ByteString cmapid = m_PredefinedCMap; m_bVertical = cmapid.Right(1) == FX_BSTRC("V"); if (cmapid.GetLength() > 2) { cmapid = cmapid.Left(cmapid.GetLength() - 2); } int index = 0; while (1) { if (g_PredefinedCMaps[index].m_pName == NULL) { return FALSE; } if (cmapid == CFX_ByteStringC(g_PredefinedCMaps[index].m_pName)) { break; } index ++; } const CPDF_PredefinedCMap& map = g_PredefinedCMaps[index]; m_Charset = map.m_Charset; m_Coding = map.m_Coding; m_CodingScheme = map.m_CodingScheme; if (m_CodingScheme == MixedTwoBytes) { m_pLeadingBytes = FX_Alloc(uint8_t, 256); for (FX_DWORD i = 0; i < map.m_LeadingSegCount; i ++) { for (int b = map.m_LeadingSegs[i * 2]; b <= map.m_LeadingSegs[i * 2 + 1]; b ++) { m_pLeadingBytes[b] = 1; } } } FPDFAPI_FindEmbeddedCMap(pName, m_Charset, m_Coding, m_pEmbedMap); if (m_pEmbedMap) { m_bLoaded = TRUE; return TRUE; } return FALSE; } extern "C" { static int compare_dword(const void* data1, const void* data2) { return (*(FX_DWORD*)data1) - (*(FX_DWORD*)data2); } }; FX_BOOL CPDF_CMap::LoadEmbedded(const uint8_t* pData, FX_DWORD size) { m_pMapping = FX_Alloc(FX_WORD, 65536); CPDF_CMapParser parser; parser.Initialize(this); CPDF_SimpleParser syntax(pData, size); while (1) { CFX_ByteStringC word = syntax.GetWord(); if (word.IsEmpty()) { break; } parser.ParseWord(word); } if (m_CodingScheme == MixedFourBytes && parser.m_AddMaps.GetSize()) { m_pAddMapping = FX_Alloc(uint8_t, parser.m_AddMaps.GetSize() + 4); *(FX_DWORD*)m_pAddMapping = parser.m_AddMaps.GetSize() / 8; FXSYS_memcpy(m_pAddMapping + 4, parser.m_AddMaps.GetBuffer(), parser.m_AddMaps.GetSize()); FXSYS_qsort(m_pAddMapping + 4, parser.m_AddMaps.GetSize() / 8, 8, compare_dword); } return TRUE; } extern "C" { static int compareCID(const void* key, const void* element) { if ((*(FX_DWORD*)key) < (*(FX_DWORD*)element)) { return -1; } if ((*(FX_DWORD*)key) > (*(FX_DWORD*)element) + ((FX_DWORD*)element)[1] / 65536) { return 1; } return 0; } }; FX_WORD CPDF_CMap::CIDFromCharCode(FX_DWORD charcode) const { if (m_Coding == CIDCODING_CID) { return (FX_WORD)charcode; } if (m_pEmbedMap) { return FPDFAPI_CIDFromCharCode(m_pEmbedMap, charcode); } if (m_pMapping == NULL) { return (FX_WORD)charcode; } if (charcode >> 16) { if (m_pAddMapping) { void* found = FXSYS_bsearch(&charcode, m_pAddMapping + 4, *(FX_DWORD*)m_pAddMapping, 8, compareCID); if (found == NULL) { if (m_pUseMap) { return m_pUseMap->CIDFromCharCode(charcode); } return 0; } return (FX_WORD)(((FX_DWORD*)found)[1] % 65536 + charcode - * (FX_DWORD*)found); } if (m_pUseMap) { return m_pUseMap->CIDFromCharCode(charcode); } return 0; } FX_DWORD CID = m_pMapping[charcode]; if (!CID && m_pUseMap) { return m_pUseMap->CIDFromCharCode(charcode); } return (FX_WORD)CID; } static int _CheckCodeRange(uint8_t* codes, int size, _CMap_CodeRange* pRanges, int nRanges) { int iSeg = nRanges - 1; while (iSeg >= 0) { if (pRanges[iSeg].m_CharSize < size) { iSeg --; continue; } int iChar = 0; while (iChar < size) { if (codes[iChar] < pRanges[iSeg].m_Lower[iChar] || codes[iChar] > pRanges[iSeg].m_Upper[iChar]) { break; } iChar ++; } if (iChar == pRanges[iSeg].m_CharSize) { return 2; } if (iChar) { if (size == pRanges[iSeg].m_CharSize) { return 2; } return 1; } iSeg --; } return 0; } FX_DWORD CPDF_CMap::GetNextChar(const FX_CHAR* pString, int nStrLen, int& offset) const { switch (m_CodingScheme) { case OneByte: return ((uint8_t*)pString)[offset++]; case TwoBytes: offset += 2; return ((uint8_t*)pString)[offset - 2] * 256 + ((uint8_t*)pString)[offset - 1]; case MixedTwoBytes: { uint8_t byte1 = ((uint8_t*)pString)[offset++]; if (!m_pLeadingBytes[byte1]) { return byte1; } uint8_t byte2 = ((uint8_t*)pString)[offset++]; return byte1 * 256 + byte2; } case MixedFourBytes: { uint8_t codes[4]; int char_size = 1; codes[0] = ((uint8_t*)pString)[offset++]; _CMap_CodeRange* pRanges = (_CMap_CodeRange*)m_pLeadingBytes; while (1) { int ret = _CheckCodeRange(codes, char_size, pRanges, m_nCodeRanges); if (ret == 0) { return 0; } if (ret == 2) { FX_DWORD charcode = 0; for (int i = 0; i < char_size; i ++) { charcode = (charcode << 8) + codes[i]; } return charcode; } if (char_size == 4 || offset == nStrLen) { return 0; } codes[char_size ++] = ((uint8_t*)pString)[offset++]; } break; } } return 0; } int CPDF_CMap::GetCharSize(FX_DWORD charcode) const { switch (m_CodingScheme) { case OneByte: return 1; case TwoBytes: return 2; case MixedTwoBytes: case MixedFourBytes: if (charcode < 0x100) { return 1; } if (charcode < 0x10000) { return 2; } if (charcode < 0x1000000) { return 3; } return 4; } return 1; } int CPDF_CMap::CountChar(const FX_CHAR* pString, int size) const { switch (m_CodingScheme) { case OneByte: return size; case TwoBytes: return (size + 1) / 2; case MixedTwoBytes: { int count = 0; for (int i = 0; i < size; i ++) { count ++; if (m_pLeadingBytes[((uint8_t*)pString)[i]]) { i ++; } } return count; } case MixedFourBytes: { int count = 0, offset = 0; while (offset < size) { GetNextChar(pString, size, offset); count ++; } return count; } } return size; } int _GetCharSize(FX_DWORD charcode, _CMap_CodeRange* pRanges, int iRangesSize) { if (!iRangesSize) { return 1; } uint8_t codes[4]; codes[0] = codes[1] = 0x00; codes[2] = (uint8_t)(charcode >> 8 & 0xFF); codes[3] = (uint8_t)charcode; int offset = 0, size = 4; for (int i = 0; i < 4; ++i) { int iSeg = iRangesSize - 1; while (iSeg >= 0) { if (pRanges[iSeg].m_CharSize < size) { iSeg --; continue; } int iChar = 0; while (iChar < size) { if (codes[offset + iChar] < pRanges[iSeg].m_Lower[iChar] || codes[offset + iChar] > pRanges[iSeg].m_Upper[iChar]) { break; } iChar ++; } if (iChar == pRanges[iSeg].m_CharSize) { return size; } iSeg --; } size --; offset ++; } return 1; } int CPDF_CMap::AppendChar(FX_CHAR* str, FX_DWORD charcode) const { switch (m_CodingScheme) { case OneByte: str[0] = (uint8_t)charcode; return 1; case TwoBytes: str[0] = (uint8_t)(charcode / 256); str[1] = (uint8_t)(charcode % 256); return 2; case MixedTwoBytes: case MixedFourBytes: if (charcode < 0x100) { _CMap_CodeRange* pRanges = (_CMap_CodeRange*)m_pLeadingBytes; int iSize = _GetCharSize(charcode, pRanges, m_nCodeRanges); if (iSize == 0) { iSize = 1; } if (iSize > 1) { FXSYS_memset(str, 0, sizeof(uint8_t) * iSize); } str[iSize - 1] = (uint8_t)charcode; return iSize; } if (charcode < 0x10000) { str[0] = (uint8_t)(charcode >> 8); str[1] = (uint8_t)charcode; return 2; } if (charcode < 0x1000000) { str[0] = (uint8_t)(charcode >> 16); str[1] = (uint8_t)(charcode >> 8); str[2] = (uint8_t)charcode; return 3; } str[0] = (uint8_t)(charcode >> 24); str[1] = (uint8_t)(charcode >> 16); str[2] = (uint8_t)(charcode >> 8); str[3] = (uint8_t)charcode; return 4; } return 0; } CPDF_CID2UnicodeMap::CPDF_CID2UnicodeMap() { m_EmbeddedCount = 0; } CPDF_CID2UnicodeMap::~CPDF_CID2UnicodeMap() { } FX_BOOL CPDF_CID2UnicodeMap::Initialize() { return TRUE; } FX_BOOL CPDF_CID2UnicodeMap::IsLoaded() { return m_EmbeddedCount != 0; } FX_WCHAR CPDF_CID2UnicodeMap::UnicodeFromCID(FX_WORD CID) { if (m_Charset == CIDSET_UNICODE) { return CID; } if (CID < m_EmbeddedCount) { return m_pEmbeddedMap[CID]; } return 0; } void FPDFAPI_LoadCID2UnicodeMap(int charset, const FX_WORD*& pMap, FX_DWORD& count); void CPDF_CID2UnicodeMap::Load(CPDF_CMapManager* pMgr, int charset, FX_BOOL bPromptCJK) { m_Charset = charset; FPDFAPI_LoadCID2UnicodeMap(charset, m_pEmbeddedMap, m_EmbeddedCount); } #include "ttgsubtable.h" CPDF_CIDFont::CPDF_CIDFont() : CPDF_Font(PDFFONT_CIDFONT) { m_pCMap = NULL; m_pAllocatedCMap = NULL; m_pCID2UnicodeMap = NULL; m_pAnsiWidths = NULL; m_pCIDToGIDMap = NULL; m_bCIDIsGID = FALSE; m_bAdobeCourierStd = FALSE; m_pTTGSUBTable = NULL; FXSYS_memset(m_CharBBox, 0xff, 256 * sizeof(FX_SMALL_RECT)); } CPDF_CIDFont::~CPDF_CIDFont() { if (m_pAnsiWidths) { FX_Free(m_pAnsiWidths); } delete m_pAllocatedCMap; delete m_pCIDToGIDMap; delete m_pTTGSUBTable; } FX_WORD CPDF_CIDFont::CIDFromCharCode(FX_DWORD charcode) const { if (m_pCMap == NULL) { return (FX_WORD)charcode; } return m_pCMap->CIDFromCharCode(charcode); } FX_BOOL CPDF_CIDFont::IsVertWriting() const { return m_pCMap ? m_pCMap->IsVertWriting() : FALSE; } extern FX_DWORD FPDFAPI_CharCodeFromCID(const FXCMAP_CMap* pMap, FX_WORD cid); static FX_DWORD _EmbeddedCharcodeFromUnicode(const FXCMAP_CMap* pEmbedMap, int charset, FX_WCHAR unicode) { if (charset <= 0 || charset > 4) { return 0; } CPDF_FontGlobals* pFontGlobals = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); const FX_WORD* pCodes = pFontGlobals->m_EmbeddedToUnicodes[charset].m_pMap; if (pCodes == NULL) { return 0; } int nCodes = pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count; for (int i = 0; i < nCodes; i++) { if (pCodes[i] == unicode) { FX_DWORD CharCode = FPDFAPI_CharCodeFromCID(pEmbedMap, i); if (CharCode == 0) { continue; } return CharCode; } } return 0; } static FX_WCHAR _EmbeddedUnicodeFromCharcode(const FXCMAP_CMap* pEmbedMap, int charset, FX_DWORD charcode) { if (charset <= 0 || charset > 4) { return 0; } FX_WORD cid = FPDFAPI_CIDFromCharCode(pEmbedMap, charcode); if (cid == 0) { return 0; } CPDF_FontGlobals* pFontGlobals = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); const FX_WORD* pCodes = pFontGlobals->m_EmbeddedToUnicodes[charset].m_pMap; if (pCodes == NULL) { return 0; } if (cid < pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count) { return pCodes[cid]; } return 0; } FX_WCHAR CPDF_CIDFont::_UnicodeFromCharCode(FX_DWORD charcode) const { switch (m_pCMap->m_Coding) { case CIDCODING_UCS2: case CIDCODING_UTF16: return (FX_WCHAR)charcode; case CIDCODING_CID: if (m_pCID2UnicodeMap == NULL || !m_pCID2UnicodeMap->IsLoaded()) { return 0; } return m_pCID2UnicodeMap->UnicodeFromCID((FX_WORD)charcode); } if (!m_pCMap->IsLoaded() || m_pCID2UnicodeMap == NULL || !m_pCID2UnicodeMap->IsLoaded()) { #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ FX_WCHAR unicode; int charsize = 1; if (charcode > 255) { charcode = (charcode % 256) * 256 + (charcode / 256); charsize = 2; } int ret = FXSYS_MultiByteToWideChar(g_CharsetCPs[m_pCMap->m_Coding], 0, (const FX_CHAR*)&charcode, charsize, &unicode, 1); if (ret != 1) { return 0; } return unicode; #endif if (m_pCMap->m_pEmbedMap) { return _EmbeddedUnicodeFromCharcode(m_pCMap->m_pEmbedMap, m_pCMap->m_Charset, charcode); } return 0; } return m_pCID2UnicodeMap->UnicodeFromCID(CIDFromCharCode(charcode)); } FX_DWORD CPDF_CIDFont::_CharCodeFromUnicode(FX_WCHAR unicode) const { switch (m_pCMap->m_Coding) { case CIDCODING_UNKNOWN: return 0; case CIDCODING_UCS2: case CIDCODING_UTF16: return unicode; case CIDCODING_CID: { if (m_pCID2UnicodeMap == NULL || !m_pCID2UnicodeMap->IsLoaded()) { return 0; } FX_DWORD CID = 0; while (CID < 65536) { FX_WCHAR this_unicode = m_pCID2UnicodeMap->UnicodeFromCID((FX_WORD)CID); if (this_unicode == unicode) { return CID; } CID ++; } break; } } if (unicode < 0x80) { return static_cast<FX_DWORD>(unicode); } if (m_pCMap->m_Coding == CIDCODING_CID) { return 0; } #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ uint8_t buffer[32]; int ret = FXSYS_WideCharToMultiByte(g_CharsetCPs[m_pCMap->m_Coding], 0, &unicode, 1, (char*)buffer, 4, NULL, NULL); if (ret == 1) { return buffer[0]; } if (ret == 2) { return buffer[0] * 256 + buffer[1]; } #else if (m_pCMap->m_pEmbedMap) { return _EmbeddedCharcodeFromUnicode(m_pCMap->m_pEmbedMap, m_pCMap->m_Charset, unicode); } #endif return 0; } static void FT_UseCIDCharmap(FXFT_Face face, int coding) { int encoding; switch (coding) { case CIDCODING_GB: encoding = FXFT_ENCODING_GB2312; break; case CIDCODING_BIG5: encoding = FXFT_ENCODING_BIG5; break; case CIDCODING_JIS: encoding = FXFT_ENCODING_SJIS; break; case CIDCODING_KOREA: encoding = FXFT_ENCODING_JOHAB; break; default: encoding = FXFT_ENCODING_UNICODE; } int err = FXFT_Select_Charmap(face, encoding); if (err) { err = FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE); } if (err && FXFT_Get_Face_Charmaps(face)) { FXFT_Set_Charmap(face, *FXFT_Get_Face_Charmaps(face)); } } FX_BOOL CPDF_CIDFont::_Load() { if (m_pFontDict->GetString(FX_BSTRC("Subtype")) == FX_BSTRC("TrueType")) { return LoadGB2312(); } CPDF_Array* pFonts = m_pFontDict->GetArray(FX_BSTRC("DescendantFonts")); if (pFonts == NULL) { return FALSE; } if (pFonts->GetCount() != 1) { return FALSE; } CPDF_Dictionary* pCIDFontDict = pFonts->GetDict(0); if (pCIDFontDict == NULL) { return FALSE; } m_BaseFont = pCIDFontDict->GetString(FX_BSTRC("BaseFont")); if ((m_BaseFont.Compare("CourierStd") == 0 || m_BaseFont.Compare("CourierStd-Bold") == 0 || m_BaseFont.Compare("CourierStd-BoldOblique") == 0 || m_BaseFont.Compare("CourierStd-Oblique") == 0) && !IsEmbedded()) { m_bAdobeCourierStd = TRUE; } CPDF_Dictionary* pFontDesc = pCIDFontDict->GetDict(FX_BSTRC("FontDescriptor")); if (pFontDesc) { LoadFontDescriptor(pFontDesc); } CPDF_Object* pEncoding = m_pFontDict->GetElementValue(FX_BSTRC("Encoding")); if (pEncoding == NULL) { return FALSE; } CFX_ByteString subtype = pCIDFontDict->GetString(FX_BSTRC("Subtype")); m_bType1 = FALSE; if (subtype == FX_BSTRC("CIDFontType0")) { m_bType1 = TRUE; } if (pEncoding->GetType() == PDFOBJ_NAME) { CFX_ByteString cmap = pEncoding->GetString(); m_pCMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()->m_CMapManager.GetPredefinedCMap(cmap, m_pFontFile && m_bType1); } else if (pEncoding->GetType() == PDFOBJ_STREAM) { m_pAllocatedCMap = m_pCMap = new CPDF_CMap; CPDF_Stream* pStream = (CPDF_Stream*)pEncoding; CPDF_StreamAcc acc; acc.LoadAllData(pStream, FALSE); m_pCMap->LoadEmbedded(acc.GetData(), acc.GetSize()); } else { return FALSE; } if (m_pCMap == NULL) { return FALSE; } m_Charset = m_pCMap->m_Charset; if (m_Charset == CIDSET_UNKNOWN) { CPDF_Dictionary* pCIDInfo = pCIDFontDict->GetDict(FX_BSTRC("CIDSystemInfo")); if (pCIDInfo) { m_Charset = _CharsetFromOrdering(pCIDInfo->GetString(FX_BSTRC("Ordering"))); } } if (m_Charset != CIDSET_UNKNOWN) m_pCID2UnicodeMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()->m_CMapManager.GetCID2UnicodeMap(m_Charset, m_pFontFile == NULL && (m_pCMap->m_Coding == CIDCODING_CID || pCIDFontDict->KeyExist(FX_BSTRC("W")))); if (m_Font.GetFace()) { if (m_bType1) { FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE); } else { FT_UseCIDCharmap(m_Font.GetFace(), m_pCMap->m_Coding); } } m_DefaultWidth = pCIDFontDict->GetInteger(FX_BSTRC("DW"), 1000); CPDF_Array* pWidthArray = pCIDFontDict->GetArray(FX_BSTRC("W")); if (pWidthArray) { LoadMetricsArray(pWidthArray, m_WidthList, 1); } if (!IsEmbedded()) { LoadSubstFont(); } if (1) { if (m_pFontFile || (GetSubstFont()->m_SubstFlags & FXFONT_SUBST_EXACT)) { CPDF_Object* pmap = pCIDFontDict->GetElementValue(FX_BSTRC("CIDToGIDMap")); if (pmap) { if (pmap->GetType() == PDFOBJ_STREAM) { m_pCIDToGIDMap = new CPDF_StreamAcc; m_pCIDToGIDMap->LoadAllData((CPDF_Stream*)pmap, FALSE); } else if (pmap->GetString() == FX_BSTRC("Identity")) { #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ if (m_pFontFile) { m_bCIDIsGID = TRUE; } #else m_bCIDIsGID = TRUE; #endif } } } } CheckFontMetrics(); if (IsVertWriting()) { pWidthArray = pCIDFontDict->GetArray(FX_BSTRC("W2")); if (pWidthArray) { LoadMetricsArray(pWidthArray, m_VertMetrics, 3); } CPDF_Array* pDefaultArray = pCIDFontDict->GetArray(FX_BSTRC("DW2")); if (pDefaultArray) { m_DefaultVY = pDefaultArray->GetInteger(0); m_DefaultW1 = pDefaultArray->GetInteger(1); } else { m_DefaultVY = 880; m_DefaultW1 = -1000; } } return TRUE; } FX_FLOAT _CIDTransformToFloat(uint8_t ch) { if (ch < 128) { return ch * 1.0f / 127; } return (-255 + ch) * 1.0f / 127; } void CPDF_CIDFont::GetCharBBox(FX_DWORD charcode, FX_RECT& rect, int level) { if (charcode < 256 && m_CharBBox[charcode].Right != -1) { rect.bottom = m_CharBBox[charcode].Bottom; rect.left = m_CharBBox[charcode].Left; rect.right = m_CharBBox[charcode].Right; rect.top = m_CharBBox[charcode].Top; return; } FX_BOOL bVert = FALSE; int glyph_index = GlyphFromCharCode(charcode, &bVert); if (m_Font.m_Face == NULL) { rect = FX_RECT(0, 0, 0, 0); } else { rect.left = rect.bottom = rect.right = rect.top = 0; FXFT_Face face = m_Font.m_Face; if (FXFT_Is_Face_Tricky(face)) { int err = FXFT_Load_Glyph(face, glyph_index, FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH); if (!err) { FXFT_BBox cbox; FXFT_Glyph glyph; err = FXFT_Get_Glyph(((FXFT_Face)face)->glyph, &glyph); if (!err) { FXFT_Glyph_Get_CBox(glyph, FXFT_GLYPH_BBOX_PIXELS, &cbox); int pixel_size_x = ((FXFT_Face)face)->size->metrics.x_ppem; int pixel_size_y = ((FXFT_Face)face)->size->metrics.y_ppem; if (pixel_size_x == 0 || pixel_size_y == 0) { rect.left = cbox.xMin; rect.right = cbox.xMax; rect.top = cbox.yMax; rect.bottom = cbox.yMin; } else { rect.left = cbox.xMin * 1000 / pixel_size_x; rect.right = cbox.xMax * 1000 / pixel_size_x; rect.top = cbox.yMax * 1000 / pixel_size_y; rect.bottom = cbox.yMin * 1000 / pixel_size_y; } if (rect.top > FXFT_Get_Face_Ascender(face)) { rect.top = FXFT_Get_Face_Ascender(face); } if (rect.bottom < FXFT_Get_Face_Descender(face)) { rect.bottom = FXFT_Get_Face_Descender(face); } FXFT_Done_Glyph(glyph); } } } else { int err = FXFT_Load_Glyph(face, glyph_index, FXFT_LOAD_NO_SCALE); if (err == 0) { rect.left = TT2PDF(FXFT_Get_Glyph_HoriBearingX(face), face); rect.right = TT2PDF(FXFT_Get_Glyph_HoriBearingX(face) + FXFT_Get_Glyph_Width(face), face); rect.top = TT2PDF(FXFT_Get_Glyph_HoriBearingY(face), face); rect.top += rect.top / 64; rect.bottom = TT2PDF(FXFT_Get_Glyph_HoriBearingY(face) - FXFT_Get_Glyph_Height(face), face); } } } if (m_pFontFile == NULL && m_Charset == CIDSET_JAPAN1) { FX_WORD CID = CIDFromCharCode(charcode); const uint8_t* pTransform = GetCIDTransform(CID); if (pTransform && !bVert) { CFX_AffineMatrix matrix(_CIDTransformToFloat(pTransform[0]), _CIDTransformToFloat(pTransform[1]), _CIDTransformToFloat(pTransform[2]), _CIDTransformToFloat(pTransform[3]), _CIDTransformToFloat(pTransform[4]) * 1000 , _CIDTransformToFloat(pTransform[5]) * 1000); CFX_FloatRect rect_f(rect); rect_f.Transform(&matrix); rect = rect_f.GetOutterRect(); } } if (charcode < 256) { m_CharBBox[charcode].Bottom = (short)rect.bottom; m_CharBBox[charcode].Left = (short)rect.left; m_CharBBox[charcode].Right = (short)rect.right; m_CharBBox[charcode].Top = (short)rect.top; } } int CPDF_CIDFont::GetCharWidthF(FX_DWORD charcode, int level) { if (m_pAnsiWidths && charcode < 0x80) { return m_pAnsiWidths[charcode]; } FX_WORD cid = CIDFromCharCode(charcode); int size = m_WidthList.GetSize(); FX_DWORD* list = m_WidthList.GetData(); for (int i = 0; i < size; i += 3) { if (cid >= list[i] && cid <= list[i + 1]) { return (int)list[i + 2]; } } return m_DefaultWidth; } short CPDF_CIDFont::GetVertWidth(FX_WORD CID) const { FX_DWORD vertsize = m_VertMetrics.GetSize() / 5; if (vertsize == 0) { return m_DefaultW1; } const FX_DWORD* pTable = m_VertMetrics.GetData(); for (FX_DWORD i = 0; i < vertsize; i ++) if (pTable[i * 5] <= CID && pTable[i * 5 + 1] >= CID) { return (short)(int)pTable[i * 5 + 2]; } return m_DefaultW1; } void CPDF_CIDFont::GetVertOrigin(FX_WORD CID, short& vx, short &vy) const { FX_DWORD vertsize = m_VertMetrics.GetSize() / 5; if (vertsize) { const FX_DWORD* pTable = m_VertMetrics.GetData(); for (FX_DWORD i = 0; i < vertsize; i ++) if (pTable[i * 5] <= CID && pTable[i * 5 + 1] >= CID) { vx = (short)(int)pTable[i * 5 + 3]; vy = (short)(int)pTable[i * 5 + 4]; return; } } FX_DWORD dwWidth = m_DefaultWidth; int size = m_WidthList.GetSize(); const FX_DWORD* list = m_WidthList.GetData(); for (int i = 0; i < size; i += 3) { if (CID >= list[i] && CID <= list[i + 1]) { dwWidth = (FX_WORD)list[i + 2]; break; } } vx = (short)dwWidth / 2; vy = (short)m_DefaultVY; } int CPDF_CIDFont::GetGlyphIndex(FX_DWORD unicode, FX_BOOL *pVertGlyph) { if (pVertGlyph) { *pVertGlyph = FALSE; } int index = FXFT_Get_Char_Index(m_Font.m_Face, unicode ); if (unicode == 0x2502) { return index; } if (index && IsVertWriting()) { if (m_pTTGSUBTable) { TT_uint32_t vindex = 0; m_pTTGSUBTable->GetVerticalGlyph(index, &vindex); if (vindex) { index = vindex; if (pVertGlyph) { *pVertGlyph = TRUE; } } return index; } if (NULL == m_Font.m_pGsubData) { unsigned long length = 0; int error = FXFT_Load_Sfnt_Table( m_Font.m_Face, FT_MAKE_TAG('G', 'S', 'U', 'B'), 0, NULL, &length); if (!error) { m_Font.m_pGsubData = (unsigned char*)FX_Alloc(uint8_t, length); } } int error = FXFT_Load_Sfnt_Table( m_Font.m_Face, FT_MAKE_TAG('G', 'S', 'U', 'B'), 0, m_Font.m_pGsubData, NULL); if (!error && m_Font.m_pGsubData) { m_pTTGSUBTable = new CFX_CTTGSUBTable; m_pTTGSUBTable->LoadGSUBTable((FT_Bytes)m_Font.m_pGsubData); TT_uint32_t vindex = 0; m_pTTGSUBTable->GetVerticalGlyph(index, &vindex); if (vindex) { index = vindex; if (pVertGlyph) { *pVertGlyph = TRUE; } } } return index; } if (pVertGlyph) { *pVertGlyph = FALSE; } return index; } int CPDF_CIDFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph) { if (pVertGlyph) { *pVertGlyph = FALSE; } if (m_pFontFile == NULL && m_pCIDToGIDMap == NULL) { FX_WORD cid = CIDFromCharCode(charcode); FX_WCHAR unicode = 0; if (m_bCIDIsGID) { #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ return cid; #else if (m_Flags & PDFFONT_SYMBOLIC) { return cid; } CFX_WideString uni_str = UnicodeFromCharCode(charcode); if (uni_str.IsEmpty()) { return cid; } unicode = uni_str.GetAt(0); #endif } else { if (cid && m_pCID2UnicodeMap && m_pCID2UnicodeMap->IsLoaded()) { unicode = m_pCID2UnicodeMap->UnicodeFromCID(cid); } if (unicode == 0) { unicode = _UnicodeFromCharCode(charcode); } if (unicode == 0 && !(m_Flags & PDFFONT_SYMBOLIC)) { unicode = UnicodeFromCharCode(charcode).GetAt(0); } } if (unicode == 0) { if (!m_bAdobeCourierStd) { return charcode == 0 ? -1 : (int)charcode; } charcode += 31; int index = 0, iBaseEncoding; FX_BOOL bMSUnicode = FT_UseTTCharmap(m_Font.m_Face, 3, 1); FX_BOOL bMacRoman = FALSE; if (!bMSUnicode) { bMacRoman = FT_UseTTCharmap(m_Font.m_Face, 1, 0); } iBaseEncoding = PDFFONT_ENCODING_STANDARD; if (bMSUnicode) { iBaseEncoding = PDFFONT_ENCODING_WINANSI; } else if (bMacRoman) { iBaseEncoding = PDFFONT_ENCODING_MACROMAN; } const FX_CHAR* name = GetAdobeCharName(iBaseEncoding, NULL, charcode); if (name == NULL) { return charcode == 0 ? -1 : (int)charcode; } FX_WORD unicode = PDF_UnicodeFromAdobeName(name); if (unicode) { if (bMSUnicode) { index = FXFT_Get_Char_Index(m_Font.m_Face, unicode); } else if (bMacRoman) { FX_DWORD maccode = FT_CharCodeFromUnicode(FXFT_ENCODING_APPLE_ROMAN, unicode); index = !maccode ? FXFT_Get_Name_Index(m_Font.m_Face, (char *)name) : FXFT_Get_Char_Index(m_Font.m_Face, maccode); } else { return FXFT_Get_Char_Index(m_Font.m_Face, unicode); } } else { return charcode == 0 ? -1 : (int)charcode; } if (index == 0 || index == 0xffff) { return charcode == 0 ? -1 : (int)charcode; } return index; } if (m_Charset == CIDSET_JAPAN1) { if (unicode == '\\') { unicode = '/'; } #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ else if (unicode == 0xa5) { unicode = 0x5c; } #endif } if (m_Font.m_Face == NULL) { return unicode; } int err = FXFT_Select_Charmap(m_Font.m_Face, FXFT_ENCODING_UNICODE); if (err != 0) { int i; for (i = 0; i < FXFT_Get_Face_CharmapCount(m_Font.m_Face); i ++) { FX_DWORD ret = FT_CharCodeFromUnicode(FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(m_Font.m_Face)[i]), (FX_WCHAR)charcode); if (ret == 0) { continue; } FXFT_Set_Charmap(m_Font.m_Face, FXFT_Get_Face_Charmaps(m_Font.m_Face)[i]); unicode = (FX_WCHAR)ret; break; } if (i == FXFT_Get_Face_CharmapCount(m_Font.m_Face) && i) { FXFT_Set_Charmap(m_Font.m_Face, FXFT_Get_Face_Charmaps(m_Font.m_Face)[0]); unicode = (FX_WCHAR)charcode; } } if (FXFT_Get_Face_Charmap(m_Font.m_Face)) { int index = GetGlyphIndex(unicode, pVertGlyph); if (index == 0) { return -1; } return index; } return unicode ; } if (m_Font.m_Face == NULL) { return -1; } FX_WORD cid = CIDFromCharCode(charcode); if (m_bType1) { if (NULL == m_pCIDToGIDMap) { return cid; } } else { if (m_pCIDToGIDMap == NULL) { if (m_pFontFile && m_pCMap->m_pMapping == NULL) { return cid; } if (m_pCMap->m_Coding == CIDCODING_UNKNOWN || FXFT_Get_Face_Charmap(m_Font.m_Face) == NULL) { return cid; } if (FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmap(m_Font.m_Face)) == FXFT_ENCODING_UNICODE) { CFX_WideString unicode_str = UnicodeFromCharCode(charcode); if (unicode_str.IsEmpty()) { return -1; } charcode = unicode_str.GetAt(0); } return GetGlyphIndex(charcode, pVertGlyph); } } FX_DWORD byte_pos = cid * 2; if (byte_pos + 2 > m_pCIDToGIDMap->GetSize()) { return -1; } const uint8_t* pdata = m_pCIDToGIDMap->GetData() + byte_pos; return pdata[0] * 256 + pdata[1]; } FX_DWORD CPDF_CIDFont::GetNextChar(const FX_CHAR* pString, int nStrLen, int& offset) const { return m_pCMap->GetNextChar(pString, nStrLen, offset); } int CPDF_CIDFont::GetCharSize(FX_DWORD charcode) const { return m_pCMap->GetCharSize(charcode); } int CPDF_CIDFont::CountChar(const FX_CHAR* pString, int size) const { return m_pCMap->CountChar(pString, size); } int CPDF_CIDFont::AppendChar(FX_CHAR* str, FX_DWORD charcode) const { return m_pCMap->AppendChar(str, charcode); } FX_BOOL CPDF_CIDFont::IsUnicodeCompatible() const { if (!m_pCMap->IsLoaded() || m_pCID2UnicodeMap == NULL || !m_pCID2UnicodeMap->IsLoaded()) { return m_pCMap->m_Coding != CIDCODING_UNKNOWN; } return TRUE; } FX_BOOL CPDF_CIDFont::IsFontStyleFromCharCode(FX_DWORD charcode) const { return TRUE; } void CPDF_CIDFont::LoadSubstFont() { m_Font.LoadSubst(m_BaseFont, !m_bType1, m_Flags, m_StemV * 5, m_ItalicAngle, g_CharsetCPs[m_Charset], IsVertWriting()); } void CPDF_CIDFont::LoadMetricsArray(CPDF_Array* pArray, CFX_DWordArray& result, int nElements) { int width_status = 0; int iCurElement = 0; int first_code = 0, last_code; FX_DWORD count = pArray->GetCount(); for (FX_DWORD i = 0; i < count; i ++) { CPDF_Object* pObj = pArray->GetElementValue(i); if (pObj == NULL) { continue; } if (pObj->GetType() == PDFOBJ_ARRAY) { if (width_status != 1) { return; } CPDF_Array* pArray = (CPDF_Array*)pObj; FX_DWORD count = pArray->GetCount(); for (FX_DWORD j = 0; j < count; j += nElements) { result.Add(first_code); result.Add(first_code); for (int k = 0; k < nElements; k ++) { result.Add(pArray->GetInteger(j + k)); } first_code ++; } width_status = 0; } else { if (width_status == 0) { first_code = pObj->GetInteger(); width_status = 1; } else if (width_status == 1) { last_code = pObj->GetInteger(); width_status = 2; iCurElement = 0; } else { if (!iCurElement) { result.Add(first_code); result.Add(last_code); } result.Add(pObj->GetInteger()); iCurElement ++; if (iCurElement == nElements) { width_status = 0; } } } } } FX_BOOL CPDF_CIDFont::LoadGB2312() { m_BaseFont = m_pFontDict->GetString(FX_BSTRC("BaseFont")); CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict(FX_BSTRC("FontDescriptor")); if (pFontDesc) { LoadFontDescriptor(pFontDesc); } m_Charset = CIDSET_GB1; m_bType1 = FALSE; m_pCMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()->m_CMapManager.GetPredefinedCMap( FX_BSTRC("GBK-EUC-H"), FALSE); m_pCID2UnicodeMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()->m_CMapManager.GetCID2UnicodeMap(m_Charset, FALSE); if (!IsEmbedded()) { LoadSubstFont(); } CheckFontMetrics(); m_DefaultWidth = 1000; m_pAnsiWidths = FX_Alloc(FX_WORD, 128); for (int i = 32; i < 127; i ++) { m_pAnsiWidths[i] = 500; } return TRUE; } const struct _CIDTransform { FX_WORD CID; uint8_t a, b, c, d, e, f; } Japan1_VertCIDs[] = { {97, 129, 0, 0, 127, 55, 0}, {7887, 127, 0, 0, 127, 76, 89}, {7888, 127, 0, 0, 127, 79, 94}, {7889, 0, 129, 127, 0, 17, 127}, {7890, 0, 129, 127, 0, 17, 127}, {7891, 0, 129, 127, 0, 17, 127}, {7892, 0, 129, 127, 0, 17, 127}, {7893, 0, 129, 127, 0, 17, 127}, {7894, 0, 129, 127, 0, 17, 127}, {7895, 0, 129, 127, 0, 17, 127}, {7896, 0, 129, 127, 0, 17, 127}, {7897, 0, 129, 127, 0, 17, 127}, {7898, 0, 129, 127, 0, 17, 127}, {7899, 0, 129, 127, 0, 17, 104}, {7900, 0, 129, 127, 0, 17, 127}, {7901, 0, 129, 127, 0, 17, 104}, {7902, 0, 129, 127, 0, 17, 127}, {7903, 0, 129, 127, 0, 17, 127}, {7904, 0, 129, 127, 0, 17, 127}, {7905, 0, 129, 127, 0, 17, 114}, {7906, 0, 129, 127, 0, 17, 127}, {7907, 0, 129, 127, 0, 17, 127}, {7908, 0, 129, 127, 0, 17, 127}, {7909, 0, 129, 127, 0, 17, 127}, {7910, 0, 129, 127, 0, 17, 127}, {7911, 0, 129, 127, 0, 17, 127}, {7912, 0, 129, 127, 0, 17, 127}, {7913, 0, 129, 127, 0, 17, 127}, {7914, 0, 129, 127, 0, 17, 127}, {7915, 0, 129, 127, 0, 17, 114}, {7916, 0, 129, 127, 0, 17, 127}, {7917, 0, 129, 127, 0, 17, 127}, {7918, 127, 0, 0, 127, 18, 25}, {7919, 127, 0, 0, 127, 18, 25}, {7920, 127, 0, 0, 127, 18, 25}, {7921, 127, 0, 0, 127, 18, 25}, {7922, 127, 0, 0, 127, 18, 25}, {7923, 127, 0, 0, 127, 18, 25}, {7924, 127, 0, 0, 127, 18, 25}, {7925, 127, 0, 0, 127, 18, 25}, {7926, 127, 0, 0, 127, 18, 25}, {7927, 127, 0, 0, 127, 18, 25}, {7928, 127, 0, 0, 127, 18, 25}, {7929, 127, 0, 0, 127, 18, 25}, {7930, 127, 0, 0, 127, 18, 25}, {7931, 127, 0, 0, 127, 18, 25}, {7932, 127, 0, 0, 127, 18, 25}, {7933, 127, 0, 0, 127, 18, 25}, {7934, 127, 0, 0, 127, 18, 25}, {7935, 127, 0, 0, 127, 18, 25}, {7936, 127, 0, 0, 127, 18, 25}, {7937, 127, 0, 0, 127, 18, 25}, {7938, 127, 0, 0, 127, 18, 25}, {7939, 127, 0, 0, 127, 18, 25}, {8720, 0, 129, 127, 0, 19, 102}, {8721, 0, 129, 127, 0, 13, 127}, {8722, 0, 129, 127, 0, 19, 108}, {8723, 0, 129, 127, 0, 19, 102}, {8724, 0, 129, 127, 0, 19, 102}, {8725, 0, 129, 127, 0, 19, 102}, {8726, 0, 129, 127, 0, 19, 102}, {8727, 0, 129, 127, 0, 19, 102}, {8728, 0, 129, 127, 0, 19, 114}, {8729, 0, 129, 127, 0, 19, 114}, {8730, 0, 129, 127, 0, 38, 108}, {8731, 0, 129, 127, 0, 13, 108}, {8732, 0, 129, 127, 0, 19, 108}, {8733, 0, 129, 127, 0, 19, 108}, {8734, 0, 129, 127, 0, 19, 108}, {8735, 0, 129, 127, 0, 19, 108}, {8736, 0, 129, 127, 0, 19, 102}, {8737, 0, 129, 127, 0, 19, 102}, {8738, 0, 129, 127, 0, 19, 102}, {8739, 0, 129, 127, 0, 19, 102}, {8740, 0, 129, 127, 0, 19, 102}, {8741, 0, 129, 127, 0, 19, 102}, {8742, 0, 129, 127, 0, 19, 102}, {8743, 0, 129, 127, 0, 19, 102}, {8744, 0, 129, 127, 0, 19, 102}, {8745, 0, 129, 127, 0, 19, 102}, {8746, 0, 129, 127, 0, 19, 114}, {8747, 0, 129, 127, 0, 19, 114}, {8748, 0, 129, 127, 0, 19, 102}, {8749, 0, 129, 127, 0, 19, 102}, {8750, 0, 129, 127, 0, 19, 102}, {8751, 0, 129, 127, 0, 19, 102}, {8752, 0, 129, 127, 0, 19, 102}, {8753, 0, 129, 127, 0, 19, 102}, {8754, 0, 129, 127, 0, 19, 102}, {8755, 0, 129, 127, 0, 19, 102}, {8756, 0, 129, 127, 0, 19, 102}, {8757, 0, 129, 127, 0, 19, 102}, {8758, 0, 129, 127, 0, 19, 102}, {8759, 0, 129, 127, 0, 19, 102}, {8760, 0, 129, 127, 0, 19, 102}, {8761, 0, 129, 127, 0, 19, 102}, {8762, 0, 129, 127, 0, 19, 102}, {8763, 0, 129, 127, 0, 19, 102}, {8764, 0, 129, 127, 0, 19, 102}, {8765, 0, 129, 127, 0, 19, 102}, {8766, 0, 129, 127, 0, 19, 102}, {8767, 0, 129, 127, 0, 19, 102}, {8768, 0, 129, 127, 0, 19, 102}, {8769, 0, 129, 127, 0, 19, 102}, {8770, 0, 129, 127, 0, 19, 102}, {8771, 0, 129, 127, 0, 19, 102}, {8772, 0, 129, 127, 0, 19, 102}, {8773, 0, 129, 127, 0, 19, 102}, {8774, 0, 129, 127, 0, 19, 102}, {8775, 0, 129, 127, 0, 19, 102}, {8776, 0, 129, 127, 0, 19, 102}, {8777, 0, 129, 127, 0, 19, 102}, {8778, 0, 129, 127, 0, 19, 102}, {8779, 0, 129, 127, 0, 19, 114}, {8780, 0, 129, 127, 0, 19, 108}, {8781, 0, 129, 127, 0, 19, 114}, {8782, 0, 129, 127, 0, 13, 114}, {8783, 0, 129, 127, 0, 19, 108}, {8784, 0, 129, 127, 0, 13, 114}, {8785, 0, 129, 127, 0, 19, 108}, {8786, 0, 129, 127, 0, 19, 108}, {8787, 0, 129, 127, 0, 19, 108}, {8788, 0, 129, 127, 0, 19, 108}, {8789, 0, 129, 127, 0, 19, 108}, {8790, 0, 129, 127, 0, 19, 108}, {8791, 0, 129, 127, 0, 19, 108}, {8792, 0, 129, 127, 0, 19, 108}, {8793, 0, 129, 127, 0, 19, 108}, {8794, 0, 129, 127, 0, 19, 108}, {8795, 0, 129, 127, 0, 19, 108}, {8796, 0, 129, 127, 0, 19, 108}, {8797, 0, 129, 127, 0, 19, 108}, {8798, 0, 129, 127, 0, 19, 108}, {8799, 0, 129, 127, 0, 19, 108}, {8800, 0, 129, 127, 0, 19, 108}, {8801, 0, 129, 127, 0, 19, 108}, {8802, 0, 129, 127, 0, 19, 108}, {8803, 0, 129, 127, 0, 19, 108}, {8804, 0, 129, 127, 0, 19, 108}, {8805, 0, 129, 127, 0, 19, 108}, {8806, 0, 129, 127, 0, 19, 108}, {8807, 0, 129, 127, 0, 19, 108}, {8808, 0, 129, 127, 0, 19, 108}, {8809, 0, 129, 127, 0, 19, 108}, {8810, 0, 129, 127, 0, 19, 108}, {8811, 0, 129, 127, 0, 19, 114}, {8812, 0, 129, 127, 0, 19, 102}, {8813, 0, 129, 127, 0, 19, 114}, {8814, 0, 129, 127, 0, 76, 102}, {8815, 0, 129, 127, 0, 13, 121}, {8816, 0, 129, 127, 0, 19, 114}, {8817, 0, 129, 127, 0, 19, 127}, {8818, 0, 129, 127, 0, 19, 114}, {8819, 0, 129, 127, 0, 218, 108}, }; const uint8_t* CPDF_CIDFont::GetCIDTransform(FX_WORD CID) const { if (m_Charset != CIDSET_JAPAN1 || m_pFontFile != NULL) { return NULL; } int begin = 0; int end = sizeof Japan1_VertCIDs / sizeof(struct _CIDTransform) - 1; while (begin <= end) { int middle = (begin + end) / 2; FX_WORD middlecode = Japan1_VertCIDs[middle].CID; if (middlecode > CID) { end = middle - 1; } else if (middlecode < CID) { begin = middle + 1; } else { return &Japan1_VertCIDs[middle].a; } } return NULL; }
/* Copyright (c) Microsoft Corporation. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #include "dml_descriptor_bfc_allocator.h" namespace tensorflow { DmlDescriptorAllocator::DmlDescriptorAllocator( D3D12DescriptorHeapAllocator* heap_allocator, const string& name) : BFCAllocator(new SubAllocatorWrapper(heap_allocator), kMaxTotalDescriptors, kAllowGrowth, name, kEnableGarbageCollection, 0, kMaxAllocationSizeInDescriptors), heap_allocator_(heap_allocator) {} DescriptorAllocation DmlDescriptorAllocator::Alloc(size_t size_in_descriptors) { void* p = this->AllocateRaw(0, size_in_descriptors); return DescriptorAllocation(this, p, size_in_descriptors); } D3D12DescriptorHandles DmlDescriptorAllocator::GetDescriptorHandles( const void* ptr) const { return heap_allocator_->GetDescriptorHandles(ptr); } DescriptorAllocation::DescriptorAllocation(DmlDescriptorAllocator* allocator, void* p, size_t size_in_descriptors) : allocator_(allocator), p_(p), size_in_descriptors_(size_in_descriptors) {} DescriptorAllocation ::~DescriptorAllocation() { Reset(); } DescriptorAllocation::DescriptorAllocation(DescriptorAllocation&& x) { *this = std::move(x); } DescriptorAllocation& DescriptorAllocation::operator=( DescriptorAllocation&& x) { if (this != &x) { allocator_ = x.allocator_; p_ = x.p_; size_in_descriptors_ = x.size_in_descriptors_; x.allocator_ = nullptr; x.p_ = nullptr; x.size_in_descriptors_ = 0; } return *this; } D3D12DescriptorHandles DescriptorAllocation::GetDescriptorHandles() const { if (!allocator_ || !p_) { return D3D12DescriptorHandles{nullptr, UINT64(-1), SIZE_T(-1)}; } return allocator_->GetDescriptorHandles(p_); } void DescriptorAllocation::Reset() { if (allocator_ && p_) { allocator_->DeallocateRaw(p_); } allocator_ = nullptr; p_ = nullptr; size_in_descriptors_ = 0; } } // namespace tensorflow
#include "hb-fuzzer.hh" #include <stdlib.h> #include <stdio.h> #include <string.h> #include <assert.h> #include "hb-subset.h" static void trySubset (hb_face_t* face, const hb_codepoint_t text[], int text_length, bool drop_hints, bool drop_layout, bool retain_gids) { hb_subset_input_t* input = hb_subset_input_create_or_fail (); if (!input) return; hb_subset_input_set_drop_hints (input, drop_hints); hb_subset_input_set_retain_gids (input, retain_gids); hb_set_t* codepoints = hb_subset_input_unicode_set (input); if (!drop_layout) { hb_set_del (hb_subset_input_drop_tables_set (input), HB_TAG ('G', 'S', 'U', 'B')); hb_set_del (hb_subset_input_drop_tables_set (input), HB_TAG ('G', 'P', 'O', 'S')); hb_set_del (hb_subset_input_drop_tables_set (input), HB_TAG ('G', 'D', 'E', 'F')); } for (int i = 0; i < text_length; i++) hb_set_add (codepoints, text[i]); hb_face_t* result = hb_subset (face, input); { hb_blob_t* blob = hb_face_reference_blob (result); unsigned int length; const char* data = hb_blob_get_data (blob, &length); // Something not optimizable just to access all the blob data unsigned int bytes_count = 0; for (unsigned int i = 0; i < length; ++i) if (data[i]) ++bytes_count; assert (bytes_count || !length); hb_blob_destroy (blob); } hb_face_destroy (result); hb_subset_input_destroy (input); } static void trySubset (hb_face_t* face, const hb_codepoint_t text[], int text_length, const uint8_t flags[1]) { bool drop_hints = flags[0] & (1 << 0); bool drop_layout = flags[0] & (1 << 1); bool retain_gids = flags[0] & (1 << 2); trySubset (face, text, text_length, drop_hints, drop_layout, retain_gids); } extern "C" int LLVMFuzzerTestOneInput (const uint8_t* data, size_t size) { alloc_state = size; /* see src/failing-alloc.c */ hb_blob_t* blob = hb_blob_create ((const char*) data, size, HB_MEMORY_MODE_READONLY, nullptr, nullptr); hb_face_t* face = hb_face_create (blob, 0); /* Just test this API here quickly. */ hb_set_t* output = hb_set_create (); hb_face_collect_unicodes (face, output); hb_set_destroy (output); uint8_t flags[1] = {0}; const hb_codepoint_t text[] = { 'A', 'B', 'C', 'D', 'E', 'X', 'Y', 'Z', '1', '2', '3', '@', '_', '%', '&', ')', '*', '$', '!' }; trySubset (face, text, sizeof (text) / sizeof (hb_codepoint_t), flags); hb_codepoint_t text_from_data[16]; if (size > sizeof (text_from_data) + sizeof (flags)) { memcpy (text_from_data, data + size - sizeof (text_from_data), sizeof (text_from_data)); memcpy (flags, data + size - sizeof (text_from_data) - sizeof (flags), sizeof (flags)); unsigned int text_size = sizeof (text_from_data) / sizeof (hb_codepoint_t); trySubset (face, text_from_data, text_size, flags); } hb_face_destroy (face); hb_blob_destroy (blob); return 0; }
#include <router/abstractrouter.hpp> namespace llarp { } // namespace llarp
/// @brief Include to save KTX textures to files or memory. /// @file gli/save_ktx.hpp #pragma once #include "texture.hpp" namespace gli { /// Save a texture storage_linear to a KTX file. /// /// @param Texture Source texture to save /// @param Path Path for where to save the file. It must include the filaname and filename extension. /// This function ignores the filename extension in the path and save to KTX anyway but keep the requested filename extension. /// @return Returns false if the function fails to save the file. bool save_ktx(texture const & Texture, char const * Path); /// Save a texture storage_linear to a KTX file. /// /// @param Texture Source texture to save /// @param Path Path for where to save the file. It must include the filaname and filename extension. /// This function ignores the filename extension in the path and save to KTX anyway but keep the requested filename extension. /// @return Returns false if the function fails to save the file. bool save_ktx(texture const & Texture, std::string const & Path); /// Save a texture storage_linear to a KTX file. /// /// @param Texture Source texture to save /// @param Memory Storage for the KTX container. The function resizes the containers to fit the necessary storage_linear. /// @return Returns false if the function fails to save the file. bool save_ktx(texture const & Texture, std::vector<char> & Memory); }//namespace gli #include "./core/save_ktx.inl"
/** * @file lltoolgun.cpp * @brief LLToolGun class implementation * * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ #include "llviewerprecompiledheaders.h" #include "lltoolgun.h" #include "llviewerwindow.h" #include "llagent.h" #include "llagentcamera.h" #include "llviewercontrol.h" #include "llsky.h" #include "llappviewer.h" #include "llresmgr.h" #include "llfontgl.h" #include "llui.h" #include "llviewertexturelist.h" #include "llviewercamera.h" // [RLVa:KB] - Checked: 2014-02-24 (RLVa-1.4.10) #include "llfocusmgr.h" // [/RLVa:KB] #include "llhudmanager.h" #include "lltoolmgr.h" #include "lltoolgrab.h" #include "lluiimage.h" // <CV:David> #include "llviewerdisplay.h" // </CV:David> // Linden library includes #include "llwindow.h" // setMouseClipping() LLToolGun::LLToolGun( LLToolComposite* composite ) : LLTool( std::string("gun"), composite ), mIsSelected(FALSE) { // <FS:Ansariel> Performance tweak mCrosshairp = LLUI::getUIImage("crosshairs.tga"); } void LLToolGun::handleSelect() { // [RLVa:KB] - Checked: 2014-02-24 (RLVa-1.4.10) if (gFocusMgr.getAppHasFocus()) { // [/RLVa:KB] gViewerWindow->hideCursor(); // <CV:David> // Jumping the cursor to the centre of the screen when using it to interact with objects is annoying. //gViewerWindow->moveCursorToCenter(); // <CV:David> gViewerWindow->getWindow()->setMouseClipping(TRUE); mIsSelected = TRUE; // [RLVa:KB] - Checked: 2014-02-24 (RLVa-1.4.10) } // [/RLVa:KB] } void LLToolGun::handleDeselect() { // <CV:David> // Jumping the cursor to the centre of the screen when using it to interact with objects is annoying. //gViewerWindow->moveCursorToCenter(); // <CV:David> gViewerWindow->showCursor(); gViewerWindow->getWindow()->setMouseClipping(FALSE); mIsSelected = FALSE; } BOOL LLToolGun::handleMouseDown(S32 x, S32 y, MASK mask) { gGrabTransientTool = this; LLToolMgr::getInstance()->getCurrentToolset()->selectTool( LLToolGrab::getInstance() ); return LLToolGrab::getInstance()->handleMouseDown(x, y, mask); } BOOL LLToolGun::handleHover(S32 x, S32 y, MASK mask) { if( gAgentCamera.cameraMouselook() && mIsSelected ) { const F32 NOMINAL_MOUSE_SENSITIVITY = 0.0025f; // <FS:Ansariel> Use faster LLCachedControl //F32 mouse_sensitivity = gSavedSettings.getF32("MouseSensitivity"); static LLCachedControl<F32> mouseSensitivity(gSavedSettings, "MouseSensitivity"); F32 mouse_sensitivity = (F32)mouseSensitivity; // </FS:Ansariel> Use faster LLCachedControl mouse_sensitivity = clamp_rescale(mouse_sensitivity, 0.f, 15.f, 0.5f, 2.75f) * NOMINAL_MOUSE_SENSITIVITY; // ...move the view with the mouse // get mouse movement delta S32 dx = -gViewerWindow->getCurrentMouseDX(); // <CV:David> //S32 dy = -gViewerWindow->getCurrentMouseDY(); S32 dy = (gRift3DEnabled && gRiftMouseHorizontal) ? 0 : -gViewerWindow->getCurrentMouseDY(); // </CV:David> if (dx != 0 || dy != 0) { // ...actually moved off center // <FS:Ansariel> Use faster LLCachedControl //if (gSavedSettings.getBOOL("InvertMouse")) static LLCachedControl<bool> invertMouse(gSavedSettings, "InvertMouse"); if (invertMouse) { gAgent.pitch(mouse_sensitivity * -dy); } else { gAgent.pitch(mouse_sensitivity * dy); } LLVector3 skyward = gAgent.getReferenceUpVector(); gAgent.rotate(mouse_sensitivity * dx, skyward.mV[VX], skyward.mV[VY], skyward.mV[VZ]); // <FS:Ansariel> Use faster LLCachedControl //if (gSavedSettings.getBOOL("MouseSun")) static LLCachedControl<bool> mouseSun(gSavedSettings, "MouseSun"); if (mouseSun) { gSky.setSunDirection(LLViewerCamera::getInstance()->getAtAxis(), LLVector3(0.f, 0.f, 0.f)); gSky.setOverrideSun(TRUE); gSavedSettings.setVector3("SkySunDefaultPosition", LLViewerCamera::getInstance()->getAtAxis()); } gViewerWindow->moveCursorToCenter(); gViewerWindow->hideCursor(); } LL_DEBUGS("UserInput") << "hover handled by LLToolGun (mouselook)" << LL_ENDL; } else { LL_DEBUGS("UserInput") << "hover handled by LLToolGun (not mouselook)" << LL_ENDL; } // HACK to avoid assert: error checking system makes sure that the cursor is set during every handleHover. This is actually a no-op since the cursor is hidden. gViewerWindow->setCursor(UI_CURSOR_ARROW); return TRUE; } void LLToolGun::draw() { // <FS:Ansariel> Use faster LLCachedControl //if( gSavedSettings.getBOOL("ShowCrosshairs") ) static LLCachedControl<bool> showCrosshairs(gSavedSettings, "ShowCrosshairs"); // <CV:David> //if (showCrosshairs) if (!gRift3DEnabled && showCrosshairs) // </CV:David> { // <FS:Ansariel> Performance tweak //LLUIImagePtr crosshair = LLUI::getUIImage("crosshairs.tga"); //crosshair->draw( // ( gViewerWindow->getWorldViewRectScaled().getWidth() - crosshair->getWidth() ) / 2, // ( gViewerWindow->getWorldViewRectScaled().getHeight() - crosshair->getHeight() ) / 2); mCrosshairp->draw( ( gViewerWindow->getWorldViewRectScaled().getWidth() - mCrosshairp->getWidth() ) / 2, ( gViewerWindow->getWorldViewRectScaled().getHeight() - mCrosshairp->getHeight() ) / 2); // </FS:Ansariel> Performance tweak } }
#include "Adapter.h" #include "Adaptee.h" using namespace adapter; Adapter::Adapter() { m_Adaptee = new Adaptee(); } Adapter::~Adapter() { delete m_Adaptee; } void Adapter::ExistingMethod() { m_Adaptee->ForeignMethod(); }
#include <memory> #include "rclcpp/rclcpp.hpp" #include "tutorial_interfaces/msg/num.hpp" using std::placeholders::_1; class MinimalSubscriber : public rclcpp::Node { public: MinimalSubscriber() : Node("minimal_subscriber") { subscription_ = this->create_subscription<tutorial_interfaces::msg::Num>( "topic", 10, std::bind(&MinimalSubscriber::topic_callback, this, _1)); } private: void topic_callback(const tutorial_interfaces::msg::Num::SharedPtr msg) const { RCLCPP_INFO(this->get_logger(), "I heard: '%d'", msg->num); } rclcpp::Subscription<tutorial_interfaces::msg::Num>::SharedPtr subscription_; }; int main(int argc, char *argv[]) { rclcpp::init(argc, argv); rclcpp::spin(std::make_shared<MinimalSubscriber>()); rclcpp::shutdown(); return 0; }
// bdlde_base64encoder.t.cpp -*-C++-*- // ---------------------------------------------------------------------------- // NOTICE // // This component is not up to date with current BDE coding standards, and // should not be used as an example for new development. // ---------------------------------------------------------------------------- #include <bdlde_base64encoder.h> #include <bslim_testutil.h> #include <bsls_assert.h> #include <bsls_objectbuffer.h> #include <bsls_review.h> #include <bsl_algorithm.h> #include <bsl_cctype.h> // isgraph(), isalpha() #include <bsl_cstdint.h> #include <bsl_cstdio.h> #include <bsl_cstdlib.h> // atoi() #include <bsl_cstring.h> // memset() #include <bsl_climits.h> // INT_MAX #include <bsl_fstream.h> #include <bsl_iostream.h> #include <bsl_sstream.h> #include <bsl_vector.h> using namespace BloombergLP; using bsl::cout; using bsl::cerr; using bsl::endl; using bsl::ends; using bsl::flush; //============================================================================= // TEST PLAN //----------------------------------------------------------------------------- // Overview // -------- // This encoder is a kind of 'mechanism' that can be customized at // construction. Since there is currently no prevision to change the // customization after construction, the choice for primary constructor must // itself permit full customization: //.. // bdlde::Base64Encoder(int maxLineLength); //.. // The primary manipulators are those needed to reach every attainable state // from the initial state (i.e., that of a newly constructed object). Clearly // 'convert' is one, but 'endConvert' is also needed in order to reach the // 'DONE' state. Hence, the primary manipulators are //.. // int convert(char *out, int *numOut, int *ni, begin, end, int maxNumOut); // int endConvert(char *out, int *numOut, int maxNumOut); //.. // The basic accessors for the encoder are all the functions that return // information about the customization and/or execution state: //.. // bool isAcceptable() const; // bool isDone() const; // bool isError() const; // bool isInitialState() const; // int maxLineLength() const; // int outputLength() const; //.. // The following tables characterize the major logical states and illustrates // transitions for the primary manipulators (as implemented under the heading // "Named STATE Values" in the "GLOBAL TYPEDEFS/CONSTANTS" section below): //.. // MAJOR STATE NAME CHARACTERIZATION // ---------------- ---------------------------------------------------- // *INITIAL_STATE nothing in accumulator; output length is 0 // State 1 one char in accumulator // State 2 two chars in accumulator // *State 3 nothing in accumulator; output length is NOT 0 // *DONE_STATE: end of input noted // ERROR_STATE error state (must be last) // // '*' = Accepting State // convert (1) endConvert // ----------- ---------- // *INITIAL_STATE: State 1 DONE_STATE // State 1: State 2 DONE_STATE // State 2: State 3 DONE_STATE // *State 3: State 1 DONE_STATE // *DONE_STATE: ERROR_STATE ERROR_STATE // ERROR_STATE: ERROR_STATE ERROR_STATE //.. // Our first step will be to ensure that each of these states can be reached // ('::setState'), that an anticipated state can be verified ('::isState'), and // that each of the above state transitions is verified. Next, we will ensure // that each internal table is correct. Then, using Category Partitioning, we // enumerate a representative collection of inputs ordered by increasing // *depth* that will be sufficient to prove that the logic associated with the // state machine is performing as desired. // // Note that because the 'convert' and 'endConvert' methods are parametrized // based on iterator types, we will want to ensure (at compile time) that // their respective implementations do not depend on more than minimal iterator // functionality. We will accomplish this goal by supplying, as template // arguments, 'bdeut::InputIterator' for 'convert' and 'bdeut::OutputIterator' // for both of these template methods. //----------------------------------------------------------------------------- // [ 7] static int encodedLength(int numInputBytes, int maxLineLength); // [10] bdlde::Base64Encoder(); // [ 2] bdlde::Base64Encoder(int maxLineLength); // [ 3] ~bdlde::Base64Encoder(); //*[ 8] int convert(char *o, int *no, int *ni, begin, end, int mno); //*[ 8] int endConvert(char *out, int *numOut, int maxNumOut); // [ 7] int convert(char *o, int *no, int*ni, const char*b, const char*e); // [ 7] int endConvert(char *out, int *numOut); // [ 9] void resetState(); // [ 3] bool isAcceptable() const; // [ 3] bool isDone() const; // [ 3] bool isError() const; // [ 3] bool isInitialState() const; // [ 2] int maxLineLength() const; // [ 3] int outputLength() const; //----------------------------------------------------------------------------- // [ 1] BREATHING TEST -- (developer's sandbox) //*[11] USAGE EXAMPLE // [ ?] That the input iterator can have *minimal* functionality. // [ ?] That the output iterator can have *minimal* functionality. // [ 1] ::myMin(const T& a, const T& b); // [ 1] ::printCharN(ostream& output, const char* sequence, int length) // [ 3] That we can reach each of the major processing states. // [ 3] void ::setState(Obj *obj, int state, const char *input); // [ 3] bool ::isState(Obj *obj, int state); // [ 5] BOOTSTRAP: 'convert' - transitions // [ 4] BOOTSTRAP: 'endConvert'- transitions // [ 6] That each internal table has no defective entries. // [ 7] DFLT convert(char *o, int *no, int *ni, begin, end, int mno = -1); // [ 7] DFLT endConvert(char *out, int *numOut, int maxNumOut = -1); // [ 7] That each bit of a 3-byte quantum finds its appropriate spot. // [ 7] That each bit of a 2-byte quantum finds its appropriate spot. // [ 7] That each bit of a 1-byte quantum finds its appropriate spot. // [ 7] That output length is calculated properly. //----------------------------------------------------------------------------- // ============================================================================ // STANDARD BSL ASSERT TEST FUNCTION // ---------------------------------------------------------------------------- namespace { int testStatus = 0; void aSsErT(bool condition, const char *message, int line) { if (condition) { printf("Error " __FILE__ "(%d): %s (failed)\n", line, message); if (0 <= testStatus && testStatus <= 100) { ++testStatus; } } } } // close unnamed namespace // ============================================================================ // STANDARD BDE TEST DRIVER MACRO ABBREVIATIONS // ---------------------------------------------------------------------------- #define ASSERT BSLIM_TESTUTIL_ASSERT #define ASSERTV BSLIM_TESTUTIL_ASSERTV #define LOOP_ASSERT BSLIM_TESTUTIL_LOOP_ASSERT #define LOOP0_ASSERT BSLIM_TESTUTIL_LOOP0_ASSERT #define LOOP1_ASSERT BSLIM_TESTUTIL_LOOP1_ASSERT #define LOOP2_ASSERT BSLIM_TESTUTIL_LOOP2_ASSERT #define LOOP3_ASSERT BSLIM_TESTUTIL_LOOP3_ASSERT #define LOOP4_ASSERT BSLIM_TESTUTIL_LOOP4_ASSERT #define LOOP5_ASSERT BSLIM_TESTUTIL_LOOP5_ASSERT #define LOOP6_ASSERT BSLIM_TESTUTIL_LOOP6_ASSERT #define Q BSLIM_TESTUTIL_Q // Quote identifier literally. #define P BSLIM_TESTUTIL_P // Print identifier and value. #define P_ BSLIM_TESTUTIL_P_ // P(X) without '\n'. #define T_ BSLIM_TESTUTIL_T_ // Print a tab (w/o newline). #define L_ BSLIM_TESTUTIL_L_ // current Line number #define V(X) { if (verbose) { cout << "\t" << X << endl; } } // no () to allow // stringing << #define VV(X) { if (veryVerbose) { cout << "\t\t" << X << endl; } } #define VVV(X) { if (veryVeryVerbose) { cout << "\t\t\t" << X << endl; } } #define VVVV(X) { if (veryVeryVeryVerbose) {cout << "\t\t\t\t" << X << endl;} } // ============================================================================ // GLOBAL TYPEDEFS/CONSTANTS // ---------------------------------------------------------------------------- typedef bdlde::Base64Encoder Obj; // ================== // Named STATE Values // ================== enum { // Enumeration of logical states described in the test plan overview. // These logical states must range in value from e_INITIAL_STATE = 0 to // e_ERROR_STATE = NUM_STATES - 1. Note that the number and values of // these logical states need not coincide with those defined explicitly in // the implementation. e_INITIAL_STATE, e_STATE_ONE, e_STATE_TWO, e_STATE_THREE, e_DONE_STATE, e_ERROR_STATE // must be last }; // The following is a list of strings to be used when printing state values. const char *STATE_NAMES[] = { "INITIAL_STATE", "State 1", "State 2", "State 3", "DONE_STATE", "ERROR_STATE" }; const int NUM_STATES = sizeof STATE_NAMES / sizeof *STATE_NAMES; char assertion[e_ERROR_STATE + 1 == NUM_STATES]; // The following is a very long text to use both in the stress test and in the // usage example. const char BLOOMBERG_NEWS[] = " (Commentary. Chet Currier is a Bloomberg News \n\ columnist. The opinions expressed are his own.) \n\ \n\ By Chet Currier\n\ Sept. 14 (Bloomberg) -- The trouble with college finance in\n\ 21st Century America is way too much homework.\n\ Study up on UGMAs, ESAs, Section 529 savings programs that\n\ come in more than 50 different versions, and prepaid tuition\n\ plans. Learn when interest on U.S. Savings Bonds may, or may not,\n\ be exempt from taxes when the money is used to pay educational\n\ expenses.\n\ Comb through some of the 117,687 items that turn up when you\n\ do a ``pay for college'' search on the Web site of Amazon.com.\n\ Read articles like ``Understanding the Aid Form,'' a discussion\n\ of something called the FAFSA that ran as part of a 28-page\n\ special ``Paying for College'' section in the Sept. 6 U.S. News &\n\ World Report.\n\ ``A college education is a worthwhile, but expensive,\n\ investment,'' says the Vanguard Group in a current bulletin to\n\ investors in its $730 billion stable of mutual funds. ``The right\n\ savings plan can help ease the financial burden, but with the\n\ variety of alternatives available you may need a crash course on\n\ the pros and cons of each one.''\n\ Please, life already has all the crash courses it needs. Is\n\ this the best we can do? Even if each piece of the system was\n\ designed with the best of intentions, the aggregate has become an\n\ absurd monstrosity.\n\ \n\ Fails the Test\n\ \n\ The system's first and most obvious offense is its utter\n\ disregard for the virtues of simplicity, both aesthetic and\n\ practical. That's just the beginning.\n\ It wastes huge amounts of time, energy and economic\n\ resources. Along the way, it undercuts several of the most\n\ important ideas colleges are supposed to be dealing in.\n\ Consider the difference between real problems that naturally\n\ arise in life, and artificial obstacles that humans put in their\n\ own path. Dealing with real problems is an unavoidable part of\n\ the human condition -- and quite often turns out to be a\n\ productive exercise that gets you somewhere. Artificial problems,\n\ being both unnecessary and sterile, offer few benefits of that\n\ kind.\n\ The wish to give young people an education, and the\n\ necessity of paying the cost of that effort, are classic examples\n\ of naturally occurring problems. When you study 529 plans, by\n\ contrast, you learn nothing but an arbitrary set of details that\n\ have no bearing on anything else.\n\ \n\ Hypocritical\n\ \n\ College should teach ways of thinking that a student can\n\ apply and build on after the degree is awarded. The college-\n\ finance system is completely out of synch with that ideal.\n\ In the few years while the teenagers in a family struggle\n\ through the miasma known as the ``admissions process,'' college-\n\ finance information presents itself as vital. Immediately after\n\ the last child matriculates, it becomes junk to be jettisoned as\n\ fast as the brain cells will allow.\n\ Also, college ought to be a place to acquire a sense of\n\ ethics -- more now than ever amid the outcry over the moral and\n\ ethical failures of so many in business, government, religion and\n\ the press. Yet a basic part of college planning, usually\n\ presented without the slightest moral compunction, is learning\n\ the slyest ways to game the system.\n\ Parents saving for a child's tuition are confronted with\n\ issues such as ``can that stash hurt your aid?'' to quote one\n\ headline in the U.S. News college-planning report. Here, son, you\n\ go study Plato and Aristotle, and we'll scrounge up the money to\n\ pay for it by hiding assets in Aunt Adelaide's name.\n\ \n\ Lessons to Learn\n\ \n\ ``Mankind, left free, instinctively complicates life,'' said\n\ the writer Katharine Fullerton Gerould.\n\ Beyond the portrait it paints of human folly, though, maybe\n\ there is something to be learned from the sorry state of college\n\ finance. It gives us a glimpse into the workings of a so-called\n\ ``information economy'' where, instead of education steering us\n\ toward life, life steers us to education.\n\ Like the computer, education was originally a tool, now is a\n\ product unto itself. Hence the resume of achievements and\n\ experiences that have come to be required of children aspiring to\n\ get into a ``selective'' college.\n\ The economics of information is pretty new stuff. One sign\n\ we are starting to figure it out will come when we do a better\n\ job of designing mechanisms like college finance.\n\ \n\ --Editors: Ahearn, Wolfson\n\ \n\ Story Illustration: To graph increase in population of U.S.\n\ college graduates, click on USP CL25 <Index> GP <GO> . To see\n\ additional Currier columns, click on NI CURRIER <GO> . To\n\ comment on this column, click on LETT <GO> and send a letter to\n\ the editor.\n\ \n\ To contact the writer of this column: Chet Currier in New York\n\ (1) (212) 318-2605 or ccurrier@bloomberg.net."; // ============================================================================ // TEST HELPER FUNCTIONS // ---------------------------------------------------------------------------- namespace { namespace u { inline bool notBase64(char c) // Return 'true' if the specified 'c' is valid base 64 character or part of // a CRLF. { unsigned char uc = c; return !(bsl::isalnum(uc) || bsl::strchr("+/=\n\r", uc)); } inline bool notBase64NotCRLF(char c) // Return 'true' if the specified 'c' is valid base 64 character. { unsigned char uc = c; return !(bsl::isalnum(uc) || bsl::strchr("+/=", uc)); } inline bool notBase64NotEquals(char c) // Return 'true' if the specified 'c' is valid base 64 character or a CRLF // but not '='. { unsigned char uc = c; return !(bsl::isalnum(uc) || bsl::strchr("+/\n\r", uc)); } inline bool notBase64NotEqualsOrCRLF(char c) // Return 'true' if the specified 'c' is valid base 64 character and not a // CRLF or '='. { unsigned char uc = c; return !(bsl::isalnum(uc) || bsl::strchr("+/", uc)); } } // close namespace u } // close unnamed namespace // ============== // Function myMin // ============== template <class T> inline T myMin(const T& a, const T& b) { return a < b ? a : b; } // =================== // Function printCharN // =================== bsl::ostream& printCharN(bsl::ostream& output, const char* sequence, int length) // Print the specified character 'sequence' of specified 'length' to the // specified 'stream' and return a reference to the modifiable 'stream' // (if a character is not graphical, its hexadecimal code is printed // instead). The behavior is undefined unless 0 <= 'length' and sequence // refers to a valid area of memory of size at least 'length'. { static char HEX[] = "0123456789ABCDEF"; for (int i = 0; i < length; ++i) { unsigned char c = static_cast<unsigned char>(sequence[i]); if (isgraph(c)) { output << c; } else { output << '<' << HEX[c/16] << HEX[c%16] << '>'; } } return output << flush; } // ================== // Function showCharN // ================== bsl::string showCharN(const char *sequence, bsl::size_t length) { bsl::ostringstream oss; printCharN(oss, sequence, static_cast<int>(length)); return oss.str(); } // ================= // Function setState // ================= void setState(bdlde::Base64Encoder *object, int state) // Move the specified 'object' from its initial (i.e., newly constructed) // state to the specified 'state' using '\0' characters for input as // needed. The behavior is undefined if 'object' is not in its // newly-constructed initial state. Note that when this function is // invoked on a newly constructed object, it is presumed that // 'isInitialState' has been sufficiently tested to ensure that it returns // 'true'. { ASSERT(object); ASSERT(0 <= state); ASSERT(state < NUM_STATES); if (!object->isInitialState()) { cout << "You must not call 'setState' from other than 'INITIAL_STATE'!" << endl << "\tNote that '::isState' *will* alter from the initial state." << endl; } ASSERT(object->isInitialState()); // If 'object' is "just created" then // this assertion should be true! char b[8]; int numOut = -1; int numIn = -1; const char input = '\0'; const char *const begin = &input; const char *const end = &input + 1; switch (state) { case e_INITIAL_STATE: { ASSERT(1 == object->isAcceptable()); ASSERT(0 == object->isDone()); ASSERT(0 == object->isError()); ASSERT(1 == object->isInitialState()); ASSERT(0 == object->outputLength()); } break; case e_STATE_ONE: { ASSERT(0 == object->convert(b, &numOut, &numIn, begin, end)); ASSERT(1 == numOut); ASSERT(1 == numIn); ASSERT(1 == object->isAcceptable()); ASSERT(0 == object->isDone()); ASSERT(0 == object->isError()); ASSERT(0 == object->isInitialState()); ASSERT(0 != object->outputLength()); } break; case e_STATE_TWO: { ASSERT(0 == object->convert(b, &numOut, &numIn, begin, end)); ASSERT(1 == numOut); ASSERT(1 == numIn); ASSERT(0 == object->convert(b, &numOut, &numIn, begin, end)); ASSERT(1 == numOut); ASSERT(1 == numIn); ASSERT(1 == object->isAcceptable()); ASSERT(0 == object->isDone()); ASSERT(0 == object->isError()); ASSERT(0 == object->isInitialState()); ASSERT(0 != object->outputLength()); } break; case e_STATE_THREE: { ASSERT(0 == object->convert(b, &numOut, &numIn, begin, end)); ASSERT(1 == numOut); ASSERT(1 == numIn); ASSERT(0 == object->convert(b, &numOut, &numIn, begin, end)); ASSERT(1 == numOut); ASSERT(1 == numIn); ASSERT(0 == object->convert(b, &numOut, &numIn, begin, end)); ASSERT(2 == numOut); ASSERT(1 == numIn); ASSERT(1 == object->isAcceptable()); ASSERT(0 == object->isDone()); ASSERT(0 == object->isError()); ASSERT(0 == object->isInitialState()); ASSERT(0 != object->outputLength()); // depends on maxLineLength } break; case e_DONE_STATE: { ASSERT(0 == object->endConvert(b, &numOut)); ASSERT(0 == numOut); ASSERT(1 == object->isAcceptable()); ASSERT(1 == object->isDone()); ASSERT(0 == object->isError()); ASSERT(0 == object->isInitialState()); ASSERT(0 == object->outputLength()); // In this case, we know! } break; case e_ERROR_STATE: { ASSERT(0 == object->endConvert(b, &numOut)); ASSERT(0 == numOut); ASSERT(-1 == object->endConvert(b, &numOut)); ASSERT(0 == numOut); ASSERT(0 == object->isAcceptable()); ASSERT(0 == object->isDone()); ASSERT(1 == object->isError()); ASSERT(0 == object->isInitialState()); ASSERT(0 == object->outputLength()); } break; default: { ASSERT("Unknown State" && 0); } break; }; } // ================ // Function isState // ================ static bool globalAssertsEnabled = false; // If set to true, will enable ASSERTs in '::isState' (for debugging). class EnabledGuard { // Enable/Disable '::isState' ASSERTs for current scope; restore status at // end. Note that guards can be nested. bool d_state; public: explicit EnabledGuard(bool flag) // Create a guard to control the activation of individual assertions in // the '::isState' test helper function using the specified enable // 'flag' value. If 'flag' is 'true' individual false values we be // reported as assertion errors. : d_state(globalAssertsEnabled) { globalAssertsEnabled = flag; } ~EnabledGuard() { globalAssertsEnabled = d_state; } }; bool isState(bdlde::Base64Encoder *object, int state) // Return 'true' if the specified 'object' was initially in the specified // 'state', and 'false' otherwise. Setting the global variable // 'globalAssertsEnabled' to 'true' enables individual sub-conditions to // be ASSERTed, which can be used to facilitate test driver debugging. // Note that the final state of 'object' may (and probably will) be // modified arbitrarily from its initial state in order to distinguish // similar states. { ASSERT(object); ASSERT(0 <= state); ASSERT(state < NUM_STATES); int enabled = globalAssertsEnabled; char b[8] = { -1, -1, -1, -1, -1, -1, -1, -1 }; int numOut = -1; int numIn = -1; const char input = '\0'; const char *const begin = &input; bool rv = false; switch (state) { case e_INITIAL_STATE: { bool a0 = 1 == object->isAcceptable(); ASSERT(a0 || !enabled); bool a1 = 0 == object->isDone(); ASSERT(a1 || !enabled); bool a2 = 0 == object->isError(); ASSERT(a2 || !enabled); bool a3 = 1 == object->isInitialState(); ASSERT(a3 || !enabled); int result = object->endConvert(b, &numOut); // e_DONE_STATE bool b0 = 1 == object->isAcceptable(); ASSERT(b0 || !enabled); bool b1 = 1 == object->isDone(); ASSERT(b1 || !enabled); bool b2 = 0 == object->isError(); ASSERT(b2 || !enabled); bool b3 = 0 == object->isInitialState(); ASSERT(b3 || !enabled); bool c0 = 0 == result; ASSERT(c0 || !enabled); bool c1 = 0 == numOut; ASSERT(c1 || !enabled); bool d0 = (char)-1 == b[0]; ASSERT(d0 || !enabled); bool d1 = (char)-1 == b[1]; ASSERT(d1 || !enabled); bool d2 = (char)-1 == b[2]; ASSERT(d2 || !enabled); bool d3 = (char)-1 == b[3]; ASSERT(d3 || !enabled); rv = a0 && a1 && a2 && a3 && b0 && b1 && b2 && b3 && c0 && c1 && d0 && d1 && d2 && d3; } break; case e_STATE_ONE: { bool a0 = 1 == object->isAcceptable(); ASSERT(a0 || !enabled); bool a1 = 0 == object->isDone(); ASSERT(a1 || !enabled); bool a2 = 0 == object->isError(); ASSERT(a2 || !enabled); bool a3 = 0 == object->isInitialState(); ASSERT(a3 || !enabled); object->convert(b, &numOut, &numIn, begin, begin); int result = object->endConvert(b, &numOut); // e_DONE_STATE bool b0 = 1 == object->isAcceptable(); ASSERT(b0 || !enabled); bool b1 = 1 == object->isDone(); ASSERT(b1 || !enabled); bool b2 = 0 == object->isError(); ASSERT(b2 || !enabled); bool b3 = 0 == object->isInitialState(); ASSERT(b3 || !enabled); bool c0 = 0 == result; ASSERT(c0 || !enabled); bool c1 = 3 == numOut; ASSERT(c1 || !enabled); bool d0 = '=' != b[0]; ASSERT(d0 || !enabled); bool d1 = '=' == b[1]; ASSERT(d1 || !enabled); bool d2 = '=' == b[2]; ASSERT(d2 || !enabled); bool d3 = (char)-1 == b[3]; ASSERT(d3 || !enabled); rv = a0 && a1 && a2 && a3 && b0 && b1 && b2 && b3 && c0 && c1 && d0 && d1 && d2 && d3; } break; case e_STATE_TWO: { bool a0 = 1 == object->isAcceptable(); ASSERT(a0 || !enabled); bool a1 = 0 == object->isDone(); ASSERT(a1 || !enabled); bool a2 = 0 == object->isError(); ASSERT(a2 || !enabled); bool a3 = 0 == object->isInitialState(); ASSERT(a3 || !enabled); object->convert(b, &numOut, &numIn, begin, begin); int result = object->endConvert(b, &numOut); // e_DONE_STATE bool b0 = 1 == object->isAcceptable(); ASSERT(b0 || !enabled); bool b1 = 1 == object->isDone(); ASSERT(b1 || !enabled); bool b2 = 0 == object->isError(); ASSERT(b2 || !enabled); bool b3 = 0 == object->isInitialState(); ASSERT(b3 || !enabled); bool c0 = 0 == result; ASSERT(c0 || !enabled); bool c1 = 2 == numOut; ASSERT(c1 || !enabled); bool d0 = '=' != b[0]; ASSERT(d0 || !enabled); bool d1 = '=' == b[1]; ASSERT(d1 || !enabled); bool d2 = (char)-1 == b[2]; ASSERT(d2 || !enabled); bool d3 = (char)-1 == b[3]; ASSERT(d3 || !enabled); rv = a0 && a1 && a2 && a3 && b0 && b1 && b2 && b3 && c0 && c1 && d0 && d1 && d2 && d3; } break; case e_STATE_THREE: { bool a0 = 1 == object->isAcceptable(); ASSERT(a0 || !enabled); bool a1 = 0 == object->isDone(); ASSERT(a1 || !enabled); bool a2 = 0 == object->isError(); ASSERT(a2 || !enabled); bool a3 = 0 == object->isInitialState(); ASSERT(a3 || !enabled); object->convert(b, &numOut, &numIn, begin, begin); int result = object->endConvert(b, &numOut); // e_DONE_STATE bool b0 = 1 == object->isAcceptable(); ASSERT(b0 || !enabled); bool b1 = 1 == object->isDone(); ASSERT(b1 || !enabled); bool b2 = 0 == object->isError(); ASSERT(b2 || !enabled); bool b3 = 0 == object->isInitialState(); ASSERT(b3 || !enabled); bool c0 = 0 == result; ASSERT(c0 || !enabled); bool c1 = 0 == numOut; ASSERT(c1 || !enabled); bool d0 = (char)-1 == b[0]; ASSERT(d0 || !enabled); bool d1 = (char)-1 == b[1]; ASSERT(d1 || !enabled); bool d2 = (char)-1 == b[2]; ASSERT(d2 || !enabled); bool d3 = (char)-1 == b[3]; ASSERT(d3 || !enabled); rv = a0 && a1 && a2 && a3 && b0 && b1 && b2 && b3 && c0 && c1 && d0 && d1 && d2 && d3; } break; case e_DONE_STATE: { bool a0 = 1 == object->isAcceptable(); ASSERT(a0 || !enabled); bool a1 = 1 == object->isDone(); ASSERT(a1 || !enabled); bool a2 = 0 == object->isError(); ASSERT(a2 || !enabled); bool a3 = 0 == object->isInitialState(); ASSERT(a3 || !enabled); int result = object->endConvert(b, &numOut); // e_ERROR_STATE bool b0 = 0 == object->isAcceptable(); ASSERT(b0 || !enabled); bool b1 = 0 == object->isDone(); ASSERT(b1 || !enabled); bool b2 = 1 == object->isError(); ASSERT(b2 || !enabled); bool b3 = 0 == object->isInitialState(); ASSERT(b3 || !enabled); bool c0 = -1 == result; ASSERT(c0 || !enabled); bool c1 = 0 == numOut; ASSERT(c1 || !enabled); bool d0 = (char)-1 == b[0]; ASSERT(d0 || !enabled); bool d1 = (char)-1 == b[1]; ASSERT(d1 || !enabled); bool d2 = (char)-1 == b[2]; ASSERT(d2 || !enabled); bool d3 = (char)-1 == b[3]; ASSERT(d3 || !enabled); rv = a0 && a1 && a2 && a3 && b0 && b1 && b2 && b3 && c0 && c1 && d0 && d1 && d2 && d3; } break; case e_ERROR_STATE: { bool a0 = 0 == object->isAcceptable(); ASSERT(a0 || !enabled); bool a1 = 0 == object->isDone(); ASSERT(a1 || !enabled); bool a2 = 1 == object->isError(); ASSERT(a2 || !enabled); bool a3 = 0 == object->isInitialState(); ASSERT(a3 || !enabled); int result = object->endConvert(b, &numOut); // e_ERROR_STATE bool b0 = 0 == object->isAcceptable(); ASSERT(b0 || !enabled); bool b1 = 0 == object->isDone(); ASSERT(b1 || !enabled); bool b2 = 1 == object->isError(); ASSERT(b2 || !enabled); bool b3 = 0 == object->isInitialState(); ASSERT(b3 || !enabled); bool c0 = -1 == result; ASSERT(c0 || !enabled); bool c1 = 0 == numOut; ASSERT(c1 || !enabled); bool d0 = (char)-1 == b[0]; ASSERT(d0 || !enabled); bool d1 = (char)-1 == b[1]; ASSERT(d1 || !enabled); bool d2 = (char)-1 == b[2]; ASSERT(d2 || !enabled); bool d3 = (char)-1 == b[3]; ASSERT(d3 || !enabled); rv = a0 && a1 && a2 && a3 && b0 && b1 && b2 && b3 && c0 && c1 && d0 && d1 && d2 && d3; } break; default: { ASSERT("Unknown State" && 0); } break; } return rv; } // ================================ // DUMMY Class u_Base64Decoder_Test // for use in case 12 (stress test) // ================================ namespace { class u_Base64Decoder_Test { // This class implements a simple base64 decoder sufficient for this test // driver. The interface and code is taken from the 'bdlde_base64decoder' // component. // PRIVATE TYPES enum { // Symbolic state values. e_ERROR_STATE = -1, // input is irreparably invalid e_INPUT_STATE = 0, // general input state e_NEED_EQUAL_STATE = 1, // need an '=' e_SOFT_DONE_STATE = 2, // only ignorable input and 'endConvert' e_DONE_STATE = 3 // any additional input is an error }; // CLASS DATA static const bool *const s_ignorableStrict_p; // Table identifying // ignorable characters in // strict mode static const bool *const s_ignorableRelaxed_p;// Table identifying // ignorable characters in // relaxed mode static const char *const s_decoding_p; // a map from numeric Base64 // encoding characters to the // corresponding 6-bit number // DATA const bool *const d_ignorable_p; // Selected table of ignorable // characters based on specified // error-reporting mode signed char d_state; // -1 = error state // 0 = general input state // 1 = need another '=' // 2 = soft done state - allow only // ignorable input // 3 = done state - no more input // allowed int d_outputLength; // total number of output characters unsigned int d_stack; // storage of non-emitted input int d_bitsInStack; // number of bits in 'd_stack' public: explicit u_Base64Decoder_Test(bool unrecognizedIsErrorFlag = true); // Create a Base64 decoder in the initial state. Unrecognized // characters (i.e., non-base64 characters other than whitespace) will // be treated as errors if the optionally specified // 'unrecognizedIsErrorFlag' is 'true', and ignored otherwise. static int maxDecodedLength(int encodedLen); // Return the maximum number of decoded bytes that could result from an // input byte sequence of the specified 'inputLength' provided to the // 'convert' method of this decoder. The behavior is undefined unless // 0 <= 'inputLength'. int convert(char *out, int *numOut, int *numIn, const char *begin, const char *end, int maxNumOut = -1); // Decode the sequence of input characters starting at the specified // 'begin' position up to, but not including, the specified 'end' // position, writing any resulting output characters to the specified // 'out' buffer. Optionally specify the 'maxNumOut' limit on the // number of bytes to output; if 'maxNumOut' is negative, no limit is // imposed. If the 'maxNumOut' limit is reached, no further input will // be consumed. Load into the specified 'numOut' and 'numIn' the // number of output bytes produced and input bytes consumed, // respectively. Return a non-negative value on success, -1 on an // input error, and -2 if the 'endConvert' method has already been // called without an intervening 'resetState' call. int endConvert(char* out, int *numOut, int maxNumOut = -1); // Terminate decoding for this decoder; write any retained output to // the specified 'out' buffer; encode any unprocessed input characters // that do not complete a 3-byte sequence. Optionally specify the // 'maxNumOut' limit on the number of bytes to output; if 'maxNumOut' // is negative, no limit is imposed. Load into the specified 'numOut' // the number of output bytes produced. Return 0 on success, the // positive number of bytes *still* retained by this decoder if the // 'maxNumOut' limit was reached, and a negative value otherwise. }; // CLASS DATA // The following table identifies characters that can be ignored when // d_isUnrecognizedAnErrorFlag 'true'. static const bool CHARACTERS_THAT_CAN_BE_IGNORED_IN_STRICT_MODE[256] = { // 0 1 2 3 4 5 6 7 8 9 A B C D E F 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, // 00 // whitespace 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 10 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20 // <space> char 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 30 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 40 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 50 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 60 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 70 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 80 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 90 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // A0 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // B0 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // C0 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // D0 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // E0 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // F0 }; // The following table identifies characters that can be ignored when // d_isUnrecognizedAnErrorFlag 'false'. static const bool CHARACTERS_THAT_CAN_BE_IGNORED_IN_RELAXED_MODE[256] = { // 0 1 2 3 4 5 6 7 8 9 A B C D E F 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 00 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 10 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, // 20 // '+', '/' 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, // 30 // '0'..'9', '=' 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 40 // uppercase 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, // 50 // alphabet 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 60 // lowercase 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, // 70 // alphabet 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 80 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 90 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A0 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B0 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C0 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D0 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E0 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // F0 }; // The following table is a map from numeric Base64 encoding characters to the // corresponding 6-bit index. static const char DEC[256] = { // 0 1 2 3 4 5 6 7 8 9 A B C D E F // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 00 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 10 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, // 20 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, // 30 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 40 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, // 50 -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 60 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, // 70 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 80 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 90 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // A0 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // B0 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // C0 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // D0 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // E0 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // F0 }; const bool *const u_Base64Decoder_Test::s_ignorableStrict_p = CHARACTERS_THAT_CAN_BE_IGNORED_IN_STRICT_MODE; const bool *const u_Base64Decoder_Test::s_ignorableRelaxed_p = CHARACTERS_THAT_CAN_BE_IGNORED_IN_RELAXED_MODE; const char *const u_Base64Decoder_Test::s_decoding_p = DEC; // CREATORS u_Base64Decoder_Test::u_Base64Decoder_Test(bool unrecognizedIsErrorFlag) : d_ignorable_p(unrecognizedIsErrorFlag ? s_ignorableStrict_p : s_ignorableRelaxed_p) , d_state(e_INPUT_STATE) , d_outputLength(0) , d_stack(0) , d_bitsInStack(0) { } // ACCESSORS int u_Base64Decoder_Test::maxDecodedLength(int encodedLen) { return (encodedLen + 3) / 4 * 3; } int u_Base64Decoder_Test::convert(char *out, int *numOut, int *numIn, const char *begin, const char *end, int maxNumOut) { if (e_ERROR_STATE == d_state || e_DONE_STATE == d_state) { int rv = e_DONE_STATE == d_state ? -2 : -1; d_state = e_ERROR_STATE; *numOut = 0; *numIn = 0; return rv; // RETURN } int numEmitted = 0; // Emit as many output bytes as possible. while (8 <= d_bitsInStack && numEmitted != maxNumOut) { d_bitsInStack -= 8; *out = static_cast<char>((d_stack >> d_bitsInStack) & 0xff); ++out; ++numEmitted; } // Consume as many input bytes as possible. *numIn = 0; if (e_INPUT_STATE == d_state) { while (18 >= d_bitsInStack && begin != end) { const unsigned char byte = *begin; ++begin; ++*numIn; unsigned char converted = static_cast<unsigned char>( s_decoding_p[byte]); if (converted < 64) { d_stack = (d_stack << 6) | converted; d_bitsInStack += 6; if (8 <= d_bitsInStack && numEmitted != maxNumOut) { d_bitsInStack -= 8; *out = static_cast<char>((d_stack>>d_bitsInStack) & 0xff); ++out; ++numEmitted; } } else if (!d_ignorable_p[byte]) { if ('=' == byte) { const int residualBits = (((d_outputLength + numEmitted) % 3) * 8 + d_bitsInStack) % 24; if (12 == residualBits && 0 == (d_stack & 0xf)) { d_stack = d_stack >> 4; d_bitsInStack -= 4; d_state = e_NEED_EQUAL_STATE; } else if (18 == residualBits && 0 == (d_stack & 0x3)) { d_stack = d_stack >> 2; d_bitsInStack -= 2; d_state = e_SOFT_DONE_STATE; } else { d_state = e_ERROR_STATE; } } else { d_state = e_ERROR_STATE; } break; } } } if (e_NEED_EQUAL_STATE == d_state) { while (begin != end) { const unsigned char byte = *begin; ++begin; ++*numIn; if (!d_ignorable_p[byte]) { if ('=' == byte) { d_state = e_SOFT_DONE_STATE; } else { d_state = e_ERROR_STATE; } break; } } } if (e_SOFT_DONE_STATE == d_state) { while (begin != end) { const unsigned char byte = *begin; ++begin; ++*numIn; if (!d_ignorable_p[byte]) { d_state = e_ERROR_STATE; break; } } } *numOut = numEmitted; d_outputLength += numEmitted; return e_ERROR_STATE == d_state ? -1 : d_bitsInStack / 8; } int u_Base64Decoder_Test::endConvert(char *out, int *numOut, int maxNumOut) { BSLS_ASSERT(numOut); const int residualBits = ((d_outputLength % 3) * 8 + d_bitsInStack) % 24; if (e_ERROR_STATE == d_state || e_NEED_EQUAL_STATE == d_state || (e_DONE_STATE == d_state && 0 == d_bitsInStack) || (e_INPUT_STATE == d_state && residualBits)) { *numOut = 0; d_state = e_ERROR_STATE; return -1; // RETURN } d_state = e_DONE_STATE; int numEmitted = 0; while (8 <= d_bitsInStack && numEmitted != maxNumOut) { d_bitsInStack -= 8; *out = static_cast<char>((d_stack >> d_bitsInStack) & 0xff); ++out; ++numEmitted; } *numOut = numEmitted; d_outputLength += numEmitted; return e_ERROR_STATE == d_state ? -1 : d_bitsInStack / 8; } int run = 0; namespace u { void checkBase64(const char *begin, const char *end, bsl::size_t lineLength) // Check that the specfied sequence '[ begin, end )' is 100% valid base 64 // characters, with CRLF's exactly where they're expected given the // specified 'lineLength'. { if (0 == lineLength) { const char *preEqualsEnd = bsl::max(begin, end - 2); ASSERT(0 == bsl::count_if(begin, preEqualsEnd, &u::notBase64NotEqualsOrCRLF)); ASSERT(0 == bsl::count_if(preEqualsEnd, end, &u::notBase64NotCRLF)); } else { const char *preEqualsEnd = bsl::max(begin, end - 4), *pc = begin; while (pc < preEqualsEnd) { const char *lineEnd = bsl::min(preEqualsEnd, pc + lineLength); ASSERT(0 == bsl::count_if(pc, lineEnd, &u::notBase64NotEqualsOrCRLF)); pc = lineEnd; if (pc < preEqualsEnd) { ASSERTV(*pc, '\r' == *pc); ++pc; } if (pc < preEqualsEnd) { ASSERTV(*pc, '\n' == *pc); ++pc; } } ASSERT(0 == bsl::count_if(pc, end, &u::notBase64)); if (begin < end) { ASSERTV(run, showCharN(begin, end - begin), '\r' != end[-1] && '\n' != end[-1]); } } } } // close namespace u } // close unnamed namespace //============================================================================= // FUZZ TESTING //----------------------------------------------------------------------------- // Overview // -------- // The following function, 'LLVMFuzzerTestOneInput', is the entry point for the // clang fuzz testing facility. See {http://bburl/BDEFuzzTesting} for details // on how to build and run with fuzz testing enabled. //----------------------------------------------------------------------------- #ifdef BDE_ACTIVATE_FUZZ_TESTING #define main test_driver_main #endif using bsl::uint8_t; extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) // Use the specified 'data' array of 'size' bytes as input to methods of // this component and return zero. { const char *FUZZ = reinterpret_cast<const char *>(data); int LENGTH = static_cast<int>(size); int test; if (FUZZ && LENGTH) { test = 1 + static_cast<unsigned char>(*FUZZ) % 99; ++FUZZ; --LENGTH; } else { test = 0; } const char GARBAGE = char(0xaf); switch (test) { case 0: // Zero is always the leading case. case 2: { // -------------------------------------------------------------------- // FUZZ TESTING WITHOUT MAXNUMOUT // // Concerns: //: 1 That object under test works properly with a varient of values //: passed to the 'lineLength' parameter, and with tha parameter //: allowed to default to 76. //: //: 2 That at most 2 '=' characters occur in the output, and that, if //: present, they are at the end (possibly divided by a CRLF). //: //: 3 That CRLF's are present, or not, exactly as dictated by the //: 'lineLength' argument. //: //: 4 Test only with 'maxNumOut' not specified. // // Plan: //: 1 Test the binary input with a variety of values passed to the //: 'lineLength' parameter (and nothing specified for the 'maxNumOut' //: parameter: //: o Test the case where no value is passed to the 'lineLength' //: parameter, interpreted as a value of 76. //: o Test 0, which means no CRLF's are inserted. //: o Test a variety of positive values, including very low values. //: //: 2 Call 'checkBase64' at the end to verify that that the output //: is a valid base64 encoding, with CRLF's exactly where they're //: expected. //: //: 3 Allocate the segment of memory to write to using 'malloc' so that //: the address santizer will detect out of bounds access. // // Testing: // FUZZ TESTING WITHOUT MAXNUMOUT // int encodedLength(int); // int encodedLength(int, int); // int convert(OUT, int *, int *, IN, IN); // int endConvert(OUT, int *); // -------------------------------------------------------------------- bool passArg; int LINE_LENGTH; { if (!LENGTH) { LINE_LENGTH = 76; passArg = false; } else { const unsigned llRoot = *FUZZ++ & 0xff; --LENGTH; passArg = true; LINE_LENGTH = (llRoot < 100) ? llRoot : (llRoot << 4); } } const char * const begin = FUZZ; const char * const end = FUZZ + LENGTH; const bool leftOver = LENGTH % 3; const int outLength = passArg ? Obj::encodedLength(LENGTH, LINE_LENGTH) : Obj::encodedLength(LENGTH); ASSERT(0 != LINE_LENGTH || 0 == outLength % 4); char *outBuf = static_cast<char *>(bsl::malloc(outLength+1)); const char *outBegin = outBuf; const char *outEnd = outBuf + outLength; bsl::fill(outBuf, outBuf + outLength + 1, GARBAGE); char *out = outBuf; bsls::ObjectBuffer<Obj> ob; if (passArg) { new (ob.address()) Obj(LINE_LENGTH); } else { new (ob.address()) Obj(); } Obj& mX = ob.object(); const Obj& X = mX; int numOut, numIn; int rc = mX.convert(out, &numOut, &numIn, begin, end); ASSERT(0 <= rc); ASSERT(0 <= numOut); ASSERT(numOut <= outLength); out += numOut; ASSERT(outBuf <= out); ASSERT(out <= outBuf + outLength); ASSERT(0 <= numIn); ASSERT(numIn <= LENGTH); ASSERT(!leftOver || numOut < outLength); ASSERT(0 == bsl::count_if(outBuf, outBuf + numOut, &u::notBase64NotEquals)); u::checkBase64(outBuf, outBuf + numOut, LINE_LENGTH); int endNumOut; rc = mX.endConvert(out, &endNumOut); ASSERT(0 == rc && X.isDone()); ASSERT(0 <= endNumOut); ASSERT(outLength == numOut + endNumOut); ASSERT(0 == bsl::count_if(outBegin, outEnd, &u::notBase64)); ASSERT(!leftOver == (0 == bsl::count_if(outBegin, outEnd, &u::notBase64NotEquals))); ASSERT(0 != LINE_LENGTH || 0 == bsl::count_if(outBegin, outEnd, &u::notBase64NotCRLF)); u::checkBase64(outBuf, outBuf + outLength, LINE_LENGTH); ASSERT(GARBAGE == outBuf[outLength]); ASSERT(leftOver == (0 < bsl::count(outBuf, outBuf + outLength, '='))); free(outBuf); mX.~Obj(); } break; case 1: { // -------------------------------------------------------------------- // FUZZ TESTING WITH MAXNUMOUT // // Concerns: //: 1 That object under test works properly with a varient of values //: passed to the 'lineLength' parameter, and with tha parameter //: allowed to default to 76. //: //: 2 That at most 2 '=' characters occur in the output, and that, if //: present, they are at the end (possibly divided by a CRLF). //: //: 3 That CRLF's are present, or not, exactly as dictated by the //: 'lineLength' argument. //: //: 4 Test with a variety of values of 'maxNumOut', including 0, //: specified to 'convert', and variety not including 0 specified to //: 'endConvert'. // // Plan: //: 1 Test the binary input with a variety of values passed to the //: 'lineLength' parameter. //: o Test the case where no value is passed to the 'lineLength' //: parameter, interpreted as a value of 76. //: o Test 0, which means no CRLF's are inserted. //: o Test a variety of positive values, including very low values. //: o Test with a variety of values passed to the 'maxNumOut' //: parameter (don't pass 0 to 'endNumOut', that would not be in //: contract. //: //: 2 Call 'checkBase64' at the end to verify that that the output //: is a valid base64 encoding, with CRLF's exactly where they're //: expected. //: //: 3 Allocate the segment of memory to write to using 'malloc' so that //: the address santizer will detect out of bounds access. // // Testing: // FUZZ TESTING WITH MAXNUMOUT // int encodedLength(int); // int encodedLength(int, int); // int convert(OUT, int *, int *, IN, IN, int); // int endConvert(OUT, int *, int); // -------------------------------------------------------------------- bool passArg; int LINE_LENGTH; int maxNumOut; { if (!LENGTH) { LINE_LENGTH = 76; passArg = false; maxNumOut = 1; } else { const unsigned llRoot = *FUZZ++ & 0xff; --LENGTH; passArg = true; LINE_LENGTH = (llRoot < 100) ? llRoot : (llRoot << 4); if (LENGTH) { maxNumOut = *FUZZ++ & 0xff; --LENGTH; } else { maxNumOut = 1; } } } const char * const begin = FUZZ; const char * const end = FUZZ + LENGTH; const bool leftOver = LENGTH % 3; const int outLength = passArg ? Obj::encodedLength(LENGTH, LINE_LENGTH) : Obj::encodedLength(LENGTH); ASSERT(0 != LINE_LENGTH || 0 == outLength % 4); char *outBuf = static_cast<char *>(bsl::malloc(outLength+1)); const char *outBegin = outBuf; bsl::fill(outBuf, outBuf + outLength + 1, GARBAGE); bsls::ObjectBuffer<Obj> ob; if (passArg) { new (ob.address()) Obj(LINE_LENGTH); } else { new (ob.address()) Obj(); } Obj& mX = ob.object(); const Obj& X = mX; int numOut, numIn, endNumOut; const char *beginIn = begin; int rc; int outSoFar = 0; char *out = outBuf; do { rc = mX.convert(out, &numOut, &numIn, beginIn, end, maxNumOut); ASSERT(0 <= rc); ASSERT(0 == rc || 0 <= maxNumOut); ASSERT(0 <= numOut); ASSERT(numOut <= maxNumOut || maxNumOut < 0); out += numOut; ASSERT(outBuf <= out); ASSERT(out <= outBuf + outLength); ASSERT(0 <= numIn); outSoFar += numOut; beginIn += numIn; ASSERTV(numIn, maxNumOut, numIn <= maxNumOut + 4 || maxNumOut < 0); ASSERT(outSoFar <= outLength); ASSERT(beginIn <= end); ASSERT(!leftOver || outSoFar < outLength); ASSERT(!leftOver || out < outBuf + outLength); } while (beginIn < end); ASSERT(end == beginIn); ASSERT(0 == bsl::count_if(outBuf, outBuf + outSoFar, &u::notBase64NotEquals)); if (0 == maxNumOut) { maxNumOut = 1; } int numEndConvertCalls = 0; do { ++numEndConvertCalls; rc = mX.endConvert(out, &endNumOut, maxNumOut); if (0 != rc) { ASSERT(0 < endNumOut); ASSERT(endNumOut == maxNumOut); } outSoFar += endNumOut; out += endNumOut; ASSERT(0 == bsl::count_if(outBegin, outBegin + outSoFar, &u::notBase64)); } while (rc); ASSERTV(maxNumOut, outSoFar, numEndConvertCalls, X.isDone()); ASSERTV(run, LINE_LENGTH, maxNumOut, numEndConvertCalls, outLength, outSoFar, outLength == outSoFar); u::checkBase64(outBuf, outBuf + outSoFar, LINE_LENGTH); ASSERT(GARBAGE == outBuf[outLength]); ASSERT(leftOver == (0 < bsl::count(outBuf, outBuf + outSoFar, '='))); free(outBuf); mX.~Obj(); } break; default: { } break; } if (testStatus > 0) { BSLS_ASSERT_INVOKE("FUZZ TEST FAILURES"); } ++run; return 0; } // ============================================================================ // SUPPORT FOR USAGE EXAMPLE // ---------------------------------------------------------------------------- int streamEncoder(bsl::ostream& os, bsl::istream& is) { enum { e_SUCCESS = 0, e_ENCODE_ERROR = -1, e_IO_ERROR = -2 }; bdlde::Base64Encoder converter; const int INBUFFER_SIZE = 1 << 10; const int OUTBUFFER_SIZE = 1 << 10; char inputBuffer[INBUFFER_SIZE]; char outputBuffer[OUTBUFFER_SIZE]; char *output = outputBuffer; char *outputEnd = outputBuffer + sizeof outputBuffer; while (is.good()) { // input stream not exhausted is.read(inputBuffer, sizeof inputBuffer); const char *input = inputBuffer; const char *inputEnd = input + is.gcount(); while (input < inputEnd) { // input encoding not complete int numOut; int numIn; int status = converter.convert( output, &numOut, &numIn, input, inputEnd, static_cast<int>(outputEnd - output)); if (status < 0) { return e_ENCODE_ERROR; // RETURN } output += numOut; input += numIn; if (output == outputEnd) { // output buffer full; write data os.write(outputBuffer, sizeof outputBuffer); if (os.fail()) { return e_IO_ERROR; // RETURN } output = outputBuffer; } } } while (1) { int numOut; int more = converter.endConvert(output, &numOut, static_cast<int>(outputEnd - output)); if (more < 0) { return e_ENCODE_ERROR; // RETURN } output += numOut; if (!more) { // no more output break; } ASSERT(output == outputEnd); // output buffer is full os.write (outputBuffer, sizeof outputBuffer); // write buffer if (os.fail()) { return e_IO_ERROR; // RETURN } output = outputBuffer; } if (output > outputBuffer) { os.write (outputBuffer, output - outputBuffer); } return (is.eof() && os.good()) ? e_SUCCESS : e_IO_ERROR; } int streamDecoder(bsl::ostream& os, bsl::istream& is) { enum { e_SUCCESS = 0, e_DECODE_ERROR = -1, e_IO_ERROR = -2 }; u_Base64Decoder_Test converter; const int INBUFFER_SIZE = 1 << 10; const int OUTBUFFER_SIZE = 1 << 10; char inputBuffer[INBUFFER_SIZE]; char outputBuffer[OUTBUFFER_SIZE]; char *output = outputBuffer; char *outputEnd = outputBuffer + sizeof outputBuffer; int numOut; int numIn; while (is.good()) { // input stream not exhausted is.read(inputBuffer, sizeof inputBuffer); const char *input = inputBuffer; const char *inputEnd = input + is.gcount(); while (input < inputEnd) { // input encoding not complete int status = converter.convert( output, &numOut, &numIn, input, inputEnd, static_cast<int>(outputEnd - output)); if (status < 0) { return e_DECODE_ERROR; // RETURN } output += numOut; input += numIn; if (output == outputEnd) { // output buffer full; write data os.write(outputBuffer, sizeof outputBuffer); if (os.fail()) { return e_IO_ERROR; // RETURN } output = outputBuffer; } } } while (1) { int more = converter.endConvert(output, &numOut, static_cast<int>(outputEnd - output)); if (more < 0) { return e_DECODE_ERROR; // RETURN } output += numOut; if (!more) { // no more output break; } ASSERT(output == outputEnd); // output buffer is full os.write (outputBuffer, sizeof outputBuffer); // write buffer if (os.fail()) { return e_IO_ERROR; // RETURN } output = outputBuffer; } if (output > outputBuffer) { os.write (outputBuffer, output - outputBuffer); } return (is.eof() && os.good()) ? e_SUCCESS : e_IO_ERROR; } // ============================================================================ // MAIN PROGRAM // ---------------------------------------------------------------------------- int main(int argc, char *argv[]) { int test = argc > 1 ? atoi(argv[1]) : 0; int verbose = argc > 2; int veryVerbose = argc > 3; int veryVeryVerbose = argc > 4; int veryVeryVeryVerbose = argc > 5; cout << "TEST " << __FILE__ << " CASE " << test << endl; // CONCERN: 'BSLS_REVIEW' failures should lead to test failures. bsls::ReviewFailureHandlerGuard reviewGuard(&bsls::Review::failByAbort); switch (test) { case 0: // Zero is always the leading case. case 13: { // -------------------------------------------------------------------- // TESTING OPTIONAL NUMIN, NUMOUT // This case is available to be used as a developers' sandbox. // // Concerns: // That 'convert' will function properly with null passed to // either or both of 'numOut' and 'numIn'. // // Plan: // Repeat breathing test, only pass null to 'numIn' or 'numOut' in // all cases. // -------------------------------------------------------------------- if (verbose) cout << endl << "TESTING OPTIONAL NUMIN, NUMOUT" << endl << "==============================" << endl; if (veryVerbose) { P_(int('+')); P((void*)'+'); P_(int('/')); P((void*)'/'); P_(int('=')); P((void*)'='); P((int)(signed char) '\xff'); P((int)(unsigned char) '\xff'); P((int)(char) '\xff'); } if (verbose) cout << "\nTry '::myMin' test helper function." << endl; { ASSERT('a'== myMin('a', 'b')); ASSERT(-5 == myMin(3, -5)); ASSERT(-3 == myMin(-3, 5)); } if (verbose) cout << "\nTry '::printCharN' test helper function." << endl; { bsl::ostringstream out; const char in[] = "a" "\x00" "b" "\x07" "c" "\x08" "d" "\x0F" "e" "\x10" "f" "\x80" "g" "\xFF"; printCharN(out, in, sizeof in) << ends; const char EXP[] = "a<00>b<07>c<08>d<0F>e<10>f<80>g<FF><00>"; if (veryVerbose) { cout << "\tRESULT = " << out.str().c_str() << endl; cout << "\tEXPECT = " << EXP << endl; } ASSERT(0 == strncmp(EXP, out.str().c_str(), sizeof EXP)); } if (verbose) cout << "\nTry instantiating an encoder." << endl; { Obj encoder; if (veryVerbose) { T_ P(encoder.isAcceptable()); T_ P(encoder.isDone()); T_ P(encoder.isError()); T_ P(encoder.isInitialState()); T_ P(encoder.maxLineLength()); T_ P(encoder.outputLength()); } if (verbose) cout << "\nEncode something." << endl; static char out[1000]; int outIdx = 0; int numIn = 0; int numOut = 0; // begin: 0 1 3 4 8 9 END // end : 1 3 4 8 9 10 INPUT const char*const input = "\0" "\0\0" "\0" "\0\0\0\0" "\0" "\0"; ASSERT(0 == numOut); ASSERT(0 == numIn); ASSERT(0 == outIdx); ASSERT(0 == out[0]); ASSERT(0 == out[1]); if (verbose) cout << "\tEncode: ^0." << endl; { const char *const begin = input + 0; const char *const end = input + 1; encoder.convert(out + outIdx, 0, 0, begin, end); outIdx += 1; if (veryVerbose) { T_ T_ P_(numIn) P_(numOut) P_(outIdx) cout << "output: \""; printCharN(cout, out, outIdx) << '"' << endl; } } ASSERT(1 == outIdx); ASSERT('A' == out[0]); ASSERT(0 == out[1]); if (verbose) cout << "\tEncode: 0^00." << endl; { const char *const begin = input + 1; const char *const end = input + 3; encoder.convert(out + outIdx, 0, 0, begin, end); outIdx += 3; if (veryVerbose) { T_ T_ P_(numOut) P_(outIdx) cout << "output: \""; printCharN(cout, out, outIdx) << '"' << endl; } } ASSERT(4 == outIdx); ASSERT('A' == out[3]); ASSERT(0 == out[4]); if (verbose) cout << "\tEncode: 000^0." << endl; { const char *const begin = input + 3; const char *const end = input + 4; encoder.convert(out + outIdx, &numOut, 0, begin, end); outIdx += numOut; if (veryVerbose) { T_ T_ P_(numOut) P_(outIdx) cout << "output: \""; printCharN(cout, out, outIdx) << '"' << endl; } } ASSERT(1 == numOut); ASSERT(5 == outIdx); ASSERT('A' == out[3]); ASSERT('A' == out[4]); ASSERT(0 == out[5]); if (verbose) cout << "\tEncode: 0000^0000." << endl; { const char *const begin = input + 4; const char *const end = input + 8; encoder.convert(out + outIdx, 0, &numIn, begin, end); outIdx += 5; if (veryVerbose) { T_ T_ P_(numIn) P_(numOut) P_(outIdx) cout << "output: \""; printCharN(cout, out, outIdx) << '"' << endl; } } ASSERT(4 == numIn); ASSERT(10 == outIdx); ASSERT('A' == out[7]); ASSERT('A' == out[8]); ASSERT('A' == out[9]); ASSERT(0 == out[10]); if (verbose) cout << "\tEncode: 00000000^0." << endl; { const char *const begin = input + 8; const char *const end = input + 9; encoder.convert(out + outIdx, &numOut, 0, begin, end); outIdx += numOut; if (veryVerbose) { T_ T_ P_(numOut) P_(outIdx) cout << "output: \""; printCharN(cout, out, outIdx) << '"' << endl; } } ASSERT(2 == numOut); ASSERT(12 == outIdx); ASSERT('A' == out[11]); ASSERT(0 == out[12]); if (verbose) cout << "\tEncode: 000000000^0." << endl; { const char *const begin = input + 9; const char *const end = input + 10; encoder.convert(out + outIdx, 0, 0, begin, end); outIdx += 1; if (veryVerbose) { T_ T_ P_(numIn) P_(outIdx) cout << "output: \""; printCharN(cout, out, outIdx) << '"' << endl; } } ASSERT(13 == outIdx); ASSERT('A' == out[11]); ASSERT('A' == out[12]); ASSERT(0 == out[13]); if (verbose) cout << "\tEncode: 0000000000^$." << endl; { encoder.endConvert(out + outIdx, &numOut); outIdx += numOut; if (veryVerbose) { T_ T_ P_(numIn) P_(numOut) P_(outIdx) cout << "output: \""; printCharN(cout, out, outIdx) << '"' << endl; } } ASSERT(3 == numOut); ASSERT(16 == outIdx); ASSERT('A' == out[12]); ASSERT('A' == out[13]); ASSERT('=' == out[14]); ASSERT('=' == out[15]); ASSERT(0 == out[16]); } } break; case 12: { // -------------------------------------------------------------------- // STRESS TEST // Demonstrate that the encoder/decoder can encode/decode a large // number of characters continuously. // // Concerns: // - That the encoder and decoder are not subject to any physical // or software limit. // - That encodedLength returns the right number of output characters // from the encoder including the soft line breaks. // // Plan: // - First have the encoder convert a large amount of text, created // for example by copying from a Bloomberg news page. Then use the // decoder to convert the result back into its original form. // Finally, verify that the output from the decoder to the input to // the encoder are identical. // // Tactics: // - Ad-Hoc Data Selection Method // - Brute-Force Implementation Technique // // Testing: // Stress limits of encoder/decoder. // -------------------------------------------------------------------- if (verbose) cout << endl << "STRESS TEST" << endl << "=============" << endl; V("Verify a text sample whose number of characters is 0 mod 3."); { const char sample[] = "Education is a useful tool."; int maxLineLength = 0; bdlde::Base64Encoder encoder(maxLineLength); u_Base64Decoder_Test decoder(true); int origSize = static_cast<int>(strlen(sample)); int encodedLen = encoder.encodedLength(origSize, maxLineLength); char *encoded = new char[encodedLen]; int maxDecodedLen = decoder.maxDecodedLength(encodedLen); char *decoded = new char[maxDecodedLen] ; VV("Original input size = " << origSize); VV("Encoded length = " << encodedLen); VV("Max decoded length = " << maxDecodedLen); int numOutEncoded = -1; int numOutEndEncode = -1; int numInEncoded = -1; int numOutDecoded = -1; int numOutEndDecode = -1; int numInDecoded = -1; encoder.convert(encoded, &numOutEncoded, &numInEncoded, sample, sample + origSize); encoder.endConvert(encoded + numOutEncoded, &numOutEndEncode); numOutEncoded += numOutEndEncode; ASSERT(numOutEncoded == encodedLen); decoder.convert(decoded, &numOutDecoded, &numInDecoded, encoded, encoded + numOutEncoded); decoder.endConvert(decoded + numOutDecoded, &numOutEndDecode); numOutDecoded += numOutEndDecode; ASSERT(numOutDecoded <= maxDecodedLen); VV("NumOut from endEncode = " << numOutEndEncode); VV("Total numOut from encoder = " << numOutEncoded); VV("NumOut from endDecode = " << numOutEndDecode); VV("Total numOut from decoder = " << numOutDecoded); VV("Encoder input = \n\"" << sample << "\""); VV("Encoder output = \n\"" << encoded << "\""); VV("Decoder output = \n\"" << decoded << "\""); ASSERT(origSize == numOutDecoded); ASSERT(0 == memcmp(decoded, sample, origSize)); delete[] encoded; delete[] decoded; } V("-----------------------------------------------------------"); V("Verify a text sample whose number of characters is 1 mod 3."); { const char sample[] = "Education is also a lot of fun."; int maxLineLength = 0; bdlde::Base64Encoder encoder(maxLineLength); u_Base64Decoder_Test decoder(true); int origSize = static_cast<int>(strlen(sample)); int encodedLen = encoder.encodedLength(origSize, maxLineLength); char *encoded = new char[encodedLen]; int maxDecodedLen = decoder.maxDecodedLength(encodedLen); char *decoded = new char[maxDecodedLen] ; VV("Original input size = " << origSize); VV("Encoded length = " << encodedLen); VV("Max decoded length = " << maxDecodedLen); int numOutEncoded = -1; int numOutEndEncode = -1; int numInEncoded = -1; int numOutDecoded = -1; int numOutEndDecode = -1; int numInDecoded = -1; encoder.convert(encoded, &numOutEncoded, &numInEncoded, sample, sample + origSize); encoder.endConvert(encoded + numOutEncoded, &numOutEndEncode); numOutEncoded += numOutEndEncode; ASSERT(numOutEncoded == encodedLen); decoder.convert(decoded, &numOutDecoded, &numInDecoded, encoded, encoded + numOutEncoded); decoder.endConvert(decoded + numOutDecoded, &numOutEndDecode); numOutDecoded += numOutEndDecode; ASSERT(numOutDecoded <= maxDecodedLen); VV("NumOut from endEncode = " << numOutEndEncode); VV("Total numOut from encoder = " << numOutEncoded); VV("NumOut from endDecode = " << numOutEndDecode); VV("Total numOut from decoder = " << numOutDecoded); VV("Encoder input = \n\"" << sample << "\""); VV("Encoder output = \n\"" << encoded << "\""); VV("Decoder output = \n\"" << decoded << "\""); ASSERT(origSize == numOutDecoded); ASSERT(0 == memcmp(decoded, sample, origSize)); delete[] encoded; delete[] decoded; } V("-----------------------------------------------------------"); V("Verify a text sample whose number of characters is 2 mod 3."); V("and also an even number"); { const char sample[] = "Education was originally a tool."; int maxLineLength = 0; bdlde::Base64Encoder encoder(maxLineLength); u_Base64Decoder_Test decoder(true); int origSize = static_cast<int>(strlen(sample)); int encodedLen = encoder.encodedLength(origSize, maxLineLength); char *encoded = new char[encodedLen]; int maxDecodedLen = decoder.maxDecodedLength(encodedLen); char *decoded = new char[maxDecodedLen] ; VV("Original input size = " << origSize); VV("Encoded length = " << encodedLen); VV("Max decoded length = " << maxDecodedLen); int numOutEncoded = -1; int numOutEndEncode = -1; int numInEncoded = -1; int numOutDecoded = -1; int numOutEndDecode = -1; int numInDecoded = -1; encoder.convert(encoded, &numOutEncoded, &numInEncoded, sample, sample + origSize); encoder.endConvert(encoded + numOutEncoded, &numOutEndEncode); numOutEncoded += numOutEndEncode; ASSERT(numOutEncoded == encodedLen); decoder.convert(decoded, &numOutDecoded, &numInDecoded, encoded, encoded + numOutEncoded); decoder.endConvert(decoded + numOutDecoded, &numOutEndDecode); numOutDecoded += numOutEndDecode; ASSERT(numOutDecoded <= maxDecodedLen); VV("NumOut from endEncode = " << numOutEndEncode); VV("Total numOut from encoder = " << numOutEncoded); VV("NumOut from endDecode = " << numOutEndDecode); VV("Total numOut from decoder = " << numOutDecoded); VV("Encoder input = \n\"" << sample << "\""); VV("Encoder output = \n\"" << encoded << "\""); VV("Decoder output = \n\"" << decoded << "\""); ASSERT(origSize == numOutDecoded); ASSERT(0 == memcmp(decoded, sample, origSize)); delete[] encoded; delete[] decoded; } V("-----------------------------------------------------------"); V("Verify a text sample whose number of characters is 2 mod 3."); V("but not an even number."); { const char sample[] = "This is exactly 29 char long."; int maxLineLength = 0; bdlde::Base64Encoder encoder(maxLineLength); u_Base64Decoder_Test decoder(true); int origSize = static_cast<int>(strlen(sample)); int encodedLen = encoder.encodedLength(origSize, maxLineLength); char *encoded = new char[encodedLen]; int maxDecodedLen = decoder.maxDecodedLength(encodedLen); char *decoded = new char[maxDecodedLen] ; VV("Original input size = " << origSize); VV("Encoded length = " << encodedLen); VV("Max decoded length = " << maxDecodedLen); int numOutEncoded = -1; int numOutEndEncode = -1; int numInEncoded = -1; int numOutDecoded = -1; int numOutEndDecode = -1; int numInDecoded = -1; encoder.convert(encoded, &numOutEncoded, &numInEncoded, sample, sample + origSize); encoder.endConvert(encoded + numOutEncoded, &numOutEndEncode); numOutEncoded += numOutEndEncode; ASSERT(numOutEncoded == encodedLen); decoder.convert(decoded, &numOutDecoded, &numInDecoded, encoded, encoded + numOutEncoded); decoder.endConvert(decoded + numOutDecoded, &numOutEndDecode); numOutDecoded += numOutEndDecode; ASSERT(numOutDecoded <= maxDecodedLen); VV("NumOut from endEncode = " << numOutEndEncode); VV("Total numOut from encoder = " << numOutEncoded); VV("NumOut from endDecode = " << numOutEndDecode); VV("Total numOut from decoder = " << numOutDecoded); VV("Encoder input = \n\"" << sample << "\""); VV("Encoder output = \n\"" << encoded << "\""); VV("Decoder output = \n\"" << decoded << "\""); ASSERT(origSize == numOutDecoded); ASSERT(0 == memcmp(decoded, sample, origSize)); delete[] encoded; delete[] decoded; } V("-----------------------------------------------------------"); V("Verify an ad-hoc text sample."); { const char sample[] = "NXTW MSG 1 * 401817628 453493 0<GO>NXTW 97<GO>"; int maxLineLength = 0; bdlde::Base64Encoder encoder(maxLineLength); u_Base64Decoder_Test decoder(true); int origSize = static_cast<int>(strlen(sample)); int encodedLen = encoder.encodedLength(origSize, maxLineLength); char *encoded = new char[encodedLen]; int maxDecodedLen = decoder.maxDecodedLength(encodedLen); char *decoded = new char[maxDecodedLen] ; VV("Original input size = " << origSize); VV("Encoded length = " << encodedLen); VV("Max decoded length = " << maxDecodedLen); int numOutEncoded = -1; int numOutEndEncode = -1; int numInEncoded = -1; int numOutDecoded = -1; int numOutEndDecode = -1; int numInDecoded = -1; encoder.convert(encoded, &numOutEncoded, &numInEncoded, sample, sample + origSize); encoder.endConvert(encoded + numOutEncoded, &numOutEndEncode); numOutEncoded += numOutEndEncode; ASSERT(numOutEncoded == encodedLen); decoder.convert(decoded, &numOutDecoded, &numInDecoded, encoded, encoded + numOutEncoded); decoder.endConvert(decoded + numOutDecoded, &numOutEndDecode); numOutDecoded += numOutEndDecode; ASSERT(numOutDecoded <= maxDecodedLen); VV("NumOut from endEncode = " << numOutEndEncode); VV("Total numOut from encoder = " << numOutEncoded); VV("NumOut from endDecode = " << numOutEndDecode); VV("Total numOut from decoder = " << numOutDecoded); VV("Encoder input = \n\"" << sample << "\""); VV("Encoder output = \n\"" << encoded << "\""); VV("Decoder output = \n\"" << decoded << "\""); ASSERT(origSize == numOutDecoded); ASSERT(0 == memcmp(decoded, sample, origSize)); delete[] encoded; delete[] decoded; } V("-----------------------------------------------------------"); V("Verify the second ad-hoc text sample."); { const char sample[] = "NXTW PRLS 78358<GO>"; int maxLineLength = 0; bdlde::Base64Encoder encoder(maxLineLength); u_Base64Decoder_Test decoder(true); int origSize = static_cast<int>(strlen(sample)); int encodedLen = encoder.encodedLength(origSize, maxLineLength); char *encoded = new char[encodedLen]; int maxDecodedLen = decoder.maxDecodedLength(encodedLen); char *decoded = new char[maxDecodedLen] ; VV("Original input size = " << origSize); VV("Encoded length = " << encodedLen); VV("Max decoded length = " << maxDecodedLen); int numOutEncoded = -1; int numOutEndEncode = -1; int numInEncoded = -1; int numOutDecoded = -1; int numOutEndDecode = -1; int numInDecoded = -1; encoder.convert(encoded, &numOutEncoded, &numInEncoded, sample, sample + origSize); encoder.endConvert(encoded + numOutEncoded, &numOutEndEncode); numOutEncoded += numOutEndEncode; ASSERT(numOutEncoded == encodedLen); decoder.convert(decoded, &numOutDecoded, &numInDecoded, encoded, encoded + numOutEncoded); decoder.endConvert(decoded + numOutDecoded, &numOutEndDecode); numOutDecoded += numOutEndDecode; ASSERT(numOutDecoded <= maxDecodedLen); VV("NumOut from endEncode = " << numOutEndEncode); VV("Total numOut from encoder = " << numOutEncoded); VV("NumOut from endDecode = " << numOutEndDecode); VV("Total numOut from decoder = " << numOutDecoded); VV("Encoder input = \n\"" << sample << "\""); VV("Encoder output = \n\"" << encoded << "\""); VV("Decoder output = \n\"" << decoded << "\""); ASSERT(origSize == numOutDecoded); ASSERT(0 == memcmp(decoded, sample, origSize)); delete[] encoded; delete[] decoded; } V("-----------------------------------------------------------"); V("Verify the third ad-hoc text sample."); { const char sample[] = "NXTW BICQ > 11 57 401806044<GO>"; int maxLineLength = 0; bdlde::Base64Encoder encoder(maxLineLength); u_Base64Decoder_Test decoder(true); int origSize = static_cast<int>(strlen(sample)); int encodedLen = encoder.encodedLength(origSize, maxLineLength); char *encoded = new char[encodedLen]; int maxDecodedLen = decoder.maxDecodedLength(encodedLen); char *decoded = new char[maxDecodedLen] ; VV("Original input size = " << origSize); VV("Encoded length = " << encodedLen); VV("Max decoded length = " << maxDecodedLen); int numOutEncoded = -1; int numOutEndEncode = -1; int numInEncoded = -1; int numOutDecoded = -1; int numOutEndDecode = -1; int numInDecoded = -1; encoder.convert(encoded, &numOutEncoded, &numInEncoded, sample, sample + origSize); encoder.endConvert(encoded + numOutEncoded, &numOutEndEncode); numOutEncoded += numOutEndEncode; ASSERT(numOutEncoded == encodedLen); decoder.convert(decoded, &numOutDecoded, &numInDecoded, encoded, encoded + numOutEncoded); decoder.endConvert(decoded + numOutDecoded, &numOutEndDecode); numOutDecoded += numOutEndDecode; ASSERT(numOutDecoded <= maxDecodedLen); VV("NumOut from endEncode = " << numOutEndEncode); VV("Total numOut from encoder = " << numOutEncoded); VV("NumOut from endDecode = " << numOutEndDecode); VV("Total numOut from decoder = " << numOutDecoded); VV("Encoder input = \n\"" << sample << "\""); VV("Encoder output = \n\"" << encoded << "\""); VV("Decoder output = \n\"" << decoded << "\""); ASSERT(origSize == numOutDecoded); ASSERT(0 == memcmp(decoded, sample, origSize)); delete[] encoded; delete[] decoded; } V("------------------------------------------------------"); V("Verify a large text sample consisting of 101 lines and"); V("(5369 - 202) = 5167 characters.") V("Verify encoder with unlimited line length."); { const char* sample = BLOOMBERG_NEWS; int maxLineLength = 0; bdlde::Base64Encoder encoder(maxLineLength); u_Base64Decoder_Test decoder(true); int origSize = static_cast<int>(strlen(sample)); int encodedLen = encoder.encodedLength(origSize, maxLineLength); char *encoded = new char[encodedLen]; int maxDecodedLen = decoder.maxDecodedLength(encodedLen); char *decoded = new char[maxDecodedLen] ; VV("Original input size = " << origSize); VV("Encoded length = " << encodedLen); VV("Max decoded length = " << maxDecodedLen); int numOutEncoded = -1; int numOutEndEncode = -1; int numInEncoded = -1; int numOutDecoded = -1; int numOutEndDecode = -1; int numInDecoded = -1; encoder.convert(encoded, &numOutEncoded, &numInEncoded, sample, sample + origSize); encoder.endConvert(encoded + numOutEncoded, &numOutEndEncode); numOutEncoded += numOutEndEncode; ASSERT(numOutEncoded == encodedLen); decoder.convert(decoded, &numOutDecoded, &numInDecoded, encoded, encoded + numOutEncoded); decoder.endConvert(decoded + numOutDecoded, &numOutEndDecode); numOutDecoded += numOutEndDecode; ASSERT(numOutDecoded <= maxDecodedLen); VV("NumOut from endEncode = " << numOutEndEncode); VV("Total numOut from encoder = " << numOutEncoded); VV("NumOut from endDecode = " << numOutEndDecode); VV("Total numOut from decoder = " << numOutDecoded); VV("Encoder input = \n\"" << sample << "\""); VV("Encoder output = \n\"" << encoded << "\""); VV("Decoder output = \n\"" << decoded << "\""); ASSERT(origSize == numOutDecoded); ASSERT(0 == memcmp(decoded, sample, origSize)); delete[] encoded; delete[] decoded; } V("Verify encoder with maximum line length = 76."); { const char* sample = BLOOMBERG_NEWS; int maxLineLength = 76; bdlde::Base64Encoder encoder; u_Base64Decoder_Test decoder(true); int origSize = static_cast<int>(strlen(sample)); int encodedLen = encoder.encodedLength(origSize, maxLineLength); char *encoded = new char[encodedLen]; int maxDecodedLen = decoder.maxDecodedLength(encodedLen); char *decoded = new char[maxDecodedLen] ; VV("Original input size = " << origSize); VV("Encoded length = " << encodedLen); VV("Max decoded length = " << maxDecodedLen); int numOutEncoded = -1; int numOutEndEncode = -1; int numInEncoded = -1; int numOutDecoded = -1; int numOutEndDecode = -1; int numInDecoded = -1; encoder.convert(encoded, &numOutEncoded, &numInEncoded, sample, sample + origSize); encoder.endConvert(encoded + numOutEncoded, &numOutEndEncode); numOutEncoded += numOutEndEncode; ASSERT(numOutEncoded == encodedLen); decoder.convert(decoded, &numOutDecoded, &numInDecoded, encoded, encoded + numOutEncoded); decoder.endConvert(decoded + numOutDecoded, &numOutEndDecode); numOutDecoded += numOutEndDecode; ASSERT(numOutDecoded <= maxDecodedLen); VV("NumOut from endEncode = " << numOutEndEncode); VV("Total numOut from encoder = " << numOutEncoded); VV("NumOut from endDecode = " << numOutEndDecode); VV("Total numOut from decoder = " << numOutDecoded); VV("Encoder input = \n\"" << sample << "\""); VV("Encoder output = \n\"" << encoded << "\""); VV("Decoder output = \n\"" << decoded << "\""); ASSERT(origSize == numOutDecoded); ASSERT(0 == memcmp(decoded, sample, origSize)); delete[] encoded; delete[] decoded; } } break; case 11: { // -------------------------------------------------------------------- // USAGE EXAMPLE // Demonstrate that the example compiles, links, and runs. // // Concerns: // That the example compiles, links, and runs. // // Plan: // Create the example in a form that can be cut and pasted easily // into the header file. Then use the stream encoder and decoder on // some string, and compare the output with the original data. // // Tactics: // - Ad-HocData Selection Method // - Brute-Force Implementation Technique // // Testing: // USAGE EXAMPLE // -------------------------------------------------------------------- if (verbose) cout << endl << "USAGE EXAMPLE" << endl << "=============" << endl; ///Usage Example ///------------- // The following example shows how to use a 'bdlde::Base64Encoder' object to // implement a function, 'streamEncode', that reads text from a 'bsl::istream', // encodes that text from base 64 representation, and writes the encoded text // to a 'bsl::ostream'. 'streamEncoder' returns 0 on success and a negative // value if the input data could not be successfully encoded or if there is an // I/O error. //.. // streamencoder.h -*-C++-*- // // int streamEncoder(bsl::ostream& os, bsl::istream& is); // // Read the entire contents of the specified input stream 'is', convert // // the input base-64 encoding into plain text, and write the decoded // // text to the specified output stream 'os'. Return 0 on success, and a // // negative value otherwise. //.. bsl::istringstream inStream(bsl::string(BLOOMBERG_NEWS, sizeof(BLOOMBERG_NEWS))); bsl::stringstream outStream; bsl::stringstream backInStream; ASSERT(0 == streamEncoder(outStream, inStream)); ASSERT(0 == streamDecoder(backInStream, outStream)); cout << backInStream.str(); ASSERT(0 == strcmp(BLOOMBERG_NEWS, backInStream.str().c_str())); } break; case 10: { // -------------------------------------------------------------------- // DEFAULT CONSTRUCTOR: // Verify initial configuration defaults. // // Concerns: // - That the default line-length is 76. // - That the state is the initial state. // // Plan: // - Create the object and query it for its information. // - Use '::isState' to verify that the newly created object is in // the initial state. // - Create two lines whose unlimited output lengths would be 76 // and 80 characters, respectively. // + Observe the respective output lengths to be 76 and 82. // // Tactics: // - Ad-HocData Selection Method // - Brute-Force Implementation Technique // // Testing: // bdlde::Base64Encoder(); // -------------------------------------------------------------------- if (verbose) cout << endl << "DEFAULT CONSTRUCTOR" << endl << "===================" << endl; if (verbose) cout << "\nVerify default configuration and initial state." << endl; { Obj obj; ASSERT(76 == obj.maxLineLength()); ASSERT( 1 == obj.isAcceptable()); ASSERT( 0 == obj.isDone()); ASSERT( 0 == obj.isError()); ASSERT( 1 == obj.isInitialState()); ASSERT( 0 == obj.outputLength()); ASSERT(isState(&obj, e_INITIAL_STATE)); } if (verbose) cout << "\nTest default maximum line length." << endl; const char *const input = "1234567890" "1234567890" "1234567890" "1234567890" "1234567890" "1234567"; if (verbose) cout << "\tInput 57 bytes; output 76 characters." << endl; { Obj obj; char outputBuffer[100]; memset(outputBuffer, '?', sizeof outputBuffer); int numIn, numOut; const char *const B = input, *const E = B + 57; obj.convert(outputBuffer, &numOut, &numIn, B, E); obj.endConvert(outputBuffer + numOut, &numOut); ASSERT(76 == obj.outputLength()); ASSERT('?' != outputBuffer[ 0]); ASSERT('?' != outputBuffer[75]); ASSERT('?' == outputBuffer[76]); ASSERT('?' == outputBuffer[77]); ASSERT('?' == outputBuffer[78]); ASSERT('?' == outputBuffer[79]); ASSERT('?' == outputBuffer[80]); ASSERT('?' == outputBuffer[81]); ASSERT('?' == outputBuffer[82]); ASSERT('?' == outputBuffer[99]); } if (verbose) cout << "\tInput 58 bytes; output 82 characters." << endl; { Obj obj; char outputBuffer[100]; memset(outputBuffer, '?', sizeof outputBuffer); int numIn, numOut; const char *const B = input, *const E = B + 58; obj.convert(outputBuffer, &numOut, &numIn, B, E); obj.endConvert(outputBuffer + numOut, &numOut); ASSERT(82 == obj.outputLength()); ASSERT('?' != outputBuffer[ 0]); ASSERT('?' != outputBuffer[75]); ASSERT('\r' == outputBuffer[76]); ASSERT('\n' == outputBuffer[77]); ASSERT('A' == outputBuffer[78]); ASSERT('A' == outputBuffer[79]); ASSERT('=' == outputBuffer[80]); ASSERT('=' == outputBuffer[81]); ASSERT('?' == outputBuffer[82]); ASSERT('?' == outputBuffer[99]); } } break; case 9: { // -------------------------------------------------------------------- // RESET STATE // Verify the 'resetState' method. // // Concerns: // - That resetState returns the object to its initial state (i.e., // the same as it was immediately after construction. // - That the initial configuration is not altered. // // Plan: // - Use put the object in each state and verify the expected // state is not/is in the initial state before/after the call to // 'resetState'. // - Verify that the initial configuration has not changed. // - Repeat the above with a different configuration. // // Tactics: // - Area Data Selection Method // - Loop-Based Implementation Technique // // Testing: // USAGE EXAMPLE // -------------------------------------------------------------------- if (verbose) cout << endl << "RESET STATE" << endl << "===========" << endl; if (verbose) cout << "\nVerify 'resetState'." << endl; if (verbose) cout << "\tWith 'maxLineLength' = 0." << endl; { for (int i = 0; i < NUM_STATES; ++i) { Obj obj(0); if (verbose) cout << "\t\t" << STATE_NAMES[i] << '.' << endl; setState(&obj, i); const bool SAME = e_INITIAL_STATE == i; if (veryVerbose) { T_ T_ T_ P(SAME) } LOOP_ASSERT(i, SAME == isState(&obj, e_INITIAL_STATE)); obj.resetState(); LOOP_ASSERT(i, 1 == isState(&obj, e_INITIAL_STATE)); LOOP_ASSERT(i, 0 == obj.maxLineLength()); } } if (verbose) cout << "\tWith 'maxLineLength' = 5." << endl; { for (int i = 0; i < NUM_STATES; ++i) { Obj obj(5); if (verbose) cout << "\t\t" << STATE_NAMES[i] << '.' << endl; setState(&obj, i); const bool SAME = e_INITIAL_STATE == i; if (veryVerbose) { T_ T_ T_ P(SAME) } LOOP_ASSERT(i, SAME == isState(&obj, e_INITIAL_STATE)); obj.resetState(); LOOP_ASSERT(i, 1 == isState(&obj, e_INITIAL_STATE)); LOOP_ASSERT(i, 5 == obj.maxLineLength()); } } } break; case 8: { // TBD? } break; case 7: { // -------------------------------------------------------------------- // PRIMARY MANIPULATORS WITH DEFAULT ARGUMENTS. // Continue testing 'convert' and 'endConvert' with defaults // arguments. // // Concerns: // - That the conversion logic is correct in all places: // + quanta of length 1 // + quanta of length 2 // + quanta of length 3 // - That max-line-length is observed and that CRLF's are inserted // accordingly. // - That a relatively long input sequence is treated correctly. // - That a longer input sequence is treated the same as any // equivalent series of shorter subsequences supplied separately. // // Plan: // - Using Category Partitioning, enumerate input sequences of // increasing length (or length + maxLineLength) to a sufficient // *Depth* that all states in the FSM are exercised thoroughly. // + With Depth = inputLength, make sure that each bit of input // data results in the proper output for the sequence. // + With Depth = inputLength + maxLineLength of sufficient depth // to ensure that all of the output processing mechanisms are // working properly. // // - As an Orthogonal Perturbation, partition each initial sequence // into every possible pair of sequences and repeat the test. // + For each pair of subsequences, verify that the end result is // identical to that of the initial sequence. // // Tactics: // - Category Partitioning and Depth-Ordered Enumeration Data // Selection Methods // - Table-Based Implementation Technique with Orthogonal // Perturbation // // Testing: // static int encodedLength(int numInputBytes, int maxLineLength); // // DFLT convert(char *o, int *no, int *ni, begin, end, int mno = -1); // DFLT endConvert(char *out, int *numOut, int maxNumOut = -1); // // That each bit of a 3-byte quantum finds its appropriate spot. // That each bit of a 2-byte quantum finds its appropriate spot. // That each bit of a 1-byte quantum finds its appropriate spot. // That output length is calculated and stored properly. // -------------------------------------------------------------------- if (verbose) cout << endl << "PRIMARY MANIPULATORS" << endl << "====================" << endl; if (verbose) cout << endl << "\nVerifying Conversion Logic." << endl; { static const struct { int d_lineNum; // source line number int d_maxLineLength; // maximum length of output line int d_inputLength; // number of input characters const char *d_input_p; // input characters int d_outputLength; // total length of output const char *d_output_p; // expected output data } DATA[] = { //--------------^ // *** DEPTH-ORDERED ENUMERATION: Depth = inputLength; (0 == maxLineLen) *** // v---------------------INPUT--------------------v v-------OUTPUT------v //lin LL #i Input Data #o Output Data //--- -- -- ------------------------------------------ -- ------------------ { L_, 0, 0,"", 0,"" }, { L_, 0, 1,"\x00", 4,"AA==" }, { L_, 0, 1,"\x01", 4,"AQ==" }, { L_, 0, 1,"\x02", 4,"Ag==" }, { L_, 0, 1,"\x04", 4,"BA==" }, { L_, 0, 1,"\x08", 4,"CA==" }, { L_, 0, 1,"\x10", 4,"EA==" }, { L_, 0, 1,"\x20", 4,"IA==" }, { L_, 0, 1,"\x40", 4,"QA==" }, { L_, 0, 1,"\x80", 4,"gA==" }, { L_, 0, 2,"\x00\x00", 4,"AAA=" }, { L_, 0, 2,"\x00\x01", 4,"AAE=" }, { L_, 0, 2,"\x00\x02", 4,"AAI=" }, { L_, 0, 2,"\x00\x04", 4,"AAQ=" }, { L_, 0, 2,"\x00\x08", 4,"AAg=" }, { L_, 0, 2,"\x00\x10", 4,"ABA=" }, { L_, 0, 2,"\x00\x20", 4,"ACA=" }, { L_, 0, 2,"\x00\x40", 4,"AEA=" }, { L_, 0, 2,"\x00\x80", 4,"AIA=" }, { L_, 0, 3,"\x00\x00\x00", 4,"AAAA" }, { L_, 0, 3,"\x00\x00\x01", 4,"AAAB" }, { L_, 0, 3,"\x00\x00\x02", 4,"AAAC" }, { L_, 0, 3,"\x00\x00\x04", 4,"AAAE" }, { L_, 0, 3,"\x00\x00\x08", 4,"AAAI" }, { L_, 0, 3,"\x00\x00\x10", 4,"AAAQ" }, { L_, 0, 3,"\x00\x00\x20", 4,"AAAg" }, { L_, 0, 3,"\x00\x00\x40", 4,"AABA" }, { L_, 0, 3,"\x00\x00\x80", 4,"AACA" }, { L_, 0, 4,"\x00\x00\x00\x00", 8,"AAAAAA==" }, { L_, 0, 4,"\x00\x00\x00\x01", 8,"AAAAAQ==" }, { L_, 0, 4,"\x00\x00\x00\x02", 8,"AAAAAg==" }, { L_, 0, 4,"\x00\x00\x00\x04", 8,"AAAABA==" }, { L_, 0, 4,"\x00\x00\x00\x08", 8,"AAAACA==" }, { L_, 0, 4,"\x00\x00\x00\x10", 8,"AAAAEA==" }, { L_, 0, 4,"\x00\x00\x00\x20", 8,"AAAAIA==" }, { L_, 0, 4,"\x00\x00\x00\x40", 8,"AAAAQA==" }, { L_, 0, 4,"\x00\x00\x00\x80", 8,"AAAAgA==" }, { L_, 0, 5,"\x00\x00\x00\x00\x00", 8,"AAAAAAA=" }, { L_, 0, 5,"\x00\x00\x00\x00\x01", 8,"AAAAAAE=" }, { L_, 0, 5,"\x00\x00\x00\x00\x02", 8,"AAAAAAI=" }, { L_, 0, 5,"\x00\x00\x00\x00\x04", 8,"AAAAAAQ=" }, { L_, 0, 5,"\x00\x00\x00\x00\x08", 8,"AAAAAAg=" }, { L_, 0, 5,"\x00\x00\x00\x00\x10", 8,"AAAAABA=" }, { L_, 0, 5,"\x00\x00\x00\x00\x20", 8,"AAAAACA=" }, { L_, 0, 5,"\x00\x00\x00\x00\x40", 8,"AAAAAEA=" }, { L_, 0, 5,"\x00\x00\x00\x00\x80", 8,"AAAAAIA=" }, { L_, 0, 6,"\x00\x00\x00\x00\x00\x00", 8,"AAAAAAAA" }, { L_, 0, 6,"\x00\x00\x00\x00\x00\x01", 8,"AAAAAAAB" }, { L_, 0, 6,"\x00\x00\x00\x00\x00\x02", 8,"AAAAAAAC" }, { L_, 0, 6,"\x00\x00\x00\x00\x00\x04", 8,"AAAAAAAE" }, { L_, 0, 6,"\x00\x00\x00\x00\x00\x08", 8,"AAAAAAAI" }, { L_, 0, 6,"\x00\x00\x00\x00\x00\x10", 8,"AAAAAAAQ" }, { L_, 0, 6,"\x00\x00\x00\x00\x00\x20", 8,"AAAAAAAg" }, { L_, 0, 6,"\x00\x00\x00\x00\x00\x40", 8,"AAAAAABA" }, { L_, 0, 6,"\x00\x00\x00\x00\x00\x80", 8,"AAAAAACA" }, { L_, 0, 7,"\x00\x00\x00\x00\x00\x00\x00", 12,"AAAAAAAAAA==" }, { L_, 0, 7,"\x00\x00\x00\x00\x00\x00\x01", 12,"AAAAAAAAAQ==" }, { L_, 0, 7,"\x00\x00\x00\x00\x00\x00\x02", 12,"AAAAAAAAAg==" }, { L_, 0, 7,"\x00\x00\x00\x00\x00\x00\x04", 12,"AAAAAAAABA==" }, { L_, 0, 7,"\x00\x00\x00\x00\x00\x00\x08", 12,"AAAAAAAACA==" }, { L_, 0, 7,"\x00\x00\x00\x00\x00\x00\x10", 12,"AAAAAAAAEA==" }, { L_, 0, 7,"\x00\x00\x00\x00\x00\x00\x20", 12,"AAAAAAAAIA==" }, { L_, 0, 7,"\x00\x00\x00\x00\x00\x00\x40", 12,"AAAAAAAAQA==" }, { L_, 0, 7,"\x00\x00\x00\x00\x00\x00\x80", 12,"AAAAAAAAgA==" }, { L_, 0, 8,"\x00\x00\x00\x00\x00\x00\x00\x00", 12,"AAAAAAAAAAA=" }, { L_, 0, 8,"\x00\x00\x00\x00\x00\x00\x00\x01", 12,"AAAAAAAAAAE=" }, { L_, 0, 8,"\x00\x00\x00\x00\x00\x00\x00\x02", 12,"AAAAAAAAAAI=" }, { L_, 0, 8,"\x00\x00\x00\x00\x00\x00\x00\x04", 12,"AAAAAAAAAAQ=" }, { L_, 0, 8,"\x00\x00\x00\x00\x00\x00\x00\x08", 12,"AAAAAAAAAAg=" }, { L_, 0, 8,"\x00\x00\x00\x00\x00\x00\x00\x10", 12,"AAAAAAAAABA=" }, { L_, 0, 8,"\x00\x00\x00\x00\x00\x00\x00\x20", 12,"AAAAAAAAACA=" }, { L_, 0, 8,"\x00\x00\x00\x00\x00\x00\x00\x40", 12,"AAAAAAAAAEA=" }, { L_, 0, 8,"\x00\x00\x00\x00\x00\x00\x00\x80", 12,"AAAAAAAAAIA=" }, { L_, 0, 9,"\x00\x00\x00\x00\x00\x00\x00\x00\x00", 12,"AAAAAAAAAAAA" }, { L_, 0, 9,"\x00\x00\x00\x00\x00\x00\x00\x00\x01", 12,"AAAAAAAAAAAB" }, { L_, 0, 9,"\x00\x00\x00\x00\x00\x00\x00\x00\x02", 12,"AAAAAAAAAAAC" }, { L_, 0, 9,"\x00\x00\x00\x00\x00\x00\x00\x00\x04", 12,"AAAAAAAAAAAE" }, { L_, 0, 9,"\x00\x00\x00\x00\x00\x00\x00\x00\x08", 12,"AAAAAAAAAAAI" }, { L_, 0, 9,"\x00\x00\x00\x00\x00\x00\x00\x00\x10", 12,"AAAAAAAAAAAQ" }, { L_, 0, 9,"\x00\x00\x00\x00\x00\x00\x00\x00\x20", 12,"AAAAAAAAAAAg" }, { L_, 0, 9,"\x00\x00\x00\x00\x00\x00\x00\x00\x40", 12,"AAAAAAAAAABA" }, { L_, 0, 9,"\x00\x00\x00\x00\x00\x00\x00\x00\x80", 12,"AAAAAAAAAACA" }, { L_, 0,10,"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 16,"AAAAAAAAAAAAAA=="}, { L_, 0,10,"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01", 16,"AAAAAAAAAAAAAQ=="}, { L_, 0,10,"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02", 16,"AAAAAAAAAAAAAg=="}, { L_, 0,10,"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04", 16,"AAAAAAAAAAAABA=="}, { L_, 0,10,"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08", 16,"AAAAAAAAAAAACA=="}, { L_, 0,10,"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10", 16,"AAAAAAAAAAAAEA=="}, { L_, 0,10,"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20", 16,"AAAAAAAAAAAAIA=="}, { L_, 0,10,"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40", 16,"AAAAAAAAAAAAQA=="}, { L_, 0,10,"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80", 16,"AAAAAAAAAAAAgA=="}, // *** DEPTH-ORDERED ENUMERATION: Depth = inputLength + maxLineLength *** // v----------INPUT-----------v v-----------------OUTPUT---------------v //lin LL #i input data #o output data //--- -- -- ---------------------- -- ------------------------------------- { L_, 0, 0,"", 0,"" }, { L_, 1, 0,"", 0,"" }, { L_, 0, 1,"\0", 4,"AA==" }, { L_, 2, 0,"", 0,"" }, { L_, 1, 1,"\0", 10,"A\r\nA\r\n=\r\n=" }, { L_, 0, 2,"\0\0", 4,"AAA=" }, { L_, 3, 0,"", 0,"" }, { L_, 2, 1,"\0", 6,"AA\r\n==" }, { L_, 1, 2,"\0\0", 10,"A\r\nA\r\nA\r\n=" }, { L_, 0, 3,"\0\0\0", 4,"AAAA" }, { L_, 4, 0,"", 0,"" }, { L_, 3, 1,"\0", 6,"AA=\r\n=" }, { L_, 2, 2,"\0\0", 6,"AA\r\nA=" }, { L_, 1, 3,"\0\0\0", 10,"A\r\nA\r\nA\r\nA" }, { L_, 0, 4,"\0\0\0\0", 8,"AAAAAA==" }, { L_, 5, 0,"", 0,"" }, { L_, 4, 1,"\0", 4,"AA==" }, { L_, 3, 2,"\0\0", 6,"AAA\r\n=" }, { L_, 2, 3,"\0\0\0", 6,"AA\r\nAA" }, { L_, 1, 4,"\0\0\0\0", 22,"A\r\nA\r\nA\r\nA\r\nA\r\nA\r\n=\r\n="}, { L_, 0, 5,"\0\0\0\0\0", 8,"AAAAAAA=" }, { L_, 6, 0,"", 0,"" }, { L_, 5, 1,"\0", 4,"AA==" }, { L_, 4, 2,"\0\0", 4,"AAA=" }, { L_, 3, 3,"\0\0\0", 6,"AAA\r\nA" }, { L_, 2, 4,"\0\0\0\0", 14,"AA\r\nAA\r\nAA\r\n==" }, { L_, 1, 5,"\0\0\0\0\0", 22,"A\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\n="}, { L_, 0, 6,"\0\0\0\0\0\0", 8,"AAAAAAAA" }, { L_, 7, 0,"", 0,"" }, { L_, 6, 1,"\0", 4,"AA==" }, { L_, 5, 2,"\0\0", 4,"AAA=" }, { L_, 4, 3,"\0\0\0", 4,"AAAA" }, { L_, 3, 4,"\0\0\0\0", 12,"AAA\r\nAAA\r\n==" }, { L_, 2, 5,"\0\0\0\0\0", 14,"AA\r\nAA\r\nAA\r\nA=" }, { L_, 1, 6,"\0\0\0\0\0\0", 22,"A\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA"}, { L_, 0, 7,"\0\0\0\0\0\0\0", 12,"AAAAAAAAAA==" }, { L_, 8, 0,"", 0,"" }, { L_, 7, 1,"\0", 4,"AA==" }, { L_, 6, 2,"\0\0", 4,"AAA=" }, { L_, 5, 3,"\0\0\0", 4,"AAAA" }, { L_, 4, 4,"\0\0\0\0", 10,"AAAA\r\nAA==" }, { L_, 3, 5,"\0\0\0\0\0", 12,"AAA\r\nAAA\r\nA=" }, { L_, 2, 6,"\0\0\0\0\0\0", 14,"AA\r\nAA\r\nAA\r\nAA" }, { L_, 1, 7,"\0\0\0\0\0\0\0", 34,"A\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA" "\r\nA\r\nA\r\n=\r\n=" }, { L_, 0, 8,"\0\0\0\0\0\0\0\0", 12,"AAAAAAAAAAA=" }, { L_, 9, 0,"", 0,"" }, { L_, 8, 1,"\0", 4,"AA==" }, { L_, 7, 2,"\0\0", 4,"AAA=" }, { L_, 6, 3,"\0\0\0", 4,"AAAA" }, { L_, 5, 4,"\0\0\0\0", 10,"AAAAA\r\nA==" }, { L_, 4, 5,"\0\0\0\0\0", 10,"AAAA\r\nAAA=" }, { L_, 3, 6,"\0\0\0\0\0\0", 12,"AAA\r\nAAA\r\nAA" }, { L_, 2, 7,"\0\0\0\0\0\0\0", 22,"AA\r\nAA\r\nAA\r\nAA\r\nAA\r\n==" }, { L_, 1, 8,"\0\0\0\0\0\0\0\0", 34,"A\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA" "\r\nA\r\nA\r\nA\r\n=" }, { L_, 0, 9,"\0\0\0\0\0\0\0\0\0", 12,"AAAAAAAAAAAA" }, { L_, 10, 0,"", 0,"" }, { L_, 9, 1,"\0", 4,"AA==" }, { L_, 8, 2,"\0\0", 4,"AAA=" }, { L_, 7, 3,"\0\0\0", 4,"AAAA" }, { L_, 6, 4,"\0\0\0\0", 10,"AAAAAA\r\n==" }, { L_, 5, 5,"\0\0\0\0\0", 10,"AAAAA\r\nAA=" }, { L_, 4, 6,"\0\0\0\0\0\0", 10,"AAAA\r\nAAAA" }, { L_, 3, 7,"\0\0\0\0\0\0\0", 18,"AAA\r\nAAA\r\nAAA\r\nA==" }, { L_, 2, 8,"\0\0\0\0\0\0\0\0", 22,"AA\r\nAA\r\nAA\r\nAA\r\nAA\r\nA=" }, { L_, 1, 9,"\0\0\0\0\0\0\0\0\0", 34,"A\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA\r\nA" "\r\nA\r\nA\r\nA\r\nA" }, { L_, 0,10,"\0\0\0\0\0\0\0\0\0\0", 16,"AAAAAAAAAAAAAA==" }, //--------------v }; const int NUM_DATA = sizeof DATA / sizeof *DATA; int depth = -1; // MAIN TEST-TABLE LOOP for (int ti = 0; ti < NUM_DATA; ++ti) { const int LINE = DATA[ti].d_lineNum; const int MAX_LEN = DATA[ti].d_maxLineLength; const int IN_LEN = DATA[ti].d_inputLength; const char *const INPUT = DATA[ti].d_input_p; const int OUT_LEN = DATA[ti].d_outputLength; const char *const OUTPUT = DATA[ti].d_output_p; const char *const B = INPUT; const char *const E = INPUT + IN_LEN; const int OUTPUT_BUFFER_SIZE = 100; // overrun will be detected const int TRAILING_OUTPUT_WINDOW = 30; // detect extra output Obj obj(MAX_LEN); const int newDepth = IN_LEN + MAX_LEN; // The following partitions the table in verbose mode. if (newDepth < depth) { // table entires "Part Two" if (verbose) cout << "\nVerifying Maximum Line Length." << endl; } if (newDepth != depth) { if (verbose) cout << "\tDepth = " << newDepth << endl; depth = newDepth; } if (veryVerbose) { T_ T_ P_(ti) P_(LINE) printCharN(cout, INPUT, IN_LEN) << endl; } // The first thing to do is to check expected output length. const int CALC_LEN = Obj::encodedLength(IN_LEN, MAX_LEN); LOOP3_ASSERT(LINE, OUT_LEN, CALC_LEN, OUT_LEN == CALC_LEN); // Define the output buffer and initialize it. char outputBuffer[OUTPUT_BUFFER_SIZE]; memset(outputBuffer, '?', sizeof outputBuffer); char *b = outputBuffer; int nOut = -1; int nIn = -1; LOOP_ASSERT(LINE, 0 == obj.convert(b, &nOut, &nIn, B, E)); LOOP_ASSERT(LINE, IN_LEN == nIn); // Prepare to call 'endConvert'. int totalOut = nOut; b += nOut; LOOP_ASSERT(LINE, 0 == obj.endConvert(b, &nOut)); totalOut += nOut; LOOP3_ASSERT(LINE, OUT_LEN, totalOut, OUT_LEN == totalOut); // Capture and verify internal output length. const int internalLen = obj.outputLength(); LOOP2_ASSERT(LINE, internalLen, OUT_LEN == internalLen); // Confirm final state is e_DONE_STATE. LOOP_ASSERT(LINE, isState(&obj, e_DONE_STATE)); if (veryVeryVerbose) { cout << "\t\t\tExpected output: "; printCharN(cout, OUTPUT, OUT_LEN) << endl; cout << "\t\t\t Actual output: "; printCharN(cout, outputBuffer, totalOut) << endl; } LOOP_ASSERT(LINE, 0 == memcmp(OUTPUT, outputBuffer, OUT_LEN)); // Verify nothing written past end of actual output. { int start = totalOut; int extra = TRAILING_OUTPUT_WINDOW; int end = myMin(start + extra, int(sizeof outputBuffer)); int last = start; for (int i = last; i < end; ++i) { if ('?' != outputBuffer[i]) { last = i; } } if (last != start) { cout << "\t\t\t Extended View: "; printCharN(cout, outputBuffer, last + 1) << endl; } LOOP3_ASSERT(LINE, start, last, start == last) } // Detect output buffer overflow. LOOP_ASSERT(LINE, '?' == outputBuffer[sizeof outputBuffer - 2]) LOOP_ASSERT(LINE, '?' == outputBuffer[sizeof outputBuffer - 1]) // ORTHOGONAL PERTURBATION: // For each index in [0, IN_LEN], partition the input into two // sequences, apply these sequences, in turn, to a newly // created instance, and verify that the result is identical to // that of the original (unpartitioned) sequence. for (int index = 0; index <= IN_LEN; ++index) { if (veryVeryVerbose) { T_ T_ T_ T_ P(index) } Obj localObj(MAX_LEN); const char *const M = B + index; char localBuf[sizeof outputBuffer]; memset(localBuf, '$', sizeof localBuf); char *lb = localBuf; int localNumIn; int localNumOut; if (veryVeryVeryVerbose) { cout << "\t\t\t\t\t" << "Input 1: "; printCharN(cout, B, static_cast<int>(M - B)) << endl; } int res1 = localObj.convert(lb, &localNumOut, &localNumIn, B, M); LOOP2_ASSERT(LINE, index, 0 == res1); // Prepare for second call to 'convert'. int localTotalIn = localNumIn; int localTotalOut = localNumOut; lb += localNumOut; if (veryVeryVeryVerbose) { cout << "\t\t\t\t\t" << "Input 2: "; printCharN(cout, M, static_cast<int>(E - M)) << endl; } int res2 = localObj.convert(lb, &localNumOut, &localNumIn, M, E); LOOP2_ASSERT(LINE, index, 0 == res2); // Prepare to call 'endConvert'. localTotalIn += localNumIn; localTotalOut += localNumOut; lb += localNumOut; int res3 = localObj.endConvert(lb, &localNumOut); LOOP2_ASSERT(LINE, index, 0 == res3); localTotalOut += localNumOut; // Compare internal output lengths. const int localLen = localObj.outputLength(); // -----^ LOOP3_ASSERT(LINE, internalLen, localLen, internalLen == localLen); // -----v // Confirm final state is e_DONE_STATE. LOOP2_ASSERT(LINE, index, isState(&localObj, e_DONE_STATE)); // Verify total amount of input consumed is the same. // -----^ LOOP4_ASSERT(LINE, index, nIn, localTotalIn, nIn == localTotalIn); // -----v int cmpStatus = memcmp(outputBuffer, localBuf, totalOut); if (cmpStatus || localTotalOut != totalOut || veryVeryVeryVerbose) { cout << "\t\t\t\t\tExpected output: "; printCharN(cout, outputBuffer, totalOut) << endl; cout << "\t\t\t\t\t Actual output: "; printCharN(cout, localBuf, localTotalOut) << endl; } // -----------------^ LOOP4_ASSERT(LINE, index, totalOut, localTotalOut, totalOut == localTotalOut); // -----------------v LOOP2_ASSERT(LINE, index, 0 == cmpStatus); // Verify nothing written past end of actual output. { int start = localTotalOut; int extra = TRAILING_OUTPUT_WINDOW; int end = myMin(start + extra, int(sizeof localBuf)); int last = start; for (int i = last; i < end; ++i) { if ('$' != localBuf[i]) { last = i; } } if (last != start) { cout << "\t\t\t\t\t Extended view: "; printCharN(cout, localBuf, last + 1) << endl; } LOOP3_ASSERT(LINE, start, last, start == last) } // Detect local buffer overflow. const int SIZE = sizeof outputBuffer; LOOP2_ASSERT(LINE, index, '$' == localBuf[SIZE - 2]); LOOP2_ASSERT(LINE, index, '$' == localBuf[SIZE - 1]); } } // end for ti } // end block } break; case 6: { // -------------------------------------------------------------------- // VERIFY INTERNAL TABLES. // Ensure that each internal table has the appropriate entries. // // Concerns: // - That there is a typo in some internal table. // // Plan: // Using a pseudo-piecewise-continuous implementation technique // i.e., Loop-Based), provide an area test that will sample each of // the table entires. The goal is that if any table entry is bad, // the test will fail. // // Tactics: // - Area Data Selection Method // - Loop-Based Implementation Technique // // Testing: // That each internal table has no defective entires. // -------------------------------------------------------------------- if (verbose) cout << endl << "VERIFY INTERNAL TABLES" << endl << "======================" << endl; if (verbose) cout << "\nVerify Encoding Table (64 entires)." << endl; { char input; const char *const B = &input, *const E = B + 1; char b[4]; int nOut; int nIn; int end = 0; if (verbose) cout << "\tVerify Entries [0-25]." << endl; { int start = end; end = start + 26; for (int i = start; i < end; ++i) { if (veryVerbose) { T_ T_ P(i) } Obj obj(0); input = char(4 * i); LOOP_ASSERT(i, 0 == obj.convert(b, &nOut, &nIn, B, E)); LOOP_ASSERT(i, 1 == nOut); LOOP_ASSERT(i, 1 == nIn); LOOP_ASSERT(i, 0 == obj.endConvert(b + nOut, &nOut)); LOOP_ASSERT(i, 3 == nOut); LOOP_ASSERT(i, 'A' + i - start == b[0]); LOOP_ASSERT(i, 'A' == b[1]); LOOP_ASSERT(i, '=' == b[2]); LOOP_ASSERT(i, '=' == b[3]); } } if (verbose) cout << "\tVerify Entries [26-51]." << endl; { int start = end; end = start + 26; for (int i = start; i < end; ++i) { if (veryVerbose) { T_ T_ P(i) } Obj obj(0); input = char(4 * i); LOOP_ASSERT(i, 0 == obj.convert(b, &nOut, &nIn, B, E)); LOOP_ASSERT(i, 1 == nOut); LOOP_ASSERT(i, 1 == nIn); LOOP_ASSERT(i, 0 == obj.endConvert(b + nOut, &nOut)); LOOP_ASSERT(i, 3 == nOut); LOOP_ASSERT(i, 'a' + i - start == b[0]); LOOP_ASSERT(i, 'A' == b[1]); LOOP_ASSERT(i, '=' == b[2]); LOOP_ASSERT(i, '=' == b[3]); } } if (verbose) cout << "\tVerify Entries [52-61]." << endl; { int start = end; end = start + 10; for (int i = start; i < end; ++i) { if (veryVerbose) { T_ T_ P(i) } Obj obj(0); input = char(4 * i); LOOP_ASSERT(i, 0 == obj.convert(b, &nOut, &nIn, B, E)); LOOP_ASSERT(i, 1 == nOut); LOOP_ASSERT(i, 1 == nIn); LOOP_ASSERT(i, 0 == obj.endConvert(b + nOut, &nOut)); LOOP_ASSERT(i, 3 == nOut); LOOP_ASSERT(i, '0' + i - start == b[0]); LOOP_ASSERT(i, 'A' == b[1]); LOOP_ASSERT(i, '=' == b[2]); LOOP_ASSERT(i, '=' == b[3]); } } if (verbose) cout << "\tVerify Entry [62]." << endl; { int start = end; end = start + 1; for (int i = start; i < end; ++i) { if (veryVerbose) { T_ T_ P(i) } Obj obj(0); input = char(4 * i); LOOP_ASSERT(i, 0 == obj.convert(b, &nOut, &nIn, B, E)); LOOP_ASSERT(i, 1 == nOut); LOOP_ASSERT(i, 1 == nIn); LOOP_ASSERT(i, 0 == obj.endConvert(b + nOut, &nOut)); LOOP_ASSERT(i, 3 == nOut); LOOP_ASSERT(i, '+' + i - start == b[0]); LOOP_ASSERT(i, 'A' == b[1]); LOOP_ASSERT(i, '=' == b[2]); LOOP_ASSERT(i, '=' == b[3]); } } if (verbose) cout << "\tVerify Entry [63]." << endl; { int start = end; end = start + 1; for (int i = start; i < end; ++i) { Obj obj(0); input = char(4 * i); LOOP_ASSERT(i, 0 == obj.convert(b, &nOut, &nIn, B, E)); LOOP_ASSERT(i, 1 == nOut); LOOP_ASSERT(i, 1 == nIn); LOOP_ASSERT(i, 0 == obj.endConvert(b + nOut, &nOut)); LOOP_ASSERT(i, 3 == nOut); LOOP_ASSERT(i, '/' + i - start == b[0]); LOOP_ASSERT(i, 'A' == b[1]); LOOP_ASSERT(i, '=' == b[2]); LOOP_ASSERT(i, '=' == b[3]); } } ASSERT(64 == end); // make sure all entires are accounted for. } } break; case 5: { // -------------------------------------------------------------------- // BOOTSTRAP: 'convert' - transitions // Verify 'convert' transitions for all states. // // Concerns: // - That we reach the correct final state after calling 'convert'. // - That convert with empty input does not change state. // - That convert with multiple inputs is identical to multiple // calls with the same input. // - That the return code is successful unless we wind up in the // error state. // - That all input characters are consumed. // // Plan: // For inputs counts of increasing value starting with 0, put the // object in each of the possible states, supply an input of the // current length and, after calling 'convert', verify that the // return code and state are as expected, and that all of the input // was consumed. // // Tactics: // - Depth-Ordered Enumeration Data Selection Method // - Table-Based Implementation Technique // // Testing: // BOOTSTRAP: 'convert' - transitions // -------------------------------------------------------------------- if (verbose) cout << endl << "BOOTSTRAP: 'convert' - transitions" << endl << "===================================" << endl; if (verbose) cout << "\nVerify 'convert' - transitions." << endl; { static const struct { int d_lineNum; // source line number int d_startState; // indicated starting state int d_numInputs; // number of input characters int d_endState; // expected ending state } DATA[] = {//-------input-------v v--output--v //lin Starting State #inputs Ending State //--- -------------- ------- ------------ { L_, e_INITIAL_STATE, 0, e_INITIAL_STATE }, { L_, e_STATE_ONE, 0, e_STATE_ONE }, { L_, e_STATE_TWO, 0, e_STATE_TWO }, { L_, e_STATE_THREE, 0, e_STATE_THREE }, { L_, e_DONE_STATE, 0, e_ERROR_STATE }, { L_, e_ERROR_STATE, 0, e_ERROR_STATE }, { L_, e_INITIAL_STATE, 1, e_STATE_ONE }, { L_, e_STATE_ONE, 1, e_STATE_TWO }, { L_, e_STATE_TWO, 1, e_STATE_THREE }, { L_, e_STATE_THREE, 1, e_STATE_ONE }, { L_, e_DONE_STATE, 1, e_ERROR_STATE }, { L_, e_ERROR_STATE, 1, e_ERROR_STATE }, { L_, e_INITIAL_STATE, 2, e_STATE_TWO }, { L_, e_STATE_ONE, 2, e_STATE_THREE }, { L_, e_STATE_TWO, 2, e_STATE_ONE }, { L_, e_STATE_THREE, 2, e_STATE_TWO }, { L_, e_DONE_STATE, 2, e_ERROR_STATE }, { L_, e_ERROR_STATE, 2, e_ERROR_STATE }, { L_, e_INITIAL_STATE, 3, e_STATE_THREE }, { L_, e_STATE_ONE, 3, e_STATE_ONE }, { L_, e_STATE_TWO, 3, e_STATE_TWO }, { L_, e_STATE_THREE, 3, e_STATE_THREE }, { L_, e_DONE_STATE, 3, e_ERROR_STATE }, { L_, e_ERROR_STATE, 3, e_ERROR_STATE }, { L_, e_INITIAL_STATE, 4, e_STATE_ONE }, { L_, e_STATE_ONE, 4, e_STATE_TWO }, { L_, e_STATE_TWO, 4, e_STATE_THREE }, { L_, e_STATE_THREE, 4, e_STATE_ONE }, { L_, e_DONE_STATE, 4, e_ERROR_STATE }, { L_, e_ERROR_STATE, 4, e_ERROR_STATE }, { L_, e_INITIAL_STATE, 5, e_STATE_TWO }, { L_, e_STATE_ONE, 5, e_STATE_THREE }, { L_, e_STATE_TWO, 5, e_STATE_ONE }, { L_, e_STATE_THREE, 5, e_STATE_TWO }, { L_, e_DONE_STATE, 5, e_ERROR_STATE }, { L_, e_ERROR_STATE, 5, e_ERROR_STATE }, { L_, e_INITIAL_STATE, 6, e_STATE_THREE }, { L_, e_STATE_ONE, 6, e_STATE_ONE }, { L_, e_STATE_TWO, 6, e_STATE_TWO }, { L_, e_STATE_THREE, 6, e_STATE_THREE }, { L_, e_DONE_STATE, 6, e_ERROR_STATE }, { L_, e_ERROR_STATE, 6, e_ERROR_STATE }, }; const int NUM_DATA = sizeof DATA / sizeof *DATA; const int OUTPUT_SIZE = 16; const char INPUT[] = "ABCDEF"; char b[OUTPUT_SIZE]; int nOut; int nIn; const char *const B = INPUT; int lastNumInputs = -1; // MAIN TEST-TABLE LOOP for (int ti = 0; ti < NUM_DATA; ++ti) { const int LINE = DATA[ti].d_lineNum; const int START = DATA[ti].d_startState; const int COUNT = DATA[ti].d_numInputs; const int END = DATA[ti].d_endState; const int RTN = -(e_ERROR_STATE == END); const char *const E = B + COUNT; Obj obj(0); if (COUNT != lastNumInputs) { if (verbose) cout << '\t' << COUNT << " input character" << (1 == COUNT ? "." : "s.") << endl; lastNumInputs = COUNT; } setState(&obj, START); if (veryVerbose) cout << "\t\t" << STATE_NAMES[START] << endl; if (veryVeryVerbose) { cout << "\t\t\tExpected end state: " << STATE_NAMES[END] << endl << "\t\t\tExpected return status: " << RTN << endl; } LOOP_ASSERT(LINE, RTN == obj.convert(b, &nOut, &nIn, B, E)); LOOP2_ASSERT(LINE, nOut, OUTPUT_SIZE > nOut); LOOP_ASSERT(LINE, isState(&obj, END)); // Verify amount of input consumed: all or none. const bool VALID = START != e_DONE_STATE && START != e_ERROR_STATE; const int EXP_NUM_IN = VALID ? COUNT : 0; LOOP2_ASSERT(LINE, nIn, EXP_NUM_IN == nIn); } // end for ti } // end block } break; case 4: { // -------------------------------------------------------------------- // BOOTSTRAP: 'endConvert' - transitions // Verify 'endConvert' transitions for all states. // // Concerns: // - Reaching the correct final state after calling 'endConvert'. // // Plan: // Put the object in each state and verify the expected state is // correct after the call to 'endConvert'. // // Tactics: // - Area Data Selection Method // - Table-Based Implementation Technique // // Testing: // BOOTSTRAP: 'endConvert' - transitions // -------------------------------------------------------------------- if (verbose) cout << endl << "BOOTSTRAP: 'endConvert' - transitions" << endl << "===================================" << endl; if (verbose) cout << "\nVerify 'endConvert' - transitions." << endl; { static const struct { int d_lineNum; // source line number int d_startState; // indicated starting state int d_endState; // expected ending state } DATA[] = {//-input----v v--output--v //lin Starting State Ending State //--- -------------- ------------ { L_, e_INITIAL_STATE, e_DONE_STATE }, { L_, e_STATE_ONE, e_DONE_STATE }, { L_, e_STATE_TWO, e_DONE_STATE }, { L_, e_STATE_THREE, e_DONE_STATE }, { L_, e_DONE_STATE, e_ERROR_STATE }, { L_, e_ERROR_STATE, e_ERROR_STATE }, }; const int NUM_DATA = sizeof DATA / sizeof *DATA; char b[4]; int numOut; // MAIN TEST-TABLE LOOP for (int ti = 0; ti < NUM_DATA; ++ti) { const int LINE = DATA[ti].d_lineNum; const int START = DATA[ti].d_startState; const int END = DATA[ti].d_endState; const int RTN = -(e_ERROR_STATE == END); Obj obj(0); if (verbose) cout << '\t' << STATE_NAMES[START] << '.' << endl; if (veryVerbose) cout << "\t\tExpected next state: " << STATE_NAMES[END] << endl; setState(&obj, START); if (veryVerbose) cout << "\t\tExpected return status: " << RTN << endl; LOOP_ASSERT(LINE, RTN == obj.endConvert(b, &numOut)); LOOP_ASSERT(LINE, isState(&obj, END)); } // end for ti } // end block } break; case 3: { // -------------------------------------------------------------------- // SET-STATE, IS-STATE, AND BASIC ACCESSORS. // Ensure that we can bring an object to any attainable state. // // Concerns: // - That we can reach all internal states. // - That we can confirm any anticipated state. // - That each direct accessor is implemented properly. // // Plan: // First make sure that when we are in the initial (i.e., newly // constructed) state, 'isInitialState()' returns 'true' (so that // the assertion that 'isInitialState()' does not fail before we have // had an opportunity to test it explicitly). // // Second, using the Brute-Force approach, reach each of the major // states from a newly constructed object as simply as possible // (i.e., by processing one character at a time) via the '::setState' // test helper function. Then use of all of the (as yet untested) // processing accessors to help verify the new state. Additionally, // call one or more manipulators to change the state (thereby // creating a partial *Distinguishing* *Sequence*) in order to // further verify that the targeted state was reached. // // Third, prove that the '::isState' helper function (implemented // using the above strategy) correctly confirms the indicated state // by showing that, for each state, only the corresponding state // setting returns true. // // We can now declare the basic accessors to have been tested, // mindful that the state values they return are calculated by the // the primary manipulators which have not yet been fully tested. // // Tactics: // - Ad-Hoc and Area Data Selection Methods // - Brute-Force and Loop-Based Implementation Techniques // // Testing: // That we can reach each of the major processing states. // void ::setState(Obj *obj, int state); // bool ::istState(Obj *obj, int state); // // bool isAcceptable() const; // bool isDone() const; // bool isError() const; // bool isInitialState() const; // int outputLength() const; // // ~bdlde::Base64Encoder(); // -------------------------------------------------------------------- if (verbose) cout << endl << "SET-STATE, IS-STATE, RESET-STATE, AND BASIC ACCESSORS" << endl << "=====================================================" << endl; if (verbose) cout << "\nMake sure we can detect the initial state." << endl; { if (verbose) cout << "\te_INITIAL_STATE." << endl; Obj obj(9); ASSERT(9 == obj.maxLineLength()); ASSERT(1 == obj.isAcceptable()); ASSERT(0 == obj.isDone()); ASSERT(0 == obj.isError()); ASSERT(1 == obj.isInitialState()); ASSERT(0 == obj.outputLength()); } if (verbose) cout << "\nVerify ::setState." << endl; { if (verbose) cout << "\te_INITIAL_STATE." << endl; { Obj obj(9); setState(&obj, e_INITIAL_STATE); ASSERT(9 == obj.maxLineLength()); ASSERT(1 == obj.isAcceptable()); ASSERT(0 == obj.isDone()); ASSERT(0 == obj.isError()); ASSERT(1 == obj.isInitialState()); ASSERT(0 == obj.outputLength()); char b[4] = { -1, -1, -1, -1 }; int numOut = -1; int result = obj.endConvert(b, &numOut); // e_DONE_STATE ASSERT(9 == obj.maxLineLength()); ASSERT(1 == obj.isAcceptable()); ASSERT(1 == obj.isDone()); ASSERT(0 == obj.isError()); ASSERT(0 == obj.isInitialState()); ASSERT(0 == obj.outputLength()); ASSERT(0 == result); ASSERT(0 == numOut); ASSERT((char)-1 == b[0]); ASSERT((char)-1 == b[1]); ASSERT((char)-1 == b[2]); ASSERT((char)-1 == b[3]); } if (verbose) cout << "\tState 1." << endl; { Obj obj(9); setState(&obj, e_STATE_ONE); ASSERT(9 == obj.maxLineLength()); ASSERT(1 == obj.isAcceptable()); ASSERT(0 == obj.isDone()); ASSERT(0 == obj.isError()); ASSERT(0 == obj.isInitialState()); ASSERT(1 == obj.outputLength()); char b[4] = { -1, -1, -1, -1 }; int numOut = -1; int result = obj.endConvert(b + 1, &numOut); // e_DONE_STATE ASSERT(9 == obj.maxLineLength()); ASSERT(9 == obj.maxLineLength()); ASSERT(1 == obj.isAcceptable()); ASSERT(1 == obj.isDone()); ASSERT(0 == obj.isError()); ASSERT(0 == obj.isInitialState()); ASSERT(4 == obj.outputLength()); ASSERT(0 == result); ASSERT(3 == numOut); ASSERT((char)-1 == b[0]); ASSERT('A' == b[1]); ASSERT('=' == b[2]); ASSERT('=' == b[3]); } if (verbose) cout << "\tState 2." << endl; { Obj obj(9); setState(&obj, e_STATE_TWO); ASSERT(9 == obj.maxLineLength()); ASSERT(1 == obj.isAcceptable()); ASSERT(0 == obj.isDone()); ASSERT(0 == obj.isError()); ASSERT(0 == obj.isInitialState()); ASSERT(2 == obj.outputLength()); char b[4] = { -1, -1, -1, -1 }; int numOut = -1; int result = obj.endConvert(b + 2, &numOut); // e_DONE_STATE ASSERT(9 == obj.maxLineLength()); ASSERT(9 == obj.maxLineLength()); ASSERT(1 == obj.isAcceptable()); ASSERT(1 == obj.isDone()); ASSERT(0 == obj.isError()); ASSERT(0 == obj.isInitialState()); ASSERT(4 == obj.outputLength()); ASSERT(0 == result); ASSERT(2 == numOut); ASSERT((char)-1 == b[0]); ASSERT((char)-1 == b[1]); ASSERT('A' == b[2]); ASSERT('=' == b[3]); } if (verbose) cout << "\tState 3." << endl; { Obj obj(9); setState(&obj, e_STATE_THREE); ASSERT(9 == obj.maxLineLength()); ASSERT(1 == obj.isAcceptable()); ASSERT(0 == obj.isDone()); ASSERT(0 == obj.isError()); ASSERT(0 == obj.isInitialState()); ASSERT(4 == obj.outputLength()); char b[4] = { -1, -1, -1, -1 }; int numOut = -1; int result = obj.endConvert(b, &numOut); // e_DONE_STATE ASSERT(9 == obj.maxLineLength()); ASSERT(9 == obj.maxLineLength()); ASSERT(1 == obj.isAcceptable()); ASSERT(1 == obj.isDone()); ASSERT(0 == obj.isError()); ASSERT(0 == obj.isInitialState()); ASSERT(4 == obj.outputLength()); ASSERT(0 == result); ASSERT(0 == numOut); ASSERT((char)-1 == b[0]); ASSERT((char)-1 == b[1]); ASSERT((char)-1 == b[2]); ASSERT((char)-1 == b[3]); } if (verbose) cout << "\te_DONE_STATE." << endl; { Obj obj(9); setState(&obj, e_DONE_STATE); ASSERT(9 == obj.maxLineLength()); ASSERT(1 == obj.isAcceptable()); ASSERT(1 == obj.isDone()); ASSERT(0 == obj.isError()); ASSERT(0 == obj.isInitialState()); ASSERT(0 == obj.outputLength()); char b[4] = { -1, -1, -1, -1 }; int numOut = -1; int result = obj.endConvert(b, &numOut); // e_ERROR_STATE ASSERT(9 == obj.maxLineLength()); ASSERT(0 == obj.isAcceptable()); ASSERT(0 == obj.isDone()); ASSERT(1 == obj.isError()); ASSERT(0 == obj.isInitialState()); ASSERT(0 == obj.outputLength()); ASSERT(-1 == result); ASSERT(0 == numOut); ASSERT((char)-1 == b[0]); ASSERT((char)-1 == b[1]); ASSERT((char)-1 == b[2]); ASSERT((char)-1 == b[3]); } if (verbose) cout << "\te_ERROR_STATE." << endl; { Obj obj(9); setState(&obj, e_ERROR_STATE); ASSERT(9 == obj.maxLineLength()); ASSERT(0 == obj.isAcceptable()); ASSERT(0 == obj.isDone()); ASSERT(1 == obj.isError()); ASSERT(0 == obj.isInitialState()); ASSERT(0 == obj.outputLength()); char b[4] = { -1, -1, -1, -1 }; int numOut = -1; int result = obj.endConvert(b, &numOut); // e_ERROR_STATE ASSERT(9 == obj.maxLineLength()); ASSERT(9 == obj.maxLineLength()); ASSERT(0 == obj.isAcceptable()); ASSERT(0 == obj.isDone()); ASSERT(1 == obj.isError()); ASSERT(0 == obj.isInitialState()); ASSERT(0 == obj.outputLength()); ASSERT(-1 == result); ASSERT(0 == numOut); ASSERT((char)-1 == b[0]); ASSERT((char)-1 == b[1]); ASSERT((char)-1 == b[2]); ASSERT((char)-1 == b[3]); } } if (verbose) cout << "\nVerify ::isState." << endl; { Obj obj(0); for (int i = 0; i < NUM_STATES; ++i) { if (verbose) cout << "\tsetState: " << STATE_NAMES[i] << '.' << endl; for (int j = 0; j < NUM_STATES; ++j) { if (veryVerbose) cout << "\t\tisState: " << STATE_NAMES[j] << '.' << endl; const bool SAME = i == j; if (veryVeryVerbose) { T_ T_ T_ P(SAME) } EnabledGuard Guard(SAME); // Enable individual '::isState' // ASSERTs in order to facilitate // debugging. Obj obj(0); setState(&obj, i); LOOP2_ASSERT(i, j, SAME == isState(&obj, j)); } } } } break; case 2: { // -------------------------------------------------------------------- // PRIMARY CONSTRUCTOR AND CONFIGURATION STATE ACCESSORS // Make sure we can bring the object to any attainable state. // // Concerns: // That we can fully configure the object from the constructor. // // Plan: // Create the object in several configurations and verify using // all of the (as yet untested) direct accessors. After this test // case, we can declare the accessors returning configuration state // to be thoroughly tested. // // Tactics: // - Boundary Data Selection Method // - Brute-Force Implementation Technique // // Testing: // bdlde::Base64Encoder(int maxLineLength); // int maxLineLength() const; // -------------------------------------------------------------------- if (verbose) cout << endl << "PRIMARY CONSTRUCTOR" << endl << "===================" << endl; if (verbose) cout << "\nTry a few different settings." << endl; if (verbose) cout << "\tmaxLineLength = 0" << endl; { Obj obj(0); ASSERT(1 == obj.isAcceptable()); ASSERT(0 == obj.isDone()); ASSERT(0 == obj.isError()); ASSERT(1 == obj.isInitialState()); ASSERT(0 == obj.maxLineLength()); ASSERT(0 == obj.outputLength()); } if (verbose) cout << "\tmaxLineLength = 1" << endl; { Obj obj(1); ASSERT(1 == obj.isAcceptable()); ASSERT(0 == obj.isDone()); ASSERT(0 == obj.isError()); ASSERT(1 == obj.isInitialState()); ASSERT(1 == obj.maxLineLength()); ASSERT(0 == obj.outputLength()); } if (verbose) cout << "\tmaxLineLength = 2" << endl; { Obj obj(2); ASSERT(1 == obj.isAcceptable()); ASSERT(0 == obj.isDone()); ASSERT(0 == obj.isError()); ASSERT(1 == obj.isInitialState()); ASSERT(2 == obj.maxLineLength()); ASSERT(0 == obj.outputLength()); } if (verbose) cout << "\tmaxLineLength = INT_MAX" << endl; { Obj obj(INT_MAX); ASSERT(1 == obj.isAcceptable()); ASSERT(0 == obj.isDone()); ASSERT(0 == obj.isError()); ASSERT(1 == obj.isInitialState()); ASSERT(INT_MAX == obj.maxLineLength()); ASSERT(0 == obj.outputLength()); } } break; case 1: { // -------------------------------------------------------------------- // BREATHING TEST // This case is available to be used as a developers' sandbox. // // Concerns: // None. // // Plan: // Ad hoc. // // Tactics: // - Ad Hoc Data Selection Method // - Brute-Force Implementation Technique // // Testing: // BREATHING TEST -- (developer's sandbox) // ::myMin(const T& a, const T& b); // ::printCharN(ostream& output, const char* sequence, int length) // -------------------------------------------------------------------- if (verbose) cout << endl << "BREATHING TEST" << endl << "==============" << endl; if (veryVerbose) { P_(int('+')); P((void*)'+'); P_(int('/')); P((void*)'/'); P_(int('=')); P((void*)'='); P((int)(signed char) '\xff'); P((int)(unsigned char) '\xff'); P((int)(char) '\xff'); } if (verbose) cout << "\nTry '::myMin' test helper function." << endl; { ASSERT('a'== myMin('a', 'b')); ASSERT(-5 == myMin(3, -5)); ASSERT(-3 == myMin(-3, 5)); } if (verbose) cout << "\nTry '::printCharN' test helper function." << endl; { bsl::ostringstream out; const char in[] = "a" "\x00" "b" "\x07" "c" "\x08" "d" "\x0F" "e" "\x10" "f" "\x80" "g" "\xFF"; printCharN(out, in, sizeof in) << ends; const char EXP[] = "a<00>b<07>c<08>d<0F>e<10>f<80>g<FF><00>"; if (veryVerbose) { cout << "\tRESULT = " << out.str().c_str() << endl; cout << "\tEXPECT = " << EXP << endl; } ASSERT(0 == strncmp(EXP, out.str().c_str(), sizeof EXP)); } if (verbose) cout << "\nTry instantiating an encoder." << endl; { Obj encoder; if (veryVerbose) { T_ P(encoder.isAcceptable()); T_ P(encoder.isDone()); T_ P(encoder.isError()); T_ P(encoder.isInitialState()); T_ P(encoder.maxLineLength()); T_ P(encoder.outputLength()); } if (verbose) cout << "\nEncode something." << endl; static char out[1000]; int outIdx = 0; int numIn = 0; int numOut = 0; // begin: 0 1 3 4 8 9 END // end : 1 3 4 8 9 10 INPUT const char*const input = "\0" "\0\0" "\0" "\0\0\0\0" "\0" "\0"; ASSERT(0 == numOut); ASSERT(0 == numIn); ASSERT(0 == outIdx); ASSERT(0 == out[0]); ASSERT(0 == out[1]); if (verbose) cout << "\tEncode: ^0." << endl; { const char *const begin = input + 0; const char *const end = input + 1; encoder.convert(out + outIdx, &numOut, &numIn, begin, end); outIdx += numOut; if (veryVerbose) { T_ T_ P_(numIn) P_(numOut) P_(outIdx) cout << "output: \""; printCharN(cout, out, outIdx) << '"' << endl; } } ASSERT(1 == numOut); ASSERT(1 == numIn); ASSERT(1 == outIdx); ASSERT('A' == out[0]); ASSERT(0 == out[1]); if (verbose) cout << "\tEncode: 0^00." << endl; { const char *const begin = input + 1; const char *const end = input + 3; encoder.convert(out + outIdx, &numOut, &numIn, begin, end); outIdx += numOut; if (veryVerbose) { T_ T_ P_(numIn) P_(numOut) P_(outIdx) cout << "output: \""; printCharN(cout, out, outIdx) << '"' << endl; } } ASSERT(3 == numOut); ASSERT(2 == numIn); ASSERT(4 == outIdx); ASSERT('A' == out[3]); ASSERT(0 == out[4]); if (verbose) cout << "\tEncode: 000^0." << endl; { const char *const begin = input + 3; const char *const end = input + 4; encoder.convert(out + outIdx, &numOut, &numIn, begin, end); outIdx += numOut; if (veryVerbose) { T_ T_ P_(numIn) P_(numOut) P_(outIdx) cout << "output: \""; printCharN(cout, out, outIdx) << '"' << endl; } } ASSERT(1 == numOut); ASSERT(1 == numIn); ASSERT(5 == outIdx); ASSERT('A' == out[3]); ASSERT('A' == out[4]); ASSERT(0 == out[5]); if (verbose) cout << "\tEncode: 0000^0000." << endl; { const char *const begin = input + 4; const char *const end = input + 8; encoder.convert(out + outIdx, &numOut, &numIn, begin, end); outIdx += numOut; if (veryVerbose) { T_ T_ P_(numIn) P_(numOut) P_(outIdx) cout << "output: \""; printCharN(cout, out, outIdx) << '"' << endl; } } ASSERT(5 == numOut); ASSERT(4 == numIn); ASSERT(10 == outIdx); ASSERT('A' == out[7]); ASSERT('A' == out[8]); ASSERT('A' == out[9]); ASSERT(0 == out[10]); if (verbose) cout << "\tEncode: 00000000^0." << endl; { const char *const begin = input + 8; const char *const end = input + 9; encoder.convert(out + outIdx, &numOut, &numIn, begin, end); outIdx += numOut; if (veryVerbose) { T_ T_ P_(numIn) P_(numOut) P_(outIdx) cout << "output: \""; printCharN(cout, out, outIdx) << '"' << endl; } } ASSERT(2 == numOut); ASSERT(1 == numIn); ASSERT(12 == outIdx); ASSERT('A' == out[11]); ASSERT(0 == out[12]); if (verbose) cout << "\tEncode: 000000000^0." << endl; { const char *const begin = input + 9; const char *const end = input + 10; encoder.convert(out + outIdx, &numOut, &numIn, begin, end); outIdx += numOut; if (veryVerbose) { T_ T_ P_(numIn) P_(numOut) P_(outIdx) cout << "output: \""; printCharN(cout, out, outIdx) << '"' << endl; } } ASSERT(1 == numOut); ASSERT(1 == numIn); ASSERT(13 == outIdx); ASSERT('A' == out[11]); ASSERT('A' == out[12]); ASSERT(0 == out[13]); if (verbose) cout << "\tEncode: 0000000000^$." << endl; { encoder.endConvert(out + outIdx, &numOut); outIdx += numOut; if (veryVerbose) { T_ T_ P_(numIn) P_(numOut) P_(outIdx) cout << "output: \""; printCharN(cout, out, outIdx) << '"' << endl; } } ASSERT(3 == numOut); ASSERT(16 == outIdx); ASSERT('A' == out[12]); ASSERT('A' == out[13]); ASSERT('=' == out[14]); ASSERT('=' == out[15]); ASSERT(0 == out[16]); } } break; default: { cerr << "WARNING: CASE `" << test << "' NOT FOUND." << endl; testStatus = -1; } } if (testStatus > 0) { cerr << "Error, non-zero test status = " << testStatus << "." << endl; } return testStatus; } // ---------------------------------------------------------------------------- // Copyright 2015 Bloomberg Finance L.P. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // ----------------------------- END-OF-FILE ----------------------------------
#include "../common/framework.hpp" #include "../../ThirdParty/AntTweakBar/include/AntTweakBar.h" int main( void ) { GLFWwindow* window = initWindow("Tutorial 17 - Rotations"); // Initialize the GUI TwInit(TW_OPENGL_CORE, NULL); TwWindowSize(1024, 768); TwBar * EulerGUI = TwNewBar("Euler settings"); TwBar * QuaternionGUI = TwNewBar("Quaternion settings"); TwSetParam(EulerGUI, NULL, "refresh", TW_PARAM_CSTRING, 1, "0.1"); TwSetParam(QuaternionGUI, NULL, "position", TW_PARAM_CSTRING, 1, "808 16"); TwAddVarRW(EulerGUI, "Euler X", TW_TYPE_FLOAT, &gOrientation1.x, "step=0.01"); TwAddVarRW(EulerGUI, "Euler Y", TW_TYPE_FLOAT, &gOrientation1.y, "step=0.01"); TwAddVarRW(EulerGUI, "Euler Z", TW_TYPE_FLOAT, &gOrientation1.z, "step=0.01"); TwAddVarRW(EulerGUI, "Pos X" , TW_TYPE_FLOAT, &gPosition1.x, "step=0.1"); TwAddVarRW(EulerGUI, "Pos Y" , TW_TYPE_FLOAT, &gPosition1.y, "step=0.1"); TwAddVarRW(EulerGUI, "Pos Z" , TW_TYPE_FLOAT, &gPosition1.z, "step=0.1"); TwAddVarRW(QuaternionGUI, "Quaternion", TW_TYPE_QUAT4F, &gOrientation2, "showval=true open=true "); TwAddVarRW(QuaternionGUI, "Use LookAt", TW_TYPE_BOOL8 , &gLookAtOther, "help='Look at the other monkey ?'"); // Set GLFW event callbacks. I removed glfwSetWindowSizeCallback for conciseness glfwSetMouseButtonCallback(window, (GLFWmousebuttonfun)TwEventMouseButtonGLFW); // - Directly redirect GLFW mouse button events to AntTweakBar glfwSetCursorPosCallback(window, (GLFWcursorposfun)TwEventMousePosGLFW); // - Directly redirect GLFW mouse position events to AntTweakBar glfwSetScrollCallback(window, (GLFWscrollfun)TwEventMouseWheelGLFW); // - Directly redirect GLFW mouse wheel events to AntTweakBar glfwSetKeyCallback(window, (GLFWkeyfun)TwEventKeyGLFW); // - Directly redirect GLFW key events to AntTweakBar glfwSetCharCallback(window, (GLFWcharfun)TwEventCharGLFW); // - Directly redirect GLFW char events to AntTweakBar // Dark blue background glClearColor(0.0f, 0.0f, 0.4f, 0.0f); // Enable depth test glEnable(GL_DEPTH_TEST); // Accept fragment if it closer to the camera than the former one glDepthFunc(GL_LESS); // Cull triangles which normal is not towards the camera glEnable(GL_CULL_FACE); // Create and compile our GLSL program from the shaders GLuint programID = LoadShaders( "StandardShading.vertexshader", "StandardShading.fragmentshader" ); // Get a handle for our "MVP" uniform GLuint MatrixID = glGetUniformLocation(programID, "MVP"); GLuint ViewMatrixID = glGetUniformLocation(programID, "V"); GLuint ModelMatrixID = glGetUniformLocation(programID, "M"); // Get a handle for our buffers GLuint vertexPosition_modelspaceID = glGetAttribLocation(programID, "vertexPosition_modelspace"); GLuint vertexUVID = glGetAttribLocation(programID, "vertexUV"); GLuint vertexNormal_modelspaceID = glGetAttribLocation(programID, "vertexNormal_modelspace"); // Load the texture GLuint Texture = loadDDS("uvmap.DDS"); // Get a handle for our "myTextureSampler" uniform GLuint TextureID = glGetUniformLocation(programID, "myTextureSampler"); // Read our .obj file std::vector<glm::vec3> vertices; std::vector<glm::vec2> uvs; std::vector<glm::vec3> normals; bool res = loadOBJ("suzanne.obj", vertices, uvs, normals); std::vector<unsigned short> indices; std::vector<glm::vec3> indexed_vertices; std::vector<glm::vec2> indexed_uvs; std::vector<glm::vec3> indexed_normals; indexVBO(vertices, uvs, normals, indices, indexed_vertices, indexed_uvs, indexed_normals); // Load it into a VBO GLuint vertexbuffer; glGenBuffers(1, &vertexbuffer); glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer); glBufferData(GL_ARRAY_BUFFER, indexed_vertices.size() * sizeof(glm::vec3), &indexed_vertices[0], GL_STATIC_DRAW); GLuint uvbuffer; glGenBuffers(1, &uvbuffer); glBindBuffer(GL_ARRAY_BUFFER, uvbuffer); glBufferData(GL_ARRAY_BUFFER, indexed_uvs.size() * sizeof(glm::vec2), &indexed_uvs[0], GL_STATIC_DRAW); GLuint normalbuffer; glGenBuffers(1, &normalbuffer); glBindBuffer(GL_ARRAY_BUFFER, normalbuffer); glBufferData(GL_ARRAY_BUFFER, indexed_normals.size() * sizeof(glm::vec3), &indexed_normals[0], GL_STATIC_DRAW); // Generate a buffer for the indices as well GLuint elementbuffer; glGenBuffers(1, &elementbuffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementbuffer); glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(unsigned short), &indices[0] , GL_STATIC_DRAW); // Get a handle for our "LightPosition" uniform glUseProgram(programID); GLuint LightID = glGetUniformLocation(programID, "LightPosition_worldspace"); // For speed computation double lastTime = glfwGetTime(); double lastFrameTime = lastTime; int nbFrames = 0; do{ // Measure speed double currentTime = glfwGetTime(); float deltaTime = (float)(currentTime - lastFrameTime); lastFrameTime = currentTime; nbFrames++; if ( currentTime - lastTime >= 1.0 ){ // If last prinf() was more than 1sec ago // printf and reset printf("%f ms/frame\n", 1000.0/double(nbFrames)); nbFrames = 0; lastTime += 1.0; } // Clear the screen glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Use our shader glUseProgram(programID); glm::mat4 ProjectionMatrix = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.0f); glm::mat4 ViewMatrix = glm::lookAt( glm::vec3( 0, 0, 7 ), // Camera is here glm::vec3( 0, 0, 0 ), // and looks here glm::vec3( 0, 1, 0 ) // Head is up (set to 0,-1,0 to look upside-down) ); // Bind our texture in Texture Unit 0 glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, Texture); // Set our "myTextureSampler" sampler to user Texture Unit 0 glUniform1i(TextureID, 0); // 1rst attribute buffer : vertices glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer); glVertexAttribPointer( vertexPosition_modelspaceID, // The attribute we want to configure 3, // size GL_FLOAT, // type GL_FALSE, // normalized? 0, // stride (void*)0 // array buffer offset ); // 2nd attribute buffer : UVs glEnableVertexAttribArray(1); glBindBuffer(GL_ARRAY_BUFFER, uvbuffer); glVertexAttribPointer( vertexUVID, // The attribute we want to configure 2, // size : U+V => 2 GL_FLOAT, // type GL_FALSE, // normalized? 0, // stride (void*)0 // array buffer offset ); // 3rd attribute buffer : normals glEnableVertexAttribArray(2); glBindBuffer(GL_ARRAY_BUFFER, normalbuffer); glVertexAttribPointer( vertexNormal_modelspaceID, // The attribute we want to configure 3, // size GL_FLOAT, // type GL_FALSE, // normalized? 0, // stride (void*)0 // array buffer offset ); // Index buffer glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementbuffer); glm::vec3 lightPos = glm::vec3(4,4,4); glUniform3f(LightID, lightPos.x, lightPos.y, lightPos.z); { // Euler // As an example, rotate arount the vertical axis at 180�/sec gOrientation1.y += 3.14159f/2.0f * deltaTime; // Build the model matrix glm::mat4 RotationMatrix = eulerAngleYXZ(gOrientation1.y, gOrientation1.x, gOrientation1.z); glm::mat4 TranslationMatrix = translate(mat4(), gPosition1); // A bit to the left glm::mat4 ScalingMatrix = scale(mat4(), vec3(1.0f, 1.0f, 1.0f)); glm::mat4 ModelMatrix = TranslationMatrix * RotationMatrix * ScalingMatrix; glm::mat4 MVP = ProjectionMatrix * ViewMatrix * ModelMatrix; // Send our transformation to the currently bound shader, // in the "MVP" uniform glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]); glUniformMatrix4fv(ModelMatrixID, 1, GL_FALSE, &ModelMatrix[0][0]); glUniformMatrix4fv(ViewMatrixID, 1, GL_FALSE, &ViewMatrix[0][0]); // Draw the triangles ! glDrawElements( GL_TRIANGLES, // mode indices.size(), // count GL_UNSIGNED_SHORT, // type (void*)0 // element array buffer offset ); } { // Quaternion // It the box is checked... if (gLookAtOther){ vec3 desiredDir = gPosition1-gPosition2; vec3 desiredUp = vec3(0.0f, 1.0f, 0.0f); // +Y // Compute the desired orientation quat targetOrientation = normalize(LookAt(desiredDir, desiredUp)); // And interpolate gOrientation2 = RotateTowards(gOrientation2, targetOrientation, 1.0f*deltaTime); } glm::mat4 RotationMatrix = mat4_cast(gOrientation2); glm::mat4 TranslationMatrix = translate(mat4(), gPosition2); // A bit to the right glm::mat4 ScalingMatrix = scale(mat4(), vec3(1.0f, 1.0f, 1.0f)); glm::mat4 ModelMatrix = TranslationMatrix * RotationMatrix * ScalingMatrix; glm::mat4 MVP = ProjectionMatrix * ViewMatrix * ModelMatrix; // Send our transformation to the currently bound shader, // in the "MVP" uniform glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]); glUniformMatrix4fv(ModelMatrixID, 1, GL_FALSE, &ModelMatrix[0][0]); glUniformMatrix4fv(ViewMatrixID, 1, GL_FALSE, &ViewMatrix[0][0]); // Draw the triangles ! glDrawElements( GL_TRIANGLES, // mode indices.size(), // count GL_UNSIGNED_SHORT, // type (void*)0 // element array buffer offset ); } glDisableVertexAttribArray(0); glDisableVertexAttribArray(1); glDisableVertexAttribArray(2); // Draw GUI TwDraw(); // Swap buffers glfwSwapBuffers(window); glfwPollEvents(); } // Check if the ESC key was pressed or the window was closed while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS && glfwWindowShouldClose(window) == 0 ); // Cleanup VBO and shader glDeleteBuffers(1, &vertexbuffer); glDeleteBuffers(1, &uvbuffer); glDeleteBuffers(1, &normalbuffer); glDeleteBuffers(1, &elementbuffer); glDeleteProgram(programID); glDeleteTextures(1, &TextureID); // Close GUI and OpenGL window, and terminate GLFW TwTerminate(); glfwTerminate(); return 0; }
/*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkBaseController.h" #include "mitkBaseRenderer.h" mitk::BaseController::BaseController() : m_LastUpdateTime(0) { m_Slice = Stepper::New(); m_Time = Stepper::New(); } mitk::BaseController::~BaseController() { } void mitk::BaseController::ExecuteOperation(mitk::Operation * /* *operation */) { } mitk::Stepper *mitk::BaseController::GetSlice() { return m_Slice.GetPointer(); } mitk::Stepper *mitk::BaseController::GetTime() { return m_Time.GetPointer(); }
// Copyright (C) 2019-2020 Zilliz. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software distributed under the License // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express // or implied. See the License for the specific language governing permissions and limitations under the License. #include "db/meta/backend/MySQLConnectionPool.h" #include <thread> #include <fiu/fiu-local.h> #include "utils/Log.h" namespace milvus::engine::meta { // Do a simple form of in-use connection limiting: wait to return // a connection until there are a reasonably low number in use // already. Can't do this in create() because we're interested in // connections actually in use, not those created. Also note that // we keep our own count; ConnectionPool::size() isn't the same! mysqlpp::Connection* MySQLConnectionPool::grab() { { std::unique_lock<std::mutex> lock(mutex_); full_.wait(lock, [this] { return conns_in_use_ < max_pool_size_; }); ++conns_in_use_; } full_.notify_one(); return mysqlpp::ConnectionPool::grab(); } mysqlpp::Connection* MySQLConnectionPool::safe_grab() { { std::unique_lock<std::mutex> lock(mutex_); full_.wait(lock, [this] { return conns_in_use_ < max_pool_size_; }); ++conns_in_use_; } full_.notify_one(); return mysqlpp::ConnectionPool::safe_grab(); } // Other half of in-use conn count limit void MySQLConnectionPool::release(const mysqlpp::Connection* pc) { mysqlpp::ConnectionPool::release(pc); std::lock_guard<std::mutex> lock(mutex_); if (conns_in_use_ <= 0) { LOG_ENGINE_WARNING_ << "MySQLConnetionPool::release: conns_in_use_ is less than zero. conns_in_use_ = " << conns_in_use_; } else { --conns_in_use_; } } // int MySQLConnectionPool::getConnectionsInUse() { // return conns_in_use_; // } // // void MySQLConnectionPool::set_max_idle_time(int max_idle) { // max_idle_time_ = max_idle; // } // Superclass overrides mysqlpp::Connection* MySQLConnectionPool::create() { try { fiu_do_on("MySQLConnectionPool.create.throw_exception", throw mysqlpp::ConnectionFailed()); // Create connection using the parameters we were passed upon // creation. auto conn = new mysqlpp::Connection(); conn->set_option(new mysqlpp::ReconnectOption(true)); conn->set_option(new mysqlpp::ConnectTimeoutOption(5)); conn->connect(db_name_.empty() ? nullptr : db_name_.c_str(), server_.empty() ? nullptr : server_.c_str(), user_.empty() ? nullptr : user_.c_str(), password_.empty() ? nullptr : password_.c_str(), port_); return conn; } catch (const mysqlpp::ConnectionFailed& er) { LOG_ENGINE_ERROR_ << "Failed to connect to database server" << ": " << er.what(); return nullptr; } } void MySQLConnectionPool::destroy(mysqlpp::Connection* cp) { // Our superclass can't know how we created the Connection, so // it delegates destruction to us, to be safe. delete cp; } unsigned int MySQLConnectionPool::max_idle_time() { return max_idle_time_; } } // namespace milvus::engine::meta
/* * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "core/svg/SVGFEMergeNodeElement.h" #include "core/svg/SVGFilterPrimitiveStandardAttributes.h" namespace blink { inline SVGFEMergeNodeElement::SVGFEMergeNodeElement(Document& document) : SVGElement(SVGNames::feMergeNodeTag, document), m_in1(SVGAnimatedString::create(this, SVGNames::inAttr)) { addToPropertyMap(m_in1); } DEFINE_TRACE(SVGFEMergeNodeElement) { visitor->trace(m_in1); SVGElement::trace(visitor); } DEFINE_NODE_FACTORY(SVGFEMergeNodeElement) void SVGFEMergeNodeElement::svgAttributeChanged(const QualifiedName& attrName) { if (attrName == SVGNames::inAttr) { SVGElement::InvalidationGuard invalidationGuard(this); invalidateFilterPrimitiveParent(this); return; } SVGElement::svgAttributeChanged(attrName); } } // namespace blink
/****************************************************************************** * $Id$ * * Project: OpenGIS Simple Features Reference Implementation * Purpose: Implements OGRODBCTableLayer class, access to an existing table. * Author: Frank Warmerdam, warmerdam@pobox.com * ****************************************************************************** * Copyright (c) 2003, Frank Warmerdam * Copyright (c) 2009-2012, Even Rouault <even dot rouault at mines-paris dot org> * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "cpl_conv.h" #include "ogr_odbc.h" CPL_CVSID("$Id$"); /************************************************************************/ /* OGRODBCTableLayer() */ /************************************************************************/ OGRODBCTableLayer::OGRODBCTableLayer( OGRODBCDataSource *poDSIn ) { poDS = poDSIn; pszQuery = NULL; bUpdateAccess = TRUE; bHaveSpatialExtents = FALSE; iNextShapeId = 0; nSRSId = -1; poFeatureDefn = NULL; pszTableName = NULL; pszSchemaName = NULL; } /************************************************************************/ /* ~OGRODBCTableLayer() */ /************************************************************************/ OGRODBCTableLayer::~OGRODBCTableLayer() { CPLFree( pszTableName ); CPLFree( pszSchemaName ); CPLFree( pszQuery ); ClearStatement(); } /************************************************************************/ /* Initialize() */ /************************************************************************/ CPLErr OGRODBCTableLayer::Initialize( const char *pszLayerName, const char *pszGeomCol ) { CPLODBCSession *poSession = poDS->GetSession(); CPLFree( pszFIDColumn ); pszFIDColumn = NULL; SetDescription( pszLayerName ); /* -------------------------------------------------------------------- */ /* Parse out schema name if present in layer. We assume a */ /* schema is provided if there is a dot in the name, and that */ /* it is in the form <schema>.<tablename> */ /* -------------------------------------------------------------------- */ const char *pszDot = strstr(pszLayerName,"."); if( pszDot != NULL ) { pszTableName = CPLStrdup(pszDot + 1); pszSchemaName = CPLStrdup(pszLayerName); pszSchemaName[pszDot - pszLayerName] = '\0'; } else { pszTableName = CPLStrdup(pszLayerName); } /* -------------------------------------------------------------------- */ /* Do we have a simple primary key? */ /* -------------------------------------------------------------------- */ CPLODBCStatement oGetKey( poSession ); if( oGetKey.GetPrimaryKeys( pszTableName, NULL, pszSchemaName ) && oGetKey.Fetch() ) { pszFIDColumn = CPLStrdup(oGetKey.GetColData( 3 )); if( oGetKey.Fetch() ) // more than one field in key! { CPLFree( pszFIDColumn ); pszFIDColumn = NULL; CPLDebug( "OGR_ODBC", "Table %s has multiple primary key fields, " "ignoring them all.", pszTableName ); } } /* -------------------------------------------------------------------- */ /* Have we been provided a geometry column? */ /* -------------------------------------------------------------------- */ CPLFree( pszGeomColumn ); if( pszGeomCol == NULL ) pszGeomColumn = NULL; else pszGeomColumn = CPLStrdup( pszGeomCol ); /* -------------------------------------------------------------------- */ /* Get the column definitions for this table. */ /* -------------------------------------------------------------------- */ CPLODBCStatement oGetCol( poSession ); CPLErr eErr; if( !oGetCol.GetColumns( pszTableName, NULL, pszSchemaName ) ) return CE_Failure; eErr = BuildFeatureDefn( pszLayerName, &oGetCol ); if( eErr != CE_None ) return eErr; if( poFeatureDefn->GetFieldCount() == 0 ) { CPLError( CE_Warning, CPLE_AppDefined, "No column definitions found for table '%s', layer not usable.", pszLayerName ); return CE_Failure; } /* -------------------------------------------------------------------- */ /* Do we have XMIN, YMIN, XMAX, YMAX extent fields? */ /* -------------------------------------------------------------------- */ if( poFeatureDefn->GetFieldIndex( "XMIN" ) != -1 && poFeatureDefn->GetFieldIndex( "XMAX" ) != -1 && poFeatureDefn->GetFieldIndex( "YMIN" ) != -1 && poFeatureDefn->GetFieldIndex( "YMAX" ) != -1 ) { bHaveSpatialExtents = TRUE; CPLDebug( "OGR_ODBC", "Table %s has geometry extent fields.", pszLayerName ); } /* -------------------------------------------------------------------- */ /* If we got a geometry column, does it exist? Is it binary? */ /* -------------------------------------------------------------------- */ if( pszGeomColumn != NULL ) { int iColumn = oGetCol.GetColId( pszGeomColumn ); if( iColumn < 0 ) { CPLError( CE_Failure, CPLE_AppDefined, "Column %s requested for geometry, but it does not exist.", pszGeomColumn ); CPLFree( pszGeomColumn ); pszGeomColumn = NULL; } else { if( CPLODBCStatement::GetTypeMapping( oGetCol.GetColType( iColumn )) == SQL_C_BINARY ) bGeomColumnWKB = TRUE; } } return CE_None; } /************************************************************************/ /* ClearStatement() */ /************************************************************************/ void OGRODBCTableLayer::ClearStatement() { if( poStmt != NULL ) { delete poStmt; poStmt = NULL; } } /************************************************************************/ /* GetStatement() */ /************************************************************************/ CPLODBCStatement *OGRODBCTableLayer::GetStatement() { if( poStmt == NULL ) ResetStatement(); return poStmt; } /************************************************************************/ /* ResetStatement() */ /************************************************************************/ OGRErr OGRODBCTableLayer::ResetStatement() { ClearStatement(); iNextShapeId = 0; poStmt = new CPLODBCStatement( poDS->GetSession() ); poStmt->Append( "SELECT * FROM " ); poStmt->Append( poFeatureDefn->GetName() ); /* Append attribute query if we have it */ if( pszQuery != NULL ) poStmt->Appendf( " WHERE %s", pszQuery ); /* If we have a spatial filter, and per record extents, query on it */ if( m_poFilterGeom != NULL && bHaveSpatialExtents ) { if( pszQuery == NULL ) poStmt->Append( " WHERE" ); else poStmt->Append( " AND" ); poStmt->Appendf( " XMAX > %.8f AND XMIN < %.8f" " AND YMAX > %.8f AND YMIN < %.8f", m_sFilterEnvelope.MinX, m_sFilterEnvelope.MaxX, m_sFilterEnvelope.MinY, m_sFilterEnvelope.MaxY ); } CPLDebug( "OGR_ODBC", "ExecuteSQL(%s)", poStmt->GetCommand() ); if( poStmt->ExecuteSQL() ) return OGRERR_NONE; else { delete poStmt; poStmt = NULL; return OGRERR_FAILURE; } } /************************************************************************/ /* ResetReading() */ /************************************************************************/ void OGRODBCTableLayer::ResetReading() { ClearStatement(); OGRODBCLayer::ResetReading(); } /************************************************************************/ /* GetFeature() */ /************************************************************************/ OGRFeature *OGRODBCTableLayer::GetFeature( GIntBig nFeatureId ) { if( pszFIDColumn == NULL ) return OGRODBCLayer::GetFeature( nFeatureId ); ClearStatement(); iNextShapeId = nFeatureId; poStmt = new CPLODBCStatement( poDS->GetSession() ); poStmt->Append( "SELECT * FROM " ); poStmt->Append( poFeatureDefn->GetName() ); poStmt->Appendf( " WHERE %s = " CPL_FRMT_GIB, pszFIDColumn, nFeatureId ); if( !poStmt->ExecuteSQL() ) { delete poStmt; poStmt = NULL; return NULL; } return GetNextRawFeature(); } /************************************************************************/ /* SetAttributeFilter() */ /************************************************************************/ OGRErr OGRODBCTableLayer::SetAttributeFilter( const char *pszQueryIn ) { CPLFree(m_pszAttrQueryString); m_pszAttrQueryString = (pszQueryIn) ? CPLStrdup(pszQueryIn) : NULL; if( (pszQueryIn == NULL && this->pszQuery == NULL) || (pszQueryIn != NULL && this->pszQuery != NULL && EQUAL(pszQueryIn,this->pszQuery)) ) return OGRERR_NONE; CPLFree( this->pszQuery ); this->pszQuery = (pszQueryIn != NULL ) ? CPLStrdup( pszQueryIn ) : NULL; ClearStatement(); return OGRERR_NONE; } /************************************************************************/ /* TestCapability() */ /************************************************************************/ int OGRODBCTableLayer::TestCapability( const char * pszCap ) { if( EQUAL(pszCap,OLCRandomRead) ) return TRUE; else return OGRODBCLayer::TestCapability( pszCap ); } /************************************************************************/ /* GetFeatureCount() */ /* */ /* If a spatial filter is in effect, we turn control over to */ /* the generic counter. Otherwise we return the total count. */ /* Eventually we should consider implementing a more efficient */ /* way of counting features matching a spatial query. */ /************************************************************************/ GIntBig OGRODBCTableLayer::GetFeatureCount( int bForce ) { if( m_poFilterGeom != NULL ) return OGRODBCLayer::GetFeatureCount( bForce ); CPLODBCStatement oStmt( poDS->GetSession() ); oStmt.Append( "SELECT COUNT(*) FROM " ); oStmt.Append( poFeatureDefn->GetName() ); if( pszQuery != NULL ) oStmt.Appendf( " WHERE %s", pszQuery ); if( !oStmt.ExecuteSQL() || !oStmt.Fetch() ) { CPLError( CE_Failure, CPLE_AppDefined, "GetFeatureCount() failed on query %s.\n%s", oStmt.GetCommand(), poDS->GetSession()->GetLastError() ); return OGRODBCLayer::GetFeatureCount(bForce); } return CPLAtoGIntBig(oStmt.GetColData(0)); } /************************************************************************/ /* GetSpatialRef() */ /* */ /* We override this to try and fetch the table SRID from the */ /* geometry_columns table if the srsid is -2 (meaning we */ /* haven't yet even looked for it). */ /************************************************************************/ OGRSpatialReference *OGRODBCTableLayer::GetSpatialRef() { #ifdef notdef if( nSRSId == -2 ) { PGconn *hPGConn = poDS->GetPGConn(); PGresult *hResult; char szCommand[1024]; nSRSId = -1; poDS->SoftStartTransaction(); sprintf( szCommand, "SELECT srid FROM geometry_columns " "WHERE f_table_name = '%s'", poFeatureDefn->GetName() ); hResult = PQexec(hPGConn, szCommand ); if( hResult && PQresultStatus(hResult) == PGRES_TUPLES_OK && PQntuples(hResult) == 1 ) { nSRSId = atoi(PQgetvalue(hResult,0,0)); } poDS->SoftCommit(); } #endif return OGRODBCLayer::GetSpatialRef(); }
/* $Id$ */ /* * Copyright (C) 2009-2011 Teluu Inc. (http://www.teluu.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* * This file is a C++ wrapper, see ticket #886 for details. */ #include "resolver.c"
// Copyright 2018 The Abseil Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include <iostream> #include "absl/base/internal/thread_identity.h" int main() { auto* tid = absl::base_internal::CurrentThreadIdentityIfPresent(); // Make sure the above call can't be optimized out std::cout << (void*)tid << std::endl; }
#include "sdbusplus/server/transaction.hpp" namespace sdbusplus { namespace server { namespace transaction { namespace details { // Transaction Id thread_local uint64_t id = 0; } // namespace details uint64_t get_id() { // If the transaction id has not been initialized, generate one. if (!details::id) { details::Transaction t; details::id = std::hash<details::Transaction>{}(t); } return details::id; } void set_id(uint64_t value) { details::id = value; } void set_id(message_t& msg) { auto tbus = msg.get_bus(); auto t = Transaction(tbus, msg); set_id(std::hash<Transaction>{}(t)); } } // namespace transaction } // namespace server } // namespace sdbusplus namespace std { size_t hash<sdbusplus::bus_t>::operator()(sdbusplus::bus_t& b) const { auto name = b.get_unique_name(); return std::hash<std::string>{}(name); } size_t hash<sdbusplus::message_t>::operator()(sdbusplus::message_t& m) const { switch (m.get_type()) { // Reply messages will always embed the cookie of the original // message in a separate location. We want to use this cookie // to correlate messages as one transaction. case SD_BUS_MESSAGE_METHOD_RETURN: case SD_BUS_MESSAGE_METHOD_ERROR: return std::hash<uint64_t>{}(m.get_reply_cookie()); // Method calls will have the cookie in the header when sealed. // Since we are on the server side that should always be the case. case SD_BUS_MESSAGE_METHOD_CALL: return std::hash<uint64_t>{}(m.get_cookie()); // Outgoing signals don't have a cookie so we need to use // something else as an id. Just use a monotonic unique one. case SD_BUS_MESSAGE_SIGNAL: return std::hash<uint64_t>{}( std::chrono::steady_clock::now().time_since_epoch().count()); default: throw std::runtime_error("hash message: Unknown message type"); } } size_t hash<sdbusplus::server::transaction::Transaction>::operator()( sdbusplus::server::transaction::Transaction const& t) const { auto hash1 = std::hash<sdbusplus::bus_t>{}(t.bus); auto hash2 = std::hash<sdbusplus::message_t>{}(t.msg); // boost::hash_combine() algorithm. return static_cast<size_t>( hash1 ^ (hash2 + 0x9e3779b9 + (hash1 << 6) + (hash1 >> 2))); } size_t hash<sdbusplus::server::transaction::details::Transaction>::operator()( sdbusplus::server::transaction::details::Transaction const& t) const { auto hash1 = std::hash<int>{}(t.time); auto hash2 = std::hash<std::thread::id>{}(t.thread); // boost::hash_combine() algorithm. return static_cast<size_t>( hash1 ^ (hash2 + 0x9e3779b9 + (hash1 << 6) + (hash1 >> 2))); } } // namespace std
/* * Copyright (C) 2014, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "dictionary/structure/v4/content/dynamic_language_model_probability_utils.h" namespace turbokeyboard { // Used to provide stable probabilities even if the user's input count is small. const int DynamicLanguageModelProbabilityUtils::ASSUMED_MIN_COUNTS[] = {8192, 2, 2, 1}; // Encoded backoff weights. // Note that we give positive values for trigrams and quadgrams that means the weight is more than // 1. // TODO: Apply backoff for main dictionaries and quit giving a positive backoff weight. const int DynamicLanguageModelProbabilityUtils::ENCODED_BACKOFF_WEIGHTS[] = {-32, -4, 2, 8}; // This value is used to remove too old entries from the dictionary. const int DynamicLanguageModelProbabilityUtils::DURATION_TO_DISCARD_ENTRY_IN_SECONDS = 300 * 24 * 60 * 60; // 300 days } // namespace turbokeyboard
class Solution { public: int singleNumber(vector<int>& nums) { int ans = 0; for (int& num : nums) ans ^= num; return ans; } };
/* * Copyright 2021 IBM Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <SPL/Core/PoolPopulator.h> #include <SPL/Core/CompilerConfiguration.h> #include <SPL/Core/CompilerError.h> #include <SPL/Core/CompilerException.h> #include <SPL/Core/CompilerMessage.h> #include <SPL/Core/PoolCollection.h> #include <SPL/Runtime/Utility/Singleton.t> #include <SPL/Utility/Debug.h> #include <SPL/Utility/ProcessLauncher.h> #include <SPL/Utility/SysOut.h> #include <UTILS/HashMapHelpers.h> #include <UTILS/HostInfo.h> #include <UTILS/RAIIFct.h> #include <UTILS/SupportFunctions.h> #include <boost/algorithm/string/trim.hpp> #include <boost/filesystem/operations.hpp> #include <boost/filesystem/path.hpp> #include <arpa/inet.h> #include <fcntl.h> #include <fstream> #include <ifaddrs.h> #include <net/if.h> #include <netdb.h> #include <netinet/in.h> #include <netinet/ip.h> #include <sys/socket.h> #include <unistd.h> using namespace std; using namespace std::tr1; using namespace SPL; using namespace Distillery; using namespace SPL; namespace bf = boost::filesystem; template class Singleton<PoolPopulator>; #define LOCALHOST_LITERAL "localhost" string PoolPopulator::convertToCanonicalName(string const& hostname) { static char thisHostName[NI_MAXHOST]; string host = hostname; if (hostname == LOCALHOST_LITERAL) { if (!thisHostName[0]) { int ret = gethostname(thisHostName, sizeof thisHostName); if (ret != 0) THROW(SPLCompilerNoValidCanonicalHostNames, SPL_CORE_CANNOT_OBTAIN_IP_THAT_RESOLVES_BACK_TO_HOST_OTHER_THAN_LOCALHOST( hostname)); } host = thisHostName; } if (!CompilerConfiguration::instance().isSet(CompilerConfiguration::HostValidation)) return host; addrinfo hints; memset(&hints, '\0', sizeof(hints)); hints.ai_flags = AI_ADDRCONFIG | AI_CANONNAME; hints.ai_protocol = PF_INET; for (int try1 = 0; try1 < 10; ++try1) { addrinfo* ai; int ret = getaddrinfo(host.c_str(), NULL, &hints, &ai); if (ret != 0) { if (ret != EAI_AGAIN) THROW(SPLCompilerNoValidCanonicalHostNames, SPL_CORE_CANNOT_OBTAIN_IP_FOR_HOST(hostname)); } else { bool foundLocal = false; Distillery::RAIIFct<addrinfo*> freeAI(ai, freeaddrinfo); for (addrinfo* p = ai; p; p = p->ai_next) { char retHost[NI_MAXHOST]; for (int try2 = 0; try2 < 10; ++try2) { ret = getnameinfo(p->ai_addr, p->ai_addrlen, retHost, sizeof(retHost), NULL, 0, NI_NAMEREQD); if (ret != 0) { if (ret != EAI_AGAIN) THROW(SPLCompilerNoValidCanonicalHostNames, SPL_CORE_CANNOT_OBTAIN_IP_FOR_HOST(hostname)); } else { string host1 = retHost; if (host1 == LOCALHOST_LITERAL || host1.find(LOCALHOST_LITERAL + string(".")) == 0) { foundLocal = true; break; } else { return host1; } } } } if (foundLocal) { THROW(SPLCompilerNoValidCanonicalHostNames, SPL_CORE_CANNOT_OBTAIN_IP_THAT_RESOLVES_BACK_TO_HOST_OTHER_THAN_LOCALHOST( hostname)); } else { THROW(SPLCompilerNoValidCanonicalHostNames, SPL_CORE_CANNOT_OBTAIN_IP_THAT_RESOLVES_BACK_TO_HOST(hostname)); } } } // Tried 10 times and failed :-( THROW(SPLCompilerNoValidCanonicalHostNames, SPL_CORE_CANNOT_OBTAIN_IP_FOR_HOST(hostname)); return host; } PoolPopulator::PoolPopulator() : Singleton<PoolPopulator>(*this) , config_(CompilerConfiguration::instance()) {} void PoolPopulator::populate(PoolCollection& pools) { { // size the default pool uint32_t size = pools.getSize(PoolCollection::defaultPoolIndex); if (size == 0 && config_.isSet(CompilerConfiguration::DefaultPoolSize)) size = config_.getIntValue(CompilerConfiguration::DefaultPoolSize); if (size) pools.setDefaultPoolSize(size); } { // collect used hosts and validate explicit pools AutoErrorTrap aet(); for (uint32_t pidx = 0, iu = pools.numPools(); pidx < iu; ++pidx) { if (pools.getKind(pidx) == PoolCollection::ImplicitPool) continue; uint32_t size = pools.getSize(pidx); vector<string> const& hosts = pools.getHosts(pidx); if (size == 0) SysOut::errorln(SPL_CORE_EMPTY_EXPLICIT_POOL(pools.getName(pidx)), pools.getLocation(pidx)); else if (size > hosts.size()) SysOut::errorln( SPL_CORE_INCOMPLETE_EXPLICIT_POOL(pools.getName(pidx), (size - hosts.size())), pools.getLocation(pidx)); bool changed = false; unordered_map<string, uint32_t> chosts; for (uint32_t hidx = 0, ju = hosts.size(); hidx < ju; ++hidx) { string host; try { host = convertToCanonicalName(hosts[hidx]); } catch (SPLCompilerNoValidCanonicalHostNamesException const& e) { SysOut::errorln(SPL_CORE_CANNOT_OBTAIN_VALID_CANONICAL_NAME_FOR_HOST_IN_POOL( hosts[hidx], pools.getName(pidx), e.getExplanation()), pools.getLocation(pidx)); host = hosts[hidx]; } if (host != hosts[hidx]) { pools.replaceHost(pidx, hidx, host); changed = true; } if (chosts.count(host) == 0) chosts.insert(make_pair(host, 1)); else chosts[host]++; } for (unordered_map<string, uint32_t>::const_iterator it = chosts.begin(); it != chosts.end(); ++it) { if (it->second > 1) { if (!changed) SysOut::errorln(SPL_CORE_HOST_APPEARS_MORE_THAN_ONCE_IN_POOL( it->first, pools.getName(pidx)), pools.getLocation(pidx)); else SysOut::errorln( SPL_CORE_HOST_APPEARS_MORE_THAN_ONCE_IN_POOL_AFTER_HOST_RESOLUTION( it->first, pools.getName(pidx)), pools.getLocation(pidx)); } } } } }
/* * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) * * This file is part of Orfeo Toolbox * * https://www.orfeo-toolbox.org/ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #if defined(_MSC_VER) #pragma warning ( disable : 4786 ) #endif #include "itkListSample.h" #include "otbSVMMarginSampler.h" #include "otbLibSVMMachineLearningModel.h" int otbSVMMarginSamplerNew(int itkNotUsed(argc), char * itkNotUsed(argv) []) { typedef itk::VariableLengthVector<double> SampleType; typedef itk::Statistics::ListSample<SampleType> SampleListType; typedef otb::LibSVMMachineLearningModel<double,unsigned int> SVMModelType; typedef otb::SVMMarginSampler<SampleListType,SVMModelType> MarginSamplerType; MarginSamplerType::Pointer marginSampler = MarginSamplerType::New(); std::cout << marginSampler << std::endl; return EXIT_SUCCESS; }
// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s // RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s // p1099 'using SCOPEDENUM::MEMBER;' namespace Zero { namespace Bob { enum class Kevin { Stuart, AlsoStuart #if __cplusplus >= 202002L // expected-note@-3{{target of using declaration}} // expected-note@-3{{target of using declaration}} #endif }; } // namespace Bob using Bob::Kevin::Stuart; #if __cplusplus < 202002L // expected-warning@-2{{using declaration naming a scoped enumerator is a C++20 extension}} #else using Bob::Kevin::Stuart; auto b = Stuart; namespace Foo { int Stuart; // expected-note{{conflicting declaration}} using Bob::Kevin::Stuart; // expected-error{{target of using declaration conflicts}} using Bob::Kevin::AlsoStuart; // expected-note{{using declaration}} int AlsoStuart; // expected-error{{declaration conflicts with target}} } // namespace Foo #endif } // namespace Zero namespace One { // derived from [namespace.udecl]/3 enum class button { up, down }; struct S { using button::up; #if __cplusplus < 202002L // expected-warning@-2{{a C++20 extension}} // expected-error@-3{{using declaration in class}} #else button b = up; #endif }; #if __cplusplus >= 202002L // some more struct T : S { button c = up; }; #endif enum E2 { e2 }; } // namespace One namespace Two { enum class E1 { e1 }; struct S { using One::e2; #if __cplusplus < 202002L // expected-error@-2{{using declaration in class}} #else One::E2 c = e2; #endif }; } // namespace Two namespace Three { enum E3 { e3 }; struct e3; struct S { using Three::e3; // expected-error{{using declaration in class}} enum class E4 { e4 }; enum E5 { e5 }; }; using S::e5; using S::E4::e4; #if __cplusplus < 202002L // expected-error@-3{{using declaration cannot refer to class member}} // expected-note@-4{{use a constexpr variable instead}} // expected-warning@-4{{a C++20 extension}} // expected-error@-5{{using declaration cannot refer to class member}} // expected-note@-6{{use a constexpr variable instead}} #else auto a = e4; auto b = e5; #endif } // namespace Three namespace Four { template <typename T> struct TPL { enum class E1 { e1 }; struct IN { enum class E2 { e2 }; }; protected: enum class E3 { e3 }; // expected-note{{declared protected here}} }; using TPL<int>::E1::e1; #if __cplusplus < 202002L // expected-warning@-2{{a C++20 extension}} // expected-error@-3{{using declaration cannot refer to class member}} // expected-note@-4{{use a constexpr variable instead}} #else using TPL<float>::IN::E2::e2; auto a = e1; auto b = e2; #endif enum class E4 { e4 }; template <typename T> struct DER : TPL<int> { using TPL<T>::E1::e1; #if __cplusplus < 202002L // expected-warning@-2{{a C++20 extension}} // expected-warning@-3{{using declaration naming a scoped}} // expected-error@-4{{which is not a base}} #endif using TPL<T>::E3::e3; // expected-error{{is a protected member}} #if __cplusplus < 202002L // expected-warning@-2 2{{using declaration naming a scoped}} // expected-error@-3{{which is not a base}} #endif using E4::e4; #if __cplusplus < 202002L // expected-warning@-2{{a C++20 extension}} // expected-error@-3{{which is not a class}} #else auto Foo() { return e1; } auto Bar() { return e2; } #endif }; DER<float> x; // expected-note{{requested here}} DER<int> y; #if __cplusplus < 202002L // expected-note@-2{{requested here}} #else auto y1 = y.Foo(); auto y2 = y.Bar(); #endif } // namespace Four namespace Five { template <unsigned I, unsigned K> struct Quux { enum class Q : unsigned; // expected-note{{member is declared here}} enum class R : unsigned { i = I, k = K }; }; using Quux<1, 2>::Q::nothing; // expected-error{{implicit instantiation of undefined}} using Quux<1, 2>::R::i; #if __cplusplus < 202002L // expected-warning@-2{{a C++20 extension}} // expected-error@-3{{using declaration cannot refer to class member}} // expected-note@-4{{use a constexpr variable instead}} #endif } // namespace Five namespace Six { template <unsigned I, unsigned K> struct Quux { enum class Q : unsigned; // expected-note{{member is declared here}} enum class R : unsigned { i = I, k = K }; }; template <unsigned I> struct Fido { using Quux<I, I>::Q::nothing; // expected-error{{implicit instantiation of undefined}} }; Fido<2> a; // expected-note{{in instantiation}} } // namespace Six namespace Seven { template <unsigned I, unsigned K> struct Quux { enum class R : unsigned { i = I, k = K }; }; template <unsigned I> struct Toto { using Quux<I, I>::R::i; #if __cplusplus < 202002L // expected-warning@-2{{a C++20 extension}} // expected-error@-3{{refers into}} #else static_assert(unsigned(i) == I); #endif }; Toto<2> b; #if __cplusplus < 202002L // expected-note@-2{{in instantiation}} #endif } // namespace Seven namespace Eight { struct Kevin { enum class B { a }; enum a {}; }; using Kevin::B::a; #if __cplusplus < 202002L // expected-warning@-2{{a C++20 extension}} // expected-error@-3{{using declaration cannot refer to class member}} // expected-note@-4{{use a constexpr variable instead}} #endif using Kevin::B::a; #if __cplusplus < 202002L // expected-warning@-2{{a C++20 extension}} // expected-error@-3{{using declaration cannot refer to class member}} // expected-note@-4{{use a constexpr variable instead}} #endif class X : Kevin { using Kevin::B::a; // expected-note{{previous using declaration}} #if __cplusplus < 202002L // expected-warning@-2{{a C++20 extension}} #endif using Kevin::a; using Kevin::B::a; // expected-error{{redeclaration of using declaration}} }; } // namespace Eight namespace Nine { namespace Q { enum class Bob { a }; using Bob::a; #if __cplusplus < 202002L // expected-warning@-2{{a C++20 extension}} #endif } // namespace Q using Q::a; using Q::Bob::a; #if __cplusplus < 202002L // expected-warning@-2{{a C++20 extension}} #endif #if __cplusplus >= 202002L struct Foo { using Q::a; // expected-note{{previous using declaration}} using Q::Bob::a; using Q::a; // expected-error{{redeclaration of using declaration}} }; #endif } // namespace Nine
// Copyright (c) 2017-2018, The Monero Project // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. // // 3. Neither the name of the copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "gtest/gtest.h" #include <cstdint> #include "wallet/wallet2.h" static const struct { const char *address; const char *spendkey; } test_addresses[] = { { "9uvjbU54ZJb8j7Dcq1h3F1DnBRkxXdYUX4pbJ7mE3ghM8uF3fKzqRKRNAKYZXcNLqMg7MxjVVD2wKC2PALUwEveGSC3YSWD", "2dd6e34a234c3e8b5d29a371789e4601e96dee4ea6f7ef79224d1a2d91164c01" }, { "9ywDBAyDbb6QKFiZxDJ4hHZqZEQXXCR5EaYNcndUpqPDeE7rEgs6neQdZnhcDrWbURYK8xUjhuG2mVjJdmknrZbcG7NnbaB", "fac47aecc948ce9d3531aa042abb18235b1df632087c55a361b632ffdd6ede0c" }, { "9t6Hn946u3eah5cuncH1hB5hGzsTUoevtf4SY7MHN5NgJZh2SFWsyVt3vUhuHyRKyrCQvr71Lfc1AevG3BXE11PQFoXDtD8", "bbd3175ef9fd9f5eefdc43035f882f74ad14c4cf1799d8b6f9001bc197175d02" } }; static void make_wallet(unsigned int idx, tools::wallet2 &wallet) { ASSERT_TRUE(idx < sizeof(test_addresses) / sizeof(test_addresses[0])); crypto::secret_key spendkey; epee::string_tools::hex_to_pod(test_addresses[idx].spendkey, spendkey); try { wallet.init(""); wallet.set_subaddress_lookahead(1, 1); wallet.generate("", "", spendkey, true, false); ASSERT_TRUE(test_addresses[idx].address == wallet.get_account().get_public_address_str(true)); } catch (const std::exception &e) { MFATAL("Error creating test wallet: " << e.what()); ASSERT_TRUE(0); } } static void make_M_2_wallet(tools::wallet2 &wallet0, tools::wallet2 &wallet1, unsigned int M) { ASSERT_TRUE(M <= 2); make_wallet(0, wallet0); make_wallet(1, wallet1); std::vector<crypto::secret_key> sk0(1), sk1(1); std::vector<crypto::public_key> pk0(1), pk1(1); std::string mi0 = wallet0.get_multisig_info(); std::string mi1 = wallet1.get_multisig_info(); ASSERT_TRUE(tools::wallet2::verify_multisig_info(mi1, sk0[0], pk0[0])); ASSERT_TRUE(tools::wallet2::verify_multisig_info(mi0, sk1[0], pk1[0])); ASSERT_FALSE(wallet0.multisig() || wallet1.multisig()); wallet0.make_multisig("", sk0, pk0, M); wallet1.make_multisig("", sk1, pk1, M); ASSERT_TRUE(wallet0.get_account().get_public_address_str(true) == wallet1.get_account().get_public_address_str(true)); bool ready; uint32_t threshold, total; ASSERT_TRUE(wallet0.multisig(&ready, &threshold, &total)); ASSERT_TRUE(ready); ASSERT_TRUE(threshold == M); ASSERT_TRUE(total == 2); ASSERT_TRUE(wallet1.multisig(&ready, &threshold, &total)); ASSERT_TRUE(ready); ASSERT_TRUE(threshold == M); ASSERT_TRUE(total == 2); } static void make_M_3_wallet(tools::wallet2 &wallet0, tools::wallet2 &wallet1, tools::wallet2 &wallet2, unsigned int M) { ASSERT_TRUE(M <= 3); make_wallet(0, wallet0); make_wallet(1, wallet1); make_wallet(2, wallet2); std::vector<crypto::secret_key> sk0(2), sk1(2), sk2(2); std::vector<crypto::public_key> pk0(2), pk1(2), pk2(2); std::string mi0 = wallet0.get_multisig_info(); std::string mi1 = wallet1.get_multisig_info(); std::string mi2 = wallet2.get_multisig_info(); ASSERT_TRUE(tools::wallet2::verify_multisig_info(mi1, sk0[0], pk0[0])); ASSERT_TRUE(tools::wallet2::verify_multisig_info(mi2, sk0[1], pk0[1])); ASSERT_TRUE(tools::wallet2::verify_multisig_info(mi0, sk1[0], pk1[0])); ASSERT_TRUE(tools::wallet2::verify_multisig_info(mi2, sk1[1], pk1[1])); ASSERT_TRUE(tools::wallet2::verify_multisig_info(mi0, sk2[0], pk2[0])); ASSERT_TRUE(tools::wallet2::verify_multisig_info(mi1, sk2[1], pk2[1])); ASSERT_FALSE(wallet0.multisig() || wallet1.multisig() || wallet2.multisig()); std::string mxi0 = wallet0.make_multisig("", sk0, pk0, M); std::string mxi1 = wallet1.make_multisig("", sk1, pk1, M); std::string mxi2 = wallet2.make_multisig("", sk2, pk2, M); const size_t nset = !mxi0.empty() + !mxi1.empty() + !mxi2.empty(); ASSERT_TRUE((M < 3 && nset == 3) || (M == 3 && nset == 0)); if (nset > 0) { std::unordered_set<crypto::public_key> pkeys; std::vector<crypto::public_key> signers(3, crypto::null_pkey); ASSERT_TRUE(tools::wallet2::verify_extra_multisig_info(mxi0, pkeys, signers[0])); ASSERT_TRUE(tools::wallet2::verify_extra_multisig_info(mxi1, pkeys, signers[1])); ASSERT_TRUE(tools::wallet2::verify_extra_multisig_info(mxi2, pkeys, signers[2])); ASSERT_TRUE(pkeys.size() == 3); ASSERT_TRUE(wallet0.finalize_multisig("", pkeys, signers)); ASSERT_TRUE(wallet1.finalize_multisig("", pkeys, signers)); ASSERT_TRUE(wallet2.finalize_multisig("", pkeys, signers)); } ASSERT_TRUE(wallet0.get_account().get_public_address_str(true) == wallet1.get_account().get_public_address_str(true)); ASSERT_TRUE(wallet0.get_account().get_public_address_str(true) == wallet2.get_account().get_public_address_str(true)); bool ready; uint32_t threshold, total; ASSERT_TRUE(wallet0.multisig(&ready, &threshold, &total)); ASSERT_TRUE(ready); ASSERT_TRUE(threshold == M); ASSERT_TRUE(total == 3); ASSERT_TRUE(wallet1.multisig(&ready, &threshold, &total)); ASSERT_TRUE(ready); ASSERT_TRUE(threshold == M); ASSERT_TRUE(total == 3); ASSERT_TRUE(wallet2.multisig(&ready, &threshold, &total)); ASSERT_TRUE(ready); ASSERT_TRUE(threshold == M); ASSERT_TRUE(total == 3); } TEST(multisig, make_2_2) { tools::wallet2 wallet0, wallet1; make_M_2_wallet(wallet0, wallet1, 2); } TEST(multisig, make_3_3) { tools::wallet2 wallet0, wallet1, wallet2; make_M_3_wallet(wallet0, wallet1, wallet2, 3); } TEST(multisig, make_2_3) { tools::wallet2 wallet0, wallet1, wallet2; make_M_3_wallet(wallet0, wallet1, wallet2, 2); }
/*========================================================================= * * Copyright NumFOCUS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * *=========================================================================*/ #include "itkMIRegistrationFunction.h" #include "itkGaussianImageSource.h" #include "itkTestingMacros.h" #include <iostream> /** * This test uses two 2D-Gaussians (standard deviation RegionSize/2) * One is shifted by 5 pixels from the other. * * This test exercises the MIRegistrationFunction * */ int itkMIRegistrationFunctionTest(int, char *[]) { constexpr unsigned int ImageDimension = 2; using PixelType = double; using DeformationPixelType = itk::Vector<PixelType, ImageDimension>; using MovingImageType = itk::Image<PixelType, ImageDimension>; using FixedImageType = itk::Image<PixelType, ImageDimension>; using DisplacementFieldType = itk::Image<DeformationPixelType, ImageDimension>; // Declare Gaussian image sources using MovingImageSourceType = itk::GaussianImageSource<MovingImageType>; using FixedImageSourceType = itk::GaussianImageSource<FixedImageType>; // Create the two images FixedImageType::SizeValueType fixedImageSize[] = { 100, 100 }; MovingImageType::SizeValueType movingImageSize[] = { 100, 100 }; FixedImageType::SpacingValueType fixedImageSpacing[] = { 1.0f, 1.0f }; MovingImageType::SpacingValueType movingImageSpacing[] = { 1.0f, 1.0f }; FixedImageType::PointValueType fixedImageOrigin[] = { 0.0f, 0.0f }; MovingImageType::PointValueType movingImageOrigin[] = { 0.0f, 0.0f }; MovingImageSourceType::Pointer movingImageSource = MovingImageSourceType::New(); FixedImageSourceType::Pointer fixedImageSource = FixedImageSourceType::New(); fixedImageSource->SetSize(fixedImageSize); fixedImageSource->SetOrigin(fixedImageOrigin); fixedImageSource->SetSpacing(fixedImageSpacing); fixedImageSource->SetNormalized(false); fixedImageSource->SetScale(250.0f); movingImageSource->SetSize(movingImageSize); movingImageSource->SetOrigin(movingImageOrigin); movingImageSource->SetSpacing(movingImageSpacing); movingImageSource->SetNormalized(false); movingImageSource->SetScale(250.0f); movingImageSource->Update(); fixedImageSource->Update(); MovingImageType::Pointer movingImage = movingImageSource->GetOutput(); FixedImageType::Pointer fixedImage = fixedImageSource->GetOutput(); // Set up the metric using MetricFunctionType = itk::MIRegistrationFunction<FixedImageType, MovingImageType, DisplacementFieldType>; MetricFunctionType::Pointer metricFunction = MetricFunctionType::New(); ITK_EXERCISE_BASIC_OBJECT_METHODS(metricFunction, MIRegistrationFunction, PDEDeformableRegistrationFunction); // Plug the images into the metric function metricFunction->SetFixedImage(fixedImage); metricFunction->SetMovingImage(movingImage); std::cout << "Test finished." << std::endl; return EXIT_SUCCESS; }
/* * Certificate Message * (C) 2004-2006,2012,2020 Jack Lloyd * * Botan is released under the Simplified BSD License (see license.txt) */ #include <botan/tls_messages.h> #include <botan/tls_extensions.h> #include <botan/tls_exceptn.h> #include <botan/tls_alert.h> #include <botan/internal/tls_reader.h> #include <botan/internal/tls_handshake_io.h> #include <botan/internal/tls_handshake_hash.h> #include <botan/internal/loadstor.h> #include <botan/data_src.h> namespace Botan::TLS { /** * Create a new Certificate message */ Certificate_12::Certificate_12(Handshake_IO& io, Handshake_Hash& hash, const std::vector<X509_Certificate>& cert_list) : m_certs(cert_list) { hash.update(io.send(*this)); } /** * Deserialize a Certificate message */ Certificate_12::Certificate_12(const std::vector<uint8_t>& buf, const Policy& policy) { if(buf.size() < 3) throw Decoding_Error("Certificate: Message malformed"); const size_t total_size = make_uint32(0, buf[0], buf[1], buf[2]); if(total_size != buf.size() - 3) throw Decoding_Error("Certificate: Message malformed"); const size_t max_size = policy.maximum_certificate_chain_size(); if(max_size > 0 && total_size > max_size) throw Decoding_Error("Certificate chain exceeds policy specified maximum size"); const uint8_t* certs = buf.data() + 3; while(size_t remaining_bytes = buf.data() + buf.size() - certs) { if(remaining_bytes < 3) throw Decoding_Error("Certificate: Message malformed"); const size_t cert_size = make_uint32(0, certs[0], certs[1], certs[2]); if(remaining_bytes < (3 + cert_size)) throw Decoding_Error("Certificate: Message malformed"); DataSource_Memory cert_buf(&certs[3], cert_size); m_certs.push_back(X509_Certificate(cert_buf)); certs += cert_size + 3; } /* * TLS 1.0 through 1.2 all seem to require that the certificate be * precisely a v3 certificate. In fact the strict wording would seem * to require that every certificate in the chain be v3. But often * the intermediates are outside of the control of the server. * But, require that the leaf certificate be v3 */ if(!m_certs.empty() && m_certs[0].x509_version() != 3) { throw TLS_Exception(Alert::BAD_CERTIFICATE, "The leaf certificate must be v3"); } } /** * Serialize a Certificate message */ std::vector<uint8_t> Certificate_12::serialize() const { std::vector<uint8_t> buf(3); for(const auto& cert : m_certs) { const auto raw_cert = cert.BER_encode(); const size_t cert_size = raw_cert.size(); for(size_t j = 0; j != 3; ++j) { buf.push_back(get_byte_var(j+1, static_cast<uint32_t>(cert_size))); } buf += raw_cert; } const size_t buf_size = buf.size() - 3; for(size_t i = 0; i != 3; ++i) buf[i] = get_byte_var(i+1, static_cast<uint32_t>(buf_size)); return buf; } }
/****************************************************************************** * * Copyright (C) 2010-2014 Broadcom Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ******************************************************************************/ /****************************************************************************** * * This file contains the implementation for Type 2 tag in Reader/Writer * mode. * ******************************************************************************/ #include <string> #include <android-base/stringprintf.h> #include <base/logging.h> #include "nfc_target.h" #include "bt_types.h" #include "gki.h" #include "nci_hmsgs.h" #include "nfc_api.h" #include "nfc_int.h" #include "rw_api.h" #include "rw_int.h" using android::base::StringPrintf; extern bool nfc_debug_enabled; /* Static local functions */ static void rw_t2t_proc_data(uint8_t conn_id, tNFC_DATA_CEVT* p_data); static tNFC_STATUS rw_t2t_send_cmd(uint8_t opcode, uint8_t* p_dat); static void rw_t2t_process_error(void); static void rw_t2t_process_frame_error(void); static void rw_t2t_handle_presence_check_rsp(tNFC_STATUS status); static void rw_t2t_resume_op(void); static std::string rw_t2t_get_state_name(uint8_t state); static std::string rw_t2t_get_substate_name(uint8_t substate); /******************************************************************************* ** ** Function rw_t2t_proc_data ** ** Description This function handles data evt received from NFC Controller. ** ** Returns none ** *******************************************************************************/ static void rw_t2t_proc_data(uint8_t conn_id, tNFC_DATA_CEVT* p_data) { tRW_EVENT rw_event = RW_RAW_FRAME_EVT; tRW_T2T_CB* p_t2t = &rw_cb.tcb.t2t; NFC_HDR* p_pkt = p_data->p_data; bool b_notify = true; bool b_release = true; uint8_t* p; tRW_READ_DATA evt_data = {}; tT2T_CMD_RSP_INFO* p_cmd_rsp_info = (tT2T_CMD_RSP_INFO*)rw_cb.tcb.t2t.p_cmd_rsp_info; tRW_DETECT_NDEF_DATA ndef_data; uint8_t begin_state = p_t2t->state; if ((p_t2t->state == RW_T2T_STATE_IDLE) || (p_cmd_rsp_info == nullptr)) { DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf( "%s - RW T2T Raw Frame: Len [0x%X] Status [%s]", __func__, p_pkt->len, NFC_GetStatusName(p_data->status).c_str()); evt_data.status = p_data->status; evt_data.p_data = p_pkt; tRW_DATA rw_data; rw_data.data = evt_data; (*rw_cb.p_cback)(RW_T2T_RAW_FRAME_EVT, &rw_data); return; } #if (RW_STATS_INCLUDED == TRUE) /* Update rx stats */ rw_main_update_rx_stats(p_pkt->len); #endif /* Stop timer as response is received */ nfc_stop_quick_timer(&p_t2t->t2_timer); DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s - RW RECV [%s]:0x%x RSP", __func__, t2t_info_to_str(p_cmd_rsp_info), p_cmd_rsp_info->opcode); if (((p_pkt->len != p_cmd_rsp_info->rsp_len) && (p_pkt->len != p_cmd_rsp_info->nack_rsp_len) && (p_t2t->substate != RW_T2T_SUBSTATE_WAIT_SELECT_SECTOR)) || (p_t2t->state == RW_T2T_STATE_HALT)) { LOG(ERROR) << StringPrintf("%s - T2T Frame error. state=%s ", __func__, rw_t2t_get_state_name(p_t2t->state).c_str()); if (p_t2t->state != RW_T2T_STATE_HALT) { /* Retrasmit the last sent command if retry-count < max retry */ rw_t2t_process_frame_error(); p_t2t->check_tag_halt = false; } GKI_freebuf(p_pkt); return; } rw_cb.cur_retry = 0; /* Assume the data is just the response byte sequence */ p = (uint8_t*)(p_pkt + 1) + p_pkt->offset; DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf( "rw_t2t_proc_data State: %u conn_id: %u len: %u data[0]: 0x%02x", p_t2t->state, conn_id, p_pkt->len, *p); evt_data.p_data = nullptr; if (p_t2t->substate == RW_T2T_SUBSTATE_WAIT_SELECT_SECTOR_SUPPORT) { /* The select process happens in two steps */ if ((*p & 0x0f) == T2T_RSP_ACK) { if (rw_t2t_sector_change(p_t2t->select_sector) == NFC_STATUS_OK) b_notify = false; else evt_data.status = NFC_STATUS_FAILED; } else { DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf( "rw_t2t_proc_data - Received NACK response(0x%x) to SEC-SELCT CMD", (*p & 0x0f)); evt_data.status = NFC_STATUS_REJECTED; } } else if (p_t2t->substate == RW_T2T_SUBSTATE_WAIT_SELECT_SECTOR) { evt_data.status = NFC_STATUS_FAILED; } else if ((p_pkt->len != p_cmd_rsp_info->rsp_len) || ((p_cmd_rsp_info->opcode == T2T_CMD_WRITE) && ((*p & 0x0f) != T2T_RSP_ACK))) { /* Received NACK response */ evt_data.p_data = p_pkt; if (p_t2t->state == RW_T2T_STATE_READ) b_release = false; DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf( "rw_t2t_proc_data - Received NACK response(0x%x)", (*p & 0x0f)); if (!p_t2t->check_tag_halt) { /* Just received first NACK. Retry just one time to find if tag went in to * HALT State */ b_notify = false; rw_t2t_process_error(); /* Assume Tag is in HALT State, untill we get response to retry command */ p_t2t->check_tag_halt = true; } else { p_t2t->check_tag_halt = false; /* Got consecutive NACK so tag not really halt after first NACK, but * current operation failed */ evt_data.status = NFC_STATUS_FAILED; } } else { /* If the response length indicates positive response or cannot be known * from length then assume success */ evt_data.status = NFC_STATUS_OK; p_t2t->check_tag_halt = false; /* The response data depends on what the current operation was */ switch (p_t2t->state) { case RW_T2T_STATE_CHECK_PRESENCE: b_notify = false; rw_t2t_handle_presence_check_rsp(NFC_STATUS_OK); break; case RW_T2T_STATE_READ: evt_data.p_data = p_pkt; b_release = false; if (p_t2t->block_read == 0) { p_t2t->b_read_hdr = true; memcpy(p_t2t->tag_hdr, p, T2T_READ_DATA_LEN); } break; case RW_T2T_STATE_WRITE: /* Write operation completed successfully */ break; default: /* NDEF/other Tlv Operation/Format-Tag/Config Tag as Read only */ b_notify = false; rw_t2t_handle_rsp(p); break; } } if (b_notify) { rw_event = rw_t2t_info_to_event(p_cmd_rsp_info); if (rw_event == RW_T2T_NDEF_DETECT_EVT) { ndef_data.status = evt_data.status; ndef_data.protocol = NFC_PROTOCOL_T2T; ndef_data.flags = RW_NDEF_FL_UNKNOWN; if (p_t2t->substate == RW_T2T_SUBSTATE_WAIT_READ_LOCKS) ndef_data.flags = RW_NDEF_FL_FORMATED; ndef_data.max_size = 0; ndef_data.cur_size = 0; /* Move back to idle state */ rw_t2t_handle_op_complete(); tRW_DATA rw_data; rw_data.ndef = ndef_data; (*rw_cb.p_cback)(rw_event, &rw_data); } else { /* Move back to idle state */ rw_t2t_handle_op_complete(); tRW_DATA rw_data; rw_data.data = evt_data; (*rw_cb.p_cback)(rw_event, &rw_data); } } if (b_release) GKI_freebuf(p_pkt); if (begin_state != p_t2t->state) { DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s - RW T2T state changed:<%s> -> <%s>", __func__, rw_t2t_get_state_name(begin_state).c_str(), rw_t2t_get_state_name(p_t2t->state).c_str()); } } /******************************************************************************* ** ** Function rw_t2t_conn_cback ** ** Description This callback function receives events/data from NFCC. ** ** Returns none ** *******************************************************************************/ void rw_t2t_conn_cback(uint8_t conn_id, tNFC_CONN_EVT event, tNFC_CONN* p_data) { tRW_T2T_CB* p_t2t = &rw_cb.tcb.t2t; tRW_READ_DATA evt_data; DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("rw_t2t_conn_cback: conn_id=%i, evt=%i", conn_id, event); /* Only handle static conn_id */ if (conn_id != NFC_RF_CONN_ID) { return; } switch (event) { case NFC_CONN_CREATE_CEVT: case NFC_CONN_CLOSE_CEVT: break; case NFC_DEACTIVATE_CEVT: #if (RW_STATS_INCLUDED == TRUE) /* Display stats */ rw_main_log_stats(); #endif /* Stop t2t timer (if started) */ nfc_stop_quick_timer(&p_t2t->t2_timer); /* Free cmd buf for retransmissions */ if (p_t2t->p_cur_cmd_buf) { GKI_freebuf(p_t2t->p_cur_cmd_buf); p_t2t->p_cur_cmd_buf = nullptr; } /* Free cmd buf used to hold command before sector change */ if (p_t2t->p_sec_cmd_buf) { GKI_freebuf(p_t2t->p_sec_cmd_buf); p_t2t->p_sec_cmd_buf = nullptr; } p_t2t->state = RW_T2T_STATE_NOT_ACTIVATED; NFC_SetStaticRfCback(nullptr); break; case NFC_DATA_CEVT: if (p_data != nullptr) { if ((p_data->data.status == NFC_STATUS_OK) || (p_data->data.status == NFC_STATUS_CONTINUE)) { rw_t2t_proc_data(conn_id, &(p_data->data)); break; } else if (p_data->data.p_data != nullptr) { /* Free the response buffer in case of error response */ GKI_freebuf((NFC_HDR*)(p_data->data.p_data)); p_data->data.p_data = nullptr; } } /* Data event with error status...fall through to NFC_ERROR_CEVT case */ FALLTHROUGH_INTENDED; case NFC_ERROR_CEVT: if ((p_t2t->state == RW_T2T_STATE_NOT_ACTIVATED) || (p_t2t->state == RW_T2T_STATE_IDLE) || (p_t2t->state == RW_T2T_STATE_HALT)) { #if (RW_STATS_INCLUDED == TRUE) rw_main_update_trans_error_stats(); #endif /* RW_STATS_INCLUDED */ if (event == NFC_ERROR_CEVT) evt_data.status = (tNFC_STATUS)(*(uint8_t*)p_data); else if (p_data) evt_data.status = p_data->status; else evt_data.status = NFC_STATUS_FAILED; evt_data.p_data = nullptr; tRW_DATA rw_data; rw_data.data = evt_data; (*rw_cb.p_cback)(RW_T2T_INTF_ERROR_EVT, &rw_data); break; } nfc_stop_quick_timer(&p_t2t->t2_timer); #if (RW_STATS_INCLUDED == TRUE) rw_main_update_trans_error_stats(); #endif if (p_t2t->state == RW_T2T_STATE_CHECK_PRESENCE) { if (p_t2t->check_tag_halt) { p_t2t->state = RW_T2T_STATE_HALT; rw_t2t_handle_presence_check_rsp(NFC_STATUS_REJECTED); } else { #ifdef ST21NFC /* Move back to idle state */ rw_t2t_handle_presence_check_rsp(NFC_STATUS_RF_FRAME_CORRUPTED); #else rw_t2t_handle_presence_check_rsp(NFC_STATUS_FAILED); #endif } } else { rw_t2t_process_error(); } break; default: break; } } /******************************************************************************* ** ** Function rw_t2t_send_cmd ** ** Description This function composes a Type 2 Tag command and send it via ** NCI to NFCC. ** ** Returns NFC_STATUS_OK if the command is successfuly sent to NCI ** otherwise, error status ** *******************************************************************************/ tNFC_STATUS rw_t2t_send_cmd(uint8_t opcode, uint8_t* p_dat) { tNFC_STATUS status = NFC_STATUS_FAILED; tRW_T2T_CB* p_t2t = &rw_cb.tcb.t2t; const tT2T_CMD_RSP_INFO* p_cmd_rsp_info = t2t_cmd_to_rsp_info(opcode); NFC_HDR* p_data; uint8_t* p; if (p_cmd_rsp_info) { /* a valid opcode for RW */ p_data = (NFC_HDR*)GKI_getpoolbuf(NFC_RW_POOL_ID); if (p_data) { p_t2t->p_cmd_rsp_info = (tT2T_CMD_RSP_INFO*)p_cmd_rsp_info; p_data->offset = NCI_MSG_OFFSET_SIZE + NCI_DATA_HDR_SIZE; p = (uint8_t*)(p_data + 1) + p_data->offset; UINT8_TO_STREAM(p, opcode); if (p_dat) { ARRAY_TO_STREAM(p, p_dat, (p_cmd_rsp_info->cmd_len - 1)); } p_data->len = p_cmd_rsp_info->cmd_len; /* Indicate first attempt to send command, back up cmd buffer in case * needed for retransmission */ rw_cb.cur_retry = 0; memcpy(p_t2t->p_cur_cmd_buf, p_data, sizeof(NFC_HDR) + p_data->offset + p_data->len); #if (RW_STATS_INCLUDED == TRUE) /* Update stats */ rw_main_update_tx_stats(p_data->len, false); #endif DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf( "%s - RW SENT [%s]:0x%x CMD", __func__, t2t_info_to_str(p_cmd_rsp_info), p_cmd_rsp_info->opcode); status = NFC_SendData(NFC_RF_CONN_ID, p_data); if (status == NFC_STATUS_OK) { nfc_start_quick_timer( &p_t2t->t2_timer, NFC_TTYPE_RW_T2T_RESPONSE, (RW_T2T_TOUT_RESP * QUICK_TIMER_TICKS_PER_SEC) / 1000); } else { LOG(ERROR) << StringPrintf( "%s - T2T NFC Send data failed. state=%s substate=%s ", __func__, rw_t2t_get_state_name(p_t2t->state).c_str(), rw_t2t_get_substate_name(p_t2t->substate).c_str()); } } else { status = NFC_STATUS_NO_BUFFERS; } } return status; } /******************************************************************************* ** ** Function rw_t2t_process_timeout ** ** Description handles timeout event ** ** Returns none ** *******************************************************************************/ void rw_t2t_process_timeout() { tRW_READ_DATA evt_data; tRW_T2T_CB* p_t2t = &rw_cb.tcb.t2t; if (p_t2t->state == RW_T2T_STATE_CHECK_PRESENCE) { if (p_t2t->check_tag_halt) { p_t2t->state = RW_T2T_STATE_HALT; rw_t2t_handle_presence_check_rsp(NFC_STATUS_REJECTED); } else { /* Move back to idle state */ #ifdef ST21NFC rw_t2t_handle_presence_check_rsp(NFC_STATUS_RF_FRAME_CORRUPTED); #else rw_t2t_handle_presence_check_rsp(NFC_STATUS_FAILED); #endif } return; } if (p_t2t->substate == RW_T2T_SUBSTATE_WAIT_SELECT_SECTOR) { p_t2t->sector = p_t2t->select_sector; /* Here timeout is an acknowledgment for successfull sector change */ if (p_t2t->state == RW_T2T_STATE_SELECT_SECTOR) { /* Notify that select sector op is successfull */ rw_t2t_handle_op_complete(); evt_data.status = NFC_STATUS_OK; evt_data.p_data = nullptr; tRW_DATA rw_data; rw_data.data = evt_data; (*rw_cb.p_cback)(RW_T2T_SELECT_CPLT_EVT, &rw_data); } else { /* Resume operation from where we stopped before sector change */ rw_t2t_resume_op(); } } else if (p_t2t->state != RW_T2T_STATE_IDLE) { LOG(ERROR) << StringPrintf("%s - T2T timeout. state=%s ", __func__, rw_t2t_get_state_name(p_t2t->state).c_str()); /* Handle timeout error as no response to the command sent */ rw_t2t_process_error(); } } /******************************************************************************* ** ** Function rw_t2t_process_frame_error ** ** Description handles frame crc error ** ** Returns none ** *******************************************************************************/ static void rw_t2t_process_frame_error(void) { #if (RW_STATS_INCLUDED == TRUE) /* Update stats */ rw_main_update_crc_error_stats(); #endif /* Process the error */ rw_t2t_process_error(); } /******************************************************************************* ** ** Function rw_t2t_process_error ** ** Description Process error including Timeout, Frame error. This function ** will retry atleast till RW_MAX_RETRIES before give up and ** sending negative notification to upper layer ** ** Returns none ** *******************************************************************************/ static void rw_t2t_process_error(void) { tRW_READ_DATA evt_data; tRW_EVENT rw_event; NFC_HDR* p_cmd_buf; tRW_T2T_CB* p_t2t = &rw_cb.tcb.t2t; tT2T_CMD_RSP_INFO* p_cmd_rsp_info = (tT2T_CMD_RSP_INFO*)rw_cb.tcb.t2t.p_cmd_rsp_info; tRW_DETECT_NDEF_DATA ndef_data; DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("State: %u", p_t2t->state); /* Retry sending command if retry-count < max */ if ((!p_t2t->check_tag_halt) && (rw_cb.cur_retry < RW_MAX_RETRIES)) { /* retry sending the command */ rw_cb.cur_retry++; DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s - T2T retransmission attempt %i of %i", __func__, rw_cb.cur_retry, RW_MAX_RETRIES); /* allocate a new buffer for message */ p_cmd_buf = (NFC_HDR*)GKI_getpoolbuf(NFC_RW_POOL_ID); if (p_cmd_buf != nullptr) { memcpy(p_cmd_buf, p_t2t->p_cur_cmd_buf, sizeof(NFC_HDR) + p_t2t->p_cur_cmd_buf->offset + p_t2t->p_cur_cmd_buf->len); #if (RW_STATS_INCLUDED == TRUE) /* Update stats */ rw_main_update_tx_stats(p_cmd_buf->len, true); #endif if (NFC_SendData(NFC_RF_CONN_ID, p_cmd_buf) == NFC_STATUS_OK) { /* Start timer for waiting for response */ nfc_start_quick_timer( &p_t2t->t2_timer, NFC_TTYPE_RW_T2T_RESPONSE, (RW_T2T_TOUT_RESP * QUICK_TIMER_TICKS_PER_SEC) / 1000); return; } } } else { if (p_t2t->check_tag_halt) { DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s - T2T Went to HALT State!", __func__); } else { DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf( "%s - T2T maximum retransmission attempts reached (%i)", __func__, RW_MAX_RETRIES); } } rw_event = rw_t2t_info_to_event(p_cmd_rsp_info); #if (RW_STATS_INCLUDED == TRUE) /* update failure count */ rw_main_update_fail_stats(); #endif if (p_t2t->check_tag_halt) { evt_data.status = NFC_STATUS_REJECTED; p_t2t->state = RW_T2T_STATE_HALT; } else { evt_data.status = NFC_STATUS_TIMEOUT; } if (rw_event == RW_T2T_NDEF_DETECT_EVT) { ndef_data.status = evt_data.status; ndef_data.protocol = NFC_PROTOCOL_T2T; ndef_data.flags = RW_NDEF_FL_UNKNOWN; if (p_t2t->substate == RW_T2T_SUBSTATE_WAIT_READ_LOCKS) ndef_data.flags = RW_NDEF_FL_FORMATED; ndef_data.max_size = 0; ndef_data.cur_size = 0; /* If not Halt move to idle state */ rw_t2t_handle_op_complete(); tRW_DATA rw_data; rw_data.ndef = ndef_data; (*rw_cb.p_cback)(rw_event, &rw_data); } else { evt_data.p_data = nullptr; /* If activated and not Halt move to idle state */ if (p_t2t->state != RW_T2T_STATE_NOT_ACTIVATED) rw_t2t_handle_op_complete(); p_t2t->substate = RW_T2T_SUBSTATE_NONE; tRW_DATA rw_data; rw_data.data = evt_data; (*rw_cb.p_cback)(rw_event, &rw_data); } } /***************************************************************************** ** ** Function rw_t2t_handle_presence_check_rsp ** ** Description Handle response to presence check ** ** Returns Nothing ** *****************************************************************************/ void rw_t2t_handle_presence_check_rsp(tNFC_STATUS status) { tRW_DATA rw_data; /* Notify, Tag is present or not */ rw_data.data.status = status; rw_t2t_handle_op_complete(); (*rw_cb.p_cback)(RW_T2T_PRESENCE_CHECK_EVT, &rw_data); } /******************************************************************************* ** ** Function rw_t2t_resume_op ** ** Description This function will continue operation after moving to new ** sector ** ** Returns tNFC_STATUS ** *******************************************************************************/ static void rw_t2t_resume_op(void) { tRW_T2T_CB* p_t2t = &rw_cb.tcb.t2t; tRW_READ_DATA evt_data; NFC_HDR* p_cmd_buf; tRW_EVENT event; const tT2T_CMD_RSP_INFO* p_cmd_rsp_info = (tT2T_CMD_RSP_INFO*)rw_cb.tcb.t2t.p_cmd_rsp_info; uint8_t* p; /* Move back to the substate where we were before changing sector */ p_t2t->substate = p_t2t->prev_substate; p = (uint8_t*)(p_t2t->p_sec_cmd_buf + 1) + p_t2t->p_sec_cmd_buf->offset; p_cmd_rsp_info = t2t_cmd_to_rsp_info((uint8_t)*p); p_t2t->p_cmd_rsp_info = (tT2T_CMD_RSP_INFO*)p_cmd_rsp_info; /* allocate a new buffer for message */ p_cmd_buf = (NFC_HDR*)GKI_getpoolbuf(NFC_RW_POOL_ID); if (p_cmd_buf != nullptr) { memcpy(p_cmd_buf, p_t2t->p_sec_cmd_buf, sizeof(NFC_HDR) + p_t2t->p_sec_cmd_buf->offset + p_t2t->p_sec_cmd_buf->len); memcpy(p_t2t->p_cur_cmd_buf, p_t2t->p_sec_cmd_buf, sizeof(NFC_HDR) + p_t2t->p_sec_cmd_buf->offset + p_t2t->p_sec_cmd_buf->len); #if (RW_STATS_INCLUDED == TRUE) /* Update stats */ rw_main_update_tx_stats(p_cmd_buf->len, true); #endif if (NFC_SendData(NFC_RF_CONN_ID, p_cmd_buf) == NFC_STATUS_OK) { /* Start timer for waiting for response */ nfc_start_quick_timer( &p_t2t->t2_timer, NFC_TTYPE_RW_T2T_RESPONSE, (RW_T2T_TOUT_RESP * QUICK_TIMER_TICKS_PER_SEC) / 1000); } else { /* failure - could not send buffer */ evt_data.p_data = nullptr; evt_data.status = NFC_STATUS_FAILED; event = rw_t2t_info_to_event(p_cmd_rsp_info); rw_t2t_handle_op_complete(); tRW_DATA rw_data; rw_data.data = evt_data; (*rw_cb.p_cback)(event, &rw_data); } } } /******************************************************************************* ** ** Function rw_t2t_sector_change ** ** Description This function issues Type 2 Tag SECTOR-SELECT command ** packet 1. ** ** Returns tNFC_STATUS ** *******************************************************************************/ tNFC_STATUS rw_t2t_sector_change(uint8_t sector) { tNFC_STATUS status; NFC_HDR* p_data; uint8_t* p; tRW_T2T_CB* p_t2t = &rw_cb.tcb.t2t; p_data = (NFC_HDR*)GKI_getpoolbuf(NFC_RW_POOL_ID); if (p_data == nullptr) { LOG(ERROR) << StringPrintf("rw_t2t_sector_change - No buffer"); return (NFC_STATUS_NO_BUFFERS); } p_data->offset = NCI_MSG_OFFSET_SIZE + NCI_DATA_HDR_SIZE; p = (uint8_t*)(p_data + 1) + p_data->offset; UINT8_TO_BE_STREAM(p, sector); UINT8_TO_BE_STREAM(p, 0x00); UINT8_TO_BE_STREAM(p, 0x00); UINT8_TO_BE_STREAM(p, 0x00); p_data->len = 4; status = NFC_SendData(NFC_RF_CONN_ID, p_data); if (status == NFC_STATUS_OK) { /* Passive rsp command and suppose not to get response to this command */ p_t2t->p_cmd_rsp_info = nullptr; p_t2t->substate = RW_T2T_SUBSTATE_WAIT_SELECT_SECTOR; DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("rw_t2t_sector_change Sent Second Command"); nfc_start_quick_timer( &p_t2t->t2_timer, NFC_TTYPE_RW_T2T_RESPONSE, (RW_T2T_SEC_SEL_TOUT_RESP * QUICK_TIMER_TICKS_PER_SEC) / 1000); } else { LOG(ERROR) << StringPrintf( "rw_t2t_sector_change Send failed at rw_t2t_send_cmd, error: %u", status); } return status; } /******************************************************************************* ** ** Function rw_t2t_read ** ** Description This function issues Type 2 Tag READ command for the ** specified block. If the specified block is in different ** sector then it first sends command to move to new sector ** and after the tag moves to new sector it issues the read ** command for the block. ** ** Returns tNFC_STATUS ** *******************************************************************************/ tNFC_STATUS rw_t2t_read(uint16_t block) { tNFC_STATUS status; uint8_t* p; tRW_T2T_CB* p_t2t = &rw_cb.tcb.t2t; uint8_t sector_byte2[1]; uint8_t read_cmd[1]; read_cmd[0] = block % T2T_BLOCKS_PER_SECTOR; if (p_t2t->sector != block / T2T_BLOCKS_PER_SECTOR) { sector_byte2[0] = 0xFF; /* First Move to new sector before sending Read command */ status = rw_t2t_send_cmd(T2T_CMD_SEC_SEL, sector_byte2); if (status == NFC_STATUS_OK) { /* Prepare command that needs to be sent after sector change op is * completed */ p_t2t->select_sector = (uint8_t)(block / T2T_BLOCKS_PER_SECTOR); p_t2t->p_sec_cmd_buf->offset = NCI_MSG_OFFSET_SIZE + NCI_DATA_HDR_SIZE; p = (uint8_t*)(p_t2t->p_sec_cmd_buf + 1) + p_t2t->p_sec_cmd_buf->offset; UINT8_TO_BE_STREAM(p, T2T_CMD_READ); UINT8_TO_BE_STREAM(p, read_cmd[0]); p_t2t->p_sec_cmd_buf->len = 2; p_t2t->block_read = block; /* Backup the current substate to move back to this substate after * changing sector */ p_t2t->prev_substate = p_t2t->substate; p_t2t->substate = RW_T2T_SUBSTATE_WAIT_SELECT_SECTOR_SUPPORT; return NFC_STATUS_OK; } return NFC_STATUS_FAILED; } /* Send Read command as sector change is not needed */ status = rw_t2t_send_cmd(T2T_CMD_READ, (uint8_t*)read_cmd); if (status == NFC_STATUS_OK) { p_t2t->block_read = block; DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("rw_t2t_read Sent Command for Block: %u", block); } return status; } /******************************************************************************* ** ** Function rw_t2t_write ** ** Description This function issues Type 2 Tag WRITE command for the ** specified block. If the specified block is in different ** sector then it first sends command to move to new sector ** and after the tag moves to new sector it issues the write ** command for the block. ** ** Returns tNFC_STATUS ** *******************************************************************************/ tNFC_STATUS rw_t2t_write(uint16_t block, uint8_t* p_write_data) { tNFC_STATUS status; uint8_t* p; tRW_T2T_CB* p_t2t = &rw_cb.tcb.t2t; uint8_t write_cmd[T2T_WRITE_DATA_LEN + 1]; uint8_t sector_byte2[1]; p_t2t->block_written = block; write_cmd[0] = (uint8_t)(block % T2T_BLOCKS_PER_SECTOR); memcpy(&write_cmd[1], p_write_data, T2T_WRITE_DATA_LEN); if (p_t2t->sector != block / T2T_BLOCKS_PER_SECTOR) { sector_byte2[0] = 0xFF; /* First Move to new sector before sending Write command */ status = rw_t2t_send_cmd(T2T_CMD_SEC_SEL, sector_byte2); if (status == NFC_STATUS_OK) { /* Prepare command that needs to be sent after sector change op is * completed */ p_t2t->select_sector = (uint8_t)(block / T2T_BLOCKS_PER_SECTOR); p_t2t->p_sec_cmd_buf->offset = NCI_MSG_OFFSET_SIZE + NCI_DATA_HDR_SIZE; p = (uint8_t*)(p_t2t->p_sec_cmd_buf + 1) + p_t2t->p_sec_cmd_buf->offset; UINT8_TO_BE_STREAM(p, T2T_CMD_WRITE); memcpy(p, write_cmd, T2T_WRITE_DATA_LEN + 1); p_t2t->p_sec_cmd_buf->len = 2 + T2T_WRITE_DATA_LEN; p_t2t->block_written = block; /* Backup the current substate to move back to this substate after * changing sector */ p_t2t->prev_substate = p_t2t->substate; p_t2t->substate = RW_T2T_SUBSTATE_WAIT_SELECT_SECTOR_SUPPORT; return NFC_STATUS_OK; } return NFC_STATUS_FAILED; } /* Send Write command as sector change is not needed */ status = rw_t2t_send_cmd(T2T_CMD_WRITE, write_cmd); if (status == NFC_STATUS_OK) { DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("rw_t2t_write Sent Command for Block: %u", block); } return status; } /******************************************************************************* ** ** Function rw_t2t_select ** ** Description This function selects type 2 tag. ** ** Returns Tag selection status ** *******************************************************************************/ tNFC_STATUS rw_t2t_select(void) { tRW_T2T_CB* p_t2t = &rw_cb.tcb.t2t; p_t2t->state = RW_T2T_STATE_IDLE; p_t2t->ndef_status = T2T_NDEF_NOT_DETECTED; /* Alloc cmd buf for retransmissions */ if (p_t2t->p_cur_cmd_buf == nullptr) { p_t2t->p_cur_cmd_buf = (NFC_HDR*)GKI_getpoolbuf(NFC_RW_POOL_ID); if (p_t2t->p_cur_cmd_buf == nullptr) { LOG(ERROR) << StringPrintf( "rw_t2t_select: unable to allocate buffer for retransmission"); return (NFC_STATUS_FAILED); } } /* Alloc cmd buf for holding a command untill sector changes */ if (p_t2t->p_sec_cmd_buf == nullptr) { p_t2t->p_sec_cmd_buf = (NFC_HDR*)GKI_getpoolbuf(NFC_RW_POOL_ID); if (p_t2t->p_sec_cmd_buf == nullptr) { LOG(ERROR) << StringPrintf( "rw_t2t_select: unable to allocate buffer used during sector change"); return (NFC_STATUS_FAILED); } } NFC_SetStaticRfCback(rw_t2t_conn_cback); rw_t2t_handle_op_complete(); p_t2t->check_tag_halt = false; return NFC_STATUS_OK; } /***************************************************************************** ** ** Function rw_t2t_handle_op_complete ** ** Description Reset to IDLE state ** ** Returns Nothing ** *****************************************************************************/ void rw_t2t_handle_op_complete(void) { tRW_T2T_CB* p_t2t = &rw_cb.tcb.t2t; DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s - p_t2t->state: %d", __func__, p_t2t->state); if ((p_t2t->state == RW_T2T_STATE_READ_NDEF) || (p_t2t->state == RW_T2T_STATE_WRITE_NDEF)) { p_t2t->b_read_data = false; } if (p_t2t->state != RW_T2T_STATE_HALT) p_t2t->state = RW_T2T_STATE_IDLE; p_t2t->substate = RW_T2T_SUBSTATE_NONE; return; } /***************************************************************************** ** ** Function RW_T2tPresenceCheck ** ** Description ** Check if the tag is still in the field. ** ** The RW_T2T_PRESENCE_CHECK_EVT w/ status is used to indicate presence ** or non-presence. ** ** Returns ** NFC_STATUS_OK, if raw data frame sent ** NFC_STATUS_NO_BUFFERS: unable to allocate a buffer for this operation ** NFC_STATUS_FAILED: other error ** *****************************************************************************/ tNFC_STATUS RW_T2tPresenceCheck(void) { tNFC_STATUS retval = NFC_STATUS_OK; tRW_DATA evt_data; tRW_CB* p_rw_cb = &rw_cb; uint8_t sector_blk = 0; /* block 0 of current sector */ DLOG_IF(INFO, nfc_debug_enabled) << __func__; /* If RW_SelectTagType was not called (no conn_callback) return failure */ if (!p_rw_cb->p_cback) { retval = NFC_STATUS_FAILED; } /* If we are not activated, then RW_T2T_PRESENCE_CHECK_EVT status=FAIL */ else if (p_rw_cb->tcb.t2t.state == RW_T2T_STATE_NOT_ACTIVATED) { evt_data.status = NFC_STATUS_FAILED; (*p_rw_cb->p_cback)(RW_T2T_PRESENCE_CHECK_EVT, &evt_data); } /* If command is pending, assume tag is still present */ else if (p_rw_cb->tcb.t2t.state != RW_T2T_STATE_IDLE) { evt_data.status = NFC_STATUS_OK; (*p_rw_cb->p_cback)(RW_T2T_PRESENCE_CHECK_EVT, &evt_data); } else { /* IDLE state: send a READ command to block 0 of the current sector */ retval = rw_t2t_send_cmd(T2T_CMD_READ, &sector_blk); if (retval == NFC_STATUS_OK) { p_rw_cb->tcb.t2t.state = RW_T2T_STATE_CHECK_PRESENCE; } } return (retval); } /******************************************************************************* ** ** Function RW_T2tRead ** ** Description This function issues the Type 2 Tag READ command. When the ** operation is complete the callback function will be called ** with a RW_T2T_READ_EVT. ** ** Returns tNFC_STATUS ** *******************************************************************************/ tNFC_STATUS RW_T2tRead(uint16_t block) { tRW_T2T_CB* p_t2t = &rw_cb.tcb.t2t; tNFC_STATUS status; if (p_t2t->state != RW_T2T_STATE_IDLE) { LOG(ERROR) << StringPrintf( "%s - Error: Type 2 tag not activated or Busy - State: %u", __func__, p_t2t->state); return (NFC_STATUS_FAILED); } status = rw_t2t_read(block); if (status == NFC_STATUS_OK) { p_t2t->state = RW_T2T_STATE_READ; DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("RW_T2tRead Sent Read command"); } return status; } /******************************************************************************* ** ** Function RW_T2tWrite ** ** Description This function issues the Type 2 Tag WRITE command. When the ** operation is complete the callback function will be called ** with a RW_T2T_WRITE_EVT. ** ** p_new_bytes points to the array of 4 bytes to be written ** ** Returns tNFC_STATUS ** *******************************************************************************/ tNFC_STATUS RW_T2tWrite(uint16_t block, uint8_t* p_write_data) { tRW_T2T_CB* p_t2t = &rw_cb.tcb.t2t; tNFC_STATUS status; if (p_t2t->state != RW_T2T_STATE_IDLE) { LOG(ERROR) << StringPrintf( "%s - Error: Type 2 tag not activated or Busy - State: %u", __func__, p_t2t->state); return (NFC_STATUS_FAILED); } status = rw_t2t_write(block, p_write_data); if (status == NFC_STATUS_OK) { p_t2t->state = RW_T2T_STATE_WRITE; if (block < T2T_FIRST_DATA_BLOCK) p_t2t->b_read_hdr = false; else if (block < (T2T_FIRST_DATA_BLOCK + T2T_READ_BLOCKS)) p_t2t->b_read_data = false; DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("RW_T2tWrite Sent Write command"); } return status; } /******************************************************************************* ** ** Function RW_T2tSectorSelect ** ** Description This function issues the Type 2 Tag SECTOR-SELECT command ** packet 1. If a NACK is received as the response, the ** callback function will be called with a ** RW_T2T_SECTOR_SELECT_EVT. If an ACK is received as the ** response, the command packet 2 with the given sector number ** is sent to the peer device. When the response for packet 2 ** is received, the callback function will be called with a ** RW_T2T_SECTOR_SELECT_EVT. ** ** A sector is 256 contiguous blocks (1024 bytes). ** ** Returns tNFC_STATUS ** *******************************************************************************/ tNFC_STATUS RW_T2tSectorSelect(uint8_t sector) { tNFC_STATUS status; tRW_T2T_CB* p_t2t = &rw_cb.tcb.t2t; uint8_t sector_byte2[1]; if (p_t2t->state != RW_T2T_STATE_IDLE) { LOG(ERROR) << StringPrintf( "%s - Error: Type 2 tag not activated or Busy - State: %u", __func__, p_t2t->state); return (NFC_STATUS_FAILED); } if (sector >= T2T_MAX_SECTOR) { LOG(ERROR) << StringPrintf( "RW_T2tSectorSelect - Invalid sector: %u, T2 Max supported sector " "value: %u", sector, T2T_MAX_SECTOR - 1); return (NFC_STATUS_FAILED); } sector_byte2[0] = 0xFF; status = rw_t2t_send_cmd(T2T_CMD_SEC_SEL, sector_byte2); if (status == NFC_STATUS_OK) { p_t2t->state = RW_T2T_STATE_SELECT_SECTOR; p_t2t->select_sector = sector; p_t2t->substate = RW_T2T_SUBSTATE_WAIT_SELECT_SECTOR_SUPPORT; DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("RW_T2tSectorSelect Sent Sector select first command"); } return status; } /******************************************************************************* ** ** Function rw_t2t_get_state_name ** ** Description This function returns the state name. ** ** NOTE conditionally compiled to save memory. ** ** Returns string ** *******************************************************************************/ static std::string rw_t2t_get_state_name(uint8_t state) { switch (state) { case RW_T2T_STATE_NOT_ACTIVATED: return "NOT_ACTIVATED"; case RW_T2T_STATE_IDLE: return "IDLE"; case RW_T2T_STATE_READ: return "APP_READ"; case RW_T2T_STATE_WRITE: return "APP_WRITE"; case RW_T2T_STATE_SELECT_SECTOR: return "SECTOR_SELECT"; case RW_T2T_STATE_DETECT_TLV: return "TLV_DETECT"; case RW_T2T_STATE_READ_NDEF: return "READ_NDEF"; case RW_T2T_STATE_WRITE_NDEF: return "WRITE_NDEF"; case RW_T2T_STATE_SET_TAG_RO: return "SET_TAG_RO"; case RW_T2T_STATE_CHECK_PRESENCE: return "CHECK_PRESENCE"; default: return "???? UNKNOWN STATE"; } } /******************************************************************************* ** ** Function rw_t2t_get_substate_name ** ** Description This function returns the substate name. ** ** NOTE conditionally compiled to save memory. ** ** Returns pointer to the name ** *******************************************************************************/ static std::string rw_t2t_get_substate_name(uint8_t substate) { switch (substate) { case RW_T2T_SUBSTATE_NONE: return "RW_T2T_SUBSTATE_NONE"; case RW_T2T_SUBSTATE_WAIT_SELECT_SECTOR_SUPPORT: return "RW_T2T_SUBSTATE_WAIT_SELECT_SECTOR_SUPPORT"; case RW_T2T_SUBSTATE_WAIT_SELECT_SECTOR: return "RW_T2T_SUBSTATE_WAIT_SELECT_SECTOR"; case RW_T2T_SUBSTATE_WAIT_READ_CC: return "RW_T2T_SUBSTATE_WAIT_READ_CC"; case RW_T2T_SUBSTATE_WAIT_TLV_DETECT: return "RW_T2T_SUBSTATE_WAIT_TLV_DETECT"; case RW_T2T_SUBSTATE_WAIT_FIND_LEN_FIELD_LEN: return "RW_T2T_SUBSTATE_WAIT_FIND_LEN_FIELD_LEN"; case RW_T2T_SUBSTATE_WAIT_READ_TLV_LEN0: return "RW_T2T_SUBSTATE_WAIT_READ_TLV_LEN0"; case RW_T2T_SUBSTATE_WAIT_READ_TLV_LEN1: return "RW_T2T_SUBSTATE_WAIT_READ_TLV_LEN1"; case RW_T2T_SUBSTATE_WAIT_READ_TLV_VALUE: return "RW_T2T_SUBSTATE_WAIT_READ_TLV_VALUE"; case RW_T2T_SUBSTATE_WAIT_READ_LOCKS: return "RW_T2T_SUBSTATE_WAIT_READ_LOCKS"; case RW_T2T_SUBSTATE_WAIT_READ_NDEF_FIRST_BLOCK: return "RW_T2T_SUBSTATE_WAIT_READ_NDEF_FIRST_BLOCK"; case RW_T2T_SUBSTATE_WAIT_READ_NDEF_LAST_BLOCK: return "RW_T2T_SUBSTATE_WAIT_READ_NDEF_LAST_BLOCK"; case RW_T2T_SUBSTATE_WAIT_READ_TERM_TLV_BLOCK: return "RW_T2T_SUBSTATE_WAIT_READ_TERM_TLV_BLOCK"; case RW_T2T_SUBSTATE_WAIT_READ_NDEF_NEXT_BLOCK: return "RW_T2T_SUBSTATE_WAIT_READ_NDEF_NEXT_BLOCK"; case RW_T2T_SUBSTATE_WAIT_WRITE_NDEF_NEXT_BLOCK: return "RW_T2T_SUBSTATE_WAIT_WRITE_NDEF_NEXT_BLOCK"; case RW_T2T_SUBSTATE_WAIT_WRITE_NDEF_LAST_BLOCK: return "RW_T2T_SUBSTATE_WAIT_WRITE_NDEF_LAST_BLOCK"; case RW_T2T_SUBSTATE_WAIT_READ_NDEF_LEN_BLOCK: return "RW_T2T_SUBSTATE_WAIT_READ_NDEF_LEN_BLOCK"; case RW_T2T_SUBSTATE_WAIT_WRITE_NDEF_LEN_BLOCK: return "RW_T2T_SUBSTATE_WAIT_WRITE_NDEF_LEN_BLOCK"; case RW_T2T_SUBSTATE_WAIT_WRITE_NDEF_LEN_NEXT_BLOCK: return "RW_T2T_SUBSTATE_WAIT_WRITE_NDEF_LEN_NEXT_BLOCK"; case RW_T2T_SUBSTATE_WAIT_WRITE_TERM_TLV_CMPLT: return "RW_T2T_SUBSTATE_WAIT_WRITE_TERM_TLV_CMPLT"; default: return "???? UNKNOWN SUBSTATE"; } }
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. #pragma once #include "dirent.h" #include <sched.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <dlfcn.h> #include <fcntl.h> #include <unistd.h> #include <limits.h> #include <stddef.h> #include <sys/sendfile.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/time.h> #include <sys/types.h> #include <sys/uio.h> #include <sys/vfs.h> #include <utime.h> #include <ostream> #include <sstream> #include <chrono> #include <mutex> #include <unordered_set> #include <unordered_map> #include "Sandbox.hpp" #include "SandboxedPip.hpp" #include "utils.h" /* * We want to compile against glibc 2.17 so that we are compatible with a broad range of Linux distributions. (e.g., starting from CentOS7) * * Compiling against that version of glibc does not prevent us from interposing the system calls that are present only in newer versions * (e.g., copy_file_range), as long as we provide appropriate INTERPOSE definitions for those system calls in detours.cpp. */ #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 17) #warning This library must support glibc 2.17. Please compile against at most glibc 2.17 before publishing a new version of this library. #endif /* * This header is compiled into two different libraries: libDetours.so and libAudit.so. * * When compiling libDetours.so, the ENABLE_INTERPOSING macro is defined, otherwise it is not. * * When ENABLE_INTERPOSING is defined, we do not need static declarations for the system calls of interest, because * we resolve those dynamically via `dlsym(name)` calls. That means that, even though we compile libDetours.so against * glibc 2.17 (where, for example, `copy_file_range` is not defined), when our libDetours.so is loaded into a process that * runs against a newer version of glibc, `dlsym("copy_file_range")` will still return a valid function pointer and we * will be able to interpose system calls that are not necessarily present in the glibc 2.17. * * When ENABLE_INTERPOSING is not defined, we need static definitions for all the system calls we reference. Therefore, * here we need to add fake definitions for the calls that we want to reference (because of libDetours) which are not present * in glibc we are compiling against. Adding empty definitions here is fine as long as in our code we never explicitly call * the corresponding real_<missing-syscall> instance methods in the BxlObserver class. */ #ifndef ENABLE_INTERPOSING // Library support for copy_file_range was added in glibc 2.27 (https://man7.org/linux/man-pages/man2/copy_file_range.2.html) #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 27) inline ssize_t copy_file_range(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags) { return -1; } #endif // Library support for pwritev2 was added in glibc 2.26 (https://man7.org/linux/man-pages/man2/pwritev2.2.html) #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 26) inline ssize_t pwritev2(int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags) { return -1; } #endif #endif using namespace std; extern const char *__progname; // CODESYNC: Public/Src/Engine/Processes/SandboxConnectionLinuxDetours.cs #define BxlEnvFamPath "__BUILDXL_FAM_PATH" #define BxlEnvLogPath "__BUILDXL_LOG_PATH" #define BxlEnvRootPid "__BUILDXL_ROOT_PID" #define BxlEnvDetoursPath "__BUILDXL_DETOURS_PATH" static const char LD_PRELOAD_ENV_VAR_PREFIX[] = "LD_PRELOAD="; #define ARRAYSIZE(arr) (sizeof(arr)/sizeof(arr[0])) #ifdef ENABLE_INTERPOSING #define GEN_FN_DEF_REAL(ret, name, ...) \ typedef ret (*fn_real_##name)(__VA_ARGS__); \ const fn_real_##name real_##name = (fn_real_##name)dlsym(RTLD_NEXT, #name); #define MAKE_BODY(B) \ B \ } // It's important to have an option to bail out early, *before* // the call to BxlObserver::GetInstance() because we might not // have the process initialized far enough for that call to succeed. #define INTERPOSE_SOMETIMES(ret, name, short_circuit_check, ...) \ DLL_EXPORT ret name(__VA_ARGS__) { \ short_circuit_check \ BxlObserver *bxl = BxlObserver::GetInstance(); \ BXL_LOG_DEBUG(bxl, "Intercepted %s", #name); \ MAKE_BODY #define INTERPOSE(ret, name, ...) \ INTERPOSE_SOMETIMES(ret, name, ;, __VA_ARGS__) #else #define GEN_FN_DEF_REAL(ret, name, ...) \ typedef ret (*fn_real_##name)(__VA_ARGS__); \ const fn_real_##name real_##name = (fn_real_##name)name; #define IGNORE_BODY(B) #define INTERPOSE(ret, name, ...) IGNORE_BODY #endif #define GEN_FN_DEF(ret, name, ...) \ GEN_FN_DEF_REAL(ret, name, __VA_ARGS__) \ template<typename ...TArgs> result_t<ret> fwd_##name(TArgs&& ...args) \ { \ ret result = real_##name(std::forward<TArgs>(args)...); \ result_t<ret> return_value(result); \ LOG_DEBUG("Forwarded syscall %s (errno: %d)", \ RenderSyscall(#name, result, std::forward<TArgs>(args)...).c_str(), \ return_value.get_errno()); \ return return_value; \ } \ template<typename ...TArgs> ret check_and_fwd_##name(AccessCheckResult &check, ret error_val, TArgs&& ...args) \ { \ if (should_deny(check)) \ { \ errno = EPERM; \ return error_val; \ } \ else \ { \ return fwd_##name(args...).restore(); \ } \ } #define _fatal(fmt, ...) do { real_fprintf(stderr, "(%s) " fmt "\n", __func__, __VA_ARGS__); _exit(1); } while (0) #define fatal(msg) _fatal("%s", msg) /** * Wraps the result of a syscall together with the current 'errno'. * * When 'restore' is called, if allowed, 'errno' is reset back to * the value that was captured in the constructor and the captured result is returned; * otherwise 'errno' is set to EPERM and the error value is returned. */ template <typename T> class result_t final { private: int my_errno_; T result_; public: result_t(T result) : result_(result), my_errno_(errno) {} /** Returns the remembered result and restores 'errno' to the value captured in the constructor. */ inline T restore() { errno = my_errno_; return result_; } /** Returns the remembered result. */ inline T get() { return result_; } /** Returns the remembered errno. */ inline int get_errno() { return my_errno_; } }; /** * Singleton class responsible for reporting accesses. * * Accesses are observed by intercepting syscalls. * * Accesses are reported to a file (can be a regular file or a FIFO) * at the location specified by the FileAccessManifest. */ class BxlObserver final { private: BxlObserver(); ~BxlObserver() { disposed_ = true; } BxlObserver(const BxlObserver&) = delete; BxlObserver& operator = (const BxlObserver&) = delete; volatile int disposed_; int rootPid_; char progFullPath_[PATH_MAX]; char logFile_[PATH_MAX]; char detoursLibFullPath_[PATH_MAX]; std::timed_mutex cacheMtx_; std::unordered_map<es_event_type_t, std::unordered_set<std::string>> cache_; // In a typical case, a process will not have more than 1024 open file descriptors at a time. // File descriptors start at 3 (1 and 2 are reserved for stdout and stderr). // Whenever a new file descriptor is created, the smallest available positive integer is assigned to it. // Whenever a file descriptor is closed, its value is returned to the pool and will be used for new ones. // Setting the size of this table to 1024 should accommodate most of the common cases. // File descriptors can be greater than 1024, and if that happens we just won't cache their paths. static const int MAX_FD = 1024; std::string fdTable_[MAX_FD]; std::string empty_str_; std::shared_ptr<SandboxedPip> pip_; std::shared_ptr<SandboxedProcess> process_; Sandbox *sandbox_; void InitFam(); void InitLogFile(); void InitDetoursLibPath(); bool Send(const char *buf, size_t bufsiz); bool IsCacheHit(es_event_type_t event, const string &path, const string &secondPath); char** ensure_env_value_with_log(char *const envp[], char const *envName); ssize_t read_path_for_fd(int fd, char *buf, size_t bufsiz); bool IsMonitoringChildProcesses() const { return !pip_ || CheckMonitorChildProcesses(pip_->GetFamFlags()); } inline bool IsValid() const { return sandbox_ != NULL; } inline bool IsEnabled() const { return // successfully initialized IsValid() && // NOT (child processes should break away AND this is a child process) !(pip_->AllowChildProcessesToBreakAway() && getpid() != rootPid_); } void PrintArgs(std::stringstream& str, bool isFirst) { } template<typename TFirst, typename ...TRest> void PrintArgs(std::stringstream& str, bool isFirst, TFirst first, const TRest& ...rest) { if (!isFirst) str << ", "; str << first; PrintArgs(str, false, rest...); } template<typename TRet, typename ...TArgs> std::string RenderSyscall(const char *syscallName, const TRet& retVal, const TArgs& ...args) { std::stringstream str; str << syscallName << "("; PrintArgs(str, true, args...); str << ") = " << retVal; return str.str(); } void resolve_path(char *fullpath, bool followFinalSymlink); static BxlObserver *sInstance; static AccessCheckResult sNotChecked; #if _DEBUG #define BXL_LOG_DEBUG(bxl, fmt, ...) if (bxl->LogDebugEnabled()) bxl->LogDebug("[%s:%d] " fmt "\n", __progname, getpid(), __VA_ARGS__); #else #define BXL_LOG_DEBUG(bxl, fmt, ...) #endif #define LOG_DEBUG(fmt, ...) BXL_LOG_DEBUG(this, fmt, __VA_ARGS__) public: static BxlObserver* GetInstance(); bool SendReport(AccessReport &report); char** ensureEnvs(char *const envp[]); const char* GetProgramPath() { return progFullPath_; } const char* GetReportsPath() { int len; return IsValid() ? pip_->GetReportsPath(&len) : NULL; } const char* GetDetoursLibPath() { return detoursLibFullPath_; } void report_exec(const char *syscallName, const char *procName, const char *file); void report_audit_objopen(const char *fullpath) { IOEvent event(ES_EVENT_TYPE_NOTIFY_OPEN, ES_ACTION_TYPE_NOTIFY, fullpath, progFullPath_, S_IFREG); report_access("la_objopen", event, /* checkCache */ true); } AccessCheckResult report_access(const char *syscallName, IOEvent &event, bool checkCache = true); AccessCheckResult report_access(const char *syscallName, es_event_type_t eventType, const char *pathname, int oflags = 0); AccessCheckResult report_access(const char *syscallName, es_event_type_t eventType, const std::string &reportPath, const std::string &secondPath); AccessCheckResult report_access_fd(const char *syscallName, es_event_type_t eventType, int fd); AccessCheckResult report_access_at(const char *syscallName, es_event_type_t eventType, int dirfd, const char *pathname, int oflags = 0); void reset_fd_table_entry(int fd); std::string fd_to_path(int fd); std::string normalize_path_at(int dirfd, const char *pathname, int oflags = 0); inline bool LogDebugEnabled() { return logFile_ && *logFile_; } inline void LogDebug(const char *fmt, ...) { if (LogDebugEnabled()) { FILE* f = real_fopen(logFile_, "a"); if (f) { va_list args; va_start(args, fmt); real_vfprintf(f, fmt, args); va_end(args); real_fclose(f); } } } mode_t get_mode(const char *path) { struct stat buf; return real___lxstat(1, path, &buf) == 0 ? buf.st_mode : 0; } std::string normalize_path(const char *pathname, int oflags = 0) { return normalize_path_at(AT_FDCWD, pathname, oflags); } std::string normalize_fd(int fd) { return normalize_path_at(fd, NULL); } bool IsFailingUnexpectedAccesses() { return CheckFailUnexpectedFileAccesses(pip_->GetFamFlags()); } /** * Returns whether the given access should be denied. * * This is true when * - the given access is not permitted * - the sandbox is configured to deny accesses that are not permitted */ bool should_deny(AccessCheckResult &check) { return IsEnabled() && check.ShouldDenyAccess() && IsFailingUnexpectedAccesses(); } GEN_FN_DEF(void*, dlopen, const char *filename, int flags); GEN_FN_DEF(int, dlclose, void *handle); GEN_FN_DEF(pid_t, fork, void); GEN_FN_DEF(int, clone, int (*fn)(void *), void *child_stack, int flags, void *arg, ... /* pid_t *ptid, void *newtls, pid_t *ctid */ ); GEN_FN_DEF_REAL(void, _exit, int); GEN_FN_DEF(int, fexecve, int, char *const[], char *const[]); GEN_FN_DEF(int, execv, const char *, char *const[]); GEN_FN_DEF(int, execve, const char *, char *const[], char *const[]); GEN_FN_DEF(int, execvp, const char *, char *const[]); GEN_FN_DEF(int, execvpe, const char *, char *const[], char *const[]); GEN_FN_DEF(int, __lxstat, int, const char *, struct stat *); GEN_FN_DEF(int, __lxstat64, int, const char*, struct stat64*); GEN_FN_DEF(int, __xstat, int, const char *, struct stat *); GEN_FN_DEF(int, __xstat64, int, const char*, struct stat64*); GEN_FN_DEF(int, __fxstat, int, int, struct stat*); GEN_FN_DEF(int, __fxstatat, int, int, const char*, struct stat*, int);; GEN_FN_DEF(int, __fxstat64, int, int, struct stat64*); GEN_FN_DEF(int, __fxstatat64, int, int, const char*, struct stat64*, int); GEN_FN_DEF(FILE*, fdopen, int, const char *); GEN_FN_DEF(FILE*, fopen, const char *, const char *); GEN_FN_DEF(FILE*, fopen64, const char *, const char *); GEN_FN_DEF(FILE*, freopen, const char *, const char *, FILE *); GEN_FN_DEF(FILE*, freopen64, const char *, const char *, FILE *); GEN_FN_DEF(size_t, fread, void*, size_t, size_t, FILE*); GEN_FN_DEF(size_t, fwrite, const void*, size_t, size_t, FILE*); GEN_FN_DEF(int, fputc, int c, FILE *stream); GEN_FN_DEF(int, fputs, const char *s, FILE *stream); GEN_FN_DEF(int, putc, int c, FILE *stream); GEN_FN_DEF(int, putchar, int c); GEN_FN_DEF(int, puts, const char *s); GEN_FN_DEF(int, access, const char *, int); GEN_FN_DEF(int, faccessat, int, const char *, int, int); GEN_FN_DEF(int, creat, const char *, mode_t); GEN_FN_DEF(int, open64, const char *, int, mode_t); GEN_FN_DEF(int, open, const char *, int, mode_t); GEN_FN_DEF(int, openat, int, const char *, int, mode_t); GEN_FN_DEF(ssize_t, write, int, const void*, size_t); GEN_FN_DEF(ssize_t, writev, int fd, const struct iovec *iov, int iovcnt); GEN_FN_DEF(ssize_t, pwritev, int fd, const struct iovec *iov, int iovcnt, off_t offset); GEN_FN_DEF(ssize_t, pwritev2, int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags); GEN_FN_DEF(ssize_t, pwrite, int fd, const void *buf, size_t count, off_t offset); GEN_FN_DEF(ssize_t, pwrite64, int fd, const void *buf, size_t count, off_t offset); GEN_FN_DEF(int, remove, const char *); GEN_FN_DEF(int, truncate, const char *path, off_t length); GEN_FN_DEF(int, ftruncate, int fd, off_t length); GEN_FN_DEF(int, truncate64, const char *path, off_t length); GEN_FN_DEF(int, ftruncate64, int fd, off_t length); GEN_FN_DEF(int, rmdir, const char *pathname); GEN_FN_DEF(int, rename, const char *, const char *); GEN_FN_DEF(int, renameat, int olddirfd, const char *oldpath, int newdirfd, const char *newpath); GEN_FN_DEF(int, link, const char *, const char *); GEN_FN_DEF(int, linkat, int, const char *, int, const char *, int); GEN_FN_DEF(int, unlink, const char *pathname); GEN_FN_DEF(int, unlinkat, int dirfd, const char *pathname, int flags); GEN_FN_DEF(int, symlink, const char *, const char *); GEN_FN_DEF(int, symlinkat, const char *, int, const char *); GEN_FN_DEF(ssize_t, readlink, const char *, char *, size_t); GEN_FN_DEF(ssize_t, readlinkat, int, const char *, char *, size_t); GEN_FN_DEF(char*, realpath, const char*, char*); GEN_FN_DEF(DIR*, opendir, const char*); GEN_FN_DEF(DIR*, fdopendir, int); GEN_FN_DEF(int, utime, const char *filename, const struct utimbuf *times); GEN_FN_DEF(int, utimes, const char *filename, const struct timeval times[2]); GEN_FN_DEF(int, utimensat, int, const char*, const struct timespec[2], int); GEN_FN_DEF(int, futimesat, int dirfd, const char *pathname, const struct timeval times[2]); GEN_FN_DEF(int, futimens, int, const struct timespec[2]); GEN_FN_DEF(int, mkdir, const char*, mode_t); GEN_FN_DEF(int, mkdirat, int, const char*, mode_t); GEN_FN_DEF(int, mknod, const char *pathname, mode_t mode, dev_t dev); GEN_FN_DEF(int, mknodat, int dirfd, const char *pathname, mode_t mode, dev_t dev); GEN_FN_DEF(int, printf, const char*, ...); GEN_FN_DEF(int, fprintf, FILE*, const char*, ...); GEN_FN_DEF(int, dprintf, int, const char*, ...); GEN_FN_DEF(int, vprintf, const char*, va_list); GEN_FN_DEF(int, vfprintf, FILE*, const char*, va_list); GEN_FN_DEF(int, vdprintf, int, const char*, va_list); GEN_FN_DEF(int, chmod, const char *pathname, mode_t mode); GEN_FN_DEF(int, fchmod, int fd, mode_t mode); GEN_FN_DEF(int, fchmodat, int dirfd, const char *pathname, mode_t mode, int flags); GEN_FN_DEF(int, chown, const char *pathname, uid_t owner, gid_t group); GEN_FN_DEF(int, fchown, int fd, uid_t owner, gid_t group); GEN_FN_DEF(int, lchown, const char *pathname, uid_t owner, gid_t group); GEN_FN_DEF(int, fchownat, int dirfd, const char *pathname, uid_t owner, gid_t group, int flags); GEN_FN_DEF(ssize_t, sendfile, int out_fd, int in_fd, off_t *offset, size_t count); GEN_FN_DEF(ssize_t, sendfile64, int out_fd, int in_fd, off_t *offset, size_t count); GEN_FN_DEF(ssize_t, copy_file_range, int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags); GEN_FN_DEF(int, name_to_handle_at, int dirfd, const char *pathname, struct file_handle *handle, int *mount_id, int flags); /* ============ don't need to be interposed ======================= */ GEN_FN_DEF(int, dup, int oldfd); GEN_FN_DEF(int, dup2, int oldfd, int newfd); GEN_FN_DEF(int, close, int fd); GEN_FN_DEF(int, fclose, FILE *stream); GEN_FN_DEF(int, statfs, const char *, struct statfs *buf); GEN_FN_DEF(int, statfs64, const char *, struct statfs64 *buf); GEN_FN_DEF(int, fstatfs, int fd, struct statfs *buf); GEN_FN_DEF(int, fstatfs64, int fd, struct statfs64 *buf); /* =================================================================== */ /* ============ old/obsolete/unavailable ========================== GEN_FN_DEF(int, execveat, int dirfd, const char *pathname, char *const argv[], char *const envp[], int flags); GEN_FN_DEF(int, renameat2, int olddirfd, const char *oldpath, int newdirfd, const char *newpath, unsigned int flags); GEN_FN_DEF(int, getdents, unsigned int fd, struct linux_dirent *dirp, unsigned int count); GEN_FN_DEF(int, getdents64, unsigned int fd, struct linux_dirent64 *dirp, unsigned int count); =================================================================== */ };
// // GameSelectScene.cpp // PehlaSchool // // Created by Gunho Lee on 09/12/17. // // #include <functional> #include "CCAppController.hpp" #include "Utils/TodoUtil.h" #include "CustomDirector.h" #include "CoopScene.hpp" #include "GameSelectScene.hpp" #include "GradeSelector.hpp" #include "Bird.hpp" #include "Common/Controls/TodoLoadingScene.hpp" #include "Common/Controls/CompletePopup.hpp" #include "Managers/LanguageManager.hpp" #include "Managers/CurriculumManager.hpp" #include "Managers/UserManager.hpp" #include "Managers/GameSoundManager.h" #include "Managers/StrictLogManager.h" #include "Common/Effects/FireworksEffect.hpp" #include "Common/Controls/CoinTab.hpp" namespace GameSelectSceneSpace { const Size designSize = Size(2560, 1800); static Size visibleSize; static Size frameSize; const Vec2 birdPos = Vec2(designSize.width / 2.f, 600); const Vec2 coopPos = Vec2(designSize.width - 220 - 241, designSize.height - 660 - 172); static Vec2 panelPos; const Size panelNodeSize = Size(670, 162); const int coopBackZ = -100; const int coopFrontZ = 100; const string fontName = "fonts/mukta-bold.ttf"; const string arialFont = "arial"; }; using namespace GameSelectSceneSpace; static bool __firstEnter = true; GameSelectScene::GameSelectScene() : _bird(nullptr), _birdShadow(nullptr), _day(0) { } Scene *GameSelectScene::createScene() { // 'scene' is an autorelease object auto scene = Scene::create(); visibleSize = Director::getInstance()->getVisibleSize(); scene->setContentSize(visibleSize); // 'layer' is an autorelease object auto layer = GameSelectScene::create(); // add layer as a child to scene scene->addChild(layer); // return the scene return scene; } void GameSelectScene::clearGameButton() { if (_debugView) { _debugView->removeFromParent(); _debugView = nullptr; } for (auto i : gameIcons) { i->removeFromParent(); } gameIcons.clear(); } void GameSelectScene::addDebugGameButton(Node *parent, std::string gameName, Vector<ui::Button *> &iconVector) { std::string iconFilename = StringUtils::format("icons/game_icon_%s.png", gameName.c_str()); bool noIcon = !FileUtils::getInstance()->isFileExist(iconFilename); if (noIcon) { iconFilename = "icons/gameicon_frame_shadow.png"; } auto btn = ui::Button::create(iconFilename); btn->setZoomScale(0); if (noIcon) { btn->setTitleFontSize(30); btn->setTitleText(gameName); } btn->addTouchEventListener( [gameName, this](Ref *pSender, ui::Widget::TouchEventType eEventType) { if (_transitionBegins) { return; } if (((CustomDirector *) Director::getInstance())->isNextScene()) return; auto btn = (ui::Button *) pSender; auto cover = btn->getChildByName("gameIconCover"); switch (eEventType) { case ui::Widget::TouchEventType::BEGAN: cover->setVisible(true); break; case ui::Widget::TouchEventType::MOVED: cover->setVisible(btn->isHighlighted()); break; case ui::Widget::TouchEventType::ENDED: cover->setVisible(false); CCAppController::sharedAppController()->startGameWithLevelChoice(gameName); SoundEffect::buttonEffect().play(); break; default: break; } }); Sprite *btnShadow = Sprite::create("icons/game_icon_frame_shadow.png"); btnShadow->setPosition(btn->getContentSize() / 2.f); btn->addChild(btnShadow, -1); Sprite *btnFrame = Sprite::create("icons/game_icon_frame.png"); if (gameName == "EggQuizLiteracy" || gameName == "EggQuizMath") { btnFrame = Sprite::create("icons/game_icon_frame_EggQuiz.png"); } btnFrame->setPosition(btn->getContentSize() / 2.f); btn->addChild(btnFrame); Sprite *cover = Sprite::create("icons/game_icon_frame_shadow.png"); cover->setPosition(btn->getContentSize() / 2); cover->setColor(Color3B::BLACK); cover->setOpacity(128); cover->setName("gameIconCover"); cover->setVisible(false); btn->addChild(cover); parent->addChild(btn); iconVector.pushBack(btn); } void GameSelectScene::addAllDebugGameButtons(char category, Vector<ui::Button *> &iconVector) { clearGameButton(); if (category == 'M') { addDebugGameButton(_rootNode, "EggQuizMath", iconVector); addDebugGameButton(_rootNode, "NumberTracing", iconVector); addDebugGameButton(_rootNode, "NumberTracingExt", iconVector); addDebugGameButton(_rootNode, "NumberPuzzle", iconVector); addDebugGameButton(_rootNode, "FindTheMatch", iconVector); addDebugGameButton(_rootNode, "NumberMatching", iconVector); addDebugGameButton(_rootNode, "Counting", iconVector); addDebugGameButton(_rootNode, "MovingInsects", iconVector); addDebugGameButton(_rootNode, "FishTank", iconVector); addDebugGameButton(_rootNode, "DoubleDigit", iconVector); addDebugGameButton(_rootNode, "EquationMaker", iconVector); addDebugGameButton(_rootNode, "Tapping", iconVector); addDebugGameButton(_rootNode, "TutorialTrace", iconVector); addDebugGameButton(_rootNode, "HundredPuzzle", iconVector); addDebugGameButton(_rootNode, "NumberTrain", iconVector); addDebugGameButton(_rootNode, "PatternTrain", iconVector); addDebugGameButton(_rootNode, "AnimalPuzzle", iconVector); addDebugGameButton(_rootNode, "ThirtyPuzzle", iconVector); addDebugGameButton(_rootNode, "FeedingTime", iconVector); addDebugGameButton(_rootNode, "MangoShop", iconVector); addDebugGameButton(_rootNode, "MissingNumber", iconVector); addDebugGameButton(_rootNode, "QuickFacts", iconVector); addDebugGameButton(_rootNode, "MultiplicationBoard", iconVector); addDebugGameButton(_rootNode, "WordWindow", iconVector); addDebugGameButton(_rootNode, "PlaceValue", iconVector); addDebugGameButton(_rootNode, "MathKicker", iconVector); } else if (category == 'L') { addDebugGameButton(_rootNode, "EggQuizLiteracy", iconVector); addDebugGameButton(_rootNode, "Book", iconVector); addDebugGameButton(_rootNode, "BookWithQuiz", iconVector); addDebugGameButton(_rootNode, "AlphabetPuzzle", iconVector); addDebugGameButton(_rootNode, "WordMachine", iconVector); addDebugGameButton(_rootNode, "LetterTrace", iconVector); addDebugGameButton(_rootNode, "LetterTracingCard", iconVector); addDebugGameButton(_rootNode, "WordTracing", iconVector); addDebugGameButton(_rootNode, "Comprehension", iconVector); addDebugGameButton(_rootNode, "StarFall", iconVector); addDebugGameButton(_rootNode, "Spelling", iconVector); addDebugGameButton(_rootNode, "LetterMatching", iconVector); // addDebugGameButton(_rootNode, "DigitalQuiz", iconVector ); addDebugGameButton(_rootNode, "AnimalPuzzle", iconVector); // addDebugGameButton(_rootNode, "CompMatching", iconVector); addDebugGameButton(_rootNode, "SentenceMaker", iconVector); addDebugGameButton(_rootNode, "BirdPhonics", iconVector); addDebugGameButton(_rootNode, "ShapeMatching", iconVector); addDebugGameButton(_rootNode, "SoundTrain", iconVector); addDebugGameButton(_rootNode, "WordNote", iconVector); addDebugGameButton(_rootNode, "WhatIsThis", iconVector); addDebugGameButton(_rootNode, "ReadingBird", iconVector); addDebugGameButton(_rootNode, "LineMatching", iconVector); addDebugGameButton(_rootNode, "SentenceBridge", iconVector); addDebugGameButton(_rootNode, "WordMatrix", iconVector); addDebugGameButton(_rootNode, "WordKicker", iconVector); addDebugGameButton(_rootNode, "Labeling", iconVector); addDebugGameButton(_rootNode, "LRComprehension", iconVector); } layoutGameButton(_rootNode, gameIcons); } void GameSelectScene::addGameButton(Node *parent, std::string levelID, int day, int gameIndex, Vector<ui::Button *> &iconVector) { auto cur = CurriculumManager::getInstance()->findCurriculum(levelID); auto dayCur = cur->getDayCurriculum(day); auto gameInfo = dayCur->games.at(gameIndex); auto gameName = gameInfo.gameName; auto gameParameter = gameInfo.gameParameter; if (gameName == "EggQuizMath" || gameName == "EggQuizLiteracy") { if (gameParameter.find("MiniTest") != string::npos) { gameName = "EggQuiz_MiddleTest"; } } std::string iconFilename = StringUtils::format("icons/game_icon_%s.png", gameName.c_str()); if (gameName == "Video") { string videoName = gameParameter; size_t lastindex = gameParameter.find_last_of("."); if (lastindex != string::npos) { videoName = gameParameter.substr(0, lastindex); } std::string videoIcon = StringUtils::format("icons/%s.png", videoName.c_str()); if (FileUtils::getInstance()->isFileExist(videoIcon)) { iconFilename = videoIcon; } } else if (gameName == "Book" || gameName == "BookWithQuiz") { auto splits = TodoUtil::split(gameParameter, '_'); string bookIcon = ""; if (splits.size() > 1) { if (gameName == "Book") { bookIcon = "icons/book_icon_" + splits[1] + ".png"; } else { bookIcon = "icons/bookquiz_icon_" + splits[1] + ".png"; } } if (FileUtils::getInstance()->isFileExist(bookIcon)) { iconFilename = bookIcon; } } else if (cur->categoryLevel == CoopScene::LEVEL_SPECIAL_COURSE) { if (gameName == "EggQuizMath" || gameName == "EggQuizLiteracy" || gameName == "EggQuiz_MiddleTest") { iconFilename = "icons/game_icon_sc-test.png"; } } bool noIcon = !FileUtils::getInstance()->isFileExist(iconFilename); if (noIcon) { iconFilename = "icons/gameicon_frame_shadow.png"; } auto btn = ui::Button::create(iconFilename); btn->setZoomScale(0); if (noIcon) { btn->setTitleFontSize(30); btn->setTitleText(gameInfo.gameName); } bool dayCleared = UserManager::getInstance()->isDayCleared(levelID, day); bool gameCleared = UserManager::getInstance()->isGameCleared(levelID, day, gameIndex); bool isAvailable = dayCleared || !gameCleared; if (isAvailable || _bird->getCategoryLevel() == CoopScene::LEVEL_SPECIAL_COURSE) { btn->addTouchEventListener([levelID, day, gameIndex, this](Ref *pSender, ui::Widget::TouchEventType eEventType) { if (_transitionBegins) { return; } if (!_backButton->isTouchEnabled()) return; if (((CustomDirector *) Director::getInstance())->isNextScene()) return; auto btn = (ui::Button *) pSender; auto cover = btn->getChildByName("gameIconCover"); switch (eEventType) { case ui::Widget::TouchEventType::BEGAN: cover->setVisible(true); break; case ui::Widget::TouchEventType::MOVED: cover->setVisible(btn->isHighlighted()); break; case ui::Widget::TouchEventType::ENDED: StrictLogManager::shared()->dailyGameChoice_ChooseDailyGame(levelID, day, gameIndex); cover->setVisible(false); _transitionBegins = true; SoundEffect::buttonEffect().play(); CCAppController::sharedAppController()->startCurriculumGame(levelID, day, gameIndex); break; default: break; } }); } Sprite *btnShadow = Sprite::create("icons/game_icon_frame_shadow.png"); btnShadow->setPosition(btn->getContentSize() / 2.f); btn->addChild(btnShadow, -1); Sprite *btnFrame = Sprite::create("icons/game_icon_frame.png"); if (gameInfo.gameName == "EggQuizLiteracy" || gameInfo.gameName == "EggQuizMath") { btnFrame = Sprite::create("icons/game_icon_frame_EggQuiz.png"); } btnFrame->setName("buttonFrame"); btnFrame->setPosition(btn->getContentSize() / 2.f); btn->addChild(btnFrame); Sprite *cover = Sprite::create("icons/game_icon_frame_shadow.png"); cover->setPosition(btn->getContentSize() / 2); cover->setColor(Color3B::BLACK); cover->setOpacity(128); cover->setName("gameIconCover"); cover->setVisible(false); btn->addChild(cover); if (gameInfo.gameName != "EggQuizLiteracy" && gameInfo.gameName != "EggQuizMath" && gameInfo.gameName != "Book" && gameInfo.gameName != "Comprehension" && gameInfo.gameName != "Video" && gameInfo.gameName != "BookWithQuiz") { Sprite *levelBG = Sprite::create("icons/game_level_circle.png"); levelBG->setAnchorPoint(Vec2::ANCHOR_BOTTOM_RIGHT); levelBG->setPosition(btnFrame->getContentSize().width, 15); btnFrame->addChild(levelBG); Node *levelNumber = Sprite::create( StringUtils::format("icons/game_level_circle_%d.png", gameInfo.gameLevel)); if (!levelNumber) { levelNumber = TodoUtil::createLabel(TodoUtil::itos(gameInfo.gameLevel), 62, Size::ZERO, "fonts/mukta-bold.ttf", Color4B::WHITE); levelNumber->setAnchorPoint(Vec2(0.5, 0.6)); } else { levelNumber->setAnchorPoint(Vec2::ANCHOR_MIDDLE); } levelNumber->setPosition(levelBG->getContentSize() / 2.f); levelBG->addChild(levelNumber); levelBG->setName("gameLevel"); levelBG->setVisible(!gameCleared); { Sprite *levelBG = Sprite::create("icons/game_level_circle.png"); levelBG->setAnchorPoint(Vec2::ANCHOR_BOTTOM_RIGHT); levelBG->setPosition(btnFrame->getContentSize().width, 15); cover->addChild(levelBG); cover->setCascadeColorEnabled(true); cover->setCascadeOpacityEnabled(true); } } if (_bird->getCategoryLevel() == CoopScene::LEVEL_SPECIAL_COURSE) { Sprite *complete = Sprite::create("icons/game_icon_frame_block.png"); complete->setPosition(btn->getContentSize() / 2.f); complete->setName("gameBlockCover"); complete->setVisible(gameCleared); btn->addChild(complete); } else { Sprite *complete = Sprite::create("icons/game_icon_frame_completed.png"); complete->setPosition(btn->getContentSize() / 2.f); complete->setName("gameCompleteCover"); complete->setVisible(gameCleared); btn->addChild(complete); } Sprite *coin = Sprite::create("icons/game_icon_frame_completed_coin.png"); coin->setPosition(btn->getContentSize() / 2.f); coin->setName("gameCoinCover"); coin->setVisible(gameCleared && !dayCleared && !dayCur->isEggQuiz); btn->addChild(coin); if (UserManager::getInstance()->getPretestProgressType(levelID) == PretestProgressType::pass) coin->setVisible(false); parent->addChild(btn); iconVector.pushBack(btn); } void GameSelectScene::addDayGameButtons(std::string levelID, int day, Vector<ui::Button *> &iconVector) { auto cur = CurriculumManager::getInstance()->findCurriculum(levelID); auto dayCur = cur->getDayCurriculum(day); clearGameButton(); for (int i = 0; i < dayCur->numGames; i++) { addGameButton(_rootNode, levelID, day, i, gameIcons); } layoutGameButton(_rootNode, gameIcons); refreshGameButtonForSpecialCourse(); if (UserManager::getInstance()->isDebugMode()) { _debugView = Node::create(); _debugView->setContentSize(Size(designSize.width, 400)); _debugView->setPosition(Vec2(0, designSize.height - 400)); addChild(_debugView); auto sk1 = ui::Button::create(); sk1->setTitleText("Clear One Game"); sk1->setTitleFontSize(50); sk1->setPosition(Vec2(designSize.width * 0.75, 300)); _debugView->addChild(sk1); sk1->addClickEventListener([dayCur, levelID, day, this](Ref *) { if (dayCur) { for (int i = 0; i < dayCur->numGames; i++) { if (!UserManager::getInstance()->isGameCleared(levelID, day, i)) { break; } } if (dayCur->isEggQuiz && !dayCur->isMiniQuiz) { if (UserManager::getInstance()->getPretestProgressType(levelID) != PretestProgressType::finish) { UserManager::getInstance()->setPretestProgressType(levelID, PretestProgressType::pass); } } if (_bird->getCategoryLevel() == CoopScene::LEVEL_SPECIAL_COURSE) { int currentGameIndex = UserManager::getInstance()->getSpecialCourseCurrentProgress( _levelID, _day); UserManager::getInstance()->setSpecialCourseCurrentProgress(_levelID, _day, currentGameIndex + 1); } addDayGameButtons(levelID, day, gameIcons); checkDayClear(); } }); auto sk2 = ui::Button::create(); sk2->setTitleText("Clear All Game"); sk2->setTitleFontSize(50); sk2->setPosition(Vec2(designSize.width * 0.75, 100)); _debugView->addChild(sk2); sk2->addClickEventListener([dayCur, levelID, day, this](Ref *) { if (dayCur) { if (dayCur->isEggQuiz && !dayCur->isMiniQuiz) { if (UserManager::getInstance()->getPretestProgressType(levelID) != PretestProgressType::finish) { UserManager::getInstance()->setPretestProgressType(levelID, PretestProgressType::pass); } } if (_bird->getCategoryLevel() == CoopScene::LEVEL_SPECIAL_COURSE) { UserManager::getInstance()->setSpecialCourseCurrentProgress(_levelID, _day, dayCur->numGames); } addDayGameButtons(levelID, day, gameIcons); checkDayClear(); } }); }; } void GameSelectScene::layoutGameButton(Node *parent, Vector<ui::Button *> &iconVector) { auto numIcon = iconVector.size(); float step = parent->getContentSize().width / (numIcon + 1); for (int i = 0; i < numIcon; i++) { auto btn = iconVector.at(i); if (UserManager::getInstance()->isGameTestingMode()) { btn->setPosition(Vec2(step * (i + 1), 180 + (i % 2) * 250)); } else { btn->setPosition(Vec2(step * (i + 1), 150)); } } } void GameSelectScene::refreshGameButtonForSpecialCourse() { if (_bird->getCategoryLevel() != CoopScene::LEVEL_SPECIAL_COURSE) { return; } int currentGameIndex = UserManager::getInstance()->getSpecialCourseCurrentProgress(_levelID, _day); auto numIcon = gameIcons.size(); if (__firstEnter) { if (numIcon <= currentGameIndex) { currentGameIndex = 0; UserManager::getInstance()->setSpecialCourseCurrentProgress(_levelID, _day, currentGameIndex); } } for (int i = 0; i < numIcon; i++) { auto btn = gameIcons.at(i); auto gameLevel = btn->getChildByName("buttonFrame")->getChildByName("gameLevel"); btn->getChildByName("gameBlockCover")->setVisible(false); btn->getChildByName("gameCoinCover")->setVisible(false); if (gameLevel != nullptr) { gameLevel->setVisible(true); } } } bool GameSelectScene::init() { // 1. super init first if (!Layer::init()) { return false; } { auto levelID = UserManager::getInstance()->getCurrentLevelID(); //auto day = UserManager::getInstance()->getCurrentDay(levelID); auto day = UserManager::getInstance()->getPlayingDay(); StrictLogManager::shared()->dailyGameChoice_Begin(levelID, day); } visibleSize = Director::getInstance()->getVisibleSize(); Size winSize = Director::getInstance()->getWinSize(); __firstEnter = true; _debugView = nullptr; _rootNode = Node::create(); _rootNode->setContentSize(designSize); _rootNode->setAnchorPoint(Vec2::ANCHOR_MIDDLE_BOTTOM); _rootNode->setPosition(Vec2(visibleSize.width / 2, 0)); addChild(_rootNode); auto skySize = Size(designSize.width, designSize.height * 2); _skyNode = Node::create(); _skyNode->setContentSize(skySize); _rootNode->addChild(_skyNode); _groundNode = Node::create(); _groundNode->setContentSize(designSize); _rootNode->addChild(_groundNode); Sprite *sky = Sprite::create("MainScene/main_bg_sky.png"); sky->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); sky->setPosition(0, 0); auto skySpriteSize = sky->getContentSize(); auto skyScale = MAX(skySize.width / skySpriteSize.width, skySize.height / skySpriteSize.height); sky->setScale(skyScale); _skyNode->addChild(sky); Sprite *cloud1 = Sprite::create("MainScene/cloud_day_1.png"); cloud1->setPosition(Vec2(visibleSize.width, random(1350, 1450))); cloud1->runAction(RepeatForever::create(Sequence::create( MoveBy::create(random(40.0, 50.0), Vec2(visibleSize.width + 1000, 0)), MoveTo::create(0, Vec2(-500, cloud1->getPositionY())), nullptr))); _skyNode->addChild(cloud1); Sprite *cloud2 = Sprite::create("MainScene/cloud_day_2.png"); cloud2->setPosition(Vec2(visibleSize.width, random(1450, 1550))); cloud2->runAction(RepeatForever::create(Sequence::create( MoveBy::create(random(35.0, 40.0), Vec2(visibleSize.width + 1000, 0)), MoveTo::create(0, Vec2(-500, cloud2->getPositionY())), nullptr))); _skyNode->addChild(cloud2); Sprite *cloud3 = Sprite::create("MainScene/cloud_day_3.png"); cloud3->setPosition(Vec2(visibleSize.width, random(1650, 1750))); cloud3->runAction(RepeatForever::create(Sequence::create( MoveBy::create(random(25.0, 35.0), Vec2(visibleSize.width + 1000, 0)), MoveTo::create(0, Vec2(-500, cloud3->getPositionY())), nullptr))); _skyNode->addChild(cloud3); /* { ui::Button* test = ui::Button::create("icons/game_icon_frame_completed.png"); test->setAnchorPoint(Vec2::ANCHOR_MIDDLE); test->setPosition(Vec2(visibleSize.width*0.3, visibleSize.height-300)); test->addClickEventListener([this](Ref*) { auto effect = FireworksEffect::create(); effect->setPosition(Vec2(1024, 1000)); this->addChild(effect); effect->start(); }); addChild(test); } { ui::Button* test = ui::Button::create("icons/game_icon_frame_completed.png"); test->setAnchorPoint(Vec2::ANCHOR_MIDDLE); test->setPosition(Vec2(visibleSize.width*0.7, visibleSize.height-300)); test->addClickEventListener([this](Ref*) { auto cl = LayerColor::create(Color4B(255, 0, 0, 64)); Director::getInstance()->getRunningScene()->addChild(cl); auto shake = Sequence::create(EaseOut::create(MoveBy::create(0.06, Vec2(50, 0)), 2.0), EaseInOut::create(MoveBy::create(0.12, Vec2(-100, 0)), 2.0), EaseOut::create(MoveBy::create(0.06, Vec2(50, 0)), 2.0), CallFunc::create([cl](){ cl->removeFromParent(); }), nullptr); Director::getInstance()->getRunningScene()->runAction(shake); }); addChild(test); } */ Sprite *mountain = Sprite::create("MainScene/right_mountain.png"); mountain->setAnchorPoint(Vec2::ANCHOR_BOTTOM_RIGHT); mountain->setPosition(designSize.width, 730); _groundNode->addChild(mountain); Sprite *grass = Sprite::create("MainScene/day_grass_ground.png"); grass->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); grass->setPosition(Vec2(0, 0)); _groundNode->addChild(grass); _rootScale = 1.f; if (visibleSize.width > designSize.width) { _rootScale = (visibleSize.width / designSize.width); _rootNode->setScale(_rootScale); frameSize = visibleSize / _rootScale; } else { frameSize = visibleSize; } _frameNode = Node::create(); _frameNode->setContentSize(frameSize); _frameNode->setAnchorPoint(Vec2::ANCHOR_MIDDLE_BOTTOM); _frameNode->setPosition(Vec2(designSize.width / 2, 0)); _rootNode->addChild(_frameNode); _leavesLeft = Sprite::create("MainScene/main_leaves_left.png"); _leavesLeft->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT); _leavesLeft->setPosition(Vec2(0, frameSize.height - 474)); _frameNode->addChild(_leavesLeft); _leavesRight = Sprite::create("MainScene/main_leaves_right.png"); _leavesRight->setAnchorPoint(Vec2::ANCHOR_BOTTOM_RIGHT); _leavesRight->setPosition(Vec2(frameSize.width, frameSize.height - 382)); _frameNode->addChild(_leavesRight); panelPos = Vec2(frameSize.width / 2, frameSize.height); _panelNode = Node::create(); _panelNode->setContentSize(panelNodeSize); _panelNode->setAnchorPoint(Vec2::ANCHOR_MIDDLE_TOP); _panelNode->setPosition(panelPos); _frameNode->addChild(_panelNode); _dayNode = Sprite::create("MainScene/panel_day.png"); _dayNode->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT); _dayNode->setPosition(Vec2(panelNodeSize.width - 44, 60)); _panelNode->addChild(_dayNode); _backButton = TodoSchoolBackButton::create(); _backButton->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT); _backButton->setPosition(Vec2(25, winSize.height - 25)); _backButton->onBack = [this] { this->stopAllActions(); GameSoundManager::getInstance()->stopBGM(); StrictLogManager::shared()->dailyGameChoice_End_Quit(_levelID, _day); }; addChild(_backButton); // // { // auto backBtn = ui::Button::create(); // backBtn->loadTextures("Common/Controls/back_arrow_inactive.png", "Common/Controls/back_arrow_active.png"); // // auto keyListener = EventListenerKeyboard::create(); // keyListener->onKeyReleased = [this](EventKeyboard::KeyCode keyCode, Event *event) { // //if (!_touchEnabled) return; // // if (keyCode == EventKeyboard::KeyCode::KEY_ESCAPE) { // ((CustomDirector*)Director::getInstance())->popSceneWithTransition<TransitionFade>(0.5); // } // }; // backBtn->getEventDispatcher()->addEventListenerWithSceneGraphPriority(keyListener, backBtn); // backBtn->addClickEventListener([this](Ref*){ // //if (!_touchEnabled) return; // SoundEffect::menuBackEffect().play(); // // ((CustomDirector*)Director::getInstance())->popSceneWithTransition<TransitionFade>(0.5); // }); // // backBtn->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT); // backBtn->setPosition(Vec2(25, winSize.height-25)); // addChild(backBtn); // } { _coinTab = CoinTab::create(); _coinTab->setPosition(winSize - Size(50, 50)); addChild(_coinTab); } SoundEffect::coopClickEffect().preload(); return true; } void GameSelectScene::onEnter() { Layer::onEnter(); _backButton->setTouchEnabled(true); visibleSize = Director::getInstance()->getVisibleSize(); stopAllActions(); setScale(1.0); setPosition(Vec2::ZERO); //_rootNode->stopAllActions(); //_rootNode->setScale(_rootScale); //_rootNode->setPosition(Vec2(visibleSize.width/2, 0)); _transitionBegins = false; _panelNode->setPosition(panelPos); //_dayNode->setPosition(dayPos); auto oldLevelID = _bird ? _bird->getLevelID() : ""; auto oldDay = _day; auto levelID = UserManager::getInstance()->getCurrentLevelID(); auto cur = CurriculumManager::getInstance()->findCurriculum(levelID); _levelID = levelID; clearGameButton(); if (cur) { if (_birdShadow) { _birdShadow->removeFromParent(); } _birdShadow = Sprite::create("MainScene/character_shadow.png"); _groundNode->addChild(_birdShadow); Bird *bird = Bird::create(cur->category, cur->categoryLevel, cur->levelID); if (UserManager::getInstance()->getPretestProgressType(levelID) == PretestProgressType::required) { bird->setStatus(Bird::BirdStatus::EGG); } else { bird->setStatus(Bird::BirdStatus::EGG_HATCHED); } bird->onTouchBegan = [bird]() { bird->runTouchAnimation(); }; setCurrentBird(bird); if (UserManager::getInstance()->isGameTestingMode()) { addAllDebugGameButtons(cur->category, gameIcons); } else { bird->setBirdProgress(UserManager::getInstance()->ratioDayCleared(cur->levelID)); auto shadowScale = bird->getBoundingBox().size.width / _birdShadow->getContentSize().width; _birdShadow->setScale(shadowScale); //_day = UserManager::getInstance()->getCurrentDay(levelID); _day = UserManager::getInstance()->getPlayingDay(); if (_day > cur->days.size()) _day = cur->days.size(); if (_day > 0) { addDayGameButtons(levelID, _day, gameIcons); } } //_birdShadow->setPosition(_groundNode->convertToNodeSpace(shadowPosInWorld)); _birdShadow->setScale( bird->getBoundingBox().size.width / _birdShadow->getContentSize().width); _birdShadow->setPosition(birdPos); { _dayNode->retain(); _panelNode->setVisible(true); _panelNode->removeAllChildren(); _panelNode->addChild(_dayNode); string panelFilename = cur->category == 'L' ? "panel_english.png" : "panel_math.png"; // if (cur->categoryLevel==0) panelFilename = "panel_prek.png"; auto panel = Sprite::create("MainScene/" + panelFilename); panel->setPosition(panelNodeSize / 2); _panelNode->addChild(panel); string labelName = cur->levelTitle; string delim = "$#$"; string labelHindi = labelName.substr(0, labelName.find(delim)); auto panelLabelHindi = Label::createWithSystemFont(labelHindi, arialFont, 60); panelLabelHindi->setTextColor(Color4B(255, 240, 184, 255)); panelLabelHindi->setAnchorPoint(Vec2::ANCHOR_MIDDLE); panelLabelHindi->setPosition(panel->getContentSize() / 2 - Size(0, 25)); panel->addChild(panelLabelHindi); } { _dayNode->setVisible(true); _dayNode->removeAllChildren(); auto dayLabel = TodoUtil::createLabel(TodoUtil::itos(_day), 70, Size::ZERO, fontName, Color4B(255, 205, 66, 255)); dayLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE); dayLabel->setPosition(_dayNode->getContentSize() / 2 + Size(20, -5)); _dayNode->addChild(dayLabel); } } GameSoundManager::getInstance()->stopBGM(); if (__firstEnter) { __firstEnter = false; const float appearDelay = 0.2; auto eng = LanguageManager::getInstance()->isEnglish(); if (_bird) { _bird->setPosition(Vec2(birdPos.x, designSize.height + _bird->getContentSize().height)); _bird->runAction(Sequence::create(DelayTime::create(appearDelay), EaseOut::create(MoveTo::create(0.12, birdPos), 3.0), nullptr )); } _leavesLeft->setPosition( Vec2(-_leavesLeft->getContentSize().width, frameSize.height - 474)); _leavesLeft->runAction(Sequence::create( DelayTime::create(appearDelay + 0.3), EaseOut::create(MoveTo::create(0.2, Vec2(0, frameSize.height - 474)), 2.0), nullptr)); _leavesRight->setPosition(Vec2(designSize.width + _leavesLeft->getContentSize().width, frameSize.height - 382)); _leavesRight->runAction(Sequence::create( DelayTime::create(appearDelay + 0.3), EaseOut::create(MoveTo::create(0.2, Vec2(frameSize.width, frameSize.height - 382)), 2.0), nullptr)); _panelNode->setPosition(panelPos + Vec2(0, panelNodeSize.height)); _panelNode->runAction(Sequence::create( DelayTime::create(appearDelay + 0.3), EaseOut::create(MoveTo::create(0.2, panelPos), 2.0), nullptr)); //GameSoundManager::getInstance()->playEffectSound("Common/Sounds/Effect/LogoFall.m4a"); spawnGameEggs(appearDelay); } else { checkDayClear(); if (_bird && _bird->getLevelID() != "" && ((oldLevelID != _bird->getLevelID()) || (oldDay != _day))) { spawnGameEggs(0.2); } else { GameSoundManager::getInstance()->playBGM("Common/Music/BGM1_TitleScreen_intro.m4a"); } } } void GameSelectScene::checkDayClear() { auto levelID = UserManager::getInstance()->getCurrentLevelID(); auto cur = CurriculumManager::getInstance()->findCurriculum(levelID); if (!cur) return; //auto day = UserManager::getInstance()->getCurrentDay(levelID); auto day = UserManager::getInstance()->getPlayingDay(); auto dayCurr = cur->getDayCurriculum(day); if (!dayCurr) return; auto pretestProgressType = UserManager::getInstance()->getPretestProgressType(levelID); bool birdActionFlag = (pretestProgressType != PretestProgressType::pass && pretestProgressType != PretestProgressType::fail) ? true : false; if (!birdActionFlag) _bird->setStatus(Bird::BirdStatus::EGG); bool isDayClearSpecialCourse = false; if (cur->categoryLevel == CoopScene::LEVEL_SPECIAL_COURSE) { if (UserManager::getInstance()->getSpecialCourseCurrentProgress(levelID, day) >= dayCurr->numGames) { isDayClearSpecialCourse = true; } } if (!UserManager::getInstance()->isDayCleared(levelID, day) || isDayClearSpecialCourse) { int numClearedGame = 0; for (int i = 0; i < dayCurr->numGames; i++) { if (UserManager::getInstance()->isGameCleared(levelID, day, i)) numClearedGame++; } if (dayCurr->numGames == numClearedGame) { auto lang = LanguageManager::getInstance()->getCurrentLanguageTag(); UserManager::getInstance()->setFishPresentEnable( CurriculumManager::getInstance()->makeLevelID(lang, _bird->getCategory(), CoopScene::LEVEL_FISH_PRESENT), true); _backButton->setTouchEnabled(false); GameSoundManager::getInstance()->stopBGM(); int reward = dayCurr->numGames; if (dayCurr->isEggQuiz) reward = 10; if (dayCurr->isMiniQuiz) reward = 8; if (UserManager::getInstance()->getPretestProgressType(levelID) == PretestProgressType::pass) { if (cur->categoryLevel == 1) reward = 100; else if (cur->categoryLevel == 2) reward = 200; else if (cur->categoryLevel <= 4) reward = 200; } bool isSpecialCourseClear = false; if (isDayClearSpecialCourse) { if (cur->numDays == dayCurr->dayOrder && !UserManager::getInstance()->isLevelCleared(levelID)) { isSpecialCourseClear = true; } if (isSpecialCourseClear) { reward = 200; } else { if (UserManager::getInstance()->isDayCleared(levelID, day)) { reward = 10; } else { reward = 20; } } } UserManager::getInstance()->setDayCleared(levelID, day); auto stars = UserManager::getInstance()->getStars(); UserManager::getInstance()->updateStars(stars + reward); SoundEffect::birdJumpEffect().preload(); SoundEffect::birdGrowEffect().preload(); auto seq = Sequence::create( CallFunc::create([this, birdActionFlag]() { if (birdActionFlag) _bird->loadAnimation(); }), DelayTime::create(1.0), CallFunc::create([]() { SoundEffect::birdJumpEffect().play(); }), EaseOut::create(MoveBy::create(0.3, Vec2(0, 30)), 2.0), EaseIn::create(MoveBy::create(0.3, Vec2(0, -30)), 2.0), CallFunc::create([]() { SoundEffect::birdJumpEffect().play(); }), EaseOut::create(MoveBy::create(0.3, Vec2(0, 30)), 2.0), EaseIn::create(MoveBy::create(0.3, Vec2(0, -30)), 2.0), CallFunc::create( [this, birdActionFlag, reward, dayCurr, isDayClearSpecialCourse, isSpecialCourseClear]() { if (birdActionFlag) _bird->runTouchAnimation(); SoundEffect::birdJumpEffect().play(); auto birdPos = _bird->getPosition() + Vec2(0, 300); auto birdParent = _bird->getParent(); for (auto icon : gameIcons) { icon->getChildByName("gameCoinCover")->setVisible(false); } if (isDayClearSpecialCourse) { _coinTab->addCoinForSpecialCourse(dayCurr->numGames, reward, birdParent->convertToWorldSpace( birdPos), isSpecialCourseClear); } else { _coinTab->addCoin(reward, birdParent->convertToWorldSpace(birdPos), dayCurr->isEggQuiz ? false : true); } }), nullptr ); auto seq2 = Sequence::create(EaseOut::create(MoveBy::create(1.6, Vec2(0, 150)), 2.0), CallFunc::create([this, birdActionFlag, levelID]() { if (birdActionFlag) { _bird->setBirdProgress( UserManager::getInstance()->ratioDayCleared( levelID)); _bird->runTouchAnimation(); } SoundEffect::birdGrowEffect().play(); auto shadowScale = _bird->getBoundingBox().size.width / _birdShadow->getContentSize().width; _birdShadow->setScale(shadowScale); }), EaseIn::create(MoveBy::create(1.6, Vec2(0, -150)), 2.0), CallFunc::create([this, levelID, day]() { StrictLogManager::shared()->dailyGameChoice_End_Complete( levelID, day); _backButton->setTouchEnabled(true); ((CustomDirector *) Director::getInstance())->popSceneWithTransition<TransitionFade>( 0.5); }), nullptr); _bird->runAction(Sequence::create(seq, seq2, nullptr)); } else { if (UserManager::getInstance()->getPretestProgressType(levelID) == PretestProgressType::fail) { UserManager::getInstance()->setCurrentDay(levelID, 1); UserManager::getInstance()->setPlayingDay(1); _backButton->setTouchEnabled(false); runAction(Sequence::create(DelayTime::create(1.f), CallFunc::create([this]() { ((CustomDirector *) Director::getInstance())->popSceneWithTransition<TransitionFade>( 0.5); }), nullptr)); } } } } void GameSelectScene::spawnGameEggs(float delay) { SoundEffect::iconSpawnEffect().preload(); GameSoundManager::getInstance()->playBGM("Common/Music/BGM1_TitleScreen_intro.m4a"); this->runAction(Sequence::create(DelayTime::create(1.0 + delay), CallFunc::create( []() { SoundEffect::iconSpawnEffect().play(); }), DelayTime::create(1.5), //CallFunc::create([](){}), nullptr)); for (auto icon : gameIcons) { if (icon->isVisible()) { auto p = icon->getPosition(); icon->setPosition(birdPos); icon->setScale(0); icon->runAction(Sequence::create( DelayTime::create(delay + random(0.0, 0.3)), Spawn::create( ScaleTo::create(0.7, 1), MoveBy::create(1.0, Vec2(p.x - birdPos.x, 0)), Sequence::create( EaseOut::create(MoveBy::create(0.5, Vec2(0, 120)), 2.0), EaseIn::create( MoveBy::create(0.5, Vec2(0, -120 + (p.y - birdPos.y))), 2.0), EaseIn::create(MoveBy::create(0.12, Vec2(0, -50)), 2.0), EaseOut::create(MoveBy::create(0.12, Vec2(0, 50)), 2.0), nullptr ), nullptr), nullptr)); } } } void GameSelectScene::setCurrentBird(Bird *bird) { if (_bird) { _bird->removeFromParent(); } _bird = bird; _bird->setPosition(birdPos); _rootNode->addChild(bird); } void GameSelectScene::onExitTransitionDidStart() { Layer::onExitTransitionDidStart(); _transitionBegins = true; }
#include <vtkActor.h> #include <vtkActor2D.h> #include <vtkArrowSource.h> #include <vtkConeSource.h> #include <vtkCubeSource.h> #include <vtkCylinderSource.h> #include <vtkDiskSource.h> #include <vtkLineSource.h> #include <vtkNamedColors.h> #include <vtkNew.h> #include <vtkPolyDataMapper.h> #include <vtkProperty.h> #include <vtkRegularPolygonSource.h> #include <vtkRenderWindow.h> #include <vtkRenderWindowInteractor.h> #include <vtkRenderer.h> #include <vtkSmartPointer.h> #include <vtkSphereSource.h> #include <vtkTextMapper.h> #include <vtkTextProperty.h> #include <array> #include <vector> #include <vtkCamera.h> int main(int, char*[]) { vtkSmartPointer<vtkNamedColors> colors = vtkSmartPointer<vtkNamedColors>::New(); // Set the background color. std::array<unsigned char, 4> bkg{{51, 77, 102, 255}}; colors->SetColor("BkgColor", bkg.data()); // Create container to hold the 3D object generators (sources) std::vector<vtkSmartPointer<vtkPolyDataAlgorithm>> geometricObjectSources; // Populate the container with the various object sources to be demonstrated geometricObjectSources.push_back(vtkSmartPointer<vtkArrowSource>::New()); geometricObjectSources.push_back(vtkSmartPointer<vtkConeSource>::New()); geometricObjectSources.push_back(vtkSmartPointer<vtkCubeSource>::New()); geometricObjectSources.push_back(vtkSmartPointer<vtkCylinderSource>::New()); geometricObjectSources.push_back(vtkSmartPointer<vtkDiskSource>::New()); geometricObjectSources.push_back(vtkSmartPointer<vtkLineSource>::New()); geometricObjectSources.push_back( vtkSmartPointer<vtkRegularPolygonSource>::New()); geometricObjectSources.push_back(vtkSmartPointer<vtkSphereSource>::New()); // Create containers for the remaining nodes of each pipeline std::vector<vtkSmartPointer<vtkPolyDataMapper>> mappers; std::vector<vtkSmartPointer<vtkActor>> actors; std::vector<vtkSmartPointer<vtkTextMapper>> textmappers; std::vector<vtkSmartPointer<vtkActor2D>> textactors; // Create a common text property. vtkNew<vtkTextProperty> textProperty; textProperty->SetFontSize(16); textProperty->SetJustificationToCentered(); textProperty->SetColor(colors->GetColor3d("LightGoldenrodYellow").GetData()); // Create a mapper and actor for each object and the corresponding text label for (unsigned int i = 0; i < geometricObjectSources.size(); i++) { geometricObjectSources[i]->Update(); mappers.push_back(vtkSmartPointer<vtkPolyDataMapper>::New()); mappers[i]->SetInputConnection(geometricObjectSources[i]->GetOutputPort()); actors.push_back(vtkSmartPointer<vtkActor>::New()); actors[i]->SetMapper(mappers[i]); actors[i]->GetProperty()->SetColor( colors->GetColor3d("PeachPuff").GetData()); textmappers.push_back(vtkSmartPointer<vtkTextMapper>::New()); textmappers[i]->SetInput( geometricObjectSources[i]->GetClassName()); // set text label to the // name of the object source textmappers[i]->SetTextProperty(textProperty); textactors.push_back(vtkSmartPointer<vtkActor2D>::New()); textactors[i]->SetMapper(textmappers[i]); textactors[i]->SetPosition(120, 16); // Note: the position of an Actor2D is // specified in display coordinates } // Define size of the grid that will hold the objects int gridCols = 3; int gridRows = 3; // Define side length (in pixels) of each renderer square int rendererSize = 300; vtkNew<vtkRenderWindow> renderWindow; renderWindow->SetWindowName("GeometricObjectsDemo"); renderWindow->SetSize(rendererSize * gridCols, rendererSize * gridRows); // Set up a grid of viewports for each renderer for (double row = 0; row < gridRows; row++) { for (double col = 0; col < gridCols; col++) { double index = row * gridCols + col; // Create a renderer for this grid cell vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New(); renderer->SetBackground(colors->GetColor3d("BkgColor").GetData()); // Set the renderer's viewport dimensions (xmin, ymin, xmax, ymax) within // the render window. Note that for the Y values, we need to subtract the // row index from gridRows because the viewport Y axis points upwards, but // we want to draw the grid from top to down double viewport[4] = {static_cast<double>(col) / gridCols, static_cast<double>(gridRows - row - 1) / gridRows, static_cast<double>(col + 1) / gridCols, static_cast<double>(gridRows - row) / gridRows}; renderer->SetViewport(viewport); // Add the corresponding actor and label for this grid cell, if they exist if (index < geometricObjectSources.size()) { renderer->AddActor(actors[index]); renderer->AddActor(textactors[index]); renderer->ResetCameraClippingRange(); } renderWindow->AddRenderer(renderer); } } vtkNew<vtkRenderWindowInteractor> interactor; interactor->SetRenderWindow(renderWindow); renderWindow->Render(); interactor->Start(); return EXIT_SUCCESS; }
#include <cstdio> #include <assert.h> #include "z80.h" ///////////////////////////////////////////////////////////////////////////// // // Callback functions for KMZ80 // static UINT32 memread(void *user, UINT32 a) { Z80_CPU *z80 = static_cast<Z80_CPU *>(user); UINT32 val; z80->Read(a, val, Z80_CPU::DEVICE_MEM); return val; } static void memwrite(void *user, UINT32 a, UINT32 d) { Z80_CPU *z80 = static_cast<Z80_CPU *>(user); z80->Write(a, d, Z80_CPU::DEVICE_MEM); } static UINT32 ioread(void *user, UINT32 a) { Z80_CPU *z80 = static_cast<Z80_CPU *>(user); UINT32 val; z80->Read(a, val, Z80_CPU::DEVICE_IO); return val; } static void iowrite(void *user, UINT32 a, UINT32 d) { Z80_CPU *z80 = static_cast<Z80_CPU *>(user); z80->Read(a, d, Z80_CPU::DEVICE_IO); } static UINT32 busread(void *user, UINT32 mode) { return 0x38; } ///////////////////////////////////////////////////////////////////////////// // // Callback function for KMEVENT // static void kmevent_handler(KMEVENT *event, KMEVENT_ITEM_ID curid, void *user) { Z80_CPU *z80 = static_cast<Z80_CPU *>(user); z80->Interrupt(curid); } ///////////////////////////////////////////////////////////////////////////// // // CREATE&DESTROY Z80_CPU // Z80_CPU::Z80_CPU() { int i; kmevent_init(&kme); context.kmevent = &kme; for (i = 0; i < INT_TYPE_MAX; i++) int_id[i] = KMEVENT_ITEM_MAX + 1; for (i = 0; i < DEVICE_MAX; i++) device[i] = NULL; } Z80_CPU::~Z80_CPU() {} ///////////////////////////////////////////////////////////////////////////// // // Main Features // void Z80_CPU::Reset() { /* Reset KMZ80 */ kmr800_reset(&context); context.user = this; context.memread = memread; context.memwrite = memwrite; context.ioread = ioread; context.iowrite = iowrite; context.busread = busread; context.regs8[REGID_M1CYCLE] = 2; context.regs8[REGID_A] = (UINT8)0; context.regs8[REGID_HALTED] = 0; context.exflag = 3; context.regs8[REGID_IFF1] = 0; context.regs8[REGID_IFF2] = 0; context.regs8[REGID_INTREQ] = 0; context.regs8[REGID_NMIREQ] = 0; context.regs8[REGID_IMODE] = 1; } void Z80_CPU::Exec(UINT32 cycles) { kmz80_exec(&context, cycles); } bool Z80_CPU::Read(UINT32 adr, UINT32 &val, UINT32 id) { assert(0 <= id && id < DEVICE_MAX); if (device[id]) return device[id]->Read(adr, val); else return false; } bool Z80_CPU::Write(UINT32 adr, UINT32 val, UINT32 id) { assert(0 <= id && id < DEVICE_MAX); if (device[id]) return device[id]->Write(adr, val); else return false; } void Z80_CPU::SetDevice(IDevice *d, int id) { assert(0 <= id && id < DEVICE_MAX); device[id] = d; } void Z80_CPU::Halt(bool flag) { context.regs8[REGID_HALTED] = (UINT8)flag; } ///////////////////////////////////////////////////////////////////////////// // // Interrupt Handler Setup // void Z80_CPU::AddIntHandler(int int_type, UINT32 int_cycles, UINT32 int_address) { assert(0 <= int_type && int_type < INT_TYPE_MAX); if (int_id[int_type] > KMEVENT_ITEM_MAX) int_id[int_type] = kmevent_alloc(&kme); int_adr[int_id[int_type]] = (int_address & 0xffff); kmevent_setevent(&kme, int_id[int_type], (void (*)(void))kmevent_handler, (void *)this); kmevent_settimer(&kme, int_id[int_type], int_cycles); } void Z80_CPU::DelIntHandler(int int_type) { assert(0 <= int_type && int_type < INT_TYPE_MAX); kmevent_free(&kme, int_id[int_type]); int_id[int_type] = KMEVENT_ITEM_MAX + 1; } void Z80_CPU::Interrupt(KMEVENT_ITEM_ID int_id) { device[DEVICE_MEM]->Write(--context.sp, context.pc >> 8); device[DEVICE_MEM]->Write(--context.sp, context.pc & 0xff); context.pc = int_adr[int_id]; } void Z80_CPU::GetMemory(UINT8 *buf, UINT32 size, UINT32 adr) { UINT32 i, val; for (i = 0; i < size; i++) { device[DEVICE_MEM]->Read(adr + i, val); buf[i] = val; } } void Z80_CPU::SetMemory(UINT8 *buf, UINT32 size, UINT32 adr) { UINT32 i; for (i = 0; i < size; i++) device[DEVICE_MEM]->Write(adr + i, buf[i]); } ///////////////////////////////////////////////////////////////////////////// // // Register Controls // void Z80_CPU::SetSP(UINT32 sp) { context.sp = sp & 0xFFFF; } UINT32 Z80_CPU::GetSP() { return context.sp; } void Z80_CPU::SetPC(UINT32 pc) { context.pc = pc & 0xFFFF; } UINT32 Z80_CPU::GetPC() { return context.pc; } void Z80_CPU::SetRegs8(int id, UINT32 val) { assert(0 <= id && id < REGID_MAX); context.regs8[id] = (UINT8)val & 0xFF; } UINT32 Z80_CPU::GetRegs8(int id) { assert(0 <= id && id < REGID_MAX); return context.regs8[id]; }
#include <string> #include <SDL_image.h> #include "Game.h" #include "Color.h" #include "Constants.h" #include "Input.h" Game::Game() { } Game::~Game() { net.clear(); TTF_CloseFont(font); TTF_Quit(); } void Game::load(SDL_Renderer& renderer) { for (int i = 0; i < 8; ++i) { net.push_back(std::make_unique<DrawableRect>( Vector2(static_cast<float>(SCREEN_WIDTH / 2 - NET_WIDTH / 2), static_cast<float>(i * (NET_HEIGHT + NET_SPACE))), NET_WIDTH, NET_HEIGHT, Color(), renderer )); } left_paddle = std::make_shared<Paddle>(Vector2(0, 200), Vector2(20, 100), renderer, true); right_paddle = std::make_shared<Paddle>(OPPONENT_START, Vector2(20, 100), renderer, false); font = TTF_OpenFont("assets/arial.ttf", 12); ball = Ball(BALL_START, BALL_SPEED, renderer, left_paddle, right_paddle); Color text_color = Color(255, 255, 255, 255); std::string left_score_string = std::to_string(left_score); std::string right_score_string = std::to_string(right_score); left_score_text = Text(Vector2(50, 50), left_score_string, font, 60, 60, text_color, renderer); right_score_text = Text(Vector2(SCREEN_WIDTH - 100, 50), right_score_string, font, 60, 60, text_color, renderer); victory_text = Text(Vector2(250, 150), "", font, 200, 50, Color(), renderer); restart_text = Text(Vector2(200, 220), "", font, 300, 50, Color(), renderer); restart_text.set_text("Click to restart game", font); #if _DEBUG fps = Text(Vector2(20, 420), "", font, 300, 50, Color(), renderer); #endif restart(); } void Game::update(float dt) { // Game if (outcome == 0) { left_paddle->update(dt); right_paddle->update(dt); ball.update(dt); if (ball.get_position().get_x() < 0) { right_score_text.set_text(std::to_string(++right_score), font); if (right_score >= MAX_SCORE) { victory_text.set_text("AI wins", font); outcome = 2; } else { reset(); } } else if (ball.get_position().get_x() > SCREEN_WIDTH) { left_score_text.set_text(std::to_string(++left_score), font); if (left_score >= MAX_SCORE) { victory_text.set_text("Player wins", font); outcome = 1; } else { reset(); } } } else { if (Input::left_button_just_clicked()) { restart(); } } #if _DEBUG if(dt > 0.02) fps.set_text(std::to_string(dt), font); #endif } void Game::draw(SDL_Renderer& renderer) { SDL_RenderClear(&renderer); if (outcome == 0) { for (auto it = net.begin(); it != net.end(); ++it) { it->get()->draw(renderer); } left_paddle->draw(renderer); right_paddle->draw(renderer); ball.draw(renderer); left_score_text.draw(renderer); right_score_text.draw(renderer); } else { victory_text.draw(renderer); restart_text.draw(renderer); } #if _DEBUG fps.draw(renderer); #endif SDL_RenderPresent(&renderer); } void Game::reset() { ball.set_position(BALL_START); ball.set_speed(BALL_SPEED); } void Game::restart() { left_score = 0; right_score = 0; std::string left_score_string = std::to_string(left_score); std::string right_score_string = std::to_string(right_score); left_score_text.set_text(left_score_string, font); right_score_text.set_text(right_score_string, font); reset(); outcome = 0; }
/** * @file oglplus/fwd.hpp * @brief Forward declarations * * @author Matus Chochlik * * Copyright 2010-2014 Matus Chochlik. Distributed under the Boost * Software License, Version 1.0. (See accompanying file * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ #pragma once #ifndef OGLPLUS_FWD_1107121519_HPP #define OGLPLUS_FWD_1107121519_HPP #include <oglplus/config_compiler.hpp> #include <type_traits> #include <cstddef> namespace oglplus { // Nothing struct Nothing { typedef int _value_type; }; // Angle template <typename T> class Angle; template <typename T> T Radians(const Angle<T>&); template <typename T> T Degrees(const Angle<T>&); template <typename T> T Sin(const Angle<T>&); template <typename T> T Cos(const Angle<T>&); template <typename T> T Tan(const Angle<T>&); // Vector template <typename T, std::size_t N> class Vector; template <typename T, std::size_t N> const T* Data(const Vector<T, N>& a); template <typename T, std::size_t N> std::size_t Size(const Vector<T, N>&); template <typename T, std::size_t N> T At(const Vector<T, N>& a, std::size_t i); template <typename T, std::size_t N> T At(const Vector<T, N>& a, std::size_t i, T fallback); // Quaternion template <typename T> class Quaternion; // Matrix template <typename T, std::size_t Rows, std::size_t Cols> class Matrix; template <typename T, std::size_t R, std::size_t C> const T* Data(const Matrix<T, R, C>& matrix); template <typename T, std::size_t R, std::size_t C> std::size_t Size(const Matrix<T, R, C>&); template <typename T, std::size_t R, std::size_t C> std::size_t Rows(const Matrix<T, R, C>&); template <typename T, std::size_t R, std::size_t C> std::size_t Cols(const Matrix<T, R, C>&); template <typename T, std::size_t R, std::size_t C> T At(const Matrix<T, R, C>& matrix, std::size_t i, std::size_t j); // ObjectTypeId template <typename ObjectOps> struct ObjectTypeId; template <typename Id> struct ObjectTypeById; #define OGLPLUS_OBJECT_TYPE_ID(OBJECT, ID) \ template <> struct ObjectTypeId<OBJECT##Ops> \ : public std::integral_constant<int, ID> { }; \ template <> struct ObjectTypeById<std::integral_constant<int, ID> > \ { typedef OBJECT##Ops Type; }; class RenderbufferOps; OGLPLUS_OBJECT_TYPE_ID(Renderbuffer, 1) class FramebufferOps; OGLPLUS_OBJECT_TYPE_ID(Framebuffer, 2) class TextureOps; OGLPLUS_OBJECT_TYPE_ID(Texture, 3) class BufferOps; OGLPLUS_OBJECT_TYPE_ID(Buffer, 4) class QueryOps; OGLPLUS_OBJECT_TYPE_ID(Query, 5) class ProgramPipelineOps; OGLPLUS_OBJECT_TYPE_ID(ProgramPipeline, 6) class ProgramOps; OGLPLUS_OBJECT_TYPE_ID(Program, 7) class TransformFeedbackOps; OGLPLUS_OBJECT_TYPE_ID(TransformFeedback, 8) class SamplerOps; OGLPLUS_OBJECT_TYPE_ID(Sampler, 9) class VertexArrayOps; OGLPLUS_OBJECT_TYPE_ID(VertexArray, 10) class ShaderOps; OGLPLUS_OBJECT_TYPE_ID(Shader, 11) class PerfMonitorAMDOps; OGLPLUS_OBJECT_TYPE_ID(PerfMonitorAMD, 12) class PathNVOps; OGLPLUS_OBJECT_TYPE_ID(PathNV, 13) class DSATextureEXTOps; OGLPLUS_OBJECT_TYPE_ID(DSATextureEXT, 14) class DSABufferEXTOps; OGLPLUS_OBJECT_TYPE_ID(DSABufferEXT, 15) class DSAFramebufferEXTOps; OGLPLUS_OBJECT_TYPE_ID(DSAFramebufferEXT, 16) class DSARenderbufferEXTOps; OGLPLUS_OBJECT_TYPE_ID(DSARenderbufferEXT, 17) class DSAVertexArrayEXTOps; OGLPLUS_OBJECT_TYPE_ID(DSAVertexArrayEXT, 18) } // namespace oglplus #endif // include guard
///////////////////////////////////////////////////////////////////// // // SFGE - Simple and Fast Game Engine // // Copyright (c) 2016-2017 DonRumata710 // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation // files (the "Software"), to deal in the Software without // restriction, including without limitation the rights to use, copy, // modify, merge, publish, distribute, sublicense, and / or sell // copies of the Software, and to permit persons to whom the Software // is furnished to do so, subject to the following conditions : // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // ///////////////////////////////////////////////////////////////////// #include "MenuBar.h" #include "PullDownMenu.h" #include "MenuItem.h" #include "Err.h" #include <SFML/Graphics/RenderTarget.hpp> using namespace sfge; void MenuBar::addItem (const UString& text, std::shared_ptr<PullDownMenu> menu) { std::shared_ptr<MenuItem> item (std::make_shared<MenuItem> ()); item->setText (text); m_style.attach (item.get ()); menu->setPosition (Position::TOP | Position::LEFT); menu->collapse (); menu->setItemStyle (m_style); m_items.push_back ({ item, menu }); add_frame (item.get ()); add_frame (menu.get ()); } void MenuBar::setBackground (std::shared_ptr<const Texture> texture) { m_view.setTexture (texture); } void MenuBar::setBackground (const Color& color) { m_view.setColor (color); } void MenuBar::setItemStyle (const WidgetStyle& style) { m_style = style; m_style.setPosition (Position::TOP | Position::LEFT); for (auto item : m_items) { style.attach (item.first.get ()); item.second->setItemStyle (style); } } void MenuBar::setRect (const PositionDesc& desc) { set_position_desc (desc); m_view.setPosition (desc.x, desc.y); m_view.setSize (desc.width, desc.height); if (m_items.empty ()) return; int32_t offset (0); for (auto item : m_items) { item.first->setPosition (offset, 0); int32_t width (item.first->getTextSize ().x + item.first->getCharacterSize ()); offset += width; item.first->setSize (width, desc.height); } } void MenuBar::draw (RenderTarget& target) const { target.draw (m_view); for (auto item : m_items) call_draw (item.first.get (), target); if (m_active_item < m_items.size ()) call_draw (m_items[m_active_item].second.get (), target); } bool MenuBar::check_key (const sf::Event::KeyEvent& e, const bool pressed) { if (m_items.empty () || m_active_item >= m_items.size ()) return false; if (e.code == sf::Keyboard::Return && pressed) { call_check_key (m_items[m_active_item].second.get (), e, pressed); if (!m_items[m_active_item].second->isShown ()) choise_handle (m_active_item); return true; } else if (e.code == sf::Keyboard::Tab) { if (m_items.empty ()) return false; if (m_active_item >= m_items.size ()) choise_handle (0); else choise_handle (m_active_item + 1); if (m_active_item >= m_items.size ()) choise_handle (0); return true; } else if (e.code == sf::Keyboard::Home) choise_handle (0); else if (e.code == sf::Keyboard::End) choise_handle (m_items.size () - 1); else call_check_key (m_items[m_active_item].second.get (), e, pressed); return false; } void MenuBar::check_mouse_button (const sf::Event::MouseButtonEvent& e, const bool pressed) { if (e.button == sf::Mouse::Button::Left) { if (m_is_mouse_over_menu) { call_check_mouse_button (m_items[m_active_item].second.get (), e, pressed); if (!m_items[m_active_item].second->isShown ()) choise_handle (m_active_item); } if (pressed) choise_handle (m_hover_item); } } bool MenuBar::check_mouse (const int x, const int y) { if (m_active_item < m_items.size () && call_check_mouse (m_items[m_active_item].second.get (), x, y)) m_is_mouse_over_menu = true; else m_is_mouse_over_menu = false; m_hover_item = SIZE_MAX; for (size_t i = 0; i < m_items.size (); ++i) { if (call_check_mouse (m_items[i].first.get (), x, y)) m_hover_item = i; } if (m_hover_item != m_active_item && m_active_item < m_items.size ()) choise_handle (m_hover_item); if (m_hover_item < m_items.size () || m_is_mouse_over_menu) return true; else return false; } void MenuBar::choise_handle (size_t item) { if (item > m_items.size ()) return; if (m_active_item < m_items.size ()) m_items[m_active_item].second->collapse (); if (item == m_active_item) { m_items[m_active_item].second->collapse (); m_active_item = SIZE_MAX; return; } Vector2i pos (m_items[item].first->getPosition ()); pos.y += m_items[item].first->getSize ().y; if (m_items[item].second) m_items[item].second->show (pos); m_active_item = item; }
#pragma once // ARKSurvivalEvolved (329.9) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "ARKSurvivalEvolved_PrimalItemStructure_AdobeRamp_classes.hpp" namespace sdk { //--------------------------------------------------------------------------- //Parameters //--------------------------------------------------------------------------- // Function PrimalItemStructure_AdobeRamp.PrimalItemStructure_AdobeRamp_C.ExecuteUbergraph_PrimalItemStructure_AdobeRamp struct UPrimalItemStructure_AdobeRamp_C_ExecuteUbergraph_PrimalItemStructure_AdobeRamp_Params { int EntryPoint; // (Parm, ZeroConstructor, IsPlainOldData) }; } #ifdef _MSC_VER #pragma pack(pop) #endif
// // Created by login on 2021/6/10. // #include "module_merge.h" #include<iostream> #include<sqlite3.h> #include <fstream> #include <sstream> #include <algorithm> #include <cstring> #include"Database/database.h" #include"Database/file_system.h" #include"module_checkout.h" using namespace std; //按照originpath升序排列 bool compare_by_path(const file_info &a, const file_info &b) { return a.origin_path > b.origin_path; } struct module_merge_node_info { std::string SHA; std::string Parent; int Branch; }; vector<module_merge_node_info> nd; static int query_node_info_callback(void *NotUsed, int cnt, char **pValue, char **pName) { //cout<<pValue[0]<<endl; if (cnt == 2) { module_merge_node_info tmp; tmp.SHA = pValue[0]; tmp.Parent = pValue[1]; nd.emplace_back(tmp); return 0; } return 0; } //获取节点的分支 static vector<int> branch_of_node; static vector<string> branch_name; static int query_node_s_branch_info_callback(void *NotUsed, int cnt, char **pValue, char **pName) { branch_of_node.emplace_back(atoi(pValue[0])); branch_name.emplace_back(pValue[1]); return 0; } /** * 执行合并 * @param node1 本分支的节点的sha1 * @param node2 要被合并进来的节点的sha1 * @param currentBranch 当前分支的编号 */ void module_merge::merge(const std::string &node2) { char sql[1000]; sprintf(sql, "SELECT SHA, Parent FROM Node WHERE SHA=(SELECT BranchHead From Branch WHERE ID=%d);", current_branch); //sprintf(sql, "SELECT BranchHead From Branch WHERE ID=%d",current_branch); //cout<<sql<<endl; rc = sqlite3_exec(db, sql, query_node_info_callback, 0, &zErrMsg); if (rc != SQLITE_OK) { cerr << "[ERROR]查询Node1信息失败: " << zErrMsg << endl; exit(1); } else if(nd.size()!=1) { cerr << "[ERROR]查询Node1信息失败, 找不到节点" << endl; exit(1); } sprintf(sql, "SELECT ID, Name FROM Branch WHERE ID=%d;", current_branch); rc = sqlite3_exec(db, sql, query_node_s_branch_info_callback, 0, &zErrMsg); if (rc != SQLITE_OK) { cerr << "[ERROR]查询当前分支HEAD节点信息失败: " << zErrMsg << endl; exit(1); } sprintf(sql, "SELECT SHA, Parent FROM Node WHERE SHA='%s';", node2.c_str()); rc = sqlite3_exec(db, sql, query_node_info_callback, 0, &zErrMsg); if (rc != SQLITE_OK) { cerr << "[ERROR]查询Node信息失败: " << zErrMsg << endl; exit(1); } else if(nd.size()<2) { cerr << "[ERROR]查询Node信息失败, 找不到节点" << endl; exit(1); } sprintf(sql, "SELECT ID, Name FROM Branch WHERE ID=(SELECT Branch FROM Node2Branch WHERE Node='%s');", node2.c_str()); rc = sqlite3_exec(db, sql, query_node_s_branch_info_callback, 0, &zErrMsg); if (rc != SQLITE_OK) { cerr << "[ERROR]查询Node信息失败: " << zErrMsg << endl; exit(1); } if (branch_of_node.size() < 2) { cerr << "[ERROR]Internal error" << endl; throw "Internal error."; } for(int i=1;i<branch_of_node.size();i++){ if (branch_of_node[0] == branch_of_node[i]) { cerr << "Argument fault: 两个节点不能属于同一分支" << endl; throw "Argument fault: 两个节点不能属于同一分支"; } } if (branch_of_node[0] != current_branch) { cerr << "[ERROR]基础节点不属于当前分支" << endl; throw "[ERROR]基础节点不属于当前分支"; } module_detect_changes tmp_det; auto node_1_file_list = tmp_det.get_node_files(nd[0].SHA); cout<<"node1:"<<endl; for(auto p:node_1_file_list) cout<<p.origin_path<<endl; auto node_2_file_list = tmp_det.get_node_files(nd[1].SHA); cout<<"node2:"<<endl; for(auto p:node_2_file_list) cout<<p.origin_path<<endl; map<string, file_info> node1_file_list; //把当前节点的文件加入路径 for (const auto &x: node_1_file_list) { node1_file_list[x.origin_path] = x; } vector<file_info> add_list; vector<file_info> change_list; //得到更改列表 for (const auto &x: node_2_file_list) { //先前已经存在了这个原始路径 if (node1_file_list.count(x.origin_path)) { //已经存在的文件 auto pre = node1_file_list.find(x.origin_path); if (x.updated_datetime > pre->second.updated_datetime) { change_list.emplace_back(x); } } else //新增的 add_list.emplace_back(x); } if (add_list.size() == 0 && change_list.size() == 0) { clog << "[INFO]无更改" << endl; exit(0); } //获得新节点的sha1 stringstream tmp_SHA; //对原始路径排序,算节点的sha1 vector<file_info> det; det.resize(change_list.size() + add_list.size()); det.insert(det.end(), change_list.begin(), change_list.end()); det.insert(det.end(), add_list.begin(), add_list.end()); sort(det.begin(), det.end(), compare_by_path); for (auto &x:det) { tmp_SHA << x.origin_sha; } det.clear(); char tmp_time[500]; //获取节点的sha1 auto tmpp = database::getCurrentTimeChar(); //为了保证节点sha的唯一性,引入当前时间 string new_node_sha1 = calculate_string_sha1(tmp_SHA.str()+tmpp); strcpy(tmp_time, tmpp); free(tmpp); //创建新节点 sprintf(sql, "INSERT INTO Node (SHA,CreatedDateTime,Parent,Message, Editable) VALUES ('%s','%s',(SELECT SHA FROM Node WHERE SHA='%s'),'%s', FALSE)", new_node_sha1.c_str(), tmp_time, nd[0].SHA.c_str(), ("Merge " + branch_name[0] + " into " + branch_name[1]).c_str()); rc = sqlite3_exec(db, sql, 0, NULL, &zErrMsg); if (rc != SQLITE_OK) { cerr << "[ERROR]新节点创建失败:" << zErrMsg << endl; exit(1); } else { if(DEV_MODE) clog << "[INFO]新节点创建成功!" << endl; } //连接新节点和分支 sprintf(sql, "INSERT INTO Node2Branch (ID,Node,Branch,CreatedDateTime) VALUES (NULL,(SELECT SHA FROM Node WHERE SHA='%s'),(SELECT ID FROM Branch WHERE ID='%d'),'%s')", new_node_sha1.c_str(), current_branch, tmp_time); rc = sqlite3_exec(db, sql, 0, NULL, &zErrMsg); if (rc != SQLITE_OK) { cerr << "[ERROR]新节点与分支连接失败:" << zErrMsg << endl; exit(1); } else { if(DEV_MODE) clog << "[INFO]新节点与分支连接成功!" << endl; } //将当前分支头节点改为新节点 sprintf(sql, "UPDATE Branch SET BranchHead=(SELECT SHA FROM Node WHERE SHA='%s') WHERE ID='%d'", new_node_sha1.c_str(), current_branch); rc = sqlite3_exec(db, sql, 0, NULL, &zErrMsg); if (rc != SQLITE_OK) { cerr << "[ERROR]当前分支头节点更改失败:" << zErrMsg << endl; exit(1); } else { if(DEV_MODE) clog << "[INFO]当前分支头节点更改成功!" << endl; } //将add信息加入到连接表中 for (auto &p:add_list) { sprintf(sql, "INSERT INTO Obj2Node (ID,File,Mode,Node,CreatedDateTime) VALUES (NULL,(SELECT CompressedSHA FROM Objects WHERE CompressedSHA='%s'),1,(SELECT SHA FROM Node WHERE SHA='%s'),'%s')", p.compressed_sha.c_str(), new_node_sha1.c_str(), tmp_time); rc = sqlite3_exec(db, sql, 0, NULL, &zErrMsg); if (rc != SQLITE_OK) { cerr << "[ERROR]发生错误:" << zErrMsg << endl; exit(1); } } //将change信息加入到连接表中 for (auto &p:change_list) { sprintf(sql, "INSERT INTO Obj2Node (ID,File,Mode,Node,CreatedDateTime) VALUES (NULL,(SELECT CompressedSHA FROM Objects WHERE CompressedSHA='%s'),0,(SELECT SHA FROM Node WHERE SHA='%s'),'%s')", p.compressed_sha.c_str(), new_node_sha1.c_str(), tmp_time); rc = sqlite3_exec(db, sql, 0, NULL, &zErrMsg); if (rc != SQLITE_OK) { cerr << "[ERROR]发生错误:" << zErrMsg << endl; exit(1); } } clog << "[INFO]" + ("Merge " + node2 + " into " + branch_name[0]) << endl; //切换到新节点 module_checkout tmp_checkout; tmp_checkout.checkout_switch_node(const_cast<char *>(new_node_sha1.c_str()),true); sqlite3_close(db); } void module_merge::help() { }
// Copyright (c) 2011-2020 The Beans Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #if defined(HAVE_CONFIG_H) #include <config/beans-config.h> #endif #include <qt/optionsmodel.h> #include <qt/beansunits.h> #include <qt/guiconstants.h> #include <qt/guiutil.h> #include <interfaces/node.h> #include <validation.h> // For DEFAULT_SCRIPTCHECK_THREADS #include <net.h> #include <netbase.h> #include <txdb.h> // for -dbcache defaults #include <util/string.h> #include <QDebug> #include <QSettings> #include <QStringList> const char *DEFAULT_GUI_PROXY_HOST = "127.0.0.1"; static const QString GetDefaultProxyAddress(); OptionsModel::OptionsModel(QObject *parent, bool resetSettings) : QAbstractListModel(parent) { Init(resetSettings); } void OptionsModel::addOverriddenOption(const std::string &option) { strOverriddenByCommandLine += QString::fromStdString(option) + "=" + QString::fromStdString(gArgs.GetArg(option, "")) + " "; } // Writes all missing QSettings with their default values void OptionsModel::Init(bool resetSettings) { if (resetSettings) Reset(); checkAndMigrate(); QSettings settings; // Ensure restart flag is unset on client startup setRestartRequired(false); // These are Qt-only settings: // Window if (!settings.contains("fHideTrayIcon")) settings.setValue("fHideTrayIcon", false); fHideTrayIcon = settings.value("fHideTrayIcon").toBool(); Q_EMIT hideTrayIconChanged(fHideTrayIcon); if (!settings.contains("fMinimizeToTray")) settings.setValue("fMinimizeToTray", false); fMinimizeToTray = settings.value("fMinimizeToTray").toBool() && !fHideTrayIcon; if (!settings.contains("fMinimizeOnClose")) settings.setValue("fMinimizeOnClose", false); fMinimizeOnClose = settings.value("fMinimizeOnClose").toBool(); // Display if (!settings.contains("nDisplayUnit")) settings.setValue("nDisplayUnit", BeansUnits::BNS); nDisplayUnit = settings.value("nDisplayUnit").toInt(); if (!settings.contains("strThirdPartyTxUrls")) settings.setValue("strThirdPartyTxUrls", ""); strThirdPartyTxUrls = settings.value("strThirdPartyTxUrls", "").toString(); if (!settings.contains("fCoinControlFeatures")) settings.setValue("fCoinControlFeatures", false); fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool(); // These are shared with the core or have a command-line parameter // and we want command-line parameters to overwrite the GUI settings. // // If setting doesn't exist create it with defaults. // // If gArgs.SoftSetArg() or gArgs.SoftSetBoolArg() return false we were overridden // by command-line and show this in the UI. // Main if (!settings.contains("bPrune")) settings.setValue("bPrune", false); if (!settings.contains("nPruneSize")) settings.setValue("nPruneSize", DEFAULT_PRUNE_TARGET_GB); SetPruneEnabled(settings.value("bPrune").toBool()); if (!settings.contains("nDatabaseCache")) settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache); if (!gArgs.SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString())) addOverriddenOption("-dbcache"); if (!settings.contains("nThreadsScriptVerif")) settings.setValue("nThreadsScriptVerif", DEFAULT_SCRIPTCHECK_THREADS); if (!gArgs.SoftSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString())) addOverriddenOption("-par"); if (!settings.contains("strDataDir")) settings.setValue("strDataDir", GUIUtil::getDefaultDataDirectory()); // Wallet #ifdef ENABLE_WALLET if (!settings.contains("bSpendZeroConfChange")) settings.setValue("bSpendZeroConfChange", true); if (!gArgs.SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool())) addOverriddenOption("-spendzeroconfchange"); #endif // Network if (!settings.contains("fUseUPnP")) settings.setValue("fUseUPnP", DEFAULT_UPNP); if (!gArgs.SoftSetBoolArg("-upnp", settings.value("fUseUPnP").toBool())) addOverriddenOption("-upnp"); if (!settings.contains("fListen")) settings.setValue("fListen", DEFAULT_LISTEN); if (!gArgs.SoftSetBoolArg("-listen", settings.value("fListen").toBool())) addOverriddenOption("-listen"); if (!settings.contains("fUseProxy")) settings.setValue("fUseProxy", false); if (!settings.contains("addrProxy")) settings.setValue("addrProxy", GetDefaultProxyAddress()); // Only try to set -proxy, if user has enabled fUseProxy if ((settings.value("fUseProxy").toBool() && !gArgs.SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString()))) addOverriddenOption("-proxy"); else if(!settings.value("fUseProxy").toBool() && !gArgs.GetArg("-proxy", "").empty()) addOverriddenOption("-proxy"); if (!settings.contains("fUseSeparateProxyTor")) settings.setValue("fUseSeparateProxyTor", false); if (!settings.contains("addrSeparateProxyTor")) settings.setValue("addrSeparateProxyTor", GetDefaultProxyAddress()); // Only try to set -onion, if user has enabled fUseSeparateProxyTor if ((settings.value("fUseSeparateProxyTor").toBool() && !gArgs.SoftSetArg("-onion", settings.value("addrSeparateProxyTor").toString().toStdString()))) addOverriddenOption("-onion"); else if(!settings.value("fUseSeparateProxyTor").toBool() && !gArgs.GetArg("-onion", "").empty()) addOverriddenOption("-onion"); // Display if (!settings.contains("language")) settings.setValue("language", ""); if (!gArgs.SoftSetArg("-lang", settings.value("language").toString().toStdString())) addOverriddenOption("-lang"); language = settings.value("language").toString(); } /** Helper function to copy contents from one QSettings to another. * By using allKeys this also covers nested settings in a hierarchy. */ static void CopySettings(QSettings& dst, const QSettings& src) { for (const QString& key : src.allKeys()) { dst.setValue(key, src.value(key)); } } /** Back up a QSettings to an ini-formatted file. */ static void BackupSettings(const fs::path& filename, const QSettings& src) { qInfo() << "Backing up GUI settings to" << GUIUtil::boostPathToQString(filename); QSettings dst(GUIUtil::boostPathToQString(filename), QSettings::IniFormat); dst.clear(); CopySettings(dst, src); } void OptionsModel::Reset() { QSettings settings; // Backup old settings to chain-specific datadir for troubleshooting BackupSettings(GetDataDir(true) / "guisettings.ini.bak", settings); // Save the strDataDir setting QString dataDir = GUIUtil::getDefaultDataDirectory(); dataDir = settings.value("strDataDir", dataDir).toString(); // Remove all entries from our QSettings object settings.clear(); // Set strDataDir settings.setValue("strDataDir", dataDir); // Set that this was reset settings.setValue("fReset", true); // default setting for OptionsModel::StartAtStartup - disabled if (GUIUtil::GetStartOnSystemStartup()) GUIUtil::SetStartOnSystemStartup(false); } int OptionsModel::rowCount(const QModelIndex & parent) const { return OptionIDRowCount; } struct ProxySetting { bool is_set; QString ip; QString port; }; static ProxySetting GetProxySetting(QSettings &settings, const QString &name) { static const ProxySetting default_val = {false, DEFAULT_GUI_PROXY_HOST, QString("%1").arg(DEFAULT_GUI_PROXY_PORT)}; // Handle the case that the setting is not set at all if (!settings.contains(name)) { return default_val; } // contains IP at index 0 and port at index 1 QStringList ip_port = settings.value(name).toString().split(":", QString::SkipEmptyParts); if (ip_port.size() == 2) { return {true, ip_port.at(0), ip_port.at(1)}; } else { // Invalid: return default return default_val; } } static void SetProxySetting(QSettings &settings, const QString &name, const ProxySetting &ip_port) { settings.setValue(name, ip_port.ip + ":" + ip_port.port); } static const QString GetDefaultProxyAddress() { return QString("%1:%2").arg(DEFAULT_GUI_PROXY_HOST).arg(DEFAULT_GUI_PROXY_PORT); } void OptionsModel::SetPruneEnabled(bool prune, bool force) { QSettings settings; settings.setValue("bPrune", prune); const int64_t prune_target_mib = PruneGBtoMiB(settings.value("nPruneSize").toInt()); std::string prune_val = prune ? ToString(prune_target_mib) : "0"; if (force) { gArgs.ForceSetArg("-prune", prune_val); return; } if (!gArgs.SoftSetArg("-prune", prune_val)) { addOverriddenOption("-prune"); } } void OptionsModel::SetPruneTargetGB(int prune_target_gb, bool force) { const bool prune = prune_target_gb > 0; if (prune) { QSettings settings; settings.setValue("nPruneSize", prune_target_gb); } SetPruneEnabled(prune, force); } // read QSettings values and return them QVariant OptionsModel::data(const QModelIndex & index, int role) const { if(role == Qt::EditRole) { QSettings settings; switch(index.row()) { case StartAtStartup: return GUIUtil::GetStartOnSystemStartup(); case HideTrayIcon: return fHideTrayIcon; case MinimizeToTray: return fMinimizeToTray; case MapPortUPnP: #ifdef USE_UPNP return settings.value("fUseUPnP"); #else return false; #endif case MinimizeOnClose: return fMinimizeOnClose; // default proxy case ProxyUse: return settings.value("fUseProxy", false); case ProxyIP: return GetProxySetting(settings, "addrProxy").ip; case ProxyPort: return GetProxySetting(settings, "addrProxy").port; // separate Tor proxy case ProxyUseTor: return settings.value("fUseSeparateProxyTor", false); case ProxyIPTor: return GetProxySetting(settings, "addrSeparateProxyTor").ip; case ProxyPortTor: return GetProxySetting(settings, "addrSeparateProxyTor").port; #ifdef ENABLE_WALLET case SpendZeroConfChange: return settings.value("bSpendZeroConfChange"); #endif case DisplayUnit: return nDisplayUnit; case ThirdPartyTxUrls: return strThirdPartyTxUrls; case Language: return settings.value("language"); case CoinControlFeatures: return fCoinControlFeatures; case Prune: return settings.value("bPrune"); case PruneSize: return settings.value("nPruneSize"); case DatabaseCache: return settings.value("nDatabaseCache"); case ThreadsScriptVerif: return settings.value("nThreadsScriptVerif"); case Listen: return settings.value("fListen"); default: return QVariant(); } } return QVariant(); } // write QSettings values bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, int role) { bool successful = true; /* set to false on parse error */ if(role == Qt::EditRole) { QSettings settings; switch(index.row()) { case StartAtStartup: successful = GUIUtil::SetStartOnSystemStartup(value.toBool()); break; case HideTrayIcon: fHideTrayIcon = value.toBool(); settings.setValue("fHideTrayIcon", fHideTrayIcon); Q_EMIT hideTrayIconChanged(fHideTrayIcon); break; case MinimizeToTray: fMinimizeToTray = value.toBool(); settings.setValue("fMinimizeToTray", fMinimizeToTray); break; case MapPortUPnP: // core option - can be changed on-the-fly settings.setValue("fUseUPnP", value.toBool()); node().mapPort(value.toBool()); break; case MinimizeOnClose: fMinimizeOnClose = value.toBool(); settings.setValue("fMinimizeOnClose", fMinimizeOnClose); break; // default proxy case ProxyUse: if (settings.value("fUseProxy") != value) { settings.setValue("fUseProxy", value.toBool()); setRestartRequired(true); } break; case ProxyIP: { auto ip_port = GetProxySetting(settings, "addrProxy"); if (!ip_port.is_set || ip_port.ip != value.toString()) { ip_port.ip = value.toString(); SetProxySetting(settings, "addrProxy", ip_port); setRestartRequired(true); } } break; case ProxyPort: { auto ip_port = GetProxySetting(settings, "addrProxy"); if (!ip_port.is_set || ip_port.port != value.toString()) { ip_port.port = value.toString(); SetProxySetting(settings, "addrProxy", ip_port); setRestartRequired(true); } } break; // separate Tor proxy case ProxyUseTor: if (settings.value("fUseSeparateProxyTor") != value) { settings.setValue("fUseSeparateProxyTor", value.toBool()); setRestartRequired(true); } break; case ProxyIPTor: { auto ip_port = GetProxySetting(settings, "addrSeparateProxyTor"); if (!ip_port.is_set || ip_port.ip != value.toString()) { ip_port.ip = value.toString(); SetProxySetting(settings, "addrSeparateProxyTor", ip_port); setRestartRequired(true); } } break; case ProxyPortTor: { auto ip_port = GetProxySetting(settings, "addrSeparateProxyTor"); if (!ip_port.is_set || ip_port.port != value.toString()) { ip_port.port = value.toString(); SetProxySetting(settings, "addrSeparateProxyTor", ip_port); setRestartRequired(true); } } break; #ifdef ENABLE_WALLET case SpendZeroConfChange: if (settings.value("bSpendZeroConfChange") != value) { settings.setValue("bSpendZeroConfChange", value); setRestartRequired(true); } break; #endif case DisplayUnit: setDisplayUnit(value); break; case ThirdPartyTxUrls: if (strThirdPartyTxUrls != value.toString()) { strThirdPartyTxUrls = value.toString(); settings.setValue("strThirdPartyTxUrls", strThirdPartyTxUrls); setRestartRequired(true); } break; case Language: if (settings.value("language") != value) { settings.setValue("language", value); setRestartRequired(true); } break; case CoinControlFeatures: fCoinControlFeatures = value.toBool(); settings.setValue("fCoinControlFeatures", fCoinControlFeatures); Q_EMIT coinControlFeaturesChanged(fCoinControlFeatures); break; case Prune: if (settings.value("bPrune") != value) { settings.setValue("bPrune", value); setRestartRequired(true); } break; case PruneSize: if (settings.value("nPruneSize") != value) { settings.setValue("nPruneSize", value); setRestartRequired(true); } break; case DatabaseCache: if (settings.value("nDatabaseCache") != value) { settings.setValue("nDatabaseCache", value); setRestartRequired(true); } break; case ThreadsScriptVerif: if (settings.value("nThreadsScriptVerif") != value) { settings.setValue("nThreadsScriptVerif", value); setRestartRequired(true); } break; case Listen: if (settings.value("fListen") != value) { settings.setValue("fListen", value); setRestartRequired(true); } break; default: break; } } Q_EMIT dataChanged(index, index); return successful; } /** Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal */ void OptionsModel::setDisplayUnit(const QVariant &value) { if (!value.isNull()) { QSettings settings; nDisplayUnit = value.toInt(); settings.setValue("nDisplayUnit", nDisplayUnit); Q_EMIT displayUnitChanged(nDisplayUnit); } } void OptionsModel::setRestartRequired(bool fRequired) { QSettings settings; return settings.setValue("fRestartRequired", fRequired); } bool OptionsModel::isRestartRequired() const { QSettings settings; return settings.value("fRestartRequired", false).toBool(); } void OptionsModel::checkAndMigrate() { // Migration of default values // Check if the QSettings container was already loaded with this client version QSettings settings; static const char strSettingsVersionKey[] = "nSettingsVersion"; int settingsVersion = settings.contains(strSettingsVersionKey) ? settings.value(strSettingsVersionKey).toInt() : 0; if (settingsVersion < CLIENT_VERSION) { // -dbcache was bumped from 100 to 300 in 0.13 // see https://github.com/beans/beans/pull/8273 // force people to upgrade to the new value if they are using 100MB if (settingsVersion < 130000 && settings.contains("nDatabaseCache") && settings.value("nDatabaseCache").toLongLong() == 100) settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache); settings.setValue(strSettingsVersionKey, CLIENT_VERSION); } // Overwrite the 'addrProxy' setting in case it has been set to an illegal // default value (see issue #12623; PR #12650). if (settings.contains("addrProxy") && settings.value("addrProxy").toString().endsWith("%2")) { settings.setValue("addrProxy", GetDefaultProxyAddress()); } // Overwrite the 'addrSeparateProxyTor' setting in case it has been set to an illegal // default value (see issue #12623; PR #12650). if (settings.contains("addrSeparateProxyTor") && settings.value("addrSeparateProxyTor").toString().endsWith("%2")) { settings.setValue("addrSeparateProxyTor", GetDefaultProxyAddress()); } }
#include "MergeTreeDataPartChecksum.h" #include <Common/SipHash.h> #include <Common/hex.h> #include <IO/ReadHelpers.h> #include <IO/WriteHelpers.h> #include <IO/ReadBufferFromString.h> #include <IO/WriteBufferFromString.h> #include <IO/CompressedReadBuffer.h> #include <IO/CompressedWriteBuffer.h> #include <Poco/File.h> namespace DB { namespace ErrorCodes { extern const int CHECKSUM_DOESNT_MATCH; extern const int BAD_SIZE_OF_FILE_IN_DATA_PART; extern const int FORMAT_VERSION_TOO_OLD; extern const int FILE_DOESNT_EXIST; extern const int UNEXPECTED_FILE_IN_DATA_PART; extern const int UNKNOWN_FORMAT; extern const int NO_FILE_IN_DATA_PART; } void MergeTreeDataPartChecksum::checkEqual(const MergeTreeDataPartChecksum & rhs, bool have_uncompressed, const String & name) const { if (is_compressed && have_uncompressed) { if (!rhs.is_compressed) throw Exception("No uncompressed checksum for file " + name, ErrorCodes::CHECKSUM_DOESNT_MATCH); if (rhs.uncompressed_size != uncompressed_size) throw Exception("Unexpected uncompressed size of file " + name + " in data part", ErrorCodes::BAD_SIZE_OF_FILE_IN_DATA_PART); if (rhs.uncompressed_hash != uncompressed_hash) throw Exception("Checksum mismatch for uncompressed file " + name + " in data part", ErrorCodes::CHECKSUM_DOESNT_MATCH); return; } if (rhs.file_size != file_size) throw Exception("Unexpected size of file " + name + " in data part", ErrorCodes::BAD_SIZE_OF_FILE_IN_DATA_PART); if (rhs.file_hash != file_hash) throw Exception("Checksum mismatch for file " + name + " in data part", ErrorCodes::CHECKSUM_DOESNT_MATCH); } void MergeTreeDataPartChecksum::checkSize(const String & path) const { Poco::File file(path); if (!file.exists()) throw Exception(path + " doesn't exist", ErrorCodes::FILE_DOESNT_EXIST); UInt64 size = file.getSize(); if (size != file_size) throw Exception(path + " has unexpected size: " + toString(size) + " instead of " + toString(file_size), ErrorCodes::BAD_SIZE_OF_FILE_IN_DATA_PART); } void MergeTreeDataPartChecksums::checkEqual(const MergeTreeDataPartChecksums & rhs, bool have_uncompressed) const { for (const auto & it : rhs.files) { const String & name = it.first; if (!files.count(name)) throw Exception("Unexpected file " + name + " in data part", ErrorCodes::UNEXPECTED_FILE_IN_DATA_PART); } for (const auto & it : files) { const String & name = it.first; auto jt = rhs.files.find(name); if (jt == rhs.files.end()) throw Exception("No file " + name + " in data part", ErrorCodes::NO_FILE_IN_DATA_PART); it.second.checkEqual(jt->second, have_uncompressed, name); } } void MergeTreeDataPartChecksums::checkSizes(const String & path) const { for (const auto & it : files) { const String & name = it.first; it.second.checkSize(path + name); } } bool MergeTreeDataPartChecksums::read(ReadBuffer & in, size_t format_version) { switch (format_version) { case 1: return false; case 2: return read_v2(in); case 3: return read_v3(in); case 4: return read_v4(in); default: throw Exception("Bad checksums format version: " + DB::toString(format_version), ErrorCodes::UNKNOWN_FORMAT); } } bool MergeTreeDataPartChecksums::read(ReadBuffer & in) { files.clear(); assertString("checksums format version: ", in); size_t format_version; readText(format_version, in); assertChar('\n', in); read(in, format_version); return true; } bool MergeTreeDataPartChecksums::read_v2(ReadBuffer & in) { size_t count; readText(count, in); assertString(" files:\n", in); for (size_t i = 0; i < count; ++i) { String name; Checksum sum; readString(name, in); assertString("\n\tsize: ", in); readText(sum.file_size, in); assertString("\n\thash: ", in); readText(sum.file_hash.first, in); assertString(" ", in); readText(sum.file_hash.second, in); assertString("\n\tcompressed: ", in); readText(sum.is_compressed, in); if (sum.is_compressed) { assertString("\n\tuncompressed size: ", in); readText(sum.uncompressed_size, in); assertString("\n\tuncompressed hash: ", in); readText(sum.uncompressed_hash.first, in); assertString(" ", in); readText(sum.uncompressed_hash.second, in); } assertChar('\n', in); files.insert(std::make_pair(name, sum)); } return true; } bool MergeTreeDataPartChecksums::read_v3(ReadBuffer & in) { size_t count; readVarUInt(count, in); for (size_t i = 0; i < count; ++i) { String name; Checksum sum; readBinary(name, in); readVarUInt(sum.file_size, in); readPODBinary(sum.file_hash, in); readBinary(sum.is_compressed, in); if (sum.is_compressed) { readVarUInt(sum.uncompressed_size, in); readPODBinary(sum.uncompressed_hash, in); } files.emplace(std::move(name), sum); } return true; } bool MergeTreeDataPartChecksums::read_v4(ReadBuffer & from) { CompressedReadBuffer in{from}; return read_v3(in); } void MergeTreeDataPartChecksums::write(WriteBuffer & to) const { writeString("checksums format version: 4\n", to); CompressedWriteBuffer out{to, CompressionSettings(CompressionMethod::LZ4), 1 << 16}; writeVarUInt(files.size(), out); for (const auto & it : files) { const String & name = it.first; const Checksum & sum = it.second; writeBinary(name, out); writeVarUInt(sum.file_size, out); writePODBinary(sum.file_hash, out); writeBinary(sum.is_compressed, out); if (sum.is_compressed) { writeVarUInt(sum.uncompressed_size, out); writePODBinary(sum.uncompressed_hash, out); } } } void MergeTreeDataPartChecksums::addFile(const String & file_name, UInt64 file_size, MergeTreeDataPartChecksum::uint128 file_hash) { files[file_name] = Checksum(file_size, file_hash); } void MergeTreeDataPartChecksums::add(MergeTreeDataPartChecksums && rhs_checksums) { for (auto & checksum : rhs_checksums.files) files[std::move(checksum.first)] = std::move(checksum.second); rhs_checksums.files.clear(); } /// Checksum computed from the set of control sums of .bin files. void MergeTreeDataPartChecksums::computeTotalChecksumDataOnly(SipHash & hash) const { /// We use fact that iteration is in deterministic (lexicographical) order. for (const auto & it : files) { const String & name = it.first; const Checksum & sum = it.second; if (!endsWith(name, ".bin")) continue; UInt64 len = name.size(); hash.update(len); hash.update(name.data(), len); hash.update(sum.uncompressed_size); hash.update(sum.uncompressed_hash); } } String MergeTreeDataPartChecksums::getSerializedString() const { WriteBufferFromOwnString out; write(out); return out.str(); } MergeTreeDataPartChecksums MergeTreeDataPartChecksums::deserializeFrom(const String & s) { ReadBufferFromString in(s); MergeTreeDataPartChecksums res; if (!res.read(in)) throw Exception("Checksums format is too old", ErrorCodes::FORMAT_VERSION_TOO_OLD); assertEOF(in); return res; } bool MergeTreeDataPartChecksums::isBadChecksumsErrorCode(int code) { return code == ErrorCodes::CHECKSUM_DOESNT_MATCH || code == ErrorCodes::BAD_SIZE_OF_FILE_IN_DATA_PART || code == ErrorCodes::NO_FILE_IN_DATA_PART || code == ErrorCodes::UNEXPECTED_FILE_IN_DATA_PART; } /// Puts into hash "stream" length of the string and its bytes static void updateHash(SipHash & hash, const std::string & data) { UInt64 len = data.size(); hash.update(len); hash.update(data.data(), len); } /// Hash is the same as MinimalisticDataPartChecksums::hash_of_all_files String MergeTreeDataPartChecksums::getTotalChecksumHex() const { SipHash hash_of_all_files; for (const auto & elem : files) { const String & name = elem.first; const auto & checksum = elem.second; updateHash(hash_of_all_files, name); hash_of_all_files.update(checksum.file_hash); } UInt64 lo, hi; hash_of_all_files.get128(lo, hi); return getHexUIntUppercase(hi) + getHexUIntUppercase(lo); } void MinimalisticDataPartChecksums::serialize(WriteBuffer & to) const { writeString("checksums format version: 5\n", to); writeVarUInt(num_compressed_files, to); writeVarUInt(num_uncompressed_files, to); writePODBinary(hash_of_all_files, to); writePODBinary(hash_of_uncompressed_files, to); writePODBinary(uncompressed_hash_of_compressed_files, to); } String MinimalisticDataPartChecksums::getSerializedString() { WriteBufferFromOwnString wb; serialize(wb); return wb.str(); } bool MinimalisticDataPartChecksums::deserialize(ReadBuffer & in) { assertString("checksums format version: ", in); size_t format_version; readText(format_version, in); assertChar('\n', in); if (format_version < MINIMAL_VERSION_WITH_MINIMALISTIC_CHECKSUMS) { auto full_checksums_ptr = std::make_unique<MergeTreeDataPartChecksums>(); if (!full_checksums_ptr->read(in, format_version)) return false; computeTotalChecksums(*full_checksums_ptr); full_checksums = std::move(full_checksums_ptr); return true; } if (format_version > MINIMAL_VERSION_WITH_MINIMALISTIC_CHECKSUMS) throw Exception("Unknown checksums format version: " + DB::toString(format_version), ErrorCodes::UNKNOWN_FORMAT); readVarUInt(num_compressed_files, in); readVarUInt(num_uncompressed_files, in); readPODBinary(hash_of_all_files, in); readPODBinary(hash_of_uncompressed_files, in); readPODBinary(uncompressed_hash_of_compressed_files, in); return true; } void MinimalisticDataPartChecksums::computeTotalChecksums(const MergeTreeDataPartChecksums & full_checksums) { num_compressed_files = 0; num_uncompressed_files = 0; SipHash hash_of_all_files_; SipHash hash_of_uncompressed_files_; SipHash uncompressed_hash_of_compressed_files_; for (const auto & elem : full_checksums.files) { const String & name = elem.first; const auto & checksum = elem.second; updateHash(hash_of_all_files_, name); hash_of_all_files_.update(checksum.file_hash); if (!checksum.is_compressed) { ++num_uncompressed_files; updateHash(hash_of_uncompressed_files_, name); hash_of_uncompressed_files_.update(checksum.file_hash); } else { ++num_compressed_files; updateHash(uncompressed_hash_of_compressed_files_, name); uncompressed_hash_of_compressed_files_.update(checksum.uncompressed_hash); } } auto get_hash = [] (SipHash & hash, uint128 & data) { hash.get128(data.first, data.second); }; get_hash(hash_of_all_files_, hash_of_all_files); get_hash(hash_of_uncompressed_files_, hash_of_uncompressed_files); get_hash(uncompressed_hash_of_compressed_files_, uncompressed_hash_of_compressed_files); } String MinimalisticDataPartChecksums::getSerializedString(const MergeTreeDataPartChecksums & full_checksums, bool minimalistic) { if (!minimalistic) return full_checksums.getSerializedString(); MinimalisticDataPartChecksums checksums; checksums.computeTotalChecksums(full_checksums); return checksums.getSerializedString(); } void MinimalisticDataPartChecksums::checkEqual(const MinimalisticDataPartChecksums & rhs, bool check_uncompressed_hash_in_compressed_files) { if (full_checksums && rhs.full_checksums) full_checksums->checkEqual(*rhs.full_checksums, check_uncompressed_hash_in_compressed_files); // If full checksums were checked, check total checksums just in case checkEqualImpl(rhs, check_uncompressed_hash_in_compressed_files); } void MinimalisticDataPartChecksums::checkEqual(const MergeTreeDataPartChecksums & rhs, bool check_uncompressed_hash_in_compressed_files) { if (full_checksums) full_checksums->checkEqual(rhs, check_uncompressed_hash_in_compressed_files); // If full checksums were checked, check total checksums just in case MinimalisticDataPartChecksums rhs_minimalistic; rhs_minimalistic.computeTotalChecksums(rhs); checkEqualImpl(rhs_minimalistic, check_uncompressed_hash_in_compressed_files); } void MinimalisticDataPartChecksums::checkEqualImpl(const MinimalisticDataPartChecksums & rhs, bool check_uncompressed_hash_in_compressed_files) { if (num_compressed_files != rhs.num_compressed_files || num_uncompressed_files != rhs.num_uncompressed_files) { std::stringstream error_msg; error_msg << "Different number of files: " << rhs.num_compressed_files << " compressed (expected " << num_compressed_files << ")" << " and " << rhs.num_uncompressed_files << " uncompressed ones (expected " << num_uncompressed_files << ")"; throw Exception(error_msg.str(), ErrorCodes::CHECKSUM_DOESNT_MATCH); } Strings errors; if (hash_of_uncompressed_files != rhs.hash_of_uncompressed_files) errors.emplace_back("hash of uncompressed files doesn't match"); if (check_uncompressed_hash_in_compressed_files) { if (uncompressed_hash_of_compressed_files != rhs.uncompressed_hash_of_compressed_files) errors.emplace_back("uncompressed hash of compressed files doesn't match"); } else { if (hash_of_all_files != rhs.hash_of_all_files) errors.emplace_back("total hash of all files doesn't match"); } if (!errors.empty()) { String error_msg = "Checksums of parts don't match: " + errors.front(); for (size_t i = 1; i < errors.size(); ++i) error_msg += ", " + errors[i]; throw Exception(error_msg, ErrorCodes::CHECKSUM_DOESNT_MATCH); } } MinimalisticDataPartChecksums MinimalisticDataPartChecksums::deserializeFrom(const String & s) { MinimalisticDataPartChecksums res; ReadBufferFromString rb(s); res.deserialize(rb); return res; } }
// Autogenerated from CppHeaderCreator // Created by Sc2ad // ========================================================================= #pragma once // Begin includes #include "extern/beatsaber-hook/shared/utils/typedefs.h" #include "extern/beatsaber-hook/shared/utils/byref.hpp" // Including type: System.MulticastDelegate #include "System/MulticastDelegate.hpp" #include "extern/beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp" #include "extern/beatsaber-hook/shared/utils/il2cpp-utils-properties.hpp" #include "extern/beatsaber-hook/shared/utils/il2cpp-utils-fields.hpp" #include "extern/beatsaber-hook/shared/utils/utils.h" // Completed includes // Begin forward declares // Forward declaring namespace: GlobalNamespace namespace GlobalNamespace { // Forward declaring type: BeatmapEventData class BeatmapEventData; } // Forward declaring namespace: System namespace System { // Forward declaring type: IAsyncResult class IAsyncResult; // Forward declaring type: AsyncCallback class AsyncCallback; } // Completed forward declares // Type namespace: namespace GlobalNamespace { // Forward declaring type: BeatmapEventCallback class BeatmapEventCallback; } #include "extern/beatsaber-hook/shared/utils/il2cpp-type-check.hpp" NEED_NO_BOX(GlobalNamespace::BeatmapEventCallback); DEFINE_IL2CPP_ARG_TYPE(GlobalNamespace::BeatmapEventCallback*, "", "BeatmapEventCallback"); // Type namespace: namespace GlobalNamespace { // Size: 0x70 #pragma pack(push, 1) // Autogenerated type: BeatmapEventCallback // [TokenAttribute] Offset: FFFFFFFF class BeatmapEventCallback : public System::MulticastDelegate { public: // public System.Void .ctor(System.Object object, System.IntPtr method) // Offset: 0x124A440 template<::il2cpp_utils::CreationType creationType = ::il2cpp_utils::CreationType::Temporary> static BeatmapEventCallback* New_ctor(::Il2CppObject* object, System::IntPtr method) { static auto ___internal__logger = ::Logger::get().WithContext("GlobalNamespace::BeatmapEventCallback::.ctor"); return THROW_UNLESS((::il2cpp_utils::New<BeatmapEventCallback*, creationType>(object, method))); } // public System.Void Invoke(BeatmapEventData eventData) // Offset: 0x124A450 void Invoke(GlobalNamespace::BeatmapEventData* eventData); // public System.IAsyncResult BeginInvoke(BeatmapEventData eventData, System.AsyncCallback callback, System.Object object) // Offset: 0x124A7E4 System::IAsyncResult* BeginInvoke(GlobalNamespace::BeatmapEventData* eventData, System::AsyncCallback* callback, ::Il2CppObject* object); // public System.Void EndInvoke(System.IAsyncResult result) // Offset: 0x124A808 void EndInvoke(System::IAsyncResult* result); }; // BeatmapEventCallback #pragma pack(pop) } #include "extern/beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp" // Writing MetadataGetter for method: GlobalNamespace::BeatmapEventCallback::New_ctor // Il2CppName: .ctor // Cannot get method pointer of value based method overload from template for constructor! // Try using FindMethod instead! // Writing MetadataGetter for method: GlobalNamespace::BeatmapEventCallback::Invoke // Il2CppName: Invoke template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (GlobalNamespace::BeatmapEventCallback::*)(GlobalNamespace::BeatmapEventData*)>(&GlobalNamespace::BeatmapEventCallback::Invoke)> { static const MethodInfo* get() { static auto* eventData = &::il2cpp_utils::GetClassFromName("", "BeatmapEventData")->byval_arg; return ::il2cpp_utils::FindMethod(classof(GlobalNamespace::BeatmapEventCallback*), "Invoke", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{eventData}); } }; // Writing MetadataGetter for method: GlobalNamespace::BeatmapEventCallback::BeginInvoke // Il2CppName: BeginInvoke template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<System::IAsyncResult* (GlobalNamespace::BeatmapEventCallback::*)(GlobalNamespace::BeatmapEventData*, System::AsyncCallback*, ::Il2CppObject*)>(&GlobalNamespace::BeatmapEventCallback::BeginInvoke)> { static const MethodInfo* get() { static auto* eventData = &::il2cpp_utils::GetClassFromName("", "BeatmapEventData")->byval_arg; static auto* callback = &::il2cpp_utils::GetClassFromName("System", "AsyncCallback")->byval_arg; static auto* object = &::il2cpp_utils::GetClassFromName("System", "Object")->byval_arg; return ::il2cpp_utils::FindMethod(classof(GlobalNamespace::BeatmapEventCallback*), "BeginInvoke", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{eventData, callback, object}); } }; // Writing MetadataGetter for method: GlobalNamespace::BeatmapEventCallback::EndInvoke // Il2CppName: EndInvoke template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (GlobalNamespace::BeatmapEventCallback::*)(System::IAsyncResult*)>(&GlobalNamespace::BeatmapEventCallback::EndInvoke)> { static const MethodInfo* get() { static auto* result = &::il2cpp_utils::GetClassFromName("System", "IAsyncResult")->byval_arg; return ::il2cpp_utils::FindMethod(classof(GlobalNamespace::BeatmapEventCallback*), "EndInvoke", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{result}); } };
/*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkRigid2DTransformView.h" #include "mitkImageAccessByItk.h" #include <mitkImageCast.h> #include <itkRigid2DTransform.h> #include <itkCenteredTransformInitializer.h> #include <QValidator> QmitkRigid2DTransformView::QmitkRigid2DTransformView(QWidget* parent, Qt::WindowFlags f ) : QmitkRigidRegistrationTransformsGUIBase(parent, f), m_CenterX(0), m_CenterY(0), m_CenterZ(0) { } QmitkRigid2DTransformView::~QmitkRigid2DTransformView() { } mitk::TransformParameters::TransformType QmitkRigid2DTransformView::GetTransformType() { return mitk::TransformParameters::RIGID2DTRANSFORM; } itk::Object::Pointer QmitkRigid2DTransformView::GetTransform() { if (m_FixedImage.IsNotNull()) { AccessFixedDimensionByItk(m_FixedImage, GetTransform2, 2); return m_TransformObject; } return nullptr; } template < class TPixelType, unsigned int VImageDimension > itk::Object::Pointer QmitkRigid2DTransformView::GetTransform2(itk::Image<TPixelType, VImageDimension>* itkImage1) { if (VImageDimension == 2) { typedef typename itk::Image< TPixelType, 2 > FixedImage2DType; typedef typename itk::Image< TPixelType, 2 > MovingImage2DType; // the fixedImage is the input parameter (fix for Bug #14626) typename FixedImage2DType::Pointer fixedImage2D = itkImage1; // the movingImage type is known, use the ImageToItk filter (fix for Bug #14626) typename mitk::ImageToItk<MovingImage2DType>::Pointer movingImageToItk = mitk::ImageToItk<MovingImage2DType>::New(); movingImageToItk->SetInput(m_MovingImage); movingImageToItk->Update(); typename MovingImage2DType::Pointer movingImage2D = movingImageToItk->GetOutput(); typename itk::Rigid2DTransform< double >::Pointer transformPointer = itk::Rigid2DTransform< double >::New(); transformPointer->SetIdentity(); if (m_Controls.m_CenterForInitializerRigid2D->isChecked()) { typedef typename itk::Rigid2DTransform< double > Rigid2DTransformType; typedef typename itk::CenteredTransformInitializer<Rigid2DTransformType, FixedImage2DType, MovingImage2DType> TransformInitializerType; typename TransformInitializerType::Pointer transformInitializer = TransformInitializerType::New(); transformInitializer->SetFixedImage( fixedImage2D ); transformInitializer->SetMovingImage( movingImage2D ); transformInitializer->SetTransform( transformPointer ); if (m_Controls.m_MomentsRigid2D->isChecked()) { transformInitializer->MomentsOn(); } else { transformInitializer->GeometryOn(); } transformInitializer->InitializeTransform(); } m_TransformObject = transformPointer.GetPointer(); return transformPointer.GetPointer(); } return nullptr; } itk::Array<double> QmitkRigid2DTransformView::GetTransformParameters() { itk::Array<double> transformValues; transformValues.SetSize(6); transformValues.fill(0); transformValues[0] = m_Controls.m_UseOptimizerScalesRigid2D->isChecked(); transformValues[1] = m_Controls.m_ScalesRigid2DTransformScale1->text().toDouble(); transformValues[2] = m_Controls.m_ScalesRigid2DTransformScaleTranslationX->text().toDouble(); transformValues[3] = m_Controls.m_ScalesRigid2DTransformScaleTranslationY->text().toDouble(); transformValues[4] = m_Controls.m_CenterForInitializerRigid2D->isChecked(); transformValues[5] = m_Controls.m_MomentsRigid2D->isChecked(); return transformValues; } void QmitkRigid2DTransformView::SetTransformParameters(itk::Array<double> transformValues) { m_Controls.m_UseOptimizerScalesRigid2D->setChecked(transformValues[0]); m_Controls.m_ScalesRigid2DTransformScale1->setText(QString::number(transformValues[1])); m_Controls.m_ScalesRigid2DTransformScaleTranslationX->setText(QString::number(transformValues[2])); m_Controls.m_ScalesRigid2DTransformScaleTranslationY->setText(QString::number(transformValues[3])); m_Controls.m_CenterForInitializerRigid2D->setChecked(transformValues[4]); m_Controls.m_MomentsRigid2D->setChecked(transformValues[5]); m_Controls.m_GeometryRigid2D->setChecked(!transformValues[5]); } QString QmitkRigid2DTransformView::GetName() { return "Rigid2D"; } void QmitkRigid2DTransformView::SetupUI(QWidget* parent) { m_Controls.setupUi(parent); QValidator* validatorLineEditInputFloat = new QDoubleValidator(0, 20000000, 8, this); m_Controls.m_ScalesRigid2DTransformScale1->setValidator(validatorLineEditInputFloat); m_Controls.m_ScalesRigid2DTransformScaleTranslationX->setValidator(validatorLineEditInputFloat); m_Controls.m_ScalesRigid2DTransformScaleTranslationY->setValidator(validatorLineEditInputFloat); } itk::Array<double> QmitkRigid2DTransformView::GetScales() { itk::Array<double> scales; scales.SetSize(3); scales.Fill(1.0); if (m_Controls.m_UseOptimizerScalesRigid2D->isChecked()) { scales[0] = m_Controls.m_ScalesRigid2DTransformScale1->text().toDouble(); scales[1] = m_Controls.m_ScalesRigid2DTransformScaleTranslationX->text().toDouble(); scales[2] = m_Controls.m_ScalesRigid2DTransformScaleTranslationY->text().toDouble(); } return scales; } vtkTransform* QmitkRigid2DTransformView::Transform(vtkMatrix4x4* /*vtkmatrix*/, vtkTransform* vtktransform, itk::Array<double> transformParams) { if (m_MovingImage.IsNotNull()) { mitk::ScalarType angle = transformParams[0] * 45.0 / atan(1.0); vtktransform->PostMultiply(); vtktransform->RotateZ(angle); vtktransform->Translate(transformParams[1], transformParams[2], 0); vtktransform->PreMultiply(); } return vtktransform; } int QmitkRigid2DTransformView::GetNumberOfTransformParameters() { if (m_FixedImage.IsNotNull()) { if (m_FixedImage->GetDimension() == 2) return 3; else return 0; } else return 0; }
#include <iostream> #include <iterator> #include <algorithm> using namespace std; int main() { ios::sync_with_stdio(false); string a, b; cin >> a >> b; cout << std::distance(a.begin(), std::search(a.begin(), a.end(), b.begin(), b.end())) + 1 << endl; return 0; } // function main
#include "includes/DCDManager.hpp" #include "includes/SuperImposer.hpp" using namespace arabica; int main(int argc, char *argv[]) { if(argc != 2) { std::cout << "Arabica DCD SuperImposer" << std::endl; std::cout << "Usage: ./superimpose <filename>.dcd" << std::endl; std::cout << "Info : SuperImposer outputs dcd file " << "containing superimposed structure" << std::endl; } std::string infile(argv[1]); DCDReader reader(infile); reader.read_file(); std::vector<SnapShot> data(reader.get_all_data()); std::vector<SnapShot> imposed(data.size()); SuperImposer simposer; simposer.set_data(data.at(1), data.at(0)); simposer.superimpose(); imposed.at(0) = simposer.get_data2();//SuperImposer rotates data2 for(int i(2); i<data.size(); ++i) { simposer.set_data_push(data.at(i)); simposer.superimpose(); imposed.at(i-1) = simposer.get_data2(); } imposed.at(data.size()-1) = simposer.get_data1(); std::string outfile("SupImp"+infile); DCDWriter writer(outfile); set_header_from_reader(&writer, &reader); writer.set_all_data(imposed); writer.write_file(); return 0; } //(c)Toru Niina 2015 all rights reserved.
/* * Copyright 2003-2013, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ #include <boot/partitions.h> #include <errno.h> #include <unistd.h> #include <string.h> #include <boot/FileMapDisk.h> #include <boot/platform.h> #include <boot/stage2.h> #include <boot/stdio.h> #include <boot/vfs.h> #include <ddm_modules.h> #include "RootFileSystem.h" using namespace boot; #define TRACE_PARTITIONS #ifdef TRACE_PARTITIONS # define TRACE(x) dprintf x #else # define TRACE(x) ; #endif /* supported partition modules */ static const partition_module_info *sPartitionModules[] = { #ifdef BOOT_SUPPORT_PARTITION_AMIGA &gAmigaPartitionModule, #endif #ifdef BOOT_SUPPORT_PARTITION_EFI &gEFIPartitionModule, #endif #ifdef BOOT_SUPPORT_PARTITION_INTEL &gIntelPartitionMapModule, &gIntelExtendedPartitionModule, #endif #ifdef BOOT_SUPPORT_PARTITION_APPLE &gApplePartitionModule, #endif }; static const int32 sNumPartitionModules = sizeof(sPartitionModules) / sizeof(partition_module_info *); /* supported file system modules */ static file_system_module_info *sFileSystemModules[] = { #ifdef BOOT_SUPPORT_FILE_SYSTEM_BFS &gBFSFileSystemModule, #endif #ifdef BOOT_SUPPORT_FILE_SYSTEM_AMIGA_FFS &gAmigaFFSFileSystemModule, #endif #ifdef BOOT_SUPPORT_FILE_SYSTEM_FAT &gFATFileSystemModule, #endif #ifdef BOOT_SUPPORT_FILE_SYSTEM_HFS_PLUS &gHFSPlusFileSystemModule, #endif #ifdef BOOT_SUPPORT_FILE_SYSTEM_TARFS &gTarFileSystemModule, #endif }; static const int32 sNumFileSystemModules = sizeof(sFileSystemModules) / sizeof(file_system_module_info *); extern NodeList gPartitions; namespace boot { /*! A convenience class to automatically close a file descriptor upon deconstruction. */ class NodeOpener { public: NodeOpener(Node *node, int mode) { fFD = open_node(node, mode); } ~NodeOpener() { close(fFD); } int Descriptor() const { return fFD; } private: int fFD; }; // #pragma mark - Partition::Partition(int fd) : fParent(NULL), fIsFileSystem(false), fIsPartitioningSystem(false) { TRACE(("%p Partition::Partition\n", this)); memset((partition_data *)this, 0, sizeof(partition_data)); id = (partition_id)this; // it's safe to close the file fFD = dup(fd); } Partition::~Partition() { TRACE(("%p Partition::~Partition\n", this)); // Tell the children that their parent is gone NodeIterator iterator = gPartitions.GetIterator(); Partition *child; while ((child = (Partition *)iterator.Next()) != NULL) { if (child->Parent() == this) child->SetParent(NULL); } close(fFD); } void Partition::SetParent(Partition *parent) { TRACE(("%p Partition::SetParent %p\n", this, parent)); fParent = parent; } Partition * Partition::Parent() const { //TRACE(("%p Partition::Parent is %p\n", this, fParent)); return fParent; } ssize_t Partition::ReadAt(void *cookie, off_t position, void *buffer, size_t bufferSize) { if (position > this->size) return 0; if (position < 0) return B_BAD_VALUE; if (position + bufferSize > this->size) bufferSize = this->size - position; ssize_t result = read_pos(fFD, this->offset + position, buffer, bufferSize); return result < 0 ? errno : result; } ssize_t Partition::WriteAt(void *cookie, off_t position, const void *buffer, size_t bufferSize) { if (position > this->size) return 0; if (position < 0) return B_BAD_VALUE; if (position + bufferSize > this->size) bufferSize = this->size - position; ssize_t result = write_pos(fFD, this->offset + position, buffer, bufferSize); return result < 0 ? errno : result; } off_t Partition::Size() const { struct stat stat; if (fstat(fFD, &stat) == B_OK) return stat.st_size; return Node::Size(); } int32 Partition::Type() const { struct stat stat; if (fstat(fFD, &stat) == B_OK) return stat.st_mode; return Node::Type(); } Partition * Partition::AddChild() { Partition *child = new(nothrow) Partition(fFD); TRACE(("%p Partition::AddChild %p\n", this, child)); if (child == NULL) return NULL; child->SetParent(this); child_count++; fChildren.Add(child); return child; } status_t Partition::_Mount(file_system_module_info *module, Directory **_fileSystem) { TRACE(("%p Partition::_Mount check for file_system: %s\n", this, module->pretty_name)); Directory *fileSystem; if (module->get_file_system(this, &fileSystem) == B_OK) { gRoot->AddVolume(fileSystem, this); if (_fileSystem) *_fileSystem = fileSystem; // remember the module that mounted us fModuleName = module->module_name; this->content_type = module->pretty_name; fIsFileSystem = true; #ifdef BOOT_SUPPORT_FILE_MAP_DISK static int fileMapDiskDepth = 0; // if we aren't already mounting an image if (!fileMapDiskDepth++) { // see if it contains an image file we could mount in turn FileMapDisk *disk = FileMapDisk::FindAnyFileMapDisk(fileSystem); if (disk) { TRACE(("%p Partition::_Mount: found FileMapDisk\n", this)); disk->RegisterFileMapBootItem(); add_partitions_for(disk, true, false); } } fileMapDiskDepth--; #endif return B_OK; } return B_BAD_VALUE; } status_t Partition::Mount(Directory **_fileSystem, bool isBootDevice) { if (isBootDevice && gBootVolume.GetBool(BOOT_VOLUME_BOOTED_FROM_IMAGE, false)) { return _Mount(&gTarFileSystemModule, _fileSystem); } for (int32 i = 0; i < sNumFileSystemModules; i++) { status_t status = _Mount(sFileSystemModules[i], _fileSystem); if (status == B_OK) return B_OK; } return B_ENTRY_NOT_FOUND; } status_t Partition::Scan(bool mountFileSystems, bool isBootDevice) { // scan for partitions first (recursively all eventual children as well) TRACE(("%p Partition::Scan()\n", this)); // if we were not booted from the real boot device, we won't scan // the device we were booted from (which is likely to be a slow // floppy or CD) if (isBootDevice && gBootVolume.GetBool(BOOT_VOLUME_BOOTED_FROM_IMAGE, false)) { return B_ENTRY_NOT_FOUND; } const partition_module_info *bestModule = NULL; void *bestCookie = NULL; float bestPriority = -1; for (int32 i = 0; i < sNumPartitionModules; i++) { const partition_module_info *module = sPartitionModules[i]; void *cookie = NULL; NodeOpener opener(this, O_RDONLY); TRACE(("check for partitioning_system: %s\n", module->pretty_name)); float priority = module->identify_partition(opener.Descriptor(), this, &cookie); if (priority < 0.0) continue; TRACE((" priority: %ld\n", (int32)(priority * 1000))); if (priority <= bestPriority) { // the disk system recognized the partition worse than the currently // best one module->free_identify_partition_cookie(this, cookie); continue; } // a new winner, replace the previous one if (bestModule) bestModule->free_identify_partition_cookie(this, bestCookie); bestModule = module; bestCookie = cookie; bestPriority = priority; } // find the best FS module const file_system_module_info *bestFSModule = NULL; float bestFSPriority = -1; for (int32 i = 0; i < sNumFileSystemModules; i++) { if (sFileSystemModules[i]->identify_file_system == NULL) continue; float priority = sFileSystemModules[i]->identify_file_system(this); if (priority <= 0) continue; if (priority > bestFSPriority) { bestFSModule = sFileSystemModules[i]; bestFSPriority = priority; } } // now let the best matching disk system scan the partition if (bestModule && bestPriority >= bestFSPriority) { NodeOpener opener(this, O_RDONLY); status_t status = bestModule->scan_partition(opener.Descriptor(), this, bestCookie); bestModule->free_identify_partition_cookie(this, bestCookie); if (status != B_OK) { dprintf("Partitioning module `%s' recognized the partition, but " "failed to scan it\n", bestModule->pretty_name); return status; } fIsPartitioningSystem = true; content_type = bestModule->pretty_name; flags |= B_PARTITION_PARTITIONING_SYSTEM; // now that we've found something, check our children // out as well! NodeIterator iterator = fChildren.GetIterator(); Partition *child = NULL; while ((child = (Partition *)iterator.Next()) != NULL) { TRACE(("%p Partition::Scan(): scan child %p (start = %Ld, size " "= %Ld, parent = %p)!\n", this, child, child->offset, child->size, child->Parent())); child->Scan(mountFileSystems); if (!mountFileSystems || child->IsFileSystem()) { // move the partitions containing file systems to the partition // list fChildren.Remove(child); gPartitions.Add(child); } } // remove all unused children (we keep only file systems) while ((child = (Partition *)fChildren.Head()) != NULL) { fChildren.Remove(child); delete child; } // remember the name of the module that identified us fModuleName = bestModule->module.name; return B_OK; } // scan for file systems if (mountFileSystems) { // TODO: Use the FS module we've got, if any. Requires to implement the // identify_file_system() hook in every FS. return Mount(); } return B_ENTRY_NOT_FOUND; } } // namespace boot // #pragma mark - /*! Scans the device passed in for partitioning systems. If none are found, a partition containing the whole device is created. All created partitions are added to the gPartitions list. */ status_t add_partitions_for(int fd, bool mountFileSystems, bool isBootDevice) { TRACE(("add_partitions_for(fd = %d, mountFS = %s)\n", fd, mountFileSystems ? "yes" : "no")); Partition *partition = new(nothrow) Partition(fd); // set some magic/default values partition->block_size = 512; partition->size = partition->Size(); // add this partition to the list of partitions, if it contains // or might contain a file system if ((partition->Scan(mountFileSystems, isBootDevice) == B_OK && partition->IsFileSystem()) || (!partition->IsPartitioningSystem() && !mountFileSystems)) { gPartitions.Add(partition); return B_OK; } // if not, we no longer need the partition delete partition; return B_OK; } status_t add_partitions_for(Node *device, bool mountFileSystems, bool isBootDevice) { TRACE(("add_partitions_for(%p, mountFS = %s)\n", device, mountFileSystems ? "yes" : "no")); int fd = open_node(device, O_RDONLY); if (fd < B_OK) return fd; status_t status = add_partitions_for(fd, mountFileSystems, isBootDevice); if (status < B_OK) dprintf("add_partitions_for(%d) failed: %ld\n", fd, status); close(fd); return B_OK; } partition_data * create_child_partition(partition_id id, int32 index, off_t offset, off_t size, partition_id childID) { Partition &partition = *(Partition *)id; Partition *child = partition.AddChild(); if (child == NULL) { dprintf("creating partition failed: no memory\n"); return NULL; } child->offset = offset; child->size = size; // we cannot do anything with the child here, because it was not // yet initialized by the partition module. TRACE(("new child partition!\n")); return child; } partition_data * get_child_partition(partition_id id, int32 index) { //Partition &partition = *(Partition *)id; // TODO: do we really have to implement this? // The intel partition module doesn't really need this for our mission... TRACE(("get_child_partition(id = %lu, index = %ld)\n", id, index)); return NULL; } partition_data * get_parent_partition(partition_id id) { Partition &partition = *(Partition *)id; return partition.Parent(); }
#include <iostream> #include <complex> #include <vector> #include <htool/htool.hpp> using namespace std; using namespace htool; class MyMatrix: public IMatrix<double>{ const vector<R3>& p1; const vector<R3>& p2; public: MyMatrix(const vector<R3>& p10,const vector<R3>& p20 ):IMatrix<double>(p10.size(),p20.size()),p1(p10),p2(p20) {} double get_coef(const int& i, const int& j)const {return 1./(norm2(p1[i]-p2[j]));} std::vector<double> operator*(std::vector<double> a){ std::vector<double> result(p1.size(),0); for (int i=0;i<p1.size();i++){ for (int k=0;k<p2.size();k++){ result[i]+=this->get_coef(i,k)*a[k]; } } return result; } double normFrob (){ double norm=0; for (int i=0;i<p1.size();i++){ for (int k=0;k<p2.size();k++){ norm = norm + std::pow(this->get_coef(i,k),2); } } return sqrt(norm); } }; int main(int argc, char* argv[]){ // Initialize the MPI environment MPI_Init(&argc,&argv); // Check the number of parameters if (argc < 3) { // Tell the user how to run the program cerr << "Usage: " << argv[0] << " distance \b outputfile \b outputpath" << endl; /* "Usage messages" are a conventional way of telling the user * how to run a program if they enter the command incorrectly. */ return 1; } double distance = StrToNbr<double>(argv[1]); std::string outputfile = argv[2]; std::string outputpath = argv[3]; SetNdofPerElt(1); SetEpsilon(0.0001); int reqrank_max = 50; srand (1); // we set a constant seed for rand because we want always the same result if we run the check many times // (two different initializations with the same seed will generate the same succession of results in the subsequent calls to rand) int nr = 500; int nc = 100; vector<int> Ir(nr); // row indices for the lrmatrix vector<int> Ic(nc); // column indices for the lrmatrix double z1 = 1; vector<R3> p1(nr); vector<double> r1(nr); vector<double> g1(nc,1); vector<int> tab1(nr); for(int j=0; j<nr; j++){ Ir[j] = j; double rho = ((double) rand() / (double)(RAND_MAX)); // (double) otherwise integer division! double theta = ((double) rand() / (double)(RAND_MAX)); p1[j][0] = sqrt(rho)*cos(2*M_PI*theta); p1[j][1] = sqrt(rho)*sin(2*M_PI*theta); p1[j][2] = z1; // sqrt(rho) otherwise the points would be concentrated in the center of the disk r1[j]=0.; tab1[j]=j; } // p2: points in a unit disk of the plane z=z2 double z2 = 1+distance; vector<R3> p2(nc); vector<double> r2(nc); vector<double> g2(nc,1); vector<int> tab2(nc); for(int j=0; j<nc; j++){ Ic[j] = j; double rho = ((double) rand() / (RAND_MAX)); // (double) otherwise integer division! double theta = ((double) rand() / (RAND_MAX)); p2[j][0] = sqrt(rho)*cos(2*M_PI*theta); p2[j][1] = sqrt(rho)*sin(2*M_PI*theta); p2[j][2] = z2; r2[j]=0.; tab2[j]=j; } // Clustering GeometricClustering t, s; t.build(p1,r1,tab1,g1); s.build(p2,r2,tab2,g2); MyMatrix A(p1,p2); double norm_A= A.normFrob(); // SVD with fixed rank SVD<double,GeometricClustering> A_SVD(t.get_perm(),s.get_perm(),reqrank_max); A_SVD.build(A,t,p1,tab1,s,p2,tab2); std::vector<double> SVD_fixed_errors; for (int k = 0 ; k < A_SVD.rank_of()+1 ; k++){ SVD_fixed_errors.push_back(Frobenius_absolute_error(A_SVD,A,k)/norm_A); } // fullACA with fixed rank fullACA<double,GeometricClustering> A_fullACA_fixed(t.get_perm(),s.get_perm(),reqrank_max); A_fullACA_fixed.build(A,t,p1,tab1,s,p2,tab2); std::vector<double> fullACA_fixed_errors; for (int k = 0 ; k < A_fullACA_fixed.rank_of()+1 ; k++){ fullACA_fixed_errors.push_back(Frobenius_absolute_error(A_fullACA_fixed,A,k)/norm_A); } // partialACA with fixed rank partialACA<double,GeometricClustering> A_partialACA_fixed(t.get_perm(),s.get_perm(),reqrank_max); A_partialACA_fixed.build(A,t,p1,tab1,s,p2,tab2); std::vector<double> partialACA_fixed_errors; for (int k = 0 ; k < A_partialACA_fixed.rank_of()+1 ; k++){ partialACA_fixed_errors.push_back(Frobenius_absolute_error(A_partialACA_fixed,A,k)/norm_A); } // sympartialACA with fixed rank sympartialACA<double,GeometricClustering> A_sympartialACA_fixed(t.get_perm(),s.get_perm(),reqrank_max); A_sympartialACA_fixed.build(A,t,p1,tab1,s,p2,tab2); std::vector<double> sympartialACA_fixed_errors; for (int k = 0 ; k < A_sympartialACA_fixed.rank_of()+1 ; k++){ sympartialACA_fixed_errors.push_back(Frobenius_absolute_error(A_sympartialACA_fixed,A,k)/norm_A); } // Output ofstream file_fixed((outputpath+"/"+outputfile).c_str()); file_fixed<<"Rank,SVD,Full ACA,partial ACA,sym partial ACA"<<endl; for (int i=0;i<reqrank_max;i++){ file_fixed<<i<<","<<SVD_fixed_errors[i]<<","<<fullACA_fixed_errors[i]<<","<<partialACA_fixed_errors[i]<<","<<sympartialACA_fixed_errors[i]<<endl; } ofstream geometry_1((outputpath+"/geometry_1_"+outputfile).c_str()); for (int i=0;i<nr;i++){ geometry_1<<p1[i][0]<<","<<p1[i][1]<<","<<p1[i][2]<<endl; } ofstream geometry_2((outputpath+"/geometry_2_"+outputfile).c_str()); for (int i=0;i<nc;i++){ geometry_2<<p2[i][0]<<","<<p2[i][1]<<","<<p2[i][2]<<endl; } // Finalize the MPI environment. MPI_Finalize(); }
#include <libclientserver.h> #include <TestServer.h> int main(int argc, char **argv) { TestServer TS; ClientBase *Client = Client::Create("unix:/tmp/TestServer"); Client->Connect(); Client->WaitForConnect(); Client->Disconnect(); delete Client; return 0; }
/* * Copyright (c) 2016, Fabian Langguth * TU Darmstadt - Graphics, Capture and Massively Parallel Computing * All rights reserved. * * This software may be modified and distributed under the terms * of the BSD 3-Clause license. See the LICENSE.txt file for details. */ #include <set> #include <iostream> #include "mve/core/mesh_tools.h" #include "mve/math/matrix_tools.h" #include "mesh_simplifier.h" namespace smvs { /* Edge collapse from MVE repo (c) Simon Fuhrmann Updated by Fabian Langguth to include non manifold check and fix bugs */ /* TODO: make edge collapse accessible in MVE rather than having it here */ bool edge_collapse (mve::core::TriangleMesh::Ptr mesh, mve::core::MeshInfo& mesh_info, std::size_t v1, std::size_t v2, mve::math::Vec3f const& new_vert, std::vector<std::size_t> const& afaces, float acos_threshold = 0.95f) { mve::core::TriangleMesh::FaceList& faces = mesh->get_faces(); mve::core::TriangleMesh::VertexList& verts = mesh->get_vertices(); /* Test if the hypothetical vertex destroys geometry. */ mve::core::MeshInfo::VertexInfo& vinfo1 = mesh_info[v1]; for (std::size_t i = 0; i < vinfo1.verts.size(); ++i) { std::size_t ip1 = (i + 1) % vinfo1.verts.size(); if (vinfo1.verts[i] == v2 || vinfo1.verts[ip1] == v2) continue; mve::math::Vec3f const& av1 = verts[vinfo1.verts[i]]; mve::math::Vec3f const& av2 = verts[vinfo1.verts[ip1]]; mve::math::Vec3f n1 = (av1 - verts[v1]).cross(av2 - verts[v1]).normalized(); mve::math::Vec3f n2 = (av1 - new_vert).cross(av2 - new_vert).normalized(); float dot = n1.dot(n2); if (MATH_ISNAN(dot)|| dot < acos_threshold) return false; } mve::core::MeshInfo::VertexInfo& vinfo2 = mesh_info[v2]; for (std::size_t i = 0; i < vinfo2.verts.size(); ++i) { std::size_t ip1 = (i + 1) % vinfo2.verts.size(); if (vinfo2.verts[i] == v1 || vinfo2.verts[ip1] == v1) continue; mve::math::Vec3f const& av1 = verts[vinfo2.verts[i]]; mve::math::Vec3f const& av2 = verts[vinfo2.verts[ip1]]; mve::math::Vec3f n1 = (av1 - verts[v2]).cross(av2 - verts[v2]).normalized(); mve::math::Vec3f n2 = (av1 - new_vert).cross(av2 - new_vert).normalized(); float dot = n1.dot(n2); if (MATH_ISNAN(dot) || dot < acos_threshold) return false; } /* Test if collapse creates nonmanifold */ std::size_t joint_neighbors = 0; for (std::size_t i = 0; i < vinfo1.verts.size(); ++i) for (std::size_t j = 0; j < vinfo2.verts.size(); ++j) if (vinfo1.verts[i] == vinfo2.verts[j]) { joint_neighbors += 1; continue; } if (joint_neighbors != 2) return false; /* Test succeeded. Assign new vertex position to v1. */ verts[v1] = new_vert; /* Delete the two faces adjacent to the collapsed edge. */ std::size_t v3 = 0, v4 = 0; for (std::size_t i = 0; i < 3; ++i) { std::size_t fid1 = afaces[0] * 3 + i; std::size_t fid2 = afaces[1] * 3 + i; if (faces[fid1] != v1 && faces[fid1] != v2) v3 = faces[fid1]; if (faces[fid2] != v1 && faces[fid2] != v2) v4 = faces[fid2]; faces[fid1] = 0; faces[fid2] = 0; } /* Update vertex info for vertices adjcent to v2, replacing v2 with v1. */ for (std::size_t i = 0; i < vinfo2.verts.size(); ++i) { std::size_t const vert_id = vinfo2.verts[i]; if (vert_id != v1 && vert_id != v3 && vert_id != v4) mesh_info[vert_id].replace_adjacent_vertex(v2, v1); } /* Update faces adjacent to v2 replacing v2 with v1. */ for (std::size_t i = 0; i < vinfo2.faces.size(); ++i) for (std::size_t j = 0; j < 3; ++j) if (faces[vinfo2.faces[i] * 3 + j] == v2) faces[vinfo2.faces[i] * 3 + j] = static_cast<unsigned int>(v1); /* Update vertex info for v3 and v4: remove v2, remove deleted faces. */ mve::core::MeshInfo::VertexInfo& vinfo3 = mesh_info[v3]; vinfo3.remove_adjacent_face(afaces[0]); vinfo3.remove_adjacent_vertex(v2); mve::core::MeshInfo::VertexInfo& vinfo4 = mesh_info[v4]; vinfo4.remove_adjacent_face(afaces[1]); vinfo4.remove_adjacent_vertex(v2); /* Update vinfo for v1: Remove v2, remove collapsed faces, add v2 faces. */ vinfo1.remove_adjacent_vertex(v2); vinfo1.remove_adjacent_face(afaces[0]); vinfo1.remove_adjacent_face(afaces[1]); for (std::size_t i = 0; i < vinfo2.faces.size(); ++i) if (vinfo2.faces[i] != afaces[0] && vinfo2.faces[i] != afaces[1]) vinfo1.faces.push_back(vinfo2.faces[i]); /* Clear verts for v1 and re-add with new faces */ vinfo1.verts.clear(); mesh_info.update_vertex(*mesh, v1); /* Update vertex info for v2. */ vinfo2.faces.clear(); vinfo2.verts.clear(); vinfo2.vclass = mve::core::MeshInfo::VERTEX_CLASS_UNREF; return true; } void MeshSimplifier::compute_initial_quadrics (void) { mve::core::TriangleMesh::VertexList & verts = this->mesh->get_vertices(); mve::core::TriangleMesh::FaceList & faces = this->mesh->get_faces(); this->quadrics.resize(this->mesh_info.size()); for (std::size_t v = 0; v < this->mesh_info.size(); ++v) { this->quadrics[v].fill(0); mve::core::MeshInfo::VertexInfo const& vinfo = this->mesh_info.at(v); for (std::size_t f = 0; f < vinfo.faces.size(); ++f) { mve::math::Vec3d faceverts[3]; for (std::size_t i = 0; i < 3; ++i) faceverts[i] = verts[faces[vinfo.faces[f] * 3 + i]]; mve::math::Vec3d normal = (faceverts[1] - faceverts[0]).cross( faceverts[2] - faceverts[0]).normalized(); mve::math::Vec4d face_plane(normal, -normal.dot(faceverts[0])); for (int r = 0; r < 4; ++r) for (int c = 0; c < 4; ++c) this->quadrics[v](r, c) += face_plane[r] * face_plane[c]; } } } MeshSimplifier::SimplifyEdge MeshSimplifier::create_simplify_edge (std::size_t v1, std::size_t v2) { mve::core::TriangleMesh::VertexList & verts = this->mesh->get_vertices(); SimplifyEdge sedge; sedge.v1 = v1; sedge.v2 = v2; sedge.quadric = this->quadrics[v1] + this->quadrics[v2]; /* Compute optimal vertex position */ mve::math::Matrix4d Q = sedge.quadric; Q(3,0) = Q(3,1) = Q(3,2) = 0; Q(3,3) = 1.0; double det = mve::math::matrix_determinant(Q); if (det != 0.0) { /* compute optimal vertex position */ Q = mve::math::matrix_inverse(Q); mve::math::Vec4d rhs(0.0, 0.0, 0.0, 1.0); mve::math::Vec4d vert4 = Q*rhs; sedge.new_vert = mve::math::Vec3d(*vert4); sedge.cost = std::max(0.0, (sedge.quadric * vert4).dot(vert4)); } else { /* Choose average between v1 and v2 */ sedge.new_vert = (verts[v1] + verts[v2]) * 0.5; mve::math::Vec4d vert4(sedge.new_vert, 1.0); sedge.cost = std::max(0.0, (sedge.quadric * vert4).dot(vert4)); } return sedge; } void MeshSimplifier::fill_queue (void) { /* find all edges to simplify */ std::set<std::pair<std::size_t, std::size_t>> edges; for (std::size_t v = 0; v < this->mesh_info.size(); ++v) { mve::core::MeshInfo::VertexInfo const& vinfo = this->mesh_info.at(v); if (vinfo.vclass != mve::core::MeshInfo::VERTEX_CLASS_SIMPLE) continue; for (std::size_t n = 0; n < vinfo.verts.size(); ++n) if (vinfo.verts[n] < v) edges.emplace(vinfo.verts[n], v); else edges.emplace(v, vinfo.verts[n]); } /* Fill initial queue for edge collapses */ for (auto const& edge : edges) this->removal_queue.emplace( this->create_simplify_edge(edge.first, edge.second)); } mve::core::TriangleMesh::Ptr MeshSimplifier::get_simplified (float percent) { this->mesh = this->input_mesh->duplicate(); this->compute_initial_quadrics(); mve::core::TriangleMesh::VertexList & verts = this->mesh->get_vertices(); this->fill_queue(); float initial_size = verts.size(); std::size_t target_remove = initial_size - (initial_size * percent / 100); std::size_t removed = 0; while (!removal_queue.empty() && removed < target_remove) { SimplifyEdge const& sedge = removal_queue.top(); std::size_t const v1 = sedge.v1; std::size_t const v2 = sedge.v2; /* Skip already collapsed vertices */ if (this->mesh_info[v1].vclass == mve::core::MeshInfo::VERTEX_CLASS_UNREF || this->mesh_info[v2].vclass == mve::core::MeshInfo::VERTEX_CLASS_UNREF) { removal_queue.pop(); continue; } std::vector<std::size_t> afaces; this->mesh_info.get_faces_for_edge(v1, v2, &afaces); /* Collapse edge */ bool collapsed = edge_collapse(this->mesh, this->mesh_info, v1, v2, sedge.new_vert, afaces); /* Cannot collapse, remove edge from queue */ if (!collapsed) { removal_queue.pop(); continue; } /* Collapse sucessfull */ removed += 1; /* Update Quartic for new vertex */ this->quadrics[v1] = sedge.quadric; /* add new edges to queue */ mve::core::MeshInfo::VertexInfo const& vinfo = this->mesh_info.at(v1); for (std::size_t n = 0; n < vinfo.verts.size(); ++n) this->removal_queue.emplace( this->create_simplify_edge(v1, vinfo.verts[n])); removal_queue.pop(); } /* Cleanup invalid triangles and unreferenced vertices. */ mve::core::geom::mesh_delete_unreferenced(mesh); return this->mesh; } } // namespace smvs
/* * Warhammer Age of Sigmar battle simulator. * * Copyright (C) 2019 by Rick Weyrauch - rpweyrauch@gmail.com * * This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) */ #include <cassert> #include <Dice.h> #include <AgeOfSigmarSim.h> std::random_device Dice::s_rd; std::mt19937 Dice::s_gen(s_rd()); std::uniform_int_distribution<int> Dice::s_d6(1, 6); std::uniform_int_distribution<int> Dice::s_d4(1, 4); int Dice::RollD6() { return s_d6(s_gen); } int Dice::Roll2D6() { return (s_d6(s_gen) + s_d6(s_gen)); } int Dice::Roll3D6() { return (s_d6(s_gen) + s_d6(s_gen) + s_d6(s_gen)); } int Dice::Roll4D6() { return (s_d6(s_gen) + s_d6(s_gen) + s_d6(s_gen) + s_d6(s_gen)); } int Dice::RollD3() { return (s_d6(s_gen) + 1) / 2; } int Dice::RollD4() { return (s_d4(s_gen)); } std::vector<int> Dice::RollD6(int number) { std::vector<int> result((size_t) number); for (auto i = 0; i < number; i++) { result[i] = s_d6(s_gen); } return result; } std::vector<int> Dice::RollD6(int number, int rerolling) { assert(rerolling >= 1); assert(rerolling <= 6); std::vector<int> result((size_t) number); for (auto i = 0; i < number; i++) { result[i] = s_d6(s_gen); if (result[i] <= rerolling) { result[i] = s_d6(s_gen); } } return result; } void Dice::RollD6(int number, Dice::RollResult &result) { result.clear(); for (auto i = 0; i < number; i++) { result.m_distribution[s_d6(s_gen)]++; } } void Dice::RollD6(int number, int rerolling, Dice::RollResult &result) { assert(rerolling >= 1); assert(rerolling <= 6); result.clear(); for (auto i = 0; i < number; i++) { int roll = s_d6(s_gen); if (roll <= rerolling) { roll = s_d6(s_gen); } result.m_distribution[roll]++; } } int Dice::RollSpecial(int number) { if (number >= 0) { return number; } else if (number == RAND_D3) { return RollD3(); } else if (number == RAND_2D3) { return RollD3() + RollD3(); } else if (number == RAND_D6) { return RollD6(); } else if (number == RAND_2D6) { return Roll2D6(); } else if (number == RAND_3D6) { return Roll3D6(); } else if (number == RAND_4D6) { return Roll4D6(); } return 0; }
#include <SDL.h> // SDL2 #include <windows.h> #include "vkmap.hpp" #include "btnmap.hpp" #include "ini.hpp" #include <iostream> #include <stdlib.h> void send_key(WORD vk, bool is_press) { static HKL hkl = GetKeyboardLayout(0); INPUT ip; ip.type = INPUT_KEYBOARD; ip.ki.wVk = vk; ip.ki.wScan = MapVirtualKeyEx(vk, 0, hkl); ip.ki.time = 0; ip.ki.dwExtraInfo = 0; ip.ki.dwFlags = is_press ? 0 : KEYEVENTF_KEYUP; SendInput(1, &ip, sizeof(INPUT)); } bool load_config(void* user, const std::string& section, const std::string& key, const std::string& value, int line, const std::string& filename) { WORD* btn2vk = static_cast<WORD*>(user); std::string line_num_str = filename + "(" + std::to_string(line) + "): "; if (std::string(section) == "button") { auto btn = g_btnmap.find(key); if (btn == g_btnmap.end()) { std::cerr << line_num_str << "'" << key << "' is invalid name for gamepad's button\n"; return false; } auto vk = g_vkmap.find(value); if (vk == g_vkmap.end()) { std::cerr << line_num_str << "'" << key << "=" << value << "' is invalid name for key\n"; return false; } btn2vk[btn->second] = vk->second; } else { std::cerr << line_num_str << "Unknown SECTION: '" << section << "'\n"; return false; } return true; } int main(int argc, char** argv) { if (argc < 2) { std::cerr << "gamepad2key.exe require .ini file\n"; std::cerr << "Usage: gamepad2key.exe [your.ini]\n"; return -1; } if (SDL_Init(SDL_INIT_GAMECONTROLLER) < 0) { std::cerr << SDL_GetError() << std::endl; return -1; } atexit(SDL_Quit); WORD btn2vk[32]; memset(btn2vk, 0, sizeof(btn2vk)); if (ini_parse(argv[1], load_config, btn2vk) == false) { std::cerr << "\n*** Failed to launch gamepad2key.exe ***\n"; goto game_over; } SDL_GameController* pad = NULL; for (;;) { SDL_Event ev; SDL_WaitEvent(&ev); if(ev.type == SDL_CONTROLLERDEVICEADDED) { if (SDL_IsGameController(ev.cdevice.which)) { SDL_GameController* c = SDL_GameControllerOpen(ev.cdevice.which); if (c) { pad = c; std::cout << "Added: " << SDL_GameControllerName(c) << std::endl; } } else { std::cerr << "'" << SDL_JoystickNameForIndex(ev.cdevice.which) << "' is not supported gamepad\n"; } } else if(ev.type == SDL_CONTROLLERDEVICEREMOVED) { if (pad == SDL_GameControllerFromInstanceID(ev.cdevice.which)) pad = NULL; } else if(ev.type == SDL_CONTROLLERBUTTONDOWN) { if (pad == SDL_GameControllerFromInstanceID(ev.cbutton.which)) { send_key(btn2vk[ev.cbutton.button], true); } } else if(ev.type == SDL_CONTROLLERBUTTONUP) { if (pad == SDL_GameControllerFromInstanceID(ev.cbutton.which)) { send_key(btn2vk[ev.cbutton.button], false); } } } game_over: return 0; }
#include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <cstring> #include <string.h> #include <stdio.h> #include <cmath> #include <limits> #include <assert.h> #include "il2cpp-class-internals.h" #include "codegen/il2cpp-codegen.h" extern const int32_t g_FieldOffsetTable5[3]; extern const int32_t g_FieldOffsetTable11[3]; extern const int32_t g_FieldOffsetTable12[1]; extern const int32_t g_FieldOffsetTable14[3]; extern const int32_t g_FieldOffsetTable15[3]; extern const int32_t g_FieldOffsetTable16[1]; extern const int32_t g_FieldOffsetTable17[1]; extern const int32_t g_FieldOffsetTable18[3]; extern const int32_t g_FieldOffsetTable19[1]; extern const int32_t g_FieldOffsetTable20[1]; extern const int32_t g_FieldOffsetTable21[3]; extern const int32_t g_FieldOffsetTable26[10]; extern const int32_t g_FieldOffsetTable27[4]; extern const int32_t g_FieldOffsetTable30[8]; extern const int32_t g_FieldOffsetTable31[14]; extern const int32_t g_FieldOffsetTable32[9]; extern const int32_t g_FieldOffsetTable33[3]; extern const int32_t g_FieldOffsetTable34[2]; extern const int32_t g_FieldOffsetTable36[2]; extern const int32_t g_FieldOffsetTable37[2]; extern const int32_t g_FieldOffsetTable38[9]; extern const int32_t g_FieldOffsetTable39[1]; extern const int32_t g_FieldOffsetTable41[2]; extern const int32_t g_FieldOffsetTable42[3]; extern const int32_t g_FieldOffsetTable43[1]; extern const int32_t g_FieldOffsetTable44[4]; extern const int32_t g_FieldOffsetTable51[8]; extern const int32_t g_FieldOffsetTable57[11]; extern const int32_t g_FieldOffsetTable59[1]; extern const int32_t g_FieldOffsetTable60[1]; extern const int32_t g_FieldOffsetTable63[2]; extern const int32_t g_FieldOffsetTable64[9]; extern const int32_t g_FieldOffsetTable65[7]; extern const int32_t g_FieldOffsetTable68[1]; extern const int32_t g_FieldOffsetTable71[2]; extern const int32_t g_FieldOffsetTable73[2]; extern const int32_t g_FieldOffsetTable74[1]; extern const int32_t g_FieldOffsetTable76[1]; extern const int32_t g_FieldOffsetTable77[5]; extern const int32_t g_FieldOffsetTable78[1]; extern const int32_t g_FieldOffsetTable79[1]; extern const int32_t g_FieldOffsetTable82[3]; extern const int32_t g_FieldOffsetTable83[4]; extern const int32_t g_FieldOffsetTable84[1]; extern const int32_t g_FieldOffsetTable85[2]; extern const int32_t g_FieldOffsetTable88[1]; extern const int32_t g_FieldOffsetTable93[4]; extern const int32_t g_FieldOffsetTable94[5]; extern const int32_t g_FieldOffsetTable95[4]; extern const int32_t g_FieldOffsetTable96[3]; extern const int32_t g_FieldOffsetTable97[1]; extern const int32_t g_FieldOffsetTable98[2]; extern const int32_t g_FieldOffsetTable99[1]; extern const int32_t g_FieldOffsetTable100[22]; extern const int32_t g_FieldOffsetTable101[7]; extern const int32_t g_FieldOffsetTable102[13]; extern const int32_t g_FieldOffsetTable103[8]; extern const int32_t g_FieldOffsetTable104[2]; extern const int32_t g_FieldOffsetTable105[5]; extern const int32_t g_FieldOffsetTable106[6]; extern const int32_t g_FieldOffsetTable107[4]; extern const int32_t g_FieldOffsetTable108[22]; extern const int32_t g_FieldOffsetTable111[7]; extern const int32_t g_FieldOffsetTable113[4]; extern const int32_t g_FieldOffsetTable114[4]; extern const int32_t g_FieldOffsetTable115[2]; extern const int32_t g_FieldOffsetTable118[1]; extern const int32_t g_FieldOffsetTable119[4]; extern const int32_t g_FieldOffsetTable120[13]; extern const int32_t g_FieldOffsetTable122[9]; extern const int32_t g_FieldOffsetTable123[5]; extern const int32_t g_FieldOffsetTable124[4]; extern const int32_t g_FieldOffsetTable126[4]; extern const int32_t g_FieldOffsetTable127[4]; extern const int32_t g_FieldOffsetTable128[13]; extern const int32_t g_FieldOffsetTable130[12]; extern const int32_t g_FieldOffsetTable131[2]; extern const int32_t g_FieldOffsetTable132[17]; extern const int32_t g_FieldOffsetTable133[7]; extern const int32_t g_FieldOffsetTable134[15]; extern const int32_t g_FieldOffsetTable135[21]; extern const int32_t g_FieldOffsetTable137[1]; extern const int32_t g_FieldOffsetTable138[3]; extern const int32_t g_FieldOffsetTable139[1]; extern const int32_t g_FieldOffsetTable140[3]; extern const int32_t g_FieldOffsetTable144[2]; extern const int32_t g_FieldOffsetTable145[4]; extern const int32_t g_FieldOffsetTable146[6]; extern const int32_t g_FieldOffsetTable147[3]; extern const int32_t g_FieldOffsetTable148[13]; extern const int32_t g_FieldOffsetTable151[2]; extern const int32_t g_FieldOffsetTable152[2]; extern const int32_t g_FieldOffsetTable156[1]; extern const int32_t g_FieldOffsetTable159[2]; extern const int32_t g_FieldOffsetTable160[16]; extern const int32_t g_FieldOffsetTable161[1]; extern const int32_t g_FieldOffsetTable162[4]; extern const int32_t g_FieldOffsetTable163[1]; extern const int32_t g_FieldOffsetTable164[1]; extern const int32_t g_FieldOffsetTable165[1]; extern const int32_t g_FieldOffsetTable166[1]; extern const int32_t g_FieldOffsetTable168[1]; extern const int32_t g_FieldOffsetTable175[2]; extern const int32_t g_FieldOffsetTable176[5]; extern const int32_t g_FieldOffsetTable177[4]; extern const int32_t g_FieldOffsetTable178[2]; extern const int32_t g_FieldOffsetTable179[1]; extern const int32_t g_FieldOffsetTable180[5]; extern const int32_t g_FieldOffsetTable181[5]; extern const int32_t g_FieldOffsetTable182[1]; extern const int32_t g_FieldOffsetTable183[1]; extern const int32_t g_FieldOffsetTable186[3]; extern const int32_t g_FieldOffsetTable187[4]; extern const int32_t g_FieldOffsetTable188[3]; extern const int32_t g_FieldOffsetTable189[3]; extern const int32_t g_FieldOffsetTable190[1]; extern const int32_t g_FieldOffsetTable192[3]; extern const int32_t g_FieldOffsetTable193[2]; extern const int32_t g_FieldOffsetTable194[14]; extern const int32_t g_FieldOffsetTable195[2]; extern const int32_t g_FieldOffsetTable196[1]; extern const int32_t g_FieldOffsetTable197[4]; extern const int32_t g_FieldOffsetTable198[8]; extern const int32_t g_FieldOffsetTable199[1]; extern const int32_t g_FieldOffsetTable200[1]; extern const int32_t g_FieldOffsetTable201[1]; extern const int32_t g_FieldOffsetTable207[6]; extern const int32_t g_FieldOffsetTable208[3]; extern const int32_t g_FieldOffsetTable209[6]; extern const int32_t g_FieldOffsetTable210[2]; extern const int32_t g_FieldOffsetTable211[4]; extern const int32_t g_FieldOffsetTable212[9]; extern const int32_t g_FieldOffsetTable213[5]; extern const int32_t g_FieldOffsetTable214[3]; extern const int32_t g_FieldOffsetTable215[4]; extern const int32_t g_FieldOffsetTable216[4]; extern const int32_t g_FieldOffsetTable218[3]; extern const int32_t g_FieldOffsetTable219[6]; extern const int32_t g_FieldOffsetTable220[1]; extern const int32_t g_FieldOffsetTable221[4]; extern const int32_t g_FieldOffsetTable222[3]; extern const int32_t g_FieldOffsetTable224[1]; extern const int32_t g_FieldOffsetTable225[8]; extern const int32_t g_FieldOffsetTable226[3]; extern const int32_t g_FieldOffsetTable227[4]; extern const int32_t g_FieldOffsetTable231[8]; extern const int32_t g_FieldOffsetTable232[10]; extern const int32_t g_FieldOffsetTable233[40]; extern const int32_t g_FieldOffsetTable234[6]; extern const int32_t g_FieldOffsetTable235[58]; extern const int32_t g_FieldOffsetTable236[11]; extern const int32_t g_FieldOffsetTable237[3]; extern const int32_t g_FieldOffsetTable238[1]; extern const int32_t g_FieldOffsetTable239[7]; extern const int32_t g_FieldOffsetTable240[39]; extern const int32_t g_FieldOffsetTable241[18]; extern const int32_t g_FieldOffsetTable242[11]; extern const int32_t g_FieldOffsetTable243[9]; extern const int32_t g_FieldOffsetTable244[5]; extern const int32_t g_FieldOffsetTable245[31]; extern const int32_t g_FieldOffsetTable247[6]; extern const int32_t g_FieldOffsetTable248[7]; extern const int32_t g_FieldOffsetTable250[2]; extern const int32_t g_FieldOffsetTable254[4]; extern const int32_t g_FieldOffsetTable255[15]; extern const int32_t g_FieldOffsetTable256[1]; extern const int32_t g_FieldOffsetTable257[4]; extern const int32_t g_FieldOffsetTable258[7]; extern const int32_t g_FieldOffsetTable259[2]; extern const int32_t g_FieldOffsetTable260[8]; extern const int32_t g_FieldOffsetTable261[7]; extern const int32_t g_FieldOffsetTable262[14]; extern const int32_t g_FieldOffsetTable265[8]; extern const int32_t g_FieldOffsetTable266[4]; extern const int32_t g_FieldOffsetTable268[10]; extern const int32_t g_FieldOffsetTable269[6]; extern const int32_t g_FieldOffsetTable270[2]; extern const int32_t g_FieldOffsetTable271[25]; extern const int32_t g_FieldOffsetTable272[6]; extern const int32_t g_FieldOffsetTable273[8]; extern const int32_t g_FieldOffsetTable275[2]; extern const int32_t g_FieldOffsetTable276[4]; extern const int32_t g_FieldOffsetTable277[1]; extern const int32_t g_FieldOffsetTable279[6]; extern const int32_t g_FieldOffsetTable280[13]; extern const int32_t g_FieldOffsetTable282[10]; extern const int32_t g_FieldOffsetTable283[3]; extern const int32_t g_FieldOffsetTable284[1]; extern const int32_t g_FieldOffsetTable286[1]; extern const int32_t g_FieldOffsetTable287[2]; extern const int32_t g_FieldOffsetTable289[2]; extern const int32_t g_FieldOffsetTable290[2]; extern const int32_t g_FieldOffsetTable292[8]; extern const int32_t g_FieldOffsetTable293[5]; extern const int32_t g_FieldOffsetTable294[2]; extern const int32_t g_FieldOffsetTable295[6]; extern const int32_t g_FieldOffsetTable296[4]; extern const int32_t g_FieldOffsetTable297[38]; extern const int32_t g_FieldOffsetTable298[5]; extern const int32_t g_FieldOffsetTable299[11]; extern const int32_t g_FieldOffsetTable301[1]; extern const int32_t g_FieldOffsetTable303[18]; extern const int32_t g_FieldOffsetTable304[2]; extern const int32_t g_FieldOffsetTable306[5]; extern const int32_t g_FieldOffsetTable307[4]; extern const int32_t g_FieldOffsetTable308[2]; extern const int32_t g_FieldOffsetTable310[14]; extern const int32_t g_FieldOffsetTable311[3]; extern const int32_t g_FieldOffsetTable312[2]; extern const int32_t g_FieldOffsetTable313[1]; extern const int32_t g_FieldOffsetTable314[1]; extern const int32_t g_FieldOffsetTable315[27]; extern const int32_t g_FieldOffsetTable316[2]; extern const int32_t g_FieldOffsetTable317[21]; extern const int32_t g_FieldOffsetTable318[1]; extern const int32_t g_FieldOffsetTable319[8]; extern const int32_t g_FieldOffsetTable320[1]; extern const int32_t g_FieldOffsetTable321[226]; extern const int32_t g_FieldOffsetTable322[19]; extern const int32_t g_FieldOffsetTable323[4]; extern const int32_t g_FieldOffsetTable324[10]; extern const int32_t g_FieldOffsetTable325[3]; extern const int32_t g_FieldOffsetTable326[6]; extern const int32_t g_FieldOffsetTable327[30]; extern const int32_t g_FieldOffsetTable328[26]; extern const int32_t g_FieldOffsetTable329[9]; extern const int32_t g_FieldOffsetTable331[10]; extern const int32_t g_FieldOffsetTable333[1]; extern const int32_t g_FieldOffsetTable334[1]; extern const int32_t g_FieldOffsetTable335[1]; extern const int32_t g_FieldOffsetTable336[1]; extern const int32_t g_FieldOffsetTable337[1]; extern const int32_t g_FieldOffsetTable338[1]; extern const int32_t g_FieldOffsetTable339[1]; extern const int32_t g_FieldOffsetTable340[1]; extern const int32_t g_FieldOffsetTable341[1]; extern const int32_t g_FieldOffsetTable342[15]; extern const int32_t g_FieldOffsetTable343[6]; extern const int32_t g_FieldOffsetTable344[1]; extern const int32_t g_FieldOffsetTable345[1]; extern const int32_t g_FieldOffsetTable346[1]; extern const int32_t g_FieldOffsetTable347[1]; extern const int32_t g_FieldOffsetTable349[21]; extern const int32_t g_FieldOffsetTable350[6]; extern const int32_t g_FieldOffsetTable351[2]; extern const int32_t g_FieldOffsetTable352[3]; extern const int32_t g_FieldOffsetTable353[2]; extern const int32_t g_FieldOffsetTable354[2]; extern const int32_t g_FieldOffsetTable355[5]; extern const int32_t g_FieldOffsetTable356[1]; extern const int32_t g_FieldOffsetTable358[20]; extern const int32_t g_FieldOffsetTable360[4]; extern const int32_t g_FieldOffsetTable361[3]; extern const int32_t g_FieldOffsetTable362[5]; extern const int32_t g_FieldOffsetTable363[10]; extern const int32_t g_FieldOffsetTable364[25]; extern const int32_t g_FieldOffsetTable366[15]; extern const int32_t g_FieldOffsetTable368[1]; extern const int32_t g_FieldOffsetTable369[10]; extern const int32_t g_FieldOffsetTable370[8]; extern const int32_t g_FieldOffsetTable371[2]; extern const int32_t g_FieldOffsetTable372[5]; extern const int32_t g_FieldOffsetTable375[5]; extern const int32_t g_FieldOffsetTable376[3]; extern const int32_t g_FieldOffsetTable377[3]; extern const int32_t g_FieldOffsetTable378[5]; extern const int32_t g_FieldOffsetTable379[7]; extern const int32_t g_FieldOffsetTable380[5]; extern const int32_t g_FieldOffsetTable384[12]; extern const int32_t g_FieldOffsetTable385[7]; extern const int32_t g_FieldOffsetTable386[1]; extern const int32_t g_FieldOffsetTable387[2]; extern const int32_t g_FieldOffsetTable388[6]; extern const int32_t g_FieldOffsetTable389[6]; extern const int32_t g_FieldOffsetTable390[9]; extern const int32_t g_FieldOffsetTable392[3]; extern const int32_t g_FieldOffsetTable393[5]; extern const int32_t g_FieldOffsetTable397[32]; extern const int32_t g_FieldOffsetTable398[1]; extern const int32_t g_FieldOffsetTable400[1]; extern const int32_t g_FieldOffsetTable401[5]; extern const int32_t g_FieldOffsetTable402[21]; extern const int32_t g_FieldOffsetTable403[13]; extern const int32_t g_FieldOffsetTable404[3]; extern const int32_t g_FieldOffsetTable405[2]; extern const int32_t g_FieldOffsetTable406[3]; extern const int32_t g_FieldOffsetTable407[4]; extern const int32_t g_FieldOffsetTable409[1]; extern const int32_t g_FieldOffsetTable410[21]; extern const int32_t g_FieldOffsetTable411[2]; extern const int32_t g_FieldOffsetTable412[2]; extern const int32_t g_FieldOffsetTable414[2]; extern const int32_t g_FieldOffsetTable415[1]; extern const int32_t g_FieldOffsetTable416[1]; extern const int32_t g_FieldOffsetTable418[4]; extern const int32_t g_FieldOffsetTable420[4]; extern const int32_t g_FieldOffsetTable421[5]; extern const int32_t g_FieldOffsetTable423[2]; extern const int32_t g_FieldOffsetTable426[6]; extern const int32_t g_FieldOffsetTable427[5]; extern const int32_t g_FieldOffsetTable428[1]; extern const int32_t g_FieldOffsetTable429[4]; extern const int32_t g_FieldOffsetTable430[1]; extern const int32_t g_FieldOffsetTable431[4]; extern const int32_t g_FieldOffsetTable432[1]; extern const int32_t g_FieldOffsetTable433[1]; extern const int32_t g_FieldOffsetTable435[1]; extern const int32_t g_FieldOffsetTable436[5]; extern const int32_t g_FieldOffsetTable437[1]; extern const int32_t g_FieldOffsetTable438[2]; extern const int32_t g_FieldOffsetTable439[1]; extern const int32_t g_FieldOffsetTable441[4]; extern const int32_t g_FieldOffsetTable442[1]; extern const int32_t g_FieldOffsetTable443[2]; extern const int32_t g_FieldOffsetTable444[1]; extern const int32_t g_FieldOffsetTable445[36]; extern const int32_t g_FieldOffsetTable471[1]; extern const int32_t g_FieldOffsetTable472[2]; extern const int32_t g_FieldOffsetTable474[1]; extern const int32_t g_FieldOffsetTable478[1]; extern const int32_t g_FieldOffsetTable479[1]; extern const int32_t g_FieldOffsetTable480[5]; extern const int32_t g_FieldOffsetTable481[3]; extern const int32_t g_FieldOffsetTable482[1]; extern const int32_t g_FieldOffsetTable483[3]; extern const int32_t g_FieldOffsetTable491[3]; extern const int32_t g_FieldOffsetTable492[14]; extern const int32_t g_FieldOffsetTable493[1]; extern const int32_t g_FieldOffsetTable494[2]; extern const int32_t g_FieldOffsetTable496[1]; extern const int32_t g_FieldOffsetTable507[5]; extern const int32_t g_FieldOffsetTable508[2]; extern const int32_t g_FieldOffsetTable509[2]; extern const int32_t g_FieldOffsetTable512[8]; extern const int32_t g_FieldOffsetTable514[2]; extern const int32_t g_FieldOffsetTable515[1]; extern const int32_t g_FieldOffsetTable516[6]; extern const int32_t g_FieldOffsetTable517[5]; extern const int32_t g_FieldOffsetTable518[3]; extern const int32_t g_FieldOffsetTable519[3]; extern const int32_t g_FieldOffsetTable520[15]; extern const int32_t g_FieldOffsetTable521[1]; extern const int32_t g_FieldOffsetTable522[7]; extern const int32_t g_FieldOffsetTable523[3]; extern const int32_t g_FieldOffsetTable524[1]; extern const int32_t g_FieldOffsetTable525[4]; extern const int32_t g_FieldOffsetTable535[2]; extern const int32_t g_FieldOffsetTable536[1]; extern const int32_t g_FieldOffsetTable537[11]; extern const int32_t g_FieldOffsetTable538[1]; extern const int32_t g_FieldOffsetTable539[6]; extern const int32_t g_FieldOffsetTable540[3]; extern const int32_t g_FieldOffsetTable541[2]; extern const int32_t g_FieldOffsetTable542[10]; extern const int32_t g_FieldOffsetTable543[5]; extern const int32_t g_FieldOffsetTable547[4]; extern const int32_t g_FieldOffsetTable548[13]; extern const int32_t g_FieldOffsetTable550[1]; extern const int32_t g_FieldOffsetTable551[2]; extern const int32_t g_FieldOffsetTable552[3]; extern const int32_t g_FieldOffsetTable553[2]; extern const int32_t g_FieldOffsetTable554[6]; extern const int32_t g_FieldOffsetTable556[7]; extern const int32_t g_FieldOffsetTable558[1]; extern const int32_t g_FieldOffsetTable559[8]; extern const int32_t g_FieldOffsetTable560[5]; extern const int32_t g_FieldOffsetTable562[1]; extern const int32_t g_FieldOffsetTable563[2]; extern const int32_t g_FieldOffsetTable564[1]; extern const int32_t g_FieldOffsetTable565[1]; extern const int32_t g_FieldOffsetTable569[7]; extern const int32_t g_FieldOffsetTable570[1]; extern const int32_t g_FieldOffsetTable571[1]; extern const int32_t g_FieldOffsetTable572[9]; extern const int32_t g_FieldOffsetTable573[13]; extern const int32_t g_FieldOffsetTable574[10]; extern const int32_t g_FieldOffsetTable575[7]; extern const int32_t g_FieldOffsetTable576[5]; extern const int32_t g_FieldOffsetTable579[8]; extern const int32_t g_FieldOffsetTable580[5]; extern const int32_t g_FieldOffsetTable584[5]; extern const int32_t g_FieldOffsetTable585[2]; extern const int32_t g_FieldOffsetTable586[2]; extern const int32_t g_FieldOffsetTable587[3]; extern const int32_t g_FieldOffsetTable588[3]; extern const int32_t g_FieldOffsetTable589[3]; extern const int32_t g_FieldOffsetTable590[3]; extern const int32_t g_FieldOffsetTable591[4]; extern const int32_t g_FieldOffsetTable592[24]; extern const int32_t g_FieldOffsetTable593[9]; extern const int32_t g_FieldOffsetTable594[11]; extern const int32_t g_FieldOffsetTable595[5]; extern const int32_t g_FieldOffsetTable596[7]; extern const int32_t g_FieldOffsetTable597[2]; extern const int32_t g_FieldOffsetTable599[12]; extern const int32_t g_FieldOffsetTable600[6]; extern const int32_t g_FieldOffsetTable601[1]; extern const int32_t g_FieldOffsetTable602[2]; extern const int32_t g_FieldOffsetTable603[1]; extern const int32_t g_FieldOffsetTable604[2]; extern const int32_t g_FieldOffsetTable605[1]; extern const int32_t g_FieldOffsetTable606[14]; extern const int32_t g_FieldOffsetTable607[2]; extern const int32_t g_FieldOffsetTable608[3]; extern const int32_t g_FieldOffsetTable609[4]; extern const int32_t g_FieldOffsetTable610[3]; extern const int32_t g_FieldOffsetTable619[3]; extern const int32_t g_FieldOffsetTable621[9]; extern const int32_t g_FieldOffsetTable622[4]; extern const int32_t g_FieldOffsetTable623[1]; extern const int32_t g_FieldOffsetTable624[1]; extern const int32_t g_FieldOffsetTable625[1]; extern const int32_t g_FieldOffsetTable626[1]; extern const int32_t g_FieldOffsetTable627[5]; extern const int32_t g_FieldOffsetTable628[13]; extern const int32_t g_FieldOffsetTable634[6]; extern const int32_t g_FieldOffsetTable636[3]; extern const int32_t g_FieldOffsetTable638[5]; extern const int32_t g_FieldOffsetTable639[1]; extern const int32_t g_FieldOffsetTable640[3]; extern const int32_t g_FieldOffsetTable641[2]; extern const int32_t g_FieldOffsetTable642[2]; extern const int32_t g_FieldOffsetTable643[10]; extern const int32_t g_FieldOffsetTable644[5]; extern const int32_t g_FieldOffsetTable645[7]; extern const int32_t g_FieldOffsetTable646[2]; extern const int32_t g_FieldOffsetTable650[2]; extern const int32_t g_FieldOffsetTable651[6]; extern const int32_t g_FieldOffsetTable652[3]; extern const int32_t g_FieldOffsetTable655[5]; extern const int32_t g_FieldOffsetTable656[9]; extern const int32_t g_FieldOffsetTable657[2]; extern const int32_t g_FieldOffsetTable658[13]; extern const int32_t g_FieldOffsetTable661[7]; extern const int32_t g_FieldOffsetTable662[8]; extern const int32_t g_FieldOffsetTable663[1]; extern const int32_t g_FieldOffsetTable664[1]; extern const int32_t g_FieldOffsetTable665[5]; extern const int32_t g_FieldOffsetTable670[2]; extern const int32_t g_FieldOffsetTable671[2]; extern const int32_t g_FieldOffsetTable672[4]; extern const int32_t g_FieldOffsetTable675[3]; extern const int32_t g_FieldOffsetTable676[1]; extern const int32_t g_FieldOffsetTable677[3]; extern const int32_t g_FieldOffsetTable679[6]; extern const int32_t g_FieldOffsetTable680[6]; extern const int32_t g_FieldOffsetTable681[1]; extern const int32_t g_FieldOffsetTable683[7]; extern const int32_t g_FieldOffsetTable685[5]; extern const int32_t g_FieldOffsetTable686[2]; extern const int32_t g_FieldOffsetTable688[7]; extern const int32_t g_FieldOffsetTable689[2]; extern const int32_t g_FieldOffsetTable690[2]; extern const int32_t g_FieldOffsetTable691[2]; extern const int32_t g_FieldOffsetTable692[8]; extern const int32_t g_FieldOffsetTable696[15]; extern const int32_t g_FieldOffsetTable697[2]; extern const int32_t g_FieldOffsetTable699[5]; extern const int32_t g_FieldOffsetTable700[1]; extern const int32_t g_FieldOffsetTable701[1]; extern const int32_t g_FieldOffsetTable703[5]; extern const int32_t g_FieldOffsetTable705[14]; extern const int32_t g_FieldOffsetTable707[14]; extern const int32_t g_FieldOffsetTable708[2]; extern const int32_t g_FieldOffsetTable709[4]; extern const int32_t g_FieldOffsetTable712[10]; extern const int32_t g_FieldOffsetTable713[1]; extern const int32_t g_FieldOffsetTable716[6]; extern const int32_t g_FieldOffsetTable720[10]; extern const int32_t g_FieldOffsetTable721[1]; extern const int32_t g_FieldOffsetTable722[1]; extern const int32_t g_FieldOffsetTable723[17]; extern const int32_t g_FieldOffsetTable724[1]; extern const int32_t g_FieldOffsetTable725[1]; extern const int32_t g_FieldOffsetTable726[4]; extern const int32_t g_FieldOffsetTable727[3]; extern const int32_t g_FieldOffsetTable728[2]; extern const int32_t g_FieldOffsetTable731[3]; extern const int32_t g_FieldOffsetTable734[4]; extern const int32_t g_FieldOffsetTable735[5]; extern const int32_t g_FieldOffsetTable736[7]; extern const int32_t g_FieldOffsetTable742[1]; extern const int32_t g_FieldOffsetTable743[4]; extern const int32_t g_FieldOffsetTable744[1]; extern const int32_t g_FieldOffsetTable745[3]; extern const int32_t g_FieldOffsetTable746[9]; extern const int32_t g_FieldOffsetTable747[2]; extern const int32_t g_FieldOffsetTable748[8]; extern const int32_t g_FieldOffsetTable749[3]; extern const int32_t g_FieldOffsetTable750[5]; extern const int32_t g_FieldOffsetTable751[5]; extern const int32_t g_FieldOffsetTable752[3]; extern const int32_t g_FieldOffsetTable757[2]; extern const int32_t g_FieldOffsetTable760[3]; extern const int32_t g_FieldOffsetTable762[2]; extern const int32_t g_FieldOffsetTable763[1]; extern const int32_t g_FieldOffsetTable764[3]; extern const int32_t g_FieldOffsetTable767[3]; extern const int32_t g_FieldOffsetTable769[4]; extern const int32_t g_FieldOffsetTable770[1]; extern const int32_t g_FieldOffsetTable771[3]; extern const int32_t g_FieldOffsetTable772[28]; extern const int32_t g_FieldOffsetTable773[1]; extern const int32_t g_FieldOffsetTable775[5]; extern const int32_t g_FieldOffsetTable776[2]; extern const int32_t g_FieldOffsetTable777[3]; extern const int32_t g_FieldOffsetTable778[3]; extern const int32_t g_FieldOffsetTable779[1]; extern const int32_t g_FieldOffsetTable780[1]; extern const int32_t g_FieldOffsetTable781[2]; extern const int32_t g_FieldOffsetTable782[2]; extern const int32_t g_FieldOffsetTable783[2]; extern const int32_t g_FieldOffsetTable784[1]; extern const int32_t g_FieldOffsetTable785[3]; extern const int32_t g_FieldOffsetTable787[3]; extern const int32_t g_FieldOffsetTable793[9]; extern const int32_t g_FieldOffsetTable794[1]; extern const int32_t g_FieldOffsetTable796[52]; extern const int32_t g_FieldOffsetTable800[11]; extern const int32_t g_FieldOffsetTable802[7]; extern const int32_t g_FieldOffsetTable804[2]; extern const int32_t g_FieldOffsetTable805[4]; extern const int32_t g_FieldOffsetTable807[1]; extern const int32_t g_FieldOffsetTable809[21]; extern const int32_t g_FieldOffsetTable811[22]; extern const int32_t g_FieldOffsetTable813[1]; extern const int32_t g_FieldOffsetTable814[2]; extern const int32_t g_FieldOffsetTable815[1]; extern const int32_t g_FieldOffsetTable816[1]; extern const int32_t g_FieldOffsetTable818[1]; extern const int32_t g_FieldOffsetTable820[17]; extern const int32_t g_FieldOffsetTable821[2]; extern const int32_t g_FieldOffsetTable823[3]; extern const int32_t g_FieldOffsetTable824[5]; extern const int32_t g_FieldOffsetTable826[2]; extern const int32_t g_FieldOffsetTable827[1]; extern const int32_t g_FieldOffsetTable828[15]; extern const int32_t g_FieldOffsetTable829[5]; extern const int32_t g_FieldOffsetTable830[4]; extern const int32_t g_FieldOffsetTable831[4]; extern const int32_t g_FieldOffsetTable833[8]; extern const int32_t g_FieldOffsetTable834[2]; extern const int32_t g_FieldOffsetTable835[1]; extern const int32_t g_FieldOffsetTable836[7]; extern const int32_t g_FieldOffsetTable837[1]; extern const int32_t g_FieldOffsetTable838[1]; extern const int32_t g_FieldOffsetTable839[1]; extern const int32_t g_FieldOffsetTable840[11]; extern const int32_t g_FieldOffsetTable845[2]; extern const int32_t g_FieldOffsetTable846[24]; extern const int32_t g_FieldOffsetTable847[1]; extern const int32_t g_FieldOffsetTable851[1]; extern const int32_t g_FieldOffsetTable853[15]; extern const int32_t g_FieldOffsetTable854[3]; extern const int32_t g_FieldOffsetTable858[1]; extern const int32_t g_FieldOffsetTable859[1]; extern const int32_t g_FieldOffsetTable860[7]; extern const int32_t g_FieldOffsetTable861[5]; extern const int32_t g_FieldOffsetTable864[1]; extern const int32_t g_FieldOffsetTable866[3]; extern const int32_t g_FieldOffsetTable867[1]; extern const int32_t g_FieldOffsetTable868[7]; extern const int32_t g_FieldOffsetTable869[3]; extern const int32_t g_FieldOffsetTable870[2]; extern const int32_t g_FieldOffsetTable871[1]; extern const int32_t g_FieldOffsetTable872[2]; extern const int32_t g_FieldOffsetTable873[1]; extern const int32_t g_FieldOffsetTable877[1]; extern const int32_t g_FieldOffsetTable878[1]; extern const int32_t g_FieldOffsetTable879[26]; extern const int32_t g_FieldOffsetTable880[14]; extern const int32_t g_FieldOffsetTable881[2]; extern const int32_t g_FieldOffsetTable882[3]; extern const int32_t g_FieldOffsetTable883[1]; extern const int32_t g_FieldOffsetTable884[1]; extern const int32_t g_FieldOffsetTable885[8]; extern const int32_t g_FieldOffsetTable886[1]; extern const int32_t g_FieldOffsetTable888[1]; extern const int32_t g_FieldOffsetTable889[1]; extern const int32_t g_FieldOffsetTable891[4]; extern const int32_t g_FieldOffsetTable892[2]; extern const int32_t g_FieldOffsetTable893[1]; extern const int32_t g_FieldOffsetTable894[7]; extern const int32_t g_FieldOffsetTable895[3]; extern const int32_t g_FieldOffsetTable898[4]; extern const int32_t g_FieldOffsetTable899[3]; extern const int32_t g_FieldOffsetTable900[8]; extern const int32_t g_FieldOffsetTable901[19]; extern const int32_t g_FieldOffsetTable902[1]; extern const int32_t g_FieldOffsetTable903[3]; extern const int32_t g_FieldOffsetTable905[2]; extern const int32_t g_FieldOffsetTable906[3]; extern const int32_t g_FieldOffsetTable907[5]; extern const int32_t g_FieldOffsetTable908[5]; extern const int32_t g_FieldOffsetTable909[2]; extern const int32_t g_FieldOffsetTable929[53]; extern const int32_t g_FieldOffsetTable955[4]; extern const int32_t g_FieldOffsetTable956[4]; extern const int32_t g_FieldOffsetTable957[2]; extern const int32_t g_FieldOffsetTable959[7]; extern const int32_t g_FieldOffsetTable963[3]; extern const int32_t g_FieldOffsetTable967[2]; extern const int32_t g_FieldOffsetTable968[4]; extern const int32_t g_FieldOffsetTable969[5]; extern const int32_t g_FieldOffsetTable971[1]; extern const int32_t g_FieldOffsetTable973[6]; extern const int32_t g_FieldOffsetTable975[5]; extern const int32_t g_FieldOffsetTable976[4]; extern const int32_t g_FieldOffsetTable978[4]; extern const int32_t g_FieldOffsetTable979[4]; extern const int32_t g_FieldOffsetTable980[2]; extern const int32_t g_FieldOffsetTable981[13]; extern const int32_t g_FieldOffsetTable983[2]; extern const int32_t g_FieldOffsetTable984[17]; extern const int32_t g_FieldOffsetTable985[7]; extern const int32_t g_FieldOffsetTable986[15]; extern const int32_t g_FieldOffsetTable987[26]; extern const int32_t g_FieldOffsetTable989[1]; extern const int32_t g_FieldOffsetTable990[5]; extern const int32_t g_FieldOffsetTable991[8]; extern const int32_t g_FieldOffsetTable992[11]; extern const int32_t g_FieldOffsetTable993[3]; extern const int32_t g_FieldOffsetTable994[3]; extern const int32_t g_FieldOffsetTable995[1]; extern const int32_t g_FieldOffsetTable996[4]; extern const int32_t g_FieldOffsetTable997[2]; extern const int32_t g_FieldOffsetTable998[2]; extern const int32_t g_FieldOffsetTable999[1]; extern const int32_t g_FieldOffsetTable1000[2]; extern const int32_t g_FieldOffsetTable1001[2]; extern const int32_t g_FieldOffsetTable1002[5]; extern const int32_t g_FieldOffsetTable1003[11]; extern const int32_t g_FieldOffsetTable1004[1]; extern const int32_t g_FieldOffsetTable1005[1]; extern const int32_t g_FieldOffsetTable1006[8]; extern const int32_t g_FieldOffsetTable1007[1]; extern const int32_t g_FieldOffsetTable1008[4]; extern const int32_t g_FieldOffsetTable1009[3]; extern const int32_t g_FieldOffsetTable1010[3]; extern const int32_t g_FieldOffsetTable1011[25]; extern const int32_t g_FieldOffsetTable1012[2]; extern const int32_t g_FieldOffsetTable1013[8]; extern const int32_t g_FieldOffsetTable1014[21]; extern const int32_t g_FieldOffsetTable1015[2]; extern const int32_t g_FieldOffsetTable1017[2]; extern const int32_t g_FieldOffsetTable1019[6]; extern const int32_t g_FieldOffsetTable1020[2]; extern const int32_t g_FieldOffsetTable1021[5]; extern const int32_t g_FieldOffsetTable1022[30]; extern const int32_t g_FieldOffsetTable1023[6]; extern const int32_t g_FieldOffsetTable1024[4]; extern const int32_t g_FieldOffsetTable1025[4]; extern const int32_t g_FieldOffsetTable1026[4]; extern const int32_t g_FieldOffsetTable1027[3]; extern const int32_t g_FieldOffsetTable1028[9]; extern const int32_t g_FieldOffsetTable1029[7]; extern const int32_t g_FieldOffsetTable1030[3]; extern const int32_t g_FieldOffsetTable1031[3]; extern const int32_t g_FieldOffsetTable1032[3]; extern const int32_t g_FieldOffsetTable1033[3]; extern const int32_t g_FieldOffsetTable1034[5]; extern const int32_t g_FieldOffsetTable1036[2]; extern const int32_t g_FieldOffsetTable1037[4]; extern const int32_t g_FieldOffsetTable1038[3]; extern const int32_t g_FieldOffsetTable1039[8]; extern const int32_t g_FieldOffsetTable1040[15]; extern const int32_t g_FieldOffsetTable1041[12]; extern const int32_t g_FieldOffsetTable1042[2]; extern const int32_t g_FieldOffsetTable1043[4]; extern const int32_t g_FieldOffsetTable1044[1]; extern const int32_t g_FieldOffsetTable1045[8]; extern const int32_t g_FieldOffsetTable1046[4]; extern const int32_t g_FieldOffsetTable1047[6]; extern const int32_t g_FieldOffsetTable1048[4]; extern const int32_t g_FieldOffsetTable1049[12]; extern const int32_t g_FieldOffsetTable1050[2]; extern const int32_t g_FieldOffsetTable1052[1]; extern const int32_t g_FieldOffsetTable1053[1]; extern const int32_t g_FieldOffsetTable1055[1]; extern const int32_t g_FieldOffsetTable1056[2]; extern const int32_t g_FieldOffsetTable1057[1]; extern const int32_t g_FieldOffsetTable1058[4]; extern const int32_t g_FieldOffsetTable1060[2]; extern const int32_t g_FieldOffsetTable1066[15]; extern const int32_t g_FieldOffsetTable1078[1]; extern const int32_t g_FieldOffsetTable1079[7]; extern const int32_t g_FieldOffsetTable1080[4]; extern const int32_t g_FieldOffsetTable1081[4]; extern const int32_t g_FieldOffsetTable1082[4]; extern const int32_t g_FieldOffsetTable1083[3]; extern const int32_t g_FieldOffsetTable1084[3]; extern const int32_t g_FieldOffsetTable1085[3]; extern const int32_t g_FieldOffsetTable1086[3]; extern const int32_t g_FieldOffsetTable1087[4]; extern const int32_t g_FieldOffsetTable1088[3]; extern const int32_t g_FieldOffsetTable1089[4]; extern const int32_t g_FieldOffsetTable1090[10]; extern const int32_t g_FieldOffsetTable1091[2]; extern const int32_t g_FieldOffsetTable1092[2]; extern const int32_t g_FieldOffsetTable1093[1]; extern const int32_t g_FieldOffsetTable1094[2]; extern const int32_t g_FieldOffsetTable1095[1]; extern const int32_t g_FieldOffsetTable1096[4]; extern const int32_t g_FieldOffsetTable1098[2]; extern const int32_t g_FieldOffsetTable1099[4]; extern const int32_t g_FieldOffsetTable1100[5]; extern const int32_t g_FieldOffsetTable1101[32]; extern const int32_t g_FieldOffsetTable1103[9]; extern const int32_t g_FieldOffsetTable1106[11]; extern const int32_t g_FieldOffsetTable1109[2]; extern const int32_t g_FieldOffsetTable1110[24]; extern const int32_t g_FieldOffsetTable1113[12]; extern const int32_t g_FieldOffsetTable1114[5]; extern const int32_t g_FieldOffsetTable1117[3]; extern const int32_t g_FieldOffsetTable1118[11]; extern const int32_t g_FieldOffsetTable1119[10]; extern const int32_t g_FieldOffsetTable1120[2]; extern const int32_t g_FieldOffsetTable1121[5]; extern const int32_t g_FieldOffsetTable1122[5]; extern const int32_t g_FieldOffsetTable1123[5]; extern const int32_t g_FieldOffsetTable1124[6]; extern const int32_t g_FieldOffsetTable1125[5]; extern const int32_t g_FieldOffsetTable1126[3]; extern const int32_t g_FieldOffsetTable1127[9]; extern const int32_t g_FieldOffsetTable1128[1]; extern const int32_t g_FieldOffsetTable1129[11]; extern const int32_t g_FieldOffsetTable1130[6]; extern const int32_t g_FieldOffsetTable1131[13]; extern const int32_t g_FieldOffsetTable1133[1]; extern const int32_t g_FieldOffsetTable1135[1]; extern const int32_t g_FieldOffsetTable1136[15]; extern const int32_t g_FieldOffsetTable1137[4]; extern const int32_t g_FieldOffsetTable1138[1]; extern const int32_t g_FieldOffsetTable1139[1]; extern const int32_t g_FieldOffsetTable1140[8]; extern const int32_t g_FieldOffsetTable1141[2]; extern const int32_t g_FieldOffsetTable1142[24]; extern const int32_t g_FieldOffsetTable1143[3]; extern const int32_t g_FieldOffsetTable1144[1]; extern const int32_t g_FieldOffsetTable1145[1]; extern const int32_t g_FieldOffsetTable1146[1]; extern const int32_t g_FieldOffsetTable1147[16]; extern const int32_t g_FieldOffsetTable1148[5]; extern const int32_t g_FieldOffsetTable1149[11]; extern const int32_t g_FieldOffsetTable1150[7]; extern const int32_t g_FieldOffsetTable1151[4]; extern const int32_t g_FieldOffsetTable1152[4]; extern const int32_t g_FieldOffsetTable1153[6]; extern const int32_t g_FieldOffsetTable1154[5]; extern const int32_t g_FieldOffsetTable1155[4]; extern const int32_t g_FieldOffsetTable1156[15]; extern const int32_t g_FieldOffsetTable1157[7]; extern const int32_t g_FieldOffsetTable1158[3]; extern const int32_t g_FieldOffsetTable1159[3]; extern const int32_t g_FieldOffsetTable1160[2]; extern const int32_t g_FieldOffsetTable1161[2]; extern const int32_t g_FieldOffsetTable1162[1]; extern const int32_t g_FieldOffsetTable1163[3]; extern const int32_t g_FieldOffsetTable1164[1]; extern const int32_t g_FieldOffsetTable1165[3]; extern const int32_t g_FieldOffsetTable1166[2]; extern const int32_t g_FieldOffsetTable1167[5]; extern const int32_t g_FieldOffsetTable1168[2]; extern const int32_t g_FieldOffsetTable1169[2]; extern const int32_t g_FieldOffsetTable1170[9]; extern const int32_t g_FieldOffsetTable1171[10]; extern const int32_t g_FieldOffsetTable1172[26]; extern const int32_t g_FieldOffsetTable1173[6]; extern const int32_t g_FieldOffsetTable1174[11]; extern const int32_t g_FieldOffsetTable1177[3]; extern const int32_t g_FieldOffsetTable1178[2]; extern const int32_t g_FieldOffsetTable1179[2]; extern const int32_t g_FieldOffsetTable1180[3]; extern const int32_t g_FieldOffsetTable1181[146]; extern const int32_t g_FieldOffsetTable1185[4]; extern const int32_t g_FieldOffsetTable1186[1]; extern const int32_t g_FieldOffsetTable1187[1]; extern const int32_t g_FieldOffsetTable1188[2]; extern const int32_t g_FieldOffsetTable1189[1]; extern const int32_t g_FieldOffsetTable1190[3]; extern const int32_t g_FieldOffsetTable1191[16]; extern const int32_t g_FieldOffsetTable1192[2]; extern const int32_t g_FieldOffsetTable1193[7]; extern const int32_t g_FieldOffsetTable1194[4]; extern const int32_t g_FieldOffsetTable1195[3]; extern const int32_t g_FieldOffsetTable1196[1]; extern const int32_t g_FieldOffsetTable1197[2]; extern const int32_t g_FieldOffsetTable1199[6]; extern const int32_t g_FieldOffsetTable1200[7]; extern const int32_t g_FieldOffsetTable1203[1]; extern const int32_t g_FieldOffsetTable1205[1]; extern const int32_t g_FieldOffsetTable1206[2]; extern const int32_t g_FieldOffsetTable1207[1]; extern const int32_t g_FieldOffsetTable1209[3]; extern const int32_t g_FieldOffsetTable1211[3]; extern const int32_t g_FieldOffsetTable1212[2]; extern const int32_t g_FieldOffsetTable1214[2]; extern const int32_t g_FieldOffsetTable1215[1]; extern const int32_t g_FieldOffsetTable1216[2]; extern const int32_t g_FieldOffsetTable1217[2]; extern const int32_t g_FieldOffsetTable1218[6]; extern const int32_t g_FieldOffsetTable1219[6]; extern const int32_t g_FieldOffsetTable1222[34]; extern const int32_t g_FieldOffsetTable1223[3]; extern const int32_t g_FieldOffsetTable1225[6]; extern const int32_t g_FieldOffsetTable1226[4]; extern const int32_t g_FieldOffsetTable1227[6]; extern const int32_t g_FieldOffsetTable1228[5]; extern const int32_t g_FieldOffsetTable1231[3]; extern const int32_t g_FieldOffsetTable1238[1]; extern const int32_t g_FieldOffsetTable1239[12]; extern const int32_t g_FieldOffsetTable1240[14]; extern const int32_t g_FieldOffsetTable1241[2]; extern const int32_t g_FieldOffsetTable1242[4]; extern const int32_t g_FieldOffsetTable1243[1]; extern const int32_t g_FieldOffsetTable1246[3]; extern const int32_t g_FieldOffsetTable1247[8]; extern const int32_t g_FieldOffsetTable1250[14]; extern const int32_t g_FieldOffsetTable1257[12]; extern const int32_t g_FieldOffsetTable1264[2]; extern const int32_t g_FieldOffsetTable1265[1]; extern const int32_t g_FieldOffsetTable1267[2]; extern const int32_t g_FieldOffsetTable1279[2]; extern const int32_t g_FieldOffsetTable1280[1]; extern const int32_t g_FieldOffsetTable1281[1]; extern const int32_t g_FieldOffsetTable1282[5]; extern const int32_t g_FieldOffsetTable1284[4]; extern const int32_t g_FieldOffsetTable1285[3]; extern const int32_t g_FieldOffsetTable1290[4]; extern const int32_t g_FieldOffsetTable1291[2]; extern const int32_t g_FieldOffsetTable1292[1]; extern const int32_t g_FieldOffsetTable1295[5]; extern const int32_t g_FieldOffsetTable1298[2]; extern const int32_t g_FieldOffsetTable1300[3]; extern const int32_t g_FieldOffsetTable1302[1]; extern const int32_t g_FieldOffsetTable1303[3]; extern const int32_t g_FieldOffsetTable1304[2]; extern const int32_t g_FieldOffsetTable1306[4]; extern const int32_t g_FieldOffsetTable1308[4]; extern const int32_t g_FieldOffsetTable1311[1]; extern const int32_t g_FieldOffsetTable1313[1]; extern const int32_t g_FieldOffsetTable1316[2]; extern const int32_t g_FieldOffsetTable1319[6]; extern const int32_t g_FieldOffsetTable1320[1]; extern const int32_t g_FieldOffsetTable1321[5]; extern const int32_t g_FieldOffsetTable1322[6]; extern const int32_t g_FieldOffsetTable1323[4]; extern const int32_t g_FieldOffsetTable1324[4]; extern const int32_t g_FieldOffsetTable1325[14]; extern const int32_t g_FieldOffsetTable1327[1]; extern const int32_t g_FieldOffsetTable1328[1]; extern const int32_t g_FieldOffsetTable1329[1]; extern const int32_t g_FieldOffsetTable1330[7]; extern const int32_t g_FieldOffsetTable1331[1]; extern const int32_t g_FieldOffsetTable1334[1]; extern const int32_t g_FieldOffsetTable1335[2]; extern const int32_t g_FieldOffsetTable1339[1]; extern const int32_t g_FieldOffsetTable1340[27]; extern const int32_t g_FieldOffsetTable1347[1]; extern const int32_t g_FieldOffsetTable1348[3]; extern const int32_t g_FieldOffsetTable1349[3]; extern const int32_t g_FieldOffsetTable1350[1]; extern const int32_t g_FieldOffsetTable1352[2]; extern const int32_t g_FieldOffsetTable1353[26]; extern const int32_t g_FieldOffsetTable1355[1]; extern const int32_t g_FieldOffsetTable1357[5]; extern const int32_t g_FieldOffsetTable1358[3]; extern const int32_t g_FieldOffsetTable1359[2]; extern const int32_t g_FieldOffsetTable1363[3]; extern const int32_t g_FieldOffsetTable1365[3]; extern const int32_t g_FieldOffsetTable1366[2]; extern const int32_t g_FieldOffsetTable1367[3]; extern const int32_t g_FieldOffsetTable1368[3]; extern const int32_t g_FieldOffsetTable1370[1]; extern const int32_t g_FieldOffsetTable1371[1]; extern const int32_t g_FieldOffsetTable1374[3]; extern const int32_t g_FieldOffsetTable1375[3]; extern const int32_t g_FieldOffsetTable1376[34]; extern const int32_t g_FieldOffsetTable1377[6]; extern const int32_t g_FieldOffsetTable1378[1]; extern const int32_t g_FieldOffsetTable1379[2]; extern const int32_t g_FieldOffsetTable1380[1]; extern const int32_t g_FieldOffsetTable1381[2]; extern const int32_t g_FieldOffsetTable1382[2]; extern const int32_t g_FieldOffsetTable1384[4]; extern const int32_t g_FieldOffsetTable1385[5]; extern const int32_t g_FieldOffsetTable1387[1]; extern const int32_t g_FieldOffsetTable1391[1]; extern const int32_t g_FieldOffsetTable1395[3]; extern const int32_t g_FieldOffsetTable1396[12]; extern const int32_t g_FieldOffsetTable1398[1]; extern const int32_t g_FieldOffsetTable1402[4]; extern const int32_t g_FieldOffsetTable1403[4]; extern const int32_t g_FieldOffsetTable1404[6]; extern const int32_t g_FieldOffsetTable1405[6]; extern const int32_t g_FieldOffsetTable1406[4]; extern const int32_t g_FieldOffsetTable1407[5]; extern const int32_t g_FieldOffsetTable1408[52]; extern const int32_t g_FieldOffsetTable1409[8]; extern const int32_t g_FieldOffsetTable1410[3]; extern const int32_t g_FieldOffsetTable1411[10]; extern const int32_t g_FieldOffsetTable1412[6]; extern const int32_t g_FieldOffsetTable1413[9]; extern const int32_t g_FieldOffsetTable1414[5]; extern const int32_t g_FieldOffsetTable1415[26]; extern const int32_t g_FieldOffsetTable1416[24]; extern const int32_t g_FieldOffsetTable1417[7]; extern const int32_t g_FieldOffsetTable1420[322]; extern const int32_t g_FieldOffsetTable1422[18]; extern const int32_t g_FieldOffsetTable1423[14]; extern const int32_t g_FieldOffsetTable1424[6]; extern const int32_t g_FieldOffsetTable1425[1]; extern const int32_t g_FieldOffsetTable1426[3]; extern const int32_t g_FieldOffsetTable1428[13]; extern const int32_t g_FieldOffsetTable1429[3]; extern const int32_t g_FieldOffsetTable1432[5]; extern const int32_t g_FieldOffsetTable1433[2]; extern const int32_t g_FieldOffsetTable1434[2]; extern const int32_t g_FieldOffsetTable1560[5]; extern const int32_t g_FieldOffsetTable1561[5]; extern const int32_t g_FieldOffsetTable1564[1]; extern const int32_t g_FieldOffsetTable1565[1]; extern const int32_t g_FieldOffsetTable1566[1]; extern const int32_t g_FieldOffsetTable1567[2]; extern const int32_t g_FieldOffsetTable1568[2]; extern const int32_t g_FieldOffsetTable1570[1]; extern const int32_t g_FieldOffsetTable1572[2]; extern const int32_t g_FieldOffsetTable1573[2]; extern const int32_t g_FieldOffsetTable1574[4]; extern const int32_t g_FieldOffsetTable1581[1]; extern const int32_t g_FieldOffsetTable1583[5]; extern const int32_t g_FieldOffsetTable1586[12]; extern const int32_t g_FieldOffsetTable1587[1]; extern const int32_t g_FieldOffsetTable1588[1]; extern const int32_t g_FieldOffsetTable1589[10]; extern const int32_t g_FieldOffsetTable1590[2]; extern const int32_t g_FieldOffsetTable1591[8]; extern const int32_t g_FieldOffsetTable1592[6]; extern const int32_t g_FieldOffsetTable1594[1]; extern const int32_t g_FieldOffsetTable1595[1]; extern const int32_t g_FieldOffsetTable1596[1]; extern const int32_t g_FieldOffsetTable1597[1]; extern const int32_t g_FieldOffsetTable1598[1]; extern const int32_t g_FieldOffsetTable1599[1]; extern const int32_t g_FieldOffsetTable1600[4]; extern const int32_t g_FieldOffsetTable1601[5]; extern const int32_t g_FieldOffsetTable1602[1]; extern const int32_t g_FieldOffsetTable1603[4]; extern const int32_t g_FieldOffsetTable1604[4]; extern const int32_t g_FieldOffsetTable1606[1]; extern const int32_t g_FieldOffsetTable1608[1]; extern const int32_t g_FieldOffsetTable1610[1]; extern const int32_t g_FieldOffsetTable1612[1]; extern const int32_t g_FieldOffsetTable1614[1]; extern const int32_t g_FieldOffsetTable1616[2]; extern const int32_t g_FieldOffsetTable1617[3]; extern const int32_t g_FieldOffsetTable1618[11]; extern const int32_t g_FieldOffsetTable1619[9]; extern const int32_t g_FieldOffsetTable1622[1]; extern const int32_t g_FieldOffsetTable1623[1]; extern const int32_t g_FieldOffsetTable1642[1]; extern const int32_t g_FieldOffsetTable1646[1]; extern const int32_t g_FieldOffsetTable1647[2]; extern const int32_t g_FieldOffsetTable1648[6]; extern const int32_t g_FieldOffsetTable1652[5]; extern const int32_t g_FieldOffsetTable1653[2]; extern const int32_t g_FieldOffsetTable1654[2]; extern const int32_t g_FieldOffsetTable1655[2]; extern const int32_t g_FieldOffsetTable1656[2]; extern const int32_t g_FieldOffsetTable1657[1]; extern const int32_t g_FieldOffsetTable1658[1]; extern const int32_t g_FieldOffsetTable1659[1]; extern const int32_t g_FieldOffsetTable1660[1]; extern const int32_t g_FieldOffsetTable1663[2]; extern const int32_t g_FieldOffsetTable1664[1]; extern const int32_t g_FieldOffsetTable1667[3]; extern const int32_t g_FieldOffsetTable1668[2]; extern const int32_t g_FieldOffsetTable1670[5]; extern const int32_t g_FieldOffsetTable1671[1]; extern const int32_t g_FieldOffsetTable1672[1]; extern const int32_t g_FieldOffsetTable1673[1]; extern const int32_t g_FieldOffsetTable1674[3]; extern const int32_t g_FieldOffsetTable1677[3]; extern const int32_t g_FieldOffsetTable1678[1]; extern const int32_t g_FieldOffsetTable1679[1]; extern const int32_t g_FieldOffsetTable1680[1]; extern const int32_t g_FieldOffsetTable1683[2]; extern const int32_t g_FieldOffsetTable1684[10]; extern const int32_t g_FieldOffsetTable1685[3]; extern const int32_t g_FieldOffsetTable1686[5]; extern const int32_t g_FieldOffsetTable1687[1]; extern const int32_t g_FieldOffsetTable1688[5]; extern const int32_t g_FieldOffsetTable1689[1]; extern const int32_t g_FieldOffsetTable1692[5]; extern const int32_t g_FieldOffsetTable1694[1]; extern const int32_t g_FieldOffsetTable1696[9]; extern const int32_t g_FieldOffsetTable1697[2]; extern const int32_t g_FieldOffsetTable1701[1]; extern const int32_t g_FieldOffsetTable1702[2]; extern const int32_t g_FieldOffsetTable1703[4]; extern const int32_t g_FieldOffsetTable1704[2]; extern const int32_t g_FieldOffsetTable1705[2]; extern const int32_t g_FieldOffsetTable1706[1]; extern const int32_t g_FieldOffsetTable1707[2]; extern const int32_t g_FieldOffsetTable1708[1]; extern const int32_t g_FieldOffsetTable1709[1]; extern const int32_t g_FieldOffsetTable1710[1]; extern const int32_t g_FieldOffsetTable1711[8]; extern const int32_t g_FieldOffsetTable1715[10]; extern const int32_t g_FieldOffsetTable1716[3]; extern const int32_t g_FieldOffsetTable1717[3]; extern const int32_t g_FieldOffsetTable1718[2]; extern const int32_t g_FieldOffsetTable1720[2]; extern const int32_t g_FieldOffsetTable1721[4]; extern const int32_t g_FieldOffsetTable1722[11]; extern const int32_t g_FieldOffsetTable1723[11]; extern const int32_t g_FieldOffsetTable1724[5]; extern const int32_t g_FieldOffsetTable1725[5]; extern const int32_t g_FieldOffsetTable1726[18]; extern const int32_t g_FieldOffsetTable1728[1]; extern const int32_t g_FieldOffsetTable1729[8]; extern const int32_t g_FieldOffsetTable1730[6]; extern const int32_t g_FieldOffsetTable1731[30]; extern const int32_t g_FieldOffsetTable1732[6]; extern const int32_t g_FieldOffsetTable1733[9]; extern const int32_t g_FieldOffsetTable1734[1]; extern const int32_t g_FieldOffsetTable1735[1]; extern const int32_t g_FieldOffsetTable1736[1]; extern const int32_t g_FieldOffsetTable1738[1]; extern const int32_t g_FieldOffsetTable1741[4]; extern const int32_t g_FieldOffsetTable1742[11]; extern const int32_t g_FieldOffsetTable1746[1]; extern const int32_t g_FieldOffsetTable1747[2]; extern const int32_t g_FieldOffsetTable1748[1]; extern const int32_t g_FieldOffsetTable1749[1]; extern const int32_t g_FieldOffsetTable1750[2]; extern const int32_t g_FieldOffsetTable1751[1]; extern const int32_t g_FieldOffsetTable1752[2]; extern const int32_t g_FieldOffsetTable1753[9]; extern const int32_t g_FieldOffsetTable1754[8]; extern const int32_t g_FieldOffsetTable1756[2]; extern const int32_t g_FieldOffsetTable1757[1]; extern const int32_t g_FieldOffsetTable1759[5]; extern const int32_t g_FieldOffsetTable1760[5]; extern const int32_t g_FieldOffsetTable1761[3]; extern const int32_t g_FieldOffsetTable1764[4]; extern const int32_t g_FieldOffsetTable1765[7]; extern const int32_t g_FieldOffsetTable1766[5]; extern const int32_t g_FieldOffsetTable1767[7]; extern const int32_t g_FieldOffsetTable1768[7]; extern const int32_t g_FieldOffsetTable1769[1]; extern const int32_t g_FieldOffsetTable1770[3]; extern const int32_t g_FieldOffsetTable1771[5]; extern const int32_t g_FieldOffsetTable1772[5]; extern const int32_t g_FieldOffsetTable1773[7]; extern const int32_t g_FieldOffsetTable1774[6]; extern const int32_t g_FieldOffsetTable1775[10]; extern const int32_t g_FieldOffsetTable1778[6]; extern const int32_t g_FieldOffsetTable1783[3]; extern const int32_t g_FieldOffsetTable1784[4]; extern const int32_t g_FieldOffsetTable1785[2]; extern const int32_t g_FieldOffsetTable1787[2]; extern const int32_t g_FieldOffsetTable1789[4]; extern const int32_t g_FieldOffsetTable1790[12]; extern const int32_t g_FieldOffsetTable1792[5]; extern const int32_t g_FieldOffsetTable1793[3]; extern const int32_t g_FieldOffsetTable1794[5]; extern const int32_t g_FieldOffsetTable1795[3]; extern const int32_t g_FieldOffsetTable1796[16]; extern const int32_t g_FieldOffsetTable1797[8]; extern const int32_t g_FieldOffsetTable1798[33]; extern const int32_t g_FieldOffsetTable1799[9]; extern const int32_t g_FieldOffsetTable1800[7]; extern const int32_t g_FieldOffsetTable1801[4]; extern const int32_t g_FieldOffsetTable1802[4]; extern const int32_t g_FieldOffsetTable1804[2]; extern const int32_t g_FieldOffsetTable1805[15]; extern const int32_t g_FieldOffsetTable1806[27]; extern const int32_t g_FieldOffsetTable1808[5]; extern const int32_t g_FieldOffsetTable1809[1]; extern const int32_t g_FieldOffsetTable1811[10]; extern const int32_t g_FieldOffsetTable1812[3]; extern const int32_t g_FieldOffsetTable1813[17]; extern const int32_t g_FieldOffsetTable1814[12]; extern const int32_t g_FieldOffsetTable1817[16]; extern const int32_t g_FieldOffsetTable1818[3]; extern const int32_t g_FieldOffsetTable1821[14]; extern const int32_t g_FieldOffsetTable1823[1]; extern const int32_t g_FieldOffsetTable1824[11]; extern const int32_t g_FieldOffsetTable1825[6]; extern const int32_t g_FieldOffsetTable1830[5]; extern const int32_t g_FieldOffsetTable1837[6]; extern const int32_t g_FieldOffsetTable1839[11]; extern const int32_t g_FieldOffsetTable1840[7]; extern const int32_t g_FieldOffsetTable1841[5]; extern const int32_t g_FieldOffsetTable1842[4]; extern const int32_t g_FieldOffsetTable1844[4]; extern const int32_t g_FieldOffsetTable1845[1]; extern const int32_t g_FieldOffsetTable1848[3]; extern const int32_t g_FieldOffsetTable1852[1]; extern const int32_t g_FieldOffsetTable1854[5]; extern const int32_t g_FieldOffsetTable1855[1]; extern const int32_t g_FieldOffsetTable1857[3]; extern const int32_t g_FieldOffsetTable1859[2]; extern const int32_t g_FieldOffsetTable1861[1]; extern const int32_t g_FieldOffsetTable1864[3]; extern const int32_t g_FieldOffsetTable1883[12]; extern const int32_t g_FieldOffsetTable1884[2]; extern const int32_t g_FieldOffsetTable1886[2]; extern const int32_t g_FieldOffsetTable1887[18]; extern const int32_t g_FieldOffsetTable1888[36]; extern const int32_t g_FieldOffsetTable1890[6]; extern const int32_t g_FieldOffsetTable1891[1]; extern const int32_t g_FieldOffsetTable1892[10]; extern const int32_t g_FieldOffsetTable1894[2]; extern const int32_t g_FieldOffsetTable1895[1]; extern const int32_t g_FieldOffsetTable1896[1]; extern const int32_t g_FieldOffsetTable1897[21]; extern const int32_t g_FieldOffsetTable1898[4]; extern const int32_t g_FieldOffsetTable1899[5]; extern const int32_t g_FieldOffsetTable1901[6]; extern const int32_t g_FieldOffsetTable1902[6]; extern const int32_t g_FieldOffsetTable1903[2]; extern const int32_t g_FieldOffsetTable1904[1]; extern const int32_t g_FieldOffsetTable1905[2]; extern const int32_t g_FieldOffsetTable1906[14]; extern const int32_t g_FieldOffsetTable1907[3]; extern const int32_t g_FieldOffsetTable1908[4]; extern const int32_t g_FieldOffsetTable1910[1]; extern const int32_t g_FieldOffsetTable1911[7]; extern const int32_t g_FieldOffsetTable1913[6]; extern const int32_t g_FieldOffsetTable1914[4]; extern const int32_t g_FieldOffsetTable1916[5]; extern const int32_t g_FieldOffsetTable1918[2]; extern const int32_t g_FieldOffsetTable1919[6]; extern const int32_t g_FieldOffsetTable1920[8]; extern const int32_t g_FieldOffsetTable1921[1]; extern const int32_t g_FieldOffsetTable1923[6]; extern const int32_t g_FieldOffsetTable1924[7]; extern const int32_t g_FieldOffsetTable1926[7]; extern const int32_t g_FieldOffsetTable1927[6]; extern const int32_t g_FieldOffsetTable1928[9]; extern const int32_t g_FieldOffsetTable1929[7]; extern const int32_t g_FieldOffsetTable1930[14]; extern const int32_t g_FieldOffsetTable1931[4]; extern const int32_t g_FieldOffsetTable1932[2]; extern const int32_t g_FieldOffsetTable1933[1]; extern const int32_t g_FieldOffsetTable1935[2]; extern const int32_t g_FieldOffsetTable1936[5]; extern const int32_t g_FieldOffsetTable1937[12]; extern const int32_t g_FieldOffsetTable1938[3]; extern const int32_t g_FieldOffsetTable1939[17]; extern const int32_t g_FieldOffsetTable1940[8]; extern const int32_t g_FieldOffsetTable1941[5]; extern const int32_t g_FieldOffsetTable1942[3]; extern const int32_t g_FieldOffsetTable1944[15]; extern const int32_t g_FieldOffsetTable1945[5]; extern const int32_t g_FieldOffsetTable1946[6]; extern const int32_t g_FieldOffsetTable1947[3]; extern const int32_t g_FieldOffsetTable1948[3]; extern const int32_t g_FieldOffsetTable1949[5]; extern const int32_t g_FieldOffsetTable1950[5]; extern const int32_t g_FieldOffsetTable1951[5]; extern const int32_t g_FieldOffsetTable1954[48]; extern const int32_t g_FieldOffsetTable1955[11]; extern const int32_t g_FieldOffsetTable1956[4]; extern const int32_t g_FieldOffsetTable1957[7]; extern const int32_t g_FieldOffsetTable1958[4]; extern const int32_t g_FieldOffsetTable1962[3]; extern const int32_t g_FieldOffsetTable1963[6]; extern const int32_t g_FieldOffsetTable1964[8]; extern const int32_t g_FieldOffsetTable1965[5]; extern const int32_t g_FieldOffsetTable1966[9]; extern const int32_t g_FieldOffsetTable1970[5]; extern const int32_t g_FieldOffsetTable1971[6]; extern const int32_t g_FieldOffsetTable1972[2]; extern const int32_t g_FieldOffsetTable1973[9]; extern const int32_t g_FieldOffsetTable1974[11]; extern const int32_t g_FieldOffsetTable1975[5]; extern const int32_t g_FieldOffsetTable1977[3]; extern const int32_t g_FieldOffsetTable1978[5]; extern const int32_t g_FieldOffsetTable1979[36]; extern const int32_t g_FieldOffsetTable1980[4]; extern const int32_t g_FieldOffsetTable1981[4]; extern const int32_t g_FieldOffsetTable1983[14]; extern const int32_t g_FieldOffsetTable1984[5]; extern const int32_t g_FieldOffsetTable1985[5]; extern const int32_t g_FieldOffsetTable1987[15]; extern const int32_t g_FieldOffsetTable1988[5]; extern const int32_t g_FieldOffsetTable1990[3]; extern const int32_t g_FieldOffsetTable1991[3]; extern const int32_t g_FieldOffsetTable1992[1]; extern const int32_t g_FieldOffsetTable1993[10]; extern const int32_t g_FieldOffsetTable1994[7]; extern const int32_t g_FieldOffsetTable1995[5]; extern const int32_t g_FieldOffsetTable1996[3]; extern const int32_t g_FieldOffsetTable1998[4]; extern const int32_t g_FieldOffsetTable1999[2]; extern const int32_t g_FieldOffsetTable2003[2]; extern const int32_t g_FieldOffsetTable2004[5]; extern const int32_t g_FieldOffsetTable2005[6]; extern const int32_t g_FieldOffsetTable2006[14]; extern const int32_t g_FieldOffsetTable2007[4]; extern const int32_t g_FieldOffsetTable2008[4]; extern const int32_t g_FieldOffsetTable2009[6]; extern const int32_t g_FieldOffsetTable2010[4]; extern const int32_t g_FieldOffsetTable2011[4]; extern const int32_t g_FieldOffsetTable2012[6]; extern const int32_t g_FieldOffsetTable2013[5]; extern const int32_t g_FieldOffsetTable2014[3]; extern const int32_t g_FieldOffsetTable2015[4]; extern const int32_t g_FieldOffsetTable2017[5]; extern const int32_t g_FieldOffsetTable2023[8]; extern const int32_t g_FieldOffsetTable2024[8]; extern const int32_t g_FieldOffsetTable2025[4]; extern const int32_t g_FieldOffsetTable2026[9]; extern const int32_t g_FieldOffsetTable2027[8]; extern const int32_t g_FieldOffsetTable2030[2]; extern const int32_t g_FieldOffsetTable2031[2]; extern const int32_t g_FieldOffsetTable2032[4]; extern const int32_t g_FieldOffsetTable2033[7]; extern const int32_t g_FieldOffsetTable2040[11]; extern const int32_t g_FieldOffsetTable2042[1]; extern const int32_t g_FieldOffsetTable2047[4]; extern const int32_t g_FieldOffsetTable2048[1]; extern const int32_t g_FieldOffsetTable2051[9]; extern const int32_t g_FieldOffsetTable2052[3]; extern const int32_t g_FieldOffsetTable2053[6]; extern const int32_t g_FieldOffsetTable2054[3]; extern const int32_t g_FieldOffsetTable2055[4]; extern const int32_t g_FieldOffsetTable2056[1]; extern const int32_t g_FieldOffsetTable2057[1]; extern const int32_t g_FieldOffsetTable2058[2]; extern const int32_t g_FieldOffsetTable2059[3]; extern const int32_t g_FieldOffsetTable2060[8]; extern const int32_t g_FieldOffsetTable2061[2]; extern const int32_t g_FieldOffsetTable2062[6]; extern const int32_t g_FieldOffsetTable2063[2]; extern const int32_t g_FieldOffsetTable2064[1]; extern const int32_t g_FieldOffsetTable2065[6]; extern const int32_t g_FieldOffsetTable2066[1]; extern const int32_t g_FieldOffsetTable2067[1]; extern const int32_t g_FieldOffsetTable2068[1]; extern const int32_t g_FieldOffsetTable2069[2]; extern const int32_t g_FieldOffsetTable2070[2]; extern const int32_t g_FieldOffsetTable2072[3]; extern const int32_t g_FieldOffsetTable2074[6]; extern const int32_t g_FieldOffsetTable2075[10]; extern const int32_t g_FieldOffsetTable2076[1]; extern const int32_t g_FieldOffsetTable2077[1]; extern const int32_t g_FieldOffsetTable2078[3]; extern const int32_t g_FieldOffsetTable2080[9]; extern const int32_t g_FieldOffsetTable2082[3]; extern const int32_t g_FieldOffsetTable2083[6]; extern const int32_t g_FieldOffsetTable2086[7]; extern const int32_t g_FieldOffsetTable2087[3]; extern const int32_t g_FieldOffsetTable2090[10]; extern const int32_t g_FieldOffsetTable2091[5]; extern const int32_t g_FieldOffsetTable2094[6]; extern const int32_t g_FieldOffsetTable2096[8]; extern const int32_t g_FieldOffsetTable2098[2]; extern const int32_t g_FieldOffsetTable2099[4]; extern const int32_t g_FieldOffsetTable2102[4]; extern const int32_t g_FieldOffsetTable2103[8]; extern const int32_t g_FieldOffsetTable2104[6]; extern const int32_t g_FieldOffsetTable2105[11]; extern const int32_t g_FieldOffsetTable2106[4]; extern const int32_t g_FieldOffsetTable2107[6]; extern const int32_t g_FieldOffsetTable2108[8]; extern const int32_t g_FieldOffsetTable2109[4]; extern const int32_t g_FieldOffsetTable2110[4]; extern const int32_t g_FieldOffsetTable2111[5]; extern const int32_t g_FieldOffsetTable2112[9]; extern const int32_t g_FieldOffsetTable2114[1]; extern const int32_t g_FieldOffsetTable2115[3]; extern const int32_t g_FieldOffsetTable2116[5]; extern const int32_t g_FieldOffsetTable2117[3]; extern const int32_t g_FieldOffsetTable2118[3]; extern const int32_t g_FieldOffsetTable2120[5]; extern const int32_t g_FieldOffsetTable2121[14]; extern const int32_t g_FieldOffsetTable2123[3]; extern const int32_t g_FieldOffsetTable2124[28]; extern const int32_t g_FieldOffsetTable2126[3]; extern const int32_t g_FieldOffsetTable2127[7]; extern const int32_t g_FieldOffsetTable2128[3]; extern const int32_t g_FieldOffsetTable2130[22]; extern const int32_t g_FieldOffsetTable2131[2]; extern const int32_t g_FieldOffsetTable2132[8]; extern const int32_t g_FieldOffsetTable2133[10]; extern const int32_t g_FieldOffsetTable2134[4]; extern const int32_t g_FieldOffsetTable2135[11]; extern const int32_t g_FieldOffsetTable2136[2]; extern const int32_t g_FieldOffsetTable2137[6]; extern const int32_t g_FieldOffsetTable2138[7]; extern const int32_t g_FieldOffsetTable2139[3]; extern const int32_t g_FieldOffsetTable2140[7]; extern const int32_t g_FieldOffsetTable2141[2]; extern const int32_t g_FieldOffsetTable2142[2]; extern const int32_t g_FieldOffsetTable2143[10]; extern const int32_t g_FieldOffsetTable2144[6]; extern const int32_t g_FieldOffsetTable2145[1]; extern const int32_t g_FieldOffsetTable2146[8]; extern const int32_t g_FieldOffsetTable2147[9]; extern const int32_t g_FieldOffsetTable2148[4]; extern const int32_t g_FieldOffsetTable2149[12]; extern const int32_t g_FieldOffsetTable2150[3]; extern const int32_t g_FieldOffsetTable2151[6]; extern const int32_t g_FieldOffsetTable2152[2]; extern const int32_t g_FieldOffsetTable2153[2]; extern const int32_t g_FieldOffsetTable2154[9]; extern const int32_t g_FieldOffsetTable2155[1]; extern const int32_t g_FieldOffsetTable2156[3]; extern const int32_t g_FieldOffsetTable2159[4]; extern const int32_t g_FieldOffsetTable2160[3]; extern const int32_t g_FieldOffsetTable2162[4]; extern const int32_t g_FieldOffsetTable2163[4]; extern const int32_t g_FieldOffsetTable2164[1]; extern const int32_t g_FieldOffsetTable2165[5]; extern const int32_t g_FieldOffsetTable2166[8]; extern const int32_t g_FieldOffsetTable2167[4]; extern const int32_t g_FieldOffsetTable2168[6]; extern const int32_t g_FieldOffsetTable2169[3]; extern const int32_t g_FieldOffsetTable2170[5]; extern const int32_t g_FieldOffsetTable2171[1]; extern const int32_t g_FieldOffsetTable2172[5]; extern const int32_t g_FieldOffsetTable2173[2]; extern const int32_t g_FieldOffsetTable2174[2]; extern const int32_t g_FieldOffsetTable2175[10]; extern const int32_t g_FieldOffsetTable2176[4]; extern const int32_t g_FieldOffsetTable2177[3]; extern const int32_t g_FieldOffsetTable2178[3]; extern const int32_t g_FieldOffsetTable2179[3]; extern const int32_t g_FieldOffsetTable2180[3]; extern const int32_t g_FieldOffsetTable2181[3]; extern const int32_t g_FieldOffsetTable2183[2]; extern const int32_t g_FieldOffsetTable2184[2]; extern const int32_t g_FieldOffsetTable2185[2]; extern const int32_t g_FieldOffsetTable2186[2]; extern const int32_t g_FieldOffsetTable2187[2]; extern const int32_t g_FieldOffsetTable2188[3]; extern const int32_t g_FieldOffsetTable2189[7]; extern const int32_t g_FieldOffsetTable2190[4]; extern const int32_t g_FieldOffsetTable2191[5]; extern const int32_t g_FieldOffsetTable2192[4]; extern const int32_t g_FieldOffsetTable2193[2]; extern const int32_t g_FieldOffsetTable2194[3]; extern const int32_t g_FieldOffsetTable2195[8]; extern const int32_t g_FieldOffsetTable2198[2]; extern const int32_t g_FieldOffsetTable2199[4]; extern const int32_t g_FieldOffsetTable2200[2]; extern const int32_t g_FieldOffsetTable2201[7]; extern const int32_t g_FieldOffsetTable2202[9]; extern const int32_t g_FieldOffsetTable2203[3]; extern const int32_t g_FieldOffsetTable2204[4]; extern const int32_t g_FieldOffsetTable2205[4]; extern const int32_t g_FieldOffsetTable2206[4]; extern const int32_t g_FieldOffsetTable2207[5]; extern const int32_t g_FieldOffsetTable2208[11]; extern const int32_t g_FieldOffsetTable2209[5]; extern const int32_t g_FieldOffsetTable2211[3]; extern const int32_t g_FieldOffsetTable2213[3]; extern const int32_t g_FieldOffsetTable2214[14]; extern const int32_t g_FieldOffsetTable2215[3]; extern const int32_t g_FieldOffsetTable2216[2]; extern const int32_t g_FieldOffsetTable2217[3]; extern const int32_t g_FieldOffsetTable2218[2]; extern const int32_t g_FieldOffsetTable2220[2]; extern const int32_t g_FieldOffsetTable2221[2]; extern const int32_t g_FieldOffsetTable2222[7]; extern const int32_t g_FieldOffsetTable2223[1]; extern const int32_t g_FieldOffsetTable2224[1]; extern const int32_t g_FieldOffsetTable2225[10]; extern const int32_t g_FieldOffsetTable2226[3]; extern const int32_t g_FieldOffsetTable2227[2]; extern const int32_t g_FieldOffsetTable2228[3]; extern const int32_t g_FieldOffsetTable2229[4]; extern const int32_t g_FieldOffsetTable2230[6]; extern const int32_t g_FieldOffsetTable2231[2]; extern const int32_t g_FieldOffsetTable2233[1]; extern const int32_t g_FieldOffsetTable2234[3]; extern const int32_t g_FieldOffsetTable2235[6]; extern const int32_t g_FieldOffsetTable2236[4]; extern const int32_t g_FieldOffsetTable2237[2]; extern const int32_t g_FieldOffsetTable2238[7]; extern const int32_t g_FieldOffsetTable2239[5]; extern const int32_t g_FieldOffsetTable2240[51]; extern const int32_t g_FieldOffsetTable2241[6]; extern const int32_t g_FieldOffsetTable2242[5]; extern const int32_t g_FieldOffsetTable2243[1]; extern const int32_t g_FieldOffsetTable2244[3]; extern const int32_t g_FieldOffsetTable2246[4]; extern const int32_t g_FieldOffsetTable2247[6]; extern const int32_t g_FieldOffsetTable2248[7]; extern const int32_t g_FieldOffsetTable2249[4]; extern const int32_t g_FieldOffsetTable2250[1]; extern const int32_t g_FieldOffsetTable2251[1]; extern const int32_t g_FieldOffsetTable2252[2]; extern const int32_t g_FieldOffsetTable2253[2]; extern const int32_t g_FieldOffsetTable2254[3]; extern const int32_t g_FieldOffsetTable2255[3]; extern const int32_t g_FieldOffsetTable2256[3]; extern const int32_t g_FieldOffsetTable2257[3]; extern const int32_t g_FieldOffsetTable2258[8]; extern const int32_t g_FieldOffsetTable2259[6]; extern const int32_t g_FieldOffsetTable2260[1]; extern const int32_t g_FieldOffsetTable2261[1]; extern const int32_t g_FieldOffsetTable2262[3]; extern const int32_t g_FieldOffsetTable2263[2]; extern const int32_t g_FieldOffsetTable2264[2]; extern const int32_t g_FieldOffsetTable2265[2]; extern const int32_t g_FieldOffsetTable2266[2]; extern const int32_t g_FieldOffsetTable2267[5]; extern const int32_t g_FieldOffsetTable2268[4]; extern const int32_t g_FieldOffsetTable2269[6]; extern const int32_t g_FieldOffsetTable2270[2]; extern const int32_t g_FieldOffsetTable2271[6]; extern const int32_t g_FieldOffsetTable2273[4]; extern const int32_t g_FieldOffsetTable2274[5]; extern const int32_t g_FieldOffsetTable2275[9]; extern const int32_t g_FieldOffsetTable2276[8]; extern const int32_t g_FieldOffsetTable2277[2]; extern const int32_t g_FieldOffsetTable2278[6]; extern const int32_t g_FieldOffsetTable2279[4]; extern const int32_t g_FieldOffsetTable2280[5]; extern const int32_t g_FieldOffsetTable2281[3]; extern const int32_t g_FieldOffsetTable2282[7]; extern const int32_t g_FieldOffsetTable2283[2]; extern const int32_t g_FieldOffsetTable2284[3]; extern const int32_t g_FieldOffsetTable2285[39]; extern const int32_t g_FieldOffsetTable2317[2]; extern const int32_t* g_FieldOffsetTable[2318] = { NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable5, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable11, g_FieldOffsetTable12, NULL, g_FieldOffsetTable14, g_FieldOffsetTable15, g_FieldOffsetTable16, g_FieldOffsetTable17, g_FieldOffsetTable18, g_FieldOffsetTable19, g_FieldOffsetTable20, g_FieldOffsetTable21, NULL, NULL, NULL, NULL, g_FieldOffsetTable26, g_FieldOffsetTable27, NULL, NULL, g_FieldOffsetTable30, g_FieldOffsetTable31, g_FieldOffsetTable32, g_FieldOffsetTable33, g_FieldOffsetTable34, NULL, g_FieldOffsetTable36, g_FieldOffsetTable37, g_FieldOffsetTable38, g_FieldOffsetTable39, NULL, g_FieldOffsetTable41, g_FieldOffsetTable42, g_FieldOffsetTable43, g_FieldOffsetTable44, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable51, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable57, NULL, g_FieldOffsetTable59, g_FieldOffsetTable60, NULL, NULL, g_FieldOffsetTable63, g_FieldOffsetTable64, g_FieldOffsetTable65, NULL, NULL, g_FieldOffsetTable68, NULL, NULL, g_FieldOffsetTable71, NULL, g_FieldOffsetTable73, g_FieldOffsetTable74, NULL, g_FieldOffsetTable76, g_FieldOffsetTable77, g_FieldOffsetTable78, g_FieldOffsetTable79, NULL, NULL, g_FieldOffsetTable82, g_FieldOffsetTable83, g_FieldOffsetTable84, g_FieldOffsetTable85, NULL, NULL, g_FieldOffsetTable88, NULL, NULL, NULL, NULL, g_FieldOffsetTable93, g_FieldOffsetTable94, g_FieldOffsetTable95, g_FieldOffsetTable96, g_FieldOffsetTable97, g_FieldOffsetTable98, g_FieldOffsetTable99, g_FieldOffsetTable100, g_FieldOffsetTable101, g_FieldOffsetTable102, g_FieldOffsetTable103, g_FieldOffsetTable104, g_FieldOffsetTable105, g_FieldOffsetTable106, g_FieldOffsetTable107, g_FieldOffsetTable108, NULL, NULL, g_FieldOffsetTable111, NULL, g_FieldOffsetTable113, g_FieldOffsetTable114, g_FieldOffsetTable115, NULL, NULL, g_FieldOffsetTable118, g_FieldOffsetTable119, g_FieldOffsetTable120, NULL, g_FieldOffsetTable122, g_FieldOffsetTable123, g_FieldOffsetTable124, NULL, g_FieldOffsetTable126, g_FieldOffsetTable127, g_FieldOffsetTable128, NULL, g_FieldOffsetTable130, g_FieldOffsetTable131, g_FieldOffsetTable132, g_FieldOffsetTable133, g_FieldOffsetTable134, g_FieldOffsetTable135, NULL, g_FieldOffsetTable137, g_FieldOffsetTable138, g_FieldOffsetTable139, g_FieldOffsetTable140, NULL, NULL, NULL, g_FieldOffsetTable144, g_FieldOffsetTable145, g_FieldOffsetTable146, g_FieldOffsetTable147, g_FieldOffsetTable148, NULL, NULL, g_FieldOffsetTable151, g_FieldOffsetTable152, NULL, NULL, NULL, g_FieldOffsetTable156, NULL, NULL, g_FieldOffsetTable159, g_FieldOffsetTable160, g_FieldOffsetTable161, g_FieldOffsetTable162, g_FieldOffsetTable163, g_FieldOffsetTable164, g_FieldOffsetTable165, g_FieldOffsetTable166, NULL, g_FieldOffsetTable168, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable175, g_FieldOffsetTable176, g_FieldOffsetTable177, g_FieldOffsetTable178, g_FieldOffsetTable179, g_FieldOffsetTable180, g_FieldOffsetTable181, g_FieldOffsetTable182, g_FieldOffsetTable183, NULL, NULL, g_FieldOffsetTable186, g_FieldOffsetTable187, g_FieldOffsetTable188, g_FieldOffsetTable189, g_FieldOffsetTable190, NULL, g_FieldOffsetTable192, g_FieldOffsetTable193, g_FieldOffsetTable194, g_FieldOffsetTable195, g_FieldOffsetTable196, g_FieldOffsetTable197, g_FieldOffsetTable198, g_FieldOffsetTable199, g_FieldOffsetTable200, g_FieldOffsetTable201, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable207, g_FieldOffsetTable208, g_FieldOffsetTable209, g_FieldOffsetTable210, g_FieldOffsetTable211, g_FieldOffsetTable212, g_FieldOffsetTable213, g_FieldOffsetTable214, g_FieldOffsetTable215, g_FieldOffsetTable216, NULL, g_FieldOffsetTable218, g_FieldOffsetTable219, g_FieldOffsetTable220, g_FieldOffsetTable221, g_FieldOffsetTable222, NULL, g_FieldOffsetTable224, g_FieldOffsetTable225, g_FieldOffsetTable226, g_FieldOffsetTable227, NULL, NULL, NULL, g_FieldOffsetTable231, g_FieldOffsetTable232, g_FieldOffsetTable233, g_FieldOffsetTable234, g_FieldOffsetTable235, g_FieldOffsetTable236, g_FieldOffsetTable237, g_FieldOffsetTable238, g_FieldOffsetTable239, g_FieldOffsetTable240, g_FieldOffsetTable241, g_FieldOffsetTable242, g_FieldOffsetTable243, g_FieldOffsetTable244, g_FieldOffsetTable245, NULL, g_FieldOffsetTable247, g_FieldOffsetTable248, NULL, g_FieldOffsetTable250, NULL, NULL, NULL, g_FieldOffsetTable254, g_FieldOffsetTable255, g_FieldOffsetTable256, g_FieldOffsetTable257, g_FieldOffsetTable258, g_FieldOffsetTable259, g_FieldOffsetTable260, g_FieldOffsetTable261, g_FieldOffsetTable262, NULL, NULL, g_FieldOffsetTable265, g_FieldOffsetTable266, NULL, g_FieldOffsetTable268, g_FieldOffsetTable269, g_FieldOffsetTable270, g_FieldOffsetTable271, g_FieldOffsetTable272, g_FieldOffsetTable273, NULL, g_FieldOffsetTable275, g_FieldOffsetTable276, g_FieldOffsetTable277, NULL, g_FieldOffsetTable279, g_FieldOffsetTable280, NULL, g_FieldOffsetTable282, g_FieldOffsetTable283, g_FieldOffsetTable284, NULL, g_FieldOffsetTable286, g_FieldOffsetTable287, NULL, g_FieldOffsetTable289, g_FieldOffsetTable290, NULL, g_FieldOffsetTable292, g_FieldOffsetTable293, g_FieldOffsetTable294, g_FieldOffsetTable295, g_FieldOffsetTable296, g_FieldOffsetTable297, g_FieldOffsetTable298, g_FieldOffsetTable299, NULL, g_FieldOffsetTable301, NULL, g_FieldOffsetTable303, g_FieldOffsetTable304, NULL, g_FieldOffsetTable306, g_FieldOffsetTable307, g_FieldOffsetTable308, NULL, g_FieldOffsetTable310, g_FieldOffsetTable311, g_FieldOffsetTable312, g_FieldOffsetTable313, g_FieldOffsetTable314, g_FieldOffsetTable315, g_FieldOffsetTable316, g_FieldOffsetTable317, g_FieldOffsetTable318, g_FieldOffsetTable319, g_FieldOffsetTable320, g_FieldOffsetTable321, g_FieldOffsetTable322, g_FieldOffsetTable323, g_FieldOffsetTable324, g_FieldOffsetTable325, g_FieldOffsetTable326, g_FieldOffsetTable327, g_FieldOffsetTable328, g_FieldOffsetTable329, NULL, g_FieldOffsetTable331, NULL, g_FieldOffsetTable333, g_FieldOffsetTable334, g_FieldOffsetTable335, g_FieldOffsetTable336, g_FieldOffsetTable337, g_FieldOffsetTable338, g_FieldOffsetTable339, g_FieldOffsetTable340, g_FieldOffsetTable341, g_FieldOffsetTable342, g_FieldOffsetTable343, g_FieldOffsetTable344, g_FieldOffsetTable345, g_FieldOffsetTable346, g_FieldOffsetTable347, NULL, g_FieldOffsetTable349, g_FieldOffsetTable350, g_FieldOffsetTable351, g_FieldOffsetTable352, g_FieldOffsetTable353, g_FieldOffsetTable354, g_FieldOffsetTable355, g_FieldOffsetTable356, NULL, g_FieldOffsetTable358, NULL, g_FieldOffsetTable360, g_FieldOffsetTable361, g_FieldOffsetTable362, g_FieldOffsetTable363, g_FieldOffsetTable364, NULL, g_FieldOffsetTable366, NULL, g_FieldOffsetTable368, g_FieldOffsetTable369, g_FieldOffsetTable370, g_FieldOffsetTable371, g_FieldOffsetTable372, NULL, NULL, g_FieldOffsetTable375, g_FieldOffsetTable376, g_FieldOffsetTable377, g_FieldOffsetTable378, g_FieldOffsetTable379, g_FieldOffsetTable380, NULL, NULL, NULL, g_FieldOffsetTable384, g_FieldOffsetTable385, g_FieldOffsetTable386, g_FieldOffsetTable387, g_FieldOffsetTable388, g_FieldOffsetTable389, g_FieldOffsetTable390, NULL, g_FieldOffsetTable392, g_FieldOffsetTable393, NULL, NULL, NULL, g_FieldOffsetTable397, g_FieldOffsetTable398, NULL, g_FieldOffsetTable400, g_FieldOffsetTable401, g_FieldOffsetTable402, g_FieldOffsetTable403, g_FieldOffsetTable404, g_FieldOffsetTable405, g_FieldOffsetTable406, g_FieldOffsetTable407, NULL, g_FieldOffsetTable409, g_FieldOffsetTable410, g_FieldOffsetTable411, g_FieldOffsetTable412, NULL, g_FieldOffsetTable414, g_FieldOffsetTable415, g_FieldOffsetTable416, NULL, g_FieldOffsetTable418, NULL, g_FieldOffsetTable420, g_FieldOffsetTable421, NULL, g_FieldOffsetTable423, NULL, NULL, g_FieldOffsetTable426, g_FieldOffsetTable427, g_FieldOffsetTable428, g_FieldOffsetTable429, g_FieldOffsetTable430, g_FieldOffsetTable431, g_FieldOffsetTable432, g_FieldOffsetTable433, NULL, g_FieldOffsetTable435, g_FieldOffsetTable436, g_FieldOffsetTable437, g_FieldOffsetTable438, g_FieldOffsetTable439, NULL, g_FieldOffsetTable441, g_FieldOffsetTable442, g_FieldOffsetTable443, g_FieldOffsetTable444, g_FieldOffsetTable445, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable471, g_FieldOffsetTable472, NULL, g_FieldOffsetTable474, NULL, NULL, NULL, g_FieldOffsetTable478, g_FieldOffsetTable479, g_FieldOffsetTable480, g_FieldOffsetTable481, g_FieldOffsetTable482, g_FieldOffsetTable483, NULL, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable491, g_FieldOffsetTable492, g_FieldOffsetTable493, g_FieldOffsetTable494, NULL, g_FieldOffsetTable496, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable507, g_FieldOffsetTable508, g_FieldOffsetTable509, NULL, NULL, g_FieldOffsetTable512, NULL, g_FieldOffsetTable514, g_FieldOffsetTable515, g_FieldOffsetTable516, g_FieldOffsetTable517, g_FieldOffsetTable518, g_FieldOffsetTable519, g_FieldOffsetTable520, g_FieldOffsetTable521, g_FieldOffsetTable522, g_FieldOffsetTable523, g_FieldOffsetTable524, g_FieldOffsetTable525, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable535, g_FieldOffsetTable536, g_FieldOffsetTable537, g_FieldOffsetTable538, g_FieldOffsetTable539, g_FieldOffsetTable540, g_FieldOffsetTable541, g_FieldOffsetTable542, g_FieldOffsetTable543, NULL, NULL, NULL, g_FieldOffsetTable547, g_FieldOffsetTable548, NULL, g_FieldOffsetTable550, g_FieldOffsetTable551, g_FieldOffsetTable552, g_FieldOffsetTable553, g_FieldOffsetTable554, NULL, g_FieldOffsetTable556, NULL, g_FieldOffsetTable558, g_FieldOffsetTable559, g_FieldOffsetTable560, NULL, g_FieldOffsetTable562, g_FieldOffsetTable563, g_FieldOffsetTable564, g_FieldOffsetTable565, NULL, NULL, NULL, g_FieldOffsetTable569, g_FieldOffsetTable570, g_FieldOffsetTable571, g_FieldOffsetTable572, g_FieldOffsetTable573, g_FieldOffsetTable574, g_FieldOffsetTable575, g_FieldOffsetTable576, NULL, NULL, g_FieldOffsetTable579, g_FieldOffsetTable580, NULL, NULL, NULL, g_FieldOffsetTable584, g_FieldOffsetTable585, g_FieldOffsetTable586, g_FieldOffsetTable587, g_FieldOffsetTable588, g_FieldOffsetTable589, g_FieldOffsetTable590, g_FieldOffsetTable591, g_FieldOffsetTable592, g_FieldOffsetTable593, g_FieldOffsetTable594, g_FieldOffsetTable595, g_FieldOffsetTable596, g_FieldOffsetTable597, NULL, g_FieldOffsetTable599, g_FieldOffsetTable600, g_FieldOffsetTable601, g_FieldOffsetTable602, g_FieldOffsetTable603, g_FieldOffsetTable604, g_FieldOffsetTable605, g_FieldOffsetTable606, g_FieldOffsetTable607, g_FieldOffsetTable608, g_FieldOffsetTable609, g_FieldOffsetTable610, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable619, NULL, g_FieldOffsetTable621, g_FieldOffsetTable622, g_FieldOffsetTable623, g_FieldOffsetTable624, g_FieldOffsetTable625, g_FieldOffsetTable626, g_FieldOffsetTable627, g_FieldOffsetTable628, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable634, NULL, g_FieldOffsetTable636, NULL, g_FieldOffsetTable638, g_FieldOffsetTable639, g_FieldOffsetTable640, g_FieldOffsetTable641, g_FieldOffsetTable642, g_FieldOffsetTable643, g_FieldOffsetTable644, g_FieldOffsetTable645, g_FieldOffsetTable646, NULL, NULL, NULL, g_FieldOffsetTable650, g_FieldOffsetTable651, g_FieldOffsetTable652, NULL, NULL, g_FieldOffsetTable655, g_FieldOffsetTable656, g_FieldOffsetTable657, g_FieldOffsetTable658, NULL, NULL, g_FieldOffsetTable661, g_FieldOffsetTable662, g_FieldOffsetTable663, g_FieldOffsetTable664, g_FieldOffsetTable665, NULL, NULL, NULL, NULL, g_FieldOffsetTable670, g_FieldOffsetTable671, g_FieldOffsetTable672, NULL, NULL, g_FieldOffsetTable675, g_FieldOffsetTable676, g_FieldOffsetTable677, NULL, g_FieldOffsetTable679, g_FieldOffsetTable680, g_FieldOffsetTable681, NULL, g_FieldOffsetTable683, NULL, g_FieldOffsetTable685, g_FieldOffsetTable686, NULL, g_FieldOffsetTable688, g_FieldOffsetTable689, g_FieldOffsetTable690, g_FieldOffsetTable691, g_FieldOffsetTable692, NULL, NULL, NULL, g_FieldOffsetTable696, g_FieldOffsetTable697, NULL, g_FieldOffsetTable699, g_FieldOffsetTable700, g_FieldOffsetTable701, NULL, g_FieldOffsetTable703, NULL, g_FieldOffsetTable705, NULL, g_FieldOffsetTable707, g_FieldOffsetTable708, g_FieldOffsetTable709, NULL, NULL, g_FieldOffsetTable712, g_FieldOffsetTable713, NULL, NULL, g_FieldOffsetTable716, NULL, NULL, NULL, g_FieldOffsetTable720, g_FieldOffsetTable721, g_FieldOffsetTable722, g_FieldOffsetTable723, g_FieldOffsetTable724, g_FieldOffsetTable725, g_FieldOffsetTable726, g_FieldOffsetTable727, g_FieldOffsetTable728, NULL, NULL, g_FieldOffsetTable731, NULL, NULL, g_FieldOffsetTable734, g_FieldOffsetTable735, g_FieldOffsetTable736, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable742, g_FieldOffsetTable743, g_FieldOffsetTable744, g_FieldOffsetTable745, g_FieldOffsetTable746, g_FieldOffsetTable747, g_FieldOffsetTable748, g_FieldOffsetTable749, g_FieldOffsetTable750, g_FieldOffsetTable751, g_FieldOffsetTable752, NULL, NULL, NULL, NULL, g_FieldOffsetTable757, NULL, NULL, g_FieldOffsetTable760, NULL, g_FieldOffsetTable762, g_FieldOffsetTable763, g_FieldOffsetTable764, NULL, NULL, g_FieldOffsetTable767, NULL, g_FieldOffsetTable769, g_FieldOffsetTable770, g_FieldOffsetTable771, g_FieldOffsetTable772, g_FieldOffsetTable773, NULL, g_FieldOffsetTable775, g_FieldOffsetTable776, g_FieldOffsetTable777, g_FieldOffsetTable778, g_FieldOffsetTable779, g_FieldOffsetTable780, g_FieldOffsetTable781, g_FieldOffsetTable782, g_FieldOffsetTable783, g_FieldOffsetTable784, g_FieldOffsetTable785, NULL, g_FieldOffsetTable787, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable793, g_FieldOffsetTable794, NULL, g_FieldOffsetTable796, NULL, NULL, NULL, g_FieldOffsetTable800, NULL, g_FieldOffsetTable802, NULL, g_FieldOffsetTable804, g_FieldOffsetTable805, NULL, g_FieldOffsetTable807, NULL, g_FieldOffsetTable809, NULL, g_FieldOffsetTable811, NULL, g_FieldOffsetTable813, g_FieldOffsetTable814, g_FieldOffsetTable815, g_FieldOffsetTable816, NULL, g_FieldOffsetTable818, NULL, g_FieldOffsetTable820, g_FieldOffsetTable821, NULL, g_FieldOffsetTable823, g_FieldOffsetTable824, NULL, g_FieldOffsetTable826, g_FieldOffsetTable827, g_FieldOffsetTable828, g_FieldOffsetTable829, g_FieldOffsetTable830, g_FieldOffsetTable831, NULL, g_FieldOffsetTable833, g_FieldOffsetTable834, g_FieldOffsetTable835, g_FieldOffsetTable836, g_FieldOffsetTable837, g_FieldOffsetTable838, g_FieldOffsetTable839, g_FieldOffsetTable840, NULL, NULL, NULL, NULL, g_FieldOffsetTable845, g_FieldOffsetTable846, g_FieldOffsetTable847, NULL, NULL, NULL, g_FieldOffsetTable851, NULL, g_FieldOffsetTable853, g_FieldOffsetTable854, NULL, NULL, NULL, g_FieldOffsetTable858, g_FieldOffsetTable859, g_FieldOffsetTable860, g_FieldOffsetTable861, NULL, NULL, g_FieldOffsetTable864, NULL, g_FieldOffsetTable866, g_FieldOffsetTable867, g_FieldOffsetTable868, g_FieldOffsetTable869, g_FieldOffsetTable870, g_FieldOffsetTable871, g_FieldOffsetTable872, g_FieldOffsetTable873, NULL, NULL, NULL, g_FieldOffsetTable877, g_FieldOffsetTable878, g_FieldOffsetTable879, g_FieldOffsetTable880, g_FieldOffsetTable881, g_FieldOffsetTable882, g_FieldOffsetTable883, g_FieldOffsetTable884, g_FieldOffsetTable885, g_FieldOffsetTable886, NULL, g_FieldOffsetTable888, g_FieldOffsetTable889, NULL, g_FieldOffsetTable891, g_FieldOffsetTable892, g_FieldOffsetTable893, g_FieldOffsetTable894, g_FieldOffsetTable895, NULL, NULL, g_FieldOffsetTable898, g_FieldOffsetTable899, g_FieldOffsetTable900, g_FieldOffsetTable901, g_FieldOffsetTable902, g_FieldOffsetTable903, NULL, g_FieldOffsetTable905, g_FieldOffsetTable906, g_FieldOffsetTable907, g_FieldOffsetTable908, g_FieldOffsetTable909, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable929, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable955, g_FieldOffsetTable956, g_FieldOffsetTable957, NULL, g_FieldOffsetTable959, NULL, NULL, NULL, g_FieldOffsetTable963, NULL, NULL, NULL, g_FieldOffsetTable967, g_FieldOffsetTable968, g_FieldOffsetTable969, NULL, g_FieldOffsetTable971, NULL, g_FieldOffsetTable973, NULL, g_FieldOffsetTable975, g_FieldOffsetTable976, NULL, g_FieldOffsetTable978, g_FieldOffsetTable979, g_FieldOffsetTable980, g_FieldOffsetTable981, NULL, g_FieldOffsetTable983, g_FieldOffsetTable984, g_FieldOffsetTable985, g_FieldOffsetTable986, g_FieldOffsetTable987, NULL, g_FieldOffsetTable989, g_FieldOffsetTable990, g_FieldOffsetTable991, g_FieldOffsetTable992, g_FieldOffsetTable993, g_FieldOffsetTable994, g_FieldOffsetTable995, g_FieldOffsetTable996, g_FieldOffsetTable997, g_FieldOffsetTable998, g_FieldOffsetTable999, g_FieldOffsetTable1000, g_FieldOffsetTable1001, g_FieldOffsetTable1002, g_FieldOffsetTable1003, g_FieldOffsetTable1004, g_FieldOffsetTable1005, g_FieldOffsetTable1006, g_FieldOffsetTable1007, g_FieldOffsetTable1008, g_FieldOffsetTable1009, g_FieldOffsetTable1010, g_FieldOffsetTable1011, g_FieldOffsetTable1012, g_FieldOffsetTable1013, g_FieldOffsetTable1014, g_FieldOffsetTable1015, NULL, g_FieldOffsetTable1017, NULL, g_FieldOffsetTable1019, g_FieldOffsetTable1020, g_FieldOffsetTable1021, g_FieldOffsetTable1022, g_FieldOffsetTable1023, g_FieldOffsetTable1024, g_FieldOffsetTable1025, g_FieldOffsetTable1026, g_FieldOffsetTable1027, g_FieldOffsetTable1028, g_FieldOffsetTable1029, g_FieldOffsetTable1030, g_FieldOffsetTable1031, g_FieldOffsetTable1032, g_FieldOffsetTable1033, g_FieldOffsetTable1034, NULL, g_FieldOffsetTable1036, g_FieldOffsetTable1037, g_FieldOffsetTable1038, g_FieldOffsetTable1039, g_FieldOffsetTable1040, g_FieldOffsetTable1041, g_FieldOffsetTable1042, g_FieldOffsetTable1043, g_FieldOffsetTable1044, g_FieldOffsetTable1045, g_FieldOffsetTable1046, g_FieldOffsetTable1047, g_FieldOffsetTable1048, g_FieldOffsetTable1049, g_FieldOffsetTable1050, NULL, g_FieldOffsetTable1052, g_FieldOffsetTable1053, NULL, g_FieldOffsetTable1055, g_FieldOffsetTable1056, g_FieldOffsetTable1057, g_FieldOffsetTable1058, NULL, g_FieldOffsetTable1060, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable1066, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable1078, g_FieldOffsetTable1079, g_FieldOffsetTable1080, g_FieldOffsetTable1081, g_FieldOffsetTable1082, g_FieldOffsetTable1083, g_FieldOffsetTable1084, g_FieldOffsetTable1085, g_FieldOffsetTable1086, g_FieldOffsetTable1087, g_FieldOffsetTable1088, g_FieldOffsetTable1089, g_FieldOffsetTable1090, g_FieldOffsetTable1091, g_FieldOffsetTable1092, g_FieldOffsetTable1093, g_FieldOffsetTable1094, g_FieldOffsetTable1095, g_FieldOffsetTable1096, NULL, g_FieldOffsetTable1098, g_FieldOffsetTable1099, g_FieldOffsetTable1100, g_FieldOffsetTable1101, NULL, g_FieldOffsetTable1103, NULL, NULL, g_FieldOffsetTable1106, NULL, NULL, g_FieldOffsetTable1109, g_FieldOffsetTable1110, NULL, NULL, g_FieldOffsetTable1113, g_FieldOffsetTable1114, NULL, NULL, g_FieldOffsetTable1117, g_FieldOffsetTable1118, g_FieldOffsetTable1119, g_FieldOffsetTable1120, g_FieldOffsetTable1121, g_FieldOffsetTable1122, g_FieldOffsetTable1123, g_FieldOffsetTable1124, g_FieldOffsetTable1125, g_FieldOffsetTable1126, g_FieldOffsetTable1127, g_FieldOffsetTable1128, g_FieldOffsetTable1129, g_FieldOffsetTable1130, g_FieldOffsetTable1131, NULL, g_FieldOffsetTable1133, NULL, g_FieldOffsetTable1135, g_FieldOffsetTable1136, g_FieldOffsetTable1137, g_FieldOffsetTable1138, g_FieldOffsetTable1139, g_FieldOffsetTable1140, g_FieldOffsetTable1141, g_FieldOffsetTable1142, g_FieldOffsetTable1143, g_FieldOffsetTable1144, g_FieldOffsetTable1145, g_FieldOffsetTable1146, g_FieldOffsetTable1147, g_FieldOffsetTable1148, g_FieldOffsetTable1149, g_FieldOffsetTable1150, g_FieldOffsetTable1151, g_FieldOffsetTable1152, g_FieldOffsetTable1153, g_FieldOffsetTable1154, g_FieldOffsetTable1155, g_FieldOffsetTable1156, g_FieldOffsetTable1157, g_FieldOffsetTable1158, g_FieldOffsetTable1159, g_FieldOffsetTable1160, g_FieldOffsetTable1161, g_FieldOffsetTable1162, g_FieldOffsetTable1163, g_FieldOffsetTable1164, g_FieldOffsetTable1165, g_FieldOffsetTable1166, g_FieldOffsetTable1167, g_FieldOffsetTable1168, g_FieldOffsetTable1169, g_FieldOffsetTable1170, g_FieldOffsetTable1171, g_FieldOffsetTable1172, g_FieldOffsetTable1173, g_FieldOffsetTable1174, NULL, NULL, g_FieldOffsetTable1177, g_FieldOffsetTable1178, g_FieldOffsetTable1179, g_FieldOffsetTable1180, g_FieldOffsetTable1181, NULL, NULL, NULL, g_FieldOffsetTable1185, g_FieldOffsetTable1186, g_FieldOffsetTable1187, g_FieldOffsetTable1188, g_FieldOffsetTable1189, g_FieldOffsetTable1190, g_FieldOffsetTable1191, g_FieldOffsetTable1192, g_FieldOffsetTable1193, g_FieldOffsetTable1194, g_FieldOffsetTable1195, g_FieldOffsetTable1196, g_FieldOffsetTable1197, NULL, g_FieldOffsetTable1199, g_FieldOffsetTable1200, NULL, NULL, g_FieldOffsetTable1203, NULL, g_FieldOffsetTable1205, g_FieldOffsetTable1206, g_FieldOffsetTable1207, NULL, g_FieldOffsetTable1209, NULL, g_FieldOffsetTable1211, g_FieldOffsetTable1212, NULL, g_FieldOffsetTable1214, g_FieldOffsetTable1215, g_FieldOffsetTable1216, g_FieldOffsetTable1217, g_FieldOffsetTable1218, g_FieldOffsetTable1219, NULL, NULL, g_FieldOffsetTable1222, g_FieldOffsetTable1223, NULL, g_FieldOffsetTable1225, g_FieldOffsetTable1226, g_FieldOffsetTable1227, g_FieldOffsetTable1228, NULL, NULL, g_FieldOffsetTable1231, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable1238, g_FieldOffsetTable1239, g_FieldOffsetTable1240, g_FieldOffsetTable1241, g_FieldOffsetTable1242, g_FieldOffsetTable1243, NULL, NULL, g_FieldOffsetTable1246, g_FieldOffsetTable1247, NULL, NULL, g_FieldOffsetTable1250, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable1257, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable1264, g_FieldOffsetTable1265, NULL, g_FieldOffsetTable1267, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable1279, g_FieldOffsetTable1280, g_FieldOffsetTable1281, g_FieldOffsetTable1282, NULL, g_FieldOffsetTable1284, g_FieldOffsetTable1285, NULL, NULL, NULL, NULL, g_FieldOffsetTable1290, g_FieldOffsetTable1291, g_FieldOffsetTable1292, NULL, NULL, g_FieldOffsetTable1295, NULL, NULL, g_FieldOffsetTable1298, NULL, g_FieldOffsetTable1300, NULL, g_FieldOffsetTable1302, g_FieldOffsetTable1303, g_FieldOffsetTable1304, NULL, g_FieldOffsetTable1306, NULL, g_FieldOffsetTable1308, NULL, NULL, g_FieldOffsetTable1311, NULL, g_FieldOffsetTable1313, NULL, NULL, g_FieldOffsetTable1316, NULL, NULL, g_FieldOffsetTable1319, g_FieldOffsetTable1320, g_FieldOffsetTable1321, g_FieldOffsetTable1322, g_FieldOffsetTable1323, g_FieldOffsetTable1324, g_FieldOffsetTable1325, NULL, g_FieldOffsetTable1327, g_FieldOffsetTable1328, g_FieldOffsetTable1329, g_FieldOffsetTable1330, g_FieldOffsetTable1331, NULL, NULL, g_FieldOffsetTable1334, g_FieldOffsetTable1335, NULL, NULL, NULL, g_FieldOffsetTable1339, g_FieldOffsetTable1340, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable1347, g_FieldOffsetTable1348, g_FieldOffsetTable1349, g_FieldOffsetTable1350, NULL, g_FieldOffsetTable1352, g_FieldOffsetTable1353, NULL, g_FieldOffsetTable1355, NULL, g_FieldOffsetTable1357, g_FieldOffsetTable1358, g_FieldOffsetTable1359, NULL, NULL, NULL, g_FieldOffsetTable1363, NULL, g_FieldOffsetTable1365, g_FieldOffsetTable1366, g_FieldOffsetTable1367, g_FieldOffsetTable1368, NULL, g_FieldOffsetTable1370, g_FieldOffsetTable1371, NULL, NULL, g_FieldOffsetTable1374, g_FieldOffsetTable1375, g_FieldOffsetTable1376, g_FieldOffsetTable1377, g_FieldOffsetTable1378, g_FieldOffsetTable1379, g_FieldOffsetTable1380, g_FieldOffsetTable1381, g_FieldOffsetTable1382, NULL, g_FieldOffsetTable1384, g_FieldOffsetTable1385, NULL, g_FieldOffsetTable1387, NULL, NULL, NULL, g_FieldOffsetTable1391, NULL, NULL, NULL, g_FieldOffsetTable1395, g_FieldOffsetTable1396, NULL, g_FieldOffsetTable1398, NULL, NULL, NULL, g_FieldOffsetTable1402, g_FieldOffsetTable1403, g_FieldOffsetTable1404, g_FieldOffsetTable1405, g_FieldOffsetTable1406, g_FieldOffsetTable1407, g_FieldOffsetTable1408, g_FieldOffsetTable1409, g_FieldOffsetTable1410, g_FieldOffsetTable1411, g_FieldOffsetTable1412, g_FieldOffsetTable1413, g_FieldOffsetTable1414, g_FieldOffsetTable1415, g_FieldOffsetTable1416, g_FieldOffsetTable1417, NULL, NULL, g_FieldOffsetTable1420, NULL, g_FieldOffsetTable1422, g_FieldOffsetTable1423, g_FieldOffsetTable1424, g_FieldOffsetTable1425, g_FieldOffsetTable1426, NULL, g_FieldOffsetTable1428, g_FieldOffsetTable1429, NULL, NULL, g_FieldOffsetTable1432, g_FieldOffsetTable1433, g_FieldOffsetTable1434, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable1560, g_FieldOffsetTable1561, NULL, NULL, g_FieldOffsetTable1564, g_FieldOffsetTable1565, g_FieldOffsetTable1566, g_FieldOffsetTable1567, g_FieldOffsetTable1568, NULL, g_FieldOffsetTable1570, NULL, g_FieldOffsetTable1572, g_FieldOffsetTable1573, g_FieldOffsetTable1574, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable1581, NULL, g_FieldOffsetTable1583, NULL, NULL, g_FieldOffsetTable1586, g_FieldOffsetTable1587, g_FieldOffsetTable1588, g_FieldOffsetTable1589, g_FieldOffsetTable1590, g_FieldOffsetTable1591, g_FieldOffsetTable1592, NULL, g_FieldOffsetTable1594, g_FieldOffsetTable1595, g_FieldOffsetTable1596, g_FieldOffsetTable1597, g_FieldOffsetTable1598, g_FieldOffsetTable1599, g_FieldOffsetTable1600, g_FieldOffsetTable1601, g_FieldOffsetTable1602, g_FieldOffsetTable1603, g_FieldOffsetTable1604, NULL, g_FieldOffsetTable1606, NULL, g_FieldOffsetTable1608, NULL, g_FieldOffsetTable1610, NULL, g_FieldOffsetTable1612, NULL, g_FieldOffsetTable1614, NULL, g_FieldOffsetTable1616, g_FieldOffsetTable1617, g_FieldOffsetTable1618, g_FieldOffsetTable1619, NULL, NULL, g_FieldOffsetTable1622, g_FieldOffsetTable1623, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable1642, NULL, NULL, NULL, g_FieldOffsetTable1646, g_FieldOffsetTable1647, g_FieldOffsetTable1648, NULL, NULL, NULL, g_FieldOffsetTable1652, g_FieldOffsetTable1653, g_FieldOffsetTable1654, g_FieldOffsetTable1655, g_FieldOffsetTable1656, g_FieldOffsetTable1657, g_FieldOffsetTable1658, g_FieldOffsetTable1659, g_FieldOffsetTable1660, NULL, NULL, g_FieldOffsetTable1663, g_FieldOffsetTable1664, NULL, NULL, g_FieldOffsetTable1667, g_FieldOffsetTable1668, NULL, g_FieldOffsetTable1670, g_FieldOffsetTable1671, g_FieldOffsetTable1672, g_FieldOffsetTable1673, g_FieldOffsetTable1674, NULL, NULL, g_FieldOffsetTable1677, g_FieldOffsetTable1678, g_FieldOffsetTable1679, g_FieldOffsetTable1680, NULL, NULL, g_FieldOffsetTable1683, g_FieldOffsetTable1684, g_FieldOffsetTable1685, g_FieldOffsetTable1686, g_FieldOffsetTable1687, g_FieldOffsetTable1688, g_FieldOffsetTable1689, NULL, NULL, g_FieldOffsetTable1692, NULL, g_FieldOffsetTable1694, NULL, g_FieldOffsetTable1696, g_FieldOffsetTable1697, NULL, NULL, NULL, g_FieldOffsetTable1701, g_FieldOffsetTable1702, g_FieldOffsetTable1703, g_FieldOffsetTable1704, g_FieldOffsetTable1705, g_FieldOffsetTable1706, g_FieldOffsetTable1707, g_FieldOffsetTable1708, g_FieldOffsetTable1709, g_FieldOffsetTable1710, g_FieldOffsetTable1711, NULL, NULL, NULL, g_FieldOffsetTable1715, g_FieldOffsetTable1716, g_FieldOffsetTable1717, g_FieldOffsetTable1718, NULL, g_FieldOffsetTable1720, g_FieldOffsetTable1721, g_FieldOffsetTable1722, g_FieldOffsetTable1723, g_FieldOffsetTable1724, g_FieldOffsetTable1725, g_FieldOffsetTable1726, NULL, g_FieldOffsetTable1728, g_FieldOffsetTable1729, g_FieldOffsetTable1730, g_FieldOffsetTable1731, g_FieldOffsetTable1732, g_FieldOffsetTable1733, g_FieldOffsetTable1734, g_FieldOffsetTable1735, g_FieldOffsetTable1736, NULL, g_FieldOffsetTable1738, NULL, NULL, g_FieldOffsetTable1741, g_FieldOffsetTable1742, NULL, NULL, NULL, g_FieldOffsetTable1746, g_FieldOffsetTable1747, g_FieldOffsetTable1748, g_FieldOffsetTable1749, g_FieldOffsetTable1750, g_FieldOffsetTable1751, g_FieldOffsetTable1752, g_FieldOffsetTable1753, g_FieldOffsetTable1754, NULL, g_FieldOffsetTable1756, g_FieldOffsetTable1757, NULL, g_FieldOffsetTable1759, g_FieldOffsetTable1760, g_FieldOffsetTable1761, NULL, NULL, g_FieldOffsetTable1764, g_FieldOffsetTable1765, g_FieldOffsetTable1766, g_FieldOffsetTable1767, g_FieldOffsetTable1768, g_FieldOffsetTable1769, g_FieldOffsetTable1770, g_FieldOffsetTable1771, g_FieldOffsetTable1772, g_FieldOffsetTable1773, g_FieldOffsetTable1774, g_FieldOffsetTable1775, NULL, NULL, g_FieldOffsetTable1778, NULL, NULL, NULL, NULL, g_FieldOffsetTable1783, g_FieldOffsetTable1784, g_FieldOffsetTable1785, NULL, g_FieldOffsetTable1787, NULL, g_FieldOffsetTable1789, g_FieldOffsetTable1790, NULL, g_FieldOffsetTable1792, g_FieldOffsetTable1793, g_FieldOffsetTable1794, g_FieldOffsetTable1795, g_FieldOffsetTable1796, g_FieldOffsetTable1797, g_FieldOffsetTable1798, g_FieldOffsetTable1799, g_FieldOffsetTable1800, g_FieldOffsetTable1801, g_FieldOffsetTable1802, NULL, g_FieldOffsetTable1804, g_FieldOffsetTable1805, g_FieldOffsetTable1806, NULL, g_FieldOffsetTable1808, g_FieldOffsetTable1809, NULL, g_FieldOffsetTable1811, g_FieldOffsetTable1812, g_FieldOffsetTable1813, g_FieldOffsetTable1814, NULL, NULL, g_FieldOffsetTable1817, g_FieldOffsetTable1818, NULL, NULL, g_FieldOffsetTable1821, NULL, g_FieldOffsetTable1823, g_FieldOffsetTable1824, g_FieldOffsetTable1825, NULL, NULL, NULL, NULL, g_FieldOffsetTable1830, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable1837, NULL, g_FieldOffsetTable1839, g_FieldOffsetTable1840, g_FieldOffsetTable1841, g_FieldOffsetTable1842, NULL, g_FieldOffsetTable1844, g_FieldOffsetTable1845, NULL, NULL, g_FieldOffsetTable1848, NULL, NULL, NULL, g_FieldOffsetTable1852, NULL, g_FieldOffsetTable1854, g_FieldOffsetTable1855, NULL, g_FieldOffsetTable1857, NULL, g_FieldOffsetTable1859, NULL, g_FieldOffsetTable1861, NULL, NULL, g_FieldOffsetTable1864, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable1883, g_FieldOffsetTable1884, NULL, g_FieldOffsetTable1886, g_FieldOffsetTable1887, g_FieldOffsetTable1888, NULL, g_FieldOffsetTable1890, g_FieldOffsetTable1891, g_FieldOffsetTable1892, NULL, g_FieldOffsetTable1894, g_FieldOffsetTable1895, g_FieldOffsetTable1896, g_FieldOffsetTable1897, g_FieldOffsetTable1898, g_FieldOffsetTable1899, NULL, g_FieldOffsetTable1901, g_FieldOffsetTable1902, g_FieldOffsetTable1903, g_FieldOffsetTable1904, g_FieldOffsetTable1905, g_FieldOffsetTable1906, g_FieldOffsetTable1907, g_FieldOffsetTable1908, NULL, g_FieldOffsetTable1910, g_FieldOffsetTable1911, NULL, g_FieldOffsetTable1913, g_FieldOffsetTable1914, NULL, g_FieldOffsetTable1916, NULL, g_FieldOffsetTable1918, g_FieldOffsetTable1919, g_FieldOffsetTable1920, g_FieldOffsetTable1921, NULL, g_FieldOffsetTable1923, g_FieldOffsetTable1924, NULL, g_FieldOffsetTable1926, g_FieldOffsetTable1927, g_FieldOffsetTable1928, g_FieldOffsetTable1929, g_FieldOffsetTable1930, g_FieldOffsetTable1931, g_FieldOffsetTable1932, g_FieldOffsetTable1933, NULL, g_FieldOffsetTable1935, g_FieldOffsetTable1936, g_FieldOffsetTable1937, g_FieldOffsetTable1938, g_FieldOffsetTable1939, g_FieldOffsetTable1940, g_FieldOffsetTable1941, g_FieldOffsetTable1942, NULL, g_FieldOffsetTable1944, g_FieldOffsetTable1945, g_FieldOffsetTable1946, g_FieldOffsetTable1947, g_FieldOffsetTable1948, g_FieldOffsetTable1949, g_FieldOffsetTable1950, g_FieldOffsetTable1951, NULL, NULL, g_FieldOffsetTable1954, g_FieldOffsetTable1955, g_FieldOffsetTable1956, g_FieldOffsetTable1957, g_FieldOffsetTable1958, NULL, NULL, NULL, g_FieldOffsetTable1962, g_FieldOffsetTable1963, g_FieldOffsetTable1964, g_FieldOffsetTable1965, g_FieldOffsetTable1966, NULL, NULL, NULL, g_FieldOffsetTable1970, g_FieldOffsetTable1971, g_FieldOffsetTable1972, g_FieldOffsetTable1973, g_FieldOffsetTable1974, g_FieldOffsetTable1975, NULL, g_FieldOffsetTable1977, g_FieldOffsetTable1978, g_FieldOffsetTable1979, g_FieldOffsetTable1980, g_FieldOffsetTable1981, NULL, g_FieldOffsetTable1983, g_FieldOffsetTable1984, g_FieldOffsetTable1985, NULL, g_FieldOffsetTable1987, g_FieldOffsetTable1988, NULL, g_FieldOffsetTable1990, g_FieldOffsetTable1991, g_FieldOffsetTable1992, g_FieldOffsetTable1993, g_FieldOffsetTable1994, g_FieldOffsetTable1995, g_FieldOffsetTable1996, NULL, g_FieldOffsetTable1998, g_FieldOffsetTable1999, NULL, NULL, NULL, g_FieldOffsetTable2003, g_FieldOffsetTable2004, g_FieldOffsetTable2005, g_FieldOffsetTable2006, g_FieldOffsetTable2007, g_FieldOffsetTable2008, g_FieldOffsetTable2009, g_FieldOffsetTable2010, g_FieldOffsetTable2011, g_FieldOffsetTable2012, g_FieldOffsetTable2013, g_FieldOffsetTable2014, g_FieldOffsetTable2015, NULL, g_FieldOffsetTable2017, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable2023, g_FieldOffsetTable2024, g_FieldOffsetTable2025, g_FieldOffsetTable2026, g_FieldOffsetTable2027, NULL, NULL, g_FieldOffsetTable2030, g_FieldOffsetTable2031, g_FieldOffsetTable2032, g_FieldOffsetTable2033, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable2040, NULL, g_FieldOffsetTable2042, NULL, NULL, NULL, NULL, g_FieldOffsetTable2047, g_FieldOffsetTable2048, NULL, NULL, g_FieldOffsetTable2051, g_FieldOffsetTable2052, g_FieldOffsetTable2053, g_FieldOffsetTable2054, g_FieldOffsetTable2055, g_FieldOffsetTable2056, g_FieldOffsetTable2057, g_FieldOffsetTable2058, g_FieldOffsetTable2059, g_FieldOffsetTable2060, g_FieldOffsetTable2061, g_FieldOffsetTable2062, g_FieldOffsetTable2063, g_FieldOffsetTable2064, g_FieldOffsetTable2065, g_FieldOffsetTable2066, g_FieldOffsetTable2067, g_FieldOffsetTable2068, g_FieldOffsetTable2069, g_FieldOffsetTable2070, NULL, g_FieldOffsetTable2072, NULL, g_FieldOffsetTable2074, g_FieldOffsetTable2075, g_FieldOffsetTable2076, g_FieldOffsetTable2077, g_FieldOffsetTable2078, NULL, g_FieldOffsetTable2080, NULL, g_FieldOffsetTable2082, g_FieldOffsetTable2083, NULL, NULL, g_FieldOffsetTable2086, g_FieldOffsetTable2087, NULL, NULL, g_FieldOffsetTable2090, g_FieldOffsetTable2091, NULL, NULL, g_FieldOffsetTable2094, NULL, g_FieldOffsetTable2096, NULL, g_FieldOffsetTable2098, g_FieldOffsetTable2099, NULL, NULL, g_FieldOffsetTable2102, g_FieldOffsetTable2103, g_FieldOffsetTable2104, g_FieldOffsetTable2105, g_FieldOffsetTable2106, g_FieldOffsetTable2107, g_FieldOffsetTable2108, g_FieldOffsetTable2109, g_FieldOffsetTable2110, g_FieldOffsetTable2111, g_FieldOffsetTable2112, NULL, g_FieldOffsetTable2114, g_FieldOffsetTable2115, g_FieldOffsetTable2116, g_FieldOffsetTable2117, g_FieldOffsetTable2118, NULL, g_FieldOffsetTable2120, g_FieldOffsetTable2121, NULL, g_FieldOffsetTable2123, g_FieldOffsetTable2124, NULL, g_FieldOffsetTable2126, g_FieldOffsetTable2127, g_FieldOffsetTable2128, NULL, g_FieldOffsetTable2130, g_FieldOffsetTable2131, g_FieldOffsetTable2132, g_FieldOffsetTable2133, g_FieldOffsetTable2134, g_FieldOffsetTable2135, g_FieldOffsetTable2136, g_FieldOffsetTable2137, g_FieldOffsetTable2138, g_FieldOffsetTable2139, g_FieldOffsetTable2140, g_FieldOffsetTable2141, g_FieldOffsetTable2142, g_FieldOffsetTable2143, g_FieldOffsetTable2144, g_FieldOffsetTable2145, g_FieldOffsetTable2146, g_FieldOffsetTable2147, g_FieldOffsetTable2148, g_FieldOffsetTable2149, g_FieldOffsetTable2150, g_FieldOffsetTable2151, g_FieldOffsetTable2152, g_FieldOffsetTable2153, g_FieldOffsetTable2154, g_FieldOffsetTable2155, g_FieldOffsetTable2156, NULL, NULL, g_FieldOffsetTable2159, g_FieldOffsetTable2160, NULL, g_FieldOffsetTable2162, g_FieldOffsetTable2163, g_FieldOffsetTable2164, g_FieldOffsetTable2165, g_FieldOffsetTable2166, g_FieldOffsetTable2167, g_FieldOffsetTable2168, g_FieldOffsetTable2169, g_FieldOffsetTable2170, g_FieldOffsetTable2171, g_FieldOffsetTable2172, g_FieldOffsetTable2173, g_FieldOffsetTable2174, g_FieldOffsetTable2175, g_FieldOffsetTable2176, g_FieldOffsetTable2177, g_FieldOffsetTable2178, g_FieldOffsetTable2179, g_FieldOffsetTable2180, g_FieldOffsetTable2181, NULL, g_FieldOffsetTable2183, g_FieldOffsetTable2184, g_FieldOffsetTable2185, g_FieldOffsetTable2186, g_FieldOffsetTable2187, g_FieldOffsetTable2188, g_FieldOffsetTable2189, g_FieldOffsetTable2190, g_FieldOffsetTable2191, g_FieldOffsetTable2192, g_FieldOffsetTable2193, g_FieldOffsetTable2194, g_FieldOffsetTable2195, NULL, NULL, g_FieldOffsetTable2198, g_FieldOffsetTable2199, g_FieldOffsetTable2200, g_FieldOffsetTable2201, g_FieldOffsetTable2202, g_FieldOffsetTable2203, g_FieldOffsetTable2204, g_FieldOffsetTable2205, g_FieldOffsetTable2206, g_FieldOffsetTable2207, g_FieldOffsetTable2208, g_FieldOffsetTable2209, NULL, g_FieldOffsetTable2211, NULL, g_FieldOffsetTable2213, g_FieldOffsetTable2214, g_FieldOffsetTable2215, g_FieldOffsetTable2216, g_FieldOffsetTable2217, g_FieldOffsetTable2218, NULL, g_FieldOffsetTable2220, g_FieldOffsetTable2221, g_FieldOffsetTable2222, g_FieldOffsetTable2223, g_FieldOffsetTable2224, g_FieldOffsetTable2225, g_FieldOffsetTable2226, g_FieldOffsetTable2227, g_FieldOffsetTable2228, g_FieldOffsetTable2229, g_FieldOffsetTable2230, g_FieldOffsetTable2231, NULL, g_FieldOffsetTable2233, g_FieldOffsetTable2234, g_FieldOffsetTable2235, g_FieldOffsetTable2236, g_FieldOffsetTable2237, g_FieldOffsetTable2238, g_FieldOffsetTable2239, g_FieldOffsetTable2240, g_FieldOffsetTable2241, g_FieldOffsetTable2242, g_FieldOffsetTable2243, g_FieldOffsetTable2244, NULL, g_FieldOffsetTable2246, g_FieldOffsetTable2247, g_FieldOffsetTable2248, g_FieldOffsetTable2249, g_FieldOffsetTable2250, g_FieldOffsetTable2251, g_FieldOffsetTable2252, g_FieldOffsetTable2253, g_FieldOffsetTable2254, g_FieldOffsetTable2255, g_FieldOffsetTable2256, g_FieldOffsetTable2257, g_FieldOffsetTable2258, g_FieldOffsetTable2259, g_FieldOffsetTable2260, g_FieldOffsetTable2261, g_FieldOffsetTable2262, g_FieldOffsetTable2263, g_FieldOffsetTable2264, g_FieldOffsetTable2265, g_FieldOffsetTable2266, g_FieldOffsetTable2267, g_FieldOffsetTable2268, g_FieldOffsetTable2269, g_FieldOffsetTable2270, g_FieldOffsetTable2271, NULL, g_FieldOffsetTable2273, g_FieldOffsetTable2274, g_FieldOffsetTable2275, g_FieldOffsetTable2276, g_FieldOffsetTable2277, g_FieldOffsetTable2278, g_FieldOffsetTable2279, g_FieldOffsetTable2280, g_FieldOffsetTable2281, g_FieldOffsetTable2282, g_FieldOffsetTable2283, g_FieldOffsetTable2284, g_FieldOffsetTable2285, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, g_FieldOffsetTable2317, }; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize0; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize3; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize4; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize5; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize6; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize7; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize8; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize9; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize10; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize11; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize12; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize13; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize14; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize15; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize16; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize17; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize18; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize19; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize20; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize21; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize22; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize23; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize24; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize25; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize26; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize27; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize28; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize29; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize30; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize31; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize32; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize33; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize34; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize35; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize36; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize37; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize38; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize39; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize40; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize41; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize42; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize43; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize44; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize45; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize46; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize47; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize48; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize49; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize50; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize51; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize52; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize53; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize54; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize55; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize56; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize57; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize58; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize59; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize60; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize61; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize62; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize63; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize64; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize65; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize66; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize67; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize68; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize69; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize70; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize71; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize72; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize73; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize74; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize75; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize76; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize77; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize78; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize79; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize80; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize81; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize82; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize83; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize84; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize85; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize86; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize87; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize88; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize89; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize90; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize91; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize92; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize93; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize94; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize95; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize96; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize97; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize98; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize99; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize100; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize101; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize102; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize103; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize104; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize105; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize106; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize107; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize108; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize109; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize110; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize111; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize112; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize113; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize114; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize115; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize116; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize117; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize118; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize119; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize120; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize121; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize122; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize123; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize124; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize125; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize126; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize127; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize128; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize129; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize130; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize131; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize132; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize133; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize134; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize135; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize136; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize137; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize138; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize139; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize140; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize141; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize142; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize143; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize144; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize145; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize146; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize147; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize148; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize149; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize150; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize151; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize152; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize153; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize154; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize155; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize156; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize157; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize158; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize159; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize160; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize161; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize162; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize163; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize164; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize165; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize166; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize167; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize168; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize169; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize170; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize171; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize172; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize173; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize174; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize175; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize176; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize177; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize178; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize179; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize180; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize181; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize182; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize183; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize184; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize185; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize186; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize187; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize188; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize189; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize190; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize191; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize192; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize193; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize194; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize195; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize196; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize197; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize198; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize199; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize200; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize201; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize202; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize203; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize204; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize205; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize206; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize207; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize208; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize209; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize210; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize211; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize212; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize213; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize214; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize215; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize216; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize217; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize218; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize219; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize220; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize221; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize222; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize223; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize224; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize225; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize226; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize227; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize228; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize229; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize230; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize231; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize232; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize233; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize234; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize235; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize236; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize237; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize238; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize239; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize240; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize241; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize242; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize243; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize244; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize245; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize246; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize247; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize248; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize249; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize250; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize251; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize252; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize253; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize254; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize255; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize256; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize257; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize258; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize259; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize260; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize261; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize262; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize263; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize264; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize265; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize266; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize267; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize268; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize269; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize270; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize271; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize272; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize273; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize274; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize275; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize276; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize277; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize278; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize279; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize280; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize281; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize282; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize283; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize284; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize285; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize286; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize287; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize288; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize289; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize290; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize291; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize292; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize293; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize294; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize295; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize296; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize297; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize298; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize299; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize300; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize301; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize302; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize303; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize304; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize305; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize306; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize307; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize308; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize309; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize310; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize311; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize312; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize313; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize314; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize315; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize316; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize317; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize318; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize319; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize320; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize321; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize322; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize323; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize324; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize325; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize326; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize327; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize328; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize329; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize330; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize331; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize332; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize333; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize334; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize335; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize336; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize337; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize338; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize339; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize340; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize341; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize342; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize343; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize344; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize345; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize346; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize347; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize348; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize349; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize350; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize351; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize352; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize353; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize354; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize355; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize356; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize357; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize358; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize359; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize360; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize361; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize362; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize363; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize364; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize365; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize366; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize367; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize368; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize369; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize370; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize371; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize372; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize373; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize374; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize375; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize376; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize377; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize378; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize379; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize380; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize381; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize382; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize383; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize384; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize385; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize386; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize387; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize388; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize389; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize390; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize391; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize392; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize393; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize394; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize395; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize396; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize397; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize398; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize399; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize400; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize401; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize402; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize403; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize404; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize405; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize406; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize407; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize408; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize409; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize410; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize411; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize412; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize413; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize414; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize415; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize416; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize417; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize418; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize419; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize420; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize421; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize422; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize423; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize424; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize425; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize426; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize427; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize428; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize429; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize430; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize431; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize432; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize433; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize434; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize435; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize436; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize437; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize438; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize439; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize440; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize441; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize442; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize443; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize444; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize445; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize446; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize447; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize448; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize449; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize450; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize451; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize452; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize453; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize454; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize455; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize456; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize457; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize458; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize459; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize460; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize461; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize462; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize463; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize464; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize465; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize466; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize467; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize468; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize469; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize470; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize471; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize472; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize473; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize474; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize475; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize476; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize477; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize478; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize479; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize480; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize481; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize482; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize483; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize484; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize485; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize486; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize487; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize488; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize489; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize490; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize491; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize492; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize493; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize494; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize495; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize496; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize497; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize498; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize499; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize500; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize501; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize502; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize503; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize504; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize505; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize506; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize507; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize508; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize509; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize510; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize511; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize512; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize513; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize514; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize515; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize516; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize517; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize518; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize519; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize520; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize521; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize522; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize523; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize524; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize525; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize526; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize527; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize528; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize529; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize530; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize531; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize532; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize533; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize534; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize535; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize536; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize537; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize538; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize539; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize540; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize541; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize542; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize543; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize544; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize545; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize546; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize547; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize548; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize549; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize550; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize551; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize552; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize553; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize554; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize555; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize556; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize557; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize558; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize559; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize560; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize561; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize562; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize563; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize564; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize565; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize566; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize567; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize568; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize569; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize570; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize571; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize572; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize573; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize574; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize575; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize576; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize577; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize578; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize579; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize580; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize581; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize582; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize583; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize584; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize585; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize586; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize587; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize588; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize589; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize590; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize591; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize592; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize593; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize594; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize595; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize596; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize597; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize598; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize599; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize600; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize601; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize602; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize603; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize604; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize605; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize606; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize607; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize608; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize609; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize610; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize611; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize612; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize613; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize614; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize615; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize616; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize617; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize618; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize619; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize620; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize621; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize622; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize623; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize624; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize625; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize626; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize627; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize628; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize629; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize630; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize631; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize632; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize633; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize634; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize635; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize636; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize637; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize638; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize639; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize640; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize641; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize642; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize643; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize644; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize645; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize646; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize647; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize648; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize649; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize650; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize651; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize652; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize653; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize654; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize655; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize656; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize657; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize658; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize659; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize660; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize661; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize662; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize663; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize664; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize665; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize666; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize667; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize668; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize669; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize670; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize671; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize672; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize673; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize674; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize675; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize676; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize677; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize678; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize679; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize680; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize681; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize682; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize683; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize684; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize685; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize686; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize687; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize688; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize689; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize690; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize691; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize692; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize693; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize694; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize695; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize696; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize697; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize698; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize699; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize700; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize701; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize702; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize703; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize704; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize705; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize706; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize707; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize708; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize709; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize710; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize711; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize712; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize713; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize714; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize715; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize716; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize717; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize718; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize719; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize720; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize721; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize722; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize723; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize724; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize725; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize726; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize727; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize728; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize729; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize730; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize731; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize732; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize733; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize734; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize735; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize736; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize737; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize738; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize739; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize740; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize741; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize742; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize743; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize744; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize745; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize746; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize747; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize748; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize749; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize750; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize751; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize752; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize753; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize754; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize755; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize756; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize757; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize758; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize759; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize760; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize761; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize762; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize763; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize764; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize765; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize766; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize767; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize768; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize769; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize770; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize771; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize772; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize773; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize774; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize775; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize776; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize777; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize778; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize779; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize780; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize781; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize782; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize783; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize784; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize785; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize786; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize787; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize788; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize789; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize790; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize791; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize792; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize793; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize794; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize795; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize796; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize797; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize798; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize799; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize800; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize801; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize802; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize803; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize804; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize805; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize806; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize807; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize808; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize809; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize810; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize811; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize812; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize813; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize814; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize815; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize816; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize817; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize818; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize819; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize820; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize821; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize822; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize823; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize824; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize825; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize826; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize827; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize828; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize829; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize830; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize831; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize832; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize833; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize834; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize835; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize836; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize837; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize838; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize839; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize840; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize841; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize842; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize843; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize844; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize845; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize846; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize847; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize848; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize849; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize850; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize851; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize852; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize853; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize854; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize855; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize856; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize857; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize858; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize859; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize860; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize861; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize862; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize863; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize864; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize865; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize866; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize867; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize868; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize869; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize870; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize871; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize872; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize873; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize874; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize875; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize876; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize877; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize878; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize879; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize880; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize881; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize882; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize883; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize884; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize885; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize886; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize887; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize888; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize889; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize890; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize891; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize892; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize893; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize894; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize895; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize896; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize897; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize898; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize899; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize900; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize901; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize902; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize903; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize904; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize905; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize906; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize907; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize908; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize909; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize910; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize911; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize912; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize913; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize914; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize915; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize916; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize917; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize918; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize919; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize920; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize921; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize922; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize923; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize924; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize925; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize926; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize927; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize928; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize929; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize930; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize931; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize932; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize933; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize934; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize935; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize936; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize937; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize938; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize939; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize940; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize941; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize942; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize943; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize944; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize945; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize946; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize947; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize948; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize949; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize950; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize951; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize952; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize953; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize954; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize955; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize956; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize957; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize958; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize959; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize960; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize961; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize962; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize963; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize964; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize965; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize966; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize967; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize968; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize969; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize970; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize971; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize972; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize973; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize974; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize975; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize976; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize977; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize978; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize979; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize980; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize981; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize982; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize983; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize984; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize985; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize986; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize987; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize988; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize989; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize990; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize991; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize992; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize993; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize994; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize995; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize996; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize997; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize998; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize999; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1000; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1001; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1002; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1003; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1004; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1005; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1006; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1007; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1008; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1009; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1010; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1011; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1012; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1013; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1014; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1015; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1016; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1017; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1018; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1019; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1020; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1021; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1022; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1023; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1024; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1025; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1026; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1027; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1028; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1029; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1030; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1031; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1032; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1033; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1034; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1035; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1036; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1037; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1038; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1039; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1040; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1041; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1042; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1043; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1044; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1045; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1046; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1047; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1048; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1049; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1050; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1051; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1052; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1053; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1054; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1055; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1056; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1057; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1058; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1059; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1060; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1061; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1062; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1063; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1064; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1065; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1066; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1067; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1068; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1069; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1070; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1071; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1072; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1073; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1074; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1075; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1076; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1077; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1078; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1079; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1080; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1081; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1082; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1083; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1084; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1085; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1086; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1087; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1088; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1089; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1090; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1091; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1092; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1093; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1094; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1095; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1096; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1097; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1098; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1099; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1100; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1101; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1102; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1103; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1104; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1105; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1106; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1107; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1108; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1109; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1110; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1111; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1112; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1113; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1114; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1115; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1116; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1117; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1118; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1119; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1120; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1121; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1122; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1123; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1124; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1125; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1126; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1127; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1128; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1129; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1130; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1131; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1132; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1133; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1134; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1135; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1136; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1137; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1138; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1139; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1140; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1141; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1142; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1143; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1144; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1145; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1146; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1147; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1148; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1149; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1150; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1151; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1152; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1153; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1154; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1155; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1156; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1157; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1158; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1159; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1160; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1161; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1162; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1163; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1164; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1165; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1166; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1167; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1168; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1169; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1170; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1171; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1172; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1173; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1174; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1175; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1176; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1177; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1178; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1179; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1180; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1181; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1182; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1183; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1184; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1185; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1186; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1187; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1188; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1189; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1190; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1191; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1192; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1193; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1194; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1195; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1196; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1197; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1198; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1199; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1200; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1201; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1202; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1203; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1204; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1205; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1206; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1207; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1208; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1209; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1210; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1211; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1212; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1213; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1214; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1215; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1216; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1217; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1218; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1219; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1220; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1221; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1222; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1223; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1224; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1225; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1226; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1227; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1228; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1229; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1230; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1231; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1232; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1233; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1234; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1235; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1236; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1237; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1238; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1239; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1240; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1241; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1242; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1243; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1244; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1245; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1246; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1247; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1248; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1249; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1250; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1251; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1252; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1253; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1254; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1255; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1256; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1257; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1258; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1259; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1260; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1261; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1262; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1263; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1264; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1265; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1266; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1267; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1268; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1269; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1270; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1271; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1272; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1273; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1274; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1275; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1276; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1277; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1278; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1279; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1280; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1281; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1282; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1283; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1284; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1285; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1286; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1287; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1288; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1289; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1290; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1291; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1292; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1293; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1294; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1295; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1296; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1297; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1298; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1299; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1300; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1301; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1302; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1303; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1304; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1305; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1306; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1307; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1308; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1309; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1310; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1311; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1312; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1313; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1314; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1315; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1316; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1317; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1318; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1319; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1320; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1321; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1322; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1323; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1324; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1325; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1326; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1327; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1328; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1329; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1330; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1331; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1332; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1333; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1334; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1335; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1336; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1337; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1338; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1339; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1340; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1341; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1342; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1343; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1344; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1345; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1346; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1347; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1348; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1349; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1350; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1351; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1352; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1353; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1354; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1355; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1356; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1357; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1358; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1359; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1360; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1361; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1362; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1363; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1364; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1365; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1366; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1367; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1368; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1369; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1370; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1371; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1372; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1373; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1374; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1375; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1376; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1377; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1378; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1379; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1380; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1381; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1382; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1383; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1384; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1385; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1386; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1387; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1388; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1389; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1390; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1391; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1392; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1393; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1394; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1395; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1396; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1397; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1398; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1399; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1400; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1401; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1402; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1403; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1404; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1405; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1406; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1407; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1408; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1409; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1410; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1411; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1412; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1413; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1414; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1415; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1416; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1417; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1418; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1419; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1420; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1421; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1422; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1423; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1424; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1425; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1426; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1427; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1428; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1429; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1430; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1431; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1432; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1433; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1434; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1435; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1436; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1437; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1438; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1439; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1440; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1441; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1442; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1443; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1444; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1445; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1446; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1447; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1448; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1449; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1450; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1451; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1452; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1453; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1454; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1455; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1456; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1457; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1458; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1459; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1460; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1461; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1462; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1463; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1464; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1465; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1466; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1467; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1468; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1469; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1470; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1471; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1472; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1473; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1474; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1475; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1476; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1477; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1478; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1479; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1480; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1481; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1482; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1483; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1484; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1485; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1486; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1487; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1488; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1489; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1490; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1491; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1492; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1493; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1494; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1495; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1496; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1497; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1498; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1499; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1500; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1501; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1502; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1503; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1504; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1505; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1506; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1507; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1508; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1509; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1510; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1511; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1512; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1513; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1514; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1515; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1516; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1517; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1518; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1519; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1520; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1521; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1522; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1523; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1524; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1525; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1526; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1527; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1528; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1529; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1530; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1531; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1532; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1533; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1534; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1535; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1536; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1537; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1538; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1539; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1540; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1541; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1542; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1543; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1544; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1545; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1546; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1547; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1548; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1549; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1550; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1551; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1552; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1553; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1554; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1555; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1556; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1557; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1558; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1559; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1560; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1561; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1562; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1563; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1564; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1565; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1566; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1567; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1568; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1569; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1570; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1571; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1572; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1573; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1574; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1575; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1576; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1577; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1578; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1579; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1580; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1581; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1582; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1583; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1584; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1585; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1586; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1587; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1588; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1589; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1590; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1591; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1592; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1593; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1594; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1595; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1596; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1597; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1598; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1599; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1600; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1601; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1602; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1603; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1604; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1605; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1606; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1607; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1608; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1609; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1610; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1611; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1612; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1613; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1614; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1615; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1616; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1617; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1618; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1619; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1620; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1621; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1622; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1623; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1624; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1625; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1626; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1627; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1628; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1629; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1630; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1631; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1632; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1633; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1634; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1635; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1636; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1637; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1638; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1639; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1640; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1641; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1642; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1643; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1644; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1645; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1646; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1647; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1648; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1649; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1650; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1651; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1652; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1653; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1654; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1655; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1656; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1657; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1658; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1659; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1660; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1661; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1662; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1663; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1664; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1665; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1666; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1667; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1668; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1669; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1670; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1671; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1672; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1673; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1674; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1675; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1676; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1677; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1678; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1679; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1680; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1681; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1682; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1683; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1684; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1685; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1686; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1687; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1688; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1689; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1690; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1691; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1692; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1693; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1694; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1695; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1696; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1697; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1698; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1699; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1700; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1701; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1702; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1703; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1704; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1705; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1706; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1707; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1708; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1709; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1710; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1711; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1712; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1713; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1714; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1715; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1716; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1717; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1718; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1719; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1720; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1721; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1722; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1723; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1724; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1725; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1726; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1727; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1728; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1729; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1730; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1731; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1732; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1733; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1734; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1735; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1736; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1737; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1738; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1739; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1740; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1741; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1742; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1743; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1744; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1745; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1746; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1747; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1748; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1749; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1750; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1751; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1752; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1753; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1754; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1755; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1756; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1757; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1758; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1759; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1760; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1761; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1762; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1763; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1764; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1765; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1766; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1767; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1768; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1769; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1770; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1771; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1772; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1773; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1774; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1775; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1776; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1777; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1778; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1779; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1780; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1781; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1782; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1783; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1784; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1785; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1786; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1787; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1788; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1789; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1790; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1791; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1792; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1793; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1794; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1795; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1796; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1797; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1798; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1799; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1800; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1801; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1802; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1803; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1804; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1805; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1806; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1807; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1808; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1809; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1810; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1811; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1812; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1813; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1814; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1815; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1816; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1817; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1818; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1819; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1820; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1821; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1822; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1823; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1824; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1825; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1826; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1827; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1828; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1829; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1830; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1831; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1832; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1833; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1834; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1835; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1836; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1837; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1838; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1839; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1840; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1841; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1842; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1843; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1844; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1845; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1846; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1847; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1848; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1849; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1850; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1851; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1852; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1853; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1854; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1855; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1856; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1857; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1858; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1859; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1860; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1861; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1862; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1863; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1864; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1865; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1866; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1867; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1868; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1869; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1870; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1871; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1872; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1873; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1874; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1875; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1876; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1877; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1878; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1879; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1880; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1881; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1882; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1883; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1884; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1885; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1886; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1887; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1888; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1889; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1890; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1891; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1892; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1893; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1894; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1895; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1896; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1897; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1898; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1899; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1900; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1901; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1902; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1903; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1904; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1905; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1906; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1907; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1908; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1909; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1910; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1911; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1912; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1913; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1914; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1915; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1916; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1917; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1918; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1919; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1920; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1921; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1922; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1923; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1924; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1925; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1926; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1927; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1928; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1929; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1930; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1931; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1932; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1933; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1934; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1935; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1936; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1937; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1938; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1939; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1940; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1941; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1942; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1943; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1944; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1945; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1946; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1947; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1948; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1949; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1950; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1951; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1952; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1953; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1954; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1955; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1956; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1957; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1958; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1959; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1960; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1961; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1962; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1963; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1964; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1965; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1966; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1967; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1968; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1969; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1970; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1971; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1972; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1973; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1974; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1975; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1976; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1977; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1978; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1979; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1980; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1981; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1982; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1983; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1984; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1985; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1986; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1987; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1988; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1989; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1990; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1991; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1992; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1993; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1994; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1995; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1996; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1997; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1998; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize1999; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2000; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2001; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2002; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2003; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2004; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2005; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2006; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2007; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2008; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2009; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2010; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2011; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2012; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2013; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2014; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2015; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2016; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2017; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2018; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2019; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2020; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2021; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2022; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2023; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2024; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2025; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2026; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2027; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2028; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2029; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2030; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2031; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2032; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2033; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2034; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2035; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2036; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2037; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2038; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2039; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2040; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2041; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2042; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2043; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2044; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2045; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2046; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2047; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2048; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2049; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2050; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2051; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2052; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2053; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2054; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2055; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2056; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2057; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2058; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2059; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2060; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2061; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2062; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2063; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2064; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2065; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2066; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2067; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2068; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2069; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2070; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2071; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2072; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2073; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2074; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2075; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2076; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2077; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2078; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2079; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2080; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2081; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2082; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2083; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2084; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2085; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2086; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2087; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2088; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2089; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2090; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2091; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2092; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2093; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2094; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2095; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2096; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2097; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2098; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2099; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2100; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2101; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2102; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2103; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2104; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2105; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2106; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2107; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2108; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2109; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2110; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2111; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2112; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2113; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2114; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2115; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2116; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2117; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2118; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2119; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2120; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2121; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2122; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2123; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2124; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2125; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2126; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2127; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2128; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2129; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2130; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2131; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2132; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2133; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2134; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2135; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2136; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2137; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2138; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2139; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2140; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2141; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2142; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2143; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2144; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2145; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2146; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2147; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2148; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2149; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2150; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2151; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2152; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2153; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2154; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2155; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2156; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2157; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2158; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2159; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2160; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2161; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2162; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2163; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2164; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2165; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2166; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2167; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2168; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2169; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2170; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2171; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2172; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2173; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2174; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2175; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2176; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2177; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2178; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2179; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2180; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2181; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2182; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2183; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2184; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2185; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2186; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2187; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2188; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2189; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2190; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2191; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2192; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2193; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2194; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2195; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2196; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2197; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2198; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2199; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2200; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2201; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2202; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2203; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2204; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2205; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2206; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2207; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2208; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2209; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2210; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2211; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2212; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2213; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2214; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2215; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2216; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2217; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2218; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2219; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2220; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2221; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2222; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2223; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2224; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2225; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2226; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2227; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2228; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2229; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2230; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2231; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2232; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2233; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2234; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2235; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2236; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2237; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2238; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2239; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2240; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2241; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2242; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2243; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2244; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2245; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2246; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2247; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2248; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2249; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2250; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2251; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2252; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2253; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2254; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2255; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2256; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2257; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2258; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2259; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2260; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2261; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2262; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2263; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2264; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2265; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2266; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2267; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2268; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2269; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2270; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2271; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2272; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2273; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2274; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2275; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2276; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2277; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2278; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2279; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2280; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2281; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2282; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2283; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2284; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2285; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2286; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2287; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2288; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2289; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2290; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2291; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2292; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2293; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2294; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2295; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2296; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2297; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2298; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2299; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2300; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2301; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2302; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2303; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2304; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2305; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2306; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2307; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2308; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2309; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2310; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2311; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2312; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2313; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2314; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2315; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2316; extern const Il2CppTypeDefinitionSizes g_typeDefinitionSize2317; extern const Il2CppTypeDefinitionSizes* g_Il2CppTypeDefinitionSizesTable[2318] = { (&g_typeDefinitionSize0), (&g_typeDefinitionSize1), (&g_typeDefinitionSize2), (&g_typeDefinitionSize3), (&g_typeDefinitionSize4), (&g_typeDefinitionSize5), (&g_typeDefinitionSize6), (&g_typeDefinitionSize7), (&g_typeDefinitionSize8), (&g_typeDefinitionSize9), (&g_typeDefinitionSize10), (&g_typeDefinitionSize11), (&g_typeDefinitionSize12), (&g_typeDefinitionSize13), (&g_typeDefinitionSize14), (&g_typeDefinitionSize15), (&g_typeDefinitionSize16), (&g_typeDefinitionSize17), (&g_typeDefinitionSize18), (&g_typeDefinitionSize19), (&g_typeDefinitionSize20), (&g_typeDefinitionSize21), (&g_typeDefinitionSize22), (&g_typeDefinitionSize23), (&g_typeDefinitionSize24), (&g_typeDefinitionSize25), (&g_typeDefinitionSize26), (&g_typeDefinitionSize27), (&g_typeDefinitionSize28), (&g_typeDefinitionSize29), (&g_typeDefinitionSize30), (&g_typeDefinitionSize31), (&g_typeDefinitionSize32), (&g_typeDefinitionSize33), (&g_typeDefinitionSize34), (&g_typeDefinitionSize35), (&g_typeDefinitionSize36), (&g_typeDefinitionSize37), (&g_typeDefinitionSize38), (&g_typeDefinitionSize39), (&g_typeDefinitionSize40), (&g_typeDefinitionSize41), (&g_typeDefinitionSize42), (&g_typeDefinitionSize43), (&g_typeDefinitionSize44), (&g_typeDefinitionSize45), (&g_typeDefinitionSize46), (&g_typeDefinitionSize47), (&g_typeDefinitionSize48), (&g_typeDefinitionSize49), (&g_typeDefinitionSize50), (&g_typeDefinitionSize51), (&g_typeDefinitionSize52), (&g_typeDefinitionSize53), (&g_typeDefinitionSize54), (&g_typeDefinitionSize55), (&g_typeDefinitionSize56), (&g_typeDefinitionSize57), (&g_typeDefinitionSize58), (&g_typeDefinitionSize59), (&g_typeDefinitionSize60), (&g_typeDefinitionSize61), (&g_typeDefinitionSize62), (&g_typeDefinitionSize63), (&g_typeDefinitionSize64), (&g_typeDefinitionSize65), (&g_typeDefinitionSize66), (&g_typeDefinitionSize67), (&g_typeDefinitionSize68), (&g_typeDefinitionSize69), (&g_typeDefinitionSize70), (&g_typeDefinitionSize71), (&g_typeDefinitionSize72), (&g_typeDefinitionSize73), (&g_typeDefinitionSize74), (&g_typeDefinitionSize75), (&g_typeDefinitionSize76), (&g_typeDefinitionSize77), (&g_typeDefinitionSize78), (&g_typeDefinitionSize79), (&g_typeDefinitionSize80), (&g_typeDefinitionSize81), (&g_typeDefinitionSize82), (&g_typeDefinitionSize83), (&g_typeDefinitionSize84), (&g_typeDefinitionSize85), (&g_typeDefinitionSize86), (&g_typeDefinitionSize87), (&g_typeDefinitionSize88), (&g_typeDefinitionSize89), (&g_typeDefinitionSize90), (&g_typeDefinitionSize91), (&g_typeDefinitionSize92), (&g_typeDefinitionSize93), (&g_typeDefinitionSize94), (&g_typeDefinitionSize95), (&g_typeDefinitionSize96), (&g_typeDefinitionSize97), (&g_typeDefinitionSize98), (&g_typeDefinitionSize99), (&g_typeDefinitionSize100), (&g_typeDefinitionSize101), (&g_typeDefinitionSize102), (&g_typeDefinitionSize103), (&g_typeDefinitionSize104), (&g_typeDefinitionSize105), (&g_typeDefinitionSize106), (&g_typeDefinitionSize107), (&g_typeDefinitionSize108), (&g_typeDefinitionSize109), (&g_typeDefinitionSize110), (&g_typeDefinitionSize111), (&g_typeDefinitionSize112), (&g_typeDefinitionSize113), (&g_typeDefinitionSize114), (&g_typeDefinitionSize115), (&g_typeDefinitionSize116), (&g_typeDefinitionSize117), (&g_typeDefinitionSize118), (&g_typeDefinitionSize119), (&g_typeDefinitionSize120), (&g_typeDefinitionSize121), (&g_typeDefinitionSize122), (&g_typeDefinitionSize123), (&g_typeDefinitionSize124), (&g_typeDefinitionSize125), (&g_typeDefinitionSize126), (&g_typeDefinitionSize127), (&g_typeDefinitionSize128), (&g_typeDefinitionSize129), (&g_typeDefinitionSize130), (&g_typeDefinitionSize131), (&g_typeDefinitionSize132), (&g_typeDefinitionSize133), (&g_typeDefinitionSize134), (&g_typeDefinitionSize135), (&g_typeDefinitionSize136), (&g_typeDefinitionSize137), (&g_typeDefinitionSize138), (&g_typeDefinitionSize139), (&g_typeDefinitionSize140), (&g_typeDefinitionSize141), (&g_typeDefinitionSize142), (&g_typeDefinitionSize143), (&g_typeDefinitionSize144), (&g_typeDefinitionSize145), (&g_typeDefinitionSize146), (&g_typeDefinitionSize147), (&g_typeDefinitionSize148), (&g_typeDefinitionSize149), (&g_typeDefinitionSize150), (&g_typeDefinitionSize151), (&g_typeDefinitionSize152), (&g_typeDefinitionSize153), (&g_typeDefinitionSize154), (&g_typeDefinitionSize155), (&g_typeDefinitionSize156), (&g_typeDefinitionSize157), (&g_typeDefinitionSize158), (&g_typeDefinitionSize159), (&g_typeDefinitionSize160), (&g_typeDefinitionSize161), (&g_typeDefinitionSize162), (&g_typeDefinitionSize163), (&g_typeDefinitionSize164), (&g_typeDefinitionSize165), (&g_typeDefinitionSize166), (&g_typeDefinitionSize167), (&g_typeDefinitionSize168), (&g_typeDefinitionSize169), (&g_typeDefinitionSize170), (&g_typeDefinitionSize171), (&g_typeDefinitionSize172), (&g_typeDefinitionSize173), (&g_typeDefinitionSize174), (&g_typeDefinitionSize175), (&g_typeDefinitionSize176), (&g_typeDefinitionSize177), (&g_typeDefinitionSize178), (&g_typeDefinitionSize179), (&g_typeDefinitionSize180), (&g_typeDefinitionSize181), (&g_typeDefinitionSize182), (&g_typeDefinitionSize183), (&g_typeDefinitionSize184), (&g_typeDefinitionSize185), (&g_typeDefinitionSize186), (&g_typeDefinitionSize187), (&g_typeDefinitionSize188), (&g_typeDefinitionSize189), (&g_typeDefinitionSize190), (&g_typeDefinitionSize191), (&g_typeDefinitionSize192), (&g_typeDefinitionSize193), (&g_typeDefinitionSize194), (&g_typeDefinitionSize195), (&g_typeDefinitionSize196), (&g_typeDefinitionSize197), (&g_typeDefinitionSize198), (&g_typeDefinitionSize199), (&g_typeDefinitionSize200), (&g_typeDefinitionSize201), (&g_typeDefinitionSize202), (&g_typeDefinitionSize203), (&g_typeDefinitionSize204), (&g_typeDefinitionSize205), (&g_typeDefinitionSize206), (&g_typeDefinitionSize207), (&g_typeDefinitionSize208), (&g_typeDefinitionSize209), (&g_typeDefinitionSize210), (&g_typeDefinitionSize211), (&g_typeDefinitionSize212), (&g_typeDefinitionSize213), (&g_typeDefinitionSize214), (&g_typeDefinitionSize215), (&g_typeDefinitionSize216), (&g_typeDefinitionSize217), (&g_typeDefinitionSize218), (&g_typeDefinitionSize219), (&g_typeDefinitionSize220), (&g_typeDefinitionSize221), (&g_typeDefinitionSize222), (&g_typeDefinitionSize223), (&g_typeDefinitionSize224), (&g_typeDefinitionSize225), (&g_typeDefinitionSize226), (&g_typeDefinitionSize227), (&g_typeDefinitionSize228), (&g_typeDefinitionSize229), (&g_typeDefinitionSize230), (&g_typeDefinitionSize231), (&g_typeDefinitionSize232), (&g_typeDefinitionSize233), (&g_typeDefinitionSize234), (&g_typeDefinitionSize235), (&g_typeDefinitionSize236), (&g_typeDefinitionSize237), (&g_typeDefinitionSize238), (&g_typeDefinitionSize239), (&g_typeDefinitionSize240), (&g_typeDefinitionSize241), (&g_typeDefinitionSize242), (&g_typeDefinitionSize243), (&g_typeDefinitionSize244), (&g_typeDefinitionSize245), (&g_typeDefinitionSize246), (&g_typeDefinitionSize247), (&g_typeDefinitionSize248), (&g_typeDefinitionSize249), (&g_typeDefinitionSize250), (&g_typeDefinitionSize251), (&g_typeDefinitionSize252), (&g_typeDefinitionSize253), (&g_typeDefinitionSize254), (&g_typeDefinitionSize255), (&g_typeDefinitionSize256), (&g_typeDefinitionSize257), (&g_typeDefinitionSize258), (&g_typeDefinitionSize259), (&g_typeDefinitionSize260), (&g_typeDefinitionSize261), (&g_typeDefinitionSize262), (&g_typeDefinitionSize263), (&g_typeDefinitionSize264), (&g_typeDefinitionSize265), (&g_typeDefinitionSize266), (&g_typeDefinitionSize267), (&g_typeDefinitionSize268), (&g_typeDefinitionSize269), (&g_typeDefinitionSize270), (&g_typeDefinitionSize271), (&g_typeDefinitionSize272), (&g_typeDefinitionSize273), (&g_typeDefinitionSize274), (&g_typeDefinitionSize275), (&g_typeDefinitionSize276), (&g_typeDefinitionSize277), (&g_typeDefinitionSize278), (&g_typeDefinitionSize279), (&g_typeDefinitionSize280), (&g_typeDefinitionSize281), (&g_typeDefinitionSize282), (&g_typeDefinitionSize283), (&g_typeDefinitionSize284), (&g_typeDefinitionSize285), (&g_typeDefinitionSize286), (&g_typeDefinitionSize287), (&g_typeDefinitionSize288), (&g_typeDefinitionSize289), (&g_typeDefinitionSize290), (&g_typeDefinitionSize291), (&g_typeDefinitionSize292), (&g_typeDefinitionSize293), (&g_typeDefinitionSize294), (&g_typeDefinitionSize295), (&g_typeDefinitionSize296), (&g_typeDefinitionSize297), (&g_typeDefinitionSize298), (&g_typeDefinitionSize299), (&g_typeDefinitionSize300), (&g_typeDefinitionSize301), (&g_typeDefinitionSize302), (&g_typeDefinitionSize303), (&g_typeDefinitionSize304), (&g_typeDefinitionSize305), (&g_typeDefinitionSize306), (&g_typeDefinitionSize307), (&g_typeDefinitionSize308), (&g_typeDefinitionSize309), (&g_typeDefinitionSize310), (&g_typeDefinitionSize311), (&g_typeDefinitionSize312), (&g_typeDefinitionSize313), (&g_typeDefinitionSize314), (&g_typeDefinitionSize315), (&g_typeDefinitionSize316), (&g_typeDefinitionSize317), (&g_typeDefinitionSize318), (&g_typeDefinitionSize319), (&g_typeDefinitionSize320), (&g_typeDefinitionSize321), (&g_typeDefinitionSize322), (&g_typeDefinitionSize323), (&g_typeDefinitionSize324), (&g_typeDefinitionSize325), (&g_typeDefinitionSize326), (&g_typeDefinitionSize327), (&g_typeDefinitionSize328), (&g_typeDefinitionSize329), (&g_typeDefinitionSize330), (&g_typeDefinitionSize331), (&g_typeDefinitionSize332), (&g_typeDefinitionSize333), (&g_typeDefinitionSize334), (&g_typeDefinitionSize335), (&g_typeDefinitionSize336), (&g_typeDefinitionSize337), (&g_typeDefinitionSize338), (&g_typeDefinitionSize339), (&g_typeDefinitionSize340), (&g_typeDefinitionSize341), (&g_typeDefinitionSize342), (&g_typeDefinitionSize343), (&g_typeDefinitionSize344), (&g_typeDefinitionSize345), (&g_typeDefinitionSize346), (&g_typeDefinitionSize347), (&g_typeDefinitionSize348), (&g_typeDefinitionSize349), (&g_typeDefinitionSize350), (&g_typeDefinitionSize351), (&g_typeDefinitionSize352), (&g_typeDefinitionSize353), (&g_typeDefinitionSize354), (&g_typeDefinitionSize355), (&g_typeDefinitionSize356), (&g_typeDefinitionSize357), (&g_typeDefinitionSize358), (&g_typeDefinitionSize359), (&g_typeDefinitionSize360), (&g_typeDefinitionSize361), (&g_typeDefinitionSize362), (&g_typeDefinitionSize363), (&g_typeDefinitionSize364), (&g_typeDefinitionSize365), (&g_typeDefinitionSize366), (&g_typeDefinitionSize367), (&g_typeDefinitionSize368), (&g_typeDefinitionSize369), (&g_typeDefinitionSize370), (&g_typeDefinitionSize371), (&g_typeDefinitionSize372), (&g_typeDefinitionSize373), (&g_typeDefinitionSize374), (&g_typeDefinitionSize375), (&g_typeDefinitionSize376), (&g_typeDefinitionSize377), (&g_typeDefinitionSize378), (&g_typeDefinitionSize379), (&g_typeDefinitionSize380), (&g_typeDefinitionSize381), (&g_typeDefinitionSize382), (&g_typeDefinitionSize383), (&g_typeDefinitionSize384), (&g_typeDefinitionSize385), (&g_typeDefinitionSize386), (&g_typeDefinitionSize387), (&g_typeDefinitionSize388), (&g_typeDefinitionSize389), (&g_typeDefinitionSize390), (&g_typeDefinitionSize391), (&g_typeDefinitionSize392), (&g_typeDefinitionSize393), (&g_typeDefinitionSize394), (&g_typeDefinitionSize395), (&g_typeDefinitionSize396), (&g_typeDefinitionSize397), (&g_typeDefinitionSize398), (&g_typeDefinitionSize399), (&g_typeDefinitionSize400), (&g_typeDefinitionSize401), (&g_typeDefinitionSize402), (&g_typeDefinitionSize403), (&g_typeDefinitionSize404), (&g_typeDefinitionSize405), (&g_typeDefinitionSize406), (&g_typeDefinitionSize407), (&g_typeDefinitionSize408), (&g_typeDefinitionSize409), (&g_typeDefinitionSize410), (&g_typeDefinitionSize411), (&g_typeDefinitionSize412), (&g_typeDefinitionSize413), (&g_typeDefinitionSize414), (&g_typeDefinitionSize415), (&g_typeDefinitionSize416), (&g_typeDefinitionSize417), (&g_typeDefinitionSize418), (&g_typeDefinitionSize419), (&g_typeDefinitionSize420), (&g_typeDefinitionSize421), (&g_typeDefinitionSize422), (&g_typeDefinitionSize423), (&g_typeDefinitionSize424), (&g_typeDefinitionSize425), (&g_typeDefinitionSize426), (&g_typeDefinitionSize427), (&g_typeDefinitionSize428), (&g_typeDefinitionSize429), (&g_typeDefinitionSize430), (&g_typeDefinitionSize431), (&g_typeDefinitionSize432), (&g_typeDefinitionSize433), (&g_typeDefinitionSize434), (&g_typeDefinitionSize435), (&g_typeDefinitionSize436), (&g_typeDefinitionSize437), (&g_typeDefinitionSize438), (&g_typeDefinitionSize439), (&g_typeDefinitionSize440), (&g_typeDefinitionSize441), (&g_typeDefinitionSize442), (&g_typeDefinitionSize443), (&g_typeDefinitionSize444), (&g_typeDefinitionSize445), (&g_typeDefinitionSize446), (&g_typeDefinitionSize447), (&g_typeDefinitionSize448), (&g_typeDefinitionSize449), (&g_typeDefinitionSize450), (&g_typeDefinitionSize451), (&g_typeDefinitionSize452), (&g_typeDefinitionSize453), (&g_typeDefinitionSize454), (&g_typeDefinitionSize455), (&g_typeDefinitionSize456), (&g_typeDefinitionSize457), (&g_typeDefinitionSize458), (&g_typeDefinitionSize459), (&g_typeDefinitionSize460), (&g_typeDefinitionSize461), (&g_typeDefinitionSize462), (&g_typeDefinitionSize463), (&g_typeDefinitionSize464), (&g_typeDefinitionSize465), (&g_typeDefinitionSize466), (&g_typeDefinitionSize467), (&g_typeDefinitionSize468), (&g_typeDefinitionSize469), (&g_typeDefinitionSize470), (&g_typeDefinitionSize471), (&g_typeDefinitionSize472), (&g_typeDefinitionSize473), (&g_typeDefinitionSize474), (&g_typeDefinitionSize475), (&g_typeDefinitionSize476), (&g_typeDefinitionSize477), (&g_typeDefinitionSize478), (&g_typeDefinitionSize479), (&g_typeDefinitionSize480), (&g_typeDefinitionSize481), (&g_typeDefinitionSize482), (&g_typeDefinitionSize483), (&g_typeDefinitionSize484), (&g_typeDefinitionSize485), (&g_typeDefinitionSize486), (&g_typeDefinitionSize487), (&g_typeDefinitionSize488), (&g_typeDefinitionSize489), (&g_typeDefinitionSize490), (&g_typeDefinitionSize491), (&g_typeDefinitionSize492), (&g_typeDefinitionSize493), (&g_typeDefinitionSize494), (&g_typeDefinitionSize495), (&g_typeDefinitionSize496), (&g_typeDefinitionSize497), (&g_typeDefinitionSize498), (&g_typeDefinitionSize499), (&g_typeDefinitionSize500), (&g_typeDefinitionSize501), (&g_typeDefinitionSize502), (&g_typeDefinitionSize503), (&g_typeDefinitionSize504), (&g_typeDefinitionSize505), (&g_typeDefinitionSize506), (&g_typeDefinitionSize507), (&g_typeDefinitionSize508), (&g_typeDefinitionSize509), (&g_typeDefinitionSize510), (&g_typeDefinitionSize511), (&g_typeDefinitionSize512), (&g_typeDefinitionSize513), (&g_typeDefinitionSize514), (&g_typeDefinitionSize515), (&g_typeDefinitionSize516), (&g_typeDefinitionSize517), (&g_typeDefinitionSize518), (&g_typeDefinitionSize519), (&g_typeDefinitionSize520), (&g_typeDefinitionSize521), (&g_typeDefinitionSize522), (&g_typeDefinitionSize523), (&g_typeDefinitionSize524), (&g_typeDefinitionSize525), (&g_typeDefinitionSize526), (&g_typeDefinitionSize527), (&g_typeDefinitionSize528), (&g_typeDefinitionSize529), (&g_typeDefinitionSize530), (&g_typeDefinitionSize531), (&g_typeDefinitionSize532), (&g_typeDefinitionSize533), (&g_typeDefinitionSize534), (&g_typeDefinitionSize535), (&g_typeDefinitionSize536), (&g_typeDefinitionSize537), (&g_typeDefinitionSize538), (&g_typeDefinitionSize539), (&g_typeDefinitionSize540), (&g_typeDefinitionSize541), (&g_typeDefinitionSize542), (&g_typeDefinitionSize543), (&g_typeDefinitionSize544), (&g_typeDefinitionSize545), (&g_typeDefinitionSize546), (&g_typeDefinitionSize547), (&g_typeDefinitionSize548), (&g_typeDefinitionSize549), (&g_typeDefinitionSize550), (&g_typeDefinitionSize551), (&g_typeDefinitionSize552), (&g_typeDefinitionSize553), (&g_typeDefinitionSize554), (&g_typeDefinitionSize555), (&g_typeDefinitionSize556), (&g_typeDefinitionSize557), (&g_typeDefinitionSize558), (&g_typeDefinitionSize559), (&g_typeDefinitionSize560), (&g_typeDefinitionSize561), (&g_typeDefinitionSize562), (&g_typeDefinitionSize563), (&g_typeDefinitionSize564), (&g_typeDefinitionSize565), (&g_typeDefinitionSize566), (&g_typeDefinitionSize567), (&g_typeDefinitionSize568), (&g_typeDefinitionSize569), (&g_typeDefinitionSize570), (&g_typeDefinitionSize571), (&g_typeDefinitionSize572), (&g_typeDefinitionSize573), (&g_typeDefinitionSize574), (&g_typeDefinitionSize575), (&g_typeDefinitionSize576), (&g_typeDefinitionSize577), (&g_typeDefinitionSize578), (&g_typeDefinitionSize579), (&g_typeDefinitionSize580), (&g_typeDefinitionSize581), (&g_typeDefinitionSize582), (&g_typeDefinitionSize583), (&g_typeDefinitionSize584), (&g_typeDefinitionSize585), (&g_typeDefinitionSize586), (&g_typeDefinitionSize587), (&g_typeDefinitionSize588), (&g_typeDefinitionSize589), (&g_typeDefinitionSize590), (&g_typeDefinitionSize591), (&g_typeDefinitionSize592), (&g_typeDefinitionSize593), (&g_typeDefinitionSize594), (&g_typeDefinitionSize595), (&g_typeDefinitionSize596), (&g_typeDefinitionSize597), (&g_typeDefinitionSize598), (&g_typeDefinitionSize599), (&g_typeDefinitionSize600), (&g_typeDefinitionSize601), (&g_typeDefinitionSize602), (&g_typeDefinitionSize603), (&g_typeDefinitionSize604), (&g_typeDefinitionSize605), (&g_typeDefinitionSize606), (&g_typeDefinitionSize607), (&g_typeDefinitionSize608), (&g_typeDefinitionSize609), (&g_typeDefinitionSize610), (&g_typeDefinitionSize611), (&g_typeDefinitionSize612), (&g_typeDefinitionSize613), (&g_typeDefinitionSize614), (&g_typeDefinitionSize615), (&g_typeDefinitionSize616), (&g_typeDefinitionSize617), (&g_typeDefinitionSize618), (&g_typeDefinitionSize619), (&g_typeDefinitionSize620), (&g_typeDefinitionSize621), (&g_typeDefinitionSize622), (&g_typeDefinitionSize623), (&g_typeDefinitionSize624), (&g_typeDefinitionSize625), (&g_typeDefinitionSize626), (&g_typeDefinitionSize627), (&g_typeDefinitionSize628), (&g_typeDefinitionSize629), (&g_typeDefinitionSize630), (&g_typeDefinitionSize631), (&g_typeDefinitionSize632), (&g_typeDefinitionSize633), (&g_typeDefinitionSize634), (&g_typeDefinitionSize635), (&g_typeDefinitionSize636), (&g_typeDefinitionSize637), (&g_typeDefinitionSize638), (&g_typeDefinitionSize639), (&g_typeDefinitionSize640), (&g_typeDefinitionSize641), (&g_typeDefinitionSize642), (&g_typeDefinitionSize643), (&g_typeDefinitionSize644), (&g_typeDefinitionSize645), (&g_typeDefinitionSize646), (&g_typeDefinitionSize647), (&g_typeDefinitionSize648), (&g_typeDefinitionSize649), (&g_typeDefinitionSize650), (&g_typeDefinitionSize651), (&g_typeDefinitionSize652), (&g_typeDefinitionSize653), (&g_typeDefinitionSize654), (&g_typeDefinitionSize655), (&g_typeDefinitionSize656), (&g_typeDefinitionSize657), (&g_typeDefinitionSize658), (&g_typeDefinitionSize659), (&g_typeDefinitionSize660), (&g_typeDefinitionSize661), (&g_typeDefinitionSize662), (&g_typeDefinitionSize663), (&g_typeDefinitionSize664), (&g_typeDefinitionSize665), (&g_typeDefinitionSize666), (&g_typeDefinitionSize667), (&g_typeDefinitionSize668), (&g_typeDefinitionSize669), (&g_typeDefinitionSize670), (&g_typeDefinitionSize671), (&g_typeDefinitionSize672), (&g_typeDefinitionSize673), (&g_typeDefinitionSize674), (&g_typeDefinitionSize675), (&g_typeDefinitionSize676), (&g_typeDefinitionSize677), (&g_typeDefinitionSize678), (&g_typeDefinitionSize679), (&g_typeDefinitionSize680), (&g_typeDefinitionSize681), (&g_typeDefinitionSize682), (&g_typeDefinitionSize683), (&g_typeDefinitionSize684), (&g_typeDefinitionSize685), (&g_typeDefinitionSize686), (&g_typeDefinitionSize687), (&g_typeDefinitionSize688), (&g_typeDefinitionSize689), (&g_typeDefinitionSize690), (&g_typeDefinitionSize691), (&g_typeDefinitionSize692), (&g_typeDefinitionSize693), (&g_typeDefinitionSize694), (&g_typeDefinitionSize695), (&g_typeDefinitionSize696), (&g_typeDefinitionSize697), (&g_typeDefinitionSize698), (&g_typeDefinitionSize699), (&g_typeDefinitionSize700), (&g_typeDefinitionSize701), (&g_typeDefinitionSize702), (&g_typeDefinitionSize703), (&g_typeDefinitionSize704), (&g_typeDefinitionSize705), (&g_typeDefinitionSize706), (&g_typeDefinitionSize707), (&g_typeDefinitionSize708), (&g_typeDefinitionSize709), (&g_typeDefinitionSize710), (&g_typeDefinitionSize711), (&g_typeDefinitionSize712), (&g_typeDefinitionSize713), (&g_typeDefinitionSize714), (&g_typeDefinitionSize715), (&g_typeDefinitionSize716), (&g_typeDefinitionSize717), (&g_typeDefinitionSize718), (&g_typeDefinitionSize719), (&g_typeDefinitionSize720), (&g_typeDefinitionSize721), (&g_typeDefinitionSize722), (&g_typeDefinitionSize723), (&g_typeDefinitionSize724), (&g_typeDefinitionSize725), (&g_typeDefinitionSize726), (&g_typeDefinitionSize727), (&g_typeDefinitionSize728), (&g_typeDefinitionSize729), (&g_typeDefinitionSize730), (&g_typeDefinitionSize731), (&g_typeDefinitionSize732), (&g_typeDefinitionSize733), (&g_typeDefinitionSize734), (&g_typeDefinitionSize735), (&g_typeDefinitionSize736), (&g_typeDefinitionSize737), (&g_typeDefinitionSize738), (&g_typeDefinitionSize739), (&g_typeDefinitionSize740), (&g_typeDefinitionSize741), (&g_typeDefinitionSize742), (&g_typeDefinitionSize743), (&g_typeDefinitionSize744), (&g_typeDefinitionSize745), (&g_typeDefinitionSize746), (&g_typeDefinitionSize747), (&g_typeDefinitionSize748), (&g_typeDefinitionSize749), (&g_typeDefinitionSize750), (&g_typeDefinitionSize751), (&g_typeDefinitionSize752), (&g_typeDefinitionSize753), (&g_typeDefinitionSize754), (&g_typeDefinitionSize755), (&g_typeDefinitionSize756), (&g_typeDefinitionSize757), (&g_typeDefinitionSize758), (&g_typeDefinitionSize759), (&g_typeDefinitionSize760), (&g_typeDefinitionSize761), (&g_typeDefinitionSize762), (&g_typeDefinitionSize763), (&g_typeDefinitionSize764), (&g_typeDefinitionSize765), (&g_typeDefinitionSize766), (&g_typeDefinitionSize767), (&g_typeDefinitionSize768), (&g_typeDefinitionSize769), (&g_typeDefinitionSize770), (&g_typeDefinitionSize771), (&g_typeDefinitionSize772), (&g_typeDefinitionSize773), (&g_typeDefinitionSize774), (&g_typeDefinitionSize775), (&g_typeDefinitionSize776), (&g_typeDefinitionSize777), (&g_typeDefinitionSize778), (&g_typeDefinitionSize779), (&g_typeDefinitionSize780), (&g_typeDefinitionSize781), (&g_typeDefinitionSize782), (&g_typeDefinitionSize783), (&g_typeDefinitionSize784), (&g_typeDefinitionSize785), (&g_typeDefinitionSize786), (&g_typeDefinitionSize787), (&g_typeDefinitionSize788), (&g_typeDefinitionSize789), (&g_typeDefinitionSize790), (&g_typeDefinitionSize791), (&g_typeDefinitionSize792), (&g_typeDefinitionSize793), (&g_typeDefinitionSize794), (&g_typeDefinitionSize795), (&g_typeDefinitionSize796), (&g_typeDefinitionSize797), (&g_typeDefinitionSize798), (&g_typeDefinitionSize799), (&g_typeDefinitionSize800), (&g_typeDefinitionSize801), (&g_typeDefinitionSize802), (&g_typeDefinitionSize803), (&g_typeDefinitionSize804), (&g_typeDefinitionSize805), (&g_typeDefinitionSize806), (&g_typeDefinitionSize807), (&g_typeDefinitionSize808), (&g_typeDefinitionSize809), (&g_typeDefinitionSize810), (&g_typeDefinitionSize811), (&g_typeDefinitionSize812), (&g_typeDefinitionSize813), (&g_typeDefinitionSize814), (&g_typeDefinitionSize815), (&g_typeDefinitionSize816), (&g_typeDefinitionSize817), (&g_typeDefinitionSize818), (&g_typeDefinitionSize819), (&g_typeDefinitionSize820), (&g_typeDefinitionSize821), (&g_typeDefinitionSize822), (&g_typeDefinitionSize823), (&g_typeDefinitionSize824), (&g_typeDefinitionSize825), (&g_typeDefinitionSize826), (&g_typeDefinitionSize827), (&g_typeDefinitionSize828), (&g_typeDefinitionSize829), (&g_typeDefinitionSize830), (&g_typeDefinitionSize831), (&g_typeDefinitionSize832), (&g_typeDefinitionSize833), (&g_typeDefinitionSize834), (&g_typeDefinitionSize835), (&g_typeDefinitionSize836), (&g_typeDefinitionSize837), (&g_typeDefinitionSize838), (&g_typeDefinitionSize839), (&g_typeDefinitionSize840), (&g_typeDefinitionSize841), (&g_typeDefinitionSize842), (&g_typeDefinitionSize843), (&g_typeDefinitionSize844), (&g_typeDefinitionSize845), (&g_typeDefinitionSize846), (&g_typeDefinitionSize847), (&g_typeDefinitionSize848), (&g_typeDefinitionSize849), (&g_typeDefinitionSize850), (&g_typeDefinitionSize851), (&g_typeDefinitionSize852), (&g_typeDefinitionSize853), (&g_typeDefinitionSize854), (&g_typeDefinitionSize855), (&g_typeDefinitionSize856), (&g_typeDefinitionSize857), (&g_typeDefinitionSize858), (&g_typeDefinitionSize859), (&g_typeDefinitionSize860), (&g_typeDefinitionSize861), (&g_typeDefinitionSize862), (&g_typeDefinitionSize863), (&g_typeDefinitionSize864), (&g_typeDefinitionSize865), (&g_typeDefinitionSize866), (&g_typeDefinitionSize867), (&g_typeDefinitionSize868), (&g_typeDefinitionSize869), (&g_typeDefinitionSize870), (&g_typeDefinitionSize871), (&g_typeDefinitionSize872), (&g_typeDefinitionSize873), (&g_typeDefinitionSize874), (&g_typeDefinitionSize875), (&g_typeDefinitionSize876), (&g_typeDefinitionSize877), (&g_typeDefinitionSize878), (&g_typeDefinitionSize879), (&g_typeDefinitionSize880), (&g_typeDefinitionSize881), (&g_typeDefinitionSize882), (&g_typeDefinitionSize883), (&g_typeDefinitionSize884), (&g_typeDefinitionSize885), (&g_typeDefinitionSize886), (&g_typeDefinitionSize887), (&g_typeDefinitionSize888), (&g_typeDefinitionSize889), (&g_typeDefinitionSize890), (&g_typeDefinitionSize891), (&g_typeDefinitionSize892), (&g_typeDefinitionSize893), (&g_typeDefinitionSize894), (&g_typeDefinitionSize895), (&g_typeDefinitionSize896), (&g_typeDefinitionSize897), (&g_typeDefinitionSize898), (&g_typeDefinitionSize899), (&g_typeDefinitionSize900), (&g_typeDefinitionSize901), (&g_typeDefinitionSize902), (&g_typeDefinitionSize903), (&g_typeDefinitionSize904), (&g_typeDefinitionSize905), (&g_typeDefinitionSize906), (&g_typeDefinitionSize907), (&g_typeDefinitionSize908), (&g_typeDefinitionSize909), (&g_typeDefinitionSize910), (&g_typeDefinitionSize911), (&g_typeDefinitionSize912), (&g_typeDefinitionSize913), (&g_typeDefinitionSize914), (&g_typeDefinitionSize915), (&g_typeDefinitionSize916), (&g_typeDefinitionSize917), (&g_typeDefinitionSize918), (&g_typeDefinitionSize919), (&g_typeDefinitionSize920), (&g_typeDefinitionSize921), (&g_typeDefinitionSize922), (&g_typeDefinitionSize923), (&g_typeDefinitionSize924), (&g_typeDefinitionSize925), (&g_typeDefinitionSize926), (&g_typeDefinitionSize927), (&g_typeDefinitionSize928), (&g_typeDefinitionSize929), (&g_typeDefinitionSize930), (&g_typeDefinitionSize931), (&g_typeDefinitionSize932), (&g_typeDefinitionSize933), (&g_typeDefinitionSize934), (&g_typeDefinitionSize935), (&g_typeDefinitionSize936), (&g_typeDefinitionSize937), (&g_typeDefinitionSize938), (&g_typeDefinitionSize939), (&g_typeDefinitionSize940), (&g_typeDefinitionSize941), (&g_typeDefinitionSize942), (&g_typeDefinitionSize943), (&g_typeDefinitionSize944), (&g_typeDefinitionSize945), (&g_typeDefinitionSize946), (&g_typeDefinitionSize947), (&g_typeDefinitionSize948), (&g_typeDefinitionSize949), (&g_typeDefinitionSize950), (&g_typeDefinitionSize951), (&g_typeDefinitionSize952), (&g_typeDefinitionSize953), (&g_typeDefinitionSize954), (&g_typeDefinitionSize955), (&g_typeDefinitionSize956), (&g_typeDefinitionSize957), (&g_typeDefinitionSize958), (&g_typeDefinitionSize959), (&g_typeDefinitionSize960), (&g_typeDefinitionSize961), (&g_typeDefinitionSize962), (&g_typeDefinitionSize963), (&g_typeDefinitionSize964), (&g_typeDefinitionSize965), (&g_typeDefinitionSize966), (&g_typeDefinitionSize967), (&g_typeDefinitionSize968), (&g_typeDefinitionSize969), (&g_typeDefinitionSize970), (&g_typeDefinitionSize971), (&g_typeDefinitionSize972), (&g_typeDefinitionSize973), (&g_typeDefinitionSize974), (&g_typeDefinitionSize975), (&g_typeDefinitionSize976), (&g_typeDefinitionSize977), (&g_typeDefinitionSize978), (&g_typeDefinitionSize979), (&g_typeDefinitionSize980), (&g_typeDefinitionSize981), (&g_typeDefinitionSize982), (&g_typeDefinitionSize983), (&g_typeDefinitionSize984), (&g_typeDefinitionSize985), (&g_typeDefinitionSize986), (&g_typeDefinitionSize987), (&g_typeDefinitionSize988), (&g_typeDefinitionSize989), (&g_typeDefinitionSize990), (&g_typeDefinitionSize991), (&g_typeDefinitionSize992), (&g_typeDefinitionSize993), (&g_typeDefinitionSize994), (&g_typeDefinitionSize995), (&g_typeDefinitionSize996), (&g_typeDefinitionSize997), (&g_typeDefinitionSize998), (&g_typeDefinitionSize999), (&g_typeDefinitionSize1000), (&g_typeDefinitionSize1001), (&g_typeDefinitionSize1002), (&g_typeDefinitionSize1003), (&g_typeDefinitionSize1004), (&g_typeDefinitionSize1005), (&g_typeDefinitionSize1006), (&g_typeDefinitionSize1007), (&g_typeDefinitionSize1008), (&g_typeDefinitionSize1009), (&g_typeDefinitionSize1010), (&g_typeDefinitionSize1011), (&g_typeDefinitionSize1012), (&g_typeDefinitionSize1013), (&g_typeDefinitionSize1014), (&g_typeDefinitionSize1015), (&g_typeDefinitionSize1016), (&g_typeDefinitionSize1017), (&g_typeDefinitionSize1018), (&g_typeDefinitionSize1019), (&g_typeDefinitionSize1020), (&g_typeDefinitionSize1021), (&g_typeDefinitionSize1022), (&g_typeDefinitionSize1023), (&g_typeDefinitionSize1024), (&g_typeDefinitionSize1025), (&g_typeDefinitionSize1026), (&g_typeDefinitionSize1027), (&g_typeDefinitionSize1028), (&g_typeDefinitionSize1029), (&g_typeDefinitionSize1030), (&g_typeDefinitionSize1031), (&g_typeDefinitionSize1032), (&g_typeDefinitionSize1033), (&g_typeDefinitionSize1034), (&g_typeDefinitionSize1035), (&g_typeDefinitionSize1036), (&g_typeDefinitionSize1037), (&g_typeDefinitionSize1038), (&g_typeDefinitionSize1039), (&g_typeDefinitionSize1040), (&g_typeDefinitionSize1041), (&g_typeDefinitionSize1042), (&g_typeDefinitionSize1043), (&g_typeDefinitionSize1044), (&g_typeDefinitionSize1045), (&g_typeDefinitionSize1046), (&g_typeDefinitionSize1047), (&g_typeDefinitionSize1048), (&g_typeDefinitionSize1049), (&g_typeDefinitionSize1050), (&g_typeDefinitionSize1051), (&g_typeDefinitionSize1052), (&g_typeDefinitionSize1053), (&g_typeDefinitionSize1054), (&g_typeDefinitionSize1055), (&g_typeDefinitionSize1056), (&g_typeDefinitionSize1057), (&g_typeDefinitionSize1058), (&g_typeDefinitionSize1059), (&g_typeDefinitionSize1060), (&g_typeDefinitionSize1061), (&g_typeDefinitionSize1062), (&g_typeDefinitionSize1063), (&g_typeDefinitionSize1064), (&g_typeDefinitionSize1065), (&g_typeDefinitionSize1066), (&g_typeDefinitionSize1067), (&g_typeDefinitionSize1068), (&g_typeDefinitionSize1069), (&g_typeDefinitionSize1070), (&g_typeDefinitionSize1071), (&g_typeDefinitionSize1072), (&g_typeDefinitionSize1073), (&g_typeDefinitionSize1074), (&g_typeDefinitionSize1075), (&g_typeDefinitionSize1076), (&g_typeDefinitionSize1077), (&g_typeDefinitionSize1078), (&g_typeDefinitionSize1079), (&g_typeDefinitionSize1080), (&g_typeDefinitionSize1081), (&g_typeDefinitionSize1082), (&g_typeDefinitionSize1083), (&g_typeDefinitionSize1084), (&g_typeDefinitionSize1085), (&g_typeDefinitionSize1086), (&g_typeDefinitionSize1087), (&g_typeDefinitionSize1088), (&g_typeDefinitionSize1089), (&g_typeDefinitionSize1090), (&g_typeDefinitionSize1091), (&g_typeDefinitionSize1092), (&g_typeDefinitionSize1093), (&g_typeDefinitionSize1094), (&g_typeDefinitionSize1095), (&g_typeDefinitionSize1096), (&g_typeDefinitionSize1097), (&g_typeDefinitionSize1098), (&g_typeDefinitionSize1099), (&g_typeDefinitionSize1100), (&g_typeDefinitionSize1101), (&g_typeDefinitionSize1102), (&g_typeDefinitionSize1103), (&g_typeDefinitionSize1104), (&g_typeDefinitionSize1105), (&g_typeDefinitionSize1106), (&g_typeDefinitionSize1107), (&g_typeDefinitionSize1108), (&g_typeDefinitionSize1109), (&g_typeDefinitionSize1110), (&g_typeDefinitionSize1111), (&g_typeDefinitionSize1112), (&g_typeDefinitionSize1113), (&g_typeDefinitionSize1114), (&g_typeDefinitionSize1115), (&g_typeDefinitionSize1116), (&g_typeDefinitionSize1117), (&g_typeDefinitionSize1118), (&g_typeDefinitionSize1119), (&g_typeDefinitionSize1120), (&g_typeDefinitionSize1121), (&g_typeDefinitionSize1122), (&g_typeDefinitionSize1123), (&g_typeDefinitionSize1124), (&g_typeDefinitionSize1125), (&g_typeDefinitionSize1126), (&g_typeDefinitionSize1127), (&g_typeDefinitionSize1128), (&g_typeDefinitionSize1129), (&g_typeDefinitionSize1130), (&g_typeDefinitionSize1131), (&g_typeDefinitionSize1132), (&g_typeDefinitionSize1133), (&g_typeDefinitionSize1134), (&g_typeDefinitionSize1135), (&g_typeDefinitionSize1136), (&g_typeDefinitionSize1137), (&g_typeDefinitionSize1138), (&g_typeDefinitionSize1139), (&g_typeDefinitionSize1140), (&g_typeDefinitionSize1141), (&g_typeDefinitionSize1142), (&g_typeDefinitionSize1143), (&g_typeDefinitionSize1144), (&g_typeDefinitionSize1145), (&g_typeDefinitionSize1146), (&g_typeDefinitionSize1147), (&g_typeDefinitionSize1148), (&g_typeDefinitionSize1149), (&g_typeDefinitionSize1150), (&g_typeDefinitionSize1151), (&g_typeDefinitionSize1152), (&g_typeDefinitionSize1153), (&g_typeDefinitionSize1154), (&g_typeDefinitionSize1155), (&g_typeDefinitionSize1156), (&g_typeDefinitionSize1157), (&g_typeDefinitionSize1158), (&g_typeDefinitionSize1159), (&g_typeDefinitionSize1160), (&g_typeDefinitionSize1161), (&g_typeDefinitionSize1162), (&g_typeDefinitionSize1163), (&g_typeDefinitionSize1164), (&g_typeDefinitionSize1165), (&g_typeDefinitionSize1166), (&g_typeDefinitionSize1167), (&g_typeDefinitionSize1168), (&g_typeDefinitionSize1169), (&g_typeDefinitionSize1170), (&g_typeDefinitionSize1171), (&g_typeDefinitionSize1172), (&g_typeDefinitionSize1173), (&g_typeDefinitionSize1174), (&g_typeDefinitionSize1175), (&g_typeDefinitionSize1176), (&g_typeDefinitionSize1177), (&g_typeDefinitionSize1178), (&g_typeDefinitionSize1179), (&g_typeDefinitionSize1180), (&g_typeDefinitionSize1181), (&g_typeDefinitionSize1182), (&g_typeDefinitionSize1183), (&g_typeDefinitionSize1184), (&g_typeDefinitionSize1185), (&g_typeDefinitionSize1186), (&g_typeDefinitionSize1187), (&g_typeDefinitionSize1188), (&g_typeDefinitionSize1189), (&g_typeDefinitionSize1190), (&g_typeDefinitionSize1191), (&g_typeDefinitionSize1192), (&g_typeDefinitionSize1193), (&g_typeDefinitionSize1194), (&g_typeDefinitionSize1195), (&g_typeDefinitionSize1196), (&g_typeDefinitionSize1197), (&g_typeDefinitionSize1198), (&g_typeDefinitionSize1199), (&g_typeDefinitionSize1200), (&g_typeDefinitionSize1201), (&g_typeDefinitionSize1202), (&g_typeDefinitionSize1203), (&g_typeDefinitionSize1204), (&g_typeDefinitionSize1205), (&g_typeDefinitionSize1206), (&g_typeDefinitionSize1207), (&g_typeDefinitionSize1208), (&g_typeDefinitionSize1209), (&g_typeDefinitionSize1210), (&g_typeDefinitionSize1211), (&g_typeDefinitionSize1212), (&g_typeDefinitionSize1213), (&g_typeDefinitionSize1214), (&g_typeDefinitionSize1215), (&g_typeDefinitionSize1216), (&g_typeDefinitionSize1217), (&g_typeDefinitionSize1218), (&g_typeDefinitionSize1219), (&g_typeDefinitionSize1220), (&g_typeDefinitionSize1221), (&g_typeDefinitionSize1222), (&g_typeDefinitionSize1223), (&g_typeDefinitionSize1224), (&g_typeDefinitionSize1225), (&g_typeDefinitionSize1226), (&g_typeDefinitionSize1227), (&g_typeDefinitionSize1228), (&g_typeDefinitionSize1229), (&g_typeDefinitionSize1230), (&g_typeDefinitionSize1231), (&g_typeDefinitionSize1232), (&g_typeDefinitionSize1233), (&g_typeDefinitionSize1234), (&g_typeDefinitionSize1235), (&g_typeDefinitionSize1236), (&g_typeDefinitionSize1237), (&g_typeDefinitionSize1238), (&g_typeDefinitionSize1239), (&g_typeDefinitionSize1240), (&g_typeDefinitionSize1241), (&g_typeDefinitionSize1242), (&g_typeDefinitionSize1243), (&g_typeDefinitionSize1244), (&g_typeDefinitionSize1245), (&g_typeDefinitionSize1246), (&g_typeDefinitionSize1247), (&g_typeDefinitionSize1248), (&g_typeDefinitionSize1249), (&g_typeDefinitionSize1250), (&g_typeDefinitionSize1251), (&g_typeDefinitionSize1252), (&g_typeDefinitionSize1253), (&g_typeDefinitionSize1254), (&g_typeDefinitionSize1255), (&g_typeDefinitionSize1256), (&g_typeDefinitionSize1257), (&g_typeDefinitionSize1258), (&g_typeDefinitionSize1259), (&g_typeDefinitionSize1260), (&g_typeDefinitionSize1261), (&g_typeDefinitionSize1262), (&g_typeDefinitionSize1263), (&g_typeDefinitionSize1264), (&g_typeDefinitionSize1265), (&g_typeDefinitionSize1266), (&g_typeDefinitionSize1267), (&g_typeDefinitionSize1268), (&g_typeDefinitionSize1269), (&g_typeDefinitionSize1270), (&g_typeDefinitionSize1271), (&g_typeDefinitionSize1272), (&g_typeDefinitionSize1273), (&g_typeDefinitionSize1274), (&g_typeDefinitionSize1275), (&g_typeDefinitionSize1276), (&g_typeDefinitionSize1277), (&g_typeDefinitionSize1278), (&g_typeDefinitionSize1279), (&g_typeDefinitionSize1280), (&g_typeDefinitionSize1281), (&g_typeDefinitionSize1282), (&g_typeDefinitionSize1283), (&g_typeDefinitionSize1284), (&g_typeDefinitionSize1285), (&g_typeDefinitionSize1286), (&g_typeDefinitionSize1287), (&g_typeDefinitionSize1288), (&g_typeDefinitionSize1289), (&g_typeDefinitionSize1290), (&g_typeDefinitionSize1291), (&g_typeDefinitionSize1292), (&g_typeDefinitionSize1293), (&g_typeDefinitionSize1294), (&g_typeDefinitionSize1295), (&g_typeDefinitionSize1296), (&g_typeDefinitionSize1297), (&g_typeDefinitionSize1298), (&g_typeDefinitionSize1299), (&g_typeDefinitionSize1300), (&g_typeDefinitionSize1301), (&g_typeDefinitionSize1302), (&g_typeDefinitionSize1303), (&g_typeDefinitionSize1304), (&g_typeDefinitionSize1305), (&g_typeDefinitionSize1306), (&g_typeDefinitionSize1307), (&g_typeDefinitionSize1308), (&g_typeDefinitionSize1309), (&g_typeDefinitionSize1310), (&g_typeDefinitionSize1311), (&g_typeDefinitionSize1312), (&g_typeDefinitionSize1313), (&g_typeDefinitionSize1314), (&g_typeDefinitionSize1315), (&g_typeDefinitionSize1316), (&g_typeDefinitionSize1317), (&g_typeDefinitionSize1318), (&g_typeDefinitionSize1319), (&g_typeDefinitionSize1320), (&g_typeDefinitionSize1321), (&g_typeDefinitionSize1322), (&g_typeDefinitionSize1323), (&g_typeDefinitionSize1324), (&g_typeDefinitionSize1325), (&g_typeDefinitionSize1326), (&g_typeDefinitionSize1327), (&g_typeDefinitionSize1328), (&g_typeDefinitionSize1329), (&g_typeDefinitionSize1330), (&g_typeDefinitionSize1331), (&g_typeDefinitionSize1332), (&g_typeDefinitionSize1333), (&g_typeDefinitionSize1334), (&g_typeDefinitionSize1335), (&g_typeDefinitionSize1336), (&g_typeDefinitionSize1337), (&g_typeDefinitionSize1338), (&g_typeDefinitionSize1339), (&g_typeDefinitionSize1340), (&g_typeDefinitionSize1341), (&g_typeDefinitionSize1342), (&g_typeDefinitionSize1343), (&g_typeDefinitionSize1344), (&g_typeDefinitionSize1345), (&g_typeDefinitionSize1346), (&g_typeDefinitionSize1347), (&g_typeDefinitionSize1348), (&g_typeDefinitionSize1349), (&g_typeDefinitionSize1350), (&g_typeDefinitionSize1351), (&g_typeDefinitionSize1352), (&g_typeDefinitionSize1353), (&g_typeDefinitionSize1354), (&g_typeDefinitionSize1355), (&g_typeDefinitionSize1356), (&g_typeDefinitionSize1357), (&g_typeDefinitionSize1358), (&g_typeDefinitionSize1359), (&g_typeDefinitionSize1360), (&g_typeDefinitionSize1361), (&g_typeDefinitionSize1362), (&g_typeDefinitionSize1363), (&g_typeDefinitionSize1364), (&g_typeDefinitionSize1365), (&g_typeDefinitionSize1366), (&g_typeDefinitionSize1367), (&g_typeDefinitionSize1368), (&g_typeDefinitionSize1369), (&g_typeDefinitionSize1370), (&g_typeDefinitionSize1371), (&g_typeDefinitionSize1372), (&g_typeDefinitionSize1373), (&g_typeDefinitionSize1374), (&g_typeDefinitionSize1375), (&g_typeDefinitionSize1376), (&g_typeDefinitionSize1377), (&g_typeDefinitionSize1378), (&g_typeDefinitionSize1379), (&g_typeDefinitionSize1380), (&g_typeDefinitionSize1381), (&g_typeDefinitionSize1382), (&g_typeDefinitionSize1383), (&g_typeDefinitionSize1384), (&g_typeDefinitionSize1385), (&g_typeDefinitionSize1386), (&g_typeDefinitionSize1387), (&g_typeDefinitionSize1388), (&g_typeDefinitionSize1389), (&g_typeDefinitionSize1390), (&g_typeDefinitionSize1391), (&g_typeDefinitionSize1392), (&g_typeDefinitionSize1393), (&g_typeDefinitionSize1394), (&g_typeDefinitionSize1395), (&g_typeDefinitionSize1396), (&g_typeDefinitionSize1397), (&g_typeDefinitionSize1398), (&g_typeDefinitionSize1399), (&g_typeDefinitionSize1400), (&g_typeDefinitionSize1401), (&g_typeDefinitionSize1402), (&g_typeDefinitionSize1403), (&g_typeDefinitionSize1404), (&g_typeDefinitionSize1405), (&g_typeDefinitionSize1406), (&g_typeDefinitionSize1407), (&g_typeDefinitionSize1408), (&g_typeDefinitionSize1409), (&g_typeDefinitionSize1410), (&g_typeDefinitionSize1411), (&g_typeDefinitionSize1412), (&g_typeDefinitionSize1413), (&g_typeDefinitionSize1414), (&g_typeDefinitionSize1415), (&g_typeDefinitionSize1416), (&g_typeDefinitionSize1417), (&g_typeDefinitionSize1418), (&g_typeDefinitionSize1419), (&g_typeDefinitionSize1420), (&g_typeDefinitionSize1421), (&g_typeDefinitionSize1422), (&g_typeDefinitionSize1423), (&g_typeDefinitionSize1424), (&g_typeDefinitionSize1425), (&g_typeDefinitionSize1426), (&g_typeDefinitionSize1427), (&g_typeDefinitionSize1428), (&g_typeDefinitionSize1429), (&g_typeDefinitionSize1430), (&g_typeDefinitionSize1431), (&g_typeDefinitionSize1432), (&g_typeDefinitionSize1433), (&g_typeDefinitionSize1434), (&g_typeDefinitionSize1435), (&g_typeDefinitionSize1436), (&g_typeDefinitionSize1437), (&g_typeDefinitionSize1438), (&g_typeDefinitionSize1439), (&g_typeDefinitionSize1440), (&g_typeDefinitionSize1441), (&g_typeDefinitionSize1442), (&g_typeDefinitionSize1443), (&g_typeDefinitionSize1444), (&g_typeDefinitionSize1445), (&g_typeDefinitionSize1446), (&g_typeDefinitionSize1447), (&g_typeDefinitionSize1448), (&g_typeDefinitionSize1449), (&g_typeDefinitionSize1450), (&g_typeDefinitionSize1451), (&g_typeDefinitionSize1452), (&g_typeDefinitionSize1453), (&g_typeDefinitionSize1454), (&g_typeDefinitionSize1455), (&g_typeDefinitionSize1456), (&g_typeDefinitionSize1457), (&g_typeDefinitionSize1458), (&g_typeDefinitionSize1459), (&g_typeDefinitionSize1460), (&g_typeDefinitionSize1461), (&g_typeDefinitionSize1462), (&g_typeDefinitionSize1463), (&g_typeDefinitionSize1464), (&g_typeDefinitionSize1465), (&g_typeDefinitionSize1466), (&g_typeDefinitionSize1467), (&g_typeDefinitionSize1468), (&g_typeDefinitionSize1469), (&g_typeDefinitionSize1470), (&g_typeDefinitionSize1471), (&g_typeDefinitionSize1472), (&g_typeDefinitionSize1473), (&g_typeDefinitionSize1474), (&g_typeDefinitionSize1475), (&g_typeDefinitionSize1476), (&g_typeDefinitionSize1477), (&g_typeDefinitionSize1478), (&g_typeDefinitionSize1479), (&g_typeDefinitionSize1480), (&g_typeDefinitionSize1481), (&g_typeDefinitionSize1482), (&g_typeDefinitionSize1483), (&g_typeDefinitionSize1484), (&g_typeDefinitionSize1485), (&g_typeDefinitionSize1486), (&g_typeDefinitionSize1487), (&g_typeDefinitionSize1488), (&g_typeDefinitionSize1489), (&g_typeDefinitionSize1490), (&g_typeDefinitionSize1491), (&g_typeDefinitionSize1492), (&g_typeDefinitionSize1493), (&g_typeDefinitionSize1494), (&g_typeDefinitionSize1495), (&g_typeDefinitionSize1496), (&g_typeDefinitionSize1497), (&g_typeDefinitionSize1498), (&g_typeDefinitionSize1499), (&g_typeDefinitionSize1500), (&g_typeDefinitionSize1501), (&g_typeDefinitionSize1502), (&g_typeDefinitionSize1503), (&g_typeDefinitionSize1504), (&g_typeDefinitionSize1505), (&g_typeDefinitionSize1506), (&g_typeDefinitionSize1507), (&g_typeDefinitionSize1508), (&g_typeDefinitionSize1509), (&g_typeDefinitionSize1510), (&g_typeDefinitionSize1511), (&g_typeDefinitionSize1512), (&g_typeDefinitionSize1513), (&g_typeDefinitionSize1514), (&g_typeDefinitionSize1515), (&g_typeDefinitionSize1516), (&g_typeDefinitionSize1517), (&g_typeDefinitionSize1518), (&g_typeDefinitionSize1519), (&g_typeDefinitionSize1520), (&g_typeDefinitionSize1521), (&g_typeDefinitionSize1522), (&g_typeDefinitionSize1523), (&g_typeDefinitionSize1524), (&g_typeDefinitionSize1525), (&g_typeDefinitionSize1526), (&g_typeDefinitionSize1527), (&g_typeDefinitionSize1528), (&g_typeDefinitionSize1529), (&g_typeDefinitionSize1530), (&g_typeDefinitionSize1531), (&g_typeDefinitionSize1532), (&g_typeDefinitionSize1533), (&g_typeDefinitionSize1534), (&g_typeDefinitionSize1535), (&g_typeDefinitionSize1536), (&g_typeDefinitionSize1537), (&g_typeDefinitionSize1538), (&g_typeDefinitionSize1539), (&g_typeDefinitionSize1540), (&g_typeDefinitionSize1541), (&g_typeDefinitionSize1542), (&g_typeDefinitionSize1543), (&g_typeDefinitionSize1544), (&g_typeDefinitionSize1545), (&g_typeDefinitionSize1546), (&g_typeDefinitionSize1547), (&g_typeDefinitionSize1548), (&g_typeDefinitionSize1549), (&g_typeDefinitionSize1550), (&g_typeDefinitionSize1551), (&g_typeDefinitionSize1552), (&g_typeDefinitionSize1553), (&g_typeDefinitionSize1554), (&g_typeDefinitionSize1555), (&g_typeDefinitionSize1556), (&g_typeDefinitionSize1557), (&g_typeDefinitionSize1558), (&g_typeDefinitionSize1559), (&g_typeDefinitionSize1560), (&g_typeDefinitionSize1561), (&g_typeDefinitionSize1562), (&g_typeDefinitionSize1563), (&g_typeDefinitionSize1564), (&g_typeDefinitionSize1565), (&g_typeDefinitionSize1566), (&g_typeDefinitionSize1567), (&g_typeDefinitionSize1568), (&g_typeDefinitionSize1569), (&g_typeDefinitionSize1570), (&g_typeDefinitionSize1571), (&g_typeDefinitionSize1572), (&g_typeDefinitionSize1573), (&g_typeDefinitionSize1574), (&g_typeDefinitionSize1575), (&g_typeDefinitionSize1576), (&g_typeDefinitionSize1577), (&g_typeDefinitionSize1578), (&g_typeDefinitionSize1579), (&g_typeDefinitionSize1580), (&g_typeDefinitionSize1581), (&g_typeDefinitionSize1582), (&g_typeDefinitionSize1583), (&g_typeDefinitionSize1584), (&g_typeDefinitionSize1585), (&g_typeDefinitionSize1586), (&g_typeDefinitionSize1587), (&g_typeDefinitionSize1588), (&g_typeDefinitionSize1589), (&g_typeDefinitionSize1590), (&g_typeDefinitionSize1591), (&g_typeDefinitionSize1592), (&g_typeDefinitionSize1593), (&g_typeDefinitionSize1594), (&g_typeDefinitionSize1595), (&g_typeDefinitionSize1596), (&g_typeDefinitionSize1597), (&g_typeDefinitionSize1598), (&g_typeDefinitionSize1599), (&g_typeDefinitionSize1600), (&g_typeDefinitionSize1601), (&g_typeDefinitionSize1602), (&g_typeDefinitionSize1603), (&g_typeDefinitionSize1604), (&g_typeDefinitionSize1605), (&g_typeDefinitionSize1606), (&g_typeDefinitionSize1607), (&g_typeDefinitionSize1608), (&g_typeDefinitionSize1609), (&g_typeDefinitionSize1610), (&g_typeDefinitionSize1611), (&g_typeDefinitionSize1612), (&g_typeDefinitionSize1613), (&g_typeDefinitionSize1614), (&g_typeDefinitionSize1615), (&g_typeDefinitionSize1616), (&g_typeDefinitionSize1617), (&g_typeDefinitionSize1618), (&g_typeDefinitionSize1619), (&g_typeDefinitionSize1620), (&g_typeDefinitionSize1621), (&g_typeDefinitionSize1622), (&g_typeDefinitionSize1623), (&g_typeDefinitionSize1624), (&g_typeDefinitionSize1625), (&g_typeDefinitionSize1626), (&g_typeDefinitionSize1627), (&g_typeDefinitionSize1628), (&g_typeDefinitionSize1629), (&g_typeDefinitionSize1630), (&g_typeDefinitionSize1631), (&g_typeDefinitionSize1632), (&g_typeDefinitionSize1633), (&g_typeDefinitionSize1634), (&g_typeDefinitionSize1635), (&g_typeDefinitionSize1636), (&g_typeDefinitionSize1637), (&g_typeDefinitionSize1638), (&g_typeDefinitionSize1639), (&g_typeDefinitionSize1640), (&g_typeDefinitionSize1641), (&g_typeDefinitionSize1642), (&g_typeDefinitionSize1643), (&g_typeDefinitionSize1644), (&g_typeDefinitionSize1645), (&g_typeDefinitionSize1646), (&g_typeDefinitionSize1647), (&g_typeDefinitionSize1648), (&g_typeDefinitionSize1649), (&g_typeDefinitionSize1650), (&g_typeDefinitionSize1651), (&g_typeDefinitionSize1652), (&g_typeDefinitionSize1653), (&g_typeDefinitionSize1654), (&g_typeDefinitionSize1655), (&g_typeDefinitionSize1656), (&g_typeDefinitionSize1657), (&g_typeDefinitionSize1658), (&g_typeDefinitionSize1659), (&g_typeDefinitionSize1660), (&g_typeDefinitionSize1661), (&g_typeDefinitionSize1662), (&g_typeDefinitionSize1663), (&g_typeDefinitionSize1664), (&g_typeDefinitionSize1665), (&g_typeDefinitionSize1666), (&g_typeDefinitionSize1667), (&g_typeDefinitionSize1668), (&g_typeDefinitionSize1669), (&g_typeDefinitionSize1670), (&g_typeDefinitionSize1671), (&g_typeDefinitionSize1672), (&g_typeDefinitionSize1673), (&g_typeDefinitionSize1674), (&g_typeDefinitionSize1675), (&g_typeDefinitionSize1676), (&g_typeDefinitionSize1677), (&g_typeDefinitionSize1678), (&g_typeDefinitionSize1679), (&g_typeDefinitionSize1680), (&g_typeDefinitionSize1681), (&g_typeDefinitionSize1682), (&g_typeDefinitionSize1683), (&g_typeDefinitionSize1684), (&g_typeDefinitionSize1685), (&g_typeDefinitionSize1686), (&g_typeDefinitionSize1687), (&g_typeDefinitionSize1688), (&g_typeDefinitionSize1689), (&g_typeDefinitionSize1690), (&g_typeDefinitionSize1691), (&g_typeDefinitionSize1692), (&g_typeDefinitionSize1693), (&g_typeDefinitionSize1694), (&g_typeDefinitionSize1695), (&g_typeDefinitionSize1696), (&g_typeDefinitionSize1697), (&g_typeDefinitionSize1698), (&g_typeDefinitionSize1699), (&g_typeDefinitionSize1700), (&g_typeDefinitionSize1701), (&g_typeDefinitionSize1702), (&g_typeDefinitionSize1703), (&g_typeDefinitionSize1704), (&g_typeDefinitionSize1705), (&g_typeDefinitionSize1706), (&g_typeDefinitionSize1707), (&g_typeDefinitionSize1708), (&g_typeDefinitionSize1709), (&g_typeDefinitionSize1710), (&g_typeDefinitionSize1711), (&g_typeDefinitionSize1712), (&g_typeDefinitionSize1713), (&g_typeDefinitionSize1714), (&g_typeDefinitionSize1715), (&g_typeDefinitionSize1716), (&g_typeDefinitionSize1717), (&g_typeDefinitionSize1718), (&g_typeDefinitionSize1719), (&g_typeDefinitionSize1720), (&g_typeDefinitionSize1721), (&g_typeDefinitionSize1722), (&g_typeDefinitionSize1723), (&g_typeDefinitionSize1724), (&g_typeDefinitionSize1725), (&g_typeDefinitionSize1726), (&g_typeDefinitionSize1727), (&g_typeDefinitionSize1728), (&g_typeDefinitionSize1729), (&g_typeDefinitionSize1730), (&g_typeDefinitionSize1731), (&g_typeDefinitionSize1732), (&g_typeDefinitionSize1733), (&g_typeDefinitionSize1734), (&g_typeDefinitionSize1735), (&g_typeDefinitionSize1736), (&g_typeDefinitionSize1737), (&g_typeDefinitionSize1738), (&g_typeDefinitionSize1739), (&g_typeDefinitionSize1740), (&g_typeDefinitionSize1741), (&g_typeDefinitionSize1742), (&g_typeDefinitionSize1743), (&g_typeDefinitionSize1744), (&g_typeDefinitionSize1745), (&g_typeDefinitionSize1746), (&g_typeDefinitionSize1747), (&g_typeDefinitionSize1748), (&g_typeDefinitionSize1749), (&g_typeDefinitionSize1750), (&g_typeDefinitionSize1751), (&g_typeDefinitionSize1752), (&g_typeDefinitionSize1753), (&g_typeDefinitionSize1754), (&g_typeDefinitionSize1755), (&g_typeDefinitionSize1756), (&g_typeDefinitionSize1757), (&g_typeDefinitionSize1758), (&g_typeDefinitionSize1759), (&g_typeDefinitionSize1760), (&g_typeDefinitionSize1761), (&g_typeDefinitionSize1762), (&g_typeDefinitionSize1763), (&g_typeDefinitionSize1764), (&g_typeDefinitionSize1765), (&g_typeDefinitionSize1766), (&g_typeDefinitionSize1767), (&g_typeDefinitionSize1768), (&g_typeDefinitionSize1769), (&g_typeDefinitionSize1770), (&g_typeDefinitionSize1771), (&g_typeDefinitionSize1772), (&g_typeDefinitionSize1773), (&g_typeDefinitionSize1774), (&g_typeDefinitionSize1775), (&g_typeDefinitionSize1776), (&g_typeDefinitionSize1777), (&g_typeDefinitionSize1778), (&g_typeDefinitionSize1779), (&g_typeDefinitionSize1780), (&g_typeDefinitionSize1781), (&g_typeDefinitionSize1782), (&g_typeDefinitionSize1783), (&g_typeDefinitionSize1784), (&g_typeDefinitionSize1785), (&g_typeDefinitionSize1786), (&g_typeDefinitionSize1787), (&g_typeDefinitionSize1788), (&g_typeDefinitionSize1789), (&g_typeDefinitionSize1790), (&g_typeDefinitionSize1791), (&g_typeDefinitionSize1792), (&g_typeDefinitionSize1793), (&g_typeDefinitionSize1794), (&g_typeDefinitionSize1795), (&g_typeDefinitionSize1796), (&g_typeDefinitionSize1797), (&g_typeDefinitionSize1798), (&g_typeDefinitionSize1799), (&g_typeDefinitionSize1800), (&g_typeDefinitionSize1801), (&g_typeDefinitionSize1802), (&g_typeDefinitionSize1803), (&g_typeDefinitionSize1804), (&g_typeDefinitionSize1805), (&g_typeDefinitionSize1806), (&g_typeDefinitionSize1807), (&g_typeDefinitionSize1808), (&g_typeDefinitionSize1809), (&g_typeDefinitionSize1810), (&g_typeDefinitionSize1811), (&g_typeDefinitionSize1812), (&g_typeDefinitionSize1813), (&g_typeDefinitionSize1814), (&g_typeDefinitionSize1815), (&g_typeDefinitionSize1816), (&g_typeDefinitionSize1817), (&g_typeDefinitionSize1818), (&g_typeDefinitionSize1819), (&g_typeDefinitionSize1820), (&g_typeDefinitionSize1821), (&g_typeDefinitionSize1822), (&g_typeDefinitionSize1823), (&g_typeDefinitionSize1824), (&g_typeDefinitionSize1825), (&g_typeDefinitionSize1826), (&g_typeDefinitionSize1827), (&g_typeDefinitionSize1828), (&g_typeDefinitionSize1829), (&g_typeDefinitionSize1830), (&g_typeDefinitionSize1831), (&g_typeDefinitionSize1832), (&g_typeDefinitionSize1833), (&g_typeDefinitionSize1834), (&g_typeDefinitionSize1835), (&g_typeDefinitionSize1836), (&g_typeDefinitionSize1837), (&g_typeDefinitionSize1838), (&g_typeDefinitionSize1839), (&g_typeDefinitionSize1840), (&g_typeDefinitionSize1841), (&g_typeDefinitionSize1842), (&g_typeDefinitionSize1843), (&g_typeDefinitionSize1844), (&g_typeDefinitionSize1845), (&g_typeDefinitionSize1846), (&g_typeDefinitionSize1847), (&g_typeDefinitionSize1848), (&g_typeDefinitionSize1849), (&g_typeDefinitionSize1850), (&g_typeDefinitionSize1851), (&g_typeDefinitionSize1852), (&g_typeDefinitionSize1853), (&g_typeDefinitionSize1854), (&g_typeDefinitionSize1855), (&g_typeDefinitionSize1856), (&g_typeDefinitionSize1857), (&g_typeDefinitionSize1858), (&g_typeDefinitionSize1859), (&g_typeDefinitionSize1860), (&g_typeDefinitionSize1861), (&g_typeDefinitionSize1862), (&g_typeDefinitionSize1863), (&g_typeDefinitionSize1864), (&g_typeDefinitionSize1865), (&g_typeDefinitionSize1866), (&g_typeDefinitionSize1867), (&g_typeDefinitionSize1868), (&g_typeDefinitionSize1869), (&g_typeDefinitionSize1870), (&g_typeDefinitionSize1871), (&g_typeDefinitionSize1872), (&g_typeDefinitionSize1873), (&g_typeDefinitionSize1874), (&g_typeDefinitionSize1875), (&g_typeDefinitionSize1876), (&g_typeDefinitionSize1877), (&g_typeDefinitionSize1878), (&g_typeDefinitionSize1879), (&g_typeDefinitionSize1880), (&g_typeDefinitionSize1881), (&g_typeDefinitionSize1882), (&g_typeDefinitionSize1883), (&g_typeDefinitionSize1884), (&g_typeDefinitionSize1885), (&g_typeDefinitionSize1886), (&g_typeDefinitionSize1887), (&g_typeDefinitionSize1888), (&g_typeDefinitionSize1889), (&g_typeDefinitionSize1890), (&g_typeDefinitionSize1891), (&g_typeDefinitionSize1892), (&g_typeDefinitionSize1893), (&g_typeDefinitionSize1894), (&g_typeDefinitionSize1895), (&g_typeDefinitionSize1896), (&g_typeDefinitionSize1897), (&g_typeDefinitionSize1898), (&g_typeDefinitionSize1899), (&g_typeDefinitionSize1900), (&g_typeDefinitionSize1901), (&g_typeDefinitionSize1902), (&g_typeDefinitionSize1903), (&g_typeDefinitionSize1904), (&g_typeDefinitionSize1905), (&g_typeDefinitionSize1906), (&g_typeDefinitionSize1907), (&g_typeDefinitionSize1908), (&g_typeDefinitionSize1909), (&g_typeDefinitionSize1910), (&g_typeDefinitionSize1911), (&g_typeDefinitionSize1912), (&g_typeDefinitionSize1913), (&g_typeDefinitionSize1914), (&g_typeDefinitionSize1915), (&g_typeDefinitionSize1916), (&g_typeDefinitionSize1917), (&g_typeDefinitionSize1918), (&g_typeDefinitionSize1919), (&g_typeDefinitionSize1920), (&g_typeDefinitionSize1921), (&g_typeDefinitionSize1922), (&g_typeDefinitionSize1923), (&g_typeDefinitionSize1924), (&g_typeDefinitionSize1925), (&g_typeDefinitionSize1926), (&g_typeDefinitionSize1927), (&g_typeDefinitionSize1928), (&g_typeDefinitionSize1929), (&g_typeDefinitionSize1930), (&g_typeDefinitionSize1931), (&g_typeDefinitionSize1932), (&g_typeDefinitionSize1933), (&g_typeDefinitionSize1934), (&g_typeDefinitionSize1935), (&g_typeDefinitionSize1936), (&g_typeDefinitionSize1937), (&g_typeDefinitionSize1938), (&g_typeDefinitionSize1939), (&g_typeDefinitionSize1940), (&g_typeDefinitionSize1941), (&g_typeDefinitionSize1942), (&g_typeDefinitionSize1943), (&g_typeDefinitionSize1944), (&g_typeDefinitionSize1945), (&g_typeDefinitionSize1946), (&g_typeDefinitionSize1947), (&g_typeDefinitionSize1948), (&g_typeDefinitionSize1949), (&g_typeDefinitionSize1950), (&g_typeDefinitionSize1951), (&g_typeDefinitionSize1952), (&g_typeDefinitionSize1953), (&g_typeDefinitionSize1954), (&g_typeDefinitionSize1955), (&g_typeDefinitionSize1956), (&g_typeDefinitionSize1957), (&g_typeDefinitionSize1958), (&g_typeDefinitionSize1959), (&g_typeDefinitionSize1960), (&g_typeDefinitionSize1961), (&g_typeDefinitionSize1962), (&g_typeDefinitionSize1963), (&g_typeDefinitionSize1964), (&g_typeDefinitionSize1965), (&g_typeDefinitionSize1966), (&g_typeDefinitionSize1967), (&g_typeDefinitionSize1968), (&g_typeDefinitionSize1969), (&g_typeDefinitionSize1970), (&g_typeDefinitionSize1971), (&g_typeDefinitionSize1972), (&g_typeDefinitionSize1973), (&g_typeDefinitionSize1974), (&g_typeDefinitionSize1975), (&g_typeDefinitionSize1976), (&g_typeDefinitionSize1977), (&g_typeDefinitionSize1978), (&g_typeDefinitionSize1979), (&g_typeDefinitionSize1980), (&g_typeDefinitionSize1981), (&g_typeDefinitionSize1982), (&g_typeDefinitionSize1983), (&g_typeDefinitionSize1984), (&g_typeDefinitionSize1985), (&g_typeDefinitionSize1986), (&g_typeDefinitionSize1987), (&g_typeDefinitionSize1988), (&g_typeDefinitionSize1989), (&g_typeDefinitionSize1990), (&g_typeDefinitionSize1991), (&g_typeDefinitionSize1992), (&g_typeDefinitionSize1993), (&g_typeDefinitionSize1994), (&g_typeDefinitionSize1995), (&g_typeDefinitionSize1996), (&g_typeDefinitionSize1997), (&g_typeDefinitionSize1998), (&g_typeDefinitionSize1999), (&g_typeDefinitionSize2000), (&g_typeDefinitionSize2001), (&g_typeDefinitionSize2002), (&g_typeDefinitionSize2003), (&g_typeDefinitionSize2004), (&g_typeDefinitionSize2005), (&g_typeDefinitionSize2006), (&g_typeDefinitionSize2007), (&g_typeDefinitionSize2008), (&g_typeDefinitionSize2009), (&g_typeDefinitionSize2010), (&g_typeDefinitionSize2011), (&g_typeDefinitionSize2012), (&g_typeDefinitionSize2013), (&g_typeDefinitionSize2014), (&g_typeDefinitionSize2015), (&g_typeDefinitionSize2016), (&g_typeDefinitionSize2017), (&g_typeDefinitionSize2018), (&g_typeDefinitionSize2019), (&g_typeDefinitionSize2020), (&g_typeDefinitionSize2021), (&g_typeDefinitionSize2022), (&g_typeDefinitionSize2023), (&g_typeDefinitionSize2024), (&g_typeDefinitionSize2025), (&g_typeDefinitionSize2026), (&g_typeDefinitionSize2027), (&g_typeDefinitionSize2028), (&g_typeDefinitionSize2029), (&g_typeDefinitionSize2030), (&g_typeDefinitionSize2031), (&g_typeDefinitionSize2032), (&g_typeDefinitionSize2033), (&g_typeDefinitionSize2034), (&g_typeDefinitionSize2035), (&g_typeDefinitionSize2036), (&g_typeDefinitionSize2037), (&g_typeDefinitionSize2038), (&g_typeDefinitionSize2039), (&g_typeDefinitionSize2040), (&g_typeDefinitionSize2041), (&g_typeDefinitionSize2042), (&g_typeDefinitionSize2043), (&g_typeDefinitionSize2044), (&g_typeDefinitionSize2045), (&g_typeDefinitionSize2046), (&g_typeDefinitionSize2047), (&g_typeDefinitionSize2048), (&g_typeDefinitionSize2049), (&g_typeDefinitionSize2050), (&g_typeDefinitionSize2051), (&g_typeDefinitionSize2052), (&g_typeDefinitionSize2053), (&g_typeDefinitionSize2054), (&g_typeDefinitionSize2055), (&g_typeDefinitionSize2056), (&g_typeDefinitionSize2057), (&g_typeDefinitionSize2058), (&g_typeDefinitionSize2059), (&g_typeDefinitionSize2060), (&g_typeDefinitionSize2061), (&g_typeDefinitionSize2062), (&g_typeDefinitionSize2063), (&g_typeDefinitionSize2064), (&g_typeDefinitionSize2065), (&g_typeDefinitionSize2066), (&g_typeDefinitionSize2067), (&g_typeDefinitionSize2068), (&g_typeDefinitionSize2069), (&g_typeDefinitionSize2070), (&g_typeDefinitionSize2071), (&g_typeDefinitionSize2072), (&g_typeDefinitionSize2073), (&g_typeDefinitionSize2074), (&g_typeDefinitionSize2075), (&g_typeDefinitionSize2076), (&g_typeDefinitionSize2077), (&g_typeDefinitionSize2078), (&g_typeDefinitionSize2079), (&g_typeDefinitionSize2080), (&g_typeDefinitionSize2081), (&g_typeDefinitionSize2082), (&g_typeDefinitionSize2083), (&g_typeDefinitionSize2084), (&g_typeDefinitionSize2085), (&g_typeDefinitionSize2086), (&g_typeDefinitionSize2087), (&g_typeDefinitionSize2088), (&g_typeDefinitionSize2089), (&g_typeDefinitionSize2090), (&g_typeDefinitionSize2091), (&g_typeDefinitionSize2092), (&g_typeDefinitionSize2093), (&g_typeDefinitionSize2094), (&g_typeDefinitionSize2095), (&g_typeDefinitionSize2096), (&g_typeDefinitionSize2097), (&g_typeDefinitionSize2098), (&g_typeDefinitionSize2099), (&g_typeDefinitionSize2100), (&g_typeDefinitionSize2101), (&g_typeDefinitionSize2102), (&g_typeDefinitionSize2103), (&g_typeDefinitionSize2104), (&g_typeDefinitionSize2105), (&g_typeDefinitionSize2106), (&g_typeDefinitionSize2107), (&g_typeDefinitionSize2108), (&g_typeDefinitionSize2109), (&g_typeDefinitionSize2110), (&g_typeDefinitionSize2111), (&g_typeDefinitionSize2112), (&g_typeDefinitionSize2113), (&g_typeDefinitionSize2114), (&g_typeDefinitionSize2115), (&g_typeDefinitionSize2116), (&g_typeDefinitionSize2117), (&g_typeDefinitionSize2118), (&g_typeDefinitionSize2119), (&g_typeDefinitionSize2120), (&g_typeDefinitionSize2121), (&g_typeDefinitionSize2122), (&g_typeDefinitionSize2123), (&g_typeDefinitionSize2124), (&g_typeDefinitionSize2125), (&g_typeDefinitionSize2126), (&g_typeDefinitionSize2127), (&g_typeDefinitionSize2128), (&g_typeDefinitionSize2129), (&g_typeDefinitionSize2130), (&g_typeDefinitionSize2131), (&g_typeDefinitionSize2132), (&g_typeDefinitionSize2133), (&g_typeDefinitionSize2134), (&g_typeDefinitionSize2135), (&g_typeDefinitionSize2136), (&g_typeDefinitionSize2137), (&g_typeDefinitionSize2138), (&g_typeDefinitionSize2139), (&g_typeDefinitionSize2140), (&g_typeDefinitionSize2141), (&g_typeDefinitionSize2142), (&g_typeDefinitionSize2143), (&g_typeDefinitionSize2144), (&g_typeDefinitionSize2145), (&g_typeDefinitionSize2146), (&g_typeDefinitionSize2147), (&g_typeDefinitionSize2148), (&g_typeDefinitionSize2149), (&g_typeDefinitionSize2150), (&g_typeDefinitionSize2151), (&g_typeDefinitionSize2152), (&g_typeDefinitionSize2153), (&g_typeDefinitionSize2154), (&g_typeDefinitionSize2155), (&g_typeDefinitionSize2156), (&g_typeDefinitionSize2157), (&g_typeDefinitionSize2158), (&g_typeDefinitionSize2159), (&g_typeDefinitionSize2160), (&g_typeDefinitionSize2161), (&g_typeDefinitionSize2162), (&g_typeDefinitionSize2163), (&g_typeDefinitionSize2164), (&g_typeDefinitionSize2165), (&g_typeDefinitionSize2166), (&g_typeDefinitionSize2167), (&g_typeDefinitionSize2168), (&g_typeDefinitionSize2169), (&g_typeDefinitionSize2170), (&g_typeDefinitionSize2171), (&g_typeDefinitionSize2172), (&g_typeDefinitionSize2173), (&g_typeDefinitionSize2174), (&g_typeDefinitionSize2175), (&g_typeDefinitionSize2176), (&g_typeDefinitionSize2177), (&g_typeDefinitionSize2178), (&g_typeDefinitionSize2179), (&g_typeDefinitionSize2180), (&g_typeDefinitionSize2181), (&g_typeDefinitionSize2182), (&g_typeDefinitionSize2183), (&g_typeDefinitionSize2184), (&g_typeDefinitionSize2185), (&g_typeDefinitionSize2186), (&g_typeDefinitionSize2187), (&g_typeDefinitionSize2188), (&g_typeDefinitionSize2189), (&g_typeDefinitionSize2190), (&g_typeDefinitionSize2191), (&g_typeDefinitionSize2192), (&g_typeDefinitionSize2193), (&g_typeDefinitionSize2194), (&g_typeDefinitionSize2195), (&g_typeDefinitionSize2196), (&g_typeDefinitionSize2197), (&g_typeDefinitionSize2198), (&g_typeDefinitionSize2199), (&g_typeDefinitionSize2200), (&g_typeDefinitionSize2201), (&g_typeDefinitionSize2202), (&g_typeDefinitionSize2203), (&g_typeDefinitionSize2204), (&g_typeDefinitionSize2205), (&g_typeDefinitionSize2206), (&g_typeDefinitionSize2207), (&g_typeDefinitionSize2208), (&g_typeDefinitionSize2209), (&g_typeDefinitionSize2210), (&g_typeDefinitionSize2211), (&g_typeDefinitionSize2212), (&g_typeDefinitionSize2213), (&g_typeDefinitionSize2214), (&g_typeDefinitionSize2215), (&g_typeDefinitionSize2216), (&g_typeDefinitionSize2217), (&g_typeDefinitionSize2218), (&g_typeDefinitionSize2219), (&g_typeDefinitionSize2220), (&g_typeDefinitionSize2221), (&g_typeDefinitionSize2222), (&g_typeDefinitionSize2223), (&g_typeDefinitionSize2224), (&g_typeDefinitionSize2225), (&g_typeDefinitionSize2226), (&g_typeDefinitionSize2227), (&g_typeDefinitionSize2228), (&g_typeDefinitionSize2229), (&g_typeDefinitionSize2230), (&g_typeDefinitionSize2231), (&g_typeDefinitionSize2232), (&g_typeDefinitionSize2233), (&g_typeDefinitionSize2234), (&g_typeDefinitionSize2235), (&g_typeDefinitionSize2236), (&g_typeDefinitionSize2237), (&g_typeDefinitionSize2238), (&g_typeDefinitionSize2239), (&g_typeDefinitionSize2240), (&g_typeDefinitionSize2241), (&g_typeDefinitionSize2242), (&g_typeDefinitionSize2243), (&g_typeDefinitionSize2244), (&g_typeDefinitionSize2245), (&g_typeDefinitionSize2246), (&g_typeDefinitionSize2247), (&g_typeDefinitionSize2248), (&g_typeDefinitionSize2249), (&g_typeDefinitionSize2250), (&g_typeDefinitionSize2251), (&g_typeDefinitionSize2252), (&g_typeDefinitionSize2253), (&g_typeDefinitionSize2254), (&g_typeDefinitionSize2255), (&g_typeDefinitionSize2256), (&g_typeDefinitionSize2257), (&g_typeDefinitionSize2258), (&g_typeDefinitionSize2259), (&g_typeDefinitionSize2260), (&g_typeDefinitionSize2261), (&g_typeDefinitionSize2262), (&g_typeDefinitionSize2263), (&g_typeDefinitionSize2264), (&g_typeDefinitionSize2265), (&g_typeDefinitionSize2266), (&g_typeDefinitionSize2267), (&g_typeDefinitionSize2268), (&g_typeDefinitionSize2269), (&g_typeDefinitionSize2270), (&g_typeDefinitionSize2271), (&g_typeDefinitionSize2272), (&g_typeDefinitionSize2273), (&g_typeDefinitionSize2274), (&g_typeDefinitionSize2275), (&g_typeDefinitionSize2276), (&g_typeDefinitionSize2277), (&g_typeDefinitionSize2278), (&g_typeDefinitionSize2279), (&g_typeDefinitionSize2280), (&g_typeDefinitionSize2281), (&g_typeDefinitionSize2282), (&g_typeDefinitionSize2283), (&g_typeDefinitionSize2284), (&g_typeDefinitionSize2285), (&g_typeDefinitionSize2286), (&g_typeDefinitionSize2287), (&g_typeDefinitionSize2288), (&g_typeDefinitionSize2289), (&g_typeDefinitionSize2290), (&g_typeDefinitionSize2291), (&g_typeDefinitionSize2292), (&g_typeDefinitionSize2293), (&g_typeDefinitionSize2294), (&g_typeDefinitionSize2295), (&g_typeDefinitionSize2296), (&g_typeDefinitionSize2297), (&g_typeDefinitionSize2298), (&g_typeDefinitionSize2299), (&g_typeDefinitionSize2300), (&g_typeDefinitionSize2301), (&g_typeDefinitionSize2302), (&g_typeDefinitionSize2303), (&g_typeDefinitionSize2304), (&g_typeDefinitionSize2305), (&g_typeDefinitionSize2306), (&g_typeDefinitionSize2307), (&g_typeDefinitionSize2308), (&g_typeDefinitionSize2309), (&g_typeDefinitionSize2310), (&g_typeDefinitionSize2311), (&g_typeDefinitionSize2312), (&g_typeDefinitionSize2313), (&g_typeDefinitionSize2314), (&g_typeDefinitionSize2315), (&g_typeDefinitionSize2316), (&g_typeDefinitionSize2317), };
#include <string> using namespace std; class Solution { public: string interpret(string command) { string parser = ""; for (int i = 0; i < command.size(); i++) { if (command[i] == '(') { if (command[i + 1] == ')') { parser += "o"; i++; } else { parser += "al"; i += 3; } } else { parser += command[i]; } } return parser; } };
/* Demone che gestisce l'inserimento in coda dei messaggi */ #include <iostream> #include "class/bot.class.h" using namespace std; // Cosa fa : Estrapola le richieste (messaggi) inviati al bot e le aggiunge in coda int main(){ string sJson; Bot *oBot = new Bot(); bool bRet; while(true){ cout << "Aggiorno..." << endl; bRet = oBot->updateQueue(); if(bRet == false){ cout << "Errore durante l'aggiornamento!" << endl; }else{ cout << "Aggiornato!" << endl; } cout << "Vado in pausa per 3 secondi..." << endl; sleep(3); } delete oBot; return 0; }
#include "DetectorDescription/Core/interface/DDExpandedView.h" #include <memory> #include <ostream> #include "DetectorDescription/Core/interface/DDComparator.h" #include "DetectorDescription/Core/interface/DDLogicalPart.h" #include "DetectorDescription/Core/interface/DDPosData.h" #include "DataFormats/Math/interface/Graph.h" #include "DataFormats/Math/interface/GraphWalker.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Math/GenVector/Cartesian3D.h" #include "Math/GenVector/DisplacementVector3D.h" #include "Math/GenVector/Rotation3D.h" class DDPartSelection; /** After construction the instance corresponds to the root of the geometrical tree. */ DDExpandedView::DDExpandedView(const DDCompactView& cpv) : walker_(nullptr), w2_(cpv.graph(), cpv.root()), trans_(DDTranslation()), rot_(DDRotationMatrix()), depth_(0), worldpos_(cpv.worldPosition()) { walker_ = &w2_; const DDPosData* pd((*walker_).current().second); if (!pd) pd = worldpos_; DDExpandedNode expn((*walker_).current().first, pd, trans_, rot_, 0); // starting point for position calculations, == root of expanded view history_.emplace_back(expn); } DDExpandedView::~DDExpandedView() {} const DDLogicalPart& DDExpandedView::logicalPart() const { return history_.back().logp_; } const DDTranslation& DDExpandedView::translation() const { return history_.back().trans_; } const DDRotationMatrix& DDExpandedView::rotation() const { return history_.back().rot_; } const DDGeoHistory& DDExpandedView::geoHistory() const { return history_; } int DDExpandedView::depth() const { return depth_; } int DDExpandedView::copyno() const { return history_.back().copyno(); } /** returns true, if a next sibling exists and updates \c this otherwise returns false. If a scope was set, the nextSibling of the root of the scope is not selected. */ bool DDExpandedView::nextSibling() { bool result(false); if (!scope_.empty() && history_.back() == scope_.back()) { ; // no-next-sibling, if current node is the root of the scope! } else { if ((*walker_).nextSibling()) { DDExpandedNode& expn(history_.back()); // back of history_ is always current node WalkerType::value_type curr = (*walker_).current(); DDPosData const* posdOld = expn.posd_; expn.logp_ = curr.first; expn.posd_ = curr.second; DDGeoHistory::size_type hsize = history_.size(); if (hsize > 1) { const DDExpandedNode& expnBefore(history_[hsize - 2]); // T = T1 + INV[R1] * T2 expn.trans_ = expnBefore.trans_ + (expnBefore.rot_ * expn.posd_->trans()); // R = R1*INV[R2] // VI in principle we can do this if (!(expn.posd_->rot() == posdOld->rot())) { expn.rot_ = expnBefore.rot_ * expn.posd_->rot(); //.inverse(); } } else { expn.trans_ = expn.posd_->trans(); expn.rot_ = expn.posd_->rot(); //.inverse(); } ++expn.siblingno_; result = true; } } return result; } /** returns true, if a child of the current node exists and updates \c this otherwise returns false */ bool DDExpandedView::firstChild() { bool result(false); bool depthNotReached(true); // Check for the depth within the scope ... if (depth_) { if ((history_.size() - scope_.size()) == depth_) { depthNotReached = false; } } if (depthNotReached) { if ((*walker_).firstChild()) { DDExpandedNode& expnBefore(history_.back()); WalkerType::value_type curr = (*walker_).current(); DDPosData* newPosd = curr.second; // T = ... (see nextSiblinig()) DDTranslation newTrans = expnBefore.trans_ + expnBefore.rot_ * newPosd->trans(); // R = ... (see nextSibling()) DDRotationMatrix newRot = expnBefore.rot_ * newPosd->rot(); //.inverse(); // create a new Expanded node and push it to the history ... DDExpandedNode expn(curr.first, curr.second, newTrans, newRot, 0); history_.emplace_back(expn); result = true; } // if firstChild } // if depthNotReached return result; } /** returns ture, if a parent exists and updates \c this otherwise returns false. When false is returned, the root node of the scope is reached. */ bool DDExpandedView::parent() { bool result(false); bool scopeRoot(false); // check for a scope if (!scope_.empty()) { if (scope_.back() == history_.back()) { // the current node is the root of the scope scopeRoot = true; } } if (!scopeRoot) { if ((*walker_).parent()) { history_.pop_back(); result = true; } } return result; } // same implementation as in GraphWalker ! /** Tree transversal: - try to go to the first child - else try to go to the next sibling - else try to go to the next sibling of the parent Currently the whole remaining subtree is transversed when next() is subsequently called. \todo stop, when subtree down a specified node has been transversed */ bool DDExpandedView::next() { bool res(false); if (firstChild()) res = true; else if (nextSibling()) res = true; else { while (parent()) { if (nextSibling()) { res = true; break; } } } return res; } /** broad first */ bool DDExpandedView::nextB() { bool res(false); return res; } void dump(const DDGeoHistory& history) { edm::LogInfo("DDExpandedView") << "--GeoHistory-Dump--[" << std::endl; int i = 0; for (const auto& it : history) { edm::LogInfo("DDExpandedView") << " " << i << it.logicalPart() << std::endl; ++i; } edm::LogInfo("DDExpandedView") << "]---------" << std::endl; } /** User specific data can be attached to single nodes or a selection of nodes in the expanded view through the DDSpecifics interface. The resulting std::vector is of size 0 if no specific data was attached. */ std::vector<const DDsvalues_type*> DDExpandedView::specifics() const { // backward compatible std::vector<const DDsvalues_type*> result; specificsV(result); return result; } void DDExpandedView::specificsV(std::vector<const DDsvalues_type*>& result) const { const auto& specs = logicalPart().attachedSpecifics(); if (!specs.empty()) { result.reserve(specs.size()); for (const auto& it : specs) { // a part selection const DDPartSelection& psel = *(it.first); const DDGeoHistory& hist = geoHistory(); if (DDCompareEqual(hist, psel)()) result.emplace_back(it.second); } } } DDsvalues_type DDExpandedView::mergedSpecifics() const { DDsvalues_type merged; mergedSpecificsV(merged); return merged; } void DDExpandedView::mergedSpecificsV(DDsvalues_type& merged) const { merged.clear(); const auto& specs = logicalPart().attachedSpecifics(); if (specs.empty()) return; const DDGeoHistory& hist = geoHistory(); for (const auto& it : specs) { if (DDCompareEqual(hist, *it.first)()) merge(merged, *it.second); } } /** All navigational commands only operate in the subtree rooted by the node marked by the node of the DDGeoHistory returned by this method. If the size() of the scope equals 0, the full scope covering the whole expanded-view is set (default). */ const DDGeoHistory& DDExpandedView::scope() const { return scope_; } void DDExpandedView::clearScope() { scope_.clear(); depth_ = 0; } void DDExpandedView::reset() { clearScope(); while (parent()) ; } /** The scope of the expanded-view is set to the subtree rooted by the node marked by the DDGeohistory hist. The current not of the expanded view is set to the root of the subtree. All navigational methods apply only on the subtree. In case of hist not marking a valid node in the expanded-view, the state of the expanded-view is unchanged and false is returned by setScope(). Otherwise true is returned. */ bool DDExpandedView::setScope(const DDGeoHistory& sc, int depth) { bool result(false); DDGeoHistory buf = scope_; // save current scope scope_.clear(); // sets scope to global (full) scope while (parent()) ; // move up to the root of the expanded-view if (descend(sc)) { // try to move down the given scope-history ... scope_ = sc; depth_ = depth; result = true; } else { scope_ = buf; } return result; } /** goTo will reset the ExpandedView if pos is not a valid position. Currently no checks are implemented to verify that pos is within the current scope of the ExpandedView. \todo check whether pos is in the current scope */ bool DDExpandedView::goToHistory(const DDGeoHistory& pos) { bool result = true; int tempD = depth_; DDGeoHistory tempScope = scope_; reset(); DDGeoHistory::size_type s = pos.size(); for (DDGeoHistory::size_type j = 1; j < s; ++j) { if (!firstChild()) { result = false; break; } int i = 0; for (; i < pos[j].siblingno(); ++i) { if (!nextSibling()) { result = false; } } } if (!result) { reset(); setScope(tempScope, tempD); } else { scope_ = tempScope; depth_ = tempD; } return result; } //! \todo implement it simpler using DDExpandedNode::siblingno() bool DDExpandedView::descend(const DDGeoHistory& sc) { DDGeoHistory::size_type mxx = sc.size(); DDGeoHistory::size_type cur = 0; bool result(false); /* algo: compare currerent node in expanded-view with current-node in sc if matching: (A)go to first child in expanded-view, go one level deeper in sc iterate over all children in expanded-view until one of them matches the current node in sc. if no one matches, return false else continue at (A) else return false */ const DDExpandedNode& curNode = history_.back(); if (!sc.empty()) { if (curNode == sc[cur]) { bool res(false); while (cur + 1 < mxx && firstChild()) { ++cur; if (!(history_.back() == sc[cur])) { while (nextSibling()) { if (history_.back() == sc[cur]) { res = true; break; } } } else { res = true; } if (res == false) break; } result = res; } } return result; } bool DDExpandedView::goTo(const nav_type& newpos) { return goTo(&newpos.front(), newpos.size()); } bool DDExpandedView::goTo(NavRange newpos) { return goTo(newpos.first, newpos.second); } bool DDExpandedView::goTo(int const* newpos, size_t sz) { bool result(false); // save the current position DDGeoHistory savedPos = history_; // reset to root node //FIXME: reset to root of scope!! reset(); // try to navigate down to the newpos for (size_t i = 1; i < sz; ++i) { result = firstChild(); if (result) { int pos = newpos[i]; for (int k = 0; k < pos; ++k) { result = nextSibling(); } } else { break; } } if (!result) { goToHistory(savedPos); } return result; } DDExpandedView::nav_type DDExpandedView::navPos() const { DDGeoHistory::size_type i = 0; DDGeoHistory::size_type j = history_.size(); nav_type pos(j); for (; i < j; ++i) pos[i] = history_[i].siblingno(); return pos; } DDExpandedView::nav_type DDExpandedView::copyNumbers() const { DDGeoHistory::size_type it = 0; DDGeoHistory::size_type sz = history_.size(); nav_type result(sz); for (; it < sz; ++it) { result[it] = history_[it].copyno(); } return result; } std::string printNavType(int const* n, size_t sz) { std::ostringstream oss; oss << '('; for (int const* it = n; it != n + sz; ++it) { oss << *it << ','; } oss << ')'; return oss.str(); }
//------------------------------------------------------------------------------ // This code was generated by a tool. // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. //------------------------------------------------------------------------------ #include "pch.h" #include "App.xaml.h" #if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); #endif #if (defined(_M_IX86) || defined(_M_AMD64)) && !defined(_VSDESIGNER_DONT_LOAD_AS_DLL) #if defined(_M_IX86) #pragma comment(linker, "/EXPORT:DllGetActivationFactory=_DllGetActivationFactory@8,PRIVATE") #pragma comment(linker, "/EXPORT:DllCanUnloadNow=_DllCanUnloadNow@0,PRIVATE") #pragma comment(linker, "/EXPORT:VSDesignerDllMain=_VSDesignerDllMain@12,PRIVATE") #pragma comment(linker, "/INCLUDE:___refMTAThread") #elif defined(_M_AMD64) #pragma comment(linker, "/EXPORT:DllGetActivationFactory=DllGetActivationFactory,PRIVATE") #pragma comment(linker, "/EXPORT:DllCanUnloadNow,PRIVATE") #pragma comment(linker, "/EXPORT:VSDesignerDllMain,PRIVATE") #pragma comment(linker, "/INCLUDE:__refMTAThread") #endif extern int __abi___threading_model; extern "C" { int __stdcall _DllMainCRTStartup(void* hinstDLL, unsigned long fdwReason, void** lpvReserved); int __stdcall VSDesignerDllMain(void* hinstDLL, unsigned long fdwReason, void** lpvReserved) { __abi___threading_model = _VCCORLIB_THREADING_MODEL_OVERRIDE; return _DllMainCRTStartup(hinstDLL, fdwReason, lpvReserved); } } #endif // (defined(_M_IX86) || defined(_M_AMD64)) && !defined(_VSDESIGNER_DONT_LOAD_AS_DLL) void ::JsRT_UWP_Sample::App::InitializeComponent() { #if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION UnhandledException += ref new ::Windows::UI::Xaml::UnhandledExceptionEventHandler( [](::Platform::Object^ sender, ::Windows::UI::Xaml::UnhandledExceptionEventArgs^ e) { (void)sender; // Unused parameter if (IsDebuggerPresent()) { ::Platform::String^ errorMessage = e->Message; __debugbreak(); } }); #endif } ::Windows::UI::Xaml::Markup::IXamlType^ ::JsRT_UWP_Sample::App::GetXamlType(::Windows::UI::Xaml::Interop::TypeName type) { if(_provider == nullptr) { _provider = ref new XamlTypeInfo::InfoProvider::XamlTypeInfoProvider(); } return _provider->GetXamlTypeByType(type); } ::Windows::UI::Xaml::Markup::IXamlType^ ::JsRT_UWP_Sample::App::GetXamlType(::Platform::String^ fullName) { if(_provider == nullptr) { _provider = ref new XamlTypeInfo::InfoProvider::XamlTypeInfoProvider(); } return _provider->GetXamlTypeByName(fullName); } ::Platform::Array<::Windows::UI::Xaml::Markup::XmlnsDefinition>^ ::JsRT_UWP_Sample::App::GetXmlnsDefinitions() { return ref new ::Platform::Array<::Windows::UI::Xaml::Markup::XmlnsDefinition>(0); } #ifndef DISABLE_XAML_GENERATED_MAIN int __cdecl main(::Platform::Array<::Platform::String^>^ args) { (void)args; // Unused parameter ::Windows::UI::Xaml::Application::Start(ref new ::Windows::UI::Xaml::ApplicationInitializationCallback( [](::Windows::UI::Xaml::ApplicationInitializationCallbackParams^ p) { (void)p; // Unused parameter auto app = ref new ::JsRT_UWP_Sample::App(); })); } #endif
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* This file is part of the library KASKADE 7 */ /* see http://www.zib.de/projects/kaskade7-finite-element-toolbox */ /* */ /* Copyright (C) 2012 Zuse Institute Berlin */ /* */ /* KASKADE 7 is distributed under the terms of the ZIB Academic License. */ /* see $KASKADE/academic.txt */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifndef TCG_HH #define TCG_HH #include <numeric> #include <boost/circular_buffer.hpp> #include "dune/common/timer.hh" #include "dune/istl/istlexception.hh" #include "dune/istl/operators.hh" #include "dune/istl/preconditioners.hh" #include "dune/istl/scalarproducts.hh" #include "dune/istl/solvers.hh" #include "utilities/geometric_sequence.hh" #include "utilities/scalar.hh" #include "utilities/duneInterface.hh" #include "linalg/apcg.hh" namespace Kaskade { struct NoRegularization { template <class X, class Xstar> void operator()(const X&, Xstar&){} }; template <class Linearization, class VariableSet> struct DoRegularization { DoRegularization(Linearization const& lin_, typename VariableSet::Descriptions const& description) : lin(lin_), v(description) {} template <class X, class Xstar> void operator()(const X& x, Xstar& r) { v = x; // Bridge::Vector<VariableSet> y(v), z(v); y *= 0; lin.ddxpy(y,z,0,2,2,3); y *= -1; v = r; // boost::fusion::at_c<0>(v.data) += boost::fusion::at_c<0>(y.get().data); boost::fusion::at_c<1>(v.data) += boost::fusion::at_c<1>(y.get().data); r = v; // } private: Linearization const& lin; VariableSet v; }; /** * \ingroup linalgsolution * \brief preconditioned conjugate gradient method * * This implements a preconditioned IterateType::CG iteration for an operator \f$ A: X\to x^* \f$, preconditioned by a * preconditioner \f$ B^{-1}: X^* \to X \f$. The termination is based on an estimate of the absolute energy error. * * The implementation follows Deuflhard/Weiser, Section 5.3.3. * */ template<class X, class Xstar, class Regularization=NoRegularization> class TCG : public Dune::InverseOperator<X,Xstar> { public: enum class Result { Converged, Failed, EncounteredNonConvexity }; /** * \brief the real field type corresponding to X::field_type */ typedef typename ScalarTraits<typename GetScalar<X>::type >::Real Real; /** * \brief Set up conjugate gradient solver with absolute energy error termination criterion. * * \param verbose */ template <class Int=int, class enable = typename std::enable_if<!std::is_same<Regularization,NoRegularization>::value && std::is_same<Int,int>::value>::type> TCG(Dune::LinearOperator<X,Xstar>& op_, Dune::Preconditioner<X,Xstar>& prec_, DualPairing<X,Xstar> const& dp_, Regularization& regularization_, double relTol_=1e-3, size_t maxSteps_=100, Int verbose_=0) : op(op_), prec(prec_), dp(dp_), regularization(regularization_), relTol(relTol_), absTol(1e-9), maxSteps(maxSteps_), verbose(verbose_) { // Do we need this in Kaskade7? // dune_static_assert( static_cast<int>(L::category) == static_cast<int>(P::category), // "L and P must have the same category!"); // dune_static_assert( static_cast<int>(L::category) == static_cast<int>(SolverCategory::sequential), // "L must be sequential!"); } /** * \brief Set up conjugate gradient solver with absolute energy error termination criterion. * * \param verbose */ template <class Int=int, class enable = typename std::enable_if<std::is_same<Regularization,NoRegularization>::value && std::is_same<Int,int>::value>::type> TCG(Dune::LinearOperator<X,Xstar>& op_, Dune::Preconditioner<X,Xstar>& prec_, DualPairing<X,Xstar> const& dp_, double relTol_=1e-3, size_t maxSteps_=100, Int verbose_=0) : op(op_), prec(prec_), dp(dp_), relTol(relTol_), absTol(1e-9), maxSteps(maxSteps_), verbose(verbose_) { // Do we need this in Kaskade7? // dune_static_assert( static_cast<int>(L::category) == static_cast<int>(P::category), // "L and P must have the same category!"); // dune_static_assert( static_cast<int>(L::category) == static_cast<int>(SolverCategory::sequential), // "L must be sequential!"); } /** * \brief Apply inverse operator. * * \param u the initial value (starting iterate) * \param b the right hand side */ virtual int apply (X& u, X& q, Xstar& b, Dune::InverseOperatorResult& res) { result = Result::Failed; int numberOfResults = 1; res.clear(); // clear solver statistics //terminate.clear(); // clear termination criterion Dune::Timer watch; // start a timer prec.pre(u,b); Xstar r(b); op.applyscaleadd(-1.0,u,r); // r = b-Au regularization(u,r); X rq(u), du(u); rq = 0; prec.apply(rq,r); // rq = B^{-1} r q = rq; X Aq(b); // some local variables Real alpha,beta,sigma,gamma; sigma = dp(rq,r); // preconditioned residual norm squared //terminate.residual(sigma); double const sigma0 = std::abs(sigma); if (verbose>0) { // printing std::cout << "=== Kaskade7 TCG" << std::endl; if (verbose>1) { this->printHeader(std::cout); this->printOutput(std::cout,0,sigma0); } } // the loop int i=0; while(true) { ++i; // minimize in given search direction p op.apply(q,Aq); // h = Aq Real qAq = dp(q,Aq); if(qAq <=0) { result = Result::EncounteredNonConvexity; if(verbose > 0) std::cout << "Nonconvexity at iteration " << i << ", qAq=" << qAq << ", ||q||=" << sqrt(q*q) << std::endl; if(i==1) { u.axpy(1.0,q); break; } numberOfResults = 2; break; // Abbruch wg. fehlender Konvexität } alpha = sigma/qAq; u.axpy(alpha,q); du = q; du *= 1./alpha; if(dp(du,du) < absTol) { result = Result::Converged; break; } gamma = sigma*alpha; //terminate.step(ScalarTraits<Real>::real(gamma)); resDebug.push_back(std::sqrt(sigma)); // convergence test //if (terminate) //break; r.axpy(-alpha,Aq); // r = r - alpha*A*q regularization(u,r); rq = 0; prec.apply(rq,r); // rq = B^{-1}r // determine new search direction double sigmaNew = dp(rq,r); //terminate.residual(ScalarTraits<Real>::real(sigmaNew)); if (verbose>1) // print this->printOutput(std::cout,i,std::abs(sigmaNew),std::abs(sigma)); // convergence check to prevent division by zero if we obtained an exact solution // (which may happen for low dimensional systems) if (std::abs(sigmaNew) < relTol*sigma0) { result = Result::Converged; break; } beta = sigmaNew/sigma; if(verbose > 0) std::cout << "step reduction: " << (sigmaNew/sigma) << ", overall reduction: " << (sigmaNew/sigma0) << std::endl; sigma = sigmaNew; q *= beta; // scale old search direction q += rq; // orthogonalization with correction if(i > maxSteps) break; } res.iterations = i; // fill statistics res.reduction = std::sqrt(std::abs(sigma)/sigma0); res.conv_rate = pow(res.reduction,1.0/i); res.elapsed = watch.elapsed(); if (verbose>0) // final print { std::cout << "=== rate=" << res.conv_rate << ", time=" << res.elapsed << ", iterations=" << i << std::endl; } prec.post(u); return numberOfResults; } /** * \brief Apply tcg and possibly forget second descent direction */ virtual void apply (X& u, Xstar& b, Dune::InverseOperatorResult& res) { X q(u); apply(u,q,b,res); } void apply (X& u, Xstar& b) { Dune::InverseOperatorResult res; apply(u,b,res); } /** * \brief Apply inverse operator with given absolute tolerance. */ virtual void apply (X& x, X& b, double relTol, Dune::InverseOperatorResult& res) { //terminate.relTol(relTol); (*this).apply(x,b,res); } void setRelativeAccuracy(double relTol_) { relTol = relTol_; } void setMaxSteps(size_t maxSteps_) { maxSteps = maxSteps_; } bool localConvergenceLikely() const { return result == Result::Converged; } bool encounteredNonConvexity() const { return result == Result::EncounteredNonConvexity; } private: Dune::LinearOperator<X,Xstar>& op; Dune::Preconditioner<X,Xstar>& prec; DualPairing<X,Xstar> const& dp; typename std::conditional<std::is_same<Regularization,NoRegularization>::value,NoRegularization,Regularization&>::type regularization; double relTol, absTol; size_t maxSteps; int verbose; std::vector<double> resDebug; Result result; }; template <class X, class Xstar, class Regularization = NoRegularization> using TPCG = TCG<X,Xstar,Regularization>; } // namespace Kaskade #endif
/* * * Copyright 2019 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include "src/core/ext/filters/client_channel/service_config.h" #include <gmock/gmock.h> #include <gtest/gtest.h> #include "absl/strings/str_cat.h" #include <grpc/grpc.h> #include "src/core/ext/filters/client_channel/resolver_result_parsing.h" #include "src/core/ext/filters/client_channel/retry_service_config.h" #include "src/core/ext/filters/client_channel/service_config_parser.h" #include "src/core/ext/filters/message_size/message_size_filter.h" #include "src/core/lib/gpr/string.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" namespace grpc_core { namespace testing { // // ServiceConfig tests // // Set this channel arg to true to disable parsing. #define GRPC_ARG_DISABLE_PARSING "disable_parsing" // A regular expression to enter referenced or child errors. #ifdef GRPC_ERROR_IS_ABSEIL_STATUS #define CHILD_ERROR_TAG ".*children.*" #else #define CHILD_ERROR_TAG ".*referenced_errors.*" #endif class TestParsedConfig1 : public ServiceConfigParser::ParsedConfig { public: explicit TestParsedConfig1(int value) : value_(value) {} int value() const { return value_; } private: int value_; }; class TestParser1 : public ServiceConfigParser::Parser { public: std::unique_ptr<ServiceConfigParser::ParsedConfig> ParseGlobalParams( const grpc_channel_args* args, const Json& json, grpc_error_handle* error) override { GPR_DEBUG_ASSERT(error != nullptr); if (grpc_channel_args_find_bool(args, GRPC_ARG_DISABLE_PARSING, false)) { return nullptr; } auto it = json.object_value().find("global_param"); if (it != json.object_value().end()) { if (it->second.type() != Json::Type::NUMBER) { *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(InvalidTypeErrorMessage()); return nullptr; } int value = gpr_parse_nonnegative_int(it->second.string_value().c_str()); if (value == -1) { *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(InvalidValueErrorMessage()); return nullptr; } return absl::make_unique<TestParsedConfig1>(value); } return nullptr; } static const char* InvalidTypeErrorMessage() { return "global_param value type should be a number"; } static const char* InvalidValueErrorMessage() { return "global_param value type should be non-negative"; } }; class TestParser2 : public ServiceConfigParser::Parser { public: std::unique_ptr<ServiceConfigParser::ParsedConfig> ParsePerMethodParams( const grpc_channel_args* args, const Json& json, grpc_error_handle* error) override { GPR_DEBUG_ASSERT(error != nullptr); if (grpc_channel_args_find_bool(args, GRPC_ARG_DISABLE_PARSING, false)) { return nullptr; } auto it = json.object_value().find("method_param"); if (it != json.object_value().end()) { if (it->second.type() != Json::Type::NUMBER) { *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(InvalidTypeErrorMessage()); return nullptr; } int value = gpr_parse_nonnegative_int(it->second.string_value().c_str()); if (value == -1) { *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(InvalidValueErrorMessage()); return nullptr; } return absl::make_unique<TestParsedConfig1>(value); } return nullptr; } static const char* InvalidTypeErrorMessage() { return "method_param value type should be a number"; } static const char* InvalidValueErrorMessage() { return "method_param value type should be non-negative"; } }; // This parser always adds errors class ErrorParser : public ServiceConfigParser::Parser { public: std::unique_ptr<ServiceConfigParser::ParsedConfig> ParsePerMethodParams( const grpc_channel_args* /*arg*/, const Json& /*json*/, grpc_error_handle* error) override { GPR_DEBUG_ASSERT(error != nullptr); *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(MethodError()); return nullptr; } std::unique_ptr<ServiceConfigParser::ParsedConfig> ParseGlobalParams( const grpc_channel_args* /*arg*/, const Json& /*json*/, grpc_error_handle* error) override { GPR_DEBUG_ASSERT(error != nullptr); *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(GlobalError()); return nullptr; } static const char* MethodError() { return "ErrorParser : methodError"; } static const char* GlobalError() { return "ErrorParser : globalError"; } }; class ServiceConfigTest : public ::testing::Test { protected: void SetUp() override { ServiceConfigParser::Shutdown(); ServiceConfigParser::Init(); EXPECT_EQ( ServiceConfigParser::RegisterParser(absl::make_unique<TestParser1>()), 0); EXPECT_EQ( ServiceConfigParser::RegisterParser(absl::make_unique<TestParser2>()), 1); } }; TEST_F(ServiceConfigTest, ErrorCheck1) { const char* test_json = ""; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex("JSON parse error")); GRPC_ERROR_UNREF(error); } TEST_F(ServiceConfigTest, BasicTest1) { const char* test_json = "{}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); } TEST_F(ServiceConfigTest, SkipMethodConfigWithNoNameOrEmptyName) { const char* test_json = "{\"methodConfig\": [" " {\"method_param\":1}," " {\"name\":[], \"method_param\":1}," " {\"name\":[{\"service\":\"TestServ\"}], \"method_param\":2}" "]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); ASSERT_NE(vector_ptr, nullptr); auto parsed_config = ((*vector_ptr)[1]).get(); EXPECT_EQ(static_cast<TestParsedConfig1*>(parsed_config)->value(), 2); } TEST_F(ServiceConfigTest, ErrorDuplicateMethodConfigNames) { const char* test_json = "{\"methodConfig\": [" " {\"name\":[{\"service\":\"TestServ\"}]}," " {\"name\":[{\"service\":\"TestServ\"}]}" "]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "multiple method configs with same name")); GRPC_ERROR_UNREF(error); } TEST_F(ServiceConfigTest, ErrorDuplicateMethodConfigNamesWithNullMethod) { const char* test_json = "{\"methodConfig\": [" " {\"name\":[{\"service\":\"TestServ\",\"method\":null}]}," " {\"name\":[{\"service\":\"TestServ\"}]}" "]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "multiple method configs with same name")); GRPC_ERROR_UNREF(error); } TEST_F(ServiceConfigTest, ErrorDuplicateMethodConfigNamesWithEmptyMethod) { const char* test_json = "{\"methodConfig\": [" " {\"name\":[{\"service\":\"TestServ\",\"method\":\"\"}]}," " {\"name\":[{\"service\":\"TestServ\"}]}" "]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "multiple method configs with same name")); GRPC_ERROR_UNREF(error); } TEST_F(ServiceConfigTest, ErrorDuplicateDefaultMethodConfigs) { const char* test_json = "{\"methodConfig\": [" " {\"name\":[{}]}," " {\"name\":[{}]}" "]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "multiple default method configs")); GRPC_ERROR_UNREF(error); } TEST_F(ServiceConfigTest, ErrorDuplicateDefaultMethodConfigsWithNullService) { const char* test_json = "{\"methodConfig\": [" " {\"name\":[{\"service\":null}]}," " {\"name\":[{}]}" "]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "multiple default method configs")); GRPC_ERROR_UNREF(error); } TEST_F(ServiceConfigTest, ErrorDuplicateDefaultMethodConfigsWithEmptyService) { const char* test_json = "{\"methodConfig\": [" " {\"name\":[{\"service\":\"\"}]}," " {\"name\":[{}]}" "]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "multiple default method configs")); GRPC_ERROR_UNREF(error); } TEST_F(ServiceConfigTest, ValidMethodConfig) { const char* test_json = "{\"methodConfig\": [{\"name\":[{\"service\":\"TestServ\"}]}]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); } TEST_F(ServiceConfigTest, Parser1BasicTest1) { const char* test_json = "{\"global_param\":5}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); EXPECT_EQ((static_cast<TestParsedConfig1*>(svc_cfg->GetGlobalParsedConfig(0))) ->value(), 5); EXPECT_EQ(svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")), nullptr); } TEST_F(ServiceConfigTest, Parser1BasicTest2) { const char* test_json = "{\"global_param\":1000}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); EXPECT_EQ((static_cast<TestParsedConfig1*>(svc_cfg->GetGlobalParsedConfig(0))) ->value(), 1000); } TEST_F(ServiceConfigTest, Parser1DisabledViaChannelArg) { grpc_arg arg = grpc_channel_arg_integer_create( const_cast<char*>(GRPC_ARG_DISABLE_PARSING), 1); grpc_channel_args args = {1, &arg}; const char* test_json = "{\"global_param\":5}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(&args, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); EXPECT_EQ(svc_cfg->GetGlobalParsedConfig(0), nullptr); } TEST_F(ServiceConfigTest, Parser1ErrorInvalidType) { const char* test_json = "{\"global_param\":\"5\"}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( absl::StrCat("Service config parsing error" CHILD_ERROR_TAG "Global Params" CHILD_ERROR_TAG, TestParser1::InvalidTypeErrorMessage()))); GRPC_ERROR_UNREF(error); } TEST_F(ServiceConfigTest, Parser1ErrorInvalidValue) { const char* test_json = "{\"global_param\":-5}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( absl::StrCat("Service config parsing error" CHILD_ERROR_TAG "Global Params" CHILD_ERROR_TAG, TestParser1::InvalidValueErrorMessage()))); GRPC_ERROR_UNREF(error); } TEST_F(ServiceConfigTest, Parser2BasicTest) { const char* test_json = "{\"methodConfig\": [{\"name\":[{\"service\":\"TestServ\"}], " "\"method_param\":5}]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); ASSERT_NE(vector_ptr, nullptr); auto parsed_config = ((*vector_ptr)[1]).get(); EXPECT_EQ(static_cast<TestParsedConfig1*>(parsed_config)->value(), 5); } TEST_F(ServiceConfigTest, Parser2DisabledViaChannelArg) { grpc_arg arg = grpc_channel_arg_integer_create( const_cast<char*>(GRPC_ARG_DISABLE_PARSING), 1); grpc_channel_args args = {1, &arg}; const char* test_json = "{\"methodConfig\": [{\"name\":[{\"service\":\"TestServ\"}], " "\"method_param\":5}]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(&args, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); ASSERT_NE(vector_ptr, nullptr); auto parsed_config = ((*vector_ptr)[1]).get(); EXPECT_EQ(parsed_config, nullptr); } TEST_F(ServiceConfigTest, Parser2ErrorInvalidType) { const char* test_json = "{\"methodConfig\": [{\"name\":[{\"service\":\"TestServ\"}], " "\"method_param\":\"5\"}]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT( grpc_error_std_string(error), ::testing::ContainsRegex(absl::StrCat( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG, TestParser2::InvalidTypeErrorMessage()))); GRPC_ERROR_UNREF(error); } TEST_F(ServiceConfigTest, Parser2ErrorInvalidValue) { const char* test_json = "{\"methodConfig\": [{\"name\":[{\"service\":\"TestServ\"}], " "\"method_param\":-5}]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT( grpc_error_std_string(error), ::testing::ContainsRegex(absl::StrCat( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG, TestParser2::InvalidValueErrorMessage()))); GRPC_ERROR_UNREF(error); } // Test parsing with ErrorParsers which always add errors class ErroredParsersScopingTest : public ::testing::Test { protected: void SetUp() override { ServiceConfigParser::Shutdown(); ServiceConfigParser::Init(); EXPECT_EQ( ServiceConfigParser::RegisterParser(absl::make_unique<ErrorParser>()), 0); EXPECT_EQ( ServiceConfigParser::RegisterParser(absl::make_unique<ErrorParser>()), 1); } }; TEST_F(ErroredParsersScopingTest, GlobalParams) { const char* test_json = "{}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT( grpc_error_std_string(error), ::testing::ContainsRegex(absl::StrCat( "Service config parsing error" CHILD_ERROR_TAG "Global Params" CHILD_ERROR_TAG, ErrorParser::GlobalError(), ".*", ErrorParser::GlobalError()))); GRPC_ERROR_UNREF(error); } TEST_F(ErroredParsersScopingTest, MethodParams) { const char* test_json = "{\"methodConfig\": [{}]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT( grpc_error_std_string(error), ::testing::ContainsRegex(absl::StrCat( "Service config parsing error" CHILD_ERROR_TAG "Global Params" CHILD_ERROR_TAG, ErrorParser::GlobalError(), ".*", ErrorParser::GlobalError(), ".*Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG, ErrorParser::MethodError(), ".*", ErrorParser::MethodError()))); GRPC_ERROR_UNREF(error); } // // client_channel parser tests // class ClientChannelParserTest : public ::testing::Test { protected: void SetUp() override { ServiceConfigParser::Shutdown(); ServiceConfigParser::Init(); EXPECT_EQ( ServiceConfigParser::RegisterParser( absl::make_unique<internal::ClientChannelServiceConfigParser>()), 0); } }; TEST_F(ClientChannelParserTest, ValidLoadBalancingConfigPickFirst) { const char* test_json = "{\"loadBalancingConfig\": [{\"pick_first\":{}}]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* parsed_config = static_cast<grpc_core::internal::ClientChannelGlobalParsedConfig*>( svc_cfg->GetGlobalParsedConfig(0)); auto lb_config = parsed_config->parsed_lb_config(); EXPECT_STREQ(lb_config->name(), "pick_first"); } TEST_F(ClientChannelParserTest, ValidLoadBalancingConfigRoundRobin) { const char* test_json = "{\"loadBalancingConfig\": [{\"round_robin\":{}}, {}]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); auto parsed_config = static_cast<grpc_core::internal::ClientChannelGlobalParsedConfig*>( svc_cfg->GetGlobalParsedConfig(0)); auto lb_config = parsed_config->parsed_lb_config(); EXPECT_STREQ(lb_config->name(), "round_robin"); } TEST_F(ClientChannelParserTest, ValidLoadBalancingConfigGrpclb) { const char* test_json = "{\"loadBalancingConfig\": " "[{\"grpclb\":{\"childPolicy\":[{\"pick_first\":{}}]}}]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* parsed_config = static_cast<grpc_core::internal::ClientChannelGlobalParsedConfig*>( svc_cfg->GetGlobalParsedConfig(0)); auto lb_config = parsed_config->parsed_lb_config(); EXPECT_STREQ(lb_config->name(), "grpclb"); } TEST_F(ClientChannelParserTest, ValidLoadBalancingConfigXds) { const char* test_json = "{\n" " \"loadBalancingConfig\":[\n" " { \"does_not_exist\":{} },\n" " { \"xds_cluster_resolver_experimental\":{\n" " \"discoveryMechanisms\": [\n" " { \"clusterName\": \"foo\",\n" " \"type\": \"EDS\"\n" " } ]\n" " } }\n" " ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* parsed_config = static_cast<grpc_core::internal::ClientChannelGlobalParsedConfig*>( svc_cfg->GetGlobalParsedConfig(0)); auto lb_config = parsed_config->parsed_lb_config(); EXPECT_STREQ(lb_config->name(), "xds_cluster_resolver_experimental"); } TEST_F(ClientChannelParserTest, UnknownLoadBalancingConfig) { const char* test_json = "{\"loadBalancingConfig\": [{\"unknown\":{}}]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT( grpc_error_std_string(error), ::testing::ContainsRegex("Service config parsing error" CHILD_ERROR_TAG "Global Params" CHILD_ERROR_TAG "Client channel global parser" CHILD_ERROR_TAG "field:loadBalancingConfig" CHILD_ERROR_TAG "No known policies in list: unknown")); GRPC_ERROR_UNREF(error); } TEST_F(ClientChannelParserTest, InvalidGrpclbLoadBalancingConfig) { const char* test_json = "{\"loadBalancingConfig\": [" " {\"grpclb\":{\"childPolicy\":1}}," " {\"round_robin\":{}}" "]}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Global Params" CHILD_ERROR_TAG "Client channel global parser" CHILD_ERROR_TAG "field:loadBalancingConfig" CHILD_ERROR_TAG "GrpcLb Parser" CHILD_ERROR_TAG "field:childPolicy" CHILD_ERROR_TAG "type should be array")); GRPC_ERROR_UNREF(error); } TEST_F(ClientChannelParserTest, ValidLoadBalancingPolicy) { const char* test_json = "{\"loadBalancingPolicy\":\"pick_first\"}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* parsed_config = static_cast<grpc_core::internal::ClientChannelGlobalParsedConfig*>( svc_cfg->GetGlobalParsedConfig(0)); EXPECT_EQ(parsed_config->parsed_deprecated_lb_policy(), "pick_first"); } TEST_F(ClientChannelParserTest, ValidLoadBalancingPolicyAllCaps) { const char* test_json = "{\"loadBalancingPolicy\":\"PICK_FIRST\"}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* parsed_config = static_cast<grpc_core::internal::ClientChannelGlobalParsedConfig*>( svc_cfg->GetGlobalParsedConfig(0)); EXPECT_EQ(parsed_config->parsed_deprecated_lb_policy(), "pick_first"); } TEST_F(ClientChannelParserTest, UnknownLoadBalancingPolicy) { const char* test_json = "{\"loadBalancingPolicy\":\"unknown\"}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Global Params" CHILD_ERROR_TAG "Client channel global parser" CHILD_ERROR_TAG "field:loadBalancingPolicy error:Unknown lb policy")); GRPC_ERROR_UNREF(error); } TEST_F(ClientChannelParserTest, LoadBalancingPolicyXdsNotAllowed) { const char* test_json = "{\"loadBalancingPolicy\":\"xds_cluster_resolver_experimental\"}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Global Params" CHILD_ERROR_TAG "Client channel global parser" CHILD_ERROR_TAG "field:loadBalancingPolicy " "error:xds_cluster_resolver_experimental requires " "a config. Please use loadBalancingConfig instead.")); GRPC_ERROR_UNREF(error); } TEST_F(ClientChannelParserTest, ValidTimeout) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"timeout\": \"5s\"\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); ASSERT_NE(vector_ptr, nullptr); auto parsed_config = ((*vector_ptr)[0]).get(); EXPECT_EQ((static_cast<grpc_core::internal::ClientChannelMethodParsedConfig*>( parsed_config)) ->timeout(), 5000); } TEST_F(ClientChannelParserTest, InvalidTimeout) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"service\", \"method\": \"method\" }\n" " ],\n" " \"timeout\": \"5sec\"\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "Client channel parser" CHILD_ERROR_TAG "field:timeout error:type should be STRING of the form given " "by google.proto.Duration")); GRPC_ERROR_UNREF(error); } TEST_F(ClientChannelParserTest, ValidWaitForReady) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"waitForReady\": true\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); ASSERT_NE(vector_ptr, nullptr); auto parsed_config = ((*vector_ptr)[0]).get(); ASSERT_TRUE( (static_cast<grpc_core::internal::ClientChannelMethodParsedConfig*>( parsed_config)) ->wait_for_ready() .has_value()); EXPECT_TRUE( (static_cast<grpc_core::internal::ClientChannelMethodParsedConfig*>( parsed_config)) ->wait_for_ready() .value()); } TEST_F(ClientChannelParserTest, InvalidWaitForReady) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"service\", \"method\": \"method\" }\n" " ],\n" " \"waitForReady\": \"true\"\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "Client channel parser" CHILD_ERROR_TAG "field:waitForReady error:Type should be true/false")); GRPC_ERROR_UNREF(error); } TEST_F(ClientChannelParserTest, ValidHealthCheck) { const char* test_json = "{\n" " \"healthCheckConfig\": {\n" " \"serviceName\": \"health_check_service_name\"\n" " }\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* parsed_config = static_cast<grpc_core::internal::ClientChannelGlobalParsedConfig*>( svc_cfg->GetGlobalParsedConfig(0)); ASSERT_NE(parsed_config, nullptr); EXPECT_EQ(parsed_config->health_check_service_name(), "health_check_service_name"); } TEST_F(ClientChannelParserTest, InvalidHealthCheckMultipleEntries) { const char* test_json = "{\n" " \"healthCheckConfig\": {\n" " \"serviceName\": \"health_check_service_name\"\n" " },\n" " \"healthCheckConfig\": {\n" " \"serviceName\": \"health_check_service_name1\"\n" " }\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "JSON parsing failed" CHILD_ERROR_TAG "duplicate key \"healthCheckConfig\" at index 104")); GRPC_ERROR_UNREF(error); } // // retry parser tests // class RetryParserTest : public ::testing::Test { protected: void SetUp() override { ServiceConfigParser::Shutdown(); ServiceConfigParser::Init(); EXPECT_EQ(ServiceConfigParser::RegisterParser( absl::make_unique<internal::RetryServiceConfigParser>()), 0); } }; TEST_F(RetryParserTest, ValidRetryThrottling) { const char* test_json = "{\n" " \"retryThrottling\": {\n" " \"maxTokens\": 2,\n" " \"tokenRatio\": 1.0\n" " }\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* parsed_config = static_cast<grpc_core::internal::RetryGlobalConfig*>( svc_cfg->GetGlobalParsedConfig(0)); ASSERT_NE(parsed_config, nullptr); EXPECT_EQ(parsed_config->max_milli_tokens(), 2000); EXPECT_EQ(parsed_config->milli_token_ratio(), 1000); } TEST_F(RetryParserTest, RetryThrottlingMissingFields) { const char* test_json = "{\n" " \"retryThrottling\": {\n" " }\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT( grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Global Params" CHILD_ERROR_TAG "retryThrottling" CHILD_ERROR_TAG "field:retryThrottling field:maxTokens error:Not found" ".*field:retryThrottling field:tokenRatio error:Not found")); GRPC_ERROR_UNREF(error); } TEST_F(RetryParserTest, InvalidRetryThrottlingNegativeMaxTokens) { const char* test_json = "{\n" " \"retryThrottling\": {\n" " \"maxTokens\": -2,\n" " \"tokenRatio\": 1.0\n" " }\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT( grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Global Params" CHILD_ERROR_TAG "retryThrottling" CHILD_ERROR_TAG "field:retryThrottling field:maxTokens error:should " "be greater than zero")); GRPC_ERROR_UNREF(error); } TEST_F(RetryParserTest, InvalidRetryThrottlingInvalidTokenRatio) { const char* test_json = "{\n" " \"retryThrottling\": {\n" " \"maxTokens\": 2,\n" " \"tokenRatio\": -1\n" " }\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT( grpc_error_std_string(error), ::testing::ContainsRegex("Service config parsing error" CHILD_ERROR_TAG "Global Params" CHILD_ERROR_TAG "retryThrottling" CHILD_ERROR_TAG "field:retryThrottling field:tokenRatio " "error:Failed parsing")); GRPC_ERROR_UNREF(error); } TEST_F(RetryParserTest, ValidRetryPolicy) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": {\n" " \"maxAttempts\": 3,\n" " \"initialBackoff\": \"1s\",\n" " \"maxBackoff\": \"120s\",\n" " \"backoffMultiplier\": 1.6,\n" " \"retryableStatusCodes\": [ \"ABORTED\" ]\n" " }\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); ASSERT_NE(vector_ptr, nullptr); const auto* parsed_config = static_cast<grpc_core::internal::RetryMethodConfig*>( ((*vector_ptr)[0]).get()); ASSERT_NE(parsed_config, nullptr); EXPECT_EQ(parsed_config->max_attempts(), 3); EXPECT_EQ(parsed_config->initial_backoff(), 1000); EXPECT_EQ(parsed_config->max_backoff(), 120000); EXPECT_EQ(parsed_config->backoff_multiplier(), 1.6f); EXPECT_EQ(parsed_config->per_attempt_recv_timeout(), absl::nullopt); EXPECT_TRUE( parsed_config->retryable_status_codes().Contains(GRPC_STATUS_ABORTED)); } TEST_F(RetryParserTest, InvalidRetryPolicyWrongType) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": 5\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "field:retryPolicy error:should be of type object")); GRPC_ERROR_UNREF(error); } TEST_F(RetryParserTest, InvalidRetryPolicyRequiredFieldsMissing) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": {\n" " \"retryableStatusCodes\": [ \"ABORTED\" ]\n" " }\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "retryPolicy" CHILD_ERROR_TAG ".*field:maxAttempts error:required field missing" ".*field:initialBackoff error:does not exist" ".*field:maxBackoff error:does not exist" ".*field:backoffMultiplier error:required field missing")); GRPC_ERROR_UNREF(error); } TEST_F(RetryParserTest, InvalidRetryPolicyMaxAttemptsWrongType) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": {\n" " \"maxAttempts\": \"FOO\",\n" " \"initialBackoff\": \"1s\",\n" " \"maxBackoff\": \"120s\",\n" " \"backoffMultiplier\": 1.6,\n" " \"retryableStatusCodes\": [ \"ABORTED\" ]\n" " }\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "retryPolicy" CHILD_ERROR_TAG "field:maxAttempts error:should be of type number")); GRPC_ERROR_UNREF(error); } TEST_F(RetryParserTest, InvalidRetryPolicyMaxAttemptsBadValue) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": {\n" " \"maxAttempts\": 1,\n" " \"initialBackoff\": \"1s\",\n" " \"maxBackoff\": \"120s\",\n" " \"backoffMultiplier\": 1.6,\n" " \"retryableStatusCodes\": [ \"ABORTED\" ]\n" " }\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "retryPolicy" CHILD_ERROR_TAG "field:maxAttempts error:should be at least 2")); GRPC_ERROR_UNREF(error); } TEST_F(RetryParserTest, InvalidRetryPolicyInitialBackoffWrongType) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": {\n" " \"maxAttempts\": 2,\n" " \"initialBackoff\": \"1sec\",\n" " \"maxBackoff\": \"120s\",\n" " \"backoffMultiplier\": 1.6,\n" " \"retryableStatusCodes\": [ \"ABORTED\" ]\n" " }\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "retryPolicy" CHILD_ERROR_TAG "field:initialBackoff error:type should be STRING of the " "form given by google.proto.Duration")); GRPC_ERROR_UNREF(error); } TEST_F(RetryParserTest, InvalidRetryPolicyInitialBackoffBadValue) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": {\n" " \"maxAttempts\": 2,\n" " \"initialBackoff\": \"0s\",\n" " \"maxBackoff\": \"120s\",\n" " \"backoffMultiplier\": 1.6,\n" " \"retryableStatusCodes\": [ \"ABORTED\" ]\n" " }\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "retryPolicy" CHILD_ERROR_TAG "field:initialBackoff error:must be greater than 0")); GRPC_ERROR_UNREF(error); } TEST_F(RetryParserTest, InvalidRetryPolicyMaxBackoffWrongType) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": {\n" " \"maxAttempts\": 2,\n" " \"initialBackoff\": \"1s\",\n" " \"maxBackoff\": \"120sec\",\n" " \"backoffMultiplier\": 1.6,\n" " \"retryableStatusCodes\": [ \"ABORTED\" ]\n" " }\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "retryPolicy" CHILD_ERROR_TAG "field:maxBackoff error:type should be STRING of the form " "given by google.proto.Duration")); GRPC_ERROR_UNREF(error); } TEST_F(RetryParserTest, InvalidRetryPolicyMaxBackoffBadValue) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": {\n" " \"maxAttempts\": 2,\n" " \"initialBackoff\": \"1s\",\n" " \"maxBackoff\": \"0s\",\n" " \"backoffMultiplier\": 1.6,\n" " \"retryableStatusCodes\": [ \"ABORTED\" ]\n" " }\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "retryPolicy" CHILD_ERROR_TAG "field:maxBackoff error:must be greater than 0")); GRPC_ERROR_UNREF(error); } TEST_F(RetryParserTest, InvalidRetryPolicyBackoffMultiplierWrongType) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": {\n" " \"maxAttempts\": 2,\n" " \"initialBackoff\": \"1s\",\n" " \"maxBackoff\": \"120s\",\n" " \"backoffMultiplier\": \"1.6\",\n" " \"retryableStatusCodes\": [ \"ABORTED\" ]\n" " }\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "retryPolicy" CHILD_ERROR_TAG "field:backoffMultiplier error:should be of type number")); GRPC_ERROR_UNREF(error); } TEST_F(RetryParserTest, InvalidRetryPolicyBackoffMultiplierBadValue) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": {\n" " \"maxAttempts\": 2,\n" " \"initialBackoff\": \"1s\",\n" " \"maxBackoff\": \"120s\",\n" " \"backoffMultiplier\": 0,\n" " \"retryableStatusCodes\": [ \"ABORTED\" ]\n" " }\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "retryPolicy" CHILD_ERROR_TAG "field:backoffMultiplier error:must be greater than 0")); GRPC_ERROR_UNREF(error); } TEST_F(RetryParserTest, InvalidRetryPolicyEmptyRetryableStatusCodes) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": {\n" " \"maxAttempts\": 2,\n" " \"initialBackoff\": \"1s\",\n" " \"maxBackoff\": \"120s\",\n" " \"backoffMultiplier\": \"1.6\",\n" " \"retryableStatusCodes\": []\n" " }\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "retryPolicy" CHILD_ERROR_TAG "field:retryableStatusCodes error:must be non-empty")); GRPC_ERROR_UNREF(error); } TEST_F(RetryParserTest, InvalidRetryPolicyRetryableStatusCodesWrongType) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": {\n" " \"maxAttempts\": 2,\n" " \"initialBackoff\": \"1s\",\n" " \"maxBackoff\": \"120s\",\n" " \"backoffMultiplier\": \"1.6\",\n" " \"retryableStatusCodes\": 0\n" " }\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "retryPolicy" CHILD_ERROR_TAG "field:retryableStatusCodes error:must be of type array")); GRPC_ERROR_UNREF(error); } TEST_F(RetryParserTest, InvalidRetryPolicyUnparseableRetryableStatusCodes) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": {\n" " \"maxAttempts\": 2,\n" " \"initialBackoff\": \"1s\",\n" " \"maxBackoff\": \"120s\",\n" " \"backoffMultiplier\": \"1.6\",\n" " \"retryableStatusCodes\": [\"FOO\", 2]\n" " }\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "retryPolicy" CHILD_ERROR_TAG "field:retryableStatusCodes " "error:failed to parse status code" ".*field:retryableStatusCodes " "error:status codes should be of type string")); GRPC_ERROR_UNREF(error); } TEST_F(RetryParserTest, ValidRetryPolicyWithPerAttemptRecvTimeout) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": {\n" " \"maxAttempts\": 2,\n" " \"initialBackoff\": \"1s\",\n" " \"maxBackoff\": \"120s\",\n" " \"backoffMultiplier\": 1.6,\n" " \"perAttemptRecvTimeout\": \"1s\",\n" " \"retryableStatusCodes\": [\"ABORTED\"]\n" " }\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; grpc_arg arg = grpc_channel_arg_integer_create( const_cast<char*>(GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING), 1); grpc_channel_args args = {1, &arg}; auto svc_cfg = ServiceConfig::Create(&args, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); ASSERT_NE(vector_ptr, nullptr); const auto* parsed_config = static_cast<grpc_core::internal::RetryMethodConfig*>( ((*vector_ptr)[0]).get()); ASSERT_NE(parsed_config, nullptr); EXPECT_EQ(parsed_config->max_attempts(), 2); EXPECT_EQ(parsed_config->initial_backoff(), 1000); EXPECT_EQ(parsed_config->max_backoff(), 120000); EXPECT_EQ(parsed_config->backoff_multiplier(), 1.6f); EXPECT_EQ(parsed_config->per_attempt_recv_timeout(), 1000); EXPECT_TRUE( parsed_config->retryable_status_codes().Contains(GRPC_STATUS_ABORTED)); } TEST_F(RetryParserTest, ValidRetryPolicyWithPerAttemptRecvTimeoutIgnoredWhenHedgingDisabled) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": {\n" " \"maxAttempts\": 2,\n" " \"initialBackoff\": \"1s\",\n" " \"maxBackoff\": \"120s\",\n" " \"backoffMultiplier\": 1.6,\n" " \"perAttemptRecvTimeout\": \"1s\",\n" " \"retryableStatusCodes\": [\"ABORTED\"]\n" " }\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); ASSERT_NE(vector_ptr, nullptr); const auto* parsed_config = static_cast<grpc_core::internal::RetryMethodConfig*>( ((*vector_ptr)[0]).get()); ASSERT_NE(parsed_config, nullptr); EXPECT_EQ(parsed_config->max_attempts(), 2); EXPECT_EQ(parsed_config->initial_backoff(), 1000); EXPECT_EQ(parsed_config->max_backoff(), 120000); EXPECT_EQ(parsed_config->backoff_multiplier(), 1.6f); EXPECT_EQ(parsed_config->per_attempt_recv_timeout(), absl::nullopt); EXPECT_TRUE( parsed_config->retryable_status_codes().Contains(GRPC_STATUS_ABORTED)); } TEST_F(RetryParserTest, ValidRetryPolicyWithPerAttemptRecvTimeoutAndUnsetRetryableStatusCodes) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": {\n" " \"maxAttempts\": 2,\n" " \"initialBackoff\": \"1s\",\n" " \"maxBackoff\": \"120s\",\n" " \"backoffMultiplier\": 1.6,\n" " \"perAttemptRecvTimeout\": \"1s\"\n" " }\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; grpc_arg arg = grpc_channel_arg_integer_create( const_cast<char*>(GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING), 1); grpc_channel_args args = {1, &arg}; auto svc_cfg = ServiceConfig::Create(&args, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); ASSERT_NE(vector_ptr, nullptr); const auto* parsed_config = static_cast<grpc_core::internal::RetryMethodConfig*>( ((*vector_ptr)[0]).get()); ASSERT_NE(parsed_config, nullptr); EXPECT_EQ(parsed_config->max_attempts(), 2); EXPECT_EQ(parsed_config->initial_backoff(), 1000); EXPECT_EQ(parsed_config->max_backoff(), 120000); EXPECT_EQ(parsed_config->backoff_multiplier(), 1.6f); EXPECT_EQ(parsed_config->per_attempt_recv_timeout(), 1000); EXPECT_TRUE(parsed_config->retryable_status_codes().Empty()); } TEST_F(RetryParserTest, InvalidRetryPolicyPerAttemptRecvTimeoutUnparseable) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": {\n" " \"maxAttempts\": 2,\n" " \"initialBackoff\": \"1s\",\n" " \"maxBackoff\": \"120s\",\n" " \"backoffMultiplier\": \"1.6\",\n" " \"perAttemptRecvTimeout\": \"1sec\",\n" " \"retryableStatusCodes\": [\"ABORTED\"]\n" " }\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; grpc_arg arg = grpc_channel_arg_integer_create( const_cast<char*>(GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING), 1); grpc_channel_args args = {1, &arg}; auto svc_cfg = ServiceConfig::Create(&args, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "retryPolicy" CHILD_ERROR_TAG "field:perAttemptRecvTimeout error:type must be STRING " "of the form given by google.proto.Duration.")); GRPC_ERROR_UNREF(error); } TEST_F(RetryParserTest, InvalidRetryPolicyPerAttemptRecvTimeoutWrongType) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": {\n" " \"maxAttempts\": 2,\n" " \"initialBackoff\": \"1s\",\n" " \"maxBackoff\": \"120s\",\n" " \"backoffMultiplier\": \"1.6\",\n" " \"perAttemptRecvTimeout\": 1,\n" " \"retryableStatusCodes\": [\"ABORTED\"]\n" " }\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; grpc_arg arg = grpc_channel_arg_integer_create( const_cast<char*>(GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING), 1); grpc_channel_args args = {1, &arg}; auto svc_cfg = ServiceConfig::Create(&args, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "retryPolicy" CHILD_ERROR_TAG "field:perAttemptRecvTimeout error:type must be STRING " "of the form given by google.proto.Duration.")); GRPC_ERROR_UNREF(error); } TEST_F(RetryParserTest, InvalidRetryPolicyPerAttemptRecvTimeoutBadValue) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"retryPolicy\": {\n" " \"maxAttempts\": 2,\n" " \"initialBackoff\": \"1s\",\n" " \"maxBackoff\": \"120s\",\n" " \"backoffMultiplier\": \"1.6\",\n" " \"perAttemptRecvTimeout\": \"0s\",\n" " \"retryableStatusCodes\": [\"ABORTED\"]\n" " }\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; grpc_arg arg = grpc_channel_arg_integer_create( const_cast<char*>(GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING), 1); grpc_channel_args args = {1, &arg}; auto svc_cfg = ServiceConfig::Create(&args, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "retryPolicy" CHILD_ERROR_TAG "field:perAttemptRecvTimeout error:must be greater than 0")); GRPC_ERROR_UNREF(error); } // // message_size parser tests // class MessageSizeParserTest : public ::testing::Test { protected: void SetUp() override { ServiceConfigParser::Shutdown(); ServiceConfigParser::Init(); EXPECT_EQ(ServiceConfigParser::RegisterParser( absl::make_unique<MessageSizeParser>()), 0); } }; TEST_F(MessageSizeParserTest, Valid) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"maxRequestMessageBytes\": 1024,\n" " \"maxResponseMessageBytes\": 1024\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error); const auto* vector_ptr = svc_cfg->GetMethodParsedConfigVector( grpc_slice_from_static_string("/TestServ/TestMethod")); ASSERT_NE(vector_ptr, nullptr); auto parsed_config = static_cast<MessageSizeParsedConfig*>(((*vector_ptr)[0]).get()); ASSERT_NE(parsed_config, nullptr); EXPECT_EQ(parsed_config->limits().max_send_size, 1024); EXPECT_EQ(parsed_config->limits().max_recv_size, 1024); } TEST_F(MessageSizeParserTest, InvalidMaxRequestMessageBytes) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"maxRequestMessageBytes\": -1024\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "Message size parser" CHILD_ERROR_TAG "field:maxRequestMessageBytes error:should be non-negative")); GRPC_ERROR_UNREF(error); } TEST_F(MessageSizeParserTest, InvalidMaxResponseMessageBytes) { const char* test_json = "{\n" " \"methodConfig\": [ {\n" " \"name\": [\n" " { \"service\": \"TestServ\", \"method\": \"TestMethod\" }\n" " ],\n" " \"maxResponseMessageBytes\": {}\n" " } ]\n" "}"; grpc_error_handle error = GRPC_ERROR_NONE; auto svc_cfg = ServiceConfig::Create(nullptr, test_json, &error); EXPECT_THAT(grpc_error_std_string(error), ::testing::ContainsRegex( "Service config parsing error" CHILD_ERROR_TAG "Method Params" CHILD_ERROR_TAG "methodConfig" CHILD_ERROR_TAG "Message size parser" CHILD_ERROR_TAG "field:maxResponseMessageBytes error:should be of type " "number")); GRPC_ERROR_UNREF(error); } } // namespace testing } // namespace grpc_core int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); grpc::testing::TestEnvironment env(argc, argv); grpc_init(); int ret = RUN_ALL_TESTS(); grpc_shutdown(); return ret; }
#include "com/mapswithme/maps/Framework.hpp" #include "com/mapswithme/core/jni_helper.hpp" #include "com/mapswithme/maps/UserMarkHelper.hpp" #include "com/mapswithme/maps/bookmarks/data/BookmarkManager.hpp" #include "com/mapswithme/opengl/androidoglcontextfactory.hpp" #include "com/mapswithme/platform/Platform.hpp" #include "com/mapswithme/util/NetworkPolicy.hpp" #include "map/chart_generator.hpp" #include "map/user_mark.hpp" #include "partners_api/ads_engine.hpp" #include "partners_api/banner.hpp" #include "search/everywhere_search_params.hpp" #include "storage/storage_helpers.hpp" #include "drape/pointers.hpp" #include "drape/visual_scale.hpp" #include "drape_frontend/user_event_stream.hpp" #include "drape_frontend/visual_params.hpp" #include "coding/file_container.hpp" #include "coding/file_name_utils.hpp" #include "geometry/angles.hpp" #include "platform/country_file.hpp" #include "platform/local_country_file.hpp" #include "platform/local_country_file_utils.hpp" #include "platform/location.hpp" #include "platform/measurement_utils.hpp" #include "platform/network_policy.hpp" #include "platform/platform.hpp" #include "platform/preferred_languages.hpp" #include "platform/settings.hpp" #include "base/logging.hpp" #include "base/math.hpp" #include "base/sunrise_sunset.hpp" using namespace std; using namespace std::placeholders; android::Framework * g_framework = 0; namespace platform { NetworkPolicy ToNativeNetworkPolicy(JNIEnv * env, jobject obj) { return NetworkPolicy(network_policy::GetNetworkPolicyStatus(env, obj)); } } // namespace platform using namespace storage; using platform::CountryFile; using platform::LocalCountryFile; using platform::ToNativeNetworkPolicy; static_assert(sizeof(int) >= 4, "Size of jint in less than 4 bytes."); namespace { ::Framework * frm() { return g_framework->NativeFramework(); } jobject g_mapObjectListener = nullptr; } // namespace namespace android { enum MultiTouchAction { MULTITOUCH_UP = 0x00000001, MULTITOUCH_DOWN = 0x00000002, MULTITOUCH_MOVE = 0x00000003, MULTITOUCH_CANCEL = 0x00000004 }; Framework::Framework() : m_lastCompass(0.0) , m_isContextDestroyed(false) , m_currentMode(location::PendingPosition) , m_isCurrentModeInitialized(false) , m_isChoosePositionMode(false) { ASSERT_EQUAL ( g_framework, 0, () ); g_framework = this; m_work.GetTrafficManager().SetStateListener(bind(&Framework::TrafficStateChanged, this, _1)); } void Framework::OnLocationError(int errorCode) { m_work.OnLocationError(static_cast<location::TLocationError>(errorCode)); } void Framework::OnLocationUpdated(location::GpsInfo const & info) { ASSERT(IsDrapeEngineCreated(), ()); m_work.OnLocationUpdate(info); } void Framework::OnCompassUpdated(location::CompassInfo const & info, bool forceRedraw) { static double const COMPASS_THRESHOLD = my::DegToRad(1.0); /// @todo Do not emit compass bearing too often. /// Need to make more experiments in future. if (forceRedraw || fabs(ang::GetShortestDistance(m_lastCompass, info.m_bearing)) >= COMPASS_THRESHOLD) { m_lastCompass = info.m_bearing; m_work.OnCompassUpdate(info); } } void Framework::UpdateCompassSensor(int ind, float * arr) { m_sensors[ind].Next(arr); } void Framework::MyPositionModeChanged(location::EMyPositionMode mode, bool routingActive) { if (m_myPositionModeSignal) m_myPositionModeSignal(mode, routingActive); } void Framework::TrafficStateChanged(TrafficManager::TrafficState state) { if (m_onTrafficStateChangedFn) m_onTrafficStateChangedFn(state); } bool Framework::CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi, bool firstLaunch, bool launchByDeepLink) { m_contextFactory = make_unique_dp<dp::ThreadSafeFactory>(new AndroidOGLContextFactory(env, jSurface)); AndroidOGLContextFactory const * factory = m_contextFactory->CastFactory<AndroidOGLContextFactory>(); if (!factory->IsValid()) { LOG(LWARNING, ("Invalid GL context.")); return false; } ::Framework::DrapeCreationParams p; p.m_apiVersion = factory->IsSupportedOpenGLES3() ? dp::ApiVersion::OpenGLES3 : dp::ApiVersion::OpenGLES2; p.m_surfaceWidth = factory->GetWidth(); p.m_surfaceHeight = factory->GetHeight(); p.m_visualScale = dp::VisualScale(densityDpi); p.m_hasMyPositionState = m_isCurrentModeInitialized; p.m_initialMyPositionState = m_currentMode; p.m_isChoosePositionMode = m_isChoosePositionMode; p.m_hints.m_isFirstLaunch = firstLaunch; p.m_hints.m_isLaunchByDeepLink = launchByDeepLink; ASSERT(!m_guiPositions.empty(), ("GUI elements must be set-up before engine is created")); p.m_widgetsInitInfo = m_guiPositions; m_work.LoadBookmarks(); m_work.SetMyPositionModeListener(bind(&Framework::MyPositionModeChanged, this, _1, _2)); m_work.CreateDrapeEngine(make_ref(m_contextFactory), move(p)); m_work.EnterForeground(); return true; } bool Framework::IsDrapeEngineCreated() { return m_work.IsDrapeEngineCreated(); } void Framework::Resize(int w, int h) { m_contextFactory->CastFactory<AndroidOGLContextFactory>()->UpdateSurfaceSize(); m_work.OnSize(w, h); //TODO: remove after correct visible rect calculation. frm()->SetVisibleViewport(m2::RectD(0, 0, w, h)); } void Framework::DetachSurface(bool destroyContext) { LOG(LINFO, ("Detach surface.")); if (destroyContext) { LOG(LINFO, ("Destroy context.")); m_isContextDestroyed = true; m_work.EnterBackground(); m_work.OnDestroyGLContext(); } m_work.SetRenderingDisabled(destroyContext); ASSERT(m_contextFactory != nullptr, ()); AndroidOGLContextFactory * factory = m_contextFactory->CastFactory<AndroidOGLContextFactory>(); factory->ResetSurface(); } bool Framework::AttachSurface(JNIEnv * env, jobject jSurface) { LOG(LINFO, ("Attach surface.")); ASSERT(m_contextFactory != nullptr, ()); AndroidOGLContextFactory * factory = m_contextFactory->CastFactory<AndroidOGLContextFactory>(); factory->SetSurface(env, jSurface); if (!factory->IsValid()) { LOG(LWARNING, ("Invalid GL context.")); return false; } ASSERT(!m_guiPositions.empty(), ("GUI elements must be set-up before engine is created")); m_work.SetRenderingEnabled(factory); if (m_isContextDestroyed) { LOG(LINFO, ("Recover GL resources, viewport size:", factory->GetWidth(), factory->GetHeight())); m_work.OnRecoverGLContext(factory->GetWidth(), factory->GetHeight()); m_isContextDestroyed = false; m_work.EnterForeground(); } return true; } void Framework::SetMapStyle(MapStyle mapStyle) { m_work.SetMapStyle(mapStyle); } void Framework::MarkMapStyle(MapStyle mapStyle) { m_work.MarkMapStyle(mapStyle); } MapStyle Framework::GetMapStyle() const { return m_work.GetMapStyle(); } void Framework::Save3dMode(bool allow3d, bool allow3dBuildings) { m_work.Save3dMode(allow3d, allow3dBuildings); } void Framework::Set3dMode(bool allow3d, bool allow3dBuildings) { m_work.Allow3dMode(allow3d, allow3dBuildings); } void Framework::Get3dMode(bool & allow3d, bool & allow3dBuildings) { m_work.Load3dMode(allow3d, allow3dBuildings); } void Framework::SetChoosePositionMode(bool isChoosePositionMode, bool isBusiness, bool hasPosition, m2::PointD const & position) { m_isChoosePositionMode = isChoosePositionMode; m_work.BlockTapEvents(isChoosePositionMode); m_work.EnableChoosePositionMode(isChoosePositionMode, isBusiness, hasPosition, position); } bool Framework::GetChoosePositionMode() { return m_isChoosePositionMode; } Storage & Framework::GetStorage() { return m_work.GetStorage(); } Index const & Framework::GetIndex() { return m_work.GetIndex(); } void Framework::ShowNode(TCountryId const & idx, bool zoomToDownloadButton) { if (zoomToDownloadButton) { m2::RectD const rect = CalcLimitRect(idx, m_work.GetStorage(), m_work.GetCountryInfoGetter()); m_work.SetViewportCenter(rect.Center(), 10); } else { m_work.ShowNode(idx); } } void Framework::Touch(int action, Finger const & f1, Finger const & f2, uint8_t maskedPointer) { MultiTouchAction eventType = static_cast<MultiTouchAction>(action); df::TouchEvent event; switch(eventType) { case MULTITOUCH_DOWN: event.SetTouchType(df::TouchEvent::TOUCH_DOWN); break; case MULTITOUCH_MOVE: event.SetTouchType(df::TouchEvent::TOUCH_MOVE); break; case MULTITOUCH_UP: event.SetTouchType(df::TouchEvent::TOUCH_UP); break; case MULTITOUCH_CANCEL: event.SetTouchType(df::TouchEvent::TOUCH_CANCEL); break; default: return; } df::Touch touch; touch.m_location = m2::PointD(f1.m_x, f1.m_y); touch.m_id = f1.m_id; event.SetFirstTouch(touch); touch.m_location = m2::PointD(f2.m_x, f2.m_y); touch.m_id = f2.m_id; event.SetSecondTouch(touch); event.SetFirstMaskedPointer(maskedPointer); m_work.TouchEvent(event); } m2::PointD Framework::GetViewportCenter() const { return m_work.GetViewportCenter(); } void Framework::AddString(string const & name, string const & value) { m_work.AddString(name, value); } void Framework::Scale(::Framework::EScaleMode mode) { m_work.Scale(mode, true); } void Framework::Scale(m2::PointD const & centerPt, int targetZoom, bool animate) { ref_ptr<df::DrapeEngine> engine = m_work.GetDrapeEngine(); if (engine) engine->SetModelViewCenter(centerPt, targetZoom, animate, false); } ::Framework * Framework::NativeFramework() { return &m_work; } bool Framework::Search(search::EverywhereSearchParams const & params) { m_searchQuery = params.m_query; return m_work.SearchEverywhere(params); } void Framework::AddLocalMaps() { m_work.RegisterAllMaps(); } void Framework::RemoveLocalMaps() { m_work.DeregisterAllMaps(); } void Framework::ReplaceBookmark(BookmarkAndCategory const & ind, BookmarkData & bm) { m_work.ReplaceBookmark(ind.m_categoryIndex, ind.m_bookmarkIndex, bm); } size_t Framework::ChangeBookmarkCategory(BookmarkAndCategory const & ind, size_t newCat) { return m_work.MoveBookmark(ind.m_bookmarkIndex, ind.m_categoryIndex, newCat); } bool Framework::ShowMapForURL(string const & url) { return m_work.ShowMapForURL(url); } void Framework::DeactivatePopup() { m_work.DeactivateMapSelection(false); } string Framework::GetOutdatedCountriesString() { vector<Country const *> countries; class Storage const & storage = GetStorage(); storage.GetOutdatedCountries(countries); string res; NodeAttrs attrs; for (size_t i = 0; i < countries.size(); ++i) { storage.GetNodeAttrs(countries[i]->Name(), attrs); if (i > 0) res += ", "; res += attrs.m_nodeLocalName; } return res; } void Framework::ShowTrack(int category, int track) { Track const * nTrack = NativeFramework()->GetBmCategory(category)->GetTrack(track); NativeFramework()->ShowTrack(*nTrack); } void Framework::SetTrafficStateListener(TrafficManager::TrafficStateChangedFn const & fn) { m_onTrafficStateChangedFn = fn; } void Framework::EnableTraffic() { m_work.GetTrafficManager().SetEnabled(true); NativeFramework()->SaveTrafficEnabled(true); } void Framework::DisableTraffic() { m_work.GetTrafficManager().SetEnabled(false); NativeFramework()->SaveTrafficEnabled(false); } void Framework::SetMyPositionModeListener(location::TMyPositionModeChanged const & fn) { m_myPositionModeSignal = fn; } location::EMyPositionMode Framework::GetMyPositionMode() { if (!m_isCurrentModeInitialized) { if (!settings::Get(settings::kLocationStateMode, m_currentMode)) m_currentMode = location::NotFollowNoPosition; m_isCurrentModeInitialized = true; } return m_currentMode; } void Framework::OnMyPositionModeChanged(location::EMyPositionMode mode) { m_currentMode = mode; m_isCurrentModeInitialized = true; } void Framework::SwitchMyPositionNextMode() { ASSERT(IsDrapeEngineCreated(), ()); m_work.SwitchMyPositionNextMode(); } void Framework::SetupWidget(gui::EWidget widget, float x, float y, dp::Anchor anchor) { m_guiPositions[widget] = gui::Position(m2::PointF(x, y), anchor); } void Framework::ApplyWidgets() { gui::TWidgetsLayoutInfo layout; for (auto const & widget : m_guiPositions) layout[widget.first] = widget.second.m_pixelPivot; m_work.SetWidgetLayout(move(layout)); } void Framework::CleanWidgets() { m_guiPositions.clear(); } void Framework::SetupMeasurementSystem() { m_work.SetupMeasurementSystem(); } void Framework::SetPlacePageInfo(place_page::Info const & info) { m_info = info; } place_page::Info & Framework::GetPlacePageInfo() { return m_info; } void Framework::RequestBookingMinPrice(JNIEnv * env, jobject policy, string const & hotelId, string const & currencyCode, booking::GetMinPriceCallback const & callback) { auto const bookingApi = m_work.GetBookingApi(ToNativeNetworkPolicy(env, policy)); if (bookingApi) bookingApi->GetMinPrice(hotelId, currencyCode, callback); } void Framework::RequestBookingInfo(JNIEnv * env, jobject policy, string const & hotelId, string const & lang, booking::GetHotelInfoCallback const & callback) { auto const bookingApi = m_work.GetBookingApi(ToNativeNetworkPolicy(env, policy)); if (bookingApi) bookingApi->GetHotelInfo(hotelId, lang, callback); } bool Framework::HasSpaceForMigration() { return m_work.IsEnoughSpaceForMigrate(); } void Framework::Migrate(bool keepOldMaps) { m_work.Migrate(keepOldMaps); } storage::TCountryId Framework::PreMigrate(ms::LatLon const & position, Storage::TChangeCountryFunction const & statusChangeListener, Storage::TProgressFunction const & progressListener) { return m_work.PreMigrate(position, statusChangeListener, progressListener); } bool Framework::IsAutoRetryDownloadFailed() { return m_work.GetDownloadingPolicy().IsAutoRetryDownloadFailed(); } bool Framework::IsDownloadOn3gEnabled() { return m_work.GetDownloadingPolicy().IsCellularDownloadEnabled(); } void Framework::EnableDownloadOn3g() { m_work.GetDownloadingPolicy().EnableCellularDownload(true); } uint64_t Framework::RequestTaxiProducts(JNIEnv * env, jobject policy, ms::LatLon const & from, ms::LatLon const & to, taxi::SuccessCallback const & onSuccess, taxi::ErrorCallback const & onError) { auto const taxiEngine = m_work.GetTaxiEngine(ToNativeNetworkPolicy(env, policy)); if (!taxiEngine) return 0; return taxiEngine->GetAvailableProducts(from, to, onSuccess, onError); } taxi::RideRequestLinks Framework::GetTaxiLinks(JNIEnv * env, jobject policy, taxi::Provider::Type type, string const & productId, ms::LatLon const & from, ms::LatLon const & to) { auto const taxiEngine = m_work.GetTaxiEngine(ToNativeNetworkPolicy(env, policy)); if (!taxiEngine) return {}; return taxiEngine->GetRideRequestLinks(type, productId, from, to); } void Framework::RequestViatorProducts(JNIEnv * env, jobject policy, std::string const & destId, std::string const & currency, viator::GetTop5ProductsCallback const & callback) { auto const viatorApi = m_work.GetViatorApi(ToNativeNetworkPolicy(env, policy)); if (!viatorApi) return; viatorApi->GetTop5Products(destId, currency, callback); } void Framework::RequestUGC(FeatureID const & fid, ugc::Api::UGCCallback const & ugcCallback) { m_work.GetUGCApi()->GetUGC(fid, ugcCallback); } uint64_t Framework::GetRentNearby(JNIEnv * env, jobject policy, ms::LatLon const & latlon, cian::Api::RentNearbyCallback const & onSuccess, cian::Api::ErrorCallback const & onError) { auto const cianApi = m_work.GetCianApi(ToNativeNetworkPolicy(env, policy)); if (!cianApi) return 0; return cianApi->GetRentNearby(latlon, onSuccess, onError); } int Framework::ToDoAfterUpdate() const { return (int) m_work.ToDoAfterUpdate(); } void Framework::LogLocalAdsEvent(local_ads::EventType type, double lat, double lon, uint16_t accuracy) { auto const & info = g_framework->GetPlacePageInfo(); auto const & featureID = info.GetID(); auto const & mwmInfo = featureID.m_mwmId.GetInfo(); if (!mwmInfo) return; local_ads::Event event(type, mwmInfo->GetVersion(), mwmInfo->GetCountryName(), featureID.m_index, m_work.GetDrawScale(), local_ads::Clock::now(), lat, lon, accuracy); m_work.GetLocalAdsManager().GetStatistics().RegisterEvent(std::move(event)); } } // namespace android //============ GLUE CODE for com.mapswithme.maps.Framework class =============// /* ____ * _ |||| _ * \\ // * \\ // * \\// * \/ */ extern "C" { void CallRoutingListener(shared_ptr<jobject> listener, int errorCode, vector<storage::TCountryId> const & absentMaps) { JNIEnv * env = jni::GetEnv(); jmethodID const method = jni::GetMethodID(env, *listener, "onRoutingEvent", "(I[Ljava/lang/String;)V"); ASSERT(method, ()); env->CallVoidMethod(*listener, method, errorCode, jni::TScopedLocalObjectArrayRef(env, jni::ToJavaStringArray(env, absentMaps)).get()); } void CallRouteProgressListener(shared_ptr<jobject> listener, float progress) { JNIEnv * env = jni::GetEnv(); jmethodID const methodId = jni::GetMethodID(env, *listener, "onRouteBuildingProgress", "(F)V"); env->CallVoidMethod(*listener, methodId, progress); } void CallRouteRecommendationListener(shared_ptr<jobject> listener, RoutingManager::Recommendation recommendation) { JNIEnv * env = jni::GetEnv(); jmethodID const methodId = jni::GetMethodID(env, *listener, "onRecommend", "(I)V"); env->CallVoidMethod(*listener, methodId, static_cast<int>(recommendation)); } /// @name JNI EXPORTS //@{ JNIEXPORT jstring JNICALL Java_com_mapswithme_maps_Framework_nativeGetNameAndAddress(JNIEnv * env, jclass clazz, jdouble lat, jdouble lon) { search::AddressInfo const info = frm()->GetAddressInfoAtPoint(MercatorBounds::FromLatLon(lat, lon)); return jni::ToJavaString(env, info.FormatNameAndAddress()); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeClearApiPoints(JNIEnv * env, jclass clazz) { UserMarkNotificationGuard guard(frm()->GetBookmarkManager(), UserMarkType::API_MARK); guard.m_controller.Clear(); } JNIEXPORT jint JNICALL Java_com_mapswithme_maps_Framework_nativeParseAndSetApiUrl(JNIEnv * env, jclass clazz, jstring url) { return static_cast<jint>(frm()->ParseAndSetApiURL(jni::ToNativeString(env, url))); } JNIEXPORT jobject JNICALL Java_com_mapswithme_maps_Framework_nativeGetParsedRoutingData(JNIEnv * env, jclass clazz) { using namespace url_scheme; static jclass const pointClazz = jni::GetGlobalClassRef(env, "com/mapswithme/maps/api/RoutePoint"); // Java signature : RoutePoint(double lat, double lon, String name) static jmethodID const pointConstructor = jni::GetConstructorID(env, pointClazz, "(DDLjava/lang/String;)V"); static jclass const routeDataClazz = jni::GetGlobalClassRef(env, "com/mapswithme/maps/api/ParsedRoutingData"); // Java signature : ParsedRoutingData(RoutePoint[] points, int routerType) { static jmethodID const routeDataConstructor = jni::GetConstructorID(env, routeDataClazz, "([Lcom/mapswithme/maps/api/RoutePoint;I)V"); auto const & routingData = frm()->GetParsedRoutingData(); jobjectArray points = jni::ToJavaArray(env, pointClazz, routingData.m_points, [](JNIEnv * env, RoutePoint const & point) { jni::TScopedLocalRef const name(env, jni::ToJavaString(env, point.m_name)); return env->NewObject(pointClazz, pointConstructor, MercatorBounds::YToLat(point.m_org.y), MercatorBounds::XToLon(point.m_org.x), name.get()); }); return env->NewObject(routeDataClazz, routeDataConstructor, points, routingData.m_type); } JNIEXPORT jobject JNICALL Java_com_mapswithme_maps_Framework_nativeGetParsedSearchRequest(JNIEnv * env, jclass clazz) { using namespace url_scheme; static jclass const cl = jni::GetGlobalClassRef(env, "com/mapswithme/maps/api/ParsedSearchRequest"); // Java signature : ParsedSearchRequest(String query, String locale, double lat, double lon, boolean isSearchOnMap) static jmethodID const ctor = jni::GetConstructorID(env, cl, "(Ljava/lang/String;Ljava/lang/String;DDZ)V"); auto const & r = frm()->GetParsedSearchRequest(); return env->NewObject(cl, ctor, jni::ToJavaString(env, r.m_query), jni::ToJavaString(env, r.m_locale), r.m_centerLat, r.m_centerLon, r.m_isSearchOnMap); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeSetMapObjectListener(JNIEnv * env, jclass clazz, jobject jListener) { g_mapObjectListener = env->NewGlobalRef(jListener); // void onMapObjectActivated(MapObject object); jmethodID const activatedId = jni::GetMethodID(env, g_mapObjectListener, "onMapObjectActivated", "(Lcom/mapswithme/maps/bookmarks/data/MapObject;)V"); // void onDismiss(boolean switchFullScreenMode); jmethodID const dismissId = jni::GetMethodID(env, g_mapObjectListener, "onDismiss", "(Z)V"); frm()->SetMapSelectionListeners([activatedId](place_page::Info const & info) { JNIEnv * env = jni::GetEnv(); g_framework->SetPlacePageInfo(info); jni::TScopedLocalRef mapObject(env, usermark_helper::CreateMapObject(env, info)); env->CallVoidMethod(g_mapObjectListener, activatedId, mapObject.get()); }, [dismissId](bool switchFullScreenMode) { JNIEnv * env = jni::GetEnv(); g_framework->SetPlacePageInfo({}); env->CallVoidMethod(g_mapObjectListener, dismissId, switchFullScreenMode); }); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeRemoveMapObjectListener(JNIEnv * env, jclass) { if (g_mapObjectListener == nullptr) return; frm()->SetMapSelectionListeners({}, {}); env->DeleteGlobalRef(g_mapObjectListener); } JNIEXPORT jstring JNICALL Java_com_mapswithme_maps_Framework_nativeGetGe0Url(JNIEnv * env, jclass, jdouble lat, jdouble lon, jdouble zoomLevel, jstring name) { ::Framework * fr = frm(); double const scale = (zoomLevel > 0 ? zoomLevel : fr->GetDrawScale()); string const url = fr->CodeGe0url(lat, lon, scale, jni::ToNativeString(env, name)); return jni::ToJavaString(env, url); } JNIEXPORT jobject JNICALL Java_com_mapswithme_maps_Framework_nativeGetDistanceAndAzimuth( JNIEnv * env, jclass, jdouble merX, jdouble merY, jdouble cLat, jdouble cLon, jdouble north) { string distance; double azimut = -1.0; frm()->GetDistanceAndAzimut(m2::PointD(merX, merY), cLat, cLon, north, distance, azimut); static jclass const daClazz = jni::GetGlobalClassRef(env, "com/mapswithme/maps/bookmarks/data/DistanceAndAzimut"); // Java signature : DistanceAndAzimut(String distance, double azimuth) static jmethodID const methodID = jni::GetConstructorID(env, daClazz, "(Ljava/lang/String;D)V"); return env->NewObject(daClazz, methodID, jni::ToJavaString(env, distance.c_str()), static_cast<jdouble>(azimut)); } JNIEXPORT jobject JNICALL Java_com_mapswithme_maps_Framework_nativeGetDistanceAndAzimuthFromLatLon( JNIEnv * env, jclass clazz, jdouble lat, jdouble lon, jdouble cLat, jdouble cLon, jdouble north) { double const merY = MercatorBounds::LatToY(lat); double const merX = MercatorBounds::LonToX(lon); return Java_com_mapswithme_maps_Framework_nativeGetDistanceAndAzimuth(env, clazz, merX, merY, cLat, cLon, north); } JNIEXPORT jobject JNICALL Java_com_mapswithme_maps_Framework_nativeFormatLatLon(JNIEnv * env, jclass, jdouble lat, jdouble lon, jboolean useDMSFormat) { return jni::ToJavaString( env, (useDMSFormat ? measurement_utils::FormatLatLonAsDMS(lat, lon, 2) : measurement_utils::FormatLatLon(lat, lon, true /* withSemicolon */, 6))); } JNIEXPORT jobjectArray JNICALL Java_com_mapswithme_maps_Framework_nativeFormatLatLonToArr(JNIEnv * env, jclass, jdouble lat, jdouble lon, jboolean useDMSFormat) { string slat, slon; if (useDMSFormat) measurement_utils::FormatLatLonAsDMS(lat, lon, slat, slon, 2); else measurement_utils::FormatLatLon(lat, lon, slat, slon, 6); static jclass const klass = jni::GetGlobalClassRef(env, "java/lang/String"); jobjectArray arr = env->NewObjectArray(2, klass, 0); env->SetObjectArrayElement(arr, 0, jni::ToJavaString(env, slat)); env->SetObjectArrayElement(arr, 1, jni::ToJavaString(env, slon)); return arr; } JNIEXPORT jobject JNICALL Java_com_mapswithme_maps_Framework_nativeFormatAltitude(JNIEnv * env, jclass, jdouble alt) { return jni::ToJavaString(env, measurement_utils::FormatAltitude(alt)); } JNIEXPORT jobject JNICALL Java_com_mapswithme_maps_Framework_nativeFormatSpeed(JNIEnv * env, jclass, jdouble speed) { return jni::ToJavaString(env, measurement_utils::FormatSpeedWithDeviceUnits(speed)); } JNIEXPORT jobject JNICALL Java_com_mapswithme_maps_Framework_nativeGetOutdatedCountriesString(JNIEnv * env, jclass) { return jni::ToJavaString(env, g_framework->GetOutdatedCountriesString()); } JNIEXPORT jobjectArray JNICALL Java_com_mapswithme_maps_Framework_nativeGetOutdatedCountries(JNIEnv * env, jclass) { vector<Country const *> countries; Storage const & storage = g_framework->GetStorage(); storage.GetOutdatedCountries(countries); vector<string> ids; for (auto country : countries) ids.push_back(country->Name()); return jni::ToJavaStringArray(env, ids); } JNIEXPORT jint JNICALL Java_com_mapswithme_maps_Framework_nativeToDoAfterUpdate(JNIEnv * env, jclass) { return g_framework->ToDoAfterUpdate(); } JNIEXPORT jboolean JNICALL Java_com_mapswithme_maps_Framework_nativeIsDataVersionChanged(JNIEnv * env, jclass) { return frm()->IsDataVersionUpdated() ? JNI_TRUE : JNI_FALSE; } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeUpdateSavedDataVersion(JNIEnv * env, jclass) { frm()->UpdateSavedDataVersion(); } JNIEXPORT jlong JNICALL Java_com_mapswithme_maps_Framework_nativeGetDataVersion(JNIEnv * env, jclass) { return frm()->GetCurrentDataVersion(); } JNIEXPORT jint JNICALL Java_com_mapswithme_maps_Framework_nativeGetDrawScale(JNIEnv * env, jclass) { return static_cast<jint>(frm()->GetDrawScale()); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeUpdateUserViewportChanged(JNIEnv * env, jclass) { frm()->UpdateUserViewportChanged(); } JNIEXPORT jdoubleArray JNICALL Java_com_mapswithme_maps_Framework_nativeGetScreenRectCenter(JNIEnv * env, jclass) { m2::PointD const center = frm()->GetViewportCenter(); double latlon[] = {MercatorBounds::YToLat(center.y), MercatorBounds::XToLon(center.x)}; jdoubleArray jLatLon = env->NewDoubleArray(2); env->SetDoubleArrayRegion(jLatLon, 0, 2, latlon); return jLatLon; } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeShowTrackRect(JNIEnv * env, jclass, jint cat, jint track) { g_framework->ShowTrack(cat, track); } JNIEXPORT jstring JNICALL Java_com_mapswithme_maps_Framework_nativeGetBookmarkDir(JNIEnv * env, jclass) { return jni::ToJavaString(env, GetPlatform().SettingsDir().c_str()); } JNIEXPORT jstring JNICALL Java_com_mapswithme_maps_Framework_nativeGetWritableDir(JNIEnv * env, jclass) { return jni::ToJavaString(env, GetPlatform().WritableDir().c_str()); } JNIEXPORT jstring JNICALL Java_com_mapswithme_maps_Framework_nativeGetSettingsDir(JNIEnv * env, jclass) { return jni::ToJavaString(env, GetPlatform().SettingsDir().c_str()); } JNIEXPORT jobjectArray JNICALL Java_com_mapswithme_maps_Framework_nativeGetMovableFilesExts(JNIEnv * env, jclass) { vector<string> exts = { DATA_FILE_EXTENSION, FONT_FILE_EXTENSION, ROUTING_FILE_EXTENSION }; platform::CountryIndexes::GetIndexesExts(exts); return jni::ToJavaStringArray(env, exts); } JNIEXPORT jstring JNICALL Java_com_mapswithme_maps_Framework_nativeGetBookmarksExt(JNIEnv * env, jclass) { return jni::ToJavaString(env, BOOKMARKS_FILE_EXTENSION); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeSetWritableDir(JNIEnv * env, jclass, jstring jNewPath) { string newPath = jni::ToNativeString(env, jNewPath); g_framework->RemoveLocalMaps(); android::Platform::Instance().SetWritableDir(newPath); g_framework->AddLocalMaps(); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeLoadBookmarks(JNIEnv * env, jclass) { frm()->LoadBookmarks(); } JNIEXPORT jboolean JNICALL Java_com_mapswithme_maps_Framework_nativeIsRoutingActive(JNIEnv * env, jclass) { return frm()->GetRoutingManager().IsRoutingActive(); } JNIEXPORT jboolean JNICALL Java_com_mapswithme_maps_Framework_nativeIsRouteBuilding(JNIEnv * env, jclass) { return frm()->GetRoutingManager().IsRouteBuilding(); } JNIEXPORT jboolean JNICALL Java_com_mapswithme_maps_Framework_nativeIsRouteBuilt(JNIEnv * env, jclass) { return frm()->GetRoutingManager().IsRouteBuilt(); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeCloseRouting(JNIEnv * env, jclass) { frm()->GetRoutingManager().CloseRouting(true /* remove route points */); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeBuildRoute(JNIEnv * env, jclass) { frm()->GetRoutingManager().BuildRoute(0 /* timeoutSec */); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeRemoveRoute(JNIEnv * env, jclass) { frm()->GetRoutingManager().RemoveRoute(false /* deactivateFollowing */); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeFollowRoute(JNIEnv * env, jclass) { frm()->GetRoutingManager().FollowRoute(); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeDisableFollowing(JNIEnv * env, jclass) { frm()->GetRoutingManager().DisableFollowMode(); } JNIEXPORT jobjectArray JNICALL Java_com_mapswithme_maps_Framework_nativeGenerateTurnNotifications(JNIEnv * env, jclass) { ::Framework * fr = frm(); if (!fr->GetRoutingManager().IsRoutingActive()) return nullptr; vector<string> turnNotifications; fr->GetRoutingManager().GenerateTurnNotifications(turnNotifications); if (turnNotifications.empty()) return nullptr; return jni::ToJavaStringArray(env, turnNotifications); } JNIEXPORT jobject JNICALL Java_com_mapswithme_maps_Framework_nativeGetRouteFollowingInfo(JNIEnv * env, jclass) { ::Framework * fr = frm(); if (!fr->GetRoutingManager().IsRoutingActive()) return nullptr; location::FollowingInfo info; fr->GetRoutingManager().GetRouteFollowingInfo(info); if (!info.IsValid()) return nullptr; static jclass const klass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/routing/RoutingInfo"); // Java signature : RoutingInfo(String distToTarget, String units, String distTurn, String turnSuffix, String currentStreet, String nextStreet, // double completionPercent, int vehicleTurnOrdinal, int vehicleNextTurnOrdinal, int pedestrianTurnOrdinal, // double pedestrianDirectionLat, double pedestrianDirectionLon, int exitNum, int totalTime, SingleLaneInfo[] lanes) static jmethodID const ctorRouteInfoID = jni::GetConstructorID(env, klass, "(Ljava/lang/String;Ljava/lang/String;" "Ljava/lang/String;Ljava/lang/String;" "Ljava/lang/String;Ljava/lang/String;DIIIDDII" "[Lcom/mapswithme/maps/routing/SingleLaneInfo;)V"); vector<location::FollowingInfo::SingleLaneInfoClient> const & lanes = info.m_lanes; jobjectArray jLanes = nullptr; if (!lanes.empty()) { static jclass const laneClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/routing/SingleLaneInfo"); size_t const lanesSize = lanes.size(); jLanes = env->NewObjectArray(lanesSize, laneClass, nullptr); ASSERT(jLanes, (jni::DescribeException())); static jmethodID const ctorSingleLaneInfoID = jni::GetConstructorID(env, laneClass, "([BZ)V"); for (size_t j = 0; j < lanesSize; ++j) { size_t const laneSize = lanes[j].m_lane.size(); jni::TScopedLocalByteArrayRef singleLane(env, env->NewByteArray(laneSize)); ASSERT(singleLane.get(), (jni::DescribeException())); env->SetByteArrayRegion(singleLane.get(), 0, laneSize, lanes[j].m_lane.data()); jni::TScopedLocalRef singleLaneInfo(env, env->NewObject(laneClass, ctorSingleLaneInfoID, singleLane.get(), lanes[j].m_isRecommended)); ASSERT(singleLaneInfo.get(), (jni::DescribeException())); env->SetObjectArrayElement(jLanes, j, singleLaneInfo.get()); } } jobject const result = env->NewObject( klass, ctorRouteInfoID, jni::ToJavaString(env, info.m_distToTarget), jni::ToJavaString(env, info.m_targetUnitsSuffix), jni::ToJavaString(env, info.m_distToTurn), jni::ToJavaString(env, info.m_turnUnitsSuffix), jni::ToJavaString(env, info.m_sourceName), jni::ToJavaString(env, info.m_displayedStreetName), info.m_completionPercent, info.m_turn, info.m_nextTurn, info.m_pedestrianTurn, info.m_pedestrianDirectionPos.lat, info.m_pedestrianDirectionPos.lon, info.m_exitNum, info.m_time, jLanes); ASSERT(result, (jni::DescribeException())); return result; } JNIEXPORT jintArray JNICALL Java_com_mapswithme_maps_Framework_nativeGenerateRouteAltitudeChartBits(JNIEnv * env, jclass, jint width, jint height, jobject routeAltitudeLimits) { ::Framework * fr = frm(); ASSERT(fr, ()); vector<uint8_t> imageRGBAData; int32_t minRouteAltitude = 0; int32_t maxRouteAltitude = 0; measurement_utils::Units units = measurement_utils::Units::Metric; if (!fr->GetRoutingManager().GenerateRouteAltitudeChart( width, height, imageRGBAData, minRouteAltitude, maxRouteAltitude, units)) { LOG(LWARNING, ("Can't generate route altitude image.")); return nullptr; } // Passing route limits. jclass const routeAltitudeLimitsClass = env->GetObjectClass(routeAltitudeLimits); ASSERT(routeAltitudeLimitsClass, ()); static jfieldID const minRouteAltitudeField = env->GetFieldID(routeAltitudeLimitsClass, "minRouteAltitude", "I"); ASSERT(minRouteAltitudeField, ()); env->SetIntField(routeAltitudeLimits, minRouteAltitudeField, minRouteAltitude); static jfieldID const maxRouteAltitudeField = env->GetFieldID(routeAltitudeLimitsClass, "maxRouteAltitude", "I"); ASSERT(maxRouteAltitudeField, ()); env->SetIntField(routeAltitudeLimits, maxRouteAltitudeField, maxRouteAltitude); static jfieldID const isMetricUnitsField = env->GetFieldID(routeAltitudeLimitsClass, "isMetricUnits", "Z"); ASSERT(isMetricUnitsField, ()); env->SetBooleanField(routeAltitudeLimits, isMetricUnitsField, units == measurement_utils::Units::Metric); size_t const imageRGBADataSize = imageRGBAData.size(); ASSERT_NOT_EQUAL(imageRGBADataSize, 0, ("GenerateRouteAltitudeChart returns true but the vector with altitude image bits is empty.")); size_t const pxlCount = width * height; if (maps::kAltitudeChartBPP * pxlCount != imageRGBADataSize) { LOG(LWARNING, ("Wrong size of vector with altitude image bits. Expected size:", pxlCount, ". Real size:", imageRGBADataSize)); return nullptr; } jintArray imageRGBADataArray = env->NewIntArray(pxlCount); ASSERT(imageRGBADataArray, ()); jint * arrayElements = env->GetIntArrayElements(imageRGBADataArray, 0); ASSERT(arrayElements, ()); for (size_t i = 0; i < pxlCount; ++i) { size_t const shiftInBytes = i * maps::kAltitudeChartBPP; // Type of |imageRGBAData| elements is uint8_t. But uint8_t is promoted to unsinged int in code below before shifting. // So there's no data lost in code below. arrayElements[i] = (imageRGBAData[shiftInBytes + 3] << 24) /* alpha */ | (imageRGBAData[shiftInBytes] << 16) /* red */ | (imageRGBAData[shiftInBytes + 1] << 8) /* green */ | (imageRGBAData[shiftInBytes + 2]); /* blue */ } env->ReleaseIntArrayElements(imageRGBADataArray, arrayElements, 0); return imageRGBADataArray; } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeShowCountry(JNIEnv * env, jclass, jstring countryId, jboolean zoomToDownloadButton) { g_framework->ShowNode(jni::ToNativeString(env, countryId), (bool) zoomToDownloadButton); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeSetRoutingListener(JNIEnv * env, jclass, jobject listener) { CHECK(g_framework, ("Framework isn't created yet!")); frm()->GetRoutingManager().SetRouteBuildingListener( bind(&CallRoutingListener, jni::make_global_ref(listener), _1, _2)); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeSetRouteProgressListener(JNIEnv * env, jclass, jobject listener) { CHECK(g_framework, ("Framework isn't created yet!")); frm()->GetRoutingManager().SetRouteProgressListener( bind(&CallRouteProgressListener, jni::make_global_ref(listener), _1)); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeSetRoutingRecommendationListener(JNIEnv * env, jclass, jobject listener) { CHECK(g_framework, ("Framework isn't created yet!")); frm()->GetRoutingManager().SetRouteRecommendationListener( bind(&CallRouteRecommendationListener, jni::make_global_ref(listener), _1)); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeDeactivatePopup(JNIEnv * env, jclass) { return g_framework->DeactivatePopup(); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeSetMapStyle(JNIEnv * env, jclass, jint mapStyle) { MapStyle const val = static_cast<MapStyle>(mapStyle); if (val != g_framework->GetMapStyle()) g_framework->SetMapStyle(val); } JNIEXPORT jint JNICALL Java_com_mapswithme_maps_Framework_nativeGetMapStyle(JNIEnv * env, jclass, jint mapStyle) { return g_framework->GetMapStyle(); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeMarkMapStyle(JNIEnv * env, jclass, jint mapStyle) { MapStyle const val = static_cast<MapStyle>(mapStyle); if (val != g_framework->GetMapStyle()) g_framework->MarkMapStyle(val); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeSetRouter(JNIEnv * env, jclass, jint routerType) { g_framework->GetRoutingManager().SetRouter(static_cast<routing::RouterType>(routerType)); } JNIEXPORT jint JNICALL Java_com_mapswithme_maps_Framework_nativeGetRouter(JNIEnv * env, jclass) { return static_cast<jint>(g_framework->GetRoutingManager().GetRouter()); } JNIEXPORT jint JNICALL Java_com_mapswithme_maps_Framework_nativeGetLastUsedRouter(JNIEnv * env, jclass) { return static_cast<jint>(g_framework->GetRoutingManager().GetLastUsedRouter()); } JNIEXPORT jint JNICALL Java_com_mapswithme_maps_Framework_nativeGetBestRouter(JNIEnv * env, jclass, jdouble srcLat, jdouble srcLon, jdouble dstLat, jdouble dstLon) { return static_cast<jint>(frm()->GetRoutingManager().GetBestRouter( MercatorBounds::FromLatLon(srcLat, srcLon), MercatorBounds::FromLatLon(dstLat, dstLon))); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeAddRoutePoint(JNIEnv * env, jclass, jstring title, jstring subtitle, jint markType, jint intermediateIndex, jboolean isMyPosition, jdouble lat, jdouble lon) { RouteMarkData data; data.m_title = jni::ToNativeString(env, title); data.m_subTitle = jni::ToNativeString(env, subtitle); data.m_pointType = static_cast<RouteMarkType>(markType); data.m_intermediateIndex = static_cast<size_t>(intermediateIndex); data.m_isMyPosition = static_cast<bool>(isMyPosition); data.m_position = m2::PointD(MercatorBounds::FromLatLon(lat, lon)); frm()->GetRoutingManager().AddRoutePoint(std::move(data)); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeRemoveRoutePoint(JNIEnv * env, jclass, jint markType, jint intermediateIndex) { frm()->GetRoutingManager().RemoveRoutePoint(static_cast<RouteMarkType>(markType), static_cast<size_t>(intermediateIndex)); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeRemoveIntermediateRoutePoints(JNIEnv * env, jclass) { frm()->GetRoutingManager().RemoveIntermediateRoutePoints(); } JNIEXPORT jboolean JNICALL Java_com_mapswithme_maps_Framework_nativeCouldAddIntermediatePoint(JNIEnv * env, jclass) { return frm()->GetRoutingManager().CouldAddIntermediatePoint(); } JNIEXPORT jobjectArray JNICALL Java_com_mapswithme_maps_Framework_nativeGetRoutePoints(JNIEnv * env, jclass) { auto const points = frm()->GetRoutingManager().GetRoutePoints(); static jclass const pointClazz = jni::GetGlobalClassRef(env, "com/mapswithme/maps/routing/RouteMarkData"); // Java signature : RouteMarkData(String title, String subtitle, // @RoutePointInfo.RouteMarkType int pointType, // int intermediateIndex, boolean isVisible, boolean isMyPosition, // boolean isPassed, double lat, double lon) static jmethodID const pointConstructor = jni::GetConstructorID(env, pointClazz, "(Ljava/lang/String;Ljava/lang/String;IIZZZDD)V"); return jni::ToJavaArray(env, pointClazz, points, [&](JNIEnv * env, RouteMarkData const & data) { jni::TScopedLocalRef const title(env, jni::ToJavaString(env, data.m_title)); jni::TScopedLocalRef const subtitle(env, jni::ToJavaString(env, data.m_subTitle)); return env->NewObject(pointClazz, pointConstructor, title.get(), subtitle.get(), static_cast<jint>(data.m_pointType), static_cast<jint>(data.m_intermediateIndex), static_cast<jboolean>(data.m_isVisible), static_cast<jboolean>(data.m_isMyPosition), static_cast<jboolean>(data.m_isPassed), MercatorBounds::YToLat(data.m_position.y), MercatorBounds::XToLon(data.m_position.x)); }); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeRegisterMaps(JNIEnv * env, jclass) { frm()->RegisterAllMaps(); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeDeregisterMaps(JNIEnv * env, jclass) { frm()->DeregisterAllMaps(); } JNIEXPORT jboolean JNICALL Java_com_mapswithme_maps_Framework_nativeIsDayTime(JNIEnv * env, jclass, jlong utcTimeSeconds, jdouble lat, jdouble lon) { DayTimeType const dt = GetDayTime(static_cast<time_t>(utcTimeSeconds), lat, lon); return (dt == DayTimeType::Day || dt == DayTimeType::PolarDay); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeSet3dMode(JNIEnv * env, jclass, jboolean allow, jboolean allowBuildings) { bool const allow3d = static_cast<bool>(allow); bool const allow3dBuildings = static_cast<bool>(allowBuildings); g_framework->Save3dMode(allow3d, allow3dBuildings); g_framework->Set3dMode(allow3d, allow3dBuildings); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeGet3dMode(JNIEnv * env, jclass, jobject result) { bool enabled; bool buildings; g_framework->Get3dMode(enabled, buildings); jclass const resultClass = env->GetObjectClass(result); static jfieldID const enabledField = env->GetFieldID(resultClass, "enabled", "Z"); env->SetBooleanField(result, enabledField, enabled); static jfieldID const buildingsField = env->GetFieldID(resultClass, "buildings", "Z"); env->SetBooleanField(result, buildingsField, buildings); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeSetAutoZoomEnabled(JNIEnv * env, jclass, jboolean enabled) { bool const autoZoomEnabled = static_cast<bool>(enabled); frm()->SaveAutoZoom(autoZoomEnabled); frm()->AllowAutoZoom(autoZoomEnabled); } JNIEXPORT jboolean JNICALL Java_com_mapswithme_maps_Framework_nativeGetAutoZoomEnabled(JNIEnv *, jclass) { return frm()->LoadAutoZoom(); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeSetSimplifiedTrafficColorsEnabled(JNIEnv *, jclass, jboolean enabled) { bool const simplifiedEnabled = static_cast<bool>(enabled); frm()->GetTrafficManager().SetSimplifiedColorScheme(simplifiedEnabled); frm()->SaveTrafficSimplifiedColors(simplifiedEnabled); } JNIEXPORT jboolean JNICALL Java_com_mapswithme_maps_Framework_nativeGetSimplifiedTrafficColorsEnabled(JNIEnv * env, jclass) { return frm()->LoadTrafficSimplifiedColors(); } // static void nativeZoomToPoint(double lat, double lon, int zoom, boolean animate); JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeZoomToPoint(JNIEnv * env, jclass, jdouble lat, jdouble lon, jint zoom, jboolean animate) { g_framework->Scale(m2::PointD(MercatorBounds::FromLatLon(lat, lon)), zoom, animate); } JNIEXPORT jobject JNICALL Java_com_mapswithme_maps_Framework_nativeDeleteBookmarkFromMapObject(JNIEnv * env, jclass) { place_page::Info & info = g_framework->GetPlacePageInfo(); auto const bac = info.GetBookmarkAndCategory(); BookmarkCategory * category = frm()->GetBmCategory(bac.m_categoryIndex); frm()->ResetBookmarkInfo(*static_cast<Bookmark const *>(category->GetUserMark(bac.m_bookmarkIndex)), info); bookmarks_helper::RemoveBookmark(bac.m_categoryIndex, bac.m_bookmarkIndex); return usermark_helper::CreateMapObject(env, info); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeOnBookmarkCategoryChanged(JNIEnv * env, jclass, jint cat, jint bmk) { place_page::Info & info = g_framework->GetPlacePageInfo(); ASSERT_GREATER_OR_EQUAL(bmk, 0, ()); ASSERT_GREATER_OR_EQUAL(cat, 0, ()); info.SetBac({static_cast<size_t>(bmk), static_cast<size_t>(cat)}); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeTurnOnChoosePositionMode(JNIEnv *, jclass, jboolean isBusiness, jboolean applyPosition) { g_framework->SetChoosePositionMode(true, isBusiness, applyPosition, applyPosition ? g_framework->GetPlacePageInfo().GetMercator() : m2::PointD()); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeTurnOffChoosePositionMode(JNIEnv *, jclass) { g_framework->SetChoosePositionMode(false, false, false, m2::PointD()); } JNIEXPORT jboolean JNICALL Java_com_mapswithme_maps_Framework_nativeIsInChoosePositionMode(JNIEnv *, jclass) { return g_framework->GetChoosePositionMode(); } JNIEXPORT jboolean JNICALL Java_com_mapswithme_maps_Framework_nativeIsDownloadedMapAtScreenCenter(JNIEnv *, jclass) { ::Framework * fr = frm(); return storage::IsPointCoveredByDownloadedMaps(fr->GetViewportCenter(), fr->GetStorage(), fr->GetCountryInfoGetter()); } JNIEXPORT jstring JNICALL Java_com_mapswithme_maps_Framework_nativeGetActiveObjectFormattedCuisine(JNIEnv * env, jclass) { return jni::ToJavaString(env, g_framework->GetPlacePageInfo().FormatCuisines()); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeSetVisibleRect(JNIEnv * env, jclass, jint left, jint top, jint right, jint bottom) { frm()->SetVisibleViewport(m2::RectD(left, top, right, bottom)); } JNIEXPORT jboolean JNICALL Java_com_mapswithme_maps_Framework_nativeIsRouteFinished(JNIEnv * env, jclass) { return frm()->GetRoutingManager().IsRouteFinished(); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeLogLocalAdsEvent(JNIEnv * env, jclass, jint type, jdouble lat, jdouble lon, jint accuracy) { g_framework->LogLocalAdsEvent(static_cast<local_ads::EventType>(type), lat, lon, accuracy); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeRunFirstLaunchAnimation(JNIEnv * env, jclass) { frm()->RunFirstLaunchAnimation(); } JNIEXPORT jint JNICALL Java_com_mapswithme_maps_Framework_nativeOpenRoutePointsTransaction(JNIEnv * env, jclass) { return frm()->GetRoutingManager().OpenRoutePointsTransaction(); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeApplyRoutePointsTransaction(JNIEnv * env, jclass, jint transactionId) { frm()->GetRoutingManager().ApplyRoutePointsTransaction(transactionId); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeCancelRoutePointsTransaction(JNIEnv * env, jclass, jint transactionId) { frm()->GetRoutingManager().CancelRoutePointsTransaction(transactionId); } JNIEXPORT jint JNICALL Java_com_mapswithme_maps_Framework_nativeInvalidRoutePointsTransactionId(JNIEnv * env, jclass) { return frm()->GetRoutingManager().InvalidRoutePointsTransactionId(); } JNIEXPORT jboolean JNICALL Java_com_mapswithme_maps_Framework_nativeHasSavedRoutePoints() { return frm()->GetRoutingManager().HasSavedRoutePoints(); } JNIEXPORT jboolean JNICALL Java_com_mapswithme_maps_Framework_nativeLoadRoutePoints() { return frm()->GetRoutingManager().LoadRoutePoints(); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeSaveRoutePoints() { frm()->GetRoutingManager().SaveRoutePoints(); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeDeleteSavedRoutePoints() { frm()->GetRoutingManager().DeleteSavedRoutePoints(); } JNIEXPORT jobjectArray JNICALL Java_com_mapswithme_maps_Framework_nativeGetSearchBanners(JNIEnv * env, jclass) { return usermark_helper::ToBannersArray(env, frm()->GetAdsEngine().GetSearchBanners()); } JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeAuthenticateUser(JNIEnv * env, jclass, jstring socialToken, jint socialTokenType) { auto const tokenStr = jni::ToNativeString(env, socialToken); frm()->GetUser().Authenticate(tokenStr, static_cast<User::SocialTokenType>(socialTokenType)); } JNIEXPORT jboolean JNICALL Java_com_mapswithme_maps_Framework_nativeIsUserAuthenticated() { return frm()->GetUser().IsAuthenticated(); } } // extern "C"