hexsha
stringlengths
40
40
size
int64
22
2.4M
ext
stringclasses
5 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
3
260
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
listlengths
1
9
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
3
260
max_issues_repo_name
stringlengths
5
109
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
listlengths
1
9
max_issues_count
float64
1
67k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
260
max_forks_repo_name
stringlengths
5
109
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
listlengths
1
9
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
22
2.4M
avg_line_length
float64
5
169k
max_line_length
int64
5
786k
alphanum_fraction
float64
0.06
0.95
matches
listlengths
1
11
01e05b681988abbc8f1181228ea5d3f319a8974f
9,201
h
C
dtb/src/cpp_stl_98/dtb.h
kaitai-io/formats-kaitai-io.github.io
2700514a2a8f67c5351fe93962c70abea02fd3d3
[ "0BSD" ]
4
2018-12-10T09:21:19.000Z
2021-11-03T16:43:22.000Z
dtb/src/cpp_stl_98/dtb.h
kaitai-io/formats-kaitai-io.github.io
2700514a2a8f67c5351fe93962c70abea02fd3d3
[ "0BSD" ]
null
null
null
dtb/src/cpp_stl_98/dtb.h
kaitai-io/formats-kaitai-io.github.io
2700514a2a8f67c5351fe93962c70abea02fd3d3
[ "0BSD" ]
3
2019-04-08T08:22:22.000Z
2021-10-10T19:11:51.000Z
#ifndef DTB_H_ #define DTB_H_ // This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild #include "kaitai/kaitaistruct.h" #include <stdint.h> #include <vector> #if KAITAI_STRUCT_VERSION < 9000L #error "Incompatible Kaitai Struct C++/STL API: version 0.9 or later is required" #endif /** * Also referred to as Devicetree Blob (DTB). It is a flat binary encoding * of data (primarily devicetree data, although other data is possible as well). * The data is internally stored as a tree of named nodes and properties. Nodes * contain properties and child nodes, while properties are name–value pairs. * * The Devicetree Blobs (`.dtb` files) are compiled from the Devicetree Source * files (`.dts`) through the Devicetree compiler (DTC). * * On Linux systems that support this, the blobs can be accessed in * `/sys/firmware/fdt`: * * * <https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-firmware-ofw> * * The encoding of strings used in the `strings_block` and `structure_block` is * actually a subset of ASCII: * * <https://devicetree-specification.readthedocs.io/en/v0.3/devicetree-basics.html#node-names> * * Example files: * * * <https://github.com/qemu/qemu/tree/master/pc-bios> * \sa https://devicetree-specification.readthedocs.io/en/v0.3/flattened-format.html Source * \sa https://elinux.org/images/f/f4/Elc2013_Fernandes.pdf Source */ class dtb_t : public kaitai::kstruct { public: class memory_block_t; class fdt_block_t; class memory_block_entry_t; class strings_t; class fdt_prop_t; class fdt_node_t; class fdt_begin_node_t; enum fdt_t { FDT_BEGIN_NODE = 1, FDT_END_NODE = 2, FDT_PROP = 3, FDT_NOP = 4, FDT_END = 9 }; dtb_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent = 0, dtb_t* p__root = 0); private: void _read(); void _clean_up(); public: ~dtb_t(); class memory_block_t : public kaitai::kstruct { public: memory_block_t(kaitai::kstream* p__io, dtb_t* p__parent = 0, dtb_t* p__root = 0); private: void _read(); void _clean_up(); public: ~memory_block_t(); private: std::vector<memory_block_entry_t*>* m_entries; dtb_t* m__root; dtb_t* m__parent; public: std::vector<memory_block_entry_t*>* entries() const { return m_entries; } dtb_t* _root() const { return m__root; } dtb_t* _parent() const { return m__parent; } }; class fdt_block_t : public kaitai::kstruct { public: fdt_block_t(kaitai::kstream* p__io, dtb_t* p__parent = 0, dtb_t* p__root = 0); private: void _read(); void _clean_up(); public: ~fdt_block_t(); private: std::vector<fdt_node_t*>* m_nodes; dtb_t* m__root; dtb_t* m__parent; public: std::vector<fdt_node_t*>* nodes() const { return m_nodes; } dtb_t* _root() const { return m__root; } dtb_t* _parent() const { return m__parent; } }; class memory_block_entry_t : public kaitai::kstruct { public: memory_block_entry_t(kaitai::kstream* p__io, dtb_t::memory_block_t* p__parent = 0, dtb_t* p__root = 0); private: void _read(); void _clean_up(); public: ~memory_block_entry_t(); private: uint64_t m_address; uint64_t m_size; dtb_t* m__root; dtb_t::memory_block_t* m__parent; public: /** * physical address of a reserved memory region */ uint64_t address() const { return m_address; } /** * size of a reserved memory region */ uint64_t size() const { return m_size; } dtb_t* _root() const { return m__root; } dtb_t::memory_block_t* _parent() const { return m__parent; } }; class strings_t : public kaitai::kstruct { public: strings_t(kaitai::kstream* p__io, dtb_t* p__parent = 0, dtb_t* p__root = 0); private: void _read(); void _clean_up(); public: ~strings_t(); private: std::vector<std::string>* m_strings; dtb_t* m__root; dtb_t* m__parent; public: std::vector<std::string>* strings() const { return m_strings; } dtb_t* _root() const { return m__root; } dtb_t* _parent() const { return m__parent; } }; class fdt_prop_t : public kaitai::kstruct { public: fdt_prop_t(kaitai::kstream* p__io, dtb_t::fdt_node_t* p__parent = 0, dtb_t* p__root = 0); private: void _read(); void _clean_up(); public: ~fdt_prop_t(); private: bool f_name; std::string m_name; public: std::string name(); private: uint32_t m_len_property; uint32_t m_ofs_name; std::string m_property; std::string m_padding; dtb_t* m__root; dtb_t::fdt_node_t* m__parent; public: uint32_t len_property() const { return m_len_property; } uint32_t ofs_name() const { return m_ofs_name; } std::string property() const { return m_property; } std::string padding() const { return m_padding; } dtb_t* _root() const { return m__root; } dtb_t::fdt_node_t* _parent() const { return m__parent; } }; class fdt_node_t : public kaitai::kstruct { public: fdt_node_t(kaitai::kstream* p__io, dtb_t::fdt_block_t* p__parent = 0, dtb_t* p__root = 0); private: void _read(); void _clean_up(); public: ~fdt_node_t(); private: fdt_t m_type; kaitai::kstruct* m_body; bool n_body; public: bool _is_null_body() { body(); return n_body; }; private: dtb_t* m__root; dtb_t::fdt_block_t* m__parent; public: fdt_t type() const { return m_type; } kaitai::kstruct* body() const { return m_body; } dtb_t* _root() const { return m__root; } dtb_t::fdt_block_t* _parent() const { return m__parent; } }; class fdt_begin_node_t : public kaitai::kstruct { public: fdt_begin_node_t(kaitai::kstream* p__io, dtb_t::fdt_node_t* p__parent = 0, dtb_t* p__root = 0); private: void _read(); void _clean_up(); public: ~fdt_begin_node_t(); private: std::string m_name; std::string m_padding; dtb_t* m__root; dtb_t::fdt_node_t* m__parent; public: std::string name() const { return m_name; } std::string padding() const { return m_padding; } dtb_t* _root() const { return m__root; } dtb_t::fdt_node_t* _parent() const { return m__parent; } }; private: bool f_memory_reservation_block; memory_block_t* m_memory_reservation_block; public: memory_block_t* memory_reservation_block(); private: bool f_structure_block; fdt_block_t* m_structure_block; public: fdt_block_t* structure_block(); private: bool f_strings_block; strings_t* m_strings_block; public: strings_t* strings_block(); private: std::string m_magic; uint32_t m_total_size; uint32_t m_ofs_structure_block; uint32_t m_ofs_strings_block; uint32_t m_ofs_memory_reservation_block; uint32_t m_version; uint32_t m_min_compatible_version; uint32_t m_boot_cpuid_phys; uint32_t m_len_strings_block; uint32_t m_len_structure_block; dtb_t* m__root; kaitai::kstruct* m__parent; std::string m__raw_memory_reservation_block; kaitai::kstream* m__io__raw_memory_reservation_block; std::string m__raw_structure_block; kaitai::kstream* m__io__raw_structure_block; std::string m__raw_strings_block; kaitai::kstream* m__io__raw_strings_block; public: std::string magic() const { return m_magic; } uint32_t total_size() const { return m_total_size; } uint32_t ofs_structure_block() const { return m_ofs_structure_block; } uint32_t ofs_strings_block() const { return m_ofs_strings_block; } uint32_t ofs_memory_reservation_block() const { return m_ofs_memory_reservation_block; } uint32_t version() const { return m_version; } uint32_t min_compatible_version() const { return m_min_compatible_version; } uint32_t boot_cpuid_phys() const { return m_boot_cpuid_phys; } uint32_t len_strings_block() const { return m_len_strings_block; } uint32_t len_structure_block() const { return m_len_structure_block; } dtb_t* _root() const { return m__root; } kaitai::kstruct* _parent() const { return m__parent; } std::string _raw_memory_reservation_block() const { return m__raw_memory_reservation_block; } kaitai::kstream* _io__raw_memory_reservation_block() const { return m__io__raw_memory_reservation_block; } std::string _raw_structure_block() const { return m__raw_structure_block; } kaitai::kstream* _io__raw_structure_block() const { return m__io__raw_structure_block; } std::string _raw_strings_block() const { return m__raw_strings_block; } kaitai::kstream* _io__raw_strings_block() const { return m__io__raw_strings_block; } }; #endif // DTB_H_
27.713855
111
0.655364
[ "vector" ]
d7e8d5be7e888b5f92bee00af946d83a69c09e1f
2,988
h
C
src/Terrain/Chunk.h
anandrav/AnandCraft
12a8047b4ec55cd1573a4159cc9736aa0ce18797
[ "MIT" ]
1
2020-04-29T01:46:33.000Z
2020-04-29T01:46:33.000Z
src/Terrain/Chunk.h
anandrav/AnandCraft
12a8047b4ec55cd1573a4159cc9736aa0ce18797
[ "MIT" ]
null
null
null
src/Terrain/Chunk.h
anandrav/AnandCraft
12a8047b4ec55cd1573a4159cc9736aa0ce18797
[ "MIT" ]
null
null
null
/* * Chunk.h * * Chunk of blocks. */ #pragma once #include "ChunkCoords.h" #include "ChunkData.h" #include "../Entity.h" #include "../Graphics/Mesh.h" #include "ChunkIndex.h" #include <shared_mutex> #include <memory> struct Direction; class Terrain; class Chunk : public std::enable_shared_from_this<Chunk> { public: Chunk(); ~Chunk() = default; Chunk(Chunk&) = delete; Chunk& operator=(Chunk&) = delete; // initializes Chunk with coords and sends load job and build job to thread queue void set_active(ChunkCoords coords_); // thread safe, atomically deinitializes Chunk, returns true if successful // returns false if jobs are in progress or Chunk must be saved // if Chunk needed to be saved, save job is sent to thread queue bool try_set_inactive(); // thread safe BlockData get_block(ChunkIndex indices) const; void set_block(ChunkIndex indices, BlockData block); // thread safe void render_opaque(const Camera& camera) const; void render_transparent(const Camera& camera) const; private: // thread safe // loads data from file or generates from seed if no save data void load_job(); // thread safe void save_job(); // thread safe // build meshes using chunk data void mesh_job(); void calculate_translation(); void build_opaque_vertices_and_indices(std::vector<Vertex>& vertices, std::vector<unsigned>& indices) const; void build_transarent_vertices_and_indices(std::vector<Vertex>& vertices, std::vector<unsigned>& indices) const; void append_block_face(std::vector<Vertex>& vertices, std::vector<unsigned int>& indices, const ChunkIndex& chunk_indices, const BlockData& current, CubeFace face) const; bool should_draw_opaque_face(const ChunkIndex& index, const Direction& direction) const; bool should_draw_transparent_face(const ChunkIndex& index, const Direction& direction) const; void generate_data_from_seed(); void load_data_from_seed(); std::string get_chunk_filename() const; Terrain* terrain; mutable std::shared_mutex mut; ChunkCoords coords; ChunkBlocks blocks; bool active; bool wrapping_up; bool can_render; bool dirty; int mesh_jobs; int load_jobs; int save_jobs; Mesh opaque_mesh; Mesh transparent_mesh; glm::mat4 translation; }; struct Direction { std::tuple<int,int,int> vec; CubeFace face; bool (ChunkIndex::*advance_plane)(); }; static const std::array<Direction, 6> directions = {{ { {-1, 0, 0}, CubeFace::XNEG, &ChunkIndex::advance_yz }, { {1, 0, 0}, CubeFace::XPOS, &ChunkIndex::advance_yz }, { {0, -1, 0}, CubeFace::YNEG, &ChunkIndex::advance_xz }, { {0, 1, 0}, CubeFace::YPOS, &ChunkIndex::advance_xz }, { {0, 0, -1}, CubeFace::ZNEG, &ChunkIndex::advance_xy }, { {0, 0, 1}, CubeFace::ZPOS, &ChunkIndex::advance_xy } }};
27.925234
116
0.672021
[ "mesh", "vector" ]
cc19d4ede7a68a52b97d229469e3ed29797e6652
2,963
h
C
sources/thelib/include/protocols/protocolfactorymanager.h
rdkcmf/rdkc-rms
65ab1efcee9e3de46a888c125f591cd48b815601
[ "Apache-2.0" ]
3
2020-07-30T19:41:00.000Z
2020-10-28T12:52:37.000Z
sources/thelib/include/protocols/protocolfactorymanager.h
rdkcmf/rdkc-rms
65ab1efcee9e3de46a888c125f591cd48b815601
[ "Apache-2.0" ]
null
null
null
sources/thelib/include/protocols/protocolfactorymanager.h
rdkcmf/rdkc-rms
65ab1efcee9e3de46a888c125f591cd48b815601
[ "Apache-2.0" ]
2
2020-05-11T03:19:00.000Z
2021-07-07T17:40:47.000Z
/** ########################################################################## # If not stated otherwise in this file or this component's LICENSE # file the following copyright and licenses apply: # # Copyright 2019 RDK Management # # 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. ########################################################################## **/ #ifndef _PROTOCOLFACTORYMANAGER_H #define _PROTOCOLFACTORYMANAGER_H #include "common.h" class BaseProtocolFactory; class BaseProtocol; /*! @class ProtocolFactoryManager @brief Class that manages protocol factories. */ class DLLEXP ProtocolFactoryManager { private: static map<uint32_t, BaseProtocolFactory *> _factoriesById; static map<uint64_t, BaseProtocolFactory *> _factoriesByProtocolId; static map<string, BaseProtocolFactory *> _factoriesByChainName; public: //(Un)Register functionality /*! @brief Registers the atomic protocols and protocol chains of the factory. @param pFactory: Pointer to the BaseProtocolFactory that contains the protocols and protocol chains. */ static bool RegisterProtocolFactory(BaseProtocolFactory *pFactory); /*! @brief Erases the atomic protocols and protocol chains of the factory @param factoryId: ID of the protocol factory to be erased. */ static bool UnRegisterProtocolFactory(uint32_t factoryId); /*! @brief Erases the atomic protocols and protocol chains of the factory @param pFactory: Pointer to the BaseProtocolFactory that contains the protocols and protocol chains. */ static bool UnRegisterProtocolFactory(BaseProtocolFactory *pFactory); //protocol creation /*! @brief Resolves the protocol chain based on the given name. @param name: Name of the protocol chain to be resolved. */ static vector<uint64_t> ResolveProtocolChain(string name); /*! @brief Creates protocol chains. @param name: The chain's name in string. This will be resolved using the ResolveProtocolChain function. @param parameters: The parameters that come with the chain. */ static BaseProtocol *CreateProtocolChain(string name, Variant &parameters); /*! @brief The function that spawns the protocols in the protocol chain. @param chain: Vector that resulted from resolving the protocol chain. @param parameters: The parameters that come with the chain. */ static BaseProtocol *CreateProtocolChain(vector<uint64_t> &chain, Variant &parameters); private: static string Dump(); }; #endif /* _PROTOCOLFACTORYMANAGER_H */
34.453488
105
0.736753
[ "vector" ]
cc36248789fd3d3110e60a9f81043550aa6bb2f7
11,050
h
C
Metadata/AudioMetadata.h
sonoramac/SFBAudioEngine
9ad7e03e71914ce446cb7ec11af6eeac5d84762d
[ "BSD-3-Clause" ]
9
2015-03-12T20:37:08.000Z
2017-11-06T03:00:41.000Z
External/SFBAudioEngine/Metadata/AudioMetadata.h
Rm1210/Sonora
8e78d101e3e8209a5b7bce183e20f03653d95025
[ "BSD-3-Clause" ]
null
null
null
External/SFBAudioEngine/Metadata/AudioMetadata.h
Rm1210/Sonora
8e78d101e3e8209a5b7bce183e20f03653d95025
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Stephen F. Booth <me@sbooth.org> * All Rights Reserved. * * 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 Stephen F. Booth 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. */ #pragma once #include <CoreFoundation/CoreFoundation.h> #include <vector> #include "AttachedPicture.h" // ======================================== // Error Codes // ======================================== extern const CFStringRef AudioMetadataErrorDomain; enum { AudioMetadataFileFormatNotRecognizedError = 0, AudioMetadataFileFormatNotSupportedError = 1, AudioMetadataInputOutputError = 2 }; // ======================================== // Key names for the metadata dictionary (for use with HasUnsavedChangesForKey()) // ======================================== extern const CFStringRef kPropertiesFormatNameKey; extern const CFStringRef kPropertiesTotalFramesKey; extern const CFStringRef kPropertiesChannelsPerFrameKey; extern const CFStringRef kPropertiesBitsPerChannelKey; extern const CFStringRef kPropertiesSampleRateKey; extern const CFStringRef kPropertiesDurationKey; extern const CFStringRef kPropertiesBitrateKey; extern const CFStringRef kMetadataTitleKey; extern const CFStringRef kMetadataAlbumTitleKey; extern const CFStringRef kMetadataArtistKey; extern const CFStringRef kMetadataAlbumArtistKey; extern const CFStringRef kMetadataGenreKey; extern const CFStringRef kMetadataComposerKey; extern const CFStringRef kMetadataReleaseDateKey; extern const CFStringRef kMetadataCompilationKey; extern const CFStringRef kMetadataTrackNumberKey; extern const CFStringRef kMetadataTrackTotalKey; extern const CFStringRef kMetadataDiscNumberKey; extern const CFStringRef kMetadataDiscTotalKey; extern const CFStringRef kMetadataLyricsKey; extern const CFStringRef kMetadataBPMKey; extern const CFStringRef kMetadataRatingKey; extern const CFStringRef kMetadataCommentKey; extern const CFStringRef kMetadataISRCKey; extern const CFStringRef kMetadataMCNKey; extern const CFStringRef kMetadataMusicBrainzReleaseIDKey; extern const CFStringRef kMetadataMusicBrainzRecordingIDKey; extern const CFStringRef kMetadataTitleSortOrderKey; extern const CFStringRef kMetadataAlbumTitleSortOrderKey; extern const CFStringRef kMetadataArtistSortOrderKey; extern const CFStringRef kMetadataAlbumArtistSortOrderKey; extern const CFStringRef kMetadataComposerSortOrderKey; extern const CFStringRef kMetadataGroupingKey; extern const CFStringRef kMetadataAdditionalMetadataKey; extern const CFStringRef kReplayGainReferenceLoudnessKey; extern const CFStringRef kReplayGainTrackGainKey; extern const CFStringRef kReplayGainTrackPeakKey; extern const CFStringRef kReplayGainAlbumGainKey; extern const CFStringRef kReplayGainAlbumPeakKey; // ======================================== // Base class for all audio metadata reader/writer classes // ======================================== class AudioMetadata { public: // ======================================== // Information on supported file formats static CFArrayRef CreateSupportedFileExtensions(); static CFArrayRef CreateSupportedMIMETypes(); static bool HandlesFilesWithExtension(CFStringRef extension); static bool HandlesMIMEType(CFStringRef mimeType); // ======================================== // Factory method that returns an AudioMetadata object for the specified URL, or nullptr on failure static AudioMetadata * CreateMetadataForURL(CFURLRef url, CFErrorRef *error = nullptr); // ======================================== // Destruction virtual ~AudioMetadata(); // This class is non-copyable AudioMetadata(const AudioMetadata& rhs) = delete; AudioMetadata& operator=(const AudioMetadata& rhs) = delete; // ======================================== // The URL containing this metadata inline CFURLRef GetURL() const { return mURL; } void SetURL(CFURLRef URL); // ======================================== // File access virtual bool ReadMetadata(CFErrorRef *error = nullptr) = 0; virtual bool WriteMetadata(CFErrorRef *error = nullptr) = 0; // ======================================== // Change management bool HasUnsavedChanges() const; void RevertUnsavedChanges(); inline bool HasUnsavedChangesForKey(CFStringRef key) const { return CFDictionaryContainsKey(mChangedMetadata, key); } // ======================================== // Properties access (if available) CFStringRef GetFormatName() const; CFNumberRef GetTotalFrames() const; CFNumberRef GetChannelsPerFrame() const; CFNumberRef GetBitsPerChannel() const; CFNumberRef GetSampleRate() const; // in Hz CFNumberRef GetDuration() const; // in sec CFNumberRef GetBitrate() const; // in KiB/sec // ======================================== // Metadata access CFStringRef GetTitle() const; void SetTitle(CFStringRef title); CFStringRef GetAlbumTitle() const; void SetAlbumTitle(CFStringRef albumTitle); CFStringRef GetArtist() const; void SetArtist(CFStringRef artist); CFStringRef GetAlbumArtist() const; void SetAlbumArtist(CFStringRef albumArtist); CFStringRef GetGenre() const; void SetGenre(CFStringRef genre); CFStringRef GetComposer() const; void SetComposer(CFStringRef composer); CFStringRef GetReleaseDate() const; void SetReleaseDate(CFStringRef releaseDate); CFBooleanRef GetCompilation() const; void SetCompilation(CFBooleanRef releaseDate); CFNumberRef GetTrackNumber() const; void SetTrackNumber(CFNumberRef trackNumber); CFNumberRef GetTrackTotal() const; void SetTrackTotal(CFNumberRef trackTotal); CFNumberRef GetDiscNumber() const; void SetDiscNumber(CFNumberRef discNumber); CFNumberRef GetDiscTotal() const; void SetDiscTotal(CFNumberRef discTotal); CFStringRef GetLyrics() const; void SetLyrics(CFStringRef lyrics); CFNumberRef GetBPM() const; void SetBPM(CFNumberRef BPM); CFNumberRef GetRating() const; void SetRating(CFNumberRef rating); CFStringRef GetComment() const; void SetComment(CFStringRef comment); CFStringRef GetMCN() const; void SetMCN(CFStringRef mcn); CFStringRef GetISRC() const; void SetISRC(CFStringRef isrc); CFStringRef GetMusicBrainzReleaseID() const; void SetMusicBrainzReleaseID(CFStringRef releaseID); CFStringRef GetMusicBrainzRecordingID() const; void SetMusicBrainzRecordingID(CFStringRef recordingID); CFStringRef GetTitleSortOrder() const; void SetTitleSortOrder(CFStringRef titleSortOrder); CFStringRef GetAlbumTitleSortOrder() const; void SetAlbumTitleSortOrder(CFStringRef albumTitleSortOrder); CFStringRef GetArtistSortOrder() const; void SetArtistSortOrder(CFStringRef artistSortOrder); CFStringRef GetAlbumArtistSortOrder() const; void SetAlbumArtistSortOrder(CFStringRef albumArtistSortOrder); CFStringRef GetComposerSortOrder() const; void SetComposerSortOrder(CFStringRef composerSortOrder); CFStringRef GetGrouping() const; void SetGrouping(CFStringRef grouping); // ======================================== // Additional metadata CFDictionaryRef GetAdditionalMetadata() const; void SetAdditionalMetadata(CFDictionaryRef additionalMetadata); // ======================================== // Replay gain information CFNumberRef GetReplayGainReferenceLoudness() const; void SetReplayGainReferenceLoudness(CFNumberRef referenceLoudness); CFNumberRef GetReplayGainTrackGain() const; void SetReplayGainTrackGain(CFNumberRef trackGain); CFNumberRef GetReplayGainTrackPeak() const; void SetReplayGainTrackPeak(CFNumberRef trackPeak); CFNumberRef GetReplayGainAlbumGain() const; void SetReplayGainAlbumGain(CFNumberRef albumGain); CFNumberRef GetReplayGainAlbumPeak() const; void SetReplayGainAlbumPeak(CFNumberRef albumPeak); // ======================================== // Album artwork const std::vector<AttachedPicture *> GetAttachedPictures() const; const std::vector<AttachedPicture *> GetAttachedPicturesOfType(AttachedPicture::Type type) const; void AttachPicture(AttachedPicture *picture); // AudioMetadata takes over ownership of picture void RemoveAttachedPicture(AttachedPicture *picture); void RemoveAttachedPicturesOfType(AttachedPicture::Type type); void RemoveAllAttachedPictures(); protected: // ======================================== // Data members CFURLRef mURL; // The location of the stream to be read/written CFMutableDictionaryRef mMetadata; // The metadata information CFMutableDictionaryRef mChangedMetadata; // The metadata information that has been changed but not saved // ======================================== // For subclass use only AudioMetadata(); AudioMetadata(CFURLRef url); // mPictures is private to prevent direct subclass manipulation, so the following methods are provided void AddSavedPicture(AttachedPicture *picture); // Subclasses should call this after a successful save operation void MergeChangedMetadataIntoMetadata(); // Type-specific access CFStringRef GetStringValue(CFStringRef key) const; CFNumberRef GetNumberValue(CFStringRef key) const; // Generic access CFTypeRef GetValue(CFStringRef key) const; void SetValue(CFStringRef key, CFTypeRef value); private: // It is bad form to use a std::vector of raw pointers (exceptions can cause memory leaks), however I don't // want to use boost solely for this single data member. // Sadly, clang's libc++ doesn't work on Snow Leopard otherwise I would use std::vector<std::shared_ptr<AttachedPicture>> // std::vector<std::shared_ptr<AttachedPicture>> mPictures; std::vector<AttachedPicture *> mPictures; // The attached picture information };
36.956522
122
0.744977
[ "object", "vector" ]
cc363cafece2f639a59c5a31bc7942bc323a9397
5,958
h
C
Framework/assets/mesh/CMeshInstanceLoader.h
echo-Mike/goOGL
bf5b58a7ecc5783aad0177c375cdb53e59880d07
[ "MIT" ]
null
null
null
Framework/assets/mesh/CMeshInstanceLoader.h
echo-Mike/goOGL
bf5b58a7ecc5783aad0177c375cdb53e59880d07
[ "MIT" ]
null
null
null
Framework/assets/mesh/CMeshInstanceLoader.h
echo-Mike/goOGL
bf5b58a7ecc5783aad0177c375cdb53e59880d07
[ "MIT" ]
null
null
null
#ifndef MESHINSTANCELOADER_H #define MESHINSTANCELOADER_H "[0.0.5@CMeshInstanceLoader.h]" /* * DESCRIPTION: * Module contains implementation of mesh instance loader class * and general mesh instance interface. * AUTHOR: * Mikhail Demchenko * mailto:dev.echo.mike@gmail.com * https://github.com/echo-Mike */ //STD #include <vector> #include <type_traits> //OUR #include "assets\shader\CShader.h" //DEBUG #ifdef DEBUG_MESHINSTANCELOADER #ifndef DEBUG_OUT #define DEBUG_OUT std::cout #endif #ifndef DEBUG_NEXT_LINE #define DEBUG_NEXT_LINE std::endl #endif #endif /* Common interface class for mesh instance data declaration. * Class abstract template definition: MeshInstanceDataInterface */ template< class TShader = Shader > class MeshInstanceDataInterface { public: //Bind instance data to shader virtual void bindData() = 0; //Set shader of instance virtual void setShader(TShader *_shader) = 0; //RTTI virtual ~MeshInstanceDataInterface() {} }; /* Load controller for mesh instance data. * Class definition: MultipleMeshInstanceLoader */ template < class TShader = Shader > class MultipleMeshInstanceLoader { public: //The base interface class of handled instances typedef MeshInstanceDataInterface<TShader> InstanceInterface; //The type of instance container used typedef std::vector<InstanceInterface*> InstanceContainer; //Container of instance data InstanceContainer instances; //Push instance data to instance array void pushInstance(InstanceInterface* _data) { try { instances.push_back(_data); } catch (std::length_error e) { #ifdef DEBUG_MESHINSTANCELOADER DEBUG_OUT << "ERROR::MULTIPLE_MESH_INSTANCE_LOADER::pushInstance::OUT_OF_RANGE" << DEBUG_NEXT_LINE; DEBUG_OUT << "\tMessege: Can't push more instance data." << DEBUG_NEXT_LINE; DEBUG_OUT << "\tError string: " << e.what() << DEBUG_NEXT_LINE; #endif } catch (...) { #ifdef DEBUG_MESHINSTANCELOADER DEBUG_OUT << "ERROR::MULTIPLE_MESH_INSTANCE_LOADER::pushInstance::UNKONWN"<< DEBUG_NEXT_LINE; #endif throw; } } //Pop last instance data from instance array void popInstance() { if (instances.empty()) { #ifdef DEBUG_MESHINSTANCELOADER DEBUG_OUT << "ERROR::MULTIPLE_MESH_INSTANCE_LOADER::popInstance::OUT_OF_RANGE" << DEBUG_NEXT_LINE; DEBUG_OUT << "\tMessege: Can't pop from empty instance array." << DEBUG_NEXT_LINE; #endif } else { instances.pop_back(); } } //Create new instance of type T by move-constructing from pointer template < class T > void newInstance(T* _valueptr) { if (std::is_base_of<InstanceInterface, T>::value) { if (std::is_copy_constructible<T>::value) { instances.push_back(nullptr); instances.back() = new T(std::move(*_valueptr)); } else { #ifdef DEBUG_MESHINSTANCELOADER DEBUG_OUT << "ERROR::MULTIPLE_MESH_INSTANCE_LOADER::newInstance::INVALID_TYPE" << DEBUG_NEXT_LINE; DEBUG_OUT << "\tMessege: Type T isn't copy constructible." << DEBUG_NEXT_LINE; #endif } } else { #ifdef DEBUG_MESHINSTANCELOADER DEBUG_OUT << "ERROR::MULTIPLE_MESH_INSTANCE_LOADER::newInstance::INVALID_TYPE" << DEBUG_NEXT_LINE; DEBUG_OUT << "\tMessege: InstanceDataInterface must be the base class of T." << DEBUG_NEXT_LINE; #endif } } //Create new instance of type T by move-constructing template < class T > void newInstance(T&& _value) { if (std::is_base_of<InstanceInterface, T>::value) { if (std::is_copy_constructible<T>::value) { instances.push_back(nullptr); instances.back() = new T(std::move(_value)); } else { #ifdef DEBUG_MESHINSTANCELOADER DEBUG_OUT << "ERROR::MULTIPLE_MESH_INSTANCE_LOADER::newInstance::INVALID_TYPE" << DEBUG_NEXT_LINE; DEBUG_OUT << "\tMessege: Type T isn't copy constructible." << DEBUG_NEXT_LINE; #endif } } else { #ifdef DEBUG_MESHINSTANCELOADER DEBUG_OUT << "ERROR::MULTIPLE_MESH_INSTANCE_LOADER::newInstance::INVALID_TYPE" << DEBUG_NEXT_LINE; DEBUG_OUT << "\tMessege: InstanceDataInterface must be the base class of T." << DEBUG_NEXT_LINE; #endif } } InstanceInterface* operator[] (const int _index) { return instances.at(_index); } protected: /* Load instance data * Instance data expected to be derived from InstanceDataInterface */ void bindInstance(int index) { try { instances.at(index)->bindData(); } catch (std::out_of_range e) { #ifdef DEBUG_MESHINSTANCELOADER DEBUG_OUT << "ERROR::MULTIPLE_MESH_INSTANCE_LOADER::bindInstance::OUT_OF_RANGE" << DEBUG_NEXT_LINE; DEBUG_OUT << "\tIn index: " << index << DEBUG_NEXT_LINE; DEBUG_OUT << "Error string: " << e.what() << DEBUG_NEXT_LINE; #endif return; } catch (...) { #ifdef DEBUG_MESHINSTANCELOADER DEBUG_OUT << "ERROR::MULTIPLE_MESH_INSTANCE_LOADER::bindInstance::UNKONWN"<< DEBUG_NEXT_LINE; #endif throw; } } public: /* * Practically now the first thing i don't understand is * "Why on Earth i created this set of virtual functions?" * The second is "How compiler distinguish calls between * MultipleInstanceLoader::drawInstances() and SimpleModel::drawInstances() of same object?" * This functions must be total abstract stuff, but object of this class must be constructible. * This section must be redone properly. */ //Draw one instance of model using instance data virtual void drawInstance(int index) { return; } //Draw multiple instances of model using their data virtual void drawInstances(int start_index = 0, int count = 1) { if (count < 1) { #ifdef DEBUG_MESHINSTANCELOADER DEBUG_OUT << "ERROR::MULTIPLE_MESH_INSTANCE_LOADER::drawInstances::INVALID_COUNT: " << count << DEBUG_NEXT_LINE; #endif return; } for (int _index = start_index; _index < start_index + count; _index++) this->drawInstance(_index); } //Set shader for all handled instances virtual void setShader(TShader *_shader) { for (auto &_value : instances) _value->setShader(_shader); } }; #endif
31.52381
116
0.725411
[ "mesh", "object", "vector", "model" ]
cc381c2dc21d9654edd301e5a973ad0ba8213cf3
4,026
h
C
src/lib/mathtools/affine/Point.h
Ibujah/compactskel
8a54b5f0123490c4e8120537ae2b56d5ec2a34c9
[ "MIT" ]
4
2019-04-15T08:50:30.000Z
2021-02-03T10:44:03.000Z
src/lib/mathtools/affine/Point.h
Ibujah/evalshape
345d95184a47a87e6aae2f2de126b88b9edd3ac6
[ "MIT" ]
null
null
null
src/lib/mathtools/affine/Point.h
Ibujah/evalshape
345d95184a47a87e6aae2f2de126b88b9edd3ac6
[ "MIT" ]
null
null
null
/* Copyright (c) 2016 Bastien Durix 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. */ /** * \file Point.h * \brief Defines a point in an affine space * \author Bastien Durix */ #ifndef _POINT_H_ #define _POINT_H_ #include <Eigen/Dense> #include "Frame.h" /** * \brief Mathematical tools */ namespace mathtools { /** * \brief Affine tools */ namespace affine { /** * \brief Point in an affine space * * \tparam Dimension of the affine space */ template<unsigned int Dim> class Point { protected: /** * \brief Coordinates in canonic frame */ Eigen::Matrix<double,Dim,1> m_coords; public: /** * \brief Constructor * * \param coords coordinates of the point * \param frame frame in which the coordinates are expressed */ Point(const Eigen::Matrix<double,Dim,1> &coords = Eigen::Matrix<double,Dim,1>::Zero(), const typename Frame<Dim>::Ptr &frame = Frame<Dim>::CanonicFrame()) { m_coords = frame->getBasis()->getMatrix() * coords + frame->getOrigin(); } /** * \brief Constructor * * \param x x-coordinate of the point * \param y y-coordinate of the point * \param frame frame in which the coordinates are expressed */ Point(double x, double y, const typename Frame<Dim>::Ptr &frame = Frame<Dim>::CanonicFrame()) : Point(Eigen::Vector2d(x,y),frame) {} /** * \brief Constructor * * \param x x-coordinate of the point * \param y y-coordinate of the point * \param z z-coordinate of the point * \param frame frame in which the coordinates are expressed */ Point(double x, double y, double z, const typename Frame<Dim>::Ptr &frame = Frame<Dim>::CanonicFrame()) : Point(Eigen::Vector3d(x,y,z),frame) {} /** * \brief Coordinates getter * * \param frame frame in which get the coordinates * * \return coordinates vector */ inline const Eigen::Matrix<double,Dim,1> getCoords(const typename Frame<Dim>::Ptr &frame) const { return frame->getBasis()->getMatrixInverse() * (m_coords - frame->getOrigin()); } /** * \brief Coordinates getter in canonic frame * * \return coordinates vector */ inline const Eigen::Matrix<double,Dim,1>& getCoords() const { return m_coords; } /** * \brief Translation operator * * \param vec translation vector in canonic frame * * \return result point of the translation */ inline const Point<Dim> operator+(const Eigen::Matrix<double,Dim,1> &vec) const { return Point<Dim>(m_coords + vec); } /** * \brief Translation getter * * \param point origin of the translation vector * * \return translation vector in canonic frame */ inline const Eigen::Matrix<double,Dim,1> operator-(const Point<Dim> &point) const { return m_coords - point.m_coords; } }; } } #endif //_POINT_H_
27.575342
158
0.655241
[ "vector" ]
cc3a566e9d944b2bee417aa78f3100da2e5d0632
3,291
h
C
client/Client.h
jgbarbosa/display-wall
ed5c42a16a20065747707ea5bec969d799609d44
[ "MIT" ]
3
2017-03-14T23:19:49.000Z
2017-03-27T09:53:01.000Z
client/Client.h
jgbarbosa/display-wall
ed5c42a16a20065747707ea5bec969d799609d44
[ "MIT" ]
null
null
null
client/Client.h
jgbarbosa/display-wall
ed5c42a16a20065747707ea5bec969d799609d44
[ "MIT" ]
1
2017-03-16T16:11:44.000Z
2017-03-16T16:11:44.000Z
/* Copyright (c) 2016-17 Ingo Wald 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 "../common/MPI.h" #include "../common/WallConfig.h" #include "../common/CompressedTile.h" namespace ospray { namespace dw { using namespace ospcommon; /*! info structure that one can query from the display wall's info port. the app can query this info and then use this to have the client connect to the display wall */ struct ServiceInfo { /* constructor that initializes everything to default values */ ServiceInfo() : totalPixelsInWall(-1,-1), mpiPortName("<value not set>") {} /*! total pixels in the entire display wall, across all indvididual displays, and including bezels (future versios will allow to render to smaller resolutions, too - and have the clients upscale this - but for now the client(s) have to render at exactly this resolution */ vec2i totalPixelsInWall; /*! the MPI port name that the service is listening on client connections for (ie, the one to use with client::establishConnection) */ std::string mpiPortName; /*! whether this runs in stereo mode */ int stereo; /*! read a service info from a given hostName:port. The service has to already be running on that port Note this may throw a std::runtime_error if the connection cannot be established */ void getFrom(const std::string &hostName, const int portNo); }; /*! complete state of a given client rank */ struct Client { Client(const MPI::Group &me, const std::string &portName); /*! return total pixels in display wall, so renderer/app can know how large a frame buffer to use ... */ vec2i totalPixelsInWall() const; void writeTile(const PlainTile &tile); void endFrame(); const WallConfig *getWallConfig() const { return wallConfig; } private: void receiveDisplayConfig(); /*! establish connection between 'me' and the remote service */ void establishConnection(const std::string &portName); WallConfig *wallConfig; MPI::Group displayGroup; MPI::Group me; }; } // ::ospray::dw } // ::ospray
36.566667
78
0.690368
[ "render" ]
cc3f309730cccec66fb5bb77d2146566fb423777
385
h
C
Framework/Framework/src/lib/System/Engine/Delegate.h
kanekona/MyFramework
9c5f6d597106e491aa0c8b2fe83b79c79ac3ae1e
[ "MIT" ]
null
null
null
Framework/Framework/src/lib/System/Engine/Delegate.h
kanekona/MyFramework
9c5f6d597106e491aa0c8b2fe83b79c79ac3ae1e
[ "MIT" ]
null
null
null
Framework/Framework/src/lib/System/Engine/Delegate.h
kanekona/MyFramework
9c5f6d597106e491aa0c8b2fe83b79c79ac3ae1e
[ "MIT" ]
null
null
null
#pragma once #include <vector> #include <functional> class CDelegate; class CMultiDelegate; class CDelegate { std::function<void()> s_func; public: void AddFunc(const std::function<void()>& f); void Execution(); }; class CMultiDelegate { std::vector<CDelegate> Delegates; public: void Run(); void Reset(); void Add(const CDelegate& InDelegate); virtual ~CMultiDelegate(); };
16.041667
46
0.724675
[ "vector" ]
cc3f460f3868abe8b74b03f9719823fafc874a39
1,334
h
C
the_cxx_stl_a_tutorial_and_reference_2012/item5_2_5/item5_2_5.h
ckelsel/c_cxx_exercise
b32ebf9aa5c725aaaa4b2dc678b118a5e2a3bed5
[ "Apache-2.0" ]
null
null
null
the_cxx_stl_a_tutorial_and_reference_2012/item5_2_5/item5_2_5.h
ckelsel/c_cxx_exercise
b32ebf9aa5c725aaaa4b2dc678b118a5e2a3bed5
[ "Apache-2.0" ]
null
null
null
the_cxx_stl_a_tutorial_and_reference_2012/item5_2_5/item5_2_5.h
ckelsel/c_cxx_exercise
b32ebf9aa5c725aaaa4b2dc678b118a5e2a3bed5
[ "Apache-2.0" ]
null
null
null
/* * 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. */ #ifndef __ITEM_5_2_5_H__ #define __ITEM_5_2_5_H__ #include <string> #include <vector> #include <iostream> #include <memory> #include <functional> inline void sink(std::unique_ptr<std::string, std::function<void(std::string *p)>> ref) { } inline std::unique_ptr<std::string, std::function<void(std::string *p)>> source(int &val) { std::unique_ptr<std::string, std::function<void(std::string *p)>> ref(new std::string("source"), [&val](std::string *p) { std::cout << "delete " << *p << std::endl; val = 2; }); return ref; } class Member { public: Member() : val_(new int) { } private: Member(const Member &); void operator=(const Member &); std::unique_ptr<int> val_; }; #endif // __ITEM_5_2_5_H__
27.22449
100
0.671664
[ "vector" ]
cc5b11c0f50b4690649c7833183df9c08d688070
11,033
c
C
extern/gtk/demos/constraint-editor/constraint-view.c
PableteProgramming/download
013e35bb5c085e5dfdb57a3a0a39cdf2fd3064b8
[ "MIT" ]
null
null
null
extern/gtk/demos/constraint-editor/constraint-view.c
PableteProgramming/download
013e35bb5c085e5dfdb57a3a0a39cdf2fd3064b8
[ "MIT" ]
null
null
null
extern/gtk/demos/constraint-editor/constraint-view.c
PableteProgramming/download
013e35bb5c085e5dfdb57a3a0a39cdf2fd3064b8
[ "MIT" ]
null
null
null
/* Copyright (C) 2019 Red Hat, 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 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 * 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/>. */ #include <gtk/gtk.h> #include "constraint-view.h" struct _ConstraintView { GtkWidget parent; GListModel *model; GtkWidget *drag_widget; }; G_DEFINE_TYPE (ConstraintView, constraint_view, GTK_TYPE_WIDGET); static void constraint_view_dispose (GObject *object) { ConstraintView *view = CONSTRAINT_VIEW (object); GtkWidget *child; while ((child = gtk_widget_get_first_child (GTK_WIDGET (view))) != NULL) gtk_widget_unparent (child); g_clear_object (&view->model); G_OBJECT_CLASS (constraint_view_parent_class)->dispose (object); } static void constraint_view_class_init (ConstraintViewClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); object_class->dispose = constraint_view_dispose; gtk_widget_class_set_css_name (widget_class, "constraintview"); } static void update_weak_position (ConstraintView *self, GtkWidget *child, double x, double y) { GtkLayoutManager *manager; GtkConstraint *constraint; manager = gtk_widget_get_layout_manager (GTK_WIDGET (self)); constraint = (GtkConstraint *)g_object_get_data (G_OBJECT (child), "x-constraint"); if (constraint) { gtk_constraint_layout_remove_constraint (GTK_CONSTRAINT_LAYOUT (manager), constraint); g_object_set_data (G_OBJECT (child), "x-constraint", NULL); } if (x != -100) { constraint = gtk_constraint_new_constant (child, GTK_CONSTRAINT_ATTRIBUTE_CENTER_X, GTK_CONSTRAINT_RELATION_EQ, x, GTK_CONSTRAINT_STRENGTH_WEAK); g_object_set_data (G_OBJECT (constraint), "internal", (char *)"yes"); gtk_constraint_layout_add_constraint (GTK_CONSTRAINT_LAYOUT (manager), constraint); g_object_set_data (G_OBJECT (child), "x-constraint", constraint); } constraint = (GtkConstraint *)g_object_get_data (G_OBJECT (child), "y-constraint"); if (constraint) { gtk_constraint_layout_remove_constraint (GTK_CONSTRAINT_LAYOUT (manager), constraint); g_object_set_data (G_OBJECT (child), "y-constraint", NULL); } if (y != -100) { constraint = gtk_constraint_new_constant (child, GTK_CONSTRAINT_ATTRIBUTE_CENTER_Y, GTK_CONSTRAINT_RELATION_EQ, y, GTK_CONSTRAINT_STRENGTH_WEAK); g_object_set_data (G_OBJECT (constraint), "internal", (char *)"yes"); gtk_constraint_layout_add_constraint (GTK_CONSTRAINT_LAYOUT (manager), constraint); g_object_set_data (G_OBJECT (child), "y-constraint", constraint); } } static void drag_begin (GtkGestureDrag *drag, double start_x, double start_y, ConstraintView *self) { GtkWidget *widget; widget = gtk_widget_pick (GTK_WIDGET (self), start_x, start_y, GTK_PICK_DEFAULT); if (GTK_IS_LABEL (widget)) { widget = gtk_widget_get_ancestor (widget, GTK_TYPE_FRAME); if (widget && gtk_widget_get_parent (widget) == (GtkWidget *)self) { self->drag_widget = widget; } } } static void drag_update (GtkGestureDrag *drag, double offset_x, double offset_y, ConstraintView *self) { double x, y; if (!self->drag_widget) return; gtk_gesture_drag_get_start_point (drag, &x, &y); update_weak_position (self, self->drag_widget, x + offset_x, y + offset_y); } static void drag_end (GtkGestureDrag *drag, double offset_x, double offset_y, ConstraintView *self) { self->drag_widget = NULL; } static gboolean omit_internal (gpointer item, gpointer user_data) { if (g_object_get_data (G_OBJECT (item), "internal")) return FALSE; return TRUE; } static void constraint_view_init (ConstraintView *self) { GtkLayoutManager *manager; GtkEventController *controller; GListStore *list; GListModel *all_children; GListModel *all_constraints; GListModel *guides; GListModel *children; GListModel *constraints; GtkFilter *filter; manager = gtk_constraint_layout_new (); gtk_widget_set_layout_manager (GTK_WIDGET (self), manager); guides = gtk_constraint_layout_observe_guides (GTK_CONSTRAINT_LAYOUT (manager)); all_constraints = gtk_constraint_layout_observe_constraints (GTK_CONSTRAINT_LAYOUT (manager)); filter = GTK_FILTER (gtk_custom_filter_new (omit_internal, NULL, NULL)); constraints = (GListModel *)gtk_filter_list_model_new (all_constraints, filter); all_children = gtk_widget_observe_children (GTK_WIDGET (self)); filter = GTK_FILTER (gtk_custom_filter_new (omit_internal, NULL, NULL)); children = (GListModel *)gtk_filter_list_model_new (all_children, filter); list = g_list_store_new (G_TYPE_LIST_MODEL); g_list_store_append (list, children); g_list_store_append (list, guides); g_list_store_append (list, constraints); g_object_unref (children); g_object_unref (guides); g_object_unref (constraints); self->model = G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list))); controller = (GtkEventController *)gtk_gesture_drag_new (); g_signal_connect (controller, "drag-begin", G_CALLBACK (drag_begin), self); g_signal_connect (controller, "drag-update", G_CALLBACK (drag_update), self); g_signal_connect (controller, "drag-end", G_CALLBACK (drag_end), self); gtk_widget_add_controller (GTK_WIDGET (self), controller); } ConstraintView * constraint_view_new (void) { return g_object_new (CONSTRAINT_VIEW_TYPE, NULL); } void constraint_view_add_child (ConstraintView *view, const char *name) { GtkWidget *frame; GtkWidget *label; label = gtk_label_new (name); frame = gtk_frame_new (NULL); gtk_widget_add_css_class (frame, "child"); gtk_widget_set_name (frame, name); gtk_frame_set_child (GTK_FRAME (frame), label); gtk_widget_set_parent (frame, GTK_WIDGET (view)); update_weak_position (view, frame, 100, 100); } void constraint_view_remove_child (ConstraintView *view, GtkWidget *child) { update_weak_position (view, child, -100, -100); gtk_widget_unparent (child); } void constraint_view_add_guide (ConstraintView *view, GtkConstraintGuide *guide) { GtkConstraintLayout *layout; GtkWidget *frame; GtkWidget *label; const char *name; GtkConstraint *constraint; struct { const char *name; GtkConstraintAttribute attr; } names[] = { { "left-constraint", GTK_CONSTRAINT_ATTRIBUTE_LEFT }, { "top-constraint", GTK_CONSTRAINT_ATTRIBUTE_TOP }, { "width-constraint", GTK_CONSTRAINT_ATTRIBUTE_WIDTH }, { "height-constraint", GTK_CONSTRAINT_ATTRIBUTE_HEIGHT }, }; int i; name = gtk_constraint_guide_get_name (guide); label = gtk_label_new (name); g_object_bind_property (guide, "name", label, "label", G_BINDING_DEFAULT); frame = gtk_frame_new (NULL); gtk_widget_add_css_class (frame, "guide"); g_object_set_data (G_OBJECT (frame), "internal", (char *)"yes"); gtk_frame_set_child (GTK_FRAME (frame), label); gtk_widget_insert_after (frame, GTK_WIDGET (view), NULL); g_object_set_data (G_OBJECT (guide), "frame", frame); layout = GTK_CONSTRAINT_LAYOUT (gtk_widget_get_layout_manager (GTK_WIDGET (view))); gtk_constraint_layout_add_guide (layout, g_object_ref (guide)); for (i = 0; i < G_N_ELEMENTS (names); i++) { constraint = gtk_constraint_new (frame, names[i].attr, GTK_CONSTRAINT_RELATION_EQ, guide, names[i].attr, 1.0, 0.0, GTK_CONSTRAINT_STRENGTH_REQUIRED); g_object_set_data (G_OBJECT (constraint), "internal", (char *)"yes"); gtk_constraint_layout_add_constraint (layout, constraint); g_object_set_data (G_OBJECT (guide), names[i].name, constraint); } update_weak_position (view, frame, 150, 150); } void constraint_view_remove_guide (ConstraintView *view, GtkConstraintGuide *guide) { GtkConstraintLayout *layout; GtkWidget *frame; GtkConstraint *constraint; const char *names[] = { "left-constraint", "top-constraint", "width-constraint", "height-constraint" }; int i; layout = GTK_CONSTRAINT_LAYOUT (gtk_widget_get_layout_manager (GTK_WIDGET (view))); for (i = 0; i < G_N_ELEMENTS (names); i++) { constraint = (GtkConstraint*)g_object_get_data (G_OBJECT (guide), names[i]); gtk_constraint_layout_remove_constraint (layout, constraint); } frame = (GtkWidget *)g_object_get_data (G_OBJECT (guide), "frame"); update_weak_position (view, frame, -100, -100); gtk_widget_unparent (frame); gtk_constraint_layout_remove_guide (layout, guide); } void constraint_view_add_constraint (ConstraintView *view, GtkConstraint *constraint) { GtkLayoutManager *manager; manager = gtk_widget_get_layout_manager (GTK_WIDGET (view)); gtk_constraint_layout_add_constraint (GTK_CONSTRAINT_LAYOUT (manager), g_object_ref (constraint)); } void constraint_view_remove_constraint (ConstraintView *view, GtkConstraint *constraint) { GtkLayoutManager *manager; manager = gtk_widget_get_layout_manager (GTK_WIDGET (view)); gtk_constraint_layout_remove_constraint (GTK_CONSTRAINT_LAYOUT (manager), constraint); } GListModel * constraint_view_get_model (ConstraintView *view) { return view->model; }
31.887283
96
0.653041
[ "object", "model" ]
cc5bdb8c54d62da69e3cebfec86d776382383f91
81,333
c
C
profiles/mojoshader_profile_hlsl.c
YoYoGames/mojoshader
9d1045f2f8949ec3182ec35683b7f569f655e47a
[ "Zlib" ]
35
2021-06-28T21:19:34.000Z
2022-03-29T08:51:26.000Z
profiles/mojoshader_profile_hlsl.c
YoYoGames/mojoshader
9d1045f2f8949ec3182ec35683b7f569f655e47a
[ "Zlib" ]
42
2018-06-19T18:19:12.000Z
2021-06-16T02:13:12.000Z
profiles/mojoshader_profile_hlsl.c
YoYoGames/mojoshader
9d1045f2f8949ec3182ec35683b7f569f655e47a
[ "Zlib" ]
20
2018-07-29T22:31:12.000Z
2021-03-25T20:33:22.000Z
/** * MojoShader; generate shader programs from bytecode of compiled * Direct3D shaders. * * Please see the file LICENSE.txt in the source's root directory. * * This file written by Ryan C. Gordon. */ #define __MOJOSHADER_INTERNAL__ 1 #include "mojoshader_profile.h" #pragma GCC visibility push(hidden) // !!! FIXME: A lot of this is cut-and-paste from the GLSL/Metal versions. #if SUPPORT_PROFILE_HLSL #define EMIT_HLSL_OPCODE_UNIMPLEMENTED_FUNC(op) \ void emit_HLSL_##op(Context *ctx) { \ fail(ctx, #op " unimplemented in hlsl profile"); \ } static inline const char *get_HLSL_register_string(Context *ctx, const RegisterType regtype, const int regnum, char *regnum_str, const size_t regnum_size) { // turns out these are identical at the moment. return get_D3D_register_string(ctx,regtype,regnum,regnum_str,regnum_size); } // get_HLSL_register_string const char *get_HLSL_uniform_type(Context *ctx, const RegisterType rtype) { switch (rtype) { case REG_TYPE_CONST: return "float4"; case REG_TYPE_CONSTINT: return "int4"; case REG_TYPE_CONSTBOOL: return "bool"; default: fail(ctx, "BUG: used a uniform we don't know how to define."); } // switch return NULL; } // get_HLSL_uniform_type const char *get_HLSL_varname_in_buf(Context *ctx, RegisterType rt, int regnum, char *buf, const size_t len) { char regnum_str[16]; const char *regtype_str = get_HLSL_register_string(ctx, rt, regnum, regnum_str, sizeof (regnum_str)); snprintf(buf,len,"%s%s", regtype_str, regnum_str); return buf; } // get_HLSL_varname_in_buf const char *get_HLSL_varname(Context *ctx, RegisterType rt, int regnum) { char buf[64]; get_HLSL_varname_in_buf(ctx, rt, regnum, buf, sizeof(buf)); return StrDup(ctx, buf); } // get_HLSL_varname static inline const char *get_HLSL_const_array_varname_in_buf(Context *ctx, const int base, const int size, char *buf, const size_t buflen) { snprintf(buf, buflen, "const_array_%d_%d", base, size); return buf; } // get_HLSL_const_array_varname_in_buf const char *get_HLSL_const_array_varname(Context *ctx, int base, int size) { char buf[64]; get_HLSL_const_array_varname_in_buf(ctx, base, size, buf, sizeof(buf)); return StrDup(ctx, buf); } // get_HLSL_const_array_varname static inline const char *get_HLSL_input_array_varname(Context *ctx, char *buf, const size_t buflen) { snprintf(buf, buflen, "%s", "vertex_input_array"); return buf; } // get_HLSL_input_array_varname const char *get_HLSL_uniform_array_varname(Context *ctx, const RegisterType regtype, char *buf, const size_t len) { const char *type = get_HLSL_uniform_type(ctx, regtype); snprintf(buf, len, "uniforms_%s", type); return buf; } // get_HLSL_uniform_array_varname const char *get_HLSL_destarg_varname(Context *ctx, char *buf, size_t len) { const DestArgInfo *arg = &ctx->dest_arg; return get_HLSL_varname_in_buf(ctx, arg->regtype, arg->regnum, buf, len); } // get_HLSL_destarg_varname const char *get_HLSL_srcarg_varname(Context *ctx, const size_t idx, char *buf, size_t len) { if (idx >= STATICARRAYLEN(ctx->source_args)) { fail(ctx, "Too many source args"); *buf = '\0'; return buf; } // if const SourceArgInfo *arg = &ctx->source_args[idx]; return get_HLSL_varname_in_buf(ctx, arg->regtype, arg->regnum, buf, len); } // get_HLSL_srcarg_varname const char *make_HLSL_destarg_assign(Context *, char *, const size_t, const char *, ...) ISPRINTF(4,5); const char *make_HLSL_destarg_assign(Context *ctx, char *buf, const size_t buflen, const char *fmt, ...) { int need_parens = 0; const DestArgInfo *arg = &ctx->dest_arg; if (arg->writemask == 0) { *buf = '\0'; return buf; // no writemask? It's a no-op. } // if const char *clampleft = ""; const char *clampright = ""; if (arg->result_mod & MOD_SATURATE) { clampleft = "saturate("; clampright = ")"; } // if // MSDN says MOD_PP is a hint and many implementations ignore it. So do we. // CENTROID only allowed in DCL opcodes, which shouldn't come through here. assert((arg->result_mod & MOD_CENTROID) == 0); if (ctx->predicated) { fail(ctx, "predicated destinations unsupported"); // !!! FIXME *buf = '\0'; return buf; } // if char operation[256]; va_list ap; va_start(ap, fmt); const int len = vsnprintf(operation, sizeof (operation), fmt, ap); va_end(ap); if (len >= sizeof (operation)) { fail(ctx, "operation string too large"); // I'm lazy. :P *buf = '\0'; return buf; } // if const char *result_shift_str = ""; switch (arg->result_shift) { case 0x1: result_shift_str = " * 2.0"; break; case 0x2: result_shift_str = " * 4.0"; break; case 0x3: result_shift_str = " * 8.0"; break; case 0xD: result_shift_str = " / 8.0"; break; case 0xE: result_shift_str = " / 4.0"; break; case 0xF: result_shift_str = " / 2.0"; break; } // switch need_parens |= (result_shift_str[0] != '\0'); char regnum_str[16]; const char *regtype_str = get_HLSL_register_string(ctx, arg->regtype, arg->regnum, regnum_str, sizeof (regnum_str)); char writemask_str[6]; size_t i = 0; const int scalar = isscalar(ctx, ctx->shader_type, arg->regtype, arg->regnum); if (!scalar && !writemask_xyzw(arg->writemask)) { writemask_str[i++] = '.'; if (arg->writemask0) writemask_str[i++] = 'x'; if (arg->writemask1) writemask_str[i++] = 'y'; if (arg->writemask2) writemask_str[i++] = 'z'; if (arg->writemask3) writemask_str[i++] = 'w'; } // if writemask_str[i] = '\0'; assert(i < sizeof (writemask_str)); const char *leftparen = (need_parens) ? "(" : ""; const char *rightparen = (need_parens) ? ")" : ""; snprintf(buf, buflen, "%s%s%s = %s%s%s%s%s%s;", regtype_str, regnum_str, writemask_str,clampleft, leftparen, operation, rightparen, result_shift_str, clampright); // !!! FIXME: make sure the scratch buffer was large enough. return buf; } // make_HLSL_destarg_assign char *make_HLSL_swizzle_string(char *swiz_str, const size_t strsize, const int swizzle, const int writemask) { size_t i = 0; if ( (!no_swizzle(swizzle)) || (!writemask_xyzw(writemask)) ) { const int writemask0 = (writemask >> 0) & 0x1; const int writemask1 = (writemask >> 1) & 0x1; const int writemask2 = (writemask >> 2) & 0x1; const int writemask3 = (writemask >> 3) & 0x1; const int swizzle_x = (swizzle >> 0) & 0x3; const int swizzle_y = (swizzle >> 2) & 0x3; const int swizzle_z = (swizzle >> 4) & 0x3; const int swizzle_w = (swizzle >> 6) & 0x3; swiz_str[i++] = '.'; if (writemask0) swiz_str[i++] = swizzle_channels[swizzle_x]; if (writemask1) swiz_str[i++] = swizzle_channels[swizzle_y]; if (writemask2) swiz_str[i++] = swizzle_channels[swizzle_z]; if (writemask3) swiz_str[i++] = swizzle_channels[swizzle_w]; } // if assert(i < strsize); swiz_str[i] = '\0'; return swiz_str; } // make_HLSL_swizzle_string const char *make_HLSL_srcarg_string(Context *ctx, const size_t idx, const int writemask, char *buf, const size_t buflen) { *buf = '\0'; if (idx >= STATICARRAYLEN(ctx->source_args)) { fail(ctx, "Too many source args"); return buf; } // if const SourceArgInfo *arg = &ctx->source_args[idx]; const char *premod_str = ""; const char *postmod_str = ""; switch (arg->src_mod) { case SRCMOD_NEGATE: premod_str = "-"; break; case SRCMOD_BIASNEGATE: premod_str = "-("; postmod_str = " - 0.5)"; break; case SRCMOD_BIAS: premod_str = "("; postmod_str = " - 0.5)"; break; case SRCMOD_SIGNNEGATE: premod_str = "-(("; postmod_str = " - 0.5) * 2.0)"; break; case SRCMOD_SIGN: premod_str = "(("; postmod_str = " - 0.5) * 2.0)"; break; case SRCMOD_COMPLEMENT: premod_str = "(1.0 - "; postmod_str = ")"; break; case SRCMOD_X2NEGATE: premod_str = "-("; postmod_str = " * 2.0)"; break; case SRCMOD_X2: premod_str = "("; postmod_str = " * 2.0)"; break; case SRCMOD_DZ: fail(ctx, "SRCMOD_DZ unsupported"); return buf; // !!! FIXME postmod_str = "_dz"; break; case SRCMOD_DW: fail(ctx, "SRCMOD_DW unsupported"); return buf; // !!! FIXME postmod_str = "_dw"; break; case SRCMOD_ABSNEGATE: premod_str = "-abs("; postmod_str = ")"; break; case SRCMOD_ABS: premod_str = "abs("; postmod_str = ")"; break; case SRCMOD_NOT: premod_str = "!"; break; case SRCMOD_NONE: case SRCMOD_TOTAL: break; // stop compiler whining. } // switch const char *regtype_str = NULL; if (!arg->relative) { regtype_str = get_HLSL_varname_in_buf(ctx, arg->regtype, arg->regnum, (char *) alloca(64), 64); } // if const char *rel_lbracket = ""; char rel_offset[32] = { '\0' }; const char *rel_rbracket = ""; char rel_swizzle[4] = { '\0' }; const char *rel_regtype_str = ""; if (arg->relative) { if (arg->regtype == REG_TYPE_INPUT) regtype_str=get_HLSL_input_array_varname(ctx,(char*)alloca(64),64); else { assert(arg->regtype == REG_TYPE_CONST); const int arrayidx = arg->relative_array->index; const int offset = arg->regnum - arrayidx; assert(offset >= 0); if (arg->relative_array->constant) { const int arraysize = arg->relative_array->count; regtype_str = get_HLSL_const_array_varname_in_buf(ctx, arrayidx, arraysize, (char *) alloca(64), 64); if (offset != 0) snprintf(rel_offset, sizeof (rel_offset), "%d + ", offset); } // if else { regtype_str = get_HLSL_uniform_array_varname(ctx, arg->regtype, (char *) alloca(64), 64); if (offset == 0) { snprintf(rel_offset, sizeof (rel_offset), "ARRAYBASE_%d + ", arrayidx); } // if else { snprintf(rel_offset, sizeof (rel_offset), "(ARRAYBASE_%d + %d) + ", arrayidx, offset); } // else } // else } // else rel_lbracket = "["; rel_regtype_str = get_HLSL_varname_in_buf(ctx, arg->relative_regtype, arg->relative_regnum, (char *) alloca(64), 64); rel_swizzle[0] = '.'; rel_swizzle[1] = swizzle_channels[arg->relative_component]; rel_swizzle[2] = '\0'; rel_rbracket = "]"; } // if char swiz_str[6] = { '\0' }; if (!isscalar(ctx, ctx->shader_type, arg->regtype, arg->regnum)) { make_HLSL_swizzle_string(swiz_str, sizeof (swiz_str), arg->swizzle, writemask); } // if if (regtype_str == NULL) { fail(ctx, "Unknown source register type."); return buf; } // if snprintf(buf, buflen, "%s%s%s%s%s%s%s%s%s", premod_str, regtype_str, rel_lbracket, rel_offset, rel_regtype_str, rel_swizzle, rel_rbracket, swiz_str, postmod_str); // !!! FIXME: make sure the scratch buffer was large enough. return buf; } // make_HLSL_srcarg_string // generate some convenience functions. #define MAKE_HLSL_SRCARG_STRING_(mask, bitmask) \ static inline const char *make_HLSL_srcarg_string_##mask(Context *ctx, \ const size_t idx, char *buf, \ const size_t buflen) { \ return make_HLSL_srcarg_string(ctx, idx, bitmask, buf, buflen); \ } MAKE_HLSL_SRCARG_STRING_(x, (1 << 0)) MAKE_HLSL_SRCARG_STRING_(y, (1 << 1)) MAKE_HLSL_SRCARG_STRING_(z, (1 << 2)) MAKE_HLSL_SRCARG_STRING_(w, (1 << 3)) MAKE_HLSL_SRCARG_STRING_(scalar, (1 << 0)) MAKE_HLSL_SRCARG_STRING_(full, 0xF) MAKE_HLSL_SRCARG_STRING_(masked, ctx->dest_arg.writemask) MAKE_HLSL_SRCARG_STRING_(vec3, 0x7) MAKE_HLSL_SRCARG_STRING_(vec2, 0x3) #undef MAKE_HLSL_SRCARG_STRING_ // special cases for comparison opcodes... const char *get_HLSL_comparison_string_scalar(Context *ctx) { const char *comps[] = { "", ">", "==", ">=", "<", "!=", "<=" }; if (ctx->instruction_controls >= STATICARRAYLEN(comps)) { fail(ctx, "unknown comparison control"); return ""; } // if return comps[ctx->instruction_controls]; } // get_HLSL_comparison_string_scalar const char *get_HLSL_comparison_string_vector(Context *ctx) { return get_HLSL_comparison_string_scalar(ctx); // standard C operators work for vectors in HLSL. } // get_HLSL_comparison_string_vector void emit_HLSL_start(Context *ctx, const char *profilestr) { if (!shader_is_vertex(ctx) && !shader_is_pixel(ctx)) { failf(ctx, "Shader type %u unsupported in this profile.", (uint) ctx->shader_type); return; } // if if (!ctx->mainfn) { if (shader_is_vertex(ctx)) ctx->mainfn = StrDup(ctx, "VertexShader"); else if (shader_is_pixel(ctx)) ctx->mainfn = StrDup(ctx, "PixelShader"); } // if set_output(ctx, &ctx->mainline); ctx->indent++; } // emit_HLSL_start void emit_HLSL_RET(Context *ctx); void emit_HLSL_end(Context *ctx) { // !!! FIXME: maybe handle this at a higher level? // ps_1_* writes color to r0 instead oC0. We move it to the right place. // We don't have to worry about a RET opcode messing this up, since // RET isn't available before ps_2_0. if (shader_is_pixel(ctx) && !shader_version_atleast(ctx, 2, 0)) { set_used_register(ctx, REG_TYPE_COLOROUT, 0, 1); output_line(ctx, "oC0 = r0;"); } // if // !!! FIXME: maybe handle this at a higher level? // force a RET opcode if we're at the end of the stream without one. if (ctx->previous_opcode != OPCODE_RET) emit_HLSL_RET(ctx); } // emit_HLSL_end void emit_HLSL_phase(Context *ctx) { // no-op in HLSL. } // emit_HLSL_phase void output_HLSL_uniform_array(Context *ctx, const RegisterType regtype, const int size) { if (size > 0) { char buf[64]; get_HLSL_uniform_array_varname(ctx, regtype, buf, sizeof (buf)); const char *typ; switch (regtype) { case REG_TYPE_CONST: typ = "float4"; break; case REG_TYPE_CONSTINT: typ = "int4"; break; case REG_TYPE_CONSTBOOL: typ = "bool"; break; default: { fail(ctx, "BUG: used a uniform we don't know how to define."); return; } // default } // switch output_line(ctx, "%s %s[%d];", typ, buf, size); } // if } // output_HLSL_uniform_array void emit_HLSL_finalize(Context *ctx) { if (ctx->have_relative_input_registers) // !!! FIXME fail(ctx, "Relative addressing of input registers not supported."); // Check uniform_float4_count too since TEXBEM affects it if (ctx->uniform_count > 0 || ctx->uniform_float4_count > 0) { push_output(ctx, &ctx->preflight); output_line(ctx, "cbuffer %s_Uniforms : register(b0)", ctx->mainfn); output_line(ctx, "{"); ctx->indent++; output_HLSL_uniform_array(ctx, REG_TYPE_CONST, ctx->uniform_float4_count); output_HLSL_uniform_array(ctx, REG_TYPE_CONSTINT, ctx->uniform_int4_count); output_HLSL_uniform_array(ctx, REG_TYPE_CONSTBOOL, ctx->uniform_bool_count); ctx->indent--; output_line(ctx, "};"); output_blank_line(ctx); pop_output(ctx); } // if // Fill in the shader's mainline function signature. push_output(ctx, &ctx->mainline_intro); output_line(ctx, "%s%s %s(%s%s%s)", ctx->outputs ? ctx->mainfn : "void", ctx->outputs ? "_Output" : "", ctx->mainfn, ctx->inputs ? ctx->mainfn : "", ctx->inputs ? "_Input" : "", ctx->inputs ? " input" : ""); output_line(ctx, "{"); if (ctx->outputs) { ctx->indent++; output_line(ctx, "%s%s output = (%s%s) 0;", ctx->mainfn, "_Output", ctx->mainfn, "_Output"); push_output(ctx, &ctx->mainline); ctx->indent++; output_line(ctx, "return output;"); pop_output(ctx); } // if pop_output(ctx); if (ctx->inputs) { push_output(ctx, &ctx->inputs); output_line(ctx, "};"); output_blank_line(ctx); pop_output(ctx); } // if if (ctx->outputs) { push_output(ctx, &ctx->outputs); // !!! FIXME: Maybe have a better check for this? if (ctx->hlsl_outpos_name[0] != '\0') { output_line(ctx, "\tfloat4 m_%s : SV_Position;", ctx->hlsl_outpos_name); } // if output_line(ctx, "};"); output_blank_line(ctx); pop_output(ctx); } // if // throw some blank lines around to make source more readable. if (ctx->globals) // don't add a blank line if the section is empty. { push_output(ctx, &ctx->globals); output_blank_line(ctx); pop_output(ctx); } // if if (ctx->need_max_float) { push_output(ctx, &ctx->mainline_top); ctx->indent++; output_line(ctx, "#define FLT_MAX 1e38"); ctx->indent--; pop_output(ctx); } // if } // emit_HLSL_finalize void emit_HLSL_global(Context *ctx, RegisterType regtype, int regnum) { char varname[64]; get_HLSL_varname_in_buf(ctx, regtype, regnum, varname, sizeof (varname)); push_output(ctx, &ctx->mainline_top); ctx->indent++; switch (regtype) { case REG_TYPE_ADDRESS: if (shader_is_vertex(ctx)) output_line(ctx, "int4 %s;", varname); else if (shader_is_pixel(ctx)) // actually REG_TYPE_TEXTURE. { // We have to map texture registers to temps for ps_1_1, since // they work like temps, initialize with tex coords, and the // ps_1_1 TEX opcode expects to overwrite it. if (!shader_version_atleast(ctx, 1, 4)) output_line(ctx, "float4 %s = input.m_%s;",varname,varname); } // else if break; case REG_TYPE_PREDICATE: output_line(ctx, "bool4 %s;", varname); break; case REG_TYPE_TEMP: output_line(ctx, "float4 %s;", varname); break; case REG_TYPE_LOOP: break; // no-op. We declare these in for loops at the moment. case REG_TYPE_LABEL: break; // no-op. If we see it here, it means we optimized it out. default: fail(ctx, "BUG: we used a register we don't know how to define."); break; } // switch pop_output(ctx); } // emit_HLSL_global void emit_HLSL_array(Context *ctx, VariableList *var) { // All uniforms (except constant arrays, which are literally constant // data embedded in HLSL shaders) are now packed into a single array, // so we can batch the uniform transfers. So this doesn't actually // define an array here; the one, big array is emitted during // finalization instead. // However, we need to #define the offset into the one, big array here, // and let dereferences use that #define. const int base = var->index; const int hlslbase = ctx->uniform_float4_count; push_output(ctx, &ctx->mainline_top); ctx->indent++; output_line(ctx, "const int ARRAYBASE_%d = %d;", base, hlslbase); pop_output(ctx); var->emit_position = hlslbase; } // emit_HLSL_array void emit_HLSL_const_array(Context *ctx, const ConstantsList *clist, int base, int size) { char varname[64]; get_HLSL_const_array_varname_in_buf(ctx,base,size,varname,sizeof(varname)); const char *cstr = NULL; push_output(ctx, &ctx->mainline_top); ctx->indent++; output_line(ctx, "const float4 %s[%d] = {", varname, size); ctx->indent++; int i; for (i = 0; i < size; i++) { while (clist->constant.type != MOJOSHADER_UNIFORM_FLOAT) clist = clist->next; assert(clist->constant.index == (base + i)); char val0[32]; char val1[32]; char val2[32]; char val3[32]; floatstr(ctx, val0, sizeof (val0), clist->constant.value.f[0], 1); floatstr(ctx, val1, sizeof (val1), clist->constant.value.f[1], 1); floatstr(ctx, val2, sizeof (val2), clist->constant.value.f[2], 1); floatstr(ctx, val3, sizeof (val3), clist->constant.value.f[3], 1); output_line(ctx, "float4(%s, %s, %s, %s)%s", val0, val1, val2, val3, (i < (size-1)) ? "," : ""); clist = clist->next; } // for ctx->indent--; output_line(ctx, "};"); pop_output(ctx); } // emit_HLSL_const_array void emit_HLSL_uniform(Context *ctx, RegisterType regtype, int regnum, const VariableList *var) { // Now that we're pushing all the uniforms as one big array, pack these // down, so if we only use register c439, it'll actually map to // HLSL_uniforms_vec4[0]. As we push one big array, this will prevent // uploading unused data. char varname[64]; char name[64]; int index = 0; get_HLSL_varname_in_buf(ctx, regtype, regnum, varname, sizeof (varname)); push_output(ctx, &ctx->mainline_top); ctx->indent++; if (var == NULL) { get_HLSL_uniform_array_varname(ctx, regtype, name, sizeof (name)); if (regtype == REG_TYPE_CONST) index = ctx->uniform_float4_count; else if (regtype == REG_TYPE_CONSTINT) index = ctx->uniform_int4_count; else if (regtype == REG_TYPE_CONSTBOOL) index = ctx->uniform_bool_count; else // get_HLSL_uniform_array_varname() would have called fail(). assert(!(ctx->isfail)); output_line(ctx, "#define %s %s[%d]", varname, name, index); push_output(ctx, &ctx->mainline); ctx->indent++; output_line(ctx, "#undef %s", varname); // !!! FIXME: gross. pop_output(ctx); } // if else { const int arraybase = var->index; if (var->constant) { get_HLSL_const_array_varname_in_buf(ctx, arraybase, var->count, name, sizeof (name)); index = (regnum - arraybase); } // if else { assert(var->emit_position != -1); get_HLSL_uniform_array_varname(ctx, regtype, name, sizeof (name)); index = (regnum - arraybase) + var->emit_position; } // else output_line(ctx, "#define %s %s[%d];", varname, name, index); push_output(ctx, &ctx->mainline); ctx->indent++; output_line(ctx, "#undef %s", varname); // !!! FIXME: gross. pop_output(ctx); } // else pop_output(ctx); } // emit_HLSL_uniform void emit_HLSL_sampler(Context *ctx,int stage,TextureType ttype,int tb) { char var[64]; const char *texsuffix = NULL; switch (ttype) { case TEXTURE_TYPE_2D: texsuffix = "2D"; break; case TEXTURE_TYPE_CUBE: texsuffix = "Cube"; break; case TEXTURE_TYPE_VOLUME: texsuffix = "3D"; break; default: assert(!"unexpected texture type"); return; } // switch get_HLSL_varname_in_buf(ctx, REG_TYPE_SAMPLER, stage, var, sizeof(var)); push_output(ctx, &ctx->globals); output_line(ctx, "Texture%s %s_texture : register(t%d);", texsuffix, var, stage); output_line(ctx, "SamplerState %s : register(%s);", var, var); pop_output(ctx); if (tb) // This sampler used a ps_1_1 TEXBEM opcode? { push_output(ctx, &ctx->mainline_top); ctx->indent++; char name[64]; const int index = ctx->uniform_float4_count; ctx->uniform_float4_count += 2; get_HLSL_uniform_array_varname(ctx, REG_TYPE_CONST, name, sizeof(name)); output_line(ctx, "const float4 %s_texbem = %s[%d];", var, name, index); output_line(ctx, "const float4 %s_texbeml = %s[%d];", var, name, index + 1); pop_output(ctx); } // if } // emit_HLSL_sampler void emit_HLSL_attribute(Context *ctx, RegisterType regtype, int regnum, MOJOSHADER_usage usage, int index, int wmask, int flags) { // !!! FIXME: this function doesn't deal with write masks at all yet! const char *usage_str = NULL; char index_str[16] = { '\0' }; char var[64]; char a[256]; get_HLSL_varname_in_buf(ctx, regtype, regnum, var, sizeof (var)); //assert((flags & MOD_PP) == 0); // !!! FIXME: is PP allowed? if (index != 0) // !!! FIXME: a lot of these MUST be zero. snprintf(index_str, sizeof (index_str), "%u", (uint) index); if (shader_is_vertex(ctx)) { // pre-vs3 output registers. // these don't ever happen in DCL opcodes, I think. Map to vs_3_* // output registers. if (!shader_version_atleast(ctx, 3, 0)) { if (regtype == REG_TYPE_RASTOUT) { regtype = REG_TYPE_OUTPUT; index = regnum; switch ((const RastOutType) regnum) { case RASTOUT_TYPE_POSITION: usage = MOJOSHADER_USAGE_POSITION; break; case RASTOUT_TYPE_FOG: usage = MOJOSHADER_USAGE_FOG; break; case RASTOUT_TYPE_POINT_SIZE: usage = MOJOSHADER_USAGE_POINTSIZE; break; } // switch } // if else if (regtype == REG_TYPE_ATTROUT) { regtype = REG_TYPE_OUTPUT; usage = MOJOSHADER_USAGE_COLOR; index = regnum; } // else if else if (regtype == REG_TYPE_TEXCRDOUT) { regtype = REG_TYPE_OUTPUT; usage = MOJOSHADER_USAGE_TEXCOORD; index = regnum; } // else if } // if if (regtype == REG_TYPE_INPUT) { push_output(ctx, &ctx->inputs); if (buffer_size(ctx->inputs) == 0) { output_line(ctx, "struct %s_Input", ctx->mainfn); output_line(ctx, "{"); } // if ctx->indent++; switch (usage) { case MOJOSHADER_USAGE_BINORMAL: output_line(ctx, "float4 m_%s : BINORMAL%d;", var, index); break; case MOJOSHADER_USAGE_BLENDINDICES: output_line(ctx, "float4 m_%s : BLENDINDICES%d;", var, index); break; case MOJOSHADER_USAGE_BLENDWEIGHT: output_line(ctx, "float4 m_%s : BLENDWEIGHT%d;", var, index); break; case MOJOSHADER_USAGE_COLOR: output_line(ctx, "float4 m_%s : COLOR%d;", var, index); break; case MOJOSHADER_USAGE_NORMAL: output_line(ctx, "float4 m_%s : NORMAL%d;", var, index); break; case MOJOSHADER_USAGE_POSITION: output_line(ctx, "float4 m_%s : POSITION%d;", var, index); break; case MOJOSHADER_USAGE_POSITIONT: output_line(ctx, "float4 m_%s : POSITIONT;", var); break; case MOJOSHADER_USAGE_POINTSIZE: output_line(ctx, "float4 m_%s : PSIZE;", var); break; case MOJOSHADER_USAGE_TANGENT: output_line(ctx, "float4 m_%s : TANGENT%d;", var, index); break; case MOJOSHADER_USAGE_TEXCOORD: output_line(ctx, "float4 m_%s : TEXCOORD%d;", var, index); break; default: fail(ctx, "Unknown vertex input semantic type!"); break; } // case pop_output(ctx); push_output(ctx, &ctx->mainline_top); ctx->indent++; output_line(ctx, "#define %s input.m_%s", var, var); pop_output(ctx); push_output(ctx, &ctx->mainline); ctx->indent++; output_line(ctx, "#undef %s", var); // !!! FIXME: gross. pop_output(ctx); } // if else if (regtype == REG_TYPE_OUTPUT) { push_output(ctx, &ctx->outputs); if (buffer_size(ctx->outputs) == 0) { output_line(ctx, "struct %s_Output", ctx->mainfn); output_line(ctx, "{"); } // if ctx->indent++; switch (usage) { case MOJOSHADER_USAGE_BINORMAL: output_line(ctx, "float4 m_%s : BINORMAL%d;", var, index); break; case MOJOSHADER_USAGE_BLENDINDICES: output_line(ctx, "float4 m_%s : BLENDINDICES%d;", var, index); break; case MOJOSHADER_USAGE_BLENDWEIGHT: output_line(ctx, "float4 m_%s : BLENDWEIGHT%d;", var, index); break; case MOJOSHADER_USAGE_COLOR: output_line(ctx, "float4 m_%s : COLOR%d;", var, index); break; case MOJOSHADER_USAGE_FOG: output_line(ctx, "float m_%s : FOG;", var); break; case MOJOSHADER_USAGE_NORMAL: output_line(ctx, "float4 m_%s : NORMAL%d;", var, index); break; case MOJOSHADER_USAGE_POSITION: if (index == 0) snprintf(ctx->hlsl_outpos_name, sizeof(ctx->hlsl_outpos_name), "%s", var); else output_line(ctx, "float4 m_%s : POSITION%d;", var, index); break; case MOJOSHADER_USAGE_POSITIONT: output_line(ctx, "float4 m_%s : POSITIONT;", var); break; case MOJOSHADER_USAGE_POINTSIZE: output_line(ctx, "float m_%s : PSIZE;", var); break; case MOJOSHADER_USAGE_TANGENT: output_line(ctx, "float4 m_%s : TANGENT%d;", var, index); break; case MOJOSHADER_USAGE_TESSFACTOR: output_line(ctx, "float m_%s : TESSFACTOR%d;", var, index); break; case MOJOSHADER_USAGE_TEXCOORD: output_line(ctx, "float4 m_%s : TEXCOORD%d;", var, index); break; default: snprintf(a, sizeof(a), "Invalid vertex output semantic %d", usage); fail(ctx, a); break; } // switch pop_output(ctx); push_output(ctx, &ctx->mainline_top); ctx->indent++; output_line(ctx, "#define %s output.m_%s", var, var); pop_output(ctx); push_output(ctx, &ctx->mainline); ctx->indent++; output_line(ctx, "#undef %s", var); // !!! FIXME: gross. pop_output(ctx); } // else if else { fail(ctx, "unknown vertex shader attribute register"); } // else } // if else if (shader_is_pixel(ctx)) { // samplers DCLs get handled in emit_HLSL_sampler(). if (flags & MOD_CENTROID) // !!! FIXME { failf(ctx, "centroid unsupported in %s profile", ctx->profile->name); return; } // if if ((regtype == REG_TYPE_COLOROUT) || (regtype == REG_TYPE_DEPTHOUT)) { push_output(ctx, &ctx->outputs); if (buffer_size(ctx->outputs) == 0) { output_line(ctx, "struct %s_Output", ctx->mainfn); output_line(ctx, "{"); } // if ctx->indent++; if (regtype == REG_TYPE_COLOROUT) output_line(ctx, "float4 m_%s : SV_Target%d;", var, regnum); else if (regtype == REG_TYPE_DEPTHOUT) output_line(ctx, "float m_%s : SV_Depth;", var); pop_output(ctx); push_output(ctx, &ctx->mainline_top); ctx->indent++; output_line(ctx, "#define %s output.m_%s", var, var); pop_output(ctx); push_output(ctx, &ctx->mainline); ctx->indent++; output_line(ctx, "#undef %s", var); // !!! FIXME: gross. pop_output(ctx); } // if // !!! FIXME: can you actualy have a texture register with COLOR usage? else if ((regtype == REG_TYPE_TEXTURE) || (regtype == REG_TYPE_INPUT) || (regtype == REG_TYPE_MISCTYPE)) { int skipreference = 0; const char *define_start = ""; const char *define_end = ""; push_output(ctx, &ctx->inputs); if (buffer_size(ctx->inputs) == 0) { output_line(ctx, "struct %s_Input", ctx->mainfn); output_line(ctx, "{"); output_line(ctx, "\t// This must match the vertex output!"); output_line(ctx, "\t// Rewrite at link time if needed!"); } // if ctx->indent++; if (regtype == REG_TYPE_MISCTYPE) { const MiscTypeType mt = (MiscTypeType) regnum; if (mt == MISCTYPE_TYPE_FACE) { // In SM 3.0, VFACE was a float whose sign determined // face direction. In SM 4.0+, it's just a bool, so // we convert the value when we output the #define. output_line(ctx, "bool m_%s : SV_IsFrontFace;", var); define_start = "("; define_end = " ? 1 : -1)"; } // if else if (mt == MISCTYPE_TYPE_POSITION) output_line(ctx, "float4 m_%s : SV_Position;", var); else fail(ctx, "BUG: unhandled misc register"); } // else if else { switch (usage) { case MOJOSHADER_USAGE_TEXCOORD: // ps_1_1 does a different hack for this attribute. // Refer to emit_HLSL_global()'s REG_TYPE_ADDRESS code. if (!shader_version_atleast(ctx, 1, 4)) skipreference = 1; output_line(ctx, "float4 m_%s : TEXCOORD%d;", var, index); break; case MOJOSHADER_USAGE_COLOR: output_line(ctx, "float4 m_%s : COLOR%d;", var, index); break; case MOJOSHADER_USAGE_FOG: output_line(ctx, "float m_%s : FOG;", var); break; case MOJOSHADER_USAGE_NORMAL: output_line(ctx, "float4 m_%s : NORMAL;", var); break; case MOJOSHADER_USAGE_POSITION: output_line(ctx, "float4 m_%s : POSITION%d;", var, index); break; default: fail(ctx, "BUG: unhandled pixel shader input"); break; } // switch } // else pop_output(ctx); if (!skipreference) { push_output(ctx, &ctx->mainline_top); ctx->indent++; output_line(ctx, "#define %s %sinput.m_%s%s", var, define_start, var, define_end); pop_output(ctx); push_output(ctx, &ctx->mainline); ctx->indent++; output_line(ctx, "#undef %s", var); // !!! FIXME: gross. pop_output(ctx); } // if } // else if else { fail(ctx, "unknown pixel shader attribute register"); } // else } // else if else { fail(ctx, "Unknown shader type"); // state machine should catch this. } // else } // emit_HLSL_attribute void emit_HLSL_NOP(Context *ctx) { // no-op is a no-op. :) } // emit_HLSL_NOP void emit_HLSL_MOV(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "%s", src0); output_line(ctx, "%s", code); } // emit_HLSL_MOV void emit_HLSL_ADD(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char src1[64]; make_HLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "%s + %s", src0, src1); output_line(ctx, "%s", code); } // emit_HLSL_ADD void emit_HLSL_SUB(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char src1[64]; make_HLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "%s - %s", src0, src1); output_line(ctx, "%s", code); } // emit_HLSL_SUB void emit_HLSL_MAD(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char src1[64]; make_HLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); char src2[64]; make_HLSL_srcarg_string_masked(ctx, 2, src2, sizeof (src2)); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "(%s * %s) + %s", src0, src1, src2); output_line(ctx, "%s", code); } // emit_HLSL_MAD void emit_HLSL_MUL(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char src1[64]; make_HLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "%s * %s", src0, src1); output_line(ctx, "%s", code); } // emit_HLSL_MUL void emit_HLSL_RCP(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char code[128]; ctx->need_max_float = 1; make_HLSL_destarg_assign(ctx, code, sizeof (code), "(%s == 0.0) ? FLT_MAX : 1.0 / %s", src0, src0); output_line(ctx, "%s", code); } // emit_HLSL_RCP void emit_HLSL_RSQ(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char code[128]; ctx->need_max_float = 1; make_HLSL_destarg_assign(ctx, code, sizeof (code), "(%s == 0.0) ? FLT_MAX : rsqrt(abs(%s))", src0, src0); output_line(ctx, "%s", code); } // emit_HLSL_RSQ void emit_HLSL_dotprod(Context *ctx, const char *src0, const char *src1, const char *extra) { char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "dot(%s, %s)%s", src0, src1, extra); output_line(ctx, "%s", code); } // emit_HLSL_dotprod void emit_HLSL_DP3(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_vec3(ctx, 0, src0, sizeof (src0)); char src1[64]; make_HLSL_srcarg_string_vec3(ctx, 1, src1, sizeof (src1)); emit_HLSL_dotprod(ctx, src0, src1, ""); } // emit_HLSL_DP3 void emit_HLSL_DP4(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_full(ctx, 0, src0, sizeof (src0)); char src1[64]; make_HLSL_srcarg_string_full(ctx, 1, src1, sizeof (src1)); emit_HLSL_dotprod(ctx, src0, src1, ""); } // emit_HLSL_DP4 void emit_HLSL_MIN(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char src1[64]; make_HLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "min(%s, %s)", src0, src1); output_line(ctx, "%s", code); } // emit_HLSL_MIN void emit_HLSL_MAX(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char src1[64]; make_HLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "max(%s, %s)", src0, src1); output_line(ctx, "%s", code); } // emit_HLSL_MAX void emit_HLSL_SLT(Context *ctx) { const int vecsize = vecsize_from_writemask(ctx->dest_arg.writemask); char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char src1[64]; make_HLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); char code[128]; // float(bool) results in 0.0 or 1.0, like SLT wants. if (vecsize == 1) make_HLSL_destarg_assign(ctx, code, sizeof (code), "float(%s < %s)", src0, src1); else make_HLSL_destarg_assign(ctx, code, sizeof (code), "%s < %s", src0, src1); output_line(ctx, "%s", code); } // emit_HLSL_SLT void emit_HLSL_SGE(Context *ctx) { const int vecsize = vecsize_from_writemask(ctx->dest_arg.writemask); char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char src1[64]; make_HLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); char code[128]; // float(bool) results in 0.0 or 1.0, like SGE wants. if (vecsize == 1) make_HLSL_destarg_assign(ctx, code, sizeof (code), "float(%s >= %s)", src0, src1); else make_HLSL_destarg_assign(ctx, code, sizeof (code), "%s >= %s", src0, src1); output_line(ctx, "%s", code); } // emit_HLSL_SGE void emit_HLSL_EXP(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "exp2(%s)", src0); output_line(ctx, "%s", code); } // emit_HLSL_EXP void emit_HLSL_LOG(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "log2(%s)", src0); output_line(ctx, "%s", code); } // emit_HLSL_LOG void emit_HLSL_LIT(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_full(ctx, 0, src0, sizeof (src0)); char code[128]; const char *maxp = "127.9961"; // value from the dx9 reference. make_HLSL_destarg_assign(ctx, code, sizeof (code), "lit(%s.x, %s.y, clamp(%s.w, -%s, %s))", src0, src0, src0, maxp, maxp); output_line(ctx, "%s", code); } // emit_HLSL_LIT void emit_HLSL_DST(Context *ctx) { // !!! FIXME: needs to take ctx->dst_arg.writemask into account // !!! FIXME: can we use dst() intrinsic instead? -caleb char src0_y[64]; make_HLSL_srcarg_string_y(ctx, 0, src0_y, sizeof (src0_y)); char src1_y[64]; make_HLSL_srcarg_string_y(ctx, 1, src1_y, sizeof (src1_y)); char src0_z[64]; make_HLSL_srcarg_string_z(ctx, 0, src0_z, sizeof (src0_z)); char src1_w[64]; make_HLSL_srcarg_string_w(ctx, 1, src1_w, sizeof (src1_w)); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "float4(1.0, %s * %s, %s, %s)", src0_y, src1_y, src0_z, src1_w); output_line(ctx, "%s", code); } // emit_HLSL_DST void emit_HLSL_LRP(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char src1[64]; make_HLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); char src2[64]; make_HLSL_srcarg_string_masked(ctx, 2, src2, sizeof (src2)); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "lerp(%s, %s, %s)", src2, src1, src0); output_line(ctx, "%s", code); } // emit_HLSL_LRP void emit_HLSL_FRC(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "frac(%s)", src0); output_line(ctx, "%s", code); } // emit_HLSL_FRC void emit_HLSL_M4X4(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_full(ctx, 0, src0, sizeof (src0)); char row0[64]; make_HLSL_srcarg_string_full(ctx, 1, row0, sizeof (row0)); char row1[64]; make_HLSL_srcarg_string_full(ctx, 2, row1, sizeof (row1)); char row2[64]; make_HLSL_srcarg_string_full(ctx, 3, row2, sizeof (row2)); char row3[64]; make_HLSL_srcarg_string_full(ctx, 4, row3, sizeof (row3)); char code[256]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "float4(dot(%s, %s), dot(%s, %s), dot(%s, %s), dot(%s, %s))", src0, row0, src0, row1, src0, row2, src0, row3); output_line(ctx, "%s", code); } // emit_HLSL_M4X4 void emit_HLSL_M4X3(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_full(ctx, 0, src0, sizeof (src0)); char row0[64]; make_HLSL_srcarg_string_full(ctx, 1, row0, sizeof (row0)); char row1[64]; make_HLSL_srcarg_string_full(ctx, 2, row1, sizeof (row1)); char row2[64]; make_HLSL_srcarg_string_full(ctx, 3, row2, sizeof (row2)); char code[256]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "float3(dot(%s, %s), dot(%s, %s), dot(%s, %s))", src0, row0, src0, row1, src0, row2); output_line(ctx, "%s", code); } // emit_HLSL_M4X3 void emit_HLSL_M3X4(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_vec3(ctx, 0, src0, sizeof (src0)); char row0[64]; make_HLSL_srcarg_string_vec3(ctx, 1, row0, sizeof (row0)); char row1[64]; make_HLSL_srcarg_string_vec3(ctx, 2, row1, sizeof (row1)); char row2[64]; make_HLSL_srcarg_string_vec3(ctx, 3, row2, sizeof (row2)); char row3[64]; make_HLSL_srcarg_string_vec3(ctx, 4, row3, sizeof (row3)); char code[256]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "float4(dot(%s, %s), dot(%s, %s), " "dot(%s, %s), dot(%s, %s))", src0, row0, src0, row1, src0, row2, src0, row3); output_line(ctx, "%s", code); } // emit_HLSL_M3X4 void emit_HLSL_M3X3(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_vec3(ctx, 0, src0, sizeof (src0)); char row0[64]; make_HLSL_srcarg_string_vec3(ctx, 1, row0, sizeof (row0)); char row1[64]; make_HLSL_srcarg_string_vec3(ctx, 2, row1, sizeof (row1)); char row2[64]; make_HLSL_srcarg_string_vec3(ctx, 3, row2, sizeof (row2)); char code[256]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "float3(dot(%s, %s), dot(%s, %s), dot(%s, %s))", src0, row0, src0, row1, src0, row2); output_line(ctx, "%s", code); } // emit_HLSL_M3X3 void emit_HLSL_M3X2(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_vec3(ctx, 0, src0, sizeof (src0)); char row0[64]; make_HLSL_srcarg_string_vec3(ctx, 1, row0, sizeof (row0)); char row1[64]; make_HLSL_srcarg_string_vec3(ctx, 2, row1, sizeof (row1)); char code[256]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "float2(dot(%s, %s), dot(%s, %s))", src0, row0, src0, row1); output_line(ctx, "%s", code); } // emit_HLSL_M3X2 void emit_HLSL_CALL(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); if (ctx->loops > 0) output_line(ctx, "%s(aL);", src0); else output_line(ctx, "%s();", src0); } // emit_HLSL_CALL void emit_HLSL_CALLNZ(Context *ctx) { // !!! FIXME: if src1 is a constbool that's true, we can remove the // !!! FIXME: if. If it's false, we can make this a no-op. char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char src1[64]; make_HLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); if (ctx->loops > 0) output_line(ctx, "if (%s) { %s(aL); }", src1, src0); else output_line(ctx, "if (%s) { %s(); }", src1, src0); } // emit_HLSL_CALLNZ void emit_HLSL_LOOP(Context *ctx) { // !!! FIXME: swizzle? char var[64]; get_HLSL_srcarg_varname(ctx, 1, var, sizeof (var)); assert(ctx->source_args[0].regnum == 0); // in case they add aL1 someday. output_line(ctx, "{"); ctx->indent++; output_line(ctx, "const int aLend = %s.x + %s.y;", var, var); output_line(ctx, "for (int aL = %s.y; aL < aLend; aL += %s.z) {", var, var); ctx->indent++; } // emit_HLSL_LOOP void emit_HLSL_RET(Context *ctx) { // thankfully, the MSDN specs say a RET _has_ to end a function...no // early returns. So if you hit one, you know you can safely close // a high-level function. push_output(ctx, &ctx->postflight); output_line(ctx, "}"); output_blank_line(ctx); set_output(ctx, &ctx->subroutines); // !!! FIXME: is this for LABEL? Maybe set it there so we don't allocate unnecessarily. } // emit_HLSL_RET void emit_HLSL_ENDLOOP(Context *ctx) { ctx->indent--; output_line(ctx, "}"); ctx->indent--; output_line(ctx, "}"); } // emit_HLSL_ENDLOOP void emit_HLSL_LABEL(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); const int label = ctx->source_args[0].regnum; RegisterList *reg = reglist_find(&ctx->used_registers, REG_TYPE_LABEL, label); assert(ctx->output == ctx->subroutines); // not mainline, etc. assert(ctx->indent == 0); // we shouldn't be in the middle of a function. // MSDN specs say CALL* has to come before the LABEL, so we know if we // can ditch the entire function here as unused. if (reg == NULL) set_output(ctx, &ctx->ignore); // Func not used. Parse, but don't output. // !!! FIXME: it would be nice if we could determine if a function is // !!! FIXME: only called once and, if so, forcibly inline it. const char *uses_loopreg = ((reg) && (reg->misc == 1)) ? "int aL" : ""; output_line(ctx, "void %s(%s)", src0, uses_loopreg); output_line(ctx, "{"); ctx->indent++; } // emit_HLSL_LABEL void emit_HLSL_DCL(Context *ctx) { // no-op. We do this in our emit_attribute() and emit_uniform(). } // emit_HLSL_DCL void emit_HLSL_POW(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char src1[64]; make_HLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "pow(abs(%s), %s)", src0, src1); output_line(ctx, "%s", code); } // emit_HLSL_POW void emit_HLSL_CRS(Context *ctx) { // !!! FIXME: needs to take ctx->dst_arg.writemask into account. char src0[64]; make_HLSL_srcarg_string_vec3(ctx, 0, src0, sizeof (src0)); char src1[64]; make_HLSL_srcarg_string_vec3(ctx, 1, src1, sizeof (src1)); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "cross(%s, %s)", src0, src1); output_line(ctx, "%s", code); } // emit_HLSL_CRS void emit_HLSL_SGN(Context *ctx) { // (we don't need the temporary registers specified for the D3D opcode.) char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "sign(%s)", src0); output_line(ctx, "%s", code); } // emit_HLSL_SGN void emit_HLSL_ABS(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "abs(%s)", src0); output_line(ctx, "%s", code); } // emit_HLSL_ABS void emit_HLSL_NRM(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "normalize(%s)", src0); output_line(ctx, "%s", code); } // emit_HLSL_NRM void emit_HLSL_SINCOS(Context *ctx) { // we don't care about the temp registers that <= sm2 demands; ignore them. // sm2 also talks about what components are left untouched vs. undefined, // but we just leave those all untouched with HLSL write masks (which // would fulfill the "undefined" requirement, too). const int mask = ctx->dest_arg.writemask; char src0[64]; make_HLSL_srcarg_string_scalar(ctx, 0, src0, sizeof (src0)); char code[128] = { '\0' }; if (writemask_x(mask)) make_HLSL_destarg_assign(ctx, code, sizeof (code), "cos(%s)", src0); else if (writemask_y(mask)) make_HLSL_destarg_assign(ctx, code, sizeof (code), "sin(%s)", src0); else if (writemask_xy(mask)) { make_HLSL_destarg_assign(ctx, code, sizeof (code), "float2(cos(%s), sin(%s))", src0, src0); } // else if output_line(ctx, "%s", code); } // emit_HLSL_SINCOS void emit_HLSL_REP(Context *ctx) { // !!! FIXME: // msdn docs say legal loop values are 0 to 255. We can check DEFI values // at parse time, but if they are pulling a value from a uniform, do // we clamp here? // !!! FIXME: swizzle is legal here, right? char src0[64]; make_HLSL_srcarg_string_x(ctx, 0, src0, sizeof (src0)); const uint rep = (uint) ctx->reps; output_line(ctx, "for (int rep%u = 0; rep%u < %s; rep%u++) {", rep, rep, src0, rep); ctx->indent++; } // emit_HLSL_REP void emit_HLSL_ENDREP(Context *ctx) { ctx->indent--; output_line(ctx, "}"); } // emit_HLSL_ENDREP void emit_HLSL_IF(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_scalar(ctx, 0, src0, sizeof (src0)); output_line(ctx, "if (%s) {", src0); ctx->indent++; } // emit_HLSL_IF void emit_HLSL_IFC(Context *ctx) { const char *comp = get_HLSL_comparison_string_scalar(ctx); char src0[64]; make_HLSL_srcarg_string_scalar(ctx, 0, src0, sizeof (src0)); char src1[64]; make_HLSL_srcarg_string_scalar(ctx, 1, src1, sizeof (src1)); output_line(ctx, "if (%s %s %s) {", src0, comp, src1); ctx->indent++; } // emit_HLSL_IFC void emit_HLSL_ELSE(Context *ctx) { ctx->indent--; output_line(ctx, "} else {"); ctx->indent++; } // emit_HLSL_ELSE void emit_HLSL_ENDIF(Context *ctx) { ctx->indent--; output_line(ctx, "}"); } // emit_HLSL_ENDIF void emit_HLSL_BREAK(Context *ctx) { output_line(ctx, "break;"); } // emit_HLSL_BREAK void emit_HLSL_BREAKC(Context *ctx) { const char *comp = get_HLSL_comparison_string_scalar(ctx); char src0[64]; make_HLSL_srcarg_string_scalar(ctx, 0, src0, sizeof (src0)); char src1[64]; make_HLSL_srcarg_string_scalar(ctx, 1, src1, sizeof (src1)); output_line(ctx, "if (%s %s %s) { break; }", src0, comp, src1); } // emit_HLSL_BREAKC void emit_HLSL_MOVA(Context *ctx) { const int vecsize = vecsize_from_writemask(ctx->dest_arg.writemask); char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char code[128]; if (vecsize == 1) { make_HLSL_destarg_assign(ctx, code, sizeof (code), "int(floor(abs(%s) + 0.5) * sign(%s))", src0, src0); } // if else { make_HLSL_destarg_assign(ctx, code, sizeof (code), "int%d(floor(abs(%s) + 0.5) * sign(%s))", vecsize, src0, src0); } // else output_line(ctx, "%s", code); } // emit_HLSL_MOVA void emit_HLSL_DEFB(Context *ctx) { char varname[64]; get_HLSL_destarg_varname(ctx, varname, sizeof (varname)); push_output(ctx, &ctx->mainline_top); ctx->indent++; output_line(ctx, "const bool %s = %s;", varname, ctx->dwords[0] ? "true" : "false"); ctx->indent--; pop_output(ctx); } // emit_HLSL_DEFB void emit_HLSL_DEFI(Context *ctx) { char varname[64]; get_HLSL_destarg_varname(ctx, varname, sizeof (varname)); const int32 *x = (const int32 *) ctx->dwords; push_output(ctx, &ctx->mainline_top); ctx->indent++; output_line(ctx, "const int4 %s = int4(%d, %d, %d, %d);", varname, (int) x[0], (int) x[1], (int) x[2], (int) x[3]); ctx->indent--; pop_output(ctx); } // emit_HLSL_DEFI EMIT_HLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXCRD) void emit_HLSL_TEXKILL(Context *ctx) { char dst[64]; get_HLSL_destarg_varname(ctx, dst, sizeof (dst)); output_line(ctx, "if (any(%s.xyz < 0.0)) discard;", dst); } // emit_HLSL_TEXKILL void emit_HLSL_TEXLD(Context *ctx) { if (!shader_version_atleast(ctx, 1, 4)) { DestArgInfo *info = &ctx->dest_arg; char dst[64]; char sampler[64]; char code[128] = {0}; RegisterList *sreg; sreg = reglist_find(&ctx->samplers, REG_TYPE_SAMPLER, info->regnum); const TextureType ttype = (TextureType) (sreg ? sreg->index : 0); // !!! FIXME: this code counts on the register not having swizzles, etc. get_HLSL_destarg_varname(ctx, dst, sizeof (dst)); get_HLSL_varname_in_buf(ctx, REG_TYPE_SAMPLER, info->regnum, sampler, sizeof (sampler)); if (ttype == TEXTURE_TYPE_2D) { make_HLSL_destarg_assign(ctx, code, sizeof (code), "%s_texture.Sample(%s, %s.xy)", sampler, sampler, dst); } // if else if (ttype == TEXTURE_TYPE_CUBE || ttype == TEXTURE_TYPE_VOLUME) { make_HLSL_destarg_assign(ctx, code, sizeof (code), "%s_texture.Sample(%s, %s.xyz)", sampler, sampler, dst); } // else if else { fail(ctx, "unexpected texture type"); } // else output_line(ctx, "%s", code); } // if else if (!shader_version_atleast(ctx, 2, 0)) { // ps_1_4 is different, too! fail(ctx, "TEXLD == Shader Model 1.4 unimplemented."); // !!! FIXME return; } // else if else { const SourceArgInfo *samp_arg = &ctx->source_args[1]; RegisterList *sreg = reglist_find(&ctx->samplers, REG_TYPE_SAMPLER, samp_arg->regnum); const char *funcname = NULL; char src0[64] = { '\0' }; char src1[64]; get_HLSL_srcarg_varname(ctx, 1, src1, sizeof (src1)); // !!! FIXME: SRC_MOD? if (sreg == NULL) { fail(ctx, "TEXLD using undeclared sampler"); return; } // if // !!! FIXME: does the d3d bias value map directly to HLSL? const char *biassep = ""; char bias[64] = { '\0' }; if (ctx->instruction_controls == CONTROL_TEXLDB) { biassep = ", "; make_HLSL_srcarg_string_w(ctx, 0, bias, sizeof (bias)); funcname = "SampleBias"; } // if else { funcname = "Sample"; } // else switch ((const TextureType) sreg->index) { case TEXTURE_TYPE_2D: make_HLSL_srcarg_string_vec2(ctx, 0, src0, sizeof (src0)); break; case TEXTURE_TYPE_CUBE: if (ctx->instruction_controls == CONTROL_TEXLDP) fail(ctx, "TEXLDP on a cubemap"); // !!! FIXME: is this legal? make_HLSL_srcarg_string_vec3(ctx, 0, src0, sizeof (src0)); break; case TEXTURE_TYPE_VOLUME: make_HLSL_srcarg_string_vec3(ctx, 0, src0, sizeof (src0)); break; default: fail(ctx, "unknown texture type"); return; } // switch assert(!isscalar(ctx, ctx->shader_type, samp_arg->regtype, samp_arg->regnum)); char swiz_str[6] = { '\0' }; make_HLSL_swizzle_string(swiz_str, sizeof (swiz_str), samp_arg->swizzle, ctx->dest_arg.writemask); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "%s_texture.%s(%s, %s%s%s)%s", src1, funcname, src1, src0, biassep, bias, swiz_str); output_line(ctx, "%s", code); } // else } // emit_HLSL_TEXLD void emit_HLSL_TEXBEM(Context *ctx) { // !!! FIXME: this code counts on the register not having swizzles, etc. DestArgInfo *info = &ctx->dest_arg; char dst[64]; get_HLSL_destarg_varname(ctx, dst, sizeof (dst)); char src[64]; get_HLSL_srcarg_varname(ctx, 0, src, sizeof (src)); char sampler[64]; char code[512]; get_HLSL_varname_in_buf(ctx, REG_TYPE_SAMPLER, info->regnum, sampler, sizeof (sampler)); make_HLSL_destarg_assign(ctx, code, sizeof (code), "%s_texture.Sample(%s, float2(%s.x + (%s_texbem.x * %s.x) + (%s_texbem.z * %s.y)," " %s.y + (%s_texbem.y * %s.x) + (%s_texbem.w * %s.y)))", sampler, sampler, dst, sampler, src, sampler, src, dst, sampler, src, sampler, src); output_line(ctx, "%s", code); } // emit_HLSL_TEXBEM void emit_HLSL_TEXBEML(Context *ctx) { // !!! FIXME: this code counts on the register not having swizzles, etc. DestArgInfo *info = &ctx->dest_arg; char dst[64]; get_HLSL_destarg_varname(ctx, dst, sizeof (dst)); char src[64]; get_HLSL_srcarg_varname(ctx, 0, src, sizeof (src)); char sampler[64]; char code[512]; get_HLSL_varname_in_buf(ctx, REG_TYPE_SAMPLER, info->regnum, sampler, sizeof (sampler)); make_HLSL_destarg_assign(ctx, code, sizeof (code), "(%s_texture.Sample(%s, float2(%s.x + (%s_texbem.x * %s.x) + (%s_texbem.z * %s.y)," " %s.y + (%s_texbem.y * %s.x) + (%s_texbem.w * %s.y)))) *" " ((%s.z * %s_texbeml.x) + %s_texbem.y)", sampler, sampler, dst, sampler, src, sampler, src, dst, sampler, src, sampler, src, src, sampler, sampler); output_line(ctx, "%s", code); } // emit_HLSL_TEXBEML EMIT_HLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXREG2AR) // !!! FIXME EMIT_HLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXREG2GB) // !!! FIXME void emit_HLSL_TEXM3X2PAD(Context *ctx) { // no-op ... work happens in emit_HLSL_TEXM3X2TEX(). } // emit_HLSL_TEXM3X2PAD void emit_HLSL_TEXM3X2TEX(Context *ctx) { if (ctx->texm3x2pad_src0 == -1) return; DestArgInfo *info = &ctx->dest_arg; char dst[64]; char src0[64]; char src1[64]; char src2[64]; char sampler[64]; char code[512]; // !!! FIXME: this code counts on the register not having swizzles, etc. get_HLSL_varname_in_buf(ctx, REG_TYPE_SAMPLER, info->regnum, sampler, sizeof (sampler)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->texm3x2pad_src0, src0, sizeof (src0)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->texm3x2pad_dst0, src1, sizeof (src1)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->source_args[0].regnum, src2, sizeof (src2)); get_HLSL_destarg_varname(ctx, dst, sizeof (dst)); make_HLSL_destarg_assign(ctx, code, sizeof (code), "%s_texture.Sample(%s, float2(dot(%s.xyz, %s.xyz), dot(%s.xyz, %s.xyz)))", sampler, sampler, src0, src1, src2, dst); output_line(ctx, "%s", code); } // emit_HLSL_TEXM3X2TEX void emit_HLSL_TEXM3X3PAD(Context *ctx) { // no-op ... work happens in emit_HLSL_TEXM3X3*(). } // emit_HLSL_TEXM3X3PAD void emit_HLSL_TEXM3X3TEX(Context *ctx) { if (ctx->texm3x3pad_src1 == -1) return; DestArgInfo *info = &ctx->dest_arg; char dst[64]; char src0[64]; char src1[64]; char src2[64]; char src3[64]; char src4[64]; char sampler[64]; char code[512]; // !!! FIXME: this code counts on the register not having swizzles, etc. get_HLSL_varname_in_buf(ctx, REG_TYPE_SAMPLER, info->regnum, sampler, sizeof (sampler)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->texm3x3pad_dst0, src0, sizeof (src0)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->texm3x3pad_src0, src1, sizeof (src1)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->texm3x3pad_dst1, src2, sizeof (src2)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->texm3x3pad_src1, src3, sizeof (src3)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->source_args[0].regnum, src4, sizeof (src4)); get_HLSL_destarg_varname(ctx, dst, sizeof (dst)); make_HLSL_destarg_assign(ctx, code, sizeof (code), "%s_texture.Sample(%s," " float3(dot(%s.xyz, %s.xyz)," " dot(%s.xyz, %s.xyz)," " dot(%s.xyz, %s.xyz)))", sampler, sampler, src0, src1, src2, src3, dst, src4); output_line(ctx, "%s", code); } // emit_HLSL_TEXM3X3TEX void emit_HLSL_TEXM3X3SPEC_helper(Context *ctx) { if (ctx->glsl_generated_texm3x3spec_helper) return; ctx->glsl_generated_texm3x3spec_helper = 1; push_output(ctx, &ctx->helpers); output_line(ctx, "float3 TEXM3X3SPEC_reflection(const float3 normal, const float3 eyeray)"); output_line(ctx, "{"); ctx->indent++; output_line(ctx, "return (2.0 * ((normal * eyeray) / (normal * normal)) * normal) - eyeray;"); ctx->indent--; output_line(ctx, "}"); output_blank_line(ctx); pop_output(ctx); } // emit_HLSL_TEXM3X3SPEC_helper void emit_HLSL_TEXM3X3SPEC(Context *ctx) { if (ctx->texm3x3pad_src1 == -1) return; DestArgInfo *info = &ctx->dest_arg; char dst[64]; char src0[64]; char src1[64]; char src2[64]; char src3[64]; char src4[64]; char src5[64]; char sampler[64]; char code[512]; emit_HLSL_TEXM3X3SPEC_helper(ctx); // !!! FIXME: this code counts on the register not having swizzles, etc. get_HLSL_varname_in_buf(ctx, REG_TYPE_SAMPLER, info->regnum, sampler, sizeof (sampler)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->texm3x3pad_dst0, src0, sizeof (src0)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->texm3x3pad_src0, src1, sizeof (src1)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->texm3x3pad_dst1, src2, sizeof (src2)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->texm3x3pad_src1, src3, sizeof (src3)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->source_args[0].regnum, src4, sizeof (src4)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->source_args[1].regnum, src5, sizeof (src5)); get_HLSL_destarg_varname(ctx, dst, sizeof (dst)); make_HLSL_destarg_assign(ctx, code, sizeof (code), "%s_texture.Sample(%s, " "TEXM3X3SPEC_reflection(" "float3(" "dot(%s.xyz, %s.xyz), " "dot(%s.xyz, %s.xyz), " "dot(%s.xyz, %s.xyz)" ")," "%s.xyz," ")" ")", sampler, sampler, src0, src1, src2, src3, dst, src4, src5); output_line(ctx, "%s", code); } // emit_HLSL_TEXM3X3SPEC void emit_HLSL_TEXM3X3VSPEC(Context *ctx) { if (ctx->texm3x3pad_src1 == -1) return; DestArgInfo *info = &ctx->dest_arg; char dst[64]; char src0[64]; char src1[64]; char src2[64]; char src3[64]; char src4[64]; char sampler[64]; char code[512]; emit_HLSL_TEXM3X3SPEC_helper(ctx); // !!! FIXME: this code counts on the register not having swizzles, etc. get_HLSL_varname_in_buf(ctx, REG_TYPE_SAMPLER, info->regnum, sampler, sizeof (sampler)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->texm3x3pad_dst0, src0, sizeof (src0)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->texm3x3pad_src0, src1, sizeof (src1)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->texm3x3pad_dst1, src2, sizeof (src2)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->texm3x3pad_src1, src3, sizeof (src3)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->source_args[0].regnum, src4, sizeof (src4)); get_HLSL_destarg_varname(ctx, dst, sizeof (dst)); make_HLSL_destarg_assign(ctx, code, sizeof (code), "%s_texture.Sample(%s, " "TEXM3X3SPEC_reflection(" "float3(" "dot(%s.xyz, %s.xyz), " "dot(%s.xyz, %s.xyz), " "dot(%s.xyz, %s.xyz)" "), " "float3(%s.w, %s.w, %s.w)" ")" ")", sampler, sampler, src0, src1, src2, src3, dst, src4, src0, src2, dst); output_line(ctx, "%s", code); } // emit_HLSL_TEXM3X3VSPEC void emit_HLSL_EXPP(Context *ctx) { // !!! FIXME: msdn's asm docs don't list this opcode, I'll have to check the driver documentation. emit_HLSL_EXP(ctx); // I guess this is just partial precision EXP? } // emit_HLSL_EXPP void emit_HLSL_LOGP(Context *ctx) { // LOGP is just low-precision LOG, but we'll take the higher precision. emit_HLSL_LOG(ctx); } // emit_HLSL_LOGP // common code between CMP and CND. void emit_HLSL_comparison_operations(Context *ctx, const char *cmp) { int i, j; DestArgInfo *dst = &ctx->dest_arg; const SourceArgInfo *srcarg0 = &ctx->source_args[0]; const int origmask = dst->writemask; int used_swiz[4] = { 0, 0, 0, 0 }; const int writemask[4] = { dst->writemask0, dst->writemask1, dst->writemask2, dst->writemask3 }; const int src0swiz[4] = { srcarg0->swizzle_x, srcarg0->swizzle_y, srcarg0->swizzle_z, srcarg0->swizzle_w }; for (i = 0; i < 4; i++) { int mask = (1 << i); if (!writemask[i]) continue; if (used_swiz[i]) continue; // This is a swizzle we haven't checked yet. used_swiz[i] = 1; // see if there are any other elements swizzled to match (.yyyy) for (j = i + 1; j < 4; j++) { if (!writemask[j]) continue; if (src0swiz[i] != src0swiz[j]) continue; mask |= (1 << j); used_swiz[j] = 1; } // for // okay, (mask) should be the writemask of swizzles we like. char src0[64]; char src1[64]; char src2[64]; make_HLSL_srcarg_string(ctx, 0, (1 << i), src0, sizeof (src0)); make_HLSL_srcarg_string(ctx, 1, mask, src1, sizeof (src1)); make_HLSL_srcarg_string(ctx, 2, mask, src2, sizeof (src2)); set_dstarg_writemask(dst, mask); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "((%s %s) ? %s : %s)", src0, cmp, src1, src2); output_line(ctx, "%s", code); } // for set_dstarg_writemask(dst, origmask); } // emit_HLSL_comparison_operations void emit_HLSL_CND(Context *ctx) { emit_HLSL_comparison_operations(ctx, "> 0.5"); } // emit_HLSL_CND void emit_HLSL_DEF(Context *ctx) { const float *val = (const float *) ctx->dwords; // !!! FIXME: could be int? char varname[64]; get_HLSL_destarg_varname(ctx, varname, sizeof (varname)); char val0[32]; floatstr(ctx, val0, sizeof (val0), val[0], 1); char val1[32]; floatstr(ctx, val1, sizeof (val1), val[1], 1); char val2[32]; floatstr(ctx, val2, sizeof (val2), val[2], 1); char val3[32]; floatstr(ctx, val3, sizeof (val3), val[3], 1); push_output(ctx, &ctx->mainline_top); ctx->indent++; output_line(ctx, "const float4 %s = float4(%s, %s, %s, %s);", varname, val0, val1, val2, val3); ctx->indent--; pop_output(ctx); } // emit_HLSL_DEF EMIT_HLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXREG2RGB) // !!! FIXME EMIT_HLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXDP3TEX) // !!! FIXME EMIT_HLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXM3X2DEPTH) // !!! FIXME EMIT_HLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXDP3) // !!! FIXME void emit_HLSL_TEXM3X3(Context *ctx) { if (ctx->texm3x3pad_src1 == -1) return; char dst[64]; char src0[64]; char src1[64]; char src2[64]; char src3[64]; char src4[64]; char code[512]; // !!! FIXME: this code counts on the register not having swizzles, etc. get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->texm3x3pad_dst0, src0, sizeof (src0)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->texm3x3pad_src0, src1, sizeof (src1)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->texm3x3pad_dst1, src2, sizeof (src2)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->texm3x3pad_src1, src3, sizeof (src3)); get_HLSL_varname_in_buf(ctx, REG_TYPE_TEXTURE, ctx->source_args[0].regnum, src4, sizeof (src4)); get_HLSL_destarg_varname(ctx, dst, sizeof (dst)); make_HLSL_destarg_assign(ctx, code, sizeof (code), "float4(dot(%s.xyz, %s.xyz), dot(%s.xyz, %s.xyz), dot(%s.xyz, %s.xyz), 1.0)", src0, src1, src2, src3, dst, src4); output_line(ctx, "%s", code); } // emit_HLSL_TEXM3X3 EMIT_HLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXDEPTH) // !!! FIXME void emit_HLSL_CMP(Context *ctx) { emit_HLSL_comparison_operations(ctx, ">= 0.0"); } // emit_HLSL_CMP EMIT_HLSL_OPCODE_UNIMPLEMENTED_FUNC(BEM) // !!! FIXME void emit_HLSL_DP2ADD(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_vec2(ctx, 0, src0, sizeof (src0)); char src1[64]; make_HLSL_srcarg_string_vec2(ctx, 1, src1, sizeof (src1)); char src2[64]; make_HLSL_srcarg_string_scalar(ctx, 2, src2, sizeof (src2)); char extra[64]; snprintf(extra, sizeof (extra), " + %s", src2); emit_HLSL_dotprod(ctx, src0, src1, extra); } // emit_HLSL_DP2ADD void emit_HLSL_DSX(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "ddx(%s)", src0); output_line(ctx, "%s", code); } // emit_HLSL_DSX void emit_HLSL_DSY(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "ddy(%s)", src0); output_line(ctx, "%s", code); } // emit_HLSL_DSY void emit_HLSL_TEXLDD(Context *ctx) { const SourceArgInfo *samp_arg = &ctx->source_args[1]; RegisterList *sreg = reglist_find(&ctx->samplers, REG_TYPE_SAMPLER, samp_arg->regnum); char src0[64] = { '\0' }; char src1[64]; get_HLSL_srcarg_varname(ctx, 1, src1, sizeof (src1)); // !!! FIXME: SRC_MOD? char src2[64] = { '\0' }; char src3[64] = { '\0' }; if (sreg == NULL) { fail(ctx, "TEXLDD using undeclared sampler"); return; } // if switch ((const TextureType) sreg->index) { case TEXTURE_TYPE_2D: make_HLSL_srcarg_string_vec2(ctx, 0, src0, sizeof (src0)); make_HLSL_srcarg_string_vec2(ctx, 2, src2, sizeof (src2)); make_HLSL_srcarg_string_vec2(ctx, 3, src3, sizeof (src3)); break; case TEXTURE_TYPE_CUBE: case TEXTURE_TYPE_VOLUME: make_HLSL_srcarg_string_vec3(ctx, 0, src0, sizeof (src0)); make_HLSL_srcarg_string_vec3(ctx, 2, src2, sizeof (src2)); make_HLSL_srcarg_string_vec3(ctx, 3, src3, sizeof (src3)); break; default: fail(ctx, "unknown texture type"); return; } // switch assert(!isscalar(ctx, ctx->shader_type, samp_arg->regtype, samp_arg->regnum)); char swiz_str[6] = { '\0' }; make_HLSL_swizzle_string(swiz_str, sizeof (swiz_str), samp_arg->swizzle, ctx->dest_arg.writemask); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof (code), "%s_texture.SampleGrad(%s, %s, %s, %s)%s", src1, src1, src0, src2, src3, swiz_str); output_line(ctx, "%s", code); } // emit_HLSL_TEXLDD void emit_HLSL_SETP(Context *ctx) { const int vecsize = vecsize_from_writemask(ctx->dest_arg.writemask); char src0[64]; make_HLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); char src1[64]; make_HLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); char code[128]; // destination is always predicate register (which is type bvec4). const char *comp = (vecsize == 1) ? get_HLSL_comparison_string_scalar(ctx) : get_HLSL_comparison_string_vector(ctx); make_HLSL_destarg_assign(ctx, code, sizeof (code), "(%s %s %s)", src0, comp, src1); output_line(ctx, "%s", code); } // emit_HLSL_SETP void emit_HLSL_TEXLDL(Context *ctx) { const SourceArgInfo *samp_arg = &ctx->source_args[1]; RegisterList *sreg = reglist_find(&ctx->samplers, REG_TYPE_SAMPLER, samp_arg->regnum); const char *pattern = NULL; char src0[64]; char src1[64]; make_HLSL_srcarg_string_full(ctx, 0, src0, sizeof (src0)); get_HLSL_srcarg_varname(ctx, 1, src1, sizeof (src1)); // !!! FIXME: SRC_MOD? if (sreg == NULL) { fail(ctx, "TEXLDL using undeclared sampler"); return; } // if switch ((const TextureType) sreg->index) { case TEXTURE_TYPE_2D: pattern = "%s_texture.SampleLevel(%s, %s.xy, %s.w)%s"; break; case TEXTURE_TYPE_CUBE: case TEXTURE_TYPE_VOLUME: pattern = "%s_texture.SampleLevel(%s, %s.xyz, %s.w)%s"; break; default: fail(ctx, "unknown texture type"); return; } // switch assert(!isscalar(ctx, ctx->shader_type, samp_arg->regtype, samp_arg->regnum)); char swiz_str[6] = { '\0' }; make_HLSL_swizzle_string(swiz_str, sizeof (swiz_str), samp_arg->swizzle, ctx->dest_arg.writemask); char code[128]; make_HLSL_destarg_assign(ctx, code, sizeof(code), pattern, src1, src1, src0, src0, swiz_str); output_line(ctx, "%s", code); } // emit_HLSL_TEXLDL void emit_HLSL_BREAKP(Context *ctx) { char src0[64]; make_HLSL_srcarg_string_scalar(ctx, 0, src0, sizeof (src0)); output_line(ctx, "if (%s) { break; }", src0); } // emit_HLSL_BREAKP void emit_HLSL_RESERVED(Context *ctx) { // do nothing; fails in the state machine. } // emit_HLSL_RESERVED #endif // SUPPORT_PROFILE_HLSL #pragma GCC visibility pop
35.672368
128
0.572941
[ "model", "3d" ]
cc5ef67a6c173e1bdef9312920dc895c5e65ff36
3,526
h
C
eagleeye/engine/nano/op/cpu/CNNOp.h
MirrorYu/eagleeye
c251e7b3bc919673b41360212c38d5fda85bbe2f
[ "Apache-2.0" ]
12
2020-09-21T02:24:11.000Z
2022-03-10T03:02:03.000Z
eagleeye/engine/nano/op/cpu/CNNOp.h
MirrorYu/eagleeye
c251e7b3bc919673b41360212c38d5fda85bbe2f
[ "Apache-2.0" ]
1
2020-11-30T08:22:50.000Z
2020-11-30T08:22:50.000Z
eagleeye/engine/nano/op/cpu/CNNOp.h
MirrorYu/eagleeye
c251e7b3bc919673b41360212c38d5fda85bbe2f
[ "Apache-2.0" ]
3
2020-03-16T12:10:55.000Z
2021-07-20T09:58:15.000Z
#ifndef _EAGLEEYE_FIXEDBASE_H_ #define _EAGLEEYE_FIXEDBASE_H_ #include "eagleeye/common/EagleeyeMacro.h" #include "eagleeye/basic/Tensor.h" #include "eagleeye/engine/nano/util/quantization.h" #include <string> #include <vector> namespace eagleeye{ namespace nano{ #define CNN_CONV_MAX_NORM_VALUE 127 #define CNN_CONV_DATA_NORM_VALUE 32768 #define CNN_CONV_DATA_NORM_MOVE 15 enum { PLACEHOLDER = 0, //0 CONV, //1 DEPTHWISE_CONV, //2 POOLING, //3 INNERPRODUCT, //4 BATCHNORM, //5 SOFTMAX, //6 CONCAT, //7 PRELU, //8 RELU, //9 SPLIT, //10 TILING, //11 SCALE, //12 ELTWISE, //13 DROPOUT, //14 RESIZE, //15 RESHAPE, SHUFFLECHANNEL, SLICE, IDENTITY }; class CNNOp{ public: CNNOp(int input_data_num, int output_data_num, int layer_flag, std::string op_name); virtual ~CNNOp(); /** * @brief initialize Op * * @param buf * @param in_size */ virtual bool init(char *buf, int in_size){return true;}; /** * @brief Set the Shape object * * @param shape * @return int */ virtual int setShape(std::vector<int64_t> shape) = 0; /** * @brief Get the Input Num object * * @return int */ int getInputNum(); /** * @brief Get the Input Shape object * * @param index * @return std::vector<int64_t> */ std::vector<int64_t> getInputShape(int index); /** * @brief Get the Output Num object * * @return int */ int getOutputNum(); /** * @brief Get the Output Shape object * * @param index * @return std::vector<int64_t> */ std::vector<int64_t> getOutputShape(int index); /** * @brief Get the Layer Type object * * @return int */ int getLayerType(){ return this->layer_flag_; } /** * @brief Get the Layer Name object * * @return std::string */ std::string getLayerName(); /** * @brief Set the Input object * * @param data */ virtual void setInput(std::vector<Tensor<float>>& data){}; // /** // * @brief Get the Ouput object // * // * @param data // * @param fixed_data // */ // virtual void getOuput(Tensor<float>& data, Tensor<FixedType>& fixed_data); /** * @brief run op on CPU * */ virtual void runOnCPU(){}; /** * @brief run op on GPU * */ virtual void runOnGPU(){}; protected: /** * @brief expand data in 8bit * * @param dst_data * @param src_data * @param channel * @param src_wd * @param src_ht * @param pad_w_left * @param pad_h_top * @param pad_w_right * @param pad_h_bottom * @param const_value */ void MakeExpandData_8Bit(FixedConvType *dst_data, FixedConvType *src_data, int channel, int src_wd, int src_ht, int pad_w_left, int pad_h_top, int pad_w_right, int pad_h_bottom, int const_value); float* m_output_multi_rate; //fixed data multiple rate by channel float* m_input_multi_rate; //fixed data multiple rate by channel std::vector<std::vector<int64_t>> m_output_shape; std::vector<std::vector<int64_t>> m_input_shape; std::string m_op_name; int layer_flag_; int input_data_num_, output_data_num_; int model_size_; }; } } #endif
21.5
199
0.572036
[ "object", "shape", "vector" ]
acf901d574143054ffb618b4c7289221c4f60f90
749
h
C
Anubis/SDK/UserCmd.h
fengjixuchui/Anubis
0145647f88aa7bf47472363b1f029c31b4273f80
[ "MIT" ]
169
2019-04-26T19:47:40.000Z
2022-03-27T21:05:47.000Z
Anubis/SDK/UserCmd.h
fengjixuchui/Anubis
0145647f88aa7bf47472363b1f029c31b4273f80
[ "MIT" ]
7
2019-05-10T00:18:15.000Z
2021-12-03T21:27:42.000Z
Anubis/SDK/UserCmd.h
fengjixuchui/Anubis
0145647f88aa7bf47472363b1f029c31b4273f80
[ "MIT" ]
41
2019-05-18T06:59:18.000Z
2022-02-21T02:46:13.000Z
#pragma once #include <stdbool.h> #include <Windows.h> #include "Vector.h" enum UserCmdButtons { IN_ATTACK = 1 << 0, IN_JUMP = 1 << 1, IN_DUCK = 1 << 2, IN_FORWARD = 1 << 3, IN_BACK = 1 << 4, IN_USE = 1 << 5, IN_MOVELEFT = 1 << 9, IN_MOVERIGHT = 1 << 10, IN_ATTACK2 = 1 << 11, IN_SCORE = 1 << 16, IN_BULLRUSH = 1 << 22 }; struct UserCmd { INT pad; INT commandNumber; INT tickCount; struct Vector viewangles; struct Vector aimdirection; FLOAT forwardmove; FLOAT sidemove; FLOAT upmove; enum UserCmdButtons buttons; BYTE impulse; INT weaponselect; INT weaponsubtype; INT randomSeed; SHORT mousedx; SHORT mousedy; bool hasbeenpredicted; };
18.725
32
0.604806
[ "vector" ]
acf99023fd39252142fb75dd3d91300453b3cac8
1,056
h
C
headers/gtk-2.0/gdk/gdkcairo.h
mwichmann/lsb-buildenv
7a7eb64b5960172e0032e7202aeb454e076880fa
[ "BSD-3-Clause" ]
null
null
null
headers/gtk-2.0/gdk/gdkcairo.h
mwichmann/lsb-buildenv
7a7eb64b5960172e0032e7202aeb454e076880fa
[ "BSD-3-Clause" ]
null
null
null
headers/gtk-2.0/gdk/gdkcairo.h
mwichmann/lsb-buildenv
7a7eb64b5960172e0032e7202aeb454e076880fa
[ "BSD-3-Clause" ]
null
null
null
#if (__LSB_VERSION__ >= 40 ) #ifndef _GTK_2_0_GDK_GDKCAIRO_H_ #define _GTK_2_0_GDK_GDKCAIRO_H_ #include <glib-2.0/glib-object.h> #include <gdk-pixbuf-2.0/gdk-pixbuf/gdk-pixbuf.h> #include <gtk-2.0/gdk/gdk.h> #include <cairo/cairo.h> #ifdef __cplusplus extern "C" { #endif /* Function prototypes */ extern cairo_t *gdk_cairo_create(GdkDrawable * drawable); extern void gdk_cairo_rectangle(cairo_t * cr, const GdkRectangle * rectangle); extern void gdk_cairo_region(cairo_t * cr, const GdkRegion * region); extern void gdk_cairo_set_source_color(cairo_t * cr, const GdkColor * color); extern void gdk_cairo_set_source_pixbuf(cairo_t * cr, const GdkPixbuf * pixbuf, double pixbuf_x, double pixbuf_y); #if __LSB_VERSION__ >= 41 extern void gdk_cairo_set_source_pixmap(cairo_t * cr, GdkPixmap * pixmap, double pixmap_x, double pixmap_y); #endif /* __LSB_VERSION__ >= 4.1 */ #ifdef __cplusplus } #endif #endif /* protection */ #endif /* LSB version */
26.4
73
0.689394
[ "object" ]
acfc736229a712d5519c1d257f1422d06fb0e410
5,465
h
C
Pod/Classes/WBWebViewController.h
huipengo/WBWebView
1f2d0eae7fd619f014a89bb347a297e6fe82564e
[ "MIT" ]
3
2018-09-03T09:30:35.000Z
2020-02-04T06:37:55.000Z
Pod/Classes/WBWebViewController.h
huipengo/WBWebView
1f2d0eae7fd619f014a89bb347a297e6fe82564e
[ "MIT" ]
null
null
null
Pod/Classes/WBWebViewController.h
huipengo/WBWebView
1f2d0eae7fd619f014a89bb347a297e6fe82564e
[ "MIT" ]
1
2018-10-18T16:21:05.000Z
2018-10-18T16:21:05.000Z
// // WBWebViewController.h // WBKit_Example // // Created by penghui8 on 2018/7/9. // Copyright © 2018年 huipengo. All rights reserved. // 参考:https://github.com/devedbox/AXWebViewController #import <UIKit/UIKit.h> #import <WebKit/WebKit.h> #import "WBWebView.h" #import "WBSecurityPolicy.h" NS_ASSUME_NONNULL_BEGIN typedef NSURLSessionAuthChallengeDisposition (^WKWebViewDidReceiveAuthenticationChallengeHandler)(WKWebView *webView, NSURLAuthenticationChallenge *challenge, NSURLCredential * _Nullable __autoreleasing * _Nullable credential); API_AVAILABLE(ios(8.0)) typedef void(^WBDismissWebViewCompletion)(void); @interface WBWebViewController : UIViewController @property (nonatomic, strong, readonly) WBWebView *webView; /// Open app link in app store app. Default is NO. @property(nonatomic, assign) BOOL reviewsAppInAppStore; /// Max length of title string content. Default is 12. @property (nonatomic, assign) NSUInteger maxAllowedTitleLength; /// Time out internal. @property (nonatomic, assign) NSTimeInterval timeoutInternal; /// Cache policy. @property (nonatomic, assign) NSURLRequestCachePolicy cachePolicy; /// The based initialized url of the web view controller if any. @property (nonatomic, readonly) NSURL *URL; /** progress color */ @property (nonatomic, strong) UIColor * _Nullable loadingProgressColor; /** Background Title. default NO */ @property (nonatomic, assign) BOOL showBackgroundLabel; @property (nonatomic, assign) BOOL showNavigationCloseBarButtonItem; /// Check url can open default YES, only work after iOS 8. @property (nonatomic, assign) BOOL checkUrlCanOpen API_AVAILABLE(ios(8.0)); @property (nonatomic, strong) NSArray<NSString *> *removeElementIds; @property (nonatomic, copy) WBDismissWebViewCompletion dismissWebViewCompletion; /// Get a instance of `WBWebViewController` by a url. /// /// @param URL a URL to be loaded. /// /// @return a instance of `WBWebViewController`. - (instancetype)initWithURL:(NSURL *)URL; /// Get a instance of `WBWebViewController` by a url request. /// /// @param request a URL request to be loaded. /// /// @return a instance of `WBWebViewController`. - (instancetype)initWithRequest:(NSURLRequest *)request; /// Get a instance of `WBWebViewController` by a url and configuration of web view. /// /// @param URL a URL to be loaded. /// @param configuration configuration instance of WKWebViewConfiguration to create web view. /// /// @return a instance of `WBWebViewController`. - (instancetype)initWithURL:(NSURL *)URL configuration:(WKWebViewConfiguration *)configuration; /// Get a instance of `WBWebViewController` by a request and configuration of web view. /// /// @param request a URL request to be loaded. /// @param configuration configuration instance of WKWebViewConfiguration to create web view. /// /// @return a instance of `WBWebViewController`. - (instancetype)initWithRequest:(NSURLRequest *)request configuration:(WKWebViewConfiguration *)configuration; /// Get a instance of `WBWebViewController` by a HTML string and a base URL. /// /// @param HTMLString a HTML string object. /// @param baseURL a baseURL to be loaded. /// /// @return a instance of `WBWebViewController`. - (instancetype)initWithHTMLString:(NSString *)HTMLString baseURL:(NSURL * _Nullable)baseURL; /// Load a new url. /// /// @param URL a new url. - (void)loadURL:(NSURL *)URL; /// Load a new html string. /// /// @param HTMLString a encoded html string. /// @param baseURL base url of bundle. - (void)loadHTMLString:(NSString *)HTMLString baseURL:(NSURL *)baseURL; @end @interface WBWebViewController (items) - (void)updateFrameOfProgressView; - (void)updateNavigationItems; - (void)updateToolbarItems; - (void)updateNavigationItemTitle; - (void)updateBackgroundLabelText; @end @interface WBWebViewController (Cookie) /** 读取本地磁盘的cookies,包括WKWebview的cookies和sharedHTTPCookieStorage存储的cookies @return 返回包含所有的cookies的数组; 当系统低于 iOS11 时,cookies 将同步NSHTTPCookieStorage的cookies,当系统大于iOS11时,cookies 将同步 */ - (NSMutableArray<NSHTTPCookie *> *)sharedHTTPCookieStorage; /** 提供cookies插入,用于loadRequest 网页之前 @param cookie NSHTTPCookie 类型 cookie 需要设置 cookie 的name,value,domain,expiresDate(过期时间,当不设置过期时间,cookie将不会自动清除); cookie 设置expiresDate时使用 [cookieProperties setObject:expiresDate forKey:NSHTTPCookieExpires];将不起作用,原因不明;使用 cookieProperties[expiresDate] = expiresDate; 设置cookies 设置时间。 */ - (void)setCookie:(NSHTTPCookie *)cookie; /** delete cookie @param cookie cookie @param completionHandler call back */ - (void)wb_deleteCookie:(NSHTTPCookie *)cookie completionHandler:(nullable void (^)(void))completionHandler; - (void)wb_deleteCookiesByURL:(NSURL *)URL completionHandler:(nullable void (^)(void))completionHandler; /** clear all cookies */ + (void)clearAllCookies; @end @interface WBWebViewController (WebCache) /** Clear cache data of web view. @param completion completion block */ + (void)clearWebCacheCompletion:(dispatch_block_t _Nullable)completion; @end @interface WBWebViewController (Security) /// Challenge handler for the credential. @property(nonatomic, copy, nullable) WKWebViewDidReceiveAuthenticationChallengeHandler challengeHandler; /// The security policy used by created session to evaluate server trust for secure connections. /// `WBWebViewController` uses the `defaultPolicy` unless otherwise specified. @property(nonatomic, readwrite, nullable) WBSecurityPolicy *securityPolicy; @end NS_ASSUME_NONNULL_END
30.19337
227
0.77237
[ "object" ]
4a06f7d8f0b36b55f9659633c1f8fb02c5d0ef0c
2,186
h
C
components/sync/model/sync_metadata_store.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
14,668
2015-01-01T01:57:10.000Z
2022-03-31T23:33:32.000Z
components/sync/model/sync_metadata_store.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
395
2020-04-18T08:22:18.000Z
2021-12-08T13:04:49.000Z
components/sync/model/sync_metadata_store.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
5,941
2015-01-02T11:32:21.000Z
2022-03-31T16:35:46.000Z
// Copyright 2017 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. #ifndef COMPONENTS_SYNC_MODEL_SYNC_METADATA_STORE_H_ #define COMPONENTS_SYNC_MODEL_SYNC_METADATA_STORE_H_ #include <string> #include "components/sync/base/model_type.h" namespace sync_pb { class EntityMetadata; class ModelTypeState; } // namespace sync_pb namespace syncer { // SyncMetadataStore defines interface implemented by model types for persisting // sync metadata and datatype state. It allows model type to use common // implementation of MetadataChangeList (SyncMetadataStoreChangeList) instead of // implementing their own. // Model type in implementation of ModelTypeSyncBridge::CreateMetadataChangeList // should create instance of SyncMetadataStoreChangeList passing pointer to // SyncMetadataStore to its constructor. // Implementations of SyncMetadataStore methods should support add/update/delete // metadata in model type specific sync metadata storage. class SyncMetadataStore { public: SyncMetadataStore() {} virtual ~SyncMetadataStore() {} // Update the metadata row for |model_type|, keyed by |storage_key|, to // contain the contents of |metadata|. // Return true on success. virtual bool UpdateSyncMetadata(syncer::ModelType model_type, const std::string& storage_key, const sync_pb::EntityMetadata& metadata) = 0; // Remove the metadata row of type |model_type| keyed by |storage_key|. // Return true on success. virtual bool ClearSyncMetadata(syncer::ModelType model_type, const std::string& storage_key) = 0; // Update the stored sync state for the |model_type|. // Return true on success. virtual bool UpdateModelTypeState( syncer::ModelType model_type, const sync_pb::ModelTypeState& model_type_state) = 0; // Clear the stored sync state for |model_type|. // Return true on success. virtual bool ClearModelTypeState(syncer::ModelType model_type) = 0; }; } // namespace syncer #endif // COMPONENTS_SYNC_MODEL_SYNC_METADATA_STORE_H_
36.433333
80
0.743367
[ "model" ]
4a30133c95d0313e5ea826d8086761b0084df276
24,134
c
C
base/mvdm/softpc.new/base/bios/bios.c
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
base/mvdm/softpc.new/base/bios/bios.c
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
base/mvdm/softpc.new/base/bios/bios.c
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
#include "insignia.h" #include "host_def.h" /* * VPC-XT Revision 1.0 * * Title : bios * * Description : Vector of BOP calls which map to appropriate BIOS functions * * Author : Rod MacGregor * * Notes : hard disk int (0D) and command_check (B0) added DAR * * Mods: (r2.14): Replaced the entry against BOP 18 (not_supported()) * with the dummy routine rom_basic(). * */ #ifdef SCCSID static char SccsID[]="@(#)bios.c 1.64 06/28/95 Copyright Insignia Solutions Ltd."; #endif #ifdef SEGMENTATION /* * The following #include specifies the code segment into which this * module will by placed by the MPW C compiler on the Mac II running * MultiFinder. */ #include "BIOS_SUPPORT.seg" #endif /* * O/S include files. */ #include <stdio.h> #include TypesH /* * SoftPC include files */ #include "xt.h" #include "bios.h" #include CpuH #include "host.h" #include "cntlbop.h" #include "host_hfx.h" #include "hfx.h" #include "virtual.h" #include "gispsvga.h" #ifdef SWIN_HFX #include "winfiles.h" #endif #ifdef RDCHK extern void get_lar IPT0(); #endif /* RDCHK */ #ifdef CPU_40_STYLE #define SWAP_INSTANCE virtual_swap_instance() #else #define SWAP_INSTANCE #endif /* Traps for BOP's requiring virtualisation. */ #ifdef SWIN_HFX LOCAL void v_SwinRedirector IFN0() { SWAP_INSTANCE; SwinRedirector(); } #endif LOCAL void v_mouse_install1 IFN0() { SWAP_INSTANCE; mouse_install1(); } LOCAL void v_mouse_install2 IFN0() { SWAP_INSTANCE; mouse_install2(); } LOCAL void v_mouse_io_interrupt IFN0() { SWAP_INSTANCE; mouse_io_interrupt(); } LOCAL void v_mouse_io_language IFN0() { SWAP_INSTANCE; mouse_io_language(); } LOCAL void v_mouse_video_io IFN0() { SWAP_INSTANCE; mouse_video_io(); } LOCAL void v_mouse_int1 IFN0() { SWAP_INSTANCE; mouse_int1(); } LOCAL void v_mouse_int2 IFN0() { SWAP_INSTANCE; mouse_int2(); } #if defined(XWINDOW) || defined(NTVDM) LOCAL void v_host_mouse_install1 IFN0() {SWAP_INSTANCE; host_mouse_install1(); } LOCAL void v_host_mouse_install2 IFN0() {SWAP_INSTANCE; host_mouse_install2(); } #endif /* XWINDOW || NTVDM */ #ifdef HFX LOCAL void v_test_for_us IFN0() { SWAP_INSTANCE; test_for_us(); } LOCAL void v_redirector IFN0() { SWAP_INSTANCE; redirector(); } #endif /* HFX */ LOCAL void v_mouse_EM_callback IFN0() { SWAP_INSTANCE; mouse_EM_callback(); } #ifdef PROFILE extern void dump_profile IPT0(); extern void reset_profile IPT0(); #endif #ifdef SIGNAL_PROFILING extern void Start_sigprof IPT0(); extern void Stop_sigprof IPT0(); extern void Dump_sigprof IPT0(); #endif #if !defined(PROD) && defined(CPU_40_STYLE) extern void FmDebugBop IPT0(); #endif #if defined(CPU_40_STYLE) && !defined(NTVDM) extern void VDD_Func IPT0(); #endif #ifndef PROD extern void trace_msg_bop IPT0(); extern void dvr_bop_trace IPT0(); #endif #ifdef NTVDM void rtc_int(void); #endif #ifndef MAC_LIKE void (*BIOS[])() = { reset, /* BOP 00 */ dummy_int, /* BOP 01 */ unexpected_int, /* BOP 02 */ #ifdef DOS_APP_LIC DOS_AppLicense, /* BOP 03 */ #else illegal_bop, /* BOP 03 */ #endif /* DOS_APP_LIC */ #ifdef WDCTRL_BOP wdctrl_bop, /* BOP 04 */ #else /* WDCTRL_BOP */ illegal_bop, /* BOP 04 */ #endif /* WDCTRL_BOP */ #if !defined(PROD) && defined(CPU_40_STYLE) FmDebugBop, /* BOP 05 */ #else illegal_bop, /* BOP 05 */ #endif /* !PROD && CPU_40_STYLE */ illegal_op_int, /* BOP 06 */ illegal_dvr_bop,/* BOP 07 */ #if defined(NTVDM) || defined(CPU_40_STYLE) illegal_bop, /* BOP 08 */ #else /* !(NTVDM || CPU_40_STYLE) */ time_int, /* BOP 08 */ #endif /* !(NTVDM || CPU_40_STYLE) */ keyboard_int, /* BOP 09 */ illegal_bop, /* BOP 0A */ illegal_bop, /* BOP 0B */ illegal_bop, /* BOP 0C */ /* disk interrupts on vector 76 .. no BOP required though! * diskbios() uses re-entrant CPU to get disk interrupt * and the disk ISR is pure Intel assembler (with no BOPs) */ illegal_bop, /* BOP 0D */ diskette_int, /* BOP 0E */ illegal_bop, /* BOP 0F */ video_io, /* BOP 10 */ equipment, /* BOP 11 */ memory_size, /* BOP 12 */ disk_io, /* BOP 13 */ rs232_io, /* BOP 14 */ cassette_io, /* BOP 15 */ keyboard_io, /* BOP 16 */ printer_io, /* BOP 17 */ rom_basic, /* BOP 18 */ #ifdef NTVDM /* NT port, kill vdm instance, instead of warmbooting */ terminate, #else bootstrap, /* BOP 19 */ #endif time_of_day, /* BOP 1A */ illegal_bop, /* BOP 1B */ illegal_bop, /* BOP 1C */ kb_idle_poll, /* BOP 1D */ illegal_bop, /* BOP 1E */ illegal_bop, /* BOP 1F */ #if defined(RDCHK) && !defined(PROD) get_lar, /* BOP 20, used to debug read checks */ #else illegal_bop, /* BOP 20 */ #endif Get_build_id, /* BOP 21 */ #ifdef WIN_VTD VtdTickSync, /* BOP 22 */ #else illegal_bop, /* BOP 22 */ #endif /* WIN_VTD */ illegal_bop, /* BOP 23 */ illegal_bop, /* BOP 24 */ #if defined(CPU_40_STYLE) && !defined(NTVDM) VDD_Func, /* BOP 25 */ #else illegal_bop, /* BOP 25 */ #endif /* CPU_40_STYLE */ illegal_bop, /* BOP 26 */ illegal_bop, /* BOP 27 */ illegal_bop, /* BOP 28 */ illegal_bop, /* BOP 29 */ illegal_bop, /* BOP 2A */ #ifndef NTVDM cmd_install, /* BOP 2B */ cmd_load, /* BOP 2C */ #else /* NTVDM */ illegal_bop, /* BOP 2B */ illegal_bop, /* BOP 2C */ #endif /* NTVDM */ illegal_bop, /* BOP 2D */ #ifdef HFX v_test_for_us, /* BOP 2E */ /* test_for_us */ v_redirector, /* BOP 2F */ /* redirector */ #else illegal_bop, /* BOP 2E */ illegal_bop, /* BOP 2F */ #endif #ifdef DPMI DPMI_2F, /* BOP 30 */ DPMI_31, /* BOP 31 */ DPMI_general, /* BOP 32 */ DPMI_int, /* BOP 33 */ #else illegal_bop, /* BOP 30 */ illegal_bop, /* BOP 31 */ illegal_bop, /* BOP 32 */ illegal_bop, /* BOP 33 */ #endif /* DPMI */ #ifdef NOVELL DriverInitialize, /* BOP 34 */ DriverReadPacket, /* BOP 35 */ DriverSendPacket, /* BOP 36 */ DriverMulticastChange, /* BOP 37 */ DriverReset, /* BOP 38 */ DriverShutdown, /* BOP 39 */ DriverAddProtocol, /* BOP 3A */ DriverChangePromiscuous, /* BOP 3B */ DriverOpenSocket, /* BOP 3C */ DriverCloseSocket, /* BOP 3D */ #ifdef NOVELL_CFM DriverCheckForMore, /* BOP 3E */ #else illegal_bop, /* Spare BOP 3E */ #endif #ifdef V4CLIENT DriverChangeIntStatus, /* BOP 3F */ #else illegal_bop, /* Spare BOP 3F */ #endif /* V4CLIENT */ #else /* NOVELL */ illegal_bop, /* BOP 34 */ illegal_bop, /* BOP 35 */ illegal_bop, /* BOP 36 */ illegal_bop, /* BOP 37 */ illegal_bop, /* BOP 38 */ illegal_bop, /* BOP 39 */ illegal_bop, /* BOP 3A */ illegal_bop, /* BOP 3B */ illegal_bop, /* BOP 3C */ illegal_bop, /* BOP 3D */ illegal_bop, /* BOP 3E */ illegal_bop, /* BOP 3F */ #endif /* NOVELL */ diskette_io, /* BOP 40 */ illegal_bop, /* BOP 41 */ #ifdef EGG ega_video_io, /* BOP 42 */ #else illegal_bop, /* BOP 42 */ #endif #ifdef JAPAN MS_DosV_bop, /* BOP 43 - for MS-DOS/V */ #elif defined(KOREA) // !JAPAN /* The basic function of Korean Hangul DOS BOP is similary with Japanese DOS/V. But, We just change the name. */ MS_HDos_bop, /* BOP 43 - for MS-HDOS */ #else // !KOREA illegal_bop, /* BOP 43 */ #endif // !KOREA illegal_bop, /* BOP 44 */ illegal_bop, /* BOP 45 */ illegal_bop, /* BOP 46 */ illegal_bop, /* BOP 47 */ illegal_bop, /* BOP 48 */ #ifdef DPMI DPMI_r0_int, /* BOP 49 */ DPMI_exc, /* BOP 4A */ DPMI_4B, /* BOP 4B */ #else illegal_bop, /* BOP 49 */ illegal_bop, /* BOP 4A */ illegal_bop, /* BOP 4B */ #endif /* DPMI */ illegal_bop, /* BOP 4C */ illegal_bop, /* BOP 4D */ illegal_bop, /* BOP 4E */ illegal_bop, /* BOP 4F */ #ifdef NTVDM /* Note that this precludes SMEG and NT existing together which seems reasonable given the Unix & X dependencies of SMEG */ MS_bop_0, /* BOP 50 - MS reserved */ MS_bop_1, /* BOP 51 - MS reserved */ MS_bop_2, /* BOP 52 - MS reserved */ MS_bop_3, /* BOP 53 - MS reserved */ MS_bop_4, /* BOP 54 - MS reserved */ MS_bop_5, /* BOP 55 - MS reserved */ MS_bop_6, /* BOP 56 - MS reserved */ MS_bop_7, /* BOP 57 - MS reserved */ MS_bop_8, /* BOP 58 - MS reserved */ MS_bop_9, /* BOP 59 - MS reserved */ MS_bop_A, /* BOP 5A - MS reserved */ MS_bop_B, /* BOP 5B - MS reserved */ MS_bop_C, /* BOP 5C - MS reserved */ MS_bop_D, /* BOP 5D - MS reserved */ MS_bop_E, /* BOP 5E - MS reserved */ MS_bop_F, /* BOP 5F - MS reserved */ #else #ifdef SMEG smeg_collect_data,/* BOP 50 */ smeg_freeze_data, /* BOP 51 */ #else illegal_bop, /* BOP 50 */ illegal_bop, /* BOP 51 */ #endif /* SMEG */ #if defined(IRET_HOOKS) && defined(GISP_CPU) Cpu_hook_bop, /* BOP 52 */ #else illegal_bop, /* BOP 52 */ #endif /* IRET_HOOKS && GISP_CPU */ #ifdef GISP_SVGA romMessageAddress, /* BOP 53 */ #else illegal_bop, /* BOP 53 */ #endif illegal_bop, /* BOP 54 */ illegal_bop, /* BOP 55 */ illegal_bop, /* BOP 56 */ illegal_bop, /* BOP 57 */ illegal_bop, /* BOP 58 */ illegal_bop, /* BOP 59 */ illegal_bop, /* BOP 5A */ illegal_bop, /* BOP 5B */ illegal_bop, /* BOP 5C */ illegal_bop, /* BOP 5D */ illegal_bop, /* BOP 5E */ illegal_bop, /* BOP 5F */ #endif /* NTVDM */ softpc_version, /* BOP 60 */ illegal_bop, /* BOP 61 */ illegal_bop, /* BOP 62 */ #ifdef PTY com_bop_pty, /* BOP 63 */ #else illegal_bop, /* BOP 63 */ #endif illegal_bop, /* BOP 64 */ #ifdef PC_CONFIG pc_config, /* BOP 65 */ #else illegal_bop, /* BOP 65 */ #endif #ifdef LIM emm_init, /* BOP 66 */ emm_io, /* BOP 67 */ return_from_call, /* BOP 68 */ #else illegal_bop, /* BOP 66 */ illegal_bop, /* BOP 67 */ illegal_bop, /* BOP 68 */ #endif #ifdef SUSPEND suspend_softpc, /* BOP 69 */ terminate, /* BOP 6A */ #else illegal_bop, /* BOP 69 */ illegal_bop, /* BOP 6A */ #endif #ifdef GEN_DRVR gen_driver_io, /* BOP 6B */ #else illegal_bop, /* BOP 6B */ #endif #ifdef SUSPEND send_script, /* BOP 6C */ #else illegal_bop, /* BOP 6C */ #endif illegal_bop, /* BOP 6D */ illegal_bop, /* BOP 6E */ #ifdef CDROM bcdrom_io, /* BOP 6F */ #else illegal_bop, /* BOP 6F */ #endif #ifdef NTVDM rtc_int, /* BOP 70 */ #else illegal_bop, /* BOP 70 */ #endif re_direct, /* BOP 71 */ D11_int, /* BOP 72 */ D11_int, /* BOP 73 */ D11_int, /* BOP 74 */ int_287, /* BOP 75 */ D11_int, /* BOP 76 */ D11_int, /* BOP 77 */ #ifndef NTVDM worm_init, /* BOP 78 */ worm_io, /* BOP 79 */ #else /* NTVDM */ illegal_bop, /* BOP 78 */ illegal_bop, /* BOP 79 */ #endif /* NTVDM */ illegal_bop, /* BOP 7A */ illegal_bop, /* BOP 7B */ illegal_bop, /* BOP 7C */ illegal_bop, /* BOP 7D */ illegal_bop, /* BOP 7E */ illegal_bop, /* BOP 7F */ illegal_bop, /* BOP 80 */ illegal_bop, /* BOP 81 */ illegal_bop, /* BOP 82 */ illegal_bop, /* BOP 83 */ illegal_bop, /* BOP 84 */ illegal_bop, /* BOP 85 */ illegal_bop, /* BOP 86 */ illegal_bop, /* BOP 87 */ illegal_bop, /* BOP 88 */ illegal_bop, /* BOP 89 */ illegal_bop, /* BOP 8A */ illegal_bop, /* BOP 8B */ illegal_bop, /* BOP 8C */ illegal_bop, /* BOP 8D */ illegal_bop, /* BOP 8E */ illegal_bop, /* BOP 8F */ #ifdef NTVDM /* No bootstrap on NT */ illegal_bop, /* BOP 90 */ illegal_bop, /* BOP 91 */ illegal_bop, /* BOP 92 */ #else bootstrap1, /* BOP 90 */ bootstrap2, /* BOP 91 */ bootstrap3, /* BOP 92 */ #endif #ifdef SWINAPI Gdi_call, /* BOP 93 */ User_call, /* BOP 94 */ Swinapi_bop, /* BOP 95 */ #else /* SWINAPI */ illegal_bop, /* BOP 93 */ illegal_bop, /* BOP 94 */ illegal_bop, /* BOP 95 */ #endif /* SWINAPI */ illegal_bop, /* BOP 96 */ illegal_bop, /* BOP 97 */ #ifdef MSWDVR ms_windows, /* BOP 98 */ msw_mouse, /* BOP 99 */ msw_copy, /* BOP 9A */ msw_keybd, /* BOP 9B */ #else illegal_bop, /* BOP 98 */ illegal_bop, /* BOP 99 */ illegal_bop, /* BOP 9A */ illegal_bop, /* BOP 9B */ #endif #if defined(SOFTWIN_API) || defined(SWIN_HFX) SoftWindowsInit, /* BOP 9C */ SoftWindowsTerm, /* BOP 9D */ #else illegal_bop, /* BOP 9C */ illegal_bop, /* BOP 9D */ #endif /* SOFTWIN_API or SWIN_HFX */ #if defined(SOFTWIN_API) SoftWindowsApi, /* BOP 9E */ #else illegal_bop, /* BOP 9E */ #endif /* SOFTWIN_API */ #ifdef SWIN_HAW msw_sound, /* BOP 9F */ #else illegal_bop, /* BOP 9F */ #endif /* SWIN_HAW */ #ifdef NOVELL_IPX IPXResInit, /* BOP A0 */ IPXResEntry, /* BOP A1 */ IPXResInterrupt,/* BOP A2 */ illegal_bop, /* BOP A3 */ #else /* NOVELL_IPX */ illegal_bop, /* BOP A0 */ illegal_bop, /* BOP A1 */ illegal_bop, /* BOP A2 */ illegal_bop, /* BOP A3 */ #endif /* NOVELL_IPX */ #ifdef NOVELL_TCPIP TCPResInit, /* BOP A4 */ TCPResEntry, /* BOP A5 */ #else /* NOVELL_TCPIP */ illegal_bop, /* BOP A4 */ illegal_bop, /* BOP A5 */ #endif /* NOVELL_TCPIP */ #ifdef WINSOCK ISWSEntry, /* BOP A6 */ illegal_bop, /* BOP A7 */ #else /* WINSOCK */ illegal_bop, /* BOP A6 */ illegal_bop, /* BOP A7 */ #endif /* WINSOCK */ illegal_bop, /* BOP A8 */ illegal_bop, /* BOP A9 */ #ifdef SWIN_HFX v_SwinRedirector, /* BOP AA */ /* SwinRedirector */ SwinFileOpened, /* BOP AB */ SwinHfxTaskTerm, /* BOP AC */ #else illegal_bop, /* BOP AA */ illegal_bop, /* BOP AB */ illegal_bop, /* BOP AC */ #endif #ifdef MSWDVR msw_copyInit, /* BOP AD */ illegal_bop, /* BOP AE */ illegal_bop, /* BOP AF */ illegal_bop, /* BOP B0 */ #else illegal_bop, /* BOP AD */ illegal_bop, /* BOP AE */ illegal_bop, /* BOP AF */ illegal_bop, /* BOP B0 */ #endif #ifdef CPU_40_STYLE virtual_device_trap, /* BOP B1 */ #else illegal_bop, /* BOP B1 */ #endif illegal_bop, /* BOP B2 */ illegal_bop, /* BOP B3 */ illegal_bop, /* BOP B4 */ illegal_bop, /* BOP B5 */ illegal_bop, /* BOP B6 */ illegal_bop, /* BOP B7 */ v_mouse_install1, /* BOP B8 */ /* mouse_install1 */ v_mouse_install2, /* BOP B9 */ /* mouse_install2 */ v_mouse_int1, /* BOP BA */ /* mouse_int1 */ v_mouse_int2, /* BOP BB */ /* mouse_int2 */ v_mouse_io_language, /* BOP BC */ /* mouse_io_language */ v_mouse_io_interrupt, /* BOP BD */ /* mouse_io_interrupt */ v_mouse_video_io, /* BOP BE */ /* mouse_video_io */ v_mouse_EM_callback, /* BOP BF */ /* mouse_EM_callback */ illegal_bop, /* BOP C0 */ illegal_bop, /* BOP C1 */ illegal_bop, /* BOP C2 */ illegal_bop, /* BOP C3 */ illegal_bop, /* BOP C4 */ illegal_bop, /* BOP C5 */ illegal_bop, /* BOP C6 */ illegal_bop, /* BOP C7 */ #if defined(XWINDOW) || defined(NTVDM) v_host_mouse_install1, /* BOP C8 */ /* host_mouse_install1 */ v_host_mouse_install2, /* BOP C9 */ /* host_mouse_install2 */ #else #ifdef GISP_SVGA mouse_install1, mouse_install2, #else /* GISP_SVGA */ illegal_bop, /* BOP C8 */ illegal_bop, /* BOP C9 */ #endif /* GISP_SVGA */ #endif /* defined(XWINDOW) || defined(NTVDM) */ illegal_bop, /* BOP CA */ illegal_bop, /* BOP CB */ illegal_bop, /* BOP CC */ illegal_bop, /* BOP CD */ illegal_bop, /* BOP CE */ illegal_bop, /* BOP CF */ #ifdef PROFILE reset_profile, /* BOP D0 */ dump_profile, /* BOP D1 */ #else illegal_bop, /* BOP D0 */ illegal_bop, /* BOP D1 */ #endif illegal_bop, /* BOP D2 */ illegal_bop, /* BOP D3 */ #ifdef SIGNAL_PROFILING Start_sigprof, /* BOP D4 */ Stop_sigprof, /* BOP D5 */ Dump_sigprof, /* BOP D6 */ #else illegal_bop, /* BOP D4 */ illegal_bop, /* BOP D5 */ illegal_bop, /* BOP D6 */ #endif illegal_bop, /* BOP D7 */ illegal_bop, /* BOP D8 */ illegal_bop, /* BOP D9 */ illegal_bop, /* BOP DA */ illegal_bop, /* BOP DB */ illegal_bop, /* BOP DC */ illegal_bop, /* BOP DD */ illegal_bop, /* BOP DE */ illegal_bop, /* BOP DF */ illegal_bop, /* BOP E0 */ illegal_bop, /* BOP E1 */ illegal_bop, /* BOP E2 */ illegal_bop, /* BOP E3 */ illegal_bop, /* BOP E4 */ illegal_bop, /* BOP E5 */ illegal_bop, /* BOP E6 */ illegal_bop, /* BOP E7 */ illegal_bop, /* BOP E8 */ illegal_bop, /* BOP E9 */ illegal_bop, /* BOP EA */ illegal_bop, /* BOP EB */ illegal_bop, /* BOP EC */ illegal_bop, /* BOP ED */ illegal_bop, /* BOP EE */ illegal_bop, /* BOP EF */ illegal_bop, /* BOP F0 */ illegal_bop, /* BOP F1 */ illegal_bop, /* BOP F2 */ illegal_bop, /* BOP F3 */ illegal_bop, /* BOP F4 */ illegal_bop, /* BOP F5 */ illegal_bop, /* BOP F6 */ illegal_bop, /* BOP F7 */ #ifndef PROD dvr_bop_trace, /* BOP F8 */ trace_msg_bop, /* BOP F9 -- pic*/ #else illegal_bop, /* BOP F8 */ illegal_bop, /* BOP F9 */ #endif #ifndef GISP_CPU illegal_bop, /* BOP FA */ illegal_bop, /* BOP FB */ illegal_bop, /* BOP FC */ #if defined(NTVDM) && defined(MONITOR) switch_to_real_mode, /* BOP FD */ #else illegal_bop, /* BOP FD */ #endif /* NTVDM && MONITOR */ #if !defined(LDBIOS) && !defined(CPU_30_STYLE) host_unsimulate,/* BOP FE */ #else #if defined(NTVDM) && defined(MONITOR) host_unsimulate, /* BOP FE */ #else illegal_bop, /* BOP FE */ #endif /* NTVDM && MONITOR */ #endif /* !LDBIOS && !CPU_30_STYLE */ #else /* ndef GISP_CPU */ /* In the GISP technology, BOPs FA, FC, FD and FE are assumed to be handled directly by the host operating system and cannot be used inside SoftPC. */ illegal_bop, /* BOP FA */ hg_bop_handler, /* BOP FB */ /* in hg_cpu.c */ illegal_bop, /* BOP FC */ illegal_bop, /* BOP FD */ illegal_bop, /* BOP FE */ #endif /* GISP_CPU */ control_bop /* BOP FF */ /* Don't put anymore entries after FF because we only have a byte quantity */ }; #endif /* MAC_LIKE */ #ifndef PROD #ifdef MAC_LIKE GLOBAL char *bop_name IFN1(IU8, bop_num) { return (NULL); } #else /* !MAC_LIKE */ typedef void (*BOP_proc) IPT0(); struct BOP_name { BOP_proc proc; char *name; }; #define BOP_NAME(proc) { proc, STRINGIFY(proc) } LOCAL struct BOP_name BOP_names[] = { BOP_NAME(reset), BOP_NAME(illegal_op_int), #if !defined(NTVDM) && !defined(CPU_40_STYLE) BOP_NAME(time_int), #endif /* !NTVDM && !CPU_40_STYLE */ BOP_NAME(keyboard_int), BOP_NAME(diskette_int), BOP_NAME(video_io), BOP_NAME(equipment), BOP_NAME(memory_size), BOP_NAME(disk_io), BOP_NAME(rs232_io), BOP_NAME(cassette_io), BOP_NAME(keyboard_io), BOP_NAME(printer_io), BOP_NAME(rom_basic), BOP_NAME(softpc_version), BOP_NAME(diskette_io), BOP_NAME(time_of_day), BOP_NAME(kb_idle_poll), #ifndef NTVDM BOP_NAME(cmd_install), BOP_NAME(cmd_load), #endif /* NTVDM */ BOP_NAME(diskette_io), BOP_NAME(v_mouse_install1), BOP_NAME(v_mouse_install2), BOP_NAME(v_mouse_int1), BOP_NAME(v_mouse_int2), BOP_NAME(v_mouse_io_language), BOP_NAME(v_mouse_io_interrupt), BOP_NAME(v_mouse_video_io), BOP_NAME(v_mouse_EM_callback), #ifdef PROFILE BOP_NAME(reset_profile), BOP_NAME(dump_profile), #endif #ifdef SIGNAL_PROFILING BOP_NAME(Start_sigprof), BOP_NAME(Stop_sigprof), BOP_NAME(Dump_sigprof), #endif BOP_NAME(re_direct), BOP_NAME(D11_int), BOP_NAME(D11_int), BOP_NAME(D11_int), BOP_NAME(int_287), BOP_NAME(D11_int), BOP_NAME(D11_int), #ifndef NTVDM BOP_NAME(worm_init), BOP_NAME(worm_io), #endif /* NTVDM */ #if defined(RDCHK) && !defined(PROD) BOP_NAME(get_lar), #endif #ifdef HFX BOP_NAME(v_test_for_us), BOP_NAME(v_redirector), #endif #ifdef DPMI BOP_NAME(DPMI_2F), BOP_NAME(DPMI_31), BOP_NAME(DPMI_general), BOP_NAME(DPMI_int), BOP_NAME(DPMI_r0_int), BOP_NAME(DPMI_exc), BOP_NAME(DPMI_4B), #endif /* DPMI */ #ifdef DOS_APP_LIC BOP_NAME(DOS_AppLicense), #endif #ifdef NOVELL BOP_NAME(DriverInitialize), BOP_NAME(DriverReadPacket), BOP_NAME(DriverSendPacket), BOP_NAME(DriverMulticastChange), BOP_NAME(DriverReset), BOP_NAME(DriverShutdown), BOP_NAME(DriverAddProtocol), BOP_NAME(DriverChangePromiscuous), BOP_NAME(DriverOpenSocket), BOP_NAME(DriverCloseSocket), #endif #ifdef EGG BOP_NAME(ega_video_io), #endif #ifdef NTVDM BOP_NAME(MS_bop_0), BOP_NAME(MS_bop_1), BOP_NAME(MS_bop_2), BOP_NAME(MS_bop_3), BOP_NAME(MS_bop_4), BOP_NAME(MS_bop_5), BOP_NAME(MS_bop_6), BOP_NAME(MS_bop_7), BOP_NAME(MS_bop_8), BOP_NAME(MS_bop_9), BOP_NAME(MS_bop_A), BOP_NAME(MS_bop_B), BOP_NAME(MS_bop_C), BOP_NAME(MS_bop_D), BOP_NAME(MS_bop_E), BOP_NAME(MS_bop_F), BOP_NAME(terminate), #else BOP_NAME(bootstrap), BOP_NAME(bootstrap1), BOP_NAME(bootstrap2), BOP_NAME(bootstrap3), #endif /* NTVDM */ #ifdef SMEG BOP_NAME(smeg_collect_data), BOP_NAME(smeg_freeze_data), #endif /* SMEG */ #if defined(IRET_HOOKS) && defined(GISP_CPU) BOP_NAME(Cpu_hook_bop), #endif /* IRET_HOOKS && GISP_CPU */ #ifdef GISP_SVGA BOP_NAME(romMessageAddress), #endif #ifdef PTY BOP_NAME(com_bop_pty), #endif #ifdef PC_CONFIG BOP_NAME(pc_config), #endif #ifdef LIM BOP_NAME(emm_init), BOP_NAME(emm_io), BOP_NAME(return_from_call), #endif #ifdef SUSPEND BOP_NAME(suspend_softpc), BOP_NAME(terminate), #endif #ifdef GEN_DRVR BOP_NAME(gen_driver_io), #endif #ifdef SUSPEND BOP_NAME(send_script), #endif #ifdef CDROM BOP_NAME(bcdrom_io), #endif #ifdef SWINAPI BOP_NAME(Gdi_call), BOP_NAME(User_call), BOP_NAME(Swinapi_bop), #endif /* SWINAPI */ #ifdef MSWDVR BOP_NAME(ms_windows), BOP_NAME(msw_mouse), BOP_NAME(msw_copy), BOP_NAME(msw_keybd), BOP_NAME(msw_copyInit), #endif #if defined(SOFTWIN_API) || defined(SWIN_HFX) BOP_NAME(SoftWindowsInit), BOP_NAME(SoftWindowsTerm), #endif /* SOFTWIN_API or SWIN_HFX */ #ifdef SOFTWIN_API BOP_NAME(SoftWindowsApi), #endif /* SOFTWIN_API */ #ifdef NOVELL_IPX BOP_NAME(IPXResInit), BOP_NAME(IPXResEntry), BOP_NAME(IPXResInterrupt), #endif /* NOVELL_IPX */ #ifdef NOVELL_TCPIP BOP_NAME(TCPResInit), BOP_NAME(TCPResEntry), #endif /* NOVELL_TCPIP */ #ifdef SWIN_HFX BOP_NAME(v_SwinRedirector), BOP_NAME(SwinFileOpened), BOP_NAME(SwinHfxTaskTerm), #endif #if defined(XWINDOW) || defined(NTVDM) BOP_NAME(v_host_mouse_install1), BOP_NAME(v_host_mouse_install2), #else #ifdef GISP_SVGA BOP_NAME(mouse_install1), BOP_NAME(mouse_install2), #endif /* GISP_SVGA */ #endif /* defined(XWINDOW) || defined(NTVDM) */ #if defined(NTVDM) && defined(MONITOR) BOP_NAME(switch_to_real_mode), #endif /* NTVDM && MONITOR */ BOP_NAME(control_bop), #ifdef WDCTRL_BOP BOP_NAME(wdctrl_bop), #endif /* WDCTRL_BOP */ #ifndef PROD BOP_NAME(trace_msg_bop), BOP_NAME(dvr_bop_trace), #endif BOP_NAME(illegal_bop), { 0, NULL } }; GLOBAL char *bop_name IFN1(IU8, bop_num) { struct BOP_name *bnp = BOP_names; BOP_proc proc = BIOS[bop_num]; if (bop_num == 0xFE) return "UNSIMULATE"; while ((bnp->name != NULL) && (proc != bnp->proc)) bnp++; return (bnp->name); } #endif /* !MAC_LIKE */ #endif /* PROD */
26.90524
83
0.603091
[ "vector", "3d" ]
4a37126d80d355aa5a81268b98dd7a62b04c54df
15,381
h
C
src/HciAdapter.h
code-in-the-cup/gobbledegook
d0fbad1b970dfd4ad86488263c9f419d09fea6ba
[ "BSD-3-Clause" ]
null
null
null
src/HciAdapter.h
code-in-the-cup/gobbledegook
d0fbad1b970dfd4ad86488263c9f419d09fea6ba
[ "BSD-3-Clause" ]
null
null
null
src/HciAdapter.h
code-in-the-cup/gobbledegook
d0fbad1b970dfd4ad86488263c9f419d09fea6ba
[ "BSD-3-Clause" ]
null
null
null
// Copyright 2017-2019 Paul Nettle // // This file is part of Gobbledegook. // // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file in the root of the source tree. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // >> // >>> INSIDE THIS FILE // >> // // Protocol-level code for the Bluetooth Management API, which is used to configure the Bluetooth adapter // // >> // >>> DISCUSSION // >> // // This class is intended for use by `Mgmt` (see Mgmt.cpp). // // See the discussion at the top of HciAdapter.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #pragma once #include <stdint.h> #include <vector> #include <thread> #include <mutex> #include <condition_variable> #include "HciSocket.h" #include "../include/Utils.h" #include "../include/Logger.h" namespace ggk { class HciAdapter { public: // // Constants // // How long to wait for a response event for commands sent to the adapter static const int kMaxEventWaitTimeMS = 1000; // A constant referring to a 'non-controller' (for commands that do not require a controller index) static const uint16_t kNonController = 0xffff; // Command code names static const int kMinCommandCode = 0x0001; static const int kMaxCommandCode = 0x0043; static const char * const kCommandCodeNames[kMaxCommandCode + 1]; // Event type names static const int kMinEventType = 0x0001; static const int kMaxEventType = 0x0025; static const char * const kEventTypeNames[kMaxEventType + 1]; static const int kMinStatusCode = 0x00; static const int kMaxStatusCode = 0x14; static const char * const kStatusCodes[kMaxStatusCode + 1]; // // Types // // HCI Controller Settings enum HciControllerSettings { EHciPowered = (1<<0), EHciConnectable = (1<<1), EHciFastConnectable = (1<<2), EHciDiscoverable = (1<<3), EHciBondable = (1<<4), EHciLinkLevelSecurity = (1<<5), EHciSecureSimplePairing = (1<<6), EHciBasicRate_EnhancedDataRate = (1<<7), EHciHighSpeed = (1<<8), EHciLowEnergy = (1<<9), EHciAdvertising = (1<<10), EHciSecureConnections = (1<<11), EHciDebugKeys = (1<<12), EHciPrivacy = (1<<13), EHciControllerConfiguration = (1<<14), EHciStaticAddress = (1<<15) }; struct HciHeader { uint16_t code; uint16_t controllerId; uint16_t dataSize; void toNetwork() { code = Utils::endianToHci(code); controllerId = Utils::endianToHci(controllerId); dataSize = Utils::endianToHci(dataSize); } void toHost() { code = Utils::endianToHost(code); controllerId = Utils::endianToHost(controllerId); dataSize = Utils::endianToHost(dataSize); } std::string debugText() { std::string text = ""; text += "> Request header\n"; text += " + Command code : " + Utils::hex(code) + " (" + HciAdapter::kCommandCodeNames[code] + ")\n"; text += " + Controller Id : " + Utils::hex(controllerId) + "\n"; text += " + Data size : " + std::to_string(dataSize) + " bytes"; return text; } } __attribute__((packed)); struct CommandCompleteEvent { HciHeader header; uint16_t commandCode; uint8_t status; CommandCompleteEvent(const std::vector<uint8_t> &data) { *this = *reinterpret_cast<const CommandCompleteEvent *>(data.data()); toHost(); // Log it Logger::debug(debugText()); } void toNetwork() { header.toNetwork(); commandCode = Utils::endianToHci(commandCode); } void toHost() { header.toHost(); commandCode = Utils::endianToHost(commandCode); } std::string debugText() { std::string text = ""; text += "> Command complete event\n"; text += " + Event code : " + Utils::hex(header.code) + " (" + HciAdapter::kEventTypeNames[header.code] + ")\n"; text += " + Controller Id : " + Utils::hex(header.controllerId) + "\n"; text += " + Data size : " + std::to_string(header.dataSize) + " bytes\n"; text += " + Command code : " + Utils::hex(commandCode) + " (" + HciAdapter::kCommandCodeNames[commandCode] + ")\n"; text += " + Status : " + Utils::hex(status); return text; } } __attribute__((packed)); struct CommandStatusEvent { HciHeader header; uint16_t commandCode; uint8_t status; CommandStatusEvent(const std::vector<uint8_t> &data) { *this = *reinterpret_cast<const CommandStatusEvent *>(data.data()); toHost(); // Log it Logger::debug(debugText()); } void toNetwork() { header.toNetwork(); commandCode = Utils::endianToHci(commandCode); } void toHost() { header.toHost(); commandCode = Utils::endianToHost(commandCode); } std::string debugText() { std::string text = ""; text += "> Command status event\n"; text += " + Event code : " + Utils::hex(header.code) + " (" + HciAdapter::kEventTypeNames[header.code] + ")\n"; text += " + Controller Id : " + Utils::hex(header.controllerId) + "\n"; text += " + Data size : " + std::to_string(header.dataSize) + " bytes\n"; text += " + Command code : " + Utils::hex(commandCode) + " (" + HciAdapter::kCommandCodeNames[commandCode] + ")\n"; text += " + Status : " + Utils::hex(status) + " (" + HciAdapter::kStatusCodes[status] + ")"; return text; } } __attribute__((packed)); struct DeviceConnectedEvent { HciHeader header; uint8_t address[6]; uint8_t addressType; uint32_t flags; uint16_t eirDataLength; DeviceConnectedEvent(const std::vector<uint8_t> &data) { *this = *reinterpret_cast<const DeviceConnectedEvent *>(data.data()); toHost(); // Log it Logger::debug(debugText()); } void toNetwork() { header.toNetwork(); flags = Utils::endianToHci(flags); eirDataLength = Utils::endianToHci(eirDataLength); } void toHost() { header.toHost(); flags = Utils::endianToHost(flags); eirDataLength = Utils::endianToHost(eirDataLength); } std::string debugText() { std::string text = ""; text += "> DeviceConnected event\n"; text += " + Event code : " + Utils::hex(header.code) + " (" + HciAdapter::kEventTypeNames[header.code] + ")\n"; text += " + Controller Id : " + Utils::hex(header.controllerId) + "\n"; text += " + Data size : " + std::to_string(header.dataSize) + " bytes\n"; text += " + Address : " + Utils::bluetoothAddressString(address) + "\n"; text += " + Address type : " + Utils::hex(addressType) + "\n"; text += " + Flags : " + Utils::hex(flags) + "\n"; text += " + EIR Data Length : " + Utils::hex(eirDataLength); if (eirDataLength > 0) { text += "\n"; text += " + EIR Data : " + Utils::hex(reinterpret_cast<uint8_t *>(&eirDataLength) + 2, eirDataLength); } return text; } } __attribute__((packed)); struct DeviceDisconnectedEvent { HciHeader header; uint8_t address[6]; uint8_t addressType; uint8_t reason; DeviceDisconnectedEvent(const std::vector<uint8_t> &data) { *this = *reinterpret_cast<const DeviceDisconnectedEvent *>(data.data()); toHost(); // Log it Logger::debug(debugText()); } void toNetwork() { header.toNetwork(); } void toHost() { header.toHost(); } std::string debugText() { std::string text = ""; text += "> DeviceDisconnected event\n"; text += " + Event code : " + Utils::hex(header.code) + " (" + HciAdapter::kEventTypeNames[header.code] + ")\n"; text += " + Controller Id : " + Utils::hex(header.controllerId) + "\n"; text += " + Data size : " + std::to_string(header.dataSize) + " bytes\n"; text += " + Address : " + Utils::bluetoothAddressString(address) + "\n"; text += " + Address type : " + Utils::hex(addressType) + "\n"; text += " + Reason : " + Utils::hex(reason); return text; } } __attribute__((packed)); struct AdapterSettings { uint32_t masks; void toHost() { masks = Utils::endianToHost(masks); } bool isSet(HciControllerSettings mask) { return (masks & mask) != 0; } // Returns a human-readable string of flags and settings std::string toString() { std::string text = ""; if (isSet(EHciPowered)) { text += "Powered, "; } if (isSet(EHciConnectable)) { text += "Connectable, "; } if (isSet(EHciFastConnectable)) { text += "FC, "; } if (isSet(EHciDiscoverable)) { text += "Discov, "; } if (isSet(EHciBondable)) { text += "Bondable, "; } if (isSet(EHciLinkLevelSecurity)) { text += "LLS, "; } if (isSet(EHciSecureSimplePairing)) { text += "SSP, "; } if (isSet(EHciBasicRate_EnhancedDataRate)) { text += "BR/EDR, "; } if (isSet(EHciHighSpeed)) { text += "HS, "; } if (isSet(EHciLowEnergy)) { text += "LE, "; } if (isSet(EHciAdvertising)) { text += "Adv, "; } if (isSet(EHciSecureConnections)) { text += "SC, "; } if (isSet(EHciDebugKeys)) { text += "DebugKeys, "; } if (isSet(EHciPrivacy)) { text += "Privacy, "; } if (isSet(EHciControllerConfiguration)) { text += "ControllerConfig, "; } if (isSet(EHciStaticAddress)) { text += "StaticAddr, "; } if (text.length() != 0) { text = text.substr(0, text.length() - 2); } return text; } std::string debugText() { std::string text = ""; text += "> Adapter settings\n"; text += " + " + toString(); return text; } } __attribute__((packed)); // The comments documenting these fields are very high level. There is a lot of detailed information not present, for example // some values are not available at all times. This is fully documented in: // // https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/mgmt-api.txt struct ControllerInformation { uint8_t address[6]; // The Bluetooth address uint8_t bluetoothVersion; // Bluetooth version uint16_t manufacturer; // The manufacturer AdapterSettings supportedSettings; // Bits for various supported settings (see HciControllerSettings) AdapterSettings currentSettings; // Bits for various currently configured settings (see HciControllerSettings) uint8_t classOfDevice[3]; // Um, yeah. That. char name[249]; // Null terminated name char shortName[11]; // Null terminated short name void toHost() { manufacturer = Utils::endianToHost(manufacturer); supportedSettings.toHost(); currentSettings.toHost(); } std::string debugText() { std::string text = ""; text += "> Controller information\n"; text += " + Current settings : " + Utils::hex(currentSettings.masks) + "\n"; text += " + Address : " + Utils::bluetoothAddressString(address) + "\n"; text += " + BT Version : " + std::to_string(static_cast<int>(bluetoothVersion)) + "\n"; text += " + Manufacturer : " + Utils::hex(manufacturer) + "\n"; text += " + Supported settings : " + supportedSettings.toString() + "\n"; text += " + Current settings : " + currentSettings.toString() + "\n"; text += " + Name : " + std::string(name) + "\n"; text += " + Short name : " + std::string(shortName); return text; } } __attribute__((packed)); struct VersionInformation { uint8_t version; uint16_t revision; void toHost() { revision = Utils::endianToHost(revision); } std::string debugText() { std::string text = ""; text += "> Version information\n"; text += " + Version : " + std::to_string(static_cast<int>(version)) + "\n"; text += " + Revision : " + std::to_string(revision); return text; } } __attribute__((packed)); struct LocalName { char name[249]; char shortName[11]; std::string debugText() { std::string text = ""; text += "> Local name information\n"; text += " + Name : '" + std::string(name) + "'\n"; text += " + Short name : '" + std::string(shortName) + "'"; return text; } } __attribute__((packed)); // // Accessors // // Returns the instance to this singleton class static HciAdapter &getInstance() { static HciAdapter instance; return instance; } AdapterSettings getAdapterSettings() { return adapterSettings; } ControllerInformation getControllerInformation() { return controllerInformation; } VersionInformation getVersionInformation() { return versionInformation; } LocalName getLocalName() { return localName; } int getActiveConnectionCount() { return activeConnections; } // // Disallow copies of our singleton (c++11) // HciAdapter(HciAdapter const&) = delete; void operator=(HciAdapter const&) = delete; // Reads current values from the controller // // This effectively requests data from the controller but that data may not be available instantly, but within a few // milliseconds. Therefore, it is not recommended attempt to retrieve the results from their accessors immediately. void sync(uint16_t controllerIndex); // Connects the HCI socket if a connection does not already exist and starts the run thread // // If a connection already exists, this method will fail // // Note that it shouldn't be necessary to connect manually; any action requiring a connection will automatically connect // // Returns true if the HCI socket is connected (either via a new connection or an existing one), otherwise false bool start(); // Waits for the HciAdapter run thread to join // // This method will block until the thread joins void stop(); // Sends a command over the HCI socket // // If the HCI socket is not connected, it will auto-connect prior to sending the command. In the case of a failed auto-connect, // a failure is returned. // // Returns true on success, otherwise false bool sendCommand(HciHeader &request); // Event processor, responsible for receiving events from the HCI socket // // This mehtod should not be called directly. Rather, it runs continuously on a thread until the server shuts down void runEventThread(); private: // Private constructor for our Singleton HciAdapter() : commandResponseLock(commandResponseMutex), activeConnections(0) {} // Uses a std::condition_variable to wait for a response event for the given `commandCode` or `timeoutMS` milliseconds. // // Returns true if the response event was received for `commandCode` or false if the timeout expired. // // Command responses are set via `setCommandResponse()` bool waitForCommandResponse(uint16_t commandCode, int timeoutMS); // Sets the command response and notifies the waiting std::condition_variable (see `waitForCommandResponse`) void setCommandResponse(uint16_t commandCode); // Our HCI Socket, which allows us to talk directly to the kernel HciSocket hciSocket; // Our event thread listens for events coming from the adapter and deals with them appropriately static std::thread eventThread; // Our adapter information AdapterSettings adapterSettings; ControllerInformation controllerInformation; VersionInformation versionInformation; LocalName localName; std::condition_variable cvCommandResponse; std::mutex commandResponseMutex; std::unique_lock<std::mutex> commandResponseLock; int conditionalValue; // Our active connection count int activeConnections; }; }; // namespace ggk
30.099804
132
0.639425
[ "vector" ]
4a418224b15319402ad42340d9dca7a7049275c2
169,997
h
C
SVFEngine/SVFEngine/mp3.h
safiar/SVFEngine
5038143a0f369e88dd4fab364a0c22f7729217b3
[ "Apache-2.0" ]
1
2018-04-26T14:27:35.000Z
2018-04-26T14:27:35.000Z
SVFEngine/SVFEngine/mp3.h
safiar/SVFEngine
5038143a0f369e88dd4fab364a0c22f7729217b3
[ "Apache-2.0" ]
1
2018-04-29T14:45:47.000Z
2018-04-29T14:45:47.000Z
SVFEngine/SVFEngine/mp3.h
safiar/SVFEngine
5038143a0f369e88dd4fab364a0c22f7729217b3
[ "Apache-2.0" ]
null
null
null
// ----------------------------------------------------------------------- // // // MODULE : mp3.h // // PURPOSE : Декодер MP3 ~ MPEG-1 Layer-3 audio // с поддержкой SSE/AVX/AVX512 оптимизации // // CREATED : SavF. ⚡ Savenkov Filipp A. (2018) // // ----------------------------------------------------------------------- // #ifndef _MP3_H #define _MP3_H #include "mathematics.h" #include "mp3h.h" #define MAXMP3SIZE 0x4000000 // ~64 MB #define MAXMP3CHECK 0xFFFFF // ~1 MB namespace SAVFGAME { // MP3 converter returning codes (UNT8) enum eMP3ConvStatus : unsigned char { eMP3ConvStatus_Normal, // no errors, success convertion eMP3ConvStatus_NoInputPtr, // Input MP3 buffer is nullptr eMP3ConvStatus_NoInputSz, // Input MP3 buffer is null sized eMP3ConvStatus_MaxInput, // Input MP3 buffer is too big, check MAXMP3SIZE macro to know max. value eMP3ConvStatus_BufferEnd, // EXIT OUT : loop == false && no available data in input buffer eMP3ConvStatus_InputMod, // unsafe modification of input data at Continue() mode eMP3ConvStatus_NoRun, // run Continue() mode without Run() previously eMP3ConvStatus_DiffFrames, // unexpected different frames types (supported only MPEG-1 Layer-3) eMP3ConvStatus_HeaderFail, // incorrect frame header data eMP3ConvStatus_DiffFreq, // some of frames have different nSamplesPerSec, convertion aborted eMP3ConvStatus_StartPosErr, // invalid start position frame or time eMP3ConvStatus_AllocOutErr, // can't allocate out PCM buffer eMP3ConvStatus_HuffmanRead, // error while reading huffman data code : huffman table error eMP3ConvStatus_HuffmanEnd, // error while reading huffman data code : part23end error eMP3ConvStatus_EOF_ID3, // unexpected end of file while reading ID3 header eMP3ConvStatus_OutSamples, // unexpected <out.samples> < 0 (internal decoder error ?) }; // MP3 converter warning bit codes (UNT32) enum eMP3ConvWarning : unsigned int { eMP3ConvWarning_Normal = 0, // no warnings eMP3ConvWarning_OutMod = MASK_BIT_00, // data_out ptr has been modified by user eMP3ConvWarning_StartTime = MASK_BIT_01, // input <start_time> value is -negative (below 0) and has been fixed to +positive eMP3ConvWarning_Time = MASK_BIT_02, // input <time> value is -negative (below 0) and has been fixed to +positive eMP3ConvWarning_LamePadding = MASK_BIT_03, // LAME padding seems to be damaged }; //>> Управление конвертированием потока MPEG-1 Layer-3 (таблицы) class CMP3Converter_hint { protected: union UNION_C_SIN // sin table union { float f [MP3LINES * 2]; // f[36] = 4 + 32 / 4x8 SSE / 8x4 AVX / 16x2 AVX-512F / #ifdef ENGINE_SSE __m128 m128[9]; // 4 float x8 + last 4 float #endif #ifdef ENGINE_AVX __m256 m256[4]; // 8 float x4 (no last 4 float) #endif #ifdef ENGINE_AVX512F __m512 m512[2]; // 16 float x2 (no last 4 float) #endif }; protected: // Requantize static float pow43 [MP3MAXHUFF]; static float pow2A [(1 + 2 * (MP3MAXSCAL + MP3MAXPRET))]; static float pow2B [(1 + 256 * 8)]; // Process stereo static float ratio_l [7]; static float ratio_r [7]; static UNIONMAX uSqrt2inv; static UNION512 & uSqrt2inv512; static UNION256 & uSqrt2inv256; static UNION128 & uSqrt2inv128; // Antialias static UNION512 ucs2, uca2; static UNION256 & ucs, & uca; //static float cs [MP3ANTIALI]; //static float ca [MP3ANTIALI]; // Hybrid synthesis static UNION_C_SIN u_IMDCT_sin [eMPEGBlockT_ENUM_MAX]; static float * IMDCT_sin [eMPEGBlockT_ENUM_MAX]; // static float IMDCT_sin [eMPEGBlockT_ENUM_MAX][MP3LINES * 2]; // Hybrid synthesis (simple) static float IMDCT_cos1tab [(1 + 12 * 6)]; static float IMDCT_cos2tab [(1 + 36 * 18)]; // Hybrid synthesis (fast) static const float c_sqrt32; static const float c_cos9; static const float c_cos94; static const float c_cos92; static const float c_sin0; static const float c_sin1; static const float c_sin2; static const float c_sin3; static UNION128 c_sin; static UNION1024 u_form_18_36; static UNION512 u_form_9_18; static UNION256 u_form_6_12; static UNION128 u_form_6_12_3; static UNION128 u_form_4_9; static UNION128 u_form_3_6; static float * form_9_18; // form_9_18 [9]; static float * form_18_36; // form_18_36 [18]; static float * form_6_12; // form_6_12 [7]; static float * form_4_9; // form_4_9 [4]; static float * form_3_6; // form_3_6 [4]; // FreqInversion SSE/AVX/AVX-256F opt. static uint16 freqInvIdx[MP3FREQINV]; static UNIONMAX freqInvMinus; static UNION512 & freqInvMinus512; static UNION256 & freqInvMinus256; static UNION128 & freqInvMinus128; // Subband synthesis (simple) static float synthesis_tab [MP3SUBBANDS * 2][MP3SUBBANDS]; // Subband synthesis (fast) static UNION512 u_form_16_32; static UNION256 u_form_8_16; static UNION128 u_form_4_8; static float * form_16_32; // form_16_32 [16]; static float * form_8_16; // form_8_16 [8]; static float * form_4_8; // form_4_8 [4]; static float form_2_4 [2]; static float cosij [2][2]; static bool opt_SSE; static bool opt_SSE_only; static bool opt_AVX; static bool opt_AVX_only; static bool opt_AVX512F; static bool opt_AVX512F_only; static bool opt_AVX512F_combo; public: CMP3Converter_hint() { Init(); }; ~CMP3Converter_hint() {}; public: CMP3Converter_hint(const CMP3Converter_hint & src) = delete; CMP3Converter_hint(CMP3Converter_hint && src) = delete; CMP3Converter_hint& operator=(const CMP3Converter_hint & src) = delete; CMP3Converter_hint& operator=(CMP3Converter_hint && src) = delete; protected: static //>> Инициализация таблиц констант void Init(); }; //>> Управление конвертированием потока MPEG-1 Layer-3 class CMP3Converter : public CMP3Converter_hint { struct MP3Settings { // input data struct SoundSet { friend class CMP3Converter; void Reset() { data = nullptr; size = 0; start_time = 0; start_frame = 0; time = 0; use_frame = false; loop = false; maximize = false; // data_mem = nullptr; // size_mem = 0; } byte * data { nullptr }; // origin MP3 data to convert uint32 size { 0 }; // origin MP3 data size float start_time { 0 }; // start timepoit in seconds uint32 start_frame { 0 }; // start MP3 frame number (alt. start) float time { 0 }; // requested time in seconds (0 == all available time, loop setting will be ignored) bool use_frame { false }; // use <start_frame> instead of <start_time> : default = false bool loop { false }; // loop MP3 : default = false bool maximize { false }; // TRUE: ceil up out.time to next frame (FALSE: floor down) : default = false // // start_time out.time : maximize = 0 in.time out.time : maximize = 1 // ! ! ! ! // +---------------------------------------+---------------------------------------+ // frame0 frame1 -> ceil up -> frame2 private: byte * data_mem { nullptr }; // private hidden memorized <data> uint32 size_mem { 0 }; // private hidden memorized <size> }; // output data struct SoundInfo { friend class CMP3Converter; void Reset() { _data = nullptr; _size = 0; start_time = 0; start_frame = 0; time = 0; samples = 0; frames = 0; total_frames = 0; end_frame = 0; loop_end_frame = 0; _skipped = 0; _padding = 0; _padding_before = 0; _padding_after = 0; wFormatTag = 0; nSamplesPerSec = 0; nChannels = 0; wBitsPerSample = 0; fsz_time = 0; fsz_samples = 0; fsz_bytes = 0; // data_out = nullptr; size_out = 0; // size_out_mem = 0; // data_out_mem = nullptr; } void Printf() { printf("\nstart_time = %f" \ "\nstart_frame = %i" \ "\ntime = %f" \ "\nsamples = %i" \ "\nframes = %i" \ "\ntotal_frames = %i" \ "\nend_frame = %i" \ "\nloop_end_frame = %i" \ "\nskipped = %i" \ "\npadding = %i" \ "\npadding_before = %i" \ "\npadding_after = %i" \ "\nwFormatTag = %i" \ "\nnSamplesPerSec = %i" \ "\nnChannels = %i" \ "\nwBitsPerSample = %i" \ "\nfsz_time = %f" \ "\nfsz_samples = %i" \ "\nfsz_bytes = %i" \ , start_time, start_frame, time, samples, frames, total_frames, end_frame, loop_end_frame, _skipped, _padding, _padding_before, _padding_after, wFormatTag, nSamplesPerSec, nChannels, wBitsPerSample, fsz_time, fsz_samples, fsz_bytes ); } byte * _data { nullptr }; // [DEBUG] stop point ptr uint32 _size { 0 }; // [DEBUG] stop point available data byte * data_out { nullptr }; // target PCM buffer (RECOMMENDED TO NOT TOUCH, IT'S AUTO MANAGED BY DEFAULT) uint32 size_out { 0 }; // target PCM buffer size float start_time { 0 }; // start timepoit, in fact uint32 start_frame { 0 }; // start MP3 frame number, in fact float time { 0 }; // converted time (in seconds) uint32 samples { 0 }; // converted blocks of samples uint32 frames { 0 }; // converted frames uint32 total_frames { 0 }; // count of frames in input mp3 buffer uint32 end_frame { 0 }; // stop frame # number uint32 loop_end_frame { 0 }; // stop frame # number (loop-fixed) uint32 _skipped { 0 }; // [DEBUG] num of skipped frames uint32 _padding { 0 }; // [DEBUG] LAME num of dummy samples skipped uint32 _padding_before { 0 }; // [DEBUG] LAME num of dummy samples added by LAME encoder at start uint32 _padding_after { 0 }; // [DEBUG] LAME num of dummy samples added by LAME encoder at end uint32 wFormatTag { 0 }; // 1 = WAVE_FORMAT_PCM (int samples), 3 = WAVE_FORMAT_IEEE_FLOAT (float samples) uint32 nSamplesPerSec { 0 }; // samples per second uint16 nChannels { 0 }; // count of channels uint16 wBitsPerSample { 0 }; // bits per sample of mono data float fsz_time { 0 }; // size of 1 frame in seconds uint32 fsz_samples { 0 }; // size of 1 frame in samples (blocks) uint32 fsz_bytes { 0 }; // size of 1 frame in bytes private: uint32 size_out_mem { 0 }; // private hidden memorized <size_out> byte * data_out_mem { nullptr }; // private hidden memorized <data_out> :: for checking if user modified ptr // use in Continue() mode void Reset_continue() { start_time = 0; start_frame = 0; time = 0; samples = 0; frames = 0; _skipped = 0; } }; SoundSet in; // user -> converter SoundInfo out; // converter -> user }; public: MP3Settings settings; // conversion settings uint32 warning; // content bits of eMP3ConvWarning, you can check it after convertion private: MPEGHeader MPEG; // content MPEG main header MPEGHeaderSide MPEGS; // content MPEG side header MPEGMainData MPEGD; // content MPEG data MPEGHeader * MPEG_p { & MPEG }; // (const) ptr to MPEG main header MPEGHeaderSide * MPEGS_p { & MPEGS }; // (const) ptr to MPEG side header private: uint32 padding_b_frame { 0 }; // LAME : <padding_before> mem frame # uint32 padding_a_frame { 0 }; // LAME : <padding_after> mem frame # uint32 padding_b { 0 }; // LAME : <padding_before> current value uint32 padding_a { 0 }; // LAME : <padding_after> current value uint32 padding_before { 0 }; // LAME : samples padding before original .wav uint32 padding_after { 0 }; // LAME : samples padding after original .wav private: uint32 frame0_position { (uint32) MPG_ERROR }; // initial 0-frame MP3-buffer offset uint32 start_position { (uint32) MPG_ERROR }; // MP3-buffer starting offset uint32 start_frame { (uint32) MPG_ERROR }; // starting frame # uint32 total_frames { (uint32) MPG_ERROR }; // total frames in buffer uint32 stop_frame { (uint32) MPG_ERROR }; // counter STOP frame # uint32 continue_frame { (uint32) MPG_ERROR }; // pause position for Continue() mode float frame_time { (float) MPG_ERROR }; // how much time presented by 1 frame eMP3ConvStatus STATUS; // returning exit code private: //>> Бегунок в памяти struct Runner { byte * p; // [buffer] current ptr byte * end; // [buffer] end ptr uint32 pos; // [buffer] position from start uint32 last; // [buffer] count of bytes available up to end } runner; float storehs[2][MP3SUBBANDS][MP3LINES]; // HybridSynth IMDCT float storess[2][MP3SYNTHESIS * 2]; // SubbandSynth 2ch * 512x2 = 1024 = [16][64] byte storess_pos[2]; // 0..15 public: CMP3Converter(const CMP3Converter & src) = delete; CMP3Converter(CMP3Converter && src) = delete; CMP3Converter& operator=(const CMP3Converter & src) = delete; CMP3Converter& operator=(CMP3Converter && src) = delete; public: CMP3Converter() : CMP3Converter_hint() {}; ~CMP3Converter() { if (settings.out.data_out != nullptr) free(settings.out.data_out); }; private: //>> Производит сдвиг бегунка в указанное положение :: возвращает <false>, если достигли конца bool RunnerShift(uint32 position) { runner.p += (int32)(position - runner.pos); runner.pos = position; if (runner.p > runner.end) { runner.last = 0; return false; } else // runner.p <= runner.end { runner.last = (uint32) (runner.end - runner.p); return true; } } //>> Производит сдвиг бегунка относительно текущей точки :: возвращает <false>, если достигли конца bool RunnerOffset(int32 offset) { runner.p += offset; runner.pos += offset; if (runner.p > runner.end) { runner.last = 0; return false; } else // runner.p <= runner.end { runner.last = (uint32)(runner.end - runner.p); return true; } } private: //>> 1.1. Приведение семпла к исходному виду (возврат съэкономленных бит) void ConvertMP3_Requantize(byte gr, byte ch) { float * mpeg_samples = MPEGD.sample[gr][ch]; uint32 pow2A_ss = MPEGS.scalefac_scale[gr][ch] ? 2 : 1; uint32 pow2B_gg = MPEGS.global_gain[gr][ch]; auto pow2A_sfl = MPEGD.scalefac_l[gr][ch]; auto pow2A_sfs = MPEGD.scalefac_s[gr][ch]; auto pow2B_sbg = MPEGS.subblock_gain[gr][ch]; bool preflag = MPEGS.preflag[gr][ch]; auto RequantizeLong = [this, mpeg_samples](byte gr, byte ch, uint16 sample_id, uint16 sfb) -> void { // x1 - get scale mul component == 2^A, A = -scale * (scalefac_l + pretab) // x2 - get scale from gain == 2^B, B = 1/4 * (global_gain - 210) // restore sample from pow ^(3/4) // //float scale = MPEGS.scalefac_scale[gr][ch] ? 1.f : 0.5f; //byte pref = MPEGS.preflag[gr][ch] ? scalefac_pretab[sfb] : 0; //float x1 = pow(2.f, -(scale * ((int32)MPEGD.scalefac_l[gr][ch][sfb] + pref))); //float x2 = pow(2.f, 0.25f * ((int32)MPEGS.global_gain[gr][ch] - 210)); float x1 = pow2A[ (MPEGS.scalefac_scale[gr][ch] ? 2ul : 1ul) * ( MPEGD.scalefac_l[gr][ch][sfb] + (MPEGS.preflag[gr][ch] ? scalefac_pretab[sfb] : 0) )]; float x2 = pow2B[ (uint32)MPEGS.global_gain[gr][ch] ]; float & sample = mpeg_samples[sample_id]; if (sample < 0) sample = -pow43[(uint16)-sample]; //-pow(-sample, sample_power); else sample = pow43[(uint16) sample]; // pow( sample, sample_power); sample *= x1 * x2; }; auto RequantizeShort = [this, mpeg_samples](byte gr, byte ch, uint16 sample_id, uint16 sfb, byte window) -> void { // x1 - get scale mul component == 2^A, A = -scale * scalefac_s // x2 - get scale from gain == 2^B, B = 1/4 * (global_gain - 210 - 8 * sub_gain) // restore sample from pow ^(3/4) // //float scale = MPEGS.scalefac_scale[gr][ch] ? 1.f : 0.5f; //float x1 = pow(2.f, -(scale * (uint32)MPEGD.scalefac_s[gr][ch][sfb][window])); //float x2 = pow(2.f, 0.25f * ((int32)MPEGS.global_gain[gr][ch] - 210 - 8 * MPEGS.subblock_gain[gr][ch][window])); float x1 = pow2A[ (MPEGS.scalefac_scale[gr][ch] ? 2ul : 1ul) * MPEGD.scalefac_s[gr][ch][sfb][window] ]; float x2 = pow2B[ (uint32)MPEGS.global_gain[gr][ch] + 256ul * MPEGS.subblock_gain[gr][ch][window] ]; float & sample = mpeg_samples[sample_id]; if (sample < 0) sample = -pow43[(uint16)-sample]; //-pow(-sample, sample_power); else sample = pow43[(uint16) sample]; // pow( sample, sample_power); sample *= x1 * x2; }; #pragma region <RequantizeOptCombo> #define _RequantizeOptCombo(sample_id, x1_x2) { \ float & sample = mpeg_samples[sample_id]; \ if (sample < 0) \ sample = -pow43[(uint16)-sample] * x1_x2; \ else sample = pow43[(uint16) sample] * x1_x2; \ } #pragma endregion #pragma region <RequantizeOpt> #define _RequantizeOpt(sample_id, x1, x2) { \ float & sample = mpeg_samples[sample_id]; \ if (sample < 0) \ sample = -pow43[(uint16)-sample] * x1 * x2; \ else sample = pow43[(uint16) sample] * x1 * x2; \ } #pragma endregion #pragma region <RequantizeLong> #define _RequantizeLong(sample_id, sfb) { \ float x1 = pow2A [ pow2A_ss * (pow2A_sfl[sfb] + \ (preflag ? scalefac_pretab[sfb] : 0)) ]; \ float x2 = pow2B [ pow2B_gg ]; \ \ _RequantizeOpt(sample_id, x1, x2) \ } #pragma endregion #pragma region <RequantizeShort> #define _RequantizeShort(sample_id, sfb, window) { \ float x1 = pow2A [ pow2A_ss * pow2A_sfs[sfb][window] ]; \ float x2 = pow2B [ pow2B_gg + 256ul * pow2B_sbg[window] ]; \ \ _RequantizeOpt(sample_id, x1, x2) \ } #pragma endregion uint16 win_len; uint16 next; // id of frame of next sfb uint16 sfb = 0; // scalefactor band index auto sfb_ind_l = sfb_indice[MPEG.freq].l; auto sfb_ind_s = sfb_indice[MPEG.freq].s; auto rzero = MPEGS.count1[gr][ch]; #ifdef _SSE_opt_is_too_bad_here_so_use_simple_code_ #pragma region <RequantizeOpt_SSE> #define _RequantizeOpt_SSE(sample_id, u1_u2) { \ UNION128 a, b; \ float f1 = mpeg_samples[sample_id]; \ float f2 = mpeg_samples[sample_id + 1]; \ float f3 = mpeg_samples[sample_id + 2]; \ float f4 = mpeg_samples[sample_id + 3]; \ \ if (f1 < 0) f1 = -pow43[(uint16)-f1]; \ else f1 = pow43[(uint16) f1]; \ if (f2 < 0) f2 = -pow43[(uint16)-f2]; \ else f2 = pow43[(uint16) f2]; \ if (f3 < 0) f3 = -pow43[(uint16)-f3]; \ else f3 = pow43[(uint16) f3]; \ if (f4 < 0) f4 = -pow43[(uint16)-f4]; \ else f4 = pow43[(uint16) f4]; \ \ a.m128 = _mm_set_ps(f4, f3, f2, f1); \ b.m128 = _mm_mul_ps(a.m128, u1_u2.m128); \ _mm_storeu_ps(mpeg_samples + sample_id, b.m128); \ } #pragma endregion if (opt_SSE_only) // SSE CODE = ??%..??% time { uint16 win_len_SSE; uint16 next_SSE, next_SSE_chunk; if (MPEGS.switch_flag[gr][ch] && MPEGS.block_type[gr][ch] == eMPEGBlockT_3ShortWindow) { uint16 i = 0; // Check for long blocks // if (MPEGS.mixed_block_flag[gr][ch]) // MIXED BLOCK L+S { UNION128 x1, x2, x1_x2; // mul constants x2.m128 = _mm_load_ps1(pow2B + pow2B_gg); x1.m128 = _mm_load_ps1(pow2A + pow2A_ss * (pow2A_sfl[sfb] + (preflag ? scalefac_pretab[sfb] : 0)) ); x1_x2.m128 = _mm_mul_ps(x1.m128, x2.m128); uint16 i_max = sfb_ind_l[MP3SFB_ML]; // i_max = 36 = sfb_ind_l[MP3SFB_ML], MP3SFB_ML = 8 next = sfb_ind_l[sfb + 1]; next_SSE = next; next_SSE >>= 2; // next_SSE / _128bit_ next_SSE <<= 2; // next_SSE * _128bit_ for (; i < i_max ;) { if (i == next) { next = sfb_ind_l[++sfb + 1]; next_SSE = next - i; next_SSE = next_SSE >> 2; next_SSE = (next_SSE << 2) + i; x1.m128 = _mm_load_ps1(pow2A + pow2A_ss * (pow2A_sfl[sfb] + (preflag ? scalefac_pretab[sfb] : 0)) ); x1_x2.m128 = _mm_mul_ps(x1.m128, x2.m128); } for (; i < next_SSE; i += 4) _RequantizeOpt_SSE(i, x1_x2); for (; i < next; i++) _RequantizeOptCombo(i, x1_x2.f[0]); } sfb = MP3SFB_MS; } // Short blocks // // sfb = 0 ? 3 next = sfb_ind_s[sfb + 1] * MP3SFB_SWIN; win_len = sfb_ind_s[sfb + 1] - sfb_ind_s[sfb]; win_len_SSE = win_len; win_len_SSE >>= 2; win_len_SSE <<= 2; UNION128 x1; // x1 for short blocks UNION128 x2[MP3SFB_SWIN]; // x2 for short blocks UNION128 x1_x2[MP3SFB_SWIN]; // x1_x2 for short blocks for (int win = 0; win < MP3SFB_SWIN; win++) { x2[win].m128 = _mm_load_ps1( pow2B + pow2B_gg + 256ul * pow2B_sbg[win] ); x1.m128 = _mm_load_ps1( pow2A + pow2A_ss * pow2A_sfs[sfb][win] ); x1_x2[win].m128 = _mm_mul_ps(x1.m128, x2[win].m128); } //i_max = rzero; // i = 0 ? 36 for (; i < rzero ;) // i < i_max { if (i == next) { next = sfb_ind_s[++sfb + 1] * MP3SFB_SWIN; win_len = sfb_ind_s[sfb + 1] - sfb_ind_s[sfb]; win_len_SSE = win_len; win_len_SSE >>= 2; win_len_SSE <<= 2; if (sfb < MP3SFB_S) for (int win = 0; win < MP3SFB_SWIN; win++) { x1.m128 = _mm_load_ps1(pow2A + pow2A_ss * pow2A_sfs[sfb][win]); x1_x2[win].m128 = _mm_mul_ps(x1.m128, x2[win].m128); } } // if (sfb >= MP3SFB_S) // { // for (byte win = 0; win < MP3SFB_SWIN; win++) // for (uint16 n = 0; n < win_len; n++) // mpeg_samples[i++] = 0; // } // else // { for (byte win = 0; win < MP3SFB_SWIN; win++) { UNION128 & _x1_x2 = x1_x2[win]; next_SSE = i + win_len_SSE; // i value for full SSE steps next_SSE_chunk = i + win_len; // i value for normal ending steps for (; i < next_SSE; i += 4) _RequantizeOpt_SSE(i, _x1_x2); for (; i < next_SSE_chunk; i++) _RequantizeOptCombo(i, _x1_x2.f[0]); } // } } } else // Long blocks only // { UNION128 x1, x2, x1_x2; // mul constants x2.m128 = _mm_load_ps1(pow2B + pow2B_gg); x1.m128 = _mm_load_ps1(pow2A + pow2A_ss * (pow2A_sfl[sfb] + (preflag ? scalefac_pretab[sfb] : 0)) ); x1_x2.m128 = _mm_mul_ps(x1.m128, x2.m128); next = sfb_ind_l[sfb + 1]; next_SSE = next; next_SSE >>= 2; // next_SSE / _128bit_ next_SSE <<= 2; // next_SSE * _128bit_ for (uint16 i = 0; i < rzero;) { if (i == next) { next = sfb_ind_l[++sfb + 1]; next_SSE = next - i; next_SSE = next_SSE >> 2; next_SSE = (next_SSE << 2) + i; if (sfb < MP3SFB_L) { x1.m128 = _mm_load_ps1(pow2A + pow2A_ss * (pow2A_sfl[sfb] + (preflag ? scalefac_pretab[sfb] : 0)) ); x1_x2.m128 = _mm_mul_ps(x1.m128, x2.m128); } } // if (sfb >= MP3SFB_L) // mpeg_samples[i++] = 0; // else // { for (; i < next_SSE; i += 4) _RequantizeOpt_SSE(i, x1_x2); for (; i < next; i++) _RequantizeOptCombo(i, x1_x2.f[0]); // } } } #undef _RequantizeOpt_SSE } else #endif // SIMPLE CODE = 100% time { if (MPEGS.switch_flag[gr][ch] && MPEGS.block_type[gr][ch] == eMPEGBlockT_3ShortWindow) { uint16 i = 0; // Check for long blocks // if (MPEGS.mixed_block_flag[gr][ch]) // MIXED BLOCK L+S { float x2 = pow2B[pow2B_gg]; float x1 = x2 * pow2A[pow2A_ss * (pow2A_sfl[sfb] + (preflag ? scalefac_pretab[sfb] : 0))]; uint16 i_max = sfb_ind_l[MP3SFB_ML]; // i_max = 36 = sfb_ind_l[MP3SFB_ML], MP3SFB_ML = 8 next = sfb_ind_l[sfb + 1]; for (; i < i_max ;) { if (i == next) { next = sfb_ind_l[++sfb + 1]; x1 = x2 * pow2A[pow2A_ss * (pow2A_sfl[sfb] + (preflag ? scalefac_pretab[sfb] : 0))]; } //_RequantizeLong(i++, sfb); _RequantizeOptCombo(i++, x1); } sfb = MP3SFB_MS; } // Short blocks // // sfb = 0 ? 3 next = sfb_ind_s[sfb + 1] * MP3SFB_SWIN; win_len = sfb_ind_s[sfb + 1] - sfb_ind_s[sfb]; float x1[MP3SFB_SWIN]; // x1 for short blocks float x2[MP3SFB_SWIN]; // x2 for short blocks for (int win = 0; win < MP3SFB_SWIN; win++) { x2[win] = pow2B [ pow2B_gg + 256ul * pow2B_sbg[win] ]; x1[win] = pow2A [ pow2A_ss * pow2A_sfs[sfb][win] ] * x2[win]; } //i_max = rzero; // i = 0 ? 36 for (; i < rzero ;) // i < i_max { if (i == next) { next = sfb_ind_s[++sfb + 1] * MP3SFB_SWIN; win_len = sfb_ind_s[sfb + 1] - sfb_ind_s[sfb]; if (sfb < MP3SFB_S) for (int win = 0; win < MP3SFB_SWIN; win++) x1[win] = pow2A[ pow2A_ss * pow2A_sfs[sfb][win] ] * x2[win]; } // if (sfb >= MP3SFB_S) // { // for (byte win = 0; win < MP3SFB_SWIN; win++) // for (uint16 n = 0; n < win_len; n++) // mpeg_samples[i++] = 0; // } // else // { for (byte win = 0; win < MP3SFB_SWIN; win++) { float _x1 = x1[win]; for (uint16 n = 0; n < win_len; n++) //_RequantizeShort(i++, sfb, win); _RequantizeOptCombo(i++, _x1); } // } } } else // Long blocks only // { float x2 = pow2B[pow2B_gg]; float x1 = x2 * pow2A[pow2A_ss * (pow2A_sfl[sfb] + (preflag ? scalefac_pretab[sfb] : 0))]; next = sfb_ind_l[sfb + 1]; for (uint16 i = 0; i < rzero; ) { if (i == next) { next = sfb_ind_l[++sfb + 1]; if (sfb < MP3SFB_L) x1 = x2 * pow2A[pow2A_ss * (pow2A_sfl[sfb] + (preflag ? scalefac_pretab[sfb] : 0))]; } // if (sfb >= MP3SFB_L) // mpeg_samples[i++] = 0; // else //_RequantizeLong(i++, sfb); _RequantizeOptCombo(i++, x1); } } } #undef _RequantizeLong #undef _RequantizeShort #undef _RequantizeOpt #undef _RequantizeOptCombo } //>> 1.2. Восстановление порядка следования коротких блоков void ConvertMP3_Reorder(byte gr, byte ch) { if (MPEGS.switch_flag[gr][ch] && MPEGS.block_type[gr][ch] == eMPEGBlockT_3ShortWindow) { // Short blocks // uint16 win_len; uint16 next; // id of frame of next sfb uint16 sfb = 0; // scalefactor band index auto sfb_ind_l = sfb_indice[MPEG.freq].l; auto sfb_ind_s = sfb_indice[MPEG.freq].s; auto rzero = MPEGS.count1[gr][ch]; float sample[MP3GRS]; // temp float * sample_o = MPEGD.sample[gr][ch]; // original location // Check for long blocks // if (MPEGS.mixed_block_flag[gr][ch]) // MIXED BLOCK L+S : do nothing with long blocks sfb = MP3SFB_MS; next = sfb_ind_s[sfb + 1] * MP3SFB_SWIN; win_len = sfb_ind_s[sfb + 1] - sfb_ind_s[sfb]; // i = 0 ? 36 for (uint16 i = (sfb) ? sfb_ind_l[MP3SFB_ML] : 0; i < MP3GRS;) { if (i == next) { // save results uint16 line = MP3SFB_SWIN * sfb_ind_s[sfb]; uint16 n_max = win_len * MP3SFB_SWIN; //for (uint16 n = 0; n < n_max; n++) // sample_o[line + n] = sample[n]; memcpy(sample_o + line, sample, (n_max << 2)); // n_max * sizeof(float) if (i >= rzero) return; sfb++; next = sfb_ind_s[sfb + 1] * MP3SFB_SWIN; win_len = sfb_ind_s[sfb + 1] - sfb_ind_s[sfb]; } for (byte win = 0; win < MP3SFB_SWIN; win++) for (uint16 n = 0; n < win_len; n++) sample[n * MP3SFB_SWIN + win] = sample_o[i++]; } // save results - copy last sfb uint16 line = MP3SFB_SWIN * sfb_ind_s[MP3SFB_S]; uint16 n_max = win_len * MP3SFB_SWIN; //for (uint16 n = 0; n < n_max; n++) // sample_o[line + n] = sample[n]; memcpy(sample_o + line, sample, (n_max << 2)); // n_max * sizeof(float) } } //>> 2. Этап декодирования для Joint Stereo void ConvertMP3_ProcessStereo(byte gr) { auto sfb_ind_l = sfb_indice[MPEG.freq].l; auto sfb_ind_s = sfb_indice[MPEG.freq].s; auto sample = MPEGD.sample[gr]; // [ch][576] auto ProcessStereoLong = [this, &sfb_ind_l](byte gr, byte sfb) -> void { uint32 i_sample = MPEGD.scalefac_l[gr][0][sfb] % 8; // 4 bits : 0..15 // no intensity stereo if (i_sample != MP3STEREOR) { for (uint32 i = sfb_ind_l[sfb], i_max = sfb_ind_l[sfb + 1]; i < i_max; i++) { float left = ratio_l[i_sample] * MPEGD.sample[gr][0][i]; float right = ratio_r[i_sample] * MPEGD.sample[gr][0][i]; MPEGD.sample[gr][0][i] = left; MPEGD.sample[gr][1][i] = right; } } }; auto ProcessStereoShort = [this, &sfb_ind_s](byte gr, byte sfb) -> void { uint16 win_len = sfb_ind_s[sfb + 1] - sfb_ind_s[sfb]; for (byte win = 0; win < MP3SFB_SWIN; win++) { uint16 i_sample = MPEGD.scalefac_s[gr][0][sfb][win] % 8; // 4 bits : 0..15 // no intensity stereo if (i_sample != MP3STEREOR) { for (uint32 i = sfb_ind_s[sfb] * MP3SFB_SWIN + win_len * win, i_end = i + win_len; i < i_end; i++) { float left = ratio_l[i_sample] * MPEGD.sample[gr][0][i]; float right = ratio_r[i_sample] * MPEGD.sample[gr][0][i]; MPEGD.sample[gr][0][i] = left; MPEGD.sample[gr][1][i] = right; } } } }; #pragma region <ProcessStereoLong> #define _ProcessStereoLong(gr, sfb) { \ uint32 i_sample = MPEGD.scalefac_l[gr][0][sfb] % 8; \ \ if (i_sample != MP3STEREOR) \ { \ for (uint32 i = sfb_ind_l[sfb], \ i_max = sfb_ind_l[sfb + 1]; \ i < i_max; i++) \ { \ sample[1][i] = ratio_r[i_sample] * sample[0][i]; \ sample[0][i] *= ratio_l[i_sample]; \ } \ } \ } #pragma endregion #pragma region <ProcessStereoShort> #define _ProcessStereoShort(gr, sfb) { \ uint16 win_len = sfb_ind_s[sfb + 1] - \ sfb_ind_s[sfb]; \ \ for (byte win = 0; win < MP3SFB_SWIN; win++) \ { \ uint16 i_sample = MPEGD.scalefac_s[gr][0][sfb][win] % 8; \ \ if (i_sample != MP3STEREOR) \ { \ for (uint32 i = sfb_ind_s[sfb] * MP3SFB_SWIN + win_len * win, \ i_end = i + win_len; \ i < i_end; i++) \ { \ sample[1][i] = ratio_r[i_sample] * sample[0][i]; \ sample[0][i] *= ratio_l[i_sample]; \ } \ } \ } \ } #pragma endregion if ((MPEG.ch != eMPEGChJointStereo) || // not joint stereo (MPEG.layer != eMPEGLayer3)) // not layer 3 return; // M/S stereo OFF, Intensity stereo OFF if (MPEG.chj == eMPEGChJBands4) return; uint16 rzero_1 = MPEGS.count1[gr][1]; // M/S stereo ON if (MPEG.chj == eMPEGChJBands12 || MPEG.chj == eMPEGChJBands16) { uint16 rzero_0 = MPEGS.count1[gr][0]; uint16 rzero = (rzero_0 > rzero_1) ? rzero_0 : rzero_1; float * sample_0 = sample[0]; // ch 0 float * sample_1 = sample[1]; // ch 1 #ifdef ENGINE_AVX512F if (opt_AVX512F_only) // AVX512F CODE = ??%..??% time _ NOT TESTED { #pragma message ("ConvertMP3_ProcessStereo : 512-bit AVX512F code not tested") uint16 i = 0; uint16 steps; steps = rzero >> 4; // (rzero / 16) * 16 _512bit AVX-512F steps = steps << 4; // . for (; i < steps; i += 16) { UNION512 a, b, c, r; a.m512 = _mm512_loadu_ps(sample_0 + i); b.m512 = _mm512_loadu_ps(sample_1 + i); c.m512 = _mm512_add_ps(a.m512, b.m512); r.m512 = _mm512_mul_ps(c.m512, uSqrt2inv512.m512); _mm512_storeu_ps(sample_0 + i, r.m512); c.m512 = _mm512_sub_ps(a.m512, b.m512); r.m512 = _mm512_mul_ps(c.m512, uSqrt2inv512.m512); _mm512_storeu_ps(sample_1 + i, r.m512); } steps = rzero >> 3; // (rzero / 8) * 8 _256bit AVX steps = steps << 3; // . for (; i < steps; i += 8) { UNION256 a, b, c, r; a.m256 = _mm256_loadu_ps(sample_0 + i); b.m256 = _mm256_loadu_ps(sample_1 + i); c.m256 = _mm256_add_ps(a.m256, b.m256); r.m256 = _mm256_mul_ps(c.m256, uSqrt2inv256.m256); _mm256_storeu_ps(sample_0 + i, r.m256); c.m256 = _mm256_sub_ps(a.m256, b.m256); r.m256 = _mm256_mul_ps(c.m256, uSqrt2inv256.m256); _mm256_storeu_ps(sample_1 + i, r.m256); } steps = rzero >> 2; // (rzero / 4) * 4 _128bit SSE steps = steps << 2; // . for (; i < steps; i += 4) { UNION128 a, b, c, r; a.m128 = _mm_loadu_ps(sample_0 + i); b.m128 = _mm_loadu_ps(sample_1 + i); c.m128 = _mm_add_ps(a.m128, b.m128); r.m128 = _mm_mul_ps(c.m128, uSqrt2inv128.m128); _mm_storeu_ps(sample_0 + i, r.m128); c.m128 = _mm_sub_ps(a.m128, b.m128); r.m128 = _mm_mul_ps(c.m128, uSqrt2inv128.m128); _mm_storeu_ps(sample_1 + i, r.m128); } for (; i < rzero; i++) { float left = (sample_0[i] + sample_1[i]) * MathSqrt2inv; float right = (sample_0[i] - sample_1[i]) * MathSqrt2inv; sample_0[i] = left; sample_1[i] = right; } } else #endif #ifdef ENGINE_AVX if (opt_AVX_only) // AVX CODE = ??%..??% time _ NOT TESTED { #pragma message ("ConvertMP3_ProcessStereo : 256-bit AVX code not tested") uint16 i = 0; uint16 steps; steps = rzero >> 3; // (rzero / 8) * 8 _256bit AVX steps = steps << 3; // . for (; i < steps; i += 8) { UNION256 a, b, c, r; a.m256 = _mm256_loadu_ps(sample_0 + i); b.m256 = _mm256_loadu_ps(sample_1 + i); c.m256 = _mm256_add_ps(a.m256, b.m256); r.m256 = _mm256_mul_ps(c.m256, uSqrt2inv256.m256); _mm256_storeu_ps(sample_0 + i, r.m256); c.m256 = _mm256_sub_ps(a.m256, b.m256); r.m256 = _mm256_mul_ps(c.m256, uSqrt2inv256.m256); _mm256_storeu_ps(sample_1 + i, r.m256); } steps = rzero >> 2; // (rzero / 4) * 4 _128bit SSE steps = steps << 2; // . for (; i < steps; i += 4) { UNION128 a, b, c, r; a.m128 = _mm_loadu_ps(sample_0 + i); b.m128 = _mm_loadu_ps(sample_1 + i); c.m128 = _mm_add_ps(a.m128, b.m128); r.m128 = _mm_mul_ps(c.m128, uSqrt2inv128.m128); _mm_storeu_ps(sample_0 + i, r.m128); c.m128 = _mm_sub_ps(a.m128, b.m128); r.m128 = _mm_mul_ps(c.m128, uSqrt2inv128.m128); _mm_storeu_ps(sample_1 + i, r.m128); } for (; i < rzero; i++) { float left = (sample_0[i] + sample_1[i]) * MathSqrt2inv; float right = (sample_0[i] - sample_1[i]) * MathSqrt2inv; sample_0[i] = left; sample_1[i] = right; } } else #endif #ifdef ENGINE_SSE if (opt_SSE) // SSE CODE = 75%..80% time { uint16 i = 0; uint16 steps; steps = rzero >> 2; // (rzero / 4) * 4 _128bit SSE steps = steps << 2; // . for (; i < steps; i += 4) { UNION128 a, b, c, r; a.m128 = _mm_loadu_ps(sample_0 + i); b.m128 = _mm_loadu_ps(sample_1 + i); c.m128 = _mm_add_ps(a.m128, b.m128); r.m128 = _mm_mul_ps(c.m128, uSqrt2inv128.m128); _mm_storeu_ps(sample_0 + i, r.m128); c.m128 = _mm_sub_ps(a.m128, b.m128); r.m128 = _mm_mul_ps(c.m128, uSqrt2inv128.m128); _mm_storeu_ps(sample_1 + i, r.m128); } for (; i < rzero; i++) { float left = (sample_0[i] + sample_1[i]) * MathSqrt2inv; float right = (sample_0[i] - sample_1[i]) * MathSqrt2inv; sample_0[i] = left; sample_1[i] = right; } } else #endif // SIMPLE CODE = 100% time { for (uint16 i = 0; i < rzero; i++) { float left = (sample_0[i] + sample_1[i]) * MathSqrt2inv; float right = (sample_0[i] - sample_1[i]) * MathSqrt2inv; sample_0[i] = left; sample_1[i] = right; } } } // ! NOT TESTED ! (нужен рабочий семпл с intensity stereo) // Intensity stereo ON else //if (MPEG.chj == eMPEGChJBands8) { if (MPEGS.switch_flag[gr][0] && MPEGS.block_type[gr][0] == eMPEGBlockT_3ShortWindow) { if (MPEGS.mixed_block_flag[gr][0]) // MIXED BLOCK L+S { for (byte sfb = 0; sfb < MP3SFB_ML; sfb++) if (sfb_ind_l[sfb] >= rzero_1) _ProcessStereoLong(gr, sfb); for (byte sfb = MP3SFB_MS; sfb < MP3SFB_S; sfb++) if (sfb_ind_s[sfb] * MP3SFB_SWIN >= rzero_1) _ProcessStereoShort(gr, sfb); } else // Short blocks only // { for (byte sfb = 0; sfb < MP3SFB_S; sfb++) if (sfb_ind_s[sfb] * MP3SFB_SWIN >= rzero_1) _ProcessStereoShort(gr, sfb); } } else { // Long blocks // for (byte sfb = 0; sfb < MP3SFB_L; sfb++) if (sfb_ind_l[sfb] >= rzero_1) _ProcessStereoLong(gr, sfb); } } #undef _ProcessStereoLong #undef _ProcessStereoShort } //>> 3.1. Сглаживание длинных блоков void ConvertMP3_Antialias(byte gr, byte ch) { uint16 subband_max = MP3SUBBANDS; // 32 if L long blocks if (MPEGS.switch_flag[gr][ch] && MPEGS.block_type[gr][ch] == eMPEGBlockT_3ShortWindow) { if (!MPEGS.mixed_block_flag[gr][ch]) return; // skip only S short blocks else subband_max = 2; // L+S (mixed block) } float * sample = MPEGD.sample[gr][ch]; #ifdef ENGINE_AVX512F if (opt_AVX512F_combo) // AVX512F CODE = ??%..??% time _ NOT TESTED { #pragma message ("ConvertMP3_Antialias : 512-bit AVX512F code not tested") // subband_max == 2 ---> i_max = (2 - 1) * 8 = 8 --------------------------> 1 step AVX // subband_max == 32 ---> i_max = (32 - 1) * 8 = 248 = 8 + 240 = 8 + 16x15 --> 1 step AVX + 15 steps AVX-256F uint16 i = 0; if (subband_max == MP3SUBBANDS) // make 15 steps AVX-256F { UNION512 sample_li, left; UNION512 sample_ui, right; UNION512 result; const uint16 i_max = (subband_max - 2) << 3; // "- 2" cause of 1 subband is 1 step AVX at the end for (; i < i_max; i += 16) { // (sample + s2 - 8) (sample + s2) (sample + s2 + 8) // (sample + s1 - 8) (sample + s1) (sample + s1 + 8) // + ........<--...... + ........-->...... + ........<--...... + .......-->....... + // | -8..-1 region 1 0..7 | -8..-1 region 2 0..7 | uint16 s1 = MP3LINES * (1 + (i >> 3)); // MP3LINES * subband:(1..subband_max) uint16 s2 = s1 + 16; float * _sample1 = sample + s1 - 8; float * _sample2 = sample + s2 - 8; // sample_li.m256[0] = _mm256_loadu_ps(sample + s1 - 8); // -8..-1 (wrong) region 1 // sample_li.m256[1] = _mm256_loadu_ps(sample + s2 - 8); // -8..-1 (wrong) region 2 sample_ui.m256[0] = _mm256_loadu_ps(sample + s1); // 0..7 region 1 sample_ui.m256[1] = _mm256_loadu_ps(sample + s2); // 0..7 region 2 sample_li.m256[0] = _mm256_set_ps ( // -1..-8 region 1 _sample1[0], _sample1[1], _sample1[2], _sample1[3], _sample1[4], _sample1[5], _sample1[6], _sample1[7] ); sample_li.m256[1] = _mm256_set_ps ( // -1..-8 region 2 _sample2[0], _sample2[1], _sample2[2], _sample2[3], _sample2[4], _sample2[5], _sample2[6], _sample2[7] ); left.m512 = _mm512_mul_ps(sample_li.m512, ucs2.m512); right.m512 = _mm512_mul_ps(sample_ui.m512, uca2.m512); result.m512 = _mm512_sub_ps(left.m512, right.m512); _sample1[0] = result.m256[0].f[7]; _sample2[0] = result.m256[1].f[7]; _sample1[1] = result.m256[0].f[6]; _sample2[1] = result.m256[1].f[6]; _sample1[2] = result.m256[0].f[5]; _sample2[2] = result.m256[1].f[5]; _sample1[3] = result.m256[0].f[4]; _sample2[3] = result.m256[1].f[4]; _sample1[4] = result.m256[0].f[3]; _sample2[4] = result.m256[1].f[3]; _sample1[5] = result.m256[0].f[2]; _sample2[5] = result.m256[1].f[2]; _sample1[6] = result.m256[0].f[1]; _sample2[6] = result.m256[1].f[1]; _sample1[7] = result.m256[0].f[0]; _sample2[7] = result.m256[1].f[0]; left.m512 = _mm512_mul_ps(sample_ui.m512, ucs2.m512); right.m512 = _mm512_mul_ps(sample_li.m512, uca2.m512); result.m512 = _mm512_add_ps(left.m512, right.m512); _mm256_storeu_ps(sample + s1, result.m256[0]); _mm256_storeu_ps(sample + s2, result.m256[1]); } } // make 1 step AVX UNION256 sample_li, left; UNION256 sample_ui, right; UNION256 result; const uint16 i_max = (subband_max - 1) << 3; for (; i < i_max; i += 8) { // (sample + s - 8) (sample + s) (sample + s + 8) == (sample + next_s - 8) // + .......<--....... + .......-->....... + uint16 s = MP3LINES * (1 + (i >> 3)); // MP3LINES * subband:(1..subband_max) float * _sample = sample + s - 8; // // sample_li.m256 = _mm256_loadu_ps(sample + s - 8); // -8..-1 (wrong) sample_ui.m256 = _mm256_loadu_ps(sample + s); // 0..7 sample_li.m256 = _mm256_set_ps ( // -1..-8 _sample[0], _sample[1], _sample[2], _sample[3], _sample[4], _sample[5], _sample[6], _sample[7] ); left.m256 = _mm256_mul_ps(sample_li.m256, ucs.m256); right.m256 = _mm256_mul_ps(sample_ui.m256, uca.m256); result.m256 = _mm256_sub_ps(left.m256, right.m256); _sample[0] = result.f[7]; _sample[1] = result.f[6]; _sample[2] = result.f[5]; _sample[3] = result.f[4]; _sample[4] = result.f[3]; _sample[5] = result.f[2]; _sample[6] = result.f[1]; _sample[7] = result.f[0]; left.m256 = _mm256_mul_ps(sample_ui.m256, ucs.m256); right.m256 = _mm256_mul_ps(sample_li.m256, uca.m256); result.m256 = _mm256_add_ps(left.m256, right.m256); _mm256_storeu_ps(sample + s, result.m256); } } else #endif #ifdef ENGINE_AVX if (opt_AVX) // AVX CODE = ??%..??% time _ NOT TESTED { #pragma message ("ConvertMP3_Antialias : 256-bit AVX code not tested") UNION256 sample_li, left; UNION256 sample_ui, right; UNION256 result; const uint16 i_max = (subband_max - 1) << 3; // * MP3ANTIALI; // кратно 8 (длина шага 1-ого subband) for (uint16 i = 0; i < i_max; i += 8) { // (sample + s - 8) (sample + s) (sample + s + 8) == (sample + next_s - 8) // + ................. + ................. + uint16 s = MP3LINES * (1 + (i >> 3)); // MP3LINES * subband:(1..subband_max) float * _sample = sample + s - 8; // // sample_li.m256 = _mm256_loadu_ps(sample + s - 8); // -8..-1 (wrong) sample_ui.m256 = _mm256_loadu_ps(sample + s); // 0..7 sample_li.m256 = _mm256_set_ps ( // -1..-8 _sample[0], _sample[1], _sample[2], _sample[3], _sample[4], _sample[5], _sample[6], _sample[7] ); left.m256 = _mm256_mul_ps(sample_li.m256, ucs.m256); right.m256 = _mm256_mul_ps(sample_ui.m256, uca.m256); result.m256 = _mm256_sub_ps(left.m256, right.m256); _sample[0] = result.f[7]; _sample[1] = result.f[6]; _sample[2] = result.f[5]; _sample[3] = result.f[4]; _sample[4] = result.f[3]; _sample[5] = result.f[2]; _sample[6] = result.f[1]; _sample[7] = result.f[0]; left.m256 = _mm256_mul_ps(sample_ui.m256, ucs.m256); right.m256 = _mm256_mul_ps(sample_li.m256, uca.m256); result.m256 = _mm256_add_ps(left.m256, right.m256); _mm256_storeu_ps(sample + s, result.m256); } } else #endif #ifdef ENGINE_SSE if (opt_SSE) // SSE CODE = 70%..80% time { UNION128 sample_li, left; UNION128 sample_ui, right; UNION128 result; const uint16 i_max = (subband_max - 1) << 3; // * MP3ANTIALI; // кратно 8 (длина шага 1-ого subband) for (uint16 i = 0; i < i_max; i += 4) { uint16 n = i & 7; // n = 0 ? 4 uint16 n01 = n >> 2; // n01 = 0 ? 1 uint16 s = MP3LINES * (1 + (i >> 3)); // MP3LINES * subband:(1..subband_max) float * _sample = sample + s - 4 - n; // sample_li.m128 = _mm_loadu_ps(sample + s - 4 - n); // -4..-1, -8..-5 (wrong) sample_ui.m128 = _mm_loadu_ps(sample + s + n); // 0.. 3, 4.. 7 sample_li.m128 = _mm_set_ps ( // -1..-4, -5..-8 _sample[0], _sample[1], _sample[2], _sample[3] ); left.m128 = _mm_mul_ps(sample_li.m128, ucs.m128[n01]); // m128[ 0 ? 1 ] right.m128 = _mm_mul_ps(sample_ui.m128, uca.m128[n01]); // . result.m128 = _mm_sub_ps(left.m128, right.m128); _sample[0] = result.f[3]; _sample[1] = result.f[2]; _sample[2] = result.f[1]; _sample[3] = result.f[0]; left.m128 = _mm_mul_ps(sample_ui.m128, ucs.m128[n01]); // m128[ 0 ? 1 ] right.m128 = _mm_mul_ps(sample_li.m128, uca.m128[n01]); // . result.m128 = _mm_add_ps(left.m128, right.m128); _mm_storeu_ps(sample + s + n, result.m128); } } else #endif // SIMPLE CODE = 100% time { for (uint16 subband = 1; subband < subband_max; subband++) // 31 (31 * 8 = 248) for (uint16 i = 0; i < MP3ANTIALI; i++) // 8 { // -8, -7, ..., -1 (li) // 7, 6, ..., 0 (ul) uint16 li = MP3LINES * subband - 1 - i; uint16 ui = MP3LINES * subband + i; float lb = sample[li] * ucs.f[i] - sample[ui] * uca.f[i]; float ub = sample[ui] * ucs.f[i] + sample[li] * uca.f[i]; sample[li] = lb; sample[ui] = ub; } } } //>> 3.2. IMDCT Обратное модифицированное дискретное косинусное преобразование void ConvertMP3_HybridSynth_simple(byte gr, byte ch) { float rawout[MP3LINES * 2]; // raw out [36] float * sample = MPEGD.sample[gr][ch]; // sample [576] auto IMDCT = [this, sample] (float * rawout, uint16 level, byte block_type) -> void { float * in = sample + level; ZeroMemory(rawout, sizeof(rawout)); if (block_type == eMPEGBlockT_3ShortWindow) { const uint16 N = 12; const uint16 N2 = N / 2; //const uint16 Nx2 = N * 2; //const uint16 N2p = N2 + 1; float out_temp[N]; for (uint16 i=0; i < 3; i++) { for (uint16 p=0; p < N; p++) { float sum = 0; for (uint16 m = 0; m < N2; m++) //sum += in[i + 3 * m] * cos(MathPI / Nx2 * (2 * p + N2p) * (2 * m + 1)); sum += in[i + 3 * m] * IMDCT_cos1tab[p + N * m]; out_temp[p] = sum * IMDCT_sin[block_type][p]; } for (uint16 p = 0; p < N; p++) { rawout[6 * i + p + 6] += out_temp[p]; } } } else { const uint16 N = 36; const uint16 N2 = N / 2; //const uint16 Nx2 = N * 2; //const uint16 N2p = N2 + 1; for (uint16 p = 0; p < N; p++) { float sum = 0; for (uint16 m=0; m < N2; m++) //sum += in[m] * cos(MathPI / Nx2 * (2 * p + N2p) * (2 * m + 1)); sum += in[m] * IMDCT_cos2tab[p + N * m]; rawout[p] = sum * IMDCT_sin[block_type][p]; } } }; for (uint16 subband = 0; subband < MP3SUBBANDS; subband++) { byte block_type = MPEGS.block_type[gr][ch]; uint16 level = subband * MP3LINES; if (subband < 2 && MPEGS.switch_flag[gr][ch] && MPEGS.mixed_block_flag[gr][ch]) block_type = 0; IMDCT(rawout, level, block_type); for (uint16 line = 0; line < MP3LINES; line++) { sample[level + line] = rawout[line] + storehs[ch][subband][line]; storehs[ch][subband][line] = rawout[line + MP3LINES]; } } } //>> 3.2. IMDCT Обратное модифицированное дискретное косинусное преобразование - fast ver. void ConvertMP3_HybridSynth(byte gr, byte ch) { float rawout[MP3LINES * 2]; // raw out [36] float * sample = MPEGD.sample[gr][ch]; // sample [576] auto storehs = this->storehs[ch]; // [32][18] auto IMDCT_3 = [this] (float in[3], float out[3]) -> void { float t0, t1; t0 = in[2] * 0.5f + in[0]; t1 = in[1] * c_sqrt32; out[0] = t0 + t1; out[1] = in[0] - in[2]; out[2] = t0 - t1; }; auto IMDCT_Short = [this, IMDCT_3] (float in[6], float out[12]) -> void { int i; float H[6], h[6], even[3], odd[3], even_idct[3], odd_idct[3]; H[0] = in[0]; for (i = 1; i < 6; i++) H[i] = in[i - 1] + in[i]; even[0] = H[0]; even[1] = H[2]; even[2] = H[4]; IMDCT_3 (even, even_idct); odd[0] = H[1]; odd[1] = H[1] + H[3]; odd[2] = H[3] + H[5]; IMDCT_3 (odd, odd_idct); odd_idct[0] *= form_3_6[0]; odd_idct[1] *= form_3_6[1]; odd_idct[2] *= form_3_6[2]; h[0] = form_6_12[0] * (even_idct[0] + odd_idct[0]); h[1] = form_6_12[1] * (even_idct[1] + odd_idct[1]); h[2] = form_6_12[2] * (even_idct[2] + odd_idct[2]); h[3] = form_6_12[3] * (even_idct[2] - odd_idct[2]); h[4] = form_6_12[4] * (even_idct[1] - odd_idct[1]); h[5] = form_6_12[5] * (even_idct[0] - odd_idct[0]); out[0] = h[3]; out[4] = -h[4]; out[8] = -h[0]; out[1] = h[4]; out[5] = -h[3]; out[9] = -h[0]; out[2] = h[5]; out[6] = -h[2]; out[10] = -h[1]; out[3] = -h[5]; out[7] = -h[1]; out[11] = -h[2]; }; auto IMDCT_4 = [this] (float in[4], float out[4]) -> void { float t0, t1; t0 = in[3] * 0.5f + in[0]; t1 = in[1] - in[2]; out[0] = t0 + in[1] * c_cos9 + in[2] * c_cos92; out[1] = t1 * 0.5f + in[0] - in[3]; out[2] = t0 - in[1] * c_cos94 - in[2] * c_cos9; out[3] = t0 - in[1] * c_cos92 + in[2] * c_cos94; }; auto IMDCT_5 = [this] (float in[5], float out[5]) -> void { float t0, t1, t2; t0 = in[3] * 0.5f + in[0]; t1 = in[0] - in[3]; t2 = in[1] - in[2] - in[4]; out[0] = t0 + in[1] * c_cos9 + in[2] * c_cos92 + in[4] * c_cos94; out[1] = t2 * 0.5f + t1; out[2] = t0 - in[1] * c_cos94 - in[2] * c_cos9 + in[4] * c_cos92; out[3] = t0 - in[1] * c_cos92 + in[2] * c_cos94 - in[4] * c_cos9; out[4] = t1 - t2; }; auto IMDCT_9 = [this, IMDCT_5, IMDCT_4](float in[9], float out[9]) -> void { int i; float H[9], h[9], even[5], odd[4], even_idct[5], odd_idct[4]; for (i = 0; i < 9; i++) H[i] = in[i]; for (i = 0; i < 5; i++) even[i] = H[2 * i]; IMDCT_5(even, even_idct); odd[0] = H[1]; for (i = 1; i < 4; i++) odd[i] = H[2 * i - 1] + H[2 * i + 1]; IMDCT_4(odd, odd_idct); odd_idct[0] += in[7] * c_sin0; odd_idct[1] += -in[7] * c_sin1; odd_idct[2] += in[7] * c_sin2; odd_idct[3] += -in[7] * c_sin3; for (i = 0; i < 4; i++) odd_idct[i] *= form_4_9[i]; for (i = 0; i < 4; i++) h[i] = even_idct[i] + odd_idct[i]; h[4] = even_idct[4]; for (i = 5; i < 9; i++) h[i] = even_idct[8 - i] - odd_idct[8 - i]; for (i = 0; i < 9; i++) out[i] = h[i]; }; auto IMDCT_Long = [this, IMDCT_9](float in[18], float out[36]) -> void { int i; float H[18], h[18], even[9], odd[9], even_idct[9], odd_idct[9]; H[0] = in[0]; for (i = 1; i < 18; i++) H[i] = in[i - 1] + in[i]; for (i = 0; i < 9; i++) even[i] = H[i * 2]; IMDCT_9(even, even_idct); odd[0] = H[1]; for (i = 1; i < 9; i++) odd[i] = H[i * 2 - 1] + H[i * 2 + 1]; IMDCT_9(odd, odd_idct); for (i = 0; i < 9; i++) odd_idct[i] *= form_9_18[i]; for (i = 0; i < 9; i++) h[i] = even_idct[i] + odd_idct[i]; for (i = 9; i < 18; i++) h[i] = even_idct[17 - i] - odd_idct[17 - i]; for (i = 0; i < 18; i++) h[i] *= form_18_36[i]; out[0] = h[9]; out[9] = -h[17]; out[18] = -h[8]; out[27] = -h[0]; out[1] = h[10]; out[10] = -h[16]; out[19] = -h[7]; out[28] = -h[1]; out[2] = h[11]; out[11] = -h[15]; out[20] = -h[6]; out[29] = -h[2]; out[3] = h[12]; out[12] = -h[14]; out[21] = -h[5]; out[30] = -h[3]; out[4] = h[13]; out[13] = -h[13]; out[22] = -h[4]; out[31] = -h[4]; out[5] = h[14]; out[14] = -h[12]; out[23] = -h[3]; out[32] = -h[5]; out[6] = h[15]; out[15] = -h[11]; out[24] = -h[2]; out[33] = -h[6]; out[7] = h[16]; out[16] = -h[10]; out[25] = -h[1]; out[34] = -h[7]; out[8] = h[17]; out[17] = -h[9]; out[26] = -h[0]; out[35] = -h[8]; }; auto IMDCT = [this, IMDCT_Short, IMDCT_Long, sample, &rawout](uint16 level, byte block_type) -> void { float * in = sample + level; ZeroMemory(rawout, sizeof(rawout)); if (block_type == eMPEGBlockT_3ShortWindow) { float out[12]; float _in[18]; for (uint16 i = 0; i < 3; i++) for (uint16 m = 0; m < 6; m++) _in[i * 6 + m] = in[i + 3 * m]; for (uint16 i = 0; i < 3; i++) { IMDCT_Short(_in + 6 * i, out); for (uint16 p = 0; p < 12; p++) rawout[6 * i + p + 6] += out[p] * IMDCT_sin[block_type][p]; } } else { IMDCT_Long(in, rawout); for (uint16 i = 0; i < 36; i++) rawout[i] *= IMDCT_sin[block_type][i]; } }; #pragma region <IMDCT_3> #define _IMDCT_3(in, out) { \ float t0, t1; \ \ t0 = in[2] * 0.5f + in[0]; \ t1 = in[1] * c_sqrt32; \ \ out[0] = t0 + t1; \ out[1] = in[0] - in[2]; \ out[2] = t0 - t1; \ } #pragma endregion #pragma region <IMDCT_Short> #define _IMDCT_Short(in, out) { \ int i; \ float H[6], h[6], even[3], odd[3], even_idct[3], odd_idct[3]; \ \ H[0] = in[0]; \ for (i = 1; i < 6; i++) \ H[i] = in[i - 1] + in[i]; \ \ even[0] = H[0]; \ even[1] = H[2]; \ even[2] = H[4]; \ \ _IMDCT_3(even, even_idct); \ \ odd[0] = H[1]; \ odd[1] = H[1] + H[3]; \ odd[2] = H[3] + H[5]; \ \ _IMDCT_3(odd, odd_idct); \ \ odd_idct[0] *= form_3_6[0]; \ odd_idct[1] *= form_3_6[1]; \ odd_idct[2] *= form_3_6[2]; \ \ h[0] = form_6_12[0] * (even_idct[0] + odd_idct[0]); \ h[1] = form_6_12[1] * (even_idct[1] + odd_idct[1]); \ h[2] = form_6_12[2] * (even_idct[2] + odd_idct[2]); \ \ h[3] = form_6_12[3] * (even_idct[2] - odd_idct[2]); \ h[4] = form_6_12[4] * (even_idct[1] - odd_idct[1]); \ h[5] = form_6_12[5] * (even_idct[0] - odd_idct[0]); \ \ out[0] = h[3]; out[4] = -h[4]; out[8] = -h[0]; \ out[1] = h[4]; out[5] = -h[3]; out[9] = -h[0]; \ out[2] = h[5]; out[6] = -h[2]; out[10] = -h[1]; \ out[3] = -h[5]; out[7] = -h[1]; out[11] = -h[2]; \ } #pragma endregion #pragma region <IMDCT_4> #define _IMDCT_4(in, out) { \ float t0, t1; \ \ t0 = in[3] * 0.5f + in[0]; \ t1 = in[1] - in[2]; \ \ out[0] = t0 + in[1] * c_cos9 + in[2] * c_cos92; \ out[1] = t1 * 0.5f + in[0] - in[3]; \ out[2] = t0 - in[1] * c_cos94 - in[2] * c_cos9; \ out[3] = t0 - in[1] * c_cos92 + in[2] * c_cos94; \ } #pragma endregion #pragma region <IMDCT_5> #define _IMDCT_5(in, out) { \ float t0, t1, t2; \ \ t0 = in[3] * 0.5f + in[0]; \ t1 = in[0] - in[3]; \ t2 = in[1] - in[2] - in[4]; \ \ out[0] = t0 + in[1] * c_cos9 + in[2] * c_cos92 + in[4] * c_cos94; \ out[1] = t2 * 0.5f + t1; \ out[2] = t0 - in[1] * c_cos94 - in[2] * c_cos9 + in[4] * c_cos92; \ out[3] = t0 - in[1] * c_cos92 + in[2] * c_cos94 - in[4] * c_cos9; \ out[4] = t1 - t2; \ } #pragma endregion #pragma region <IMDCT_9> #define _IMDCT_9(in, out) { \ int i; \ float H9[9], h9[9], even9[5], odd9[4], even_idct9[5], odd_idct9[4]; \ \ for (i = 0; i < 9; i++) \ H9[i] = in[i]; \ \ for (i = 0; i < 5; i++) \ even9[i] = H9[2 * i]; \ \ _IMDCT_5(even9, even_idct9); \ \ odd9[0] = H9[1]; \ for (i = 1; i < 4; i++) \ odd9[i] = H9[2 * i - 1] + H9[2 * i + 1]; \ \ _IMDCT_4(odd9, odd_idct9); \ \ odd_idct9[0] += in[7] * c_sin0; \ odd_idct9[1] += -in[7] * c_sin1; \ odd_idct9[2] += in[7] * c_sin2; \ odd_idct9[3] += -in[7] * c_sin3; \ \ for (i = 0; i < 4; i++) \ odd_idct9[i] *= form_4_9[i]; \ \ for (i = 0; i < 4; i++) \ h9[i] = even_idct9[i] + odd_idct9[i]; \ \ h9[4] = even_idct9[4]; \ \ for (i = 5; i < 9; i++) \ h9[i] = even_idct9[8 - i] - odd_idct9[8 - i]; \ \ for (i = 0; i < 9; i++) \ out[i] = h9[i]; \ } #pragma endregion #pragma region <IMDCT_Long> #define _IMDCT_Long(in, out) { \ int i; \ float H[18], h[18], even[9], odd[9], even_idct[9], odd_idct[9]; \ \ H[0] = in[0]; \ for (i = 1; i < 18; i++) \ H[i] = in[i - 1] + in[i]; \ \ for (i = 0; i < 9; i++) \ even[i] = H[i * 2]; \ \ _IMDCT_9(even, even_idct); \ \ odd[0] = H[1]; \ for (i = 1; i < 9; i++) \ odd[i] = H[i * 2 - 1] + H[i * 2 + 1]; \ \ _IMDCT_9(odd, odd_idct); \ \ for (i = 0; i < 9; i++) \ odd_idct[i] *= form_9_18[i]; \ \ for (i = 0; i < 9; i++) \ h[i] = even_idct[i] + odd_idct[i]; \ \ for (i = 9; i < 18; i++) \ h[i] = even_idct[17 - i] - odd_idct[17 - i]; \ \ for (i = 0; i < 18; i++) \ h[i] *= form_18_36[i]; \ \ memcpy(out, h + 9, 36); \ \ out[9] = -h[17]; out[18] = -h[8]; out[27] = -h[0]; \ out[10] = -h[16]; out[19] = -h[7]; out[28] = -h[1]; \ out[11] = -h[15]; out[20] = -h[6]; out[29] = -h[2]; \ out[12] = -h[14]; out[21] = -h[5]; out[30] = -h[3]; \ out[13] = -h[13]; out[22] = -h[4]; out[31] = -h[4]; \ out[14] = -h[12]; out[23] = -h[3]; out[32] = -h[5]; \ out[15] = -h[11]; out[24] = -h[2]; out[33] = -h[6]; \ out[16] = -h[10]; out[25] = -h[1]; out[34] = -h[7]; \ out[17] = -h[9]; out[26] = -h[0]; out[35] = -h[8]; \ } #pragma endregion #pragma region <IMDCT> #define _IMDCT(level, block_type) { \ float * in = sample + level; \ \ ZeroMemory(rawout, sizeof(rawout)); \ \ if (block_type == eMPEGBlockT_3ShortWindow) \ { \ float out[12]; \ float _in[18]; \ \ for (uint16 i = 0; i < 3; i++) \ for (uint16 m = 0; m < 6; m++) \ _in[i * 6 + m] = in[i + 3 * m]; \ \ for (uint16 i = 0; i < 3; i++) \ { \ in = _in + i * 6; \ _IMDCT_Short(in, out); \ \ for (uint16 p = 0; p < 12; p++) \ rawout[6 * i + p + 6] += \ out[p] * IMDCT_sin[block_type][p]; \ } \ } \ else \ { \ _IMDCT_Long(in, rawout); \ \ for (uint16 i = 0; i < 36; i++) \ rawout[i] *= IMDCT_sin[block_type][i]; \ } \ } #pragma endregion #ifdef ENGINE_SSE if (opt_SSE_only) // SSE CODE = 80%..85% time { #pragma region <IMDCT_Short_SSE> #define _IMDCT_Short_SSE(in, out) { \ float H[6], h[7], even[3], odd[3], even_idct[4], odd_idct[4]; \ UNION128 a, b, r; \ \ H[0] = in[0]; \ H[5] = in[4] + in[5]; \ { \ a.m128 = _mm_loadu_ps(in); \ b.m128 = _mm_loadu_ps(in + 1); \ r.m128 = _mm_add_ps(a.m128, b.m128); \ _mm_storeu_ps(H + 1, r.m128); \ } \ \ even[0] = H[0]; \ even[1] = H[2]; \ even[2] = H[4]; \ \ _IMDCT_3(even, even_idct); \ \ odd[0] = H[1]; \ odd[1] = H[1] + H[3]; \ odd[2] = H[3] + H[5]; \ \ _IMDCT_3(odd, odd_idct); \ \ { \ a.m128 = _mm_loadu_ps(odd_idct); \ r.m128 = _mm_mul_ps(a.m128, u_form_3_6.m128); \ _mm_storeu_ps(odd_idct, r.m128); \ } \ \ { \ a.m128 = _mm_loadu_ps(even_idct); \ b.m128 = _mm_loadu_ps(odd_idct); \ r.m128 = _mm_add_ps(a.m128, b.m128); \ a.m128 = _mm_mul_ps(r.m128, u_form_6_12.m128[0]); \ _mm_storeu_ps(h, a.m128); \ } \ \ { \ a.m128 = _mm_loadu_ps(even_idct); \ b.m128 = _mm_loadu_ps(odd_idct); \ r.m128 = _mm_sub_ps(a.m128, b.m128); \ a.f[0] = r.f[2]; \ a.f[1] = r.f[1]; \ a.f[2] = r.f[0]; \ r.m128 = _mm_mul_ps(a.m128, u_form_6_12_3.m128); \ _mm_storeu_ps(h + 3, r.m128); \ } \ \ out[0] = h[3]; out[4] = -h[4]; out[8] = -h[0]; \ out[1] = h[4]; out[5] = -h[3]; out[9] = -h[0]; \ out[2] = h[5]; out[6] = -h[2]; out[10] = -h[1]; \ out[3] = -h[5]; out[7] = -h[1]; out[11] = -h[2]; \ } #pragma endregion #pragma region <IMDCT_9_SSE> #define _IMDCT_9_SSE(in, out) { \ int i; \ float H9[9], h9[9], even9[5], odd9[4], even_idct9[5], odd_idct9[4]; \ UNION128 a, b, r; \ \ memcpy(H9, in, 36); \ \ for (i = 0; i < 5; i++) \ even9[i] = H9[2 * i]; \ \ _IMDCT_5(even9, even_idct9); \ \ odd9[0] = H9[1]; \ for (i = 1; i < 4; i++) \ odd9[i] = H9[2 * i - 1] + H9[2 * i + 1]; \ \ _IMDCT_4(odd9, odd_idct9); \ \ { \ b.m128 = _mm_load_ps1(in + 7); \ b.f[1] = -b.f[1]; \ b.f[3] = -b.f[3]; \ r.m128 = _mm_mul_ps(c_sin.m128, b.m128); \ a.m128 = _mm_loadu_ps(odd_idct9); \ b.m128 = _mm_add_ps(a.m128, r.m128); \ _mm_storeu_ps(odd_idct9, b.m128); \ } \ \ { \ a.m128 = _mm_loadu_ps(odd_idct9); \ r.m128 = _mm_mul_ps(a.m128, u_form_4_9.m128); \ _mm_storeu_ps(odd_idct9, r.m128); \ } \ \ { \ a.m128 = _mm_loadu_ps(even_idct9); \ b.m128 = _mm_loadu_ps(odd_idct9); \ r.m128 = _mm_add_ps(a.m128, b.m128); \ _mm_storeu_ps(h9, r.m128); \ r.m128 = _mm_sub_ps(a.m128, b.m128); \ h9[4] = even_idct9[4]; \ h9[5] = r.f[3]; \ h9[6] = r.f[2]; \ h9[7] = r.f[1]; \ h9[8] = r.f[0]; \ } \ \ memcpy(out, h9, 36); \ } #pragma endregion #pragma region <IMDCT_Long_SSE> #define _IMDCT_Long_SSE(in, out) { \ int i; \ float H[18], h[18], even[9], odd[9], even_idct[9], odd_idct[9]; \ UNION128 a, b, r; \ \ H[0] = in[0]; \ H[17] = in[16] + in[17]; \ for (i = 1; i < 17; i += 4) \ { \ a.m128 = _mm_loadu_ps(in + i); \ b.m128 = _mm_loadu_ps(in + i - 1); \ r.m128 = _mm_add_ps(a.m128, b.m128); \ _mm_storeu_ps(H + i, r.m128); \ } \ \ for (i = 0; i < 9; i++) \ even[i] = H[i * 2]; \ \ _IMDCT_9_SSE(even, even_idct); \ \ odd[0] = H[1]; \ for (i = 1; i < 9; i++) \ odd[i] = H[i * 2 - 1] + H[i * 2 + 1]; \ \ _IMDCT_9_SSE(odd, odd_idct); \ \ for (i = 0; i < 8; i += 4) \ { \ a.m128 = _mm_loadu_ps(odd_idct + i); \ r.m128 = _mm_mul_ps(a.m128, u_form_9_18.m128[i>>2]); \ _mm_storeu_ps(odd_idct + i, r.m128); \ } \ odd_idct[8] *= form_9_18[8]; \ \ for (i = 0; i < 8; i += 4) \ { \ a.m128 = _mm_loadu_ps(even_idct + i); \ b.m128 = _mm_loadu_ps(odd_idct + i); \ r.m128 = _mm_add_ps(a.m128, b.m128); \ _mm_storeu_ps(h + i, r.m128); \ } \ \ h[8] = even_idct[8] + odd_idct[8]; \ h[9] = even_idct[8] - odd_idct[8]; \ \ for (i = 10; i < 18; i += 4) \ { \ a.m128 = _mm_loadu_ps(even_idct + (17 - i) - 3); \ b.m128 = _mm_loadu_ps(odd_idct + (17 - i) - 3); \ r.m128 = _mm_sub_ps(a.m128, b.m128); \ h[i] = r.f[3]; \ h[i+1] = r.f[2]; \ h[i+2] = r.f[1]; \ h[i+3] = r.f[0]; \ } \ \ h[16] *= form_18_36[16]; \ h[17] *= form_18_36[17]; \ for (i = 0; i < 16; i += 4) \ { \ a.m128 = _mm_loadu_ps(h + i); \ r.m128 = _mm_mul_ps(a.m128, u_form_18_36.m128[i>>2]); \ _mm_storeu_ps(h + i, r.m128); \ } \ \ memcpy(out, h + 9, 36); \ \ out[9] = -h[17]; out[18] = -h[8]; out[27] = -h[0]; \ out[10] = -h[16]; out[19] = -h[7]; out[28] = -h[1]; \ out[11] = -h[15]; out[20] = -h[6]; out[29] = -h[2]; \ out[12] = -h[14]; out[21] = -h[5]; out[30] = -h[3]; \ out[13] = -h[13]; out[22] = -h[4]; out[31] = -h[4]; \ out[14] = -h[12]; out[23] = -h[3]; out[32] = -h[5]; \ out[15] = -h[11]; out[24] = -h[2]; out[33] = -h[6]; \ out[16] = -h[10]; out[25] = -h[1]; out[34] = -h[7]; \ out[17] = -h[9]; out[26] = -h[0]; out[35] = -h[8]; \ } #pragma endregion #pragma region <IMDCT_SSE> #define _IMDCT_SSE(level, block_type) { \ float * in = sample + level; \ auto & IMDCT_sin_bt = u_IMDCT_sin[block_type]; \ UNION128 a, b, r; \ \ ZeroMemory(rawout, sizeof(rawout)); \ \ if (block_type == eMPEGBlockT_3ShortWindow) \ { \ float out[12]; \ float _in[18]; \ \ for (uint16 i = 0; i < 3; i++) \ for (uint16 m = 0; m < 6; m++) \ _in[i * 6 + m] = in[i + 3 * m]; \ \ for (uint16 i = 0; i < 3; i++) \ { \ in = _in + i * 6; \ _IMDCT_Short_SSE(in, out); \ \ uint16 _6i6 = 6 * i + 6; \ for (uint16 p = 0; p < 12; p += 4) \ { \ a.m128 = _mm_loadu_ps(out + p); \ r.m128 = _mm_mul_ps(a.m128, IMDCT_sin_bt.m128[p>>2]); \ \ a.m128 = _mm_loadu_ps(rawout + _6i6 + p); \ b.m128 = _mm_add_ps(a.m128, r.m128); \ _mm_storeu_ps(rawout + _6i6 + p, b.m128); \ } \ } \ } \ else \ { \ _IMDCT_Long_SSE(in, rawout); \ \ for (uint16 i=0; i<36; i+=4) \ { \ a.m128 = _mm_loadu_ps(rawout + i); \ r.m128 = _mm_mul_ps(a.m128, IMDCT_sin_bt.m128[i>>2]); \ _mm_storeu_ps(rawout + i, r.m128); \ } \ } \ } #pragma endregion for (uint16 subband = 0; subband < MP3SUBBANDS; subband++) { byte block_type = MPEGS.block_type[gr][ch]; uint16 level = subband * MP3LINES; float * store = storehs[subband]; // [18] if (subband < 2 && MPEGS.switch_flag[gr][ch] && MPEGS.mixed_block_flag[gr][ch]) block_type = 0; _IMDCT_SSE(level, block_type); for (uint16 line = 0; line < 16; line += 4) // 16 = 4x4 (SSE) 8x2 (AVX) 16x1 (AVX256) { UNION128 a, b, r; a.m128 = _mm_loadu_ps(rawout + line); b.m128 = _mm_loadu_ps(store + line); r.m128 = _mm_add_ps(a.m128, b.m128); _mm_storeu_ps(sample + level + line, r.m128); } sample[level + 16] = rawout[16] + store[16]; sample[level + 17] = rawout[17] + store[17]; memcpy(store, rawout + MP3LINES, MP3LINES * sizeof(float)); } } else #endif #ifdef ENGINE_AVX if (opt_AVX_only) // AVX CODE = ??%..??% time _ NOT TESTED { #pragma region <IMDCT_Long_AVX> #define _IMDCT_Long_AVX(in, out) { \ int i; \ float H[18], h[18], even[9], odd[9], even_idct[9], odd_idct[9]; \ UNION256 a, b, r; \ \ H[0] = in[0]; \ H[17] = in[16] + in[17]; \ for (i = 1; i < 17; i += 8) \ { \ a.m256 = _mm256_loadu_ps(in + i); \ b.m256 = _mm256_loadu_ps(in + i - 1); \ r.m256 = _mm256_add_ps(a.m256, b.m256); \ _mm256_storeu_ps(H + i, r.m256); \ } \ \ for (i = 0; i < 9; i++) \ even[i] = H[i * 2]; \ \ _IMDCT_9_SSE(even, even_idct); \ \ odd[0] = H[1]; \ for (i = 1; i < 9; i++) \ odd[i] = H[i * 2 - 1] + H[i * 2 + 1]; \ \ _IMDCT_9_SSE(odd, odd_idct); \ \ a.m256 = _mm256_loadu_ps(odd_idct); \ r.m256 = _mm256_mul_ps(a.m256, u_form_9_18.m256[0]); \ _mm256_storeu_ps(odd_idct, r.m256); \ \ odd_idct[8] *= form_9_18[8]; \ \ a.m256 = _mm256_loadu_ps(even_idct); \ b.m256 = _mm256_loadu_ps(odd_idct); \ r.m256 = _mm256_add_ps(a.m256, b.m256); \ _mm256_storeu_ps(h, r.m256); \ \ h[8] = even_idct[8] + odd_idct[8]; \ h[9] = even_idct[8] - odd_idct[8]; \ \ a.m256 = _mm256_loadu_ps(even_idct); \ b.m256 = _mm256_loadu_ps(odd_idct); \ r.m256 = _mm256_sub_ps(a.m256, b.m256); \ h[10] = r.f[7]; \ h[11] = r.f[6]; \ h[12] = r.f[5]; \ h[13] = r.f[4]; \ h[14] = r.f[3]; \ h[15] = r.f[2]; \ h[16] = r.f[1]; \ h[17] = r.f[0]; \ \ h[16] *= form_18_36[16]; \ h[17] *= form_18_36[17]; \ for (i = 0; i < 16; i += 8) \ { \ a.m256 = _mm256_loadu_ps(h + i); \ r.m256 = _mm256_mul_ps(a.m256, u_form_18_36.m256[i>>3]); \ _mm256_storeu_ps(h + i, r.m256); \ } \ \ memcpy(out, h + 9, 36); \ \ out[9] = -h[17]; out[18] = -h[8]; out[27] = -h[0]; \ out[10] = -h[16]; out[19] = -h[7]; out[28] = -h[1]; \ out[11] = -h[15]; out[20] = -h[6]; out[29] = -h[2]; \ out[12] = -h[14]; out[21] = -h[5]; out[30] = -h[3]; \ out[13] = -h[13]; out[22] = -h[4]; out[31] = -h[4]; \ out[14] = -h[12]; out[23] = -h[3]; out[32] = -h[5]; \ out[15] = -h[11]; out[24] = -h[2]; out[33] = -h[6]; \ out[16] = -h[10]; out[25] = -h[1]; out[34] = -h[7]; \ out[17] = -h[9]; out[26] = -h[0]; out[35] = -h[8]; \ } #pragma endregion #pragma region <IMDCT_AVX> #define _IMDCT_AVX(level, block_type) { \ float * in = sample + level; \ auto & IMDCT_sin_bt = u_IMDCT_sin[block_type]; \ UNION256 a, b, r; \ \ ZeroMemory(rawout, sizeof(rawout)); \ \ if (block_type == eMPEGBlockT_3ShortWindow) \ { \ float out[12]; \ float _in[18]; \ \ for (uint16 i = 0; i < 3; i++) \ for (uint16 m = 0; m < 6; m++) \ _in[i * 6 + m] = in[i + 3 * m]; \ \ for (uint16 i = 0; i < 3; i++) \ { \ in = _in + i * 6; \ _IMDCT_Short_SSE(in, out); \ \ uint16 _6i6 = 6 * i + 6; \ \ a.m256 = _mm256_loadu_ps(out); \ r.m256 = _mm256_mul_ps(a.m256, IMDCT_sin_bt.m256[0]); \ \ a.m256 = _mm256_loadu_ps(rawout + _6i6); \ b.m256 = _mm256_add_ps(a.m256, r.m256); \ _mm256_storeu_ps(rawout + _6i6, b.m256); \ \ \ a.m128[0] = _mm_loadu_ps(out + 8); \ r.m128[0] = _mm_mul_ps(a.m128[0], IMDCT_sin_bt.m128[2]); \ \ a.m128[0] = _mm_loadu_ps(rawout + _6i6 + 8); \ b.m128[0] = _mm_add_ps(a.m128[0], r.m128[0]); \ _mm_storeu_ps(rawout + _6i6 + 8, b.m128[0]); \ } \ } \ else \ { \ _IMDCT_Long_AVX(in, rawout); \ \ for (uint16 i=0; i<32; i+=8) \ { \ a.m256 = _mm256_loadu_ps(rawout + i); \ r.m256 = _mm256_mul_ps(a.m256, IMDCT_sin_bt.m256[i>>3]); \ _mm256_storeu_ps(rawout + i, r.m256); \ } \ \ a.m128[0] = _mm_loadu_ps(rawout + 32); \ r.m128[0] = _mm_mul_ps(a.m128[0], IMDCT_sin_bt.m128[8]); \ _mm_storeu_ps(rawout + 32, r.m128[0]); \ } \ } #pragma endregion #pragma message ("ConvertMP3_HybridSynth : 256-bit AVX code not tested") for (uint16 subband = 0; subband < MP3SUBBANDS; subband++) { byte block_type = MPEGS.block_type[gr][ch]; uint16 level = subband * MP3LINES; float * store = storehs[subband]; // [18] if (subband < 2 && MPEGS.switch_flag[gr][ch] && MPEGS.mixed_block_flag[gr][ch]) block_type = 0; _IMDCT_AVX(level, block_type); for (uint16 line = 0; line < 16; line += 8) // 16 = 4x4 (SSE) 8x2 (AVX) 16x1 (AVX256) { UNION256 a, b, r; a.m256 = _mm256_loadu_ps(rawout + line); b.m256 = _mm256_loadu_ps(store + line); r.m256 = _mm256_add_ps(a.m256, b.m256); _mm256_storeu_ps(sample + level + line, r.m256); } sample[level + 16] = rawout[16] + store[16]; sample[level + 17] = rawout[17] + store[17]; memcpy(store, rawout + MP3LINES, MP3LINES * sizeof(float)); } } else #endif #ifdef ENGINE_AVX512F #pragma region <IMDCT_Long_AVX512F> #define _IMDCT_Long_AVX512F(in, out) { \ int i; \ float H[18], h[18], even[9], odd[9], even_idct[9], odd_idct[9]; \ UNION512 a, b, r; \ \ H[0] = in[0]; \ H[17] = in[16] + in[17]; \ \ a.m512 = _mm512_loadu_ps(in + 1); \ b.m512 = _mm512_loadu_ps(in); \ r.m512 = _mm512_add_ps(a.m512, b.m512); \ _mm512_storeu_ps(H + 1, r.m512); \ \ for (i = 0; i < 9; i++) \ even[i] = H[i * 2]; \ \ _IMDCT_9_SSE(even, even_idct); \ \ odd[0] = H[1]; \ for (i = 1; i < 9; i++) \ odd[i] = H[i * 2 - 1] + H[i * 2 + 1]; \ \ _IMDCT_9_SSE(odd, odd_idct); \ \ a.m256[0] = _mm256_loadu_ps(odd_idct); \ r.m256[0] = _mm256_mul_ps(a.m256[0], u_form_9_18.m256[0]); \ _mm256_storeu_ps(odd_idct, r.m256[0]); \ \ odd_idct[8] *= form_9_18[8]; \ \ a.m256[0] = _mm256_loadu_ps(even_idct); \ b.m256[0] = _mm256_loadu_ps(odd_idct); \ r.m256[0] = _mm256_add_ps(a.m256[0], b.m256[0]); \ _mm256_storeu_ps(h, r.m256[0]); \ \ h[8] = even_idct[8] + odd_idct[8]; \ h[9] = even_idct[8] - odd_idct[8]; \ \ a.m256[0] = _mm256_loadu_ps(even_idct); \ b.m256[0] = _mm256_loadu_ps(odd_idct); \ r.m256[0] = _mm256_sub_ps(a.m256[0], b.m256[0]); \ h[10] = r.f[7]; \ h[11] = r.f[6]; \ h[12] = r.f[5]; \ h[13] = r.f[4]; \ h[14] = r.f[3]; \ h[15] = r.f[2]; \ h[16] = r.f[1]; \ h[17] = r.f[0]; \ \ h[16] *= form_18_36[16]; \ h[17] *= form_18_36[17]; \ \ a.m512 = _mm512_loadu_ps(h); \ r.m512 = _mm512_mul_ps(a.m512, u_form_18_36.m512[0]); \ _mm512_storeu_ps(h, r.m512); \ \ memcpy(out, h + 9, 36); \ \ out[9] = -h[17]; out[18] = -h[8]; out[27] = -h[0]; \ out[10] = -h[16]; out[19] = -h[7]; out[28] = -h[1]; \ out[11] = -h[15]; out[20] = -h[6]; out[29] = -h[2]; \ out[12] = -h[14]; out[21] = -h[5]; out[30] = -h[3]; \ out[13] = -h[13]; out[22] = -h[4]; out[31] = -h[4]; \ out[14] = -h[12]; out[23] = -h[3]; out[32] = -h[5]; \ out[15] = -h[11]; out[24] = -h[2]; out[33] = -h[6]; \ out[16] = -h[10]; out[25] = -h[1]; out[34] = -h[7]; \ out[17] = -h[9]; out[26] = -h[0]; out[35] = -h[8]; \ } #pragma endregion #pragma region <IMDCT_AVX512F> #define _IMDCT_AVX512F(level, block_type) { \ float * in = sample + level; \ auto & IMDCT_sin_bt = u_IMDCT_sin[block_type]; \ UNION512 a, b, r; \ \ ZeroMemory(rawout, sizeof(rawout)); \ \ if (block_type == eMPEGBlockT_3ShortWindow) \ { \ float out[12]; \ float _in[18]; \ \ for (uint16 i = 0; i < 3; i++) \ for (uint16 m = 0; m < 6; m++) \ _in[i * 6 + m] = in[i + 3 * m]; \ \ for (uint16 i = 0; i < 3; i++) \ { \ in = _in + i * 6; \ _IMDCT_Short_SSE(in, out); \ \ uint16 _6i6 = 6 * i + 6; \ \ a.m256[0] = _mm256_loadu_ps(out); \ r.m256[0] = _mm256_mul_ps(a.m256[0], IMDCT_sin_bt.m256[0]); \ \ a.m256[0] = _mm256_loadu_ps(rawout + _6i6); \ b.m256[0] = _mm256_add_ps(a.m256[0], r.m256[0]); \ _mm256_storeu_ps(rawout + _6i6, b.m256[0]); \ \ \ a.m128[0] = _mm_loadu_ps(out + 8); \ r.m128[0] = _mm_mul_ps(a.m128[0], IMDCT_sin_bt.m128[2]); \ \ a.m128[0] = _mm_loadu_ps(rawout + _6i6 + 8); \ b.m128[0] = _mm_add_ps(a.m128[0], r.m128[0]); \ _mm_storeu_ps(rawout + _6i6 + 8, b.m128[0]); \ } \ } \ else \ { \ _IMDCT_Long_AVX512F(in, rawout); \ \ for (uint16 i=0; i<32; i+=16) \ { \ a.m512 = _mm512_loadu_ps(rawout + i); \ r.m512 = _mm512_mul_ps(a.m512, IMDCT_sin_bt.m512[i>>4]); \ _mm512_storeu_ps(rawout + i, r.m512); \ } \ \ a.m128[0] = _mm_loadu_ps(rawout + 32); \ r.m128[0] = _mm_mul_ps(a.m128[0], IMDCT_sin_bt.m128[8]); \ _mm_storeu_ps(rawout + 32, r.m128[0]); \ } \ } #pragma endregion if (opt_AVX512F_only) // AVX512F CODE = ??%..??% time _ NOT TESTED { #pragma message ("ConvertMP3_HybridSynth : 512-bit AVX512F code not tested") for (uint16 subband = 0; subband < MP3SUBBANDS; subband++) { byte block_type = MPEGS.block_type[gr][ch]; uint16 level = subband * MP3LINES; float * store = storehs[subband]; // [18] if (subband < 2 && MPEGS.switch_flag[gr][ch] && MPEGS.mixed_block_flag[gr][ch]) block_type = 0; _IMDCT_AVX512F(level, block_type); //for (uint16 line = 0; line < 16; line += 16) // 16 = 4x4 (SSE) 8x2 (AVX) 16x1 (AVX256) { UNION512 a, b, r; a.m512 = _mm512_loadu_ps(rawout); // + line ); b.m512 = _mm512_loadu_ps(store); // + line ); r.m512 = _mm512_add_ps(a.m512, b.m512); _mm512_storeu_ps(sample + level, // + line, r.m512); } sample[level + 16] = rawout[16] + store[16]; sample[level + 17] = rawout[17] + store[17]; memcpy(store, rawout + MP3LINES, MP3LINES * sizeof(float)); } } else #endif // SIMPLE CODE = 100% time { for (uint16 subband = 0; subband < MP3SUBBANDS; subband++) { byte block_type = MPEGS.block_type[gr][ch]; uint16 level = subband * MP3LINES; float * store = storehs[subband]; // [18] if (subband < 2 && MPEGS.switch_flag[gr][ch] && MPEGS.mixed_block_flag[gr][ch]) block_type = 0; _IMDCT(level, block_type); for (uint16 line = 0; line < MP3LINES; line++) { sample[level + line] = rawout[line] + store[line]; //store[line] = rawout[line + MP3LINES]; // using memcpy instead } memcpy(store, rawout + MP3LINES, MP3LINES * sizeof(float)); } } #ifdef ENGINE_AVX512F #undef _IMDCT_Long_AVX512F #undef _IMDCT_AVX512F #endif #ifdef ENGINE_AVX #undef _IMDCT_Long_AVX #undef _IMDCT_AVX #endif #ifdef ENGINE_SSE #undef _IMDCT_Short_SSE #undef _IMDCT_9_SSE #undef _IMDCT_Long_SSE #undef _IMDCT_SSE #endif #undef _IMDCT_3 #undef _IMDCT_Short #undef _IMDCT_4 #undef _IMDCT_5 #undef _IMDCT_9 #undef _IMDCT_Long #undef _IMDCT } //>> 3.3. Инверсия семплов void ConvertMP3_FreqInversion(byte gr, byte ch) { float * sample = MPEGD.sample[gr][ch]; #ifdef ENGINE_AVX512F if (opt_AVX512F) // AVX512F CODE = ??%..??% time _ NOT TESTED { #pragma message ("ConvertMP3_FreqInversion : 512-bit AVX512F code not tested") UNION512 data, out; uint16 * idx = freqInvIdx; for (int i=0; i<9; i++) // 144 = 4 x36 (SSE) or 8 x18 (AVX) or 16 x9 (AVX-512F) { data.m512 = _mm512_set_ps ( sample[idx[15]], sample[idx[14]], sample[idx[13]], sample[idx[12]], sample[idx[11]], sample[idx[10]], sample[idx[9]], sample[idx[8]], sample[idx[7]], sample[idx[6]], sample[idx[5]], sample[idx[4]], sample[idx[3]], sample[idx[2]], sample[idx[1]], sample[idx[0]] ); out.m512 = _mm512_mul_ps(data.m512, freqInvMinus512.m512); sample[idx[15]] = out.f[15]; sample[idx[14]] = out.f[14]; sample[idx[13]] = out.f[13]; sample[idx[12]] = out.f[12]; sample[idx[11]] = out.f[11]; sample[idx[10]] = out.f[10]; sample[idx[9]] = out.f[9]; sample[idx[8]] = out.f[8]; sample[idx[7]] = out.f[7]; sample[idx[6]] = out.f[6]; sample[idx[5]] = out.f[5]; sample[idx[4]] = out.f[4]; sample[idx[3]] = out.f[3]; sample[idx[2]] = out.f[2]; sample[idx[1]] = out.f[1]; sample[idx[0]] = out.f[0]; idx += 16; } } else #endif #ifdef ENGINE_AVX if (opt_AVX) // AVX CODE = ??%..??% time _ NOT TESTED { #pragma message ("ConvertMP3_FreqInversion : 256-bit AVX code not tested") UNION256 data, out; uint16 * idx = freqInvIdx; for (int i=0; i<18; i++) // 144 = 4 x36 (SSE) or 8 x18 (AVX) or 16 x9 (AVX-512F) { data.m256 = _mm256_set_ps ( sample[idx[7]], sample[idx[6]], sample[idx[5]], sample[idx[4]], sample[idx[3]], sample[idx[2]], sample[idx[1]], sample[idx[0]] ); out.m256 = _mm256_mul_ps(data.m256, freqInvMinus256.m256); sample[idx[7]] = out.f[7]; sample[idx[6]] = out.f[6]; sample[idx[5]] = out.f[5]; sample[idx[4]] = out.f[4]; sample[idx[3]] = out.f[3]; sample[idx[2]] = out.f[2]; sample[idx[1]] = out.f[1]; sample[idx[0]] = out.f[0]; idx += 8; } } else #endif #ifdef ENGINE_SSE if (opt_SSE) // SSE CODE = 80%..90% time { // r.m128 = _mm_set_ps(a_store[3], a_store[2], a_store[1], a_store[0]); // r.m128 = _mm_loadu_ps(a_store); // r.m128 = _mm_mul_ps(a.m128, b.m128); // _mm_storeu_ps(a_store, r.m128); UNION128 data, out; uint16 * idx = freqInvIdx; for (int i=0; i<36; i++) // 144 = 4 x36 (SSE) or 8 x18 (AVX) or 16 x9 (AVX-512F) { data.m128 = _mm_set_ps ( sample[idx[3]], sample[idx[2]], sample[idx[1]], sample[idx[0]] ); out.m128 = _mm_mul_ps(data.m128, freqInvMinus128.m128); sample[idx[3]] = out.f[3]; sample[idx[2]] = out.f[2]; sample[idx[1]] = out.f[1]; sample[idx[0]] = out.f[0]; idx += 4; } } else #endif // SIMPLE CODE = 100% time { //for (uint16 subband = 1; subband < MP3SUBBANDS; subband += 2) //{ // uint16 level = subband * MP3LINES; // for (uint16 line = 1; line < MP3LINES; line += 2) // { // uint16 level_line = level + line; // sample[level_line] = -sample[level_line]; // } //} for (int i = 0; i < MP3FREQINV; i++) { auto & s = sample[ freqInvIdx[i] ]; s = -s; } } } //>> 3.4. Синтезирование полифазного набора фильтров void ConvertMP3_SubbandSynth_simple(byte gr, byte ch, bool mono, uint32 result_granule[MP3GRS]) { float synthesis [MP3SYNTHESIS]; float * storess = this->storess[ch]; // store ss [1024] = [16][64] float * sample = MPEGD.sample[gr][ch]; // sample [576] for (uint16 line = 0; line < MP3LINES; line++) { for (uint16 i = MP3SYNTHESIS * 2 - 1; i > MP3SUBBANDS * 2 - 1; i--) storess[i] = storess[i - MP3SUBBANDS * 2]; for (uint16 subband = 0; subband < MP3SUBBANDS; subband++) synthesis[subband] = sample[subband * MP3LINES + line]; for (uint16 i = 0; i < MP3SUBBANDS * 2; i++) { float sum = 0; for (uint16 j = 0; j < MP3SUBBANDS; j++) sum += synthesis_tab[i][j] * synthesis[j]; storess[i] = sum; } for (uint16 i = 0; i < 8; i++) for (uint16 j = 0; j < 32; j++) { // i * 64 i * 128 synthesis[(i << 6) + j] = storess[(i << 7) + j]; synthesis[(i << 6) + j + 32] = storess[(i << 7) + j + 96]; } for (uint16 i = 0; i < MP3SYNTHESIS; i++) synthesis[i] *= subband_synthesis_table[i]; /* Calculate 32 samples and store them in the outdata vector */ for (uint16 subband = 0; subband < MP3SUBBANDS; subband++) { float sum = 0; for (uint16 j = 0; j < 16; j++) { // j * 32 sum += synthesis[(j << 5) + subband]; } int32 samp = (int32)(sum * MASK_INT16_MAX); if (samp > MASK_INT16_MAX) samp = MASK_INT16_MAX; else if (samp < -MASK_INT16_MAX) samp = -MASK_INT16_MAX; samp &= MASK_INT16; if (!ch) { if (mono) result_granule [32 * line + subband] = (samp << 16) | samp; else result_granule [32 * line + subband] = samp; } else result_granule [32 * line + subband] |= samp << 16; } } } //>> 3.4. Синтезирование полифазного набора фильтров - fast ver. void ConvertMP3_SubbandSynth(byte gr, byte ch, bool mono, uint32 result_granule[MP3GRS], uint32 skip_samples) { float synthesis [MP3SYNTHESIS]; auto & storess_pos = this->storess_pos[ch]; // 0..15 float * storess = this->storess[ch]; // store sub synth [1024] = [16][64] float * sample = MPEGD.sample[gr][ch]; // sample [576] auto DCT2 = [] (float* in, float* out) -> void { int i, j; for (i = 0; i < 2; i++) { out[i] = 0; for (j = 0; j < 2; j++) { out[i] += in[j] * cosij[i][j]; } } }; auto DCT4 = [DCT2] (float* in, float* out) -> void { const int N = 4; const int N2 = N >> 1; int i; float even_in[N2], even_out[N2], odd_in[N2], odd_out[N2]; for (i = 0; i < N2; i++) even_in[i] = in[i] + in[N - 1 - i]; DCT2(even_in, even_out); for (i = 0; i < N2; i++) odd_in[i] = (in[i] - in[N - 1 - i]) * form_2_4[i]; DCT2(odd_in, odd_out); for (i = 0; i < N2; i++) out[2 * i] = even_out[i]; for (i = 0; i < N2 - 1; i++) out[2 * i + 1] = odd_out[i] + odd_out[i + 1]; out[N - 1] = odd_out[N2 - 1]; }; auto DCT8 = [DCT4] (float* in, float* out) -> void { const int N = 8; const int N2 = N >> 1; int i; float even_in[N2], even_out[N2], odd_in[N2], odd_out[N2]; for (i = 0; i < N2; i++) even_in[i] = in[i] + in[N - 1 - i]; DCT4(even_in, even_out); for (i = 0; i < N2; i++) odd_in[i] = (in[i] - in[N - 1 - i]) * form_4_8[i]; DCT4(odd_in, odd_out); for (i = 0; i < N2; i++) out[2 * i] = even_out[i]; for (i = 0; i < N2 - 1; i++) out[2 * i + 1] = odd_out[i] + odd_out[i + 1]; out[N - 1] = odd_out[N2 - 1]; }; auto DCT16 = [DCT8] (float* in, float* out) -> void { const int N = 16; const int N2 = N >> 1; int i; float even_in[N2], even_out[N2], odd_in[N2], odd_out[N2]; for (i = 0; i < N2; i++) even_in[i] = in[i] + in[N - 1 - i]; DCT8(even_in, even_out); for (i = 0; i < N2; i++) odd_in[i] = (in[i] - in[N - 1 - i]) * form_8_16[i]; DCT8(odd_in, odd_out); for (i = 0; i < N2; i++) out[2 * i] = even_out[i]; for (i = 0; i < N2 - 1; i++) out[2 * i + 1] = odd_out[i] + odd_out[i + 1]; out[N - 1] = odd_out[N2 - 1]; }; auto DCT32 = [DCT16] (float* in, float* out) -> void { const int N = 32; const int N2 = N >> 1; int i; float even_in[N2], even_out[N2], odd_in[N2], odd_out[N2]; for (i = 0; i < N2; i++) even_in[i] = in[i] + in[N - 1 - i]; DCT16(even_in, even_out); for (i = 0; i < N2; i++) odd_in[i] = (in[i] - in[N - 1 - i]) * form_16_32[i]; DCT16(odd_in, odd_out); for (i = 0; i < N2; i++) out[2 * i] = even_out[i]; for (i = 0; i < N2 - 1; i++) out[2 * i + 1] = odd_out[i] + odd_out[i + 1]; out[N - 1] = odd_out[N2 - 1]; }; auto DCT_2pt = [] (float in[2], float out[2]) -> void { int i, j; for (i = 0; i < 2; i++) { out[i] = 0; for (j = 0; j < 2; j++) { out[i] += in[j] * cosij[i][j]; } } }; std::function<void(float*,float*,int)> DCT = [&, DCT_2pt] (float* in, float* out, int N) { // N = [32, 16, 8, 4, 2] // 4 2 1 0 int i, N8 = N >> 3, N2 = N >> 1; float even_in[16], even_out[16], odd_in[16], odd_out[16]; static const float * form[5] = { form_2_4, form_4_8, form_8_16, 0, form_16_32 }; if (N == 2) { DCT_2pt(in, out); return; } for (i = 0; i < N2; i++) even_in[i] = in[i] + in[N - 1 - i]; DCT(even_in, even_out, N2); // for (i = 0; i < N_half; i++) // odd_in[i] = (in[i] - in[N - 1 - i]) * POST_TWIDDLE(i, N); for (i = 0; i < N2; i++) odd_in[i] = (in[i] - in[N - 1 - i]) * form[N8][i]; DCT(odd_in, odd_out, N2); for (i = 0; i < N2; i++) out[2 * i] = even_out[i]; for (i = 0; i < N2 - 1; i++) out[2 * i + 1] = odd_out[i] + odd_out[i + 1]; out[N - 1] = odd_out[N2 - 1]; }; auto PolyphaseMatrixing = [DCT, DCT32](float in[32], float out[64]) -> void { int i; float tmp[32]; //DCT(in, tmp, 32); DCT32(in, tmp); out[16] = 0; for (i = 0; i < 16; i++) out[i] = tmp[i + 16]; for (i = 17; i < 32; i++) out[i] = -tmp[48 - i]; for (i = 32; i < 48; i++) out[i] = -tmp[48 - i]; for (i = 48; i < 64; i++) out[i] = -tmp[i - 48]; }; #pragma region <DCT2> #define _DCT2(in, out) { \ int i, j; \ \ for (i = 0; i < 2; i++) \ { \ out[i] = 0; \ for (j = 0; j < 2; j++) \ { \ out[i] += in[j] * cosij[i][j]; \ } \ } \ } #pragma endregion #pragma region <DCT4> #define _DCT4(in, out) { \ int i; \ float even_in2[2], even_out2[2]; \ float odd_in2[2], odd_out2[2]; \ \ for (i = 0; i < 2; i++) \ even_in2[i] = in[i] + in[3 - i]; \ \ _DCT2(even_in2, even_out2); \ \ for (i = 0; i < 2; i++) \ odd_in2[i] = (in[i] - in[3 - i]) * form_2_4[i]; \ \ _DCT2(odd_in2, odd_out2); \ \ for (i = 0; i < 2; i++) \ out[2 * i] = even_out2[i]; \ \ for (i = 0; i < 1; i++) \ out[2 * i + 1] = odd_out2[i] + odd_out2[i + 1]; \ \ out[3] = odd_out2[1]; \ } #pragma endregion #pragma region <DCT8> #define _DCT8(in, out) { \ int i; \ float even_in4[4], even_out4[4]; \ float odd_in4[4], odd_out4[4]; \ \ for (i = 0; i < 4; i++) \ even_in4[i] = in[i] + in[7 - i]; \ \ _DCT4(even_in4, even_out4); \ \ for (i = 0; i < 4; i++) \ odd_in4[i] = (in[i] - in[7 - i]) * form_4_8[i]; \ \ _DCT4(odd_in4, odd_out4); \ \ for (i = 0; i < 4; i++) \ out[2 * i] = even_out4[i]; \ \ for (i = 0; i < 3; i++) \ out[2 * i + 1] = odd_out4[i] + odd_out4[i + 1]; \ \ out[7] = odd_out4[3]; \ } #pragma endregion #pragma region <DCT16> #define _DCT16(in, out) { \ int i; \ float even_in8[8], even_out8[8]; \ float odd_in8[8], odd_out8[8]; \ \ for (i = 0; i < 8; i++) \ even_in8[i] = in[i] + in[15 - i]; \ \ DCT8(even_in8, even_out8); \ \ for (i = 0; i < 8; i++) \ odd_in8[i] = (in[i] - in[15 - i]) * form_8_16[i]; \ \ DCT8(odd_in8, odd_out8); \ \ for (i = 0; i < 8; i++) \ out[2 * i] = even_out8[i]; \ \ for (i = 0; i < 7; i++) \ out[2 * i + 1] = odd_out8[i] + odd_out8[i + 1]; \ \ out[15] = odd_out8[7]; \ } #pragma endregion #pragma region <DCT32> #define _DCT32(in, out) { \ int i; \ float even_in[16], even_out[16]; \ float odd_in[16], odd_out[16]; \ \ for (i = 0; i < 16; i++) \ even_in[i] = in[i] + in[32 - 1 - i]; \ \ _DCT16(even_in, even_out); \ \ for (i = 0; i < 16; i++) \ odd_in[i] = (in[i] - in[31 - i]) * form_16_32[i]; \ \ _DCT16(odd_in, odd_out); \ \ for (i = 0; i < 16; i++) \ out[2 * i] = even_out[i]; \ \ for (i = 0; i < 15; i++) \ out[2 * i + 1] = odd_out[i] + odd_out[i + 1]; \ \ out[31] = odd_out[15]; \ } #pragma endregion #pragma region <PolyphaseMatrixing> #define _PolyphaseMatrixing(in, out) { \ int i; \ float tmp[32]; \ \ _DCT32(in, tmp); \ \ out[16] = 0; \ \ memcpy(out, tmp + 16, 16 * sizeof(float)); \ for (i = 17; i < 32; i++) out[i] = -tmp[48 - i]; \ for (i = 32; i < 48; i++) out[i] = -tmp[48 - i]; \ for (i = 48; i < 64; i++) out[i] = -tmp[i - 48]; \ } #pragma endregion #pragma region <CalcSamples> #define _CalcSamples { \ \ uint32 shift_line = MP3SUBBANDS * line; \ uint32 * result_gr = result_granule + shift_line - skip_samples; \ \ for (uint16 subband = 0; subband < MP3SUBBANDS; subband++) \ { \ UFLOAT out = 0; \ \ for (uint16 j = 0; j < 16; j++) \ out.f32 += synthesis[(j << 5) + subband]; \ \ out.i32 = (int32)(out.f32 * MASK_INT16_MAX); \ \ if (out.i32 > MASK_INT16_MAX) out.i32 = MASK_INT16_MAX; \ else if (out.i32 < -MASK_INT16_MAX) out.i32 = -MASK_INT16_MAX; \ \ out.i32 &= MASK_INT16; \ \ if (shift_line + subband >= skip_samples) \ if (!ch) \ { \ if (mono) result_gr [subband] = (out.i32 << 16) | out.i32; \ else result_gr [subband] = out.i32; \ } else result_gr [subband] |= out.i32 << 16; \ } \ } #pragma endregion #ifdef ENGINE_SSE #pragma region <DCT8_SSE> #define _DCT8_SSE(in, out) { \ int i; \ float even_in4[4], even_out4[4]; \ float odd_in4[4], odd_out4[4]; \ UNION128 a, b, r; \ \ a.m128 = _mm_loadu_ps(in); \ b.m128 = _mm_set_ps ( in[4], in[5], in[6], in[7] ); \ \ r.m128 = _mm_add_ps(a.m128, b.m128); \ _mm_storeu_ps(even_in4, r.m128); \ \ r.m128 = _mm_sub_ps(a.m128, b.m128); \ a.m128 = _mm_mul_ps(r.m128, u_form_4_8.m128); \ _mm_storeu_ps(odd_in4, a.m128); \ \ _DCT4(even_in4, even_out4); \ _DCT4(odd_in4, odd_out4); \ \ for (i = 0; i < 4; i++) \ out[2 * i] = even_out4[i]; \ \ for (i = 0; i < 3; i++) \ out[2 * i + 1] = odd_out4[i] + odd_out4[i + 1]; \ \ out[7] = odd_out4[3]; \ } #pragma endregion #pragma region <DCT16_SSE> #define _DCT16_SSE(in, out) { \ int i; \ float even_in8[8], even_out8[8]; \ float odd_in8[8], odd_out8[8]; \ UNION128 a, b, r; \ \ for (i = 0; i < 8; i += 4) \ { \ a.m128 = _mm_loadu_ps(in + i); \ b.m128 = _mm_set_ps ( \ in[12-i], in[13-i], in[14-i], in[15-i] ); \ \ r.m128 = _mm_add_ps(a.m128, b.m128); \ _mm_storeu_ps(even_in8 + i, r.m128); \ \ r.m128 = _mm_sub_ps(a.m128, b.m128); \ a.m128 = _mm_mul_ps(r.m128, u_form_8_16.m128[i>>2]); \ _mm_storeu_ps(odd_in8 + i, a.m128); \ } \ \ _DCT8_SSE(even_in8, even_out8); \ _DCT8_SSE(odd_in8, odd_out8); \ \ for (i = 0; i < 8; i++) \ out[2 * i] = even_out8[i]; \ \ a.m128 = _mm_loadu_ps(odd_out8); \ b.m128 = _mm_loadu_ps(odd_out8 + 1); \ r.m128 = _mm_add_ps(a.m128, b.m128); \ out[1] = r.f[0]; \ out[3] = r.f[1]; \ out[5] = r.f[2]; \ out[7] = r.f[3]; \ \ for (i = 4; i < 7; i++) \ out[2 * i + 1] = odd_out8[i] + odd_out8[i + 1]; \ \ out[15] = odd_out8[7]; \ } #pragma endregion #pragma region <DCT32_SSE> #define _DCT32_SSE(in, out) { \ int i; \ float even_in[16], even_out[16]; \ float odd_in[16], odd_out[16]; \ UNION128 a, b, r; \ \ for (i = 0; i < 16; i += 4) \ { \ a.m128 = _mm_loadu_ps(in + i); \ b.m128 = _mm_set_ps ( \ in[28-i], in[29-i], in[30-i], in[31-i] ); \ \ r.m128 = _mm_add_ps(a.m128, b.m128); \ _mm_storeu_ps(even_in + i, r.m128); \ \ r.m128 = _mm_sub_ps(a.m128, b.m128); \ a.m128 = _mm_mul_ps(r.m128, u_form_16_32.m128[i>>2]); \ _mm_storeu_ps(odd_in + i, a.m128); \ } \ \ _DCT16_SSE(odd_in, odd_out); \ _DCT16_SSE(even_in, even_out); \ \ for (i = 0; i < 16; i++) \ out[2 * i] = even_out[i]; \ \ for (i = 0; i < 12; i += 4) \ { \ a.m128 = _mm_loadu_ps(odd_out + i); \ b.m128 = _mm_loadu_ps(odd_out + i + 1); \ r.m128 = _mm_add_ps(a.m128, b.m128); \ out[2 * i + 1] = r.f[0]; \ out[2 * (i + 1) + 1] = r.f[1]; \ out[2 * (i + 2) + 1] = r.f[2]; \ out[2 * (i + 3) + 1] = r.f[3]; \ } \ \ for (i = 12; i < 15; i++) \ out[2 * i + 1] = odd_out[i] + odd_out[i + 1]; \ \ out[31] = odd_out[15]; \ } #pragma endregion #pragma region <PolyphaseMatrixing_SSE> #define _PolyphaseMatrixing_SSE(in, out) { \ int i; \ float tmp[32]; \ \ _DCT32_SSE(in, tmp); \ \ out[16] = 0; \ \ memcpy(out, tmp + 16, 16 * sizeof(float)); \ for (i = 17; i < 32; i++) out[i] = -tmp[48 - i]; \ for (i = 32; i < 48; i++) out[i] = -tmp[48 - i]; \ for (i = 48; i < 64; i++) out[i] = -tmp[i - 48]; \ } #pragma endregion if (opt_SSE_only) // SSE CODE = 79%..83% time { for (uint16 line = 0; line < MP3LINES; line++) { --storess_pos &= 0xF; // [0..15] for (uint16 subband = 0; subband < MP3SUBBANDS; subband++) synthesis[subband] = sample[subband * MP3LINES + line]; { float * store64 = storess + (storess_pos << 6); // + (storess_pos * 64) _PolyphaseMatrixing_SSE(synthesis, store64); } for (uint16 i = 0; i < 8; i++) // [16][64] = { 0, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960 } (1024) { float * synthesis_1 = synthesis + (i << 6); // i * 64 float * synthesis_2 = synthesis + (i << 6) + 32; // i * 64 + 32 // float * storess_1 = storess + (i << 7); // i * 128 0, 128, 256, 384, 512, 640, 768, 896, (1024) // float * storess_2 = storess + (i << 7) + 96; // i * 128 + 96 96, 224, 352, 480, 608, 736, 864, 992 float * storess_1 = storess + (((storess_pos << 6) + (i << 7) ) % 1024); // storess[1024] float * storess_2 = storess + (((storess_pos << 6) + (i << 7) + 96) % 1024); // storess[1024] auto table_1 = subband_synthesis_table + (i << 6); auto table_2 = subband_synthesis_table + (i << 6) + 32; for (uint16 j = 0; j < MP3SUBBANDS; j += 4) // 32 = 4 x8 (SSE), 8 x4 (AVX), 16 x2 (AVX512F) { UNION128 a, b, r; a.m128 = _mm_loadu_ps(storess_1 + j); // synthesis_1[j] = storess_1[j] * table_1[j]; b.m128 = _mm_loadu_ps(table_1 + j); r.m128 = _mm_mul_ps(a.m128, b.m128); _mm_storeu_ps(synthesis_1 + j, r.m128); a.m128 = _mm_loadu_ps(storess_2 + j); // synthesis_2[j] = storess_2[j] * table_2[j]; b.m128 = _mm_loadu_ps(table_2 + j); r.m128 = _mm_mul_ps(a.m128, b.m128); _mm_storeu_ps(synthesis_2 + j, r.m128); } } _CalcSamples; } } else #endif #ifdef ENGINE_AVX #pragma region <DCT16_AVX> #define _DCT16_AVX(in, out) { \ int i; \ float even_in8[8], even_out8[8]; \ float odd_in8[8], odd_out8[8]; \ UNION256 a, b, r; \ \ a.m256 = _mm256_loadu_ps(in); \ b.m256 = _mm256_set_ps ( \ in[8], in[9], in[10], in[11], \ in[12], in[13], in[14], in[15] ); \ \ r.m256 = _mm256_add_ps(a.m256, b.m256); \ _mm256_storeu_ps(even_in8, r.m256); \ \ r.m256 = _mm256_sub_ps(a.m256, b.m256); \ a.m256 = _mm256_mul_ps(r.m256, u_form_8_16.m256); \ _mm256_storeu_ps(odd_in8, a.m256); \ \ _DCT8_SSE(even_in8, even_out8); \ _DCT8_SSE(odd_in8, odd_out8); \ \ for (i = 0; i < 8; i++) \ out[2 * i] = even_out8[i]; \ \ a.m128[0] = _mm_loadu_ps(odd_out8); \ b.m128[0] = _mm_loadu_ps(odd_out8 + 1); \ r.m128[0] = _mm_add_ps(a.m128[0], b.m128[0]); \ out[1] = r.f[0]; \ out[3] = r.f[1]; \ out[5] = r.f[2]; \ out[7] = r.f[3]; \ \ for (i = 4; i < 7; i++) \ out[2 * i + 1] = odd_out8[i] + odd_out8[i + 1]; \ \ out[15] = odd_out8[7]; \ } #pragma endregion #pragma region <DCT32_AVX> #define _DCT32_AVX(in, out) { \ int i; \ float even_in[16], even_out[16]; \ float odd_in[16], odd_out[16]; \ UNION256 a, b, r; \ \ for (i = 0; i < 16; i += 8) \ { \ a.m256 = _mm256_loadu_ps(in + i); \ b.m256 = _mm256_set_ps ( \ in[24-i], in[25-i], in[26-i], in[27-i], \ in[28-i], in[29-i], in[30-i], in[31-i] ); \ \ r.m256 = _mm256_add_ps(a.m256, b.m256); \ _mm256_storeu_ps(even_in + i, r.m256); \ \ r.m256 = _mm256_sub_ps(a.m256, b.m256); \ a.m256 = _mm256_mul_ps(r.m256, u_form_16_32.m256[i>>3]); \ _mm256_storeu_ps(odd_in + i, a.m256); \ } \ \ _DCT16_AVX(even_in, even_out); \ _DCT16_AVX(odd_in, odd_out); \ \ for (i = 0; i < 16; i++) \ out[2 * i] = even_out[i]; \ \ a.m256 = _mm256_loadu_ps(odd_out); \ b.m256 = _mm256_loadu_ps(odd_out + 1); \ r.m256 = _mm256_add_ps(a.m256, b.m256); \ for (i = 0; i < 8; i++) \ out[2 * i + 1] = r.f[i]; \ \ a.m128[0] = _mm_loadu_ps(odd_out + 8); \ b.m128[0] = _mm_loadu_ps(odd_out + 9); \ r.m128[0] = _mm_add_ps(a.m128[0], b.m128[0]); \ out[2 * 8 + 1] = r.f[0]; \ out[2 * 9 + 1] = r.f[1]; \ out[2 * 10 + 1] = r.f[2]; \ out[2 * 11 + 1] = r.f[3]; \ \ for (i = 12; i < 15; i++) \ out[2 * i + 1] = odd_out[i] + odd_out[i + 1]; \ \ out[31] = odd_out[15]; \ } #pragma endregion #pragma region <PolyphaseMatrixing_AVX> #define _PolyphaseMatrixing_AVX(in, out) { \ int i; \ float tmp[32]; \ \ _DCT32_AVX(in, tmp); \ \ out[16] = 0; \ \ memcpy(out, tmp + 16, 16 * sizeof(float)); \ for (i = 17; i < 32; i++) out[i] = -tmp[48 - i]; \ for (i = 32; i < 48; i++) out[i] = -tmp[48 - i]; \ for (i = 48; i < 64; i++) out[i] = -tmp[i - 48]; \ } #pragma endregion if (opt_AVX_only) // AVX CODE = ??%..??% time _ NOT TESTED { #pragma message ("ConvertMP3_SubbandSynth : 256-bit AVX code not tested") for (uint16 line = 0; line < MP3LINES; line++) { --storess_pos &= 0xF; // [0..15] for (uint16 subband = 0; subband < MP3SUBBANDS; subband++) synthesis[subband] = sample[subband * MP3LINES + line]; { float * store64 = storess + (storess_pos << 6); // + (storess_pos * 64) _PolyphaseMatrixing_AVX(synthesis, store64); } for (uint16 i = 0; i < 8; i++) // [16][64] = { 0, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960 } (1024) { float * synthesis_1 = synthesis + (i << 6); // i * 64 float * synthesis_2 = synthesis + (i << 6) + 32; // i * 64 + 32 // float * storess_1 = storess + (i << 7); // i * 128 0, 128, 256, 384, 512, 640, 768, 896, (1024) // float * storess_2 = storess + (i << 7) + 96; // i * 128 + 96 96, 224, 352, 480, 608, 736, 864, 992 float * storess_1 = storess + (((storess_pos << 6) + (i << 7) ) % 1024); // storess[1024] float * storess_2 = storess + (((storess_pos << 6) + (i << 7) + 96) % 1024); // storess[1024] auto table_1 = subband_synthesis_table + (i << 6); auto table_2 = subband_synthesis_table + (i << 6) + 32; for (uint16 j = 0; j < MP3SUBBANDS; j += 8) // 32 = 4 x8 (SSE), 8 x4 (AVX), 16 x2 (AVX512F) { UNION256 a, b, r; a.m256 = _mm256_loadu_ps(storess_1 + j); // synthesis_1[j] = storess_1[j] * table_1[j]; b.m256 = _mm256_loadu_ps(table_1 + j); r.m256 = _mm256_mul_ps(a.m256, b.m256); _mm256_storeu_ps(synthesis_1 + j, r.m256); a.m256 = _mm256_loadu_ps(storess_2 + j); // synthesis_2[j] = storess_2[j] * table_2[j]; b.m256 = _mm256_loadu_ps(table_2 + j); r.m256 = _mm256_mul_ps(a.m256, b.m256); _mm256_storeu_ps(synthesis_2 + j, r.m256); } } _CalcSamples; } } else #endif #ifdef ENGINE_AVX512F #pragma region <DCT32_AVX512F> #define _DCT32_AVX512F(in, out) { \ int i; \ float even_in[16], even_out[16]; \ float odd_in[16], odd_out[16]; \ UNION512 a, b, r; \ \ a.m512 = _mm512_loadu_ps(in); \ b.m512 = _mm512_set_ps ( \ in[16], in[17], in[18], in[19], \ in[20], in[21], in[22], in[23], \ in[24], in[25], in[26], in[27], \ in[28], in[29], in[30], in[31] ); \ \ r.m512 = _mm512_add_ps(a.m512, b.m512); \ _mm512_storeu_ps(even_in, r.m512); \ \ r.m512 = _mm512_sub_ps(a.m512, b.m512); \ a.m512 = _mm512_mul_ps(r.m512, u_form_16_32.m512); \ _mm512_storeu_ps(odd_in, a.m256); \ \ _DCT16_AVX(even_in, even_out); \ _DCT16_AVX(odd_in, odd_out); \ \ for (i = 0; i < 16; i++) \ out[2 * i] = even_out[i]; \ \ a.m256[0] = _mm256_loadu_ps(odd_out); \ b.m256[0] = _mm256_loadu_ps(odd_out + 1); \ r.m256[0] = _mm256_add_ps(a.m256[0], b.m256[0]); \ for (i = 0; i < 8; i++) \ out[2 * i + 1] = r.f[i]; \ \ a.m128[0] = _mm_loadu_ps(odd_out + 8); \ b.m128[0] = _mm_loadu_ps(odd_out + 9); \ r.m128[0] = _mm_add_ps(a.m128[0], b.m128[0]); \ out[2 * 8 + 1] = r.f[0]; \ out[2 * 9 + 1] = r.f[1]; \ out[2 * 10 + 1] = r.f[2]; \ out[2 * 11 + 1] = r.f[3]; \ \ for (i = 12; i < 15; i++) \ out[2 * i + 1] = odd_out[i] + odd_out[i + 1]; \ \ out[31] = odd_out[15]; \ } #pragma endregion #pragma region <PolyphaseMatrixing_AVX512F> #define _PolyphaseMatrixing_AVX512F(in, out) { \ int i; \ float tmp[32]; \ \ _DCT32_AVX512F(in, tmp); \ \ out[16] = 0; \ \ memcpy(out, tmp + 16, 16 * sizeof(float)); \ for (i = 17; i < 32; i++) out[i] = -tmp[48 - i]; \ for (i = 32; i < 48; i++) out[i] = -tmp[48 - i]; \ for (i = 48; i < 64; i++) out[i] = -tmp[i - 48]; \ } #pragma endregion if (opt_AVX512F_only) // AVX512F CODE = ??%..??% time _ NOT TESTED { #pragma message ("ConvertMP3_SubbandSynth : 512-bit AVX512F code not tested") for (uint16 line = 0; line < MP3LINES; line++) { --storess_pos &= 0xF; // [0..15] for (uint16 subband = 0; subband < MP3SUBBANDS; subband++) synthesis[subband] = sample[subband * MP3LINES + line]; { float * store64 = storess + (storess_pos << 6); // + (storess_pos * 64) _PolyphaseMatrixing_AVX512F(synthesis, store64); } for (uint16 i = 0; i < 8; i++) // [16][64] = { 0, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960 } (1024) { float * synthesis_1 = synthesis + (i << 6); // i * 64 float * synthesis_2 = synthesis + (i << 6) + 32; // i * 64 + 32 // float * storess_1 = storess + (i << 7); // i * 128 0, 128, 256, 384, 512, 640, 768, 896, (1024) // float * storess_2 = storess + (i << 7) + 96; // i * 128 + 96 96, 224, 352, 480, 608, 736, 864, 992 float * storess_1 = storess + (((storess_pos << 6) + (i << 7) ) % 1024); // storess[1024] float * storess_2 = storess + (((storess_pos << 6) + (i << 7) + 96) % 1024); // storess[1024] auto table_1 = subband_synthesis_table + (i << 6); auto table_2 = subband_synthesis_table + (i << 6) + 32; for (uint16 j = 0; j < MP3SUBBANDS; j += 16) // 32 = 4 x8 (SSE), 8 x4 (AVX), 16 x2 (AVX512F) { UNION512 a, b, r; a.m512 = _mm512_loadu_ps(storess_1 + j); // synthesis_1[j] = storess_1[j] * table_1[j]; b.m512 = _mm512_loadu_ps(table_1 + j); r.m512 = _mm512_mul_ps(a.m512, b.m512); _mm512_storeu_ps(synthesis_1 + j, r.m512); a.m512 = _mm512_loadu_ps(storess_2 + j); // synthesis_2[j] = storess_2[j] * table_2[j]; b.m512 = _mm512_loadu_ps(table_2 + j); r.m512 = _mm512_mul_ps(a.m256, b.m256); _mm512_storeu_ps(synthesis_2 + j, r.m512); } } _CalcSamples; } } else #endif // SIMPLE CODE = 100% time { for (uint16 line = 0; line < MP3LINES; line++) { --storess_pos &= 0xF; // [0..15] for (uint16 subband = 0; subband < MP3SUBBANDS; subband++) synthesis[subband] = sample[subband * MP3LINES + line]; { float * store64 = storess + (storess_pos << 6); // + (storess_pos * 64) _PolyphaseMatrixing(synthesis, store64); } for (uint16 i = 0; i < 8; i++) // [16][64] = { 0, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960 } (1024) { float * synthesis_1 = synthesis + (i << 6); // i * 64 float * synthesis_2 = synthesis + (i << 6) + 32; // i * 64 + 32 // float * storess_1 = storess + (i << 7); // i * 128 0, 128, 256, 384, 512, 640, 768, 896, (1024) // float * storess_2 = storess + (i << 7) + 96; // i * 128 + 96 96, 224, 352, 480, 608, 736, 864, 992 float * storess_1 = storess + (((storess_pos << 6) + (i << 7) ) % 1024); // storess[1024] float * storess_2 = storess + (((storess_pos << 6) + (i << 7) + 96) % 1024); // storess[1024] auto table_1 = subband_synthesis_table + (i << 6); auto table_2 = subband_synthesis_table + (i << 6) + 32; for (uint16 j = 0; j < MP3SUBBANDS; j++) { synthesis_1[j] = storess_1[j] * table_1[j]; synthesis_2[j] = storess_2[j] * table_2[j]; } } _CalcSamples; } } #ifdef ENGINE_AVX512F #undef _PolyphaseMatrixing_AVX512F #undef _DCT32_AVX512F #endif #ifdef ENGINE_AVX #undef _PolyphaseMatrixing_AVX #undef _DCT32_AVX #undef _DCT16_AVX #endif #ifdef ENGINE_SSE #undef _PolyphaseMatrixing_SSE #undef _DCT32_SSE #undef _DCT16_SSE #undef _DCT8_SSE #endif #undef _CalcSamples #undef _PolyphaseMatrixing #undef _DCT32 #undef _DCT16 #undef _DCT8 #undef _DCT4 #undef _DCT2 } //>> [MAIN] bool ConvertMP3() { uint32 frames = 0; // total frames counter uint32 frames_skipped = 0; // skipped frames counter uint32 frames_loop = start_frame; // frame # in loop byte * result_granule = settings.out.data_out; // out data ptr for current frame bool padding_enable = false; // do 'before' padding or not uint32 padding_skip_counter = 0; // total skipped samples (by LAME padding) for (; frames < stop_frame; frames++, frames_loop++) { ////////////// HANDLE PADDING /////////////// if (frames_loop == 1) { padding_b = padding_before; // update for a new loop round if (padding_after) { // ЗАМЕТКА надеюсь в конце не бывает мусорных фреймов, иначе стоит // взять (MPEGD.lame.XING.frames + 1) вместо (total_frames) // calc 'after' frame # (start of end padding) padding_a_frame = total_frames - (padding_after / MP31152) - 1; // calc how many samples to save at 'after' frame padding_a = (total_frames - padding_a_frame) * MP31152 - padding_after; } } if ( padding_b && (frames_loop == 1 || // first start frame OR frames_loop == padding_b_frame + 1) // next frame in chain (continue) ) { padding_enable = true; padding_b_frame = frames_loop; // mem this frame } else // break chain of frames & disable 'before' padding { padding_enable = false; padding_b_frame = 0; padding_b = 0; } ////////////// LOOP CONDITION /////////////// if (frames_loop == total_frames) { frames_loop = 0; // reset runner runner.p = settings.in.data; runner.end = runner.p + settings.in.size; runner.pos = 0; runner.last = settings.in.size; // reset static data ZeroMemory(storehs, sizeof(storehs)); ZeroMemory(storess, sizeof(storess)); ZeroMemory(storess_pos, sizeof(storess_pos)); MPEGD._Reset_fast(); } ///////////////////// READING ///////////////////// uint32 mem_start_pos = runner.pos; if (!MPEG._Read(runner.p, runner.last)) // EOF break; if (!MPEG.RUNFRAMECALC()) // incorrect frame data (MP3 DONE) break; // move to side info RunnerOffset(MPG_SIZE + MPEG.FRAME.crc); // local runner byte * local_ptr = runner.p; byte local_bit = 0; MPEGS._Read(local_ptr, local_bit, MPEG_p); // ERROR : this can't be //if (MPEG.FRAME.side != (local_ptr - runner.p)) // break; // ERROR : this can't be //if (local_bit != 0) // { printf("\nlocal.bit != 0"); getchar(); } //break; // move to mpeg main data RunnerOffset(MPEG.FRAME.side); //MPEGD.offset = runner.from.pos; // debug uint32 MPEGDStatus = MPEGD._Read(local_ptr, local_bit, MPEG_p, MPEGS_p); // move to next frame RunnerShift(mem_start_pos + MPEG.FRAME.size); // printf("\n%3i: bitrate %i", frames, MPEG.FRAME.bitrate); // printf("\n%3i: size %i", frames, MPEG.FRAME.size); // printf("\n%3i: pure %i", frames, MPEG.FRAME.pure); // handle errors if (MPEGDStatus != eMPEGDStatus_Normal) { if (MPEGDStatus & eMPEGDStatus_PhysFrame) { //printf("\nSkip frame # %i : eMPEGDStatus_PhysFrame", frames); frames_skipped++; //if (frames > ((MP3JUMPS/2)-1)) //{ // printf("PhysFrame border error & frame # %i", frames); getchar(); // return false; //} //else continue; } if (MPEGDStatus & eMPEGDStatus_Huffman) // critical error - EXIT { //printf("\nDEBUG: check huffman table error!"); getchar(); STATUS = eMP3ConvStatus_HuffmanRead; return false; } if (MPEGDStatus & eMPEGDStatus_Part23end) // critical error - EXIT { //printf("\nERROR due stopping read huffman bits... check it!"); getchar(); STATUS = eMP3ConvStatus_HuffmanEnd; return false; } if ((MPEGDStatus & eMPEGDStatus_nullData) == eMPEGDStatus_nullData) if (frames_loop == 0) { if (MPEGDStatus & eMPEGDStatus_XingLame) { padding_before = MPEGD.lame.LAME.misc.delay_start; padding_after = MPEGD.lame.LAME.misc.delay_end; if (padding_before) padding_before += MP3LAMEDECDELAY + 1; if (padding_after) padding_after -= MP3LAMEDECDELAY + 1; if ((int32)padding_after < 0) { warning |= eMP3ConvWarning_LamePadding; padding_before = 0; padding_after = 0; } //printf("\nSkip frame # %i : eMPEGDStatus_XingLame", frames); frames_skipped++; continue; } else if (MPEGDStatus & eMPEGDStatus_Fraunhofer) { //printf("\nSkip frame # %i : eMPEGDStatus_Fraunhofer", frames); frames_skipped++; continue; } } //if ((MPEGDStatus & eMPEGDStatus_nullData) != eMPEGDStatus_nullData) //{ // if (MPEGDStatus & eMPEGDStatus_nullData00) // printf("\n\ng0c0 frame # %i : eMPEGDStatus_nullData00", frames); // if (MPEGDStatus & eMPEGDStatus_nullData01) // printf("\ng0c1 frame # %i : eMPEGDStatus_nullData01", frames); // if (MPEGDStatus & eMPEGDStatus_nullData10) // printf("\ng1c0 frame # %i : eMPEGDStatus_nullData10", frames); // if (MPEGDStatus & eMPEGDStatus_nullData11) // printf("\ng1c1 frame # %i : eMPEGDStatus_nullData11\n", frames); // continue; //} } ///////////////////// CONVERTING ///////////////////// bool mpeg_1 = (MPEG.mpeg == eMPEGType1); bool mono = (MPEG.ch == eMPEGChSingle); byte channels = mono ? 1 : 2; byte granules = mpeg_1 ? eMPEG_1_Granules : eMPEG_2_Granules; for (byte gr = 0; gr < granules; gr++) { uint32 skip_samples = 0; // LAME encoder padding if (padding_enable) // check how many samples to skip { if (padding_b > MP3GRS) skip_samples = MP3GRS; else skip_samples = padding_b; padding_skip_counter += skip_samples; } ///////////// begin ///////////// for (byte ch = 0; ch < channels; ch++) { ConvertMP3_Requantize(gr, ch); ConvertMP3_Reorder(gr, ch); } ConvertMP3_ProcessStereo(gr); for (byte ch = 0; ch < channels; ch++) { ConvertMP3_Antialias(gr, ch); ConvertMP3_HybridSynth(gr, ch); ConvertMP3_FreqInversion(gr, ch); ConvertMP3_SubbandSynth(gr, ch, mono, (uint32*)result_granule, skip_samples); } ///////////// end ///////////// // manage 'before' padding if (padding_enable) { if (padding_b > MP3GRS) // skip_samples == MP3GRS { padding_b -= MP3GRS; } else // padding <= MP3GRS { result_granule += ((uint32)MP3GRS - skip_samples) << 2; // * 2ch * 16bit padding_b = 0; padding_enable = false; } } else // no padding { result_granule += MP3FRAMESIZE_half; } // manage 'after' padding if (padding_after) { if (frames_loop == padding_a_frame) { result_granule -= MP3FRAMESIZE_half; // make it back uint32 save; if (!gr) save = (padding_a > MP3GRS) ? MP3GRS : padding_a; else save = (padding_a > MP3GRS) ? (MP3GRS - (MP31152 - padding_a)) : 0; result_granule += (save << 2); // * 2ch * 16bit padding_skip_counter += MP3GRS - save; } else if (frames_loop > padding_a_frame) { result_granule -= MP3FRAMESIZE_half; // make it back padding_skip_counter += MP3GRS; } } } } continue_frame = frames_loop; // provide Continue() mode settings.out._data = runner.p; // debug info settings.out._size = runner.last; // debug info settings.out._padding = padding_skip_counter; // debug info settings.out._padding_before = padding_before; // debug info settings.out._padding_after = padding_after; // debug info // FIX OUT DATA (вычитаем из ожидаемого сколько кадров пропустили и сколько семплов выбросили в связи с LAME-паддингом) settings.out.size_out -= frames_skipped * MP3FRAMESIZE; settings.out.frames -= frames_skipped; settings.out.samples -= frames_skipped * MP31152; settings.out.time -= frames_skipped * frame_time; settings.out._skipped = frames_skipped; // debug info settings.out.size_out -= padding_skip_counter << 2; // * 2ch * 16bit settings.out.samples -= padding_skip_counter; settings.out.time -= (float)padding_skip_counter / settings.out.nSamplesPerSec; if (settings.out.time < 0.00002f) // 0.00002 s * 48000 KHz = 0.96 s settings.out.time = 0; // ERROR : unexpected <out.samples> if ((int32)settings.out.samples < 0) { STATUS = eMP3ConvStatus_OutSamples; return false; } // ERROR : ? //if (frames < stop_frame) // return false; //printf("\nMP3 CONV DONE"); return true; } private: //>> Проверка на первичные ошибки запуска bool CheckRun() { if (settings.in.data == nullptr) { STATUS = eMP3ConvStatus_NoInputPtr; return false; } if (settings.in.size == 0) { STATUS = eMP3ConvStatus_NoInputSz; return false; } if (settings.in.size > MAXMP3SIZE) { STATUS = eMP3ConvStatus_MaxInput; return false; } if (settings.in.start_time < 0) { warning |= eMP3ConvWarning_StartTime; settings.in.start_time = abs(settings.in.start_time); } if (settings.in.time < 0) { warning |= eMP3ConvWarning_Time; settings.in.time = abs(settings.in.time); } return true; } //>> Установка начальных значений bool PreSet(bool continue_mode) { if (!continue_mode) // Run() mode { ZeroMemory(storehs, sizeof(storehs)); // HybridSynth ZeroMemory(storess, sizeof(storess)); // SubbandSynth ZeroMemory(storess_pos, sizeof(storess_pos)); // SubbandSynth MPEGD._Reset_fast(); // reset phys. frame borders if (settings.in.data_mem != settings.in.data || settings.in.size_mem != settings.in.size) { padding_b = 0; // Source changed, reset padding memory padding_a = 0; // . padding_b_frame = 0; // . padding_a_frame = 0; // . padding_before = 0; // . padding_after = 0; // . } settings.in.data_mem = settings.in.data; settings.in.size_mem = settings.in.size; frame0_position = 0; start_position = MPG_ERROR; start_frame = MPG_ERROR; total_frames = 0; stop_frame = MPG_ERROR; frame_time = MPG_ERROR; settings.out.Reset(); } else // Continue() mode { // ERROR : unsafe modification of input data if (settings.in.data_mem != settings.in.data || settings.in.size_mem != settings.in.size) { STATUS = eMP3ConvStatus_InputMod; return false; } // ERROR : converter should be initialized with Run() before Contimue() if (frame_time == MPG_ERROR) { STATUS = eMP3ConvStatus_NoRun; return false; } // frame0_position = 0; start_position = MPG_ERROR; start_frame = MPG_ERROR; // total_frames = 0; stop_frame = MPG_ERROR; // frame_time = MPG_ERROR; settings.out.Reset_continue(); } /////////////////////////////////////////////////////// if (!continue_mode) // Run() mode : calc everything from the beginning { runner.p = settings.in.data; runner.end = runner.p + settings.in.size; runner.pos = 0; runner.last = settings.in.size; if (!SkipID3(runner.p, runner.last, frame0_position)) // EOF { STATUS = eMP3ConvStatus_EOF_ID3; return false; } RunnerShift(frame0_position); // init calculations & validation process for (;; total_frames++) { uint32 mem_start_pos = runner.pos; if (!MPEG._Read(runner.p, runner.last)) // EOF break; // . uint32 frame_size = MPEG._Frame(); if (frame_size == MPG_ERROR) // incorrect input break; // . // move to next frame OR break if cur frame data is not full if (!RunnerShift(mem_start_pos + frame_size)) break; if (!_Check(MPEG, false)) // not MPEG-1 Layer 3 frame { STATUS = eMP3ConvStatus_DiffFrames; return false; } if (!MPEG.RUNFRAMECALC()) // incorrect frame data { STATUS = eMP3ConvStatus_HeaderFail; return false; } // do once if (!total_frames) { settings.out.nChannels = 2; // MPEG.FRAME.channels; settings.out.nSamplesPerSec = MPEG.FRAME.frequency; settings.out.wBitsPerSample = 16; settings.out.wFormatTag = 1; settings.out.fsz_samples = MP31152; settings.out.fsz_bytes = MP3FRAMESIZE; settings.out.fsz_time = MP31152 * (1.f / MPEG.FRAME.frequency); frame_time = (float)MP31152 / MPEG.FRAME.frequency; if (settings.in.use_frame) start_frame = settings.in.start_frame; else start_frame = (uint32)(settings.in.start_time / frame_time); } // ERROR : all frames should have same frequency if (settings.out.nSamplesPerSec != MPEG.FRAME.frequency) { STATUS = eMP3ConvStatus_DiffFreq; return false; } // get start position if (total_frames == start_frame) start_position = mem_start_pos; } } else // Continue() mode : recalc some { start_position = runner.pos; start_frame = continue_frame; } /////////////////////////////////////////////////////// // ERROR : invalid start_time or start_frame if (start_position == MPG_ERROR) { STATUS = eMP3ConvStatus_StartPosErr; return false; } // move to start position RunnerShift(start_position); // count frames to proceed if (settings.in.time == 0) stop_frame = total_frames - start_frame; else { uint32 requested_frames; float delta_start_time; // difference between requested and real start point float settings_in_time; if (!settings.in.use_frame) delta_start_time = settings.in.start_time - start_frame * frame_time; else delta_start_time = 0.f; // DEBUG check if (delta_start_time < 0) printf("\nWARNING MP3conv : delta_start_time < 0"); // добавить расхождение к заказанному времени settings_in_time = settings.in.time + delta_start_time; if (settings_in_time < frame_time) // auto fix small request requested_frames = 1; else { float requested_frames_f = settings_in_time / frame_time; if (settings.in.maximize) requested_frames = (uint32) ceil (requested_frames_f); else requested_frames = (uint32) requested_frames_f; // floor (requested_frames_f); } uint32 available_frames = total_frames - start_frame; if (!settings.in.loop && available_frames < requested_frames) stop_frame = available_frames; else stop_frame = requested_frames; } // ERROR : there is no available data AND it's not a loop if (stop_frame == 0) { STATUS = eMP3ConvStatus_BufferEnd; return false; } return true; } //>> Подготовка выходных данных bool CalcOut() { // NOTE : some out data may be fixed due convertion in case of eMPEGDStatus_PhysFrame (skipped frames) ////// OUT PCM BUF ////// { uint32 target_size = stop_frame * MP3FRAMESIZE; if (settings.out.data_out_mem != settings.out.data_out) { warning |= eMP3ConvWarning_OutMod; } if (settings.out.data_out == nullptr) { settings.out.size_out = target_size; settings.out.data_out = (byte*) malloc(target_size); settings.out.size_out_mem = target_size; settings.out.data_out_mem = settings.out.data_out; } else if (settings.out.size_out_mem < target_size) // realloc { free(settings.out.data_out); settings.out.size_out = target_size; settings.out.data_out = (byte*) malloc(target_size); settings.out.size_out_mem = target_size; settings.out.data_out_mem = settings.out.data_out; } else // no need to alloc memory, just use old one { settings.out.size_out = target_size; } // <settings.out.size_out> will be fixed later by <frames_skipped> // ERROR : can't allocate memory if (settings.out.data_out == nullptr) { STATUS = eMP3ConvStatus_AllocOutErr; return false; } } ////// OTHER OUT ////// settings.out.start_frame = start_frame; settings.out.start_time = start_frame * frame_time; settings.out.frames = stop_frame; // fixed later by <frames_skipped> settings.out.time = stop_frame * frame_time; // fixed later by <frames_skipped> settings.out.samples = stop_frame * MP31152; // fixed later by <frames_skipped> settings.out.total_frames = total_frames; settings.out.end_frame = start_frame + stop_frame; settings.out.loop_end_frame = settings.out.end_frame % total_frames; return true; } //>> Запуск MP3 конвертора eMP3ConvStatus Run(bool continue_mode) { STATUS = eMP3ConvStatus_Normal; warning = eMP3ConvWarning_Normal; // POSSIBLE ERRORS if (CheckRun()) // error input if (PreSet(continue_mode)) // EOF ? error input if (CalcOut()) // alloc memory fail ConvertMP3(); // internal convertion error return STATUS; } public: //>> Запуск MP3 конвертора с начала (инициализирующий пуск) eMP3ConvStatus Run() { return Run(false); } //>> Продолжение работы с последней точки останова (нет сброса статических данных) eMP3ConvStatus Continue() { return Run(true); } private: static //>> Сообщает позицию начала данных, пропуская ID3 заголовок :: возвращает <false> в случае EOF bool SkipID3(byte * data, uint32 size, uint32 & position) { ID3TAG ID3; for (;;) { if (!ID3._Read(data + position, size - position)) // EOF return false; if (ID3.sign == ID3_SIGN) // skip ID3 { if (ID3.size + ID3_SIZE > size) // EOF return false; position += ID3.size + ID3_SIZE; for (;; position++) // skip NULL segment if presented { if (position >= size) return false; if (*(data + position)) break; } } else // ID3 not found { return true; } } } static //>> Проверка заголовка на возможность работы с кадром bool _Check(MPEGHeader & MPEG, bool deep_test) { if (MPEG.sync != MPG_SYNC) // sync FAIL return false; if (MPEG.mpeg != eMPEGType1) // MPEG-1 only return false; if (MPEG.layer != eMPEGLayer3) // Layer-3 only return false; if (MPEG.emph != eMPEGEmphasisNONE) // NONE-Emphasis only return false; if (deep_test) { if (MPEG._Bitrate() == MPG_ERROR) // ERROR bitrate return false; if (MPEG._Samples() == MPG_ERROR) // ERROR samples per frame return false; if (MPEG._Frequency() == MPG_ERROR) // ERROR samples per second return false; // if (MPEG._CheckLayerII() == MPG_ERROR) // LAYER 2 ERROR // return false; } return true; } public: static //>> Анализ длительности bool _Duration(byte * data, uint32 size, float & out_seconds) { uint32 position = 0; uint32 frames = 0; if (!SkipID3(data, size, position)) // EOF return false; // . //////////////////////////////////// MPEGHeader MPEG; if (!MPEG._Read(data + position, size - position)) // EOF return false; // . if (!MPEG.RUNFRAMECALC()) // incorrect frame data return false; // . uint32 frequency = MPEG.FRAME.frequency; uint32 frame_size = MPEG.FRAME.size; float frame_time = (float)MP31152 / frequency; //////////////////////////////////// for (frames = 1;; frames++) { position += frame_size; if (position >= size) // EOF break; // . if (!MPEG._Read(data + position, size - position)) // EOF break; // . if (MPG_ERROR == (frame_size = MPEG._Frame())) // incorrect input break; // . if (frequency != MPEG._Frequency()) // critical error return false; // . } //////////////////////////////////// out_seconds = frame_time * frames; return true; } static //>> Проверка MP3 bool _Check(byte * data, uint32 size) { ID3TAG ID3; MPEGHeader MPEG; uint32 position = 0; if (size > MAXMP3SIZE) // ignore too big files { wprintf(L"\nToo big mp3 file: %i MB (max %i MB)", _BYTESTOMB(size), _BYTESTOMB(MAXMP3SIZE)); return false; } if (size > MAXMP3CHECK) // check only first MAXMP3CHECK bytes size = MAXMP3CHECK; ///////// ID3 check ///////// if (!SkipID3(data, size, position)) return false; ///////// MPEG check ///////// if (!MPEG._Read(data + position, size - position)) // EOF return false; if (!_Check(MPEG, true)) return false; position += MPG_SIZE; ///////// MPEG-1 Layer-3 first frame size check ///////// uint32 frame = MPEG._Frame(); if (frame == MPG_ERROR || // ERROR frame > (size - position)) // EOF return false; return true; } static //>> Проверка MP3 : DEBUG bool _Check(FILE * fp) { uint32 fsize = (uint32) _filelengthi64(_fileno(fp)); if (fsize > MAXMP3SIZE) // ignore too big files { wprintf(L"\nToo big mp3 file: %i MB (max %i MB)", _BYTESTOMB(fsize), _BYTESTOMB(MAXMP3SIZE)); return false; } TBUFFER <byte, uint32> data; bool hRes = data.Create((fsize > MAXMP3CHECK) ? MAXMP3CHECK : fsize); if (!hRes) // mem alloc failed return false; rewind(fp); fread(data.buf, 1, data.count, fp); return _Check(data.buf, data.count); } }; } #endif // _MP3_H
37.634935
137
0.411948
[ "vector" ]
4a4327fe2860e13fb8a159876e47d7ce746520f9
3,348
h
C
src/point.h
yenyi/kicadPcb
f624156f59829554cb9fbf9b0438e7b84a42ee94
[ "BSD-3-Clause" ]
6
2020-02-08T07:29:42.000Z
2020-11-25T03:09:13.000Z
src/point.h
yenyi/kicadPcb
f624156f59829554cb9fbf9b0438e7b84a42ee94
[ "BSD-3-Clause" ]
2
2019-12-23T17:19:41.000Z
2020-01-09T00:10:50.000Z
src/point.h
yenyi/kicadPcb
f624156f59829554cb9fbf9b0438e7b84a42ee94
[ "BSD-3-Clause" ]
5
2020-10-16T23:59:42.000Z
2021-04-28T05:49:22.000Z
#ifndef KICAD_PCB_POINT_H #define KICAD_PCB_POINT_H #include <math.h> #include <iostream> #include <tuple> #include <vector> //public math structures using namespace std; template <class T> class Point_2D { public: Point_2D() {} Point_2D(const Point_2D &p) : m_x(p.m_x), m_y(p.m_y) {} Point_2D(T x, T y) : m_x(x), m_y(y) {} ~Point_2D() {} bool operator==(const Point_2D &p) const { return std::tie(m_x, m_y) == std::tie(p.m_x, p.m_y); } bool operator!=(const Point_2D &p) const { return std::tie(m_x, m_y) != std::tie(p.m_x, p.m_y); } bool operator<(const Point_2D &p) const { return std::tie(m_x, m_y) < std::tie(p.m_x, p.m_y); } bool operator<=(const Point_2D &p) const { return std::tie(m_x, m_y) <= std::tie(p.m_x, p.m_y); } void operator=(const Point_2D &p) { m_x = p.m_x; m_y = p.m_y; } const Point_2D &operator+=(const Point_2D &p) { m_x += p.m_x; m_y += p.m_y; return *this; } Point_2D operator-(const Point_2D &p) const { return Point_2D(m_x - p.m_x, m_y - p.m_y); } Point_2D operator+(const Point_2D &p) const { return Point_2D(m_x + p.m_x, m_y + p.m_y); } static double getDistance(const Point_2D &a, const Point_2D &b) { return sqrt(pow(a.m_x - b.m_x, 2.0) + pow(a.m_y - b.m_y, 2.0)); } T x() const { return m_x; } T y() const { return m_y; } T m_x; T m_y; }; using point_2d = Point_2D<double>; using points_2d = std::vector<Point_2D<double>>; template <class T> inline ostream &operator<<(ostream &out, const Point_2D<T> &p) { out << "(" << p.x() << ", " << p.y() << ")"; return out; } template <class T> class Point_3D { public: Point_3D() {} Point_3D(T x, T y, T z) : m_x(x), m_y(y), m_z(z) {} bool operator==(const Point_3D &p) const { return std::tie(m_x, m_y, m_z) == std::tie(p.m_x, p.m_y, p.m_z); } bool operator!=(const Point_3D &p) const { return std::tie(m_x, m_y, m_z) != std::tie(p.m_x, p.m_y, p.m_z); } bool operator<(const Point_3D &p) const { return std::tie(m_x, m_y, m_z) < std::tie(p.m_x, p.m_y, p.m_z); } void operator=(const Point_3D &p) { m_x = p.m_x; m_y = p.m_y; m_z = p.m_z; } Point_3D operator-(const Point_3D &p) const { return Point_3D(m_x - p.m_x, m_y - p.m_y, m_z - p.m_z); } Point_3D operator+(const Point_3D &p) const { return Point_3D(m_x + p.m_x, m_y + p.m_y, m_z + p.m_z); } const Point_3D &operator+=(const Point_3D &p) { m_x += p.m_x; m_y += p.m_y; m_z += p.m_z; return *this; } static double getDistance2D(const Point_3D &a, const Point_3D &b) { return sqrt(pow(a.m_x - b.m_x, 2.0) + pow(a.m_y - b.m_y, 2.0)); } T x() const { return m_x; } T y() const { return m_y; } T z() const { return m_z; } T m_x; T m_y; T m_z; }; template <class T> inline ostream &operator<<(ostream &out, const Point_3D<T> &p) { out << "(" << p.x() << ", " << p.y() << ", " << p.z() << ")"; return out; } using point_3d = Point_3D<double>; using points_3d = std::vector<Point_3D<double>>; using Location = Point_3D<int>; #endif
23.914286
72
0.54779
[ "vector" ]
4a44730888934e9fdd77f971d73b3702e44a8a7a
1,049
h
C
module/PcbRouter/src/GridPin.h
aspdac-submission-pcb-layout/PCB-Layout-Framework
cac05a813cb5616170a9fb4cb11c13ac9a31fb36
[ "BSD-3-Clause" ]
null
null
null
module/PcbRouter/src/GridPin.h
aspdac-submission-pcb-layout/PCB-Layout-Framework
cac05a813cb5616170a9fb4cb11c13ac9a31fb36
[ "BSD-3-Clause" ]
null
null
null
module/PcbRouter/src/GridPin.h
aspdac-submission-pcb-layout/PCB-Layout-Framework
cac05a813cb5616170a9fb4cb11c13ac9a31fb36
[ "BSD-3-Clause" ]
null
null
null
#ifndef PCBROUTER_GRID_PIN_H #define PCBROUTER_GRID_PIN_H #include <algorithm> #include <vector> #include "globalParam.h" #include "point.h" class GridPin { public: //ctor GridPin() {} //dtor ~GridPin() {} friend class BoardGrid; friend class MultipinRoute; friend class GridBasedRouter; const Point_2D<int> &getPinLL() const { return pinLL; } const Point_2D<int> &getPinUR() const { return pinUR; } void setPinLL(Point_2D<int> &point) { pinLL = point; } void setPinUR(Point_2D<int> &point) { pinUR = point; } const std::vector<Location> &getPinWithLayers() const { return pinWithLayers; } void addPinShapeGridPoint(const Point_2D<int> &pt) { pinShapeToGrids.push_back(pt); } const std::vector<Point_2D<int>> &getPinShapeToGrids() const { return pinShapeToGrids; } private: // TODO:: Change to layer index only std::vector<Location> pinWithLayers; // Pin Shape std::vector<Point_2D<int>> pinShapeToGrids; Point_2D<int> pinLL; Point_2D<int> pinUR; }; #endif
27.605263
92
0.687321
[ "shape", "vector" ]
4a577e38e76f8fa5e331f6847e1731650d204915
10,422
h
C
llvm/passes/include/fuseminix/FuseMinixFuser.h
vusec/dsn-2016-osiris
5a5855ae36419d0c6e1ae9cae5984f9f7d2719ac
[ "Apache-2.0" ]
4
2017-12-21T14:33:04.000Z
2019-05-14T20:12:54.000Z
llvm/passes/include/fuseminix/FuseMinixFuser.h
vusec/dsn-2016-osiris
5a5855ae36419d0c6e1ae9cae5984f9f7d2719ac
[ "Apache-2.0" ]
null
null
null
llvm/passes/include/fuseminix/FuseMinixFuser.h
vusec/dsn-2016-osiris
5a5855ae36419d0c6e1ae9cae5984f9f7d2719ac
[ "Apache-2.0" ]
4
2016-12-17T10:18:07.000Z
2021-11-19T23:15:23.000Z
/****************************** * Author : Koustubha Bhat * Jul-Oct 2014 * Vrije Universiteit, Amsterdam. *******************************/ #ifndef FUSE_MINIX_FUSER_H #define FUSE_MINIX_FUSER_H #include <llvm/Transforms/Utils/BasicBlockUtils.h> #include <pass.h> #include <common/util/string.h> #include <common/pass_common.h> #include <common/dsa_common.h> #include <fuseminix/common.h> #include <fuseminix/FuseMinixPass.h> #include <fuseminix/FuseMinixPreparer.h> namespace llvm { STATISTIC(NumSendrecFuserWrappers, "SEND SIDE: Number of wrapper functions created to fuse ipc_sendrec() calls to potential destinations."); class FuseMinixFuser { public: FuseMinixFuser(FuseMinixPass *FMP); bool fuse(FuseMinixPreparer *preparer); private: Module *M; FuseMinixPass *FMP; DSAUtil *dsau; FuseMinixPreparer *preparer; std::vector<CallSite> sendrecCallSites; Function* createSendrecCallFusingFunction(CallSite *callSite); Function* createFusingFunction(IPCInfo *ipcInfo, Function *theSendrecCaller, std::vector<Function*> functionCallees); bool replaceCallInst(CallSite *callSite, Function *functionToCall); }; FuseMinixFuser::FuseMinixFuser(FuseMinixPass *FMP) { this->FMP = FMP; dsau = NULL; } bool FuseMinixFuser::fuse(FuseMinixPreparer *preparer) { bool returnValue = true; std::map<CallSite*, IPCInfo*>* sendrecCallSitesInfoMap; this->preparer = preparer; sendrecCallSitesInfoMap = preparer->getSendrecCallSitesInfoMap(); if (NULL == sendrecCallSitesInfoMap) { return false; } std::vector<Function*> destFunctions; for (std::map<CallSite*, IPCInfo*>::iterator IM = sendrecCallSitesInfoMap->begin(), EM = sendrecCallSitesInfoMap->end(); IM != EM; IM++) { DEBUG(errs() << "Caller of sendrec callsite: " << (*IM).first->getCaller()->getName() << " mtype: " << (*IM).second->mtype << " " << " src endpointValue: " << (*IM).second->srcEndpoint << " num dest endpointValues: " << (*IM).second->destEndpoints.size() << " "); DEBUG(errs() << "["); for(unsigned i = 0; i < (*IM).second->destEndpoints.size(); i++) { DEBUG(errs() << (*IM).second->destEndpoints[i] << " "); } DEBUG(errs() << "]\n"); } for (std::map<CallSite*, IPCInfo*>::iterator IM = sendrecCallSitesInfoMap->begin(), EM = sendrecCallSitesInfoMap->end(); IM != EM; IM++) { CallSite *currCallSite = (*IM).first; IPCInfo *currInfo = (*IM).second; std::vector<Function*> callSiteDestFunctions; Function *fuserFunction= NULL; callSiteDestFunctions.clear(); DEBUG(errs() << "Getting potential sendrec destinations.\n"); if (0 > preparer->getPotentialSendrecDestinations(currInfo, callSiteDestFunctions)) { DEBUG(errs() << "@ Fuser getPotentialSendrecDestinations returned -1.\n"); returnValue = false; continue; } errs() << "[ DESTFUNCTS ] \n"; for (auto FI = callSiteDestFunctions.begin(); FI != callSiteDestFunctions.end(); FI++) { errs() << " DESTFUNCT: " << (*FI)->getName() << "\n"; } DEBUG(errs() << "Num potential destinations: " << callSiteDestFunctions.size() << "\n"); DEBUG(errs() << "CREATING FUSE FUNCTION\n"); DEBUG(errs() << "Target sendrec function at callsite: " << currCallSite->getCalledFunction()->getName() << "\n"); this->M = currCallSite->getCalledFunction()->getParent(); fuserFunction = createFusingFunction(currInfo, currCallSite->getCalledFunction(), callSiteDestFunctions); if (NULL == fuserFunction) { DEBUG(errs() << "WARNING: Failed creating fuser function for callsite @ " << currCallSite->getCaller()->getName() << "\n"); returnValue = false; continue; } NumSendrecFuserWrappers++; if (false == replaceCallInst(currCallSite, fuserFunction)) { DEBUG(errs() << "WARNING: Failed replacing callsite call inst. @ " << currCallSite->getCaller()->getName() << "\n"); returnValue = false; } } return returnValue; } Function* FuseMinixFuser::createFusingFunction(IPCInfo *ipcInfo, Function *theSendrecCaller, std::vector<Function*> functionCallees) { DEBUG(errs() << "Creating fusing function for ipc_sendrec call: " << theSendrecCaller->getName() << "\n"); // Create a wrapper function std::string modulePrefix = getMinixModulePrefix(theSendrecCaller); DEBUG(errs() << "module prefix: " << modulePrefix << "\n"); std::string destModuleName = ""; if (NULL != ipcInfo) { if ( 1 == ipcInfo->destEndpoints.size()) { std::string tmpStr; getEndpointMapping(ipcInfo->destEndpoints[0], tmpStr); destModuleName = (std::string)"_" + tmpStr + (std::string)"_" + OutputUtil::intToStr(ipcInfo->mtype) + (std::string)"_"; } else if (1 < ipcInfo->destEndpoints.size()) { destModuleName = "_multipledest_"; } else { destModuleName = "_X_"; // dont know why we are here! } } std::string wrapperName = (std::string)theSendrecCaller->getName() + (std::string)FUSER_FUNCTION_PREFIX + destModuleName; Function *wrapperFunction = NULL; FunctionType *FTy = NULL; std::vector<Type*> argTypes; for (Function::const_arg_iterator I = theSendrecCaller->arg_begin(), E = theSendrecCaller->arg_end(); I != E; ++I) { argTypes.push_back(I->getType()); } FTy = FunctionType::get(theSendrecCaller->getFunctionType()->getReturnType(), argTypes, theSendrecCaller->getFunctionType()->isVarArg()); DEBUG(errs() << "Wrapper name: " << wrapperName << "\n"); wrapperFunction = PassUtil::createFunctionWeakPtrWrapper(*(this->M), wrapperName, FTy); if(NULL == wrapperFunction) { return NULL; } DEBUG(errs() << "Created wrapper function.\n"); // Create call instructions to the destination functions BasicBlock *entryBB = NULL; entryBB = &wrapperFunction->getEntryBlock(); std::vector<CallInst*> replacementCallInsts; Instruction *beforeInst = NULL; for (BasicBlock::iterator I = entryBB->begin(), E = entryBB->end(); I != E; I++) { if (dyn_cast<TerminatorInst>(I)) { beforeInst = dyn_cast<Instruction>(I); break; } } std::vector<Value*> args; Value *argcArgument = ConstantInt::get(Type::getInt32Ty(M->getContext()), 0, false); Value *argvArgument = ConstantPointerNull::get(Type::getInt8Ty(M->getContext())->getPointerTo()->getPointerTo()); Value *voidPointerNullArgument = ConstantPointerNull::get(VOID_PTR_TY(*M)); bool success = false; for (unsigned i = 0; i < functionCallees.size(); i++) { Function *currCallee = functionCallees[i]; // Prepare arguments args.clear(); DEBUG(errs() << "Arg size of callee : " << currCallee->getArgumentList().size() << "\n"); switch(currCallee->getArgumentList().size()) { case 0: { // nothing to do break; } case 1: { Argument *parameter = dyn_cast<Argument>(currCallee->getArgumentList().begin()); if (NULL == parameter) { continue; } if (parameter->getType()->isIntegerTy()) { args.push_back(argcArgument); } else if(parameter->getType()->isPointerTy()) { args.push_back(voidPointerNullArgument); } else { DEBUG(errs() << "TypeMismatch_ONE_ARG: Arg type: " << parameter->getType()->getTypeID() << "(" << currCallee->getName() << ")\n"); continue; } break; } case 2: { args.push_back(argcArgument); args.push_back(argvArgument); unsigned j = 0; bool nope = false; for (Function::const_arg_iterator I = currCallee->arg_begin(), E = currCallee->arg_end(); I != E; ++I) { if (I->getType() != args[j]->getType()) { DEBUG(errs() << "TypeMismatch_TWO_ARGS: I: " << I->getType()->getTypeID() << " args[" << j << "] : " << args[j]->getType()->getTypeID() << "(Funcn. call:" << currCallee->getName() << ")\n"); nope = true; } j++; } if (nope) { continue; } break; } default: { DEBUG(errs() << "TypeMismatch_MORE_ARGS : " << currCallee->getArgumentList().size() << "\n"); continue; } } std::string callInstName = (std::string)REPLACEMENT_CALL_PREFIX + (std::string)currCallee->getName(); CallInst *callInst = PassUtil::createCallInstruction(currCallee, args, "", beforeInst); if (NULL != callInst) { replacementCallInsts.push_back(callInst); success = true; } else { DEBUG(errs() << "WARNING: CallInst couldn't be created for callee: " << currCallee->getName() << "(caller: " << theSendrecCaller->getName() << ")\n"); } } if (success) { return wrapperFunction; } else { return NULL; } } static void dump_mapping(CallInst *CI, Function *F) { errs() << "IPC_CALL_TO_FUESERMAP: " << F->getName() << " "; MDNode *N = CI->getMetadata(FUSE_IPC_SITE_ID_KEY); if (N) { ConstantInt *I = dyn_cast_or_null<ConstantInt>(N->getOperand(0)); MDString *S = dyn_cast_or_null<MDString>(N->getOperand(1)); errs() << " " << S->getString() << ":" << I->getZExtValue() << "\n"; } else errs() << " NO_MAPPING\n"; } bool FuseMinixFuser::replaceCallInst(CallSite *callSite, Function* functionToCall) { if (NULL == callSite || NULL == functionToCall) { return false; } std::vector<Value*> *args = new std::vector<Value*>(callSite->arg_begin(), callSite->arg_end()); CallInst *newInst = NULL; Instruction *insertPoint = callSite->getInstruction(); CallInst *originalInst = dyn_cast<CallInst>(callSite->getInstruction()); newInst = PassUtil::createCallInstruction(functionToCall, *args, "", insertPoint); if (NULL == newInst) { return false; } SmallVector< std::pair< unsigned, MDNode * >, 8> MDs; originalInst->getAllMetadata(MDs); for(unsigned i=0;i<MDs.size();i++) { newInst->setMetadata(MDs[i].first, MDs[i].second); } int argOffset = 0; CallingConv::ID CC = callSite->getCallingConv(); newInst->setCallingConv(CC); ATTRIBUTE_SET_TY NewAttrs = PassUtil::remapCallSiteAttributes(*callSite, argOffset); newInst->setAttributes(NewAttrs); originalInst->replaceAllUsesWith(newInst); // If the old instruction was an invoke, add an unconditional branch // before the invoke, which will become the new terminator. if (InvokeInst *II = dyn_cast<InvokeInst>(originalInst)) BranchInst::Create(II->getNormalDest(), originalInst); dump_mapping(originalInst, functionToCall); // Delete the old call site originalInst->eraseFromParent(); return true; } } #endif
30.925816
140
0.653905
[ "vector" ]
4a5a247c71a66b1f005a63df8072fda207209d0a
11,223
h
C
mitsuba-af602c6fd98a/include/mitsuba/hw/device.h
NTForked-ML/pbrs
0b405d92c12d257e2581366542762c9f0c3facce
[ "MIT" ]
139
2017-04-21T00:22:34.000Z
2022-02-16T20:33:10.000Z
mitsuba-af602c6fd98a/include/mitsuba/hw/device.h
NTForked-ML/pbrs
0b405d92c12d257e2581366542762c9f0c3facce
[ "MIT" ]
11
2017-08-15T18:22:59.000Z
2019-07-01T05:44:41.000Z
mitsuba-af602c6fd98a/include/mitsuba/hw/device.h
NTForked-ML/pbrs
0b405d92c12d257e2581366542762c9f0c3facce
[ "MIT" ]
30
2017-07-21T03:56:45.000Z
2022-03-11T06:55:34.000Z
/* This file is part of Mitsuba, a physically based rendering system. Copyright (c) 2007-2014 by Wenzel Jakob and others. Mitsuba is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License Version 3 as published by the Free Software Foundation. Mitsuba 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, see <http://www.gnu.org/licenses/>. */ #pragma once #if !defined(__MITSUBA_HW_DEVICE_H_) #define __MITSUBA_HW_DEVICE_H_ #include <mitsuba/hw/session.h> #include <list> MTS_NAMESPACE_BEGIN class Renderer; /** \brief The device event structure encapsulates event * information such as mouse movement or key presses * \ingroup libhw */ struct MTS_EXPORT_HW DeviceEvent { public: /// Default constructor inline DeviceEvent() { } /// Type constructor inline DeviceEvent(unsigned short type) { m_type = type; } /// Return the event type inline unsigned short getType() const { return m_type; } /// Set the event type inline void setType(int type) { m_type = type; } /// Get the mouse position vector inline void setMousePosition(const Point2i &position) { m_mouse.x = position.x; m_mouse.y = position.y; } /// Set the mouse position vector inline Point2i getMousePosition() const { return Point2i(m_mouse.x, m_mouse.y); } /// Get the relative mouse movement vector inline void setMouseRelative(const Vector2i &relative) { m_mouse.xrel = relative.x; m_mouse.yrel = relative.y; } /// Set the relative mouse movement vector inline Vector2i getMouseRelative() const { return Vector2i(m_mouse.xrel, m_mouse.yrel); } /// Set the enum of the pressed mouse button inline void setMouseButton(unsigned short button) { m_mouse.button = button; } /// Get the enum of the pressed mouse button inline unsigned short getMouseButton() const { return m_mouse.button; } /// Set the pressed keyboard key (latin1) inline void setKeyboardKey(char key) { m_keyboard.key = key; } /// Get the pressed keyboard key (latin1) inline char getKeyboardKey() const { return m_keyboard.key; } /// Set the pressed keyboard key special identifier enum (see Device::ESpecialKeys) inline void setKeyboardSpecial(unsigned short special) { m_keyboard.special = special; } /// Get the pressed keyboard key special identifier enum (see Device::ESpecialKeys) inline unsigned short getKeyboardSpecial() const { return m_keyboard.special; } /// Set the keyboard modifiers (see Device::EKeyboardModifiers) inline void setKeyboardModifiers(unsigned short modifiers) { m_keyboard.modifiers = modifiers; } /// Get the keyboard modifiers (see Device::EKeyboardModifiers) inline unsigned short getKeyboardModifiers() const { return m_keyboard.modifiers; } /// Get the interpreted keypress data inline const char* getKeyboardInterpreted() const { return m_keyboard.interpreted; } /// Get the interpreted keypress data inline char* getKeyboardInterpreted() { return m_keyboard.interpreted; } /// Set the event source inline void setActionSource(Object *source) { m_action.source = source; } /// Get the event source inline Object *getActionSource() { return m_action.source; } /// Return a string representation std::string toString() const; private: unsigned short m_type; union { struct { unsigned short special, modifiers; char key, interpreted[16]; } m_keyboard; struct { int x, y, xrel, yrel; unsigned short button; } m_mouse; struct { Object *source; } m_action; }; }; /** \brief Abstract device event callback * \ingroup libhw */ class MTS_EXPORT_HW DeviceEventListener { public: /** \brief Called when a device event occurs * \param event The event data structure * \return True if the result has been handled, false otherwise */ virtual bool deviceEventOccurred(const DeviceEvent &event) = 0; protected: /// Virtual destructor virtual ~DeviceEventListener() { } }; /** \brief An abstract drawing device * \ingroup libhw */ class MTS_EXPORT_HW Device : public Object { public: /// Device event types enum EEventType { ENoEvent = 0x0000, EQuitEvent = 0x0001, EKeyDownEvent = 0x0002, EKeyUpEvent = 0x0004, EMouseMotionEvent = 0x0008, EMouseDragEvent = 0x0010, EMouseButtonDownEvent = 0x0020, EMouseButtonUpEvent = 0x0040, EMouseEnterEvent = 0x0080, EMouseLeaveEvent = 0x0100, EMouseBeginDragEvent = 0x0200, EMouseEndDragEvent = 0x0400, EMouseDoubleClickEvent = 0x0800, EGainFocusEvent = 0x1000, ELoseFocusEvent = 0x2000, EResizeEvent = 0x4000 }; /// Device keyboard event modifiers enum EKeyboardModifiers { EShiftModifier = 0x01, EControlModifier = 0x02, EAltModifier = 0x04, EMetaModifier = 0x08 }; /// Device keyboard event modifiers enum EMouseButton { ENoButton = 0x0, ELeftButton = 0x01, EMiddleButton = 0x02, ERightButton = 0x04, EWheelUpButton = 0x08, EWheelDownButton = 0x10 }; /// Device special keys enum ESpecialKeys { ENoSpecial = 0, EKeyEscape, EKeyF1, EKeyF2, EKeyF3, EKeyF4, EKeyF5, EKeyF6, EKeyF7, EKeyF8, EKeyF9, EKeyF10, EKeyF11, EKeyF12, EKeyF13, EKeyF14, EKeyF15, EKeyBackspace, EKeyTab, EKeyClear, EKeyReturn, EKeyPause, EKeyInsert, EKeyDelete, EKeyUp, EKeyDown, EKeyLeft, EKeyRight, EKeyHome, EKeyEnd, EKeyPageUp, EKeyPageDown, EKeyNumLock, EKeyCapsLock, EKeyScrollLock, EKeyLShift, EKeyRShift, EKeyLAlt, EKeyRAlt, EKeyLMeta, EKeyRMeta, EKeyLControl, EKeyRControl, EKeyKeyPad0, EKeyKeyPad1, EKeyKeyPad2, EKeyKeyPad3, EKeyKeyPad4, EKeyKeyPad5, EKeyKeyPad6, EKeyKeyPad7, EKeyKeyPad8, EKeyKeyPad9, EKeyKeyPadPeriod, EKeyKeyPadDivide, EKeyKeyPadMultiply, EKeyKeyPadMinus, EKeyKeyPadPlus, EKeyKeyPadEnter, EKeyKeyPadEquals, EKeyLastSpecialKey }; /// Construct a new device using the appropriate implementation static Device *create(Session *session); /// Return the dimension of the device inline Vector2i getSize() const { return m_size; } /// Set the dimension of the device void setSize(const Vector2i &dimension); /// Return the aspect ratio of the device inline Float getAspect() const { return (Float) m_size.x / (Float) m_size.y; } /// Return the position of the device inline Point2i getPosition() const { return m_position; } /// Set the position of the device virtual void setPosition(const Point2i &position); /// Set the FSAA sample count, do this before Init() void setFSAA(int fsaa); /// Return the FSAA sample count inline int getFSAA() const { return m_fsaa; } /// Only applies to devices, which are UI windows virtual void setVisible(bool visible) = 0; /** \brief A convenience method. * * Sets the amount of bits for the red, green and * blue components */ void setColorBits(int colorBits); /// Set the amount of bits for the red component void setRedBits(int redBits); /// Return the amount of bits for the red component inline int getRedBits() const { return m_redBits; } /// Set the amount of bits for the green component void setGreenBits(int greenBits); /// Return the amount of bits for the green component inline int getGreenBits() const { return m_greenBits; } /// Set the amount of bits for the blue component void setBlueBits(int blueBits); /// Return the amount of bits for the blue component inline int getBlueBits() const { return m_blueBits; } /// Set the amount of bits for the alpha component void setAlphaBits(int alphaBits); /// Return the amount of bits for the alpha component inline int getAlphaBits() const { return m_alphaBits; } /// Set the amount of bits for the depth component void setDepthBits(int depthBits); /// Return the amount of bits for the depth component inline int getDepthBits() const { return m_depthBits; } /// Set the amount of bits for the stencil component void setStencilBits(int stencilBits); /// Return the amount of bits for the stencil component inline int getStencilBits() const { return m_stencilBits; } /// Define whether to enable double buffering void setDoubleBuffer(bool doubleBuffer); // Return whether double buffering is enabled inline bool getDoubleBuffer() const { return m_doubleBuffer; } // Define whether to enable full screen drawing void setFullscreen(bool fullscreen); /// Return whether full screen drawing is enabled inline bool getFullscreen() const { return m_fullscreen; } // Specify whether resizing the window is allowed void setResizeAllowed(bool resizeAllowed); /// Return whether it is possible to resize the window inline bool isResizeAllowed() const { return m_resizeAllowed; } /// Define whether to enable window centering void setCenter(bool center); /// Return whether window centering is enabled inline bool getCenter() const { return m_center; } /// Define whether to show the frames per second inline void setShowFPS(bool showFPS) { m_showFPS = showFPS; } /// Return whether to show the frames per second inline bool getShowFPS() const { return m_showFPS; } /// Return the frames per second (0 if no data is available) inline int getFPS() const { return m_fps; } /// Set the x window position void setXPos(int xpos); /// Set the window title virtual void setTitle(const std::string &title); /// Return the window title inline const std::string &getTitle() const { return m_title; } /// Get the session inline const Session *getSession() const { return m_session.get(); } /// Get the session inline Session *getSession() { return m_session; } /** * Initialize the renderer. Optionally, an existing device instance * can be provided as a second argument -- this is primarily meant * to create a device that will be able to support a shared context * with another device. */ virtual void init(Device *other = NULL); /// Shut the device down virtual void shutdown(); /// Add an event callback to the device void addCallback(DeviceEventListener *callback); /// Remove an event callback from the device void removeCallback(DeviceEventListener *callback); /// Associate the renderer with this device virtual void makeCurrent(Renderer *renderer) = 0; /// Flip the buffers (when using double buffering) virtual void flip(); MTS_DECLARE_CLASS() protected: /// Virtual destructor virtual ~Device(); /// Create a new device Device(Session *session); /** \brief Send a device event using * the registered callbacks */ void fireDeviceEvent(const DeviceEvent &event); protected: ref<Session> m_session; ref<Timer> m_timer; Vector2i m_size; Point2i m_position; int m_fsaa; int m_redBits, m_greenBits, m_blueBits; int m_alphaBits, m_depthBits, m_stencilBits; bool m_doubleBuffer, m_initialized, m_fullscreen; bool m_center, m_showFPS, m_resizeAllowed; int m_fpsCounter, m_fps, m_lastTime; std::string m_title; std::list<DeviceEventListener *> m_callbacks; }; MTS_NAMESPACE_END #endif /* __MITSUBA_HW_DEVICE_H_ */
27.240291
113
0.737147
[ "object", "vector" ]
4a693aa555bce5ad82807016553af532dd833d74
9,598
c
C
acm_service.c
LaudateCorpus1/openbmc-acm
c23c40fcb1a6eb0a092ebff75255097063296ce3
[ "MIT" ]
1
2021-05-24T03:36:19.000Z
2021-05-24T03:36:19.000Z
acm_service.c
LaudateCorpus1/openbmc-acm
c23c40fcb1a6eb0a092ebff75255097063296ce3
[ "MIT" ]
null
null
null
acm_service.c
LaudateCorpus1/openbmc-acm
c23c40fcb1a6eb0a092ebff75255097063296ce3
[ "MIT" ]
2
2021-03-05T10:55:39.000Z
2021-03-05T10:56:00.000Z
/************************************************************************************* (C) Copyright (2012-2021) Hewlett PAckard Enterprise Development LP \************************************************************************************* File: acm_service.c Objective: SD-BUS service Provide support for ACM(Apollo Chassis Manager) interface from user application/deamon. Polling for packets from ACM. Polling for FAN PWM value changes Handler for SD-Bus client **************************************************************************************/ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <errno.h> #include <systemd/sd-bus.h> #include <fcntl.h> //#include <sys/types.h> //#include <sys/stat.h> #include <unistd.h> #include "acm.h" #include "acm_extra.h" #define FAN_PWM_BLOCK_1 1 extern ACM_BLK_INDX acm_idx[]; extern int acm_rd_req(unsigned short blk_num); typedef struct { unsigned char block_len[2]; unsigned char inst; unsigned char block_num[2]; unsigned char data[512]; } BLOCK_DATA; /* Send a single packet block to acm int acm_send_single_block(BLOCK_DATA *block, int size) { int fd, r; fd = open(ACM_IN, O_WRONLY | O_TRUNC, 0664); if(fd < -1) { fprintf(stderr, "Failed to open file\n"); } r = write(fd, (unsigned char *)block, size); close(fd); return(0); } */ static int method_dump(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { int x, i; int r; unsigned char a[512], *ptr; /* Read the parameters */ r = sd_bus_message_read(m, "x", &x); //block number read if (r < 0) { fprintf(stderr, "Failed to parse parameters: %s\n", strerror(-r)); return r; } if(x == 0xff) { //dump all block data for(i = 0; i < 0x105; i++) { if(acm_idx[i].type >= 0) { printf("Block %x \n", i); dumphex(acm_idx[i].blk_ptr, acm_idx[i].blk_size); } } } else { i = 1; printf("Block %x \n", x); dumphex(acm_idx[x].blk_ptr, acm_idx[x].blk_size); } return sd_bus_reply_method_return(m, "x", i); } extern void acm_ping_init(void); static int method_ping(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { int x, i; int r; /* Read the parameters */ r = sd_bus_message_read(m, "x", &x); //block number read if (r < 0) { fprintf(stderr, "Failed to parse parameters: %s\n", strerror(-r)); return r; } if(x == 8) { acm_ping_init(); i = x; } else { i = 0xff; } return sd_bus_reply_method_return(m, "x", i); } static int method_read(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { int x; int r=0; unsigned char a[512], *ptr; /* Read the parameters */ r = sd_bus_message_read(m, "x", &x); //block number read if (r < 0) { fprintf(stderr, "Failed to parse parameters: %s\n", strerror(-r)); } else { if(acm_idx[x].type >= 0) { ptr = (unsigned char *)acm_idx[x].blk_ptr; printf("copying data for block: %x, size: %x, data: %x %x %x %x\n", x, acm_idx[x].blk_size, ptr[0], ptr[1], ptr[2], ptr[3]); memcpy(a, acm_idx[x].blk_ptr, acm_idx[x].blk_size); /* Reply with the response */ printf("Reading block: %x data: %x %x %x %x\n",x, a[0], a[1], a[2],a[3]); } else { printf("Invalid block number\n"); r = 1; } } if(r == 0) { // return sd_bus_message_new_method_return(m, &reply); return sd_bus_reply_method_return(m, "ay", acm_idx[x].blk_size, a[0], a[1], a[2], a[3], a[4], a[5],a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15], a[16], a[17], a[18], a[19], a[20], a[21], a[22], a[23], a[24], a[25], a[26], a[27], a[28], a[29], a[30], a[31], a[32], a[33], a[34], a[35], a[36], a[37], a[38], a[39], a[40], a[41], a[42], a[43], a[44], a[45], a[46], a[47], a[48], a[49]); } else { return sd_bus_reply_method_return(m, "ay", 1, r); } } static int method_write(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { int x; const char *s; int r=0; // int fd; /* Read the parameters */ r = sd_bus_message_read(m, "xs", &x, &s); if (r < 0) { fprintf(stderr, "Failed to parse parameters: %s\n", strerror(-r)); } else { fprintf(stderr,"Received block: %x, data: %s\n",x, s); if(acm_idx[x].type >= 0) { memcpy(acm_idx[x].blk_ptr, s, (acm_idx[x].blk_size < strlen(s)) ? acm_idx[x].blk_size : strlen(s)); acm_rd_req(x); //This will send data to acm } else { r = 1; } } /* Reply with the response */ return sd_bus_reply_method_return(m, "x", r); } static int method_fan_pwm_write(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { int x,i; int pwm; unsigned char *ptr; int r=0; BLOCK_DATA block; /* Read the parameters */ r = sd_bus_message_read(m, "xx", &x, &pwm); if (r < 0) { fprintf(stderr, "Failed to parse parameters: %s\n", strerror(-r)); } else { fprintf(stderr,"Received PWM value: %02x\n", pwm); ptr = (unsigned char *)acm_idx[x].blk_ptr; for(i = 0; i < 8; i++) { ptr[i] = pwm; } acm_rd_req(x); //This will send data to acm r = pwm; } /* Reply with the response */ return sd_bus_reply_method_return(m, "x", r); } /* The vtable of our little object, implements the net.poettering.Calculator interface */ static const sd_bus_vtable blocks_vtable[] = { SD_BUS_VTABLE_START(0), SD_BUS_METHOD("Dump", "x", "x", method_dump, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("Read", "x", "ay", method_read, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("Write", "xs", "x", method_write, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("FANPWM", "xx", "x", method_fan_pwm_write, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("Ping", "x", "x", method_ping, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_VTABLE_END }; void *sd_thread(void *vargp) { //int argc, char *argv[]) { ACM_BLK_INDX *sd_acm_idx; sd_bus_slot *slot = NULL; sd_bus *bus = NULL; int r; struct thread_info *tinfo = vargp; printf("SD_Bus service thread starting !!!!!!!!!!!!!!!!!!!!!!\n"); sd_acm_idx = tinfo->blocks; /* Connect to the user bus this time */ r = sd_bus_default(&bus); if (r < 0) { fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-r)); goto finish; } /* Install the object */ r = sd_bus_add_object_vtable(bus, &slot, "/net/acm/blocks", /* object path */ "net.acm.blocks", /* interface name */ blocks_vtable, NULL); if (r < 0) { fprintf(stderr, "Failed to issue method call: %s\n", strerror(-r)); goto finish; } /* Take a well-known service name so that clients can find us */ r = sd_bus_request_name(bus, "net.acm.blocks", 0); if (r < 0) { fprintf(stderr, "Failed to acquire service name: %s\n", strerror(-r)); goto finish; } for (;;) { /* Process requests */ r = sd_bus_process(bus, NULL); if (r < 0) { fprintf(stderr, "Failed to process bus: %s\n", strerror(-r)); goto finish; } if (r > 0) /* we processed a request, try to process another one, right-away */ continue; /* Wait for the next request to process */ r = sd_bus_wait(bus, (uint64_t) -1); if (r < 0) { fprintf(stderr, "Failed to wait on bus: %s\n", strerror(-r)); goto finish; } } finish: sd_bus_slot_unref(slot); sd_bus_unref(bus); return(NULL); }
31.676568
183
0.453219
[ "object" ]
4a6a9d6a9b1cb7e4916b03ff2b61f862f908314a
2,571
h
C
DEM/Low/src/Resources/Resource.h
niello/deusexmachina
2f698054fe82d8b40a0a0e58b86d64ffed0de06c
[ "MIT" ]
15
2019-05-07T11:26:13.000Z
2022-01-12T18:26:45.000Z
DEM/Low/src/Resources/Resource.h
niello/deusexmachina
2f698054fe82d8b40a0a0e58b86d64ffed0de06c
[ "MIT" ]
16
2021-10-04T17:15:31.000Z
2022-03-20T09:34:29.000Z
DEM/Low/src/Resources/Resource.h
niello/deusexmachina
2f698054fe82d8b40a0a0e58b86d64ffed0de06c
[ "MIT" ]
2
2019-04-28T23:27:48.000Z
2019-05-07T11:26:18.000Z
#pragma once #include <Core/Object.h> #include <Data/StringID.h> // A container that wraps some actual resource object along with any information // required for its management. This class is not intended to be a base class for // specific resources. Inherit from a CObject instead. // Resource UID may consist of 2 parts and must have at least one of them. // Format is "engine:path/to/file.ext#Id". '#' is a delimiter, you can't // use it as an identifier part. System processes UIDs as follows: // a) "engine:path/to/file.ext" is loaded from file with 1 file - 1 resource relation; // b) "#Id" is generated procedurally and is not associated with a file; // c) "engine:path/to/file.ext#Id" is intended for loading from files that contain // multiple resources. Loader will use an "Id" part to select a subresource to load. // TODO: can implement own refcounting and drop virtual table & destructor required by CRefCounted namespace Resources { typedef Ptr<class IResourceCreator> PResourceCreator; typedef Ptr<class CResource> PResource; enum class EResourceState : U8 { NotLoaded, LoadingRequested, LoadingInProgress, Loaded, LoadingFailed, LoadingCancelled }; class CResource final : public Data::CRefCounted { protected: CStrID _UID; ::Core::PObject _Object; // Actual object, such as a texture or a game object description PResourceCreator _Creator; // For (re)creation of an actual resource object EResourceState _State = EResourceState::NotLoaded; //Core::PObject _Placeholder; //???here or register per RTTI in Mgr? //UPTR _ByteSize = 0; //???or getter with redirection to Core::PObject? public: CResource(CStrID UID); virtual ~CResource() override; template<class T> T* GetObject() { ::Core::CObject* pObj = GetObject(); return (pObj && pObj->IsA<T>()) ? static_cast<T*>(pObj) : nullptr; } template<class T> T* ValidateObject() { ::Core::CObject* pObj = ValidateObject(); return (pObj && pObj->IsA<T>()) ? static_cast<T*>(pObj) : nullptr; } ::Core::CObject* GetObject(); ::Core::CObject* ValidateObject(); void Unload(); //PJob ValidateObjectAsync(callback on finished); - doesn't create a job if already actual CStrID GetUID() const { return _UID; } EResourceState GetState() const { return _State; } //!!!must be thread-safe! bool IsLoaded() const { return _State == EResourceState::Loaded; } //!!!must be thread-safe! IResourceCreator* GetCreator() const { return _Creator.Get(); } void SetCreator(IResourceCreator* pNewCreator); }; }
33.828947
106
0.709841
[ "object" ]
4a783355461b9d3be4043e4da6a9b007373b98fc
69,168
h
C
Source/Readers/HTKMLFReader/msra_mgram.h
adonese/CNTK
4fe5fd725176f8fbd59ad1d4e233b5bdf0b2d846
[ "RSA-MD" ]
1
2021-07-06T02:57:10.000Z
2021-07-06T02:57:10.000Z
Source/Readers/HTKMLFReader/msra_mgram.h
adonese/CNTK
4fe5fd725176f8fbd59ad1d4e233b5bdf0b2d846
[ "RSA-MD" ]
null
null
null
Source/Readers/HTKMLFReader/msra_mgram.h
adonese/CNTK
4fe5fd725176f8fbd59ad1d4e233b5bdf0b2d846
[ "RSA-MD" ]
null
null
null
// // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE.md file in the project root for full license information. // // msra_mgram.h -- simple ARPA LM read and access function // #pragma once #include "Basics.h" #include "fileutil.h" // for opening/reading the ARPA file #include <vector> #include <string> #include <unordered_map> #include <algorithm> // for various sort() calls #include <math.h> namespace msra { namespace lm { // =========================================================================== // core LM interface -- LM scores are accessed through this exclusively // =========================================================================== class ILM // generic interface -- mostly the score() function { public: virtual double score(const int *mgram, int m) const = 0; virtual bool oov(int w) const = 0; // needed for perplexity calculation // ... TODO (?): return true/false to indicate whether anything changed. // Intended as a signal to derived LMs that cache values. virtual void adapt(const int *data, size_t m) = 0; // (NULL,M) to reset, (!NULL,0) to flush // iterator for composing models --iterates in increasing order w.r.t. w class IIter { public: virtual operator bool() const = 0; // has iterator not yet reached end? // ... TODO: ensure iterators do not return OOVs w.r.t. user symbol table // (It needs to be checked which LM type's iterator currently does.) virtual void operator++() = 0; // advance by one // ... TODO: change this to key() or something like this virtual std::pair<const int *, int> operator*() const = 0; // current m-gram (mgram,m) virtual std::pair<double, double> value() const = 0; // current (logP, logB) }; virtual IIter *iter(int minM = 0, int maxM = INT_MAX) const = 0; virtual int order() const = 0; // order, e.g. 3 for trigram virtual size_t size(int m) const = 0; // return #m-grams // diagnostics functions -- not all models implement these virtual int getLastLongestHistoryFound() const = 0; virtual int getLastLongestMGramFound() const = 0; }; // =========================================================================== // log-add helpers // =========================================================================== const double logzero = -1e30; static inline double logadd(double x, double y) { double diff = y - x; double sum = x; // x no longer used after this if (diff > 0) { sum = y; // y no longer used after this diff = -diff; // that means we need to negate diff } if (diff > -24.0) // approx. from a constant from fmpe.h sum += log(1.0 + exp(diff)); return sum; } // take the log, but clip to logzero template <class FLOATTYPE> // float or double static inline FLOATTYPE logclip(FLOATTYPE x) { // ... TODO: use the proper constants here (slightly inconsistent) return x > (FLOATTYPE) 1e-30 ? log(x) : (FLOATTYPE) logzero; } // compute 1-P in logarithmic representation static inline double invertlogprob(double logP) { return logclip(1.0 - exp(logP)); } // =========================================================================== // CSymbolSet -- a simple symbol table // =========================================================================== // compare function to allow char* as keys (without, unordered_map will correctly // compute a hash key from the actual strings, but then compare the pointers // -- duh!) struct less_strcmp : public binary_function<const char *, const char *, bool> { // this implements operator< bool operator()(const char *const &_Left, const char *const &_Right) const { return strcmp(_Left, _Right) < 0; } }; class CSymbolSet : public std::unordered_map<const char *, int, std::hash<const char *>, less_strcmp> { vector<const char *> symbols; // the symbols CSymbolSet(const CSymbolSet &); CSymbolSet &operator=(const CSymbolSet &); public: CSymbolSet() { symbols.reserve(1000); } ~CSymbolSet() { clear(); } void clear() { foreach_index (i, symbols) free((void *) symbols[i]); unordered_map::clear(); } // operator[key] on a 'const' object // get id for an existing word, returns -1 if not existing int operator[](const char *key) const { unordered_map<const char *, int>::const_iterator iter = find(key); return (iter != end()) ? iter->second : -1; } // operator[key] on a non-'const' object // determine unique id for a word ('key') int operator[](const char *key) { unordered_map<const char *, int>::const_iterator iter = find(key); if (iter != end()) return iter->second; // create const char *p = _strdup(key); if (!p) BadExceptionError("CSymbolSet:id string allocation failure"); try { int id = (int) symbols.size(); symbols.push_back(p); // we own the memory--remember to free it insert(make_pair(p, id)); return id; } catch (...) { free((void *) p); throw; } } // return symbol string for a given id // Returned pointer is owned by this object. inline const char *operator[](int id) const { return symbols[id]; } // overloads to be compatible with C++ strings and CSymMap int sym2existingId(const string &key) const { return (*this)[key.c_str()]; } int sym2id(const string &key) { return (*this)[key.c_str()]; } inline const char *id2sym(int id) { return (*this)[id]; } // some helpers for writing and reading back a symbol set void write(FILE *f) { fputTag(f, "SYMS"); // header fputint(f, (int) size()); // symbol set foreach_index (k, symbols) fputstring(f, symbols[k]); } void read(FILE *f) { clear(); // clear out what was there before (typically nothing) fcheckTag(f, "SYMS"); int numWords = fgetint(f); char buf[1000]; for (int k = 0; k < numWords; k++) { fgetstring(f, buf); int id = (*this)[buf]; if (id != k) RuntimeError("plsa: sequence error while reading vocabulary"); } } }; // =========================================================================== // mgram_map -- lookup table for mgrams // =========================================================================== // variable naming convention for word ids: // - w a word in user space // Defined by userSymMap::operator[](string) passed to read(). // Data passed to score() and adapt() functions are in 'w' space. // - id an id in internal LM space // E.g. defined by vocabulary in LM input file. // All external LM accesses involve an implicit mapping, including: // w -> id --for calls to score() and adapt() // id -> w --for iterators (IIter++ orders by and *IIter returns keys in 'w' space) // representation of LM in memory // LMs are stored sparsely, i.e. only used elements are stored. // For each m-gram, a score is stored. For each history, a back-off weight is stored. // Both are stored in flat arrays, one per order, that are concatenations of // individual arrays per history. // The mgram_map provides a measure of locating these entries. For each level, // it stores a flat array of 'firsts' which point to the first child entry in // the next level (the next 'firsts' value denotes the end). // The mgram_map also stores word ids, which are the indexes of the sparse // elements. // To access an m-gram score of back-off weight, the mgram_map structure is // traversed, involving a binary search operation at each level. // a compact vector to hold 24-bit vaulues class int24_vector : std::vector<unsigned char> { public: // basic (non-tricky) operations --just multiply anything by 3 int24_vector() { } int24_vector(size_t n) : std::vector<unsigned char>(n * 3) { } void resize(size_t n) { std::vector<unsigned char> &base = *this; base.resize(n * 3); } void reserve(size_t n) { std::vector<unsigned char> &base = *this; base.reserve(n * 3); } void swap(int24_vector &other) { std::vector<unsigned char> &base = *this; base.swap(other); } size_t size() const { const std::vector<unsigned char> &base = *this; return base.size() / 3; } bool empty() const { const std::vector<unsigned char> &base = *this; return base.empty(); } // a reference to a 3-byte int (not a naked pointer as we cannot just assign to it) template <class T> class uint24_ref_t { protected: T p; friend class int24_vector; // only int24_vector may instantiate this __forceinline uint24_ref_t(T p) : p(p) { } public: // access __forceinline operator int() const { return (((((signed char) p[2]) << 8) + p[1]) << 8) + p[0]; } }; typedef uint24_ref_t<const unsigned char *> const_uint24_ref; // const version (only read) class uint24_ref : public uint24_ref_t<unsigned char *> // non-const (read and assign) { static void overflow() { RuntimeError("uint32_ref: attempting to store value > 24 bits"); } protected: friend class int24_vector; // only int24_vector may instantiate this __forceinline uint24_ref(unsigned char *p) : uint24_ref_t(p) { } public: // assignment operator __forceinline int operator=(int value) { if ((unsigned int) (value + 0x800000) > 0xffffff) overflow(); p[0] = (unsigned char) value; p[1] = (unsigned char) (value >> 8); p[2] = (unsigned char) (value >> 16); assert(value == (int) *this); return value; } }; // reading and writing __forceinline uint24_ref operator[](size_t i) { std::vector<unsigned char> &base = *this; return uint24_ref(&base[i * 3]); } __forceinline const_uint24_ref operator[](size_t i) const { const std::vector<unsigned char> &base = *this; return const_uint24_ref(&base[i * 3]); } __forceinline int back() const { const std::vector<unsigned char> &base = *this; return const_uint24_ref(&base[base.size() - 3]); } void push_back(int value) { std::vector<unsigned char> &base = *this; size_t cursize = base.size(); size_t newsize = cursize + 3; if (newsize > base.capacity()) base.reserve(newsize * 2); // double the size to ensure constant-time base.resize(newsize); uint24_ref r = uint24_ref(&base[cursize]); r = value; assert(value == back()); } }; // maps from m-grams to m-gram storage locations. class mgram_map { typedef unsigned int index_t; // (-> size_t when we really need it) // typedef size_t index_t; // (tested once, seems to work) static const index_t nindex; // invalid index // entry [m][i] is first index of children in level m+1, entry[m][i+1] the end. int M; // order, e.g. M=3 for trigram std::vector<std::vector<index_t>> firsts; // [M][i] ([0] = zerogram = root) std::vector<int24_vector> ids; // [M+1][i] ([0] = not used) bool level1nonsparse; // true: level[1] can be directly looked up std::vector<index_t> level1lookup; // id->index for unigram level static void fail(const char *msg) { RuntimeError("mgram_map::%s", msg); } // mapping from w -> i -- users pass 'w', internally we use our own 'ids' std::vector<int> w2id; // w -> id std::vector<int> id2w; // id -> w int idmax; // max id ever encountered by create() inline int map(int w) const { if (w < 0 || w >= (int) w2id.size()) return -1; else return w2id[w]; } // get index for 'id' in level m+1, as a child of index i in level m. // Returns -1 if not found. // This is a relatively generic binary search. inline index_t find_child(int m, index_t i, int id) const { // unigram level is a special case where we can avoid searching if (m == 0) { if (id < 0) return nindex; index_t i; if (level1nonsparse) i = (index_t) id; else // sparse: use a look-up table { if ((size_t) id >= level1lookup.size()) return nindex; i = level1lookup[id]; } assert(i == nindex || ids[1][i] == id); return i; } index_t beg = firsts[m][i]; index_t end = firsts[m][i + 1]; const int24_vector &ids_m1 = ids[m + 1]; while (beg < end) { index_t i = (beg + end) / 2; int v = ids_m1[i]; if (id == v) return i; // found it else if (id < v) end = i; // id is left of i else beg = i + 1; // id is right of i } return nindex; // not found } public: // --- allocation mgram_map() { } mgram_map(int p_M) { init(p_M); } // construct void init(int p_M) { clear(); M = p_M; firsts.assign(M, std::vector<index_t>(1, 0)); ids.assign(M + 1, int24_vector()); ids[0].resize(1); // fake zerogram entry for consistency ids[0][0] = -1; } // reserve memory for a level void reserve(int m, size_t size) { if (m == 0) return; // cannot reserve level 0 ids[m].reserve(size); if (m < M) firsts[m].reserve(size + 1); if (m == 1) level1lookup.reserve(size); } // allow to reduce M after the fact void resize(int newM) { if (newM > M) fail("resize() can only shrink"); M = newM; firsts.resize(M); ids.resize(M + 1); } // destruct void clear() { M = 0; firsts.clear(); ids.clear(); w2id.clear(); id2w.clear(); idmax = -1; } // size inline int size(int m) const { return (int) ids[m].size(); } // swap --used e.g. in merging void swap(mgram_map &other) { ::swap(M, other.M); firsts.swap(other.firsts); ids.swap(other.ids); ::swap(level1nonsparse, other.level1nonsparse); level1lookup.swap(other.level1lookup); w2id.swap(other.w2id); id2w.swap(other.id2w); ::swap(idmax, other.idmax); } // --- id mapping // test whether a word id is known in this model inline bool oov(int w) const { return map(w) < 0; } // return largest used word id (=last entry in unigram ids[]) int maxid() const { return idmax; } // return largest used w (only after created()) int maxw() const { return -1 + (int) w2id.size(); } // map is indexed with a 'key'. // A key represents an m-gram by storing a pointer to the original array. // The key allows to remove predicted word (pop_w()) or history (pop_h()). class key { protected: friend class mgram_map; const int *mgram; // pointer to mgram array --key does not own that memory! int m; // elements in mgram array public: // constructors inline key() : mgram(NULL), m(0) { } // required for use in std::vector inline key(const int *mgram, int m) : mgram(mgram), m(m) { } // manipulations inline key pop_h() const { if (m == 0) fail("key::pop_h() called on empty key"); return key(mgram + 1, m - 1); } inline key pop_w() const { if (m == 0) fail("key::pop_w() called on empty key"); return key(mgram, m - 1); } // access inline int back() const { if (m == 0) fail("key::back() called on empty key"); return mgram[m - 1]; } inline const int &operator[](int n) const { if (n < 0 || n >= m) fail("key::operator[] out of bounds"); return mgram[n]; } inline int order() const { return m; } // key comparison (used in sorting and merging) inline bool operator<(const key &other) const { for (int k = 0; k < m && k < other.m; k++) if (mgram[k] != other.mgram[k]) return mgram[k] < other.mgram[k]; return m < other.m; } inline bool operator>(const key &other) const { return other < *this; } inline bool operator<=(const key &other) const { return !(*this > other); } inline bool operator>=(const key &other) const { return !(*this < other); } inline bool operator==(const key &other) const { if (m != other.m) return false; for (int k = 0; k < m; k++) if (mgram[k] != other.mgram[k]) return false; return true; } inline bool operator!=(const key &other) const { return !(*this == other); } }; // 'coord' is an abstract coordinate of an m-gram. This is returned by // operator[], and is used as an index in our sister structure, mgram_data. struct coord { index_t i; // index in that level -- -1 means not found unsigned short m; // level inline bool valid() const { return i != nindex; } inline void validate() const { if (!valid()) fail("coord used but invalid"); } void invalidate() { i = nindex; } inline int order() const { validate(); return m; } inline coord(int m, index_t i) : m((unsigned short) m), i(i) { } // valid coord // ^^ this is where we'd test for index_t overflow if we ever need it inline coord(bool valid = true) : m(0), i(valid ? 0 : nindex) { } // root or invalid }; // 'foundcoord' is an extended 'coord' as returned by operator[], with // information on whether it is valid or not, and whether it refers to // an m-gram or to a history only. class foundcoord : public /*<-want to get rid of this*/ coord { const short type; foundcoord &operator=(const foundcoord &); public: inline bool valid_w() const { return type > 0; } inline bool valid_h() const { return type == 0; } inline bool valid() const { return type >= 0; } inline operator const coord &() const { return *this; } inline foundcoord(short type, int m, index_t i) : type(type), coord(m, i) { } inline foundcoord(short type) : type(type), coord(type >= 0) { } }; // search for an mgram -- given a 'key', return its 'coord.' // If m-gram is found, type=1. If only history found then type=0, and // coord represents the history token instead. // The given key may not be longer than our storage (we do not automatically // truncate because that would not be detectable by caller). __forceinline foundcoord operator[](const key &k) const { if (k.m > M) // call truncate() first with too long keys fail("operator[] called with too long key"); if (k.m == 0) return foundcoord(1); // zerogram -> root // We traverse history one by one. index_t i = 0; for (int n = 1; n < k.m; n++) { int w = k[n - 1]; // may be -1 for unknown word int id = map(w); // may still be -1 // const char * sym = idToSymbol (id); sym; // (debugging) i = find_child(n - 1, i, id); if (i == nindex) // unknown history: fall back return foundcoord(-1); // indicates failure // found it: advance search by one history token } // Found history. Do we also find the prediced word? int w = k[k.m - 1]; // may be -1 for unknown word int id = map(w); // may still be -1 index_t i_m = find_child(k.m - 1, i, id); if (i_m == nindex) // not found return foundcoord(0, k.m - 1, i); else // found return foundcoord(1, k.m, i_m); } // truncate a key to the m-gram length supported by this inline key truncate(const key &k) const { if (k.m <= M) return k; else return key(k.mgram + (k.m - M), M); } // --- iterators // - iterating over children of a history // - deep-iterating over the entire tree // for (iterator iter (mgram_map, parent_coord); iter; ++iter) { mgram_data[iter]; w=*iter; } class iterator : public coord { index_t end; // end index: i is invalid when it reaches this const mgram_map &map; // remembered for operator* void operator=(const iterator &); public: // bool: true if can use or increment inline operator bool() const { return i < end; } // increment inline void operator++() { if (i < end) i++; else fail("iterator used beyond end"); } // retrieve word -- returns -1 if not used in user's w->id map, e.g. skipped word inline int operator*() const { if (i >= end) fail("iterator used beyond end"); return map.id2w[map.ids[m][i]]; } // construct 'coord' as first element iterator(const mgram_map &map, const coord &c) : map(map) { c.validate(); // get the range index_t beg = map.firsts[c.m][c.i]; // first element of child end = map.firsts[c.m][c.i + 1]; // end = first of next entry // set the first child coordinate m = c.m + 1; // we iterate over the child level i = beg; // first element } // alternative to loop over all m-grams of a level iterator(const mgram_map &map, int m) : map(map), coord(m, 0) { end = (m > 0) ? (index_t) map.ids[m].size() : 1; // loop over entire vector } }; // for (deep_iterator iter (mgram_map, maxM); iter; ++iter) { mgram_data[iter]; key=*iter; } class deep_iterator : public coord { protected: int maxM; std::vector<index_t> pos; // current position [0..m] std::vector<int> mgram; // current m-gram corresponding to 'pos' const mgram_map &map; // remembered for operator* void operator=(const deep_iterator &); void validate() const { if (!valid()) fail("iterator used beyond end"); } public: // constructor deep_iterator(const mgram_map &map, int p_maxM = -1) : map(map), maxM(p_maxM), coord(map.firsts[0].size() >= 2) { if (maxM == -1) maxM = map.M; else if (maxM > map.M) fail("deep_iterator instantiated for invalid maximum depth"); mgram.resize(maxM, -1); pos.resize(maxM + 1, 0); } // bool: true if can use or increment inline operator bool() const { return valid(); } // increment inline void operator++() { validate(); // if current position has a child then enter it if (m < maxM && m < map.M && map.firsts[m][pos[m]] < map.firsts[m][pos[m] + 1]) { i = map.firsts[m][pos[m]]; m++; pos[m] = i; mgram[m - 1] = map.id2w[map.ids[m][i]]; return; } // advance vertically or step up one level for (; m > 0;) { // advance current position if still elements left i++; if (i < map.firsts[m - 1][pos[m - 1] + 1]) // not hit the end yet { pos[m] = i; mgram[m - 1] = map.id2w[map.ids[m][i]]; return; } // cannot enter or advance: step back one m--; i = pos[m]; // parent position } // reached the end invalidate(); // invalidates 'coord'--next call to bool() will return false return; } // retrieve keys -- returns -1 if not used in user's w->id map, e.g. skipped word // The key points into the iterator structure, i.e. it operator++ invalidates it! inline key operator*() const { validate(); return key(&mgram[0], m); } }; // for (reordering_iterator iter (mgram_map, wrank[], maxM); iter; ++iter) { mgram_data[iter]; key=*iter; } // Like deep_iterator, but iterates the map such that ws are returned in // increasing wrank[w] rather than in the original storage order. // Used for merging multiple models such as linear interpolation. class reordering_iterator : public deep_iterator { const std::vector<int> &wrank; // assigns a rank to each w const char *i; // hide coord::i against accidental access std::vector<std::vector<index_t>> indexes; // coord::i <- indexes[m][this->i] std::vector<index_t> indexbase; // indexes[m] is indexbase[m]-based inline index_t &index_at(int m, index_t i) { return indexes[m][i - indexbase[m]]; } std::vector<std::pair<int, int>> sortTemp; // temp for creating indexes void operator=(const reordering_iterator &); public: // constructor reordering_iterator(const mgram_map &map, const std::vector<int> &wrank, int p_maxM = -1) : deep_iterator(map, p_maxM), wrank(wrank) { if (wrank.size() < map.w2id.size()) fail("reordering_iterator: wrank has wrong dimension"); indexes.resize(maxM + 1); indexes[0].push_back(0); // look-up table for root: only one item indexbase.resize(maxM + 1, 0); pos[0] = coord::i; // zerogram level: same i because no mapping there if (map.M >= 1) sortTemp.reserve(map.size(1)); } // increment // We iterate through the map using (m, pos[m]) while user consumes (m, i) // i.e. for operator++(), coord::i is not iterated but a return value. inline void operator++() { validate(); // if current position has a child then enter it // Note: We enter the item that coord::i points to, which is not pos[m] // but the mapped pos[m]. if (m < maxM && m < map.M && map.firsts[m][index_at(m, pos[m])] < map.firsts[m][index_at(m, pos[m]) + 1]) { // enter the level index_t beg = map.firsts[m][index_at(m, pos[m])]; // index range of sub-level index_t end = map.firsts[m][index_at(m, pos[m]) + 1]; m++; pos[m] = beg; // build look-up table for returned values size_t num = end - beg; // we sort i by rank (and i, keeping original order for identical rank) sortTemp.resize(end - beg); foreach_index (k, sortTemp) { index_t i = beg + k; int id = map.ids[m][i]; int w = map.id2w[id]; sortTemp[k] = std::make_pair(wrank[w], i); } std::sort(sortTemp.begin(), sortTemp.end()); // remember sorted i's indexbase[m] = beg; // used by index_at (m, *) indexes[m].resize(num); foreach_index (k, sortTemp) index_at(m, k + beg) = sortTemp[k].second; // set up return values coord::i = index_at(m, pos[m]); mgram[m - 1] = map.id2w[map.ids[m][coord::i]]; return; } // advance vertically or step up one level for (; m > 0;) { // advance current position if still elements left // use our own i (in pos[m]), then map to coord::i using sorted list pos[m]++; if (pos[m] < map.firsts[m - 1][index_at(m - 1, pos[m - 1]) + 1]) // not hit the end yet { coord::i = index_at(m, pos[m]); mgram[m - 1] = map.id2w[map.ids[m][coord::i]]; return; } // cannot enter or advance: step back one m--; } // reached the end invalidate(); // invalidates 'coord'--next call to bool() will return false return; } }; // --- functions for building // 'unmapped_key' contains original 'id' rather than 'w' values. It is only // used for create()--at creation time, we use our private mapping. typedef key unmapped_key; // create a new key (to be called in sequence). // Only the last word given in the key is added. The history of the given // mgram must already exist and must be the last. // Important: Unlike operator[], create() takes an unmapped_key, i.e. the // mapping is not applied. // 'cache' is used for speed-up, it must be as large as key.m-1 and // initialized to 0. #pragma warning(push) // known compiler bug: size_t (marked _w64) vs. unsigned... #pragma warning(disable : 4267) // ...int (not marked) incorrectly flagged in templates typedef std::vector<index_t> cache_t; coord create(const unmapped_key &k, cache_t &cache) { if (k.m < 1) return coord(); // (root need not be created) // locate history (must exist), also updates cache[] bool prevValid = true; index_t i = 0; // index of history in level k.m-1 if (cache.empty()) cache.resize(M, nindex); // lazy initialization for (int m = 1; m < k.m; m++) { int thisid = k[m - 1]; if (prevValid && cache[m - 1] != nindex && ids[m][cache[m - 1]] == thisid) { i = cache[m - 1]; // get from cache continue; } // need to actually search i = find_child(m - 1, i, thisid); if (i == nindex) fail("create() called with unknown history"); cache[m - 1] = i; prevValid = false; } for (int m = k.m; m < M && cache[m - 1] != nindex; m++) cache[m - 1] = nindex; // clear upper entries (now invalid) // now i is the index of the id of the last history item // make the firsts entry if not there yet bool newHist = (firsts[k.m - 1].size() < (size_t) i + 2); while (firsts[k.m - 1].size() < (size_t) i + 2) // [i+1] is the end for this array firsts[k.m - 1].push_back((mgram_map::index_t) ids[k.m].size()); if (firsts[k.m - 1].size() != (size_t) i + 2) fail("create() called out of order (history)"); // create new word id int thisid = k[k.m - 1]; if (!newHist && thisid <= ids[k.m].back()) fail("create() called out of order"); // keep track of idmax if (thisid > idmax) idmax = thisid; coord c(k.m, (index_t) ids[k.m].size()); assert(firsts[k.m - 1].back() == (index_t) ids[k.m].size()); ids[k.m].push_back(thisid); // create value firsts[k.m - 1].back() = (index_t) ids[k.m].size(); if (firsts[k.m - 1].back() != (index_t) ids[k.m].size()) fail("create() numeric overflow--index_t too small"); assert(k.m == M || firsts[k.m].back() == (index_t) ids[k.m + 1].size()); // optimization: level1nonsparse flag // If unigram level is entirely non-sparse, we can save the search // operation at that level, which is significantly slower than for the // much sparser higher levels. if (c.m == 1) { if (c.i == 0) level1nonsparse = true; // first entry level1nonsparse &= (c.i == (index_t) thisid); // no search needed level1lookup.resize(thisid + 1, nindex); level1lookup[thisid] = c.i; } return c; } #pragma warning(pop) // call this at the end // - establish the w->id mapping that is used in operator[] // - finalize the firsts arrays // This function swaps the user-provided map and our current one. // We use swapping to avoid the memory allocation (noone else outside should // have to keep the map). // This function also builds our internal reverse map used in the iterator. void created(std::vector<int> &userToLMSymMap) { // finalize firsts arrays foreach_index (m, firsts) firsts[m].resize(ids[m].size() + 1, (int) ids[m + 1].size()); foreach_index (m, firsts) { assert(firsts[m][0] == 0); foreach_index (i, ids[m]) assert(firsts[m][i] <= firsts[m][i + 1]); assert((size_t) firsts[m].back() == ids[m + 1].size()); } // id mapping // user-provided w->id map ::swap(w2id, userToLMSymMap); // reverse map id2w.assign(maxid() + 1, nindex); foreach_index (w, w2id) { int id = w2id[w]; if (id < 0) continue; // invalid word if (id > maxid()) continue; // id not in use id2w[id] = w; } } // helper for created()--return an identical map, as we have several // occasions where such a map is passed as userToLMSymMap to created(). std::vector<int> identical_map(size_t n = SIZE_MAX) const { if (n == SIZE_MAX) n = maxid() + 1; std::vector<int> v(n); foreach_index (i, v) v[i] = i; return v; } // decide whether iterator will return in increasing w order bool inorder() const { #if 0 // fix this: need access to w2id, or have an inorder() function in mgram_map bool inorder = true; for (int i = 1; inorder && i < (int) map.w2id.size(); i++) inorder &= (map.w2id[i+1] >= map.w2id[i]); #endif return false; } }; // =========================================================================== // mgram_data -- data stored according to mgram_map // Separate from mgram_map, so that we can share the same map for multiple data. // =========================================================================== template <class DATATYPE> class mgram_data { std::vector<std::vector<DATATYPE>> data; static void fail(const char *msg) { RuntimeError("mgram_data::%s", msg); } public: mgram_data() { } mgram_data(int M) { init(M); } // for an M-gram, indexes [0..M] are valid thus data[] has M+1 elements void init(int M) { data.assign(M + 1, std::vector<DATATYPE>()); } void reserve(int m, size_t size) { data[m].reserve(size); } void resize(int M) { if ((size_t) M + 1 <= data.size()) data.resize(M + 1); else fail("resize() can only shrink"); } size_t size(int m) const { return data[m].size(); } size_t size() const { size_t sz = 0; foreach_index (m, data) sz += size(m); return sz; } void clear() { data.clear(); } void swap(mgram_data &other) { data.swap(other.data); } // access existing elements. Usage: // DATATYPE & element = mgram_data[mgram_map[mgram_map::key (mgram, m)]] __forceinline DATATYPE &operator[](const mgram_map::coord &c) { c.validate(); return data[c.m][c.i]; } __forceinline const DATATYPE &operator[](const mgram_map::coord &c) const { c.validate(); return data[c.m][c.i]; } // create entire vector (for random-access situations). void assign(int m, size_t size, const DATATYPE &value) { data[m].assign(size, value); } // create an element. We can only append. inline void push_back(const mgram_map::coord &c, const DATATYPE &val) { c.validate(); if (data[c.m].size() != (size_t) c.i) fail("push_back() only allowed for last entry"); data[c.m].push_back(val); } }; // =========================================================================== // CMGramLM -- a back-off M-gram language model in memory, loaded from an ARPA file // =========================================================================== class CMGramLM : public ILM { protected: #if 0 void clear() // release all memory --object unusable after this { M = -1; map.clear(); logP.clear(); logB.clear(); } #endif int M; // e.g. M=3 for trigram // ^^ TODO: can we do away with this entirely and replace it by map.order()/this->order() mgram_map map; mgram_data<float> logP; // [M+1][i] probabilities mgram_data<float> logB; // [M][i] back-off weights (stored for histories only) friend class CMGramLMIterator; // diagnostics of previous score() call mutable int longestMGramFound; // longest m-gram (incl. predicted token) found mutable int longestHistoryFound; // longest history (excl. predicted token) found // this function is for reducing M after the fact, e.g. during estimation // ... TODO: rethink the resize business. It is for shrinking only. void resize(int newM) { M = newM; map.resize(M); } public: CMGramLM() : M(-1) { } // needs explicit initialization through read() or init() virtual int getLastLongestHistoryFound() const { return longestHistoryFound; } virtual int getLastLongestMGramFound() const { return longestMGramFound; } // ----------------------------------------------------------------------- // score() -- compute an m-gram score (incl. back-off and fallback) // ----------------------------------------------------------------------- // mgram[m-1] = word to predict, tokens before that are history // m=3 means trigram virtual double score(const int *mgram, int m) const { longestHistoryFound = 0; // (diagnostics) double totalLogB = 0.0; // accumulated back-off for (mgram_map::key key = map.truncate(mgram_map::key(mgram, m));; key = key.pop_h()) { // look up the m-gram const mgram_map::foundcoord c = map[key]; // (diagnostics -- can be removed if not used) if (c.valid() && key.order() - 1 > longestHistoryFound) longestHistoryFound = key.order() - 1; if (c.valid_w()) longestMGramFound = key.order(); // full m-gram found -> return it (zerogram always considered found) if (c.valid_w()) return totalLogB + logP[c]; // history found but predicted word not -> back-off if (c.valid_h()) // c is coordinate of parent instead totalLogB += logB[c]; // and continue like fall back // history not found -> fall back } // and go again with the shortened history } // same as score() but without optimizations (for reference) // ... this is really no longer needed virtual double score_unoptimized(const int *mgram, int m) const { return score_unoptimized(map.truncate(mgram_map::key(mgram, m))); } inline double score_unoptimized(const mgram_map::key &key) const { // look up the m-gram const mgram_map::foundcoord c = map[key]; // full m-gram found -> return it if (c.valid_w()) return logP[c]; // history found but predicted word not -> back-off else if (c.valid_h()) // c is coordinate of patent instead return logB[c] + score_unoptimized(key.pop_h()); // history not found -> fall back else return score_unoptimized(key.pop_h()); } // test for OOV word (OOV w.r.t. LM) virtual bool oov(int w) const { return map.oov(w); } virtual void adapt(const int *, size_t) { } // this LM does not adapt private: // keep this for debugging std::wstring filename; // input filename struct SYMBOL { string symbol; // token int id; // numeric id in LM space (index of word read) bool operator<(const SYMBOL &other) const { return symbol < other.symbol; } SYMBOL(int p_id, const char *p_symbol) : id(p_id), symbol(p_symbol) { } }; std::vector<SYMBOL> lmSymbols; // (id, word) symbols used in LM std::vector<int> idToSymIndex; // map LM id to index in lmSymbols[] array // search for a word in the sorted word array. // Only use this after sorting, i.e. after full 1-gram section has been read. // Only really used in read(). inline int symbolToId(const char *word) const { int beg = 0; int end = (int) lmSymbols.size(); while (beg < end) { int i = (beg + end) / 2; const char *v = lmSymbols[i].symbol.c_str(); int cmp = strcmp(word, v); if (cmp == 0) return lmSymbols[i].id; // found it else if (cmp < 0) end = i; // id is left of i else beg = i + 1; // id is right of i } return -1; // not found } inline const char *idToSymbol(int id) const { if (id < 0) return NULL; // empty string for unknown ids int i = idToSymIndex[id]; return lmSymbols[i].symbol.c_str(); } private: // type cast to const char*, to allow write() to use both const char* and string static const char *const_char_ptr(const char *p) { return p; } static const char *const_char_ptr(const string &s) { return s.c_str(); } public: // write model out as an ARPA (text) file. // symbols can be anything that has symbols[w] -> std::string& or const char* template <class SYMMAP> void write(FILE *outf, const SYMMAP &symbols, int M = INT_MAX) const { if (M > this->M) M = this->M; // clip; also covers default value if (M < 1 || map.size(1) == 0) RuntimeError("write: attempting to write empty model"); // output header // \data\ // ngram 1=58289 // ngram 2=956100 // ... fprintfOrDie(outf, "\\data\\\n"); for (int m = 1; m <= M; m++) { fprintfOrDie(outf, "ngram %d=%d\n", m, map.size(m)); } fflushOrDie(outf); // output m-grams themselves // M-gram sections const double log10 = log(10.0); for (int m = 1; m <= M; m++) { fprintf(stderr, "estimate: writing %d %d-grams..", map.size(m), m); int step = (int) logP.size(m) / 100; if (step == 0) step = 1; int numMGramsWritten = 0; // output m-gram section fprintfOrDie(outf, "\n\\%d-grams:\n", m); for (mgram_map::deep_iterator iter(map, m); iter; ++iter) { if (iter.order() != m) // a parent continue; const mgram_map::key key = *iter; assert(m == key.order()); // --- output m-gram to ARPA file fprintfOrDie(outf, "%.4f", logP[iter] / log10); for (int k = 0; k < m; k++) { // the M-gram words int wid = key[k]; const char *w = const_char_ptr(symbols[wid]); fprintfOrDie(outf, " %s", w); } if (m < M) { // back-off weight (not for highest order) fprintfOrDie(outf, " %.4f", logB[iter] / log10); } fprintfOrDie(outf, "\n"); // progress if (numMGramsWritten % step == 0) { fprintf(stderr, "."); } numMGramsWritten++; } fflushOrDie(outf); assert(numMGramsWritten == map.size(m)); fprintf(stderr, "\n"); } fprintfOrDie(outf, "\n\\end\\\n"); fflushOrDie(outf); } // get TopM Ngram probability // GangLi add this function to do probability pruning double KeepTopMNgramThreshold(int topM, int ngram) { // initial return as a very low value double probThrshold = -99; // check if nessary to prune if (map.size(ngram) > topM) { std::vector<std::pair<int, float>> probArray; probArray.reserve(map.size(ngram)); } return probThrshold; } protected: // replace zerogram prob by one appropriate for OOVs // We use the minimum of all unigram scores (assuming they represent singleton // events, which are closest to a zerogram--a better choice may be a leaving- // one-out estimate?). // Back-off weight is reset to 1.0 such that there is no extra penalty on it. void updateOOVScore() { float unknownLogP = 0.0f; for (mgram_map::iterator iter(map, mgram_map::coord()); iter; ++iter) { if (logP[iter] < -98.0f) continue; // disabled token, such as <s>, does not count if (logP[iter] < unknownLogP) unknownLogP = logP[iter]; } logP[mgram_map::coord()] = unknownLogP; logB[mgram_map::coord()] = 0.0f; } public: // read an ARPA (text) file. // Words do not need to be sorted in the unigram section, but the m-gram // sections have to be in the same order as the unigrams. // The 'userSymMap' defines the vocabulary space used in score(). // If 'filterVocabulary' then LM entries for words not in userSymMap are skipped. // Otherwise the userSymMap is updated with the words from the LM. // 'maxM' allows to restrict the loading to a smaller LM order. // SYMMAP can be e.g. CSymMap or CSymbolSet. template <class SYMMAP> void read(const std::wstring &pathname, SYMMAP &userSymMap, bool filterVocabulary, int maxM) { int lineNo = 0; auto_file_ptr f(fopenOrDie(pathname, L"rbS")); fprintf(stderr, "read: reading %ls", pathname.c_str()); filename = pathname; // (keep this info for debugging) // --- read header information // search for header line char buf[1024]; lineNo++, fgetline(f, buf); while (strcmp(buf, "\\data\\") != 0 && !feof(f)) lineNo++, fgetline(f, buf); lineNo++, fgetline(f, buf); // get the dimensions std::vector<int> dims; dims.reserve(4); while (buf[0] == 0 && !feof(f)) lineNo++, fgetline(f, buf); int n, dim; dims.push_back(1); // dummy zerogram entry while (sscanf(buf, "ngram %d=%d", &n, &dim) == 2 && n == (int) dims.size()) { dims.push_back(dim); lineNo++, fgetline(f, buf); } M = (int) dims.size() - 1; if (M == 0) RuntimeError("read: mal-formed LM file, no dimension information (%d): %ls", lineNo, pathname.c_str()); int fileM = M; if (M > maxM) M = maxM; // allocate main storage map.init(M); logP.init(M); logB.init(M - 1); for (int m = 0; m <= M; m++) { map.reserve(m, dims[m]); logP.reserve(m, dims[m]); if (m < M) logB.reserve(m, dims[m]); } lmSymbols.reserve(dims[0]); logB.push_back(mgram_map::coord(), 0.0f); // dummy logB for backing off to zg logP.push_back(mgram_map::coord(), 0.0f); // zerogram score -- gets updated later std::vector<bool> skipWord; // true: skip entry containing this word skipWord.reserve(lmSymbols.capacity()); // --- read main sections const double ln10xLMF = log(10.0); // ARPA scores are strangely scaled msra::strfun::tokenizer tokens(" \t\n\r", M + 1); // used in tokenizing the input line for (int m = 1; m <= M; m++) { while (buf[0] == 0 && !feof(f)) lineNo++, fgetline(f, buf); if (sscanf(buf, "\\%d-grams:", &n) != 1 || n != m) RuntimeError("read: mal-formed LM file, bad section header (%d): %ls", lineNo, pathname.c_str()); lineNo++, fgetline(f, buf); std::vector<int> mgram(m + 1, -1); // current mgram being read ([0]=dummy) std::vector<int> prevmgram(m + 1, -1); // cache to speed up symbol lookup mgram_map::cache_t mapCache; // cache to speed up map.create() // read all the m-grams while (buf[0] != '\\' && !feof(f)) { if (buf[0] == 0) { lineNo++, fgetline(f, buf); continue; } // -- parse the line tokens = &buf[0]; if ((int) tokens.size() != ((m < fileM) ? m + 2 : m + 1)) RuntimeError("read: mal-formed LM file, incorrect number of tokens (%d): %ls", lineNo, pathname.c_str()); double scoreVal = atof(tokens[0]); // ... use sscanf() instead for error checking? double thisLogP = scoreVal * ln10xLMF; // convert to natural log bool skipEntry = false; for (int n = 1; n <= m; n++) { const char *tok = tokens[n]; // map to id int id; if (m == 1) // unigram: build vocab table { id = (int) lmSymbols.size(); // unique id for this symbol lmSymbols.push_back(SYMBOL(id, tok)); bool toSkip = false; if (userSymMap.sym2existingId(lmSymbols.back().symbol) == -1) { if (filterVocabulary) toSkip = true; // unknown word else userSymMap.sym2id(lmSymbols.back().symbol); // create it in user's space } skipWord.push_back(toSkip); } else // mgram: look up word in vocabulary { if (prevmgram[n] >= 0 && strcmp(idToSymbol(prevmgram[n]), tok) == 0) id = prevmgram[n]; // optimization: most of the time, it's the same else { id = symbolToId(tok); if (id == -1) RuntimeError("read: mal-formed LM file, m-gram contains unknown word (%d): %ls", lineNo, pathname.c_str()); } } mgram[n] = id; // that's our id skipEntry |= skipWord[id]; // skip entry if any token is unknown } double thisLogB = 0.0; if (m < M && !skipEntry) { double boVal = atof(tokens[m + 1]); // ... use sscanf() instead for error checking? thisLogB = boVal * ln10xLMF; // convert to natural log } lineNo++, fgetline(f, buf); if (skipEntry) // word contained unknown vocabulary: skip entire entry goto skipMGram; // -- enter the information into our data structure // Note that the mgram_map/mgram_data functions are highly efficient // because they can only be called in sorted order. // locate the corresponding entries { // (local block because we 'goto' over this) mgram_map::key key(&mgram[1], m); // key to locate this m-gram mgram_map::coord c = map.create(key, mapCache); // create it & gets its location // enter into data structure logP.push_back(c, (float) thisLogP); // prob value if (m < M) // back-off weight logB.push_back(c, (float) thisLogB); } skipMGram: // remember current mgram for next iteration ::swap(mgram, prevmgram); } // fix the symbol set -- now we can binary-search in them with symbolToId() if (m == 1) { std::sort(lmSymbols.begin(), lmSymbols.end()); idToSymIndex.resize(lmSymbols.size(), -1); for (int i = 0; i < (int) lmSymbols.size(); i++) { idToSymIndex[lmSymbols[i].id] = i; } } fprintf(stderr, ", %d %d-grams", map.size(m), m); } fprintf(stderr, "\n"); // check end tag if (M == fileM) { // only if caller did not restrict us to a lower order while (buf[0] == 0 && !feof(f)) lineNo++, fgetline(f, buf); if (strcmp(buf, "\\end\\") != 0) RuntimeError("read: mal-formed LM file, no \\end\\ tag (%d): %ls", lineNo, pathname.c_str()); } // update zerogram score by one appropriate for OOVs updateOOVScore(); // establish mapping of word ids from user to LM space. // map's operator[] maps mgrams using this map. std::vector<int> userToLMSymMap(userSymMap.size()); for (int i = 0; i < (int) userSymMap.size(); i++) { const char *sym = userSymMap.id2sym(i); int id = symbolToId(sym); // may be -1 if not found userToLMSymMap[i] = id; } map.created(userToLMSymMap); } protected: // sort LM such that iterators will iterate in increasing order w.r.t. w2id[w] // This is achieved by replacing all internal ids by w2id[w]. // This function is expensive: it makes a full temporary copy and involves sorting. // w2id[] gets destroyed by this function. void sort(std::vector<int> &w2id) { // create a full copy of logP and logB in the changed order mgram_map sortedMap(M); mgram_data<float> sortedLogP(M); mgram_data<float> sortedLogB(M - 1); for (int m = 1; m <= M; m++) { sortedMap.reserve(m, map.size(m)); sortedLogP.reserve(m, logP.size(m)); if (m < M) sortedLogB.reserve(m, logB.size(m)); } // iterate in order of w2id // Order is determined by w2id[], i.e. entries with lower new id are // returned first. std::vector<int> mgram(M + 1, -1); // unmapped key in new id space mgram_map::cache_t createCache; for (mgram_map::reordering_iterator iter(map, w2id); iter; ++iter) { int m = iter.order(); mgram_map::key key = *iter; // key in old 'w' space // keep track of an unmapped key in new id space if (m > 0) { int w = key.back(); int newid = w2id[w]; // map to new id space mgram[m - 1] = newid; } for (int k = 0; k < m; k++) assert(mgram[k] == w2id[key[k]]); // insert new key into sortedMap mgram_map::coord c = sortedMap.create(mgram_map::unmapped_key(&mgram[0], m), createCache); // copy over logP and logB sortedLogP.push_back(c, logP[iter]); if (m < M) sortedLogB.push_back(c, logB[iter]); } // finalize sorted map sortedMap.created(w2id); // replace LM by sorted LM map.swap(sortedMap); logP.swap(sortedLogP); logB.swap(sortedLogB); } public: // sort LM such that internal ids are in lexical order // After calling this function, iterators will iterate in lexical order, // and writing to an ARPA file creates a lexicographically sorted file. // Having sorted files is useful w.r.t. efficiency when iterating multiple // models in parallel, e.g. interpolating or otherwise merging models, // because then IIter can use the efficient deep_iterator (which iterates // in our internal order and therefore does not do any sorting) rather than // the reordering_iterator (which involves sort operations). template <class SYMMAP> void sort(const SYMMAP &userSymMap) { // deterine sort order // Note: This code copies all strings twice. std::vector<pair<std::string, int>> sortTemp(userSymMap.size()); // (string, w) foreach_index (w, sortTemp) sortTemp[w] = make_pair(userSymMap[w], w); std::sort(sortTemp.begin(), sortTemp.end()); std::vector<int> w2id(userSymMap.size(), -1); // w -> its new id foreach_index (id, w2id) w2id[sortTemp[id].second] = id; // sort w.r.t. new id space sort(w2id); } // iterator to enumerate all known m-grams // This is used when creating whole models at once. template <class ITERATOR> class TIter : public ILM::IIter { int minM; // minimum M we want to iterate (skip all below) const CMGramLM &lm; // the underlying LM (for value()) std::vector<int> wrank; // sorting criterion ITERATOR iter; // the iterator used in this interface void findMinM() { while (iter && iter.order() < minM) ++iter; } public: // constructors TIter(const CMGramLM &lm, int minM, int maxM) : minM(minM), lm(lm), iter(lm.map, maxM) { findMinM(); } TIter(const CMGramLM &lm, bool, int minM, int maxM) : minM(minM), lm(lm), wrank(lm.map.identical_map(lm.map.maxw() + 1)), iter(lm.map, wrank, maxM) { findMinM(); } // has iterator not yet reached end? virtual operator bool() const { return iter; } // advance by one virtual void operator++() { ++iter; findMinM(); } // current m-gram (mgram,m) virtual std::pair<const int *, int> operator*() const { mgram_map::key key = *iter; return std::make_pair(key.order() == 0 ? NULL : &key[0], key.order()); } // current value (logP, logB) // No processing here--read out the logP/logB values directly from the data structure. virtual std::pair<double, double> value() const { if (iter.order() < lm.M) return std::make_pair(lm.logP[iter], lm.logB[iter]); else return std::make_pair(lm.logP[iter], 0.0); } }; virtual IIter *iter(int minM, int maxM) const { if (maxM == INT_MAX) maxM = M; // default value // if no sorting needed, then we can use the efficient deep_iterator if (map.inorder()) return new TIter<mgram_map::deep_iterator>(*this, minM, maxM); // sorting needed: use reordering_iterator return new TIter<mgram_map::reordering_iterator>(*this, true, minM, maxM); } virtual int order() const { return M; } virtual size_t size(int m) const { return (int) logP.size(m); } protected: // computeSeenSums -- compute sum of seen m-grams, store at their history coord // If islog then P is logP, otherwise linear (non-log) P. template <class FLOATTYPE> static void computeSeenSums(const mgram_map &map, int M, const mgram_data<float> &P, mgram_data<FLOATTYPE> &PSum, mgram_data<FLOATTYPE> &backoffPSum, bool islog) { // dimension the accumulators and initialize them to 0 PSum.init(M - 1); for (int m = 0; m <= M - 1; m++) PSum.assign(m, map.size(m), 0); backoffPSum.init(M - 1); for (int m = 0; m <= M - 1; m++) backoffPSum.assign(m, map.size(m), 0); // iterate over all seen m-grams msra::basetypes::fixed_vector<mgram_map::coord> histCoord(M); // index of history mgram for (mgram_map::deep_iterator iter(map, M); iter; ++iter) { int m = iter.order(); if (m < M) histCoord[m] = iter; if (m == 0) continue; const mgram_map::key key = *iter; assert(m == key.order()); float thisP = P[iter]; if (islog) { if (thisP <= logzero) continue; // pruned or otherwise lost thisP = exp(thisP); } else { if (thisP == 0.0f) continue; // a pruned or otherwise lost m-gram } // parent entry const mgram_map::coord j = histCoord[m - 1]; // index of parent entry // accumulate prob in B field (temporarily misused) PSum[j] += thisP; // the mass of the back-off distribution covered by higher-order seen m-grams. // This must exist, as any sub-sequence of any seen m-mgram exists // due to the way we count the tokens. const mgram_map::key boKey = key.pop_h(); const mgram_map::foundcoord c = map[boKey]; if (!c.valid_w()) RuntimeError("estimate: malformed data: back-off value not found"); // must exist // look it up float Pc = P[c]; backoffPSum[j] += islog ? exp(Pc) : Pc; } } // computeBackoff -- compute back-off weights // Set up or update logB[] based on P[]. // logB[] is an output from this function only. // If islog then P is logP, otherwise linear (non-log) P. static void computeBackoff(const mgram_map &map, int M, const mgram_data<float> &P, mgram_data<float> &logB, bool islog) { mgram_data<float> backoffPSum; // accumulator for the probability mass covered by seen m-grams // sum up probabilities of seen m-grams // - we temporarily use the B field for the actual seen probs // - and backoffSum for their prob pretending we are backing off computeSeenSums(map, M, P, logB, backoffPSum, islog); // That has dimensioned logB as we need it. // derive the back-off weight from it for (mgram_map::deep_iterator iter(map, M - 1); iter; ++iter) { double seenMass = logB[iter]; // B field misused: sum over all seen children if (seenMass > 1.0) { if (seenMass > 1.0001) // (a minor round-off error is acceptable) fprintf(stderr, "estimate: seen mass > 1.0: %8.5f --oops??\n", seenMass); seenMass = 1.0; // oops? } // mass covered by seen m-grams is unused -> take out double coveredBackoffMass = backoffPSum[iter]; if (coveredBackoffMass > 1.0) { if (coveredBackoffMass > 1.0001) // 1.0 for unigrams, sometimes flags this fprintf(stderr, "estimate: unseen backoff mass < 0: %8.5f --oops??\n", 1.0 - coveredBackoffMass); coveredBackoffMass = 1.0; // oops? } // redistribute such that // seenMass + bow * usedBackoffMass = 1 // ==> bow = (1 - seenMass) / usedBackoffMass double freeMass = 1.0 - seenMass; double accessibleBackoffMass = 1.0 - coveredBackoffMass; // sum of all backed-off items // back-off weight is just the free probability mass double bow = (accessibleBackoffMass > 0) ? freeMass / accessibleBackoffMass : 1.0; // A note on the curious choice of bow=1.0 for accessibleBackoffMass==0: // If accessibleBackoffMass==0, we are in undefined territory. // Because this means we never back off. Problem is that we have // already discounted the probabilities, i.e. there is probability // mass missing (distribution not normalized). Possibilities for // remedying the normalization issue are: // 1. use linear interpolation instead generally // 2. use linear interpolation only for such distributions // 3. push mass into <UNK> class if available // 4. ignore the normalization problem. // We choose 2. for the unigram distribution (enforced outside of this // function), and 4. for all other cases. // A second question arises for OOV words in this case. With OOVs, // accessibleBackoffMass should no longer be 0, but we don't know its // value. Be Poov the mass of all OOV words, then // bow = (1 - seenMass) / Poov // Further, if seenMass was not discounted (as in our unigram case), // it computes to 1, but if we had accounted for Poov, it would // compute as (1-Poov) instead. Thus, // bow = (1 - (1-Poov)) / Poov = 1 // Realistically, this case happens for the unigram distribution. // Practically it means fallback instead of back-off for OOV words. // Also, practically, Poov is very small, so is the error. logB[iter] = logclip((float) bow); } } }; // =========================================================================== // CMGramLMIterator -- a special-purpose class that allows for direct iteration. // =========================================================================== class CMGramLMIterator : public msra::lm::mgram_map::iterator { const CMGramLM &lm; public: CMGramLMIterator(const CMGramLM &lm, mgram_map::coord c) : lm(lm), msra::lm::mgram_map::iterator(lm.map, c) { } float logP() const { return lm.logP[*this]; } float logB() const { return lm.logB[*this]; } float logB(mgram_map::coord c) const { return lm.logB[c]; } msra::lm::mgram_map::coord locate(const int *mgram, int m) const { msra::lm::mgram_map::foundcoord c = lm.map[msra::lm::mgram_map::key(mgram, m)]; if (!c.valid_w()) LogicError("locate: attempting to locate a non-existing history"); return c; } }; }; }; // namespace
35.146341
139
0.518115
[ "object", "vector", "model" ]
7d2367830216a169e17668b049a4778983b741a6
1,328
h
C
autoRepairForiOS/GCP/BaiduBCESTS.framework/Versions/A/Headers/STSClient.h
hfqf/autoRepair-iOS
770b82ba64c12e62eab3ddb3c7da1fa78b153840
[ "Apache-2.0" ]
1
2019-06-19T06:52:56.000Z
2019-06-19T06:52:56.000Z
Example/ThirdSDK/ThirdSDK/BaiduUploader/Frameworks/BaiduBCESTS.framework/Headers/STSClient.h
winterwine/CaamDau
65eb581db66376deefa95e01765b8a7019d521b6
[ "MIT" ]
1
2018-08-23T21:43:25.000Z
2018-08-23T21:43:25.000Z
Example/ThirdSDK/ThirdSDK/BaiduUploader/Frameworks/BaiduBCESTS.framework/Headers/STSClient.h
winterwine/CaamDau
65eb581db66376deefa95e01765b8a7019d521b6
[ "MIT" ]
1
2019-01-16T09:14:16.000Z
2019-01-16T09:14:16.000Z
/* * Copyright (c) 2016 Baidu.com, Inc. 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. */ #import <BaiduBCEBasic/BCEClient.h> @class STSClientConfiguration; @class BCETask; @class STSGetSessionTokenRequest; /** * @brief Provides the client for accessing the Baidu Security Token Service. */ @interface STSClient : BCEClient /** * @brief Constructs a new client using the client configuration. * @param configuration The client configuration. * @return Client object. */ - (instancetype)initWithConfiguration:(STSClientConfiguration*)configuration; /** * @brief Get a set of temporary security credentials representing your account. * @param request The request. * @return Task of the get session token request. */ - (BCETask*)getSessionToken:(STSGetSessionTokenRequest*)request; @end
32.390244
118
0.756024
[ "object" ]
7d52b250c259539296997c899a181dc77fb3916b
9,496
h
C
mip/codebuf.h
stardot/ncc
8c2bda7122c651756d1b66844e7b1f0d3f44d940
[ "Apache-2.0" ]
null
null
null
mip/codebuf.h
stardot/ncc
8c2bda7122c651756d1b66844e7b1f0d3f44d940
[ "Apache-2.0" ]
null
null
null
mip/codebuf.h
stardot/ncc
8c2bda7122c651756d1b66844e7b1f0d3f44d940
[ "Apache-2.0" ]
null
null
null
/* * codebuf.h : target-independent part of object code generation, version 23 * Copyright (C) Acorn Computers Ltd., 1988-1990. * Copyright (C) Codemist Ltd, 1988-1992. * Copyright (C) Advanced Risc Machines Ltd., 1991-1992. * SPDX-Licence-Identifier: Apache-2.0 */ /* * RCS $Revision$ * Checkin $Date$ * Revising $Author$ */ #ifndef _codebuf_LOADED #define _codebuf_LOADED 1 #ifndef _defs_LOADED # include "defs.h" #endif #include "xrefs.h" typedef struct DataDesc { DataInit *head, *tail; int32 size; DataXref *xrefs; int xrarea; union { int32 w32[1]; int16 w16[2]; int8 w8[4]; } wbuff; uint8 wpos; uint8 wtype; } DataDesc; typedef enum { DS_None , DS_ReadWrite #ifdef CONST_DATA_IN_CODE , DS_Const #endif } DataAreaSort; #if defined(CALLABLE_COMPILER) #define get_datadesc_ht(head) ((DataInit *)0) #define set_datadesc_ht(head,val) ((void)0) #define get_datadesc_size() ((int32) 0) #define set_datadesc_size(val) ((void)0) #define get_datadesc_xrefs() ((DataXref *)0) #define set_datadesc_xrefs(val) ((void)0) #define get_datadesc_xrarea() ((int)0) #define set_datadesc_xrarea(val) ((void)0) #define get_datadesc() ((DataDesc *)0) #define copy_datadesc(dest) ((void)0) #define restore_datadesc(src) ((void)0) #define data_size() ((int32)0) #define data_head() ((DataInit *)0) #define data_xrefs() ((DataXref *)0) #define constdata_size() ((int32)0) #define constdata_head() ((DataInit *)0) #define constdata_xrefs() ((DataXref *)0) #define is_constdata() ((bool)0) #define SetDataArea(x) DS_ReadWrite #else extern DataInit *get_datadesc_ht(bool head); extern void set_datadesc_ht(bool head, DataInit *val); extern int32 get_datadesc_size(void); extern void set_datadesc_size(int32 val); extern DataXref *get_datadesc_xrefs(void); extern void set_datadesc_xrefs(DataXref *val); extern int get_datadesc_xrarea(void); extern void set_datadesc_xrarea(int val); extern DataDesc *get_datadesc(void); extern void copy_datadesc(DataDesc *dest); extern void restore_datadesc(DataDesc *src); extern int32 data_size(void); extern DataInit *data_head(void); extern DataXref *data_xrefs(void); extern DataInit *get_extable_ht(bool head); extern void set_extable_ht(bool head, DataInit *val); extern void set_extable_size(int32 val); extern int32 extable_size(void); extern DataInit *extable_head(void); extern DataXref *extable_xrefs(void); extern bool is_extable(void); extern DataInit *get_exhandler_ht(bool head); extern void set_exhandler_ht(bool head, DataInit *val); extern void set_exhandler_size(int32 val); extern int32 exhandler_size(void); extern DataInit *exhandler_head(void); extern DataXref *exhandler_xrefs(void); extern bool is_exhandler(void); # ifdef CONST_DATA_IN_CODE extern int32 constdata_size(void); extern DataInit *constdata_head(void); extern DataXref *constdata_xrefs(void); extern bool is_constdata(void); # else #define dataloc (get_datadesc_size()) /* compatibility with other back ends. */ #define datainitp (get_datadesc_ht(YES)) #define dataxrefs (get_datadesc_xrefs()) # endif extern DataAreaSort SetDataArea(DataAreaSort); #endif extern int32 code_area_idx; /* for armcc -S -ZO ... */ extern int32 codebase; extern struct LabelNumber *litlab; extern int32 litpoolp; extern int32 codep; #ifdef TARGET_HAS_BSS extern int32 bss_size; #endif /* xxx/gen.c obj.c and asm.c should now only access 'codeandflagvec' */ /* via the macros code_xxx_() below. */ /* ECN: Modified to allow non-aligned words if TARGET_HAS_HALFWORD_INSTRUCTIONS * Unfortunately there are large scale assumptions elsewhere that * codeandflagvec addresses an array of 32 bit words. */ #ifdef TARGET_HAS_HALFWORD_INSTRUCTIONS # define CodeFlag_t unsigned char extern struct CodeAndFlag { unsigned16 code[CODEVECSEGSIZE*2]; CodeFlag_t flag[CODEVECSEGSIZE*2]; } *codeandflagvec[CODEVECSEGMAX]; #define code_byte_(q) ((unsigned8 *)(codeandflagvec[(q) >> CODEVECSEGBITS+2]->code)) \ [(q) & (CODEVECSEGSIZE*4-1)] #define code_hword_(q) (codeandflagvec[(q) >> (CODEVECSEGBITS+2)])-> \ code[((q) >> 1) & (CODEVECSEGSIZE*2-1)] #define code_flag_(q) (codeandflagvec[(q) >> (CODEVECSEGBITS+2)])-> \ flag[((q) >> 1) & (CODEVECSEGSIZE*2-1)] #define code_inst_(q) (host_lsbytefirst ? \ (code_hword_(q) | (code_hword_(q+2) << 16)) : \ ((code_hword_(q) << 16) | code_hword_(q+2))) #define set_code_inst_(q,v) (host_lsbytefirst ? \ ((code_hword_(q) = (unsigned16)(v)), (code_hword_((q)+2) = (v) >> 16)) : \ ((code_hword_(q) = (v) >> 16), (code_hword_((q)+2) = (unsigned16)(v)))) #else #ifdef TARGET_HAS_BYTE_INSTRUCTIONS # define CodeFlag_t int32 /* dying? */ #else # define CodeFlag_t unsigned char #endif extern struct CodeAndFlag { int32 code[CODEVECSEGSIZE]; CodeFlag_t flag[CODEVECSEGSIZE]; } *codeandflagvec[CODEVECSEGMAX]; #define code_inst_(q) (codeandflagvec[(q) >> CODEVECSEGBITS+2])-> \ code[(q)>>2 & CODEVECSEGSIZE-1] #define set_code_inst_(q,v) (code_inst_(q)=v) #define code_flag_(q) (codeandflagvec[(q)>>CODEVECSEGBITS+2])-> \ flag[(q)>>2 & CODEVECSEGSIZE-1] #endif #ifndef NO_ASSEMBLER_OUTPUT /* i.e. lay off otherwise */ extern VoidStar (*(codeasmauxvec[CODEVECSEGMAX]))[CODEVECSEGSIZE]; # define code_aux_(q) (*codeasmauxvec[(q) >> CODEVECSEGBITS+2]) \ [(q)>>2 & CODEVECSEGSIZE-1] #endif /* The following macros provide easy access to blocks for xxx/obj.c */ #define code_instvec_(i) (&(codeandflagvec[i]->code)[0]) #define code_flagvec_(i) (&(codeandflagvec[i]->flag)[0]) #ifdef TARGET_HAS_BYTE_INSTRUCTIONS #define code_byte_(q) \ ((unsigned char *)(codeandflagvec[(q) >> CODEVECSEGBITS+2]->code)) \ [(q) & 4*CODEVECSEGSIZE-1] /* miserable macro to interpret int32 flags as 4 byte flags. Hmm. */ #define flag_byte_(q) \ ((unsigned char *)(codeandflagvec[(q) >> CODEVECSEGBITS+2]->flag)) \ [(q) & 4*CODEVECSEGSIZE-1] #endif extern struct LabList *asm_lablist; /* exported to xxxgen.c */ extern struct LabelNumber *nextlabel(void); extern void labeldata(Symstr *b); extern int32 trydeletezerodata(DataInit *previous, int32 minsize); extern void gendcAX(Symstr *sv, int32 offset, int xrflavour); /* (possibly external) name + offset, flavour is xr_data or xr_code */ #ifdef CALLABLE_COMPILER #define gendc0(n) ((void)0) #else extern void gendc0(int32 nbytes); #endif extern void gendcI_a(int32 len, int32 val, bool aligned); #define gendcI(len, val) gendcI_a(len, val, YES) extern void gendcE(int32 len, FloatCon *val); #ifdef TARGET_CALL_USES_DESCRIPTOR extern void gendcF(Symstr *sv, int32 offset); extern int32 genfncon(Symstr* sv); #else /* TARGET_CALL_USES_DESCRIPTOR */ # define gendcF(sym, off, strength) gendcAX(sym, off, xr_code|(strength)) #endif /* TARGET_CALL_USES_DESCRIPTOR */ #define gendcA(sym, off, strength) gendcAX(sym, off, xr_data|(strength)) extern void vg_genstring(StringSegList *s, int32 size, int pad); extern void padstatic(int32 align); #ifdef TARGET_HAS_BSS extern void padbss(int32 align); #endif int32 totargetsex(int32 w, int flag); extern void codeseg_stringsegs(StringSegList *x, bool incode); extern void codeseg_flush(Symstr *strlitname); extern int32 codeseg_function_name(Symstr *name, int32 argn); extern void show_entry(Symstr *name, int flags); extern void show_code(Symstr *name); extern void outcodeword(int32 w, int32 f); extern void outcodewordaux(int32 w, int32 f, VoidStar aux); extern void outlitword(int32 w, int32 flavour, Symstr *sym, VoidStar aux, int32 flag); extern int32 codeloc(void); extern int32 lit_findadcon(Symstr *name, int32 offset, int32 wherefrom); extern void dumplits2(bool needsjump); extern int lit_of_count_name(char *s); extern void dump_count_names(void); extern int32 lit_findword(int32 w, int32 flavour, Symstr *sym, int32 flag); extern int32 lit_findwordaux(int32 w, int32 flavour, VoidStar aux, int32 flag); extern int32 lit_findwordsincurpool(int32 w[], int32 count, int32 flavour); extern int32 lit_findwordsinprevpools(int32 w[], int32 count, int32 flavour, int32 earliest); extern int32 lit_findstringincurpool(StringSegList *s); extern int32 lit_findstringinprevpools(StringSegList *s, int32 earliest); extern int32 stringlength(StringSegList *s); extern int32 addbsssym(Symstr *sym, int32 size, int32 align, bool statik, bool local); extern void codebuf_init(void); extern void codebuf_reinit(void); extern void codebuf_reinit1(char * codeseg_name); /* for C++ dynamic inits */ extern void codebuf_reinit2(void); extern void codebuf_tidy(void); #ifdef TARGET_IS_ACW extern void outbytef(int32 w, int f); #endif #endif /* end of codebuf.h */
38.290323
86
0.673757
[ "object" ]
7d55b94334126e7d98d85a338aa46b6c4bca898f
3,387
h
C
jni/sdk/v2_0_1/ARDroneLib/VP_SDK/VP_Stages/vp_stages_io_file.h
hatpick/DroneMyoGlass
d1a7a0d9ebd71a62f54f4356a47a0eb6b98474ee
[ "Apache-2.0" ]
null
null
null
jni/sdk/v2_0_1/ARDroneLib/VP_SDK/VP_Stages/vp_stages_io_file.h
hatpick/DroneMyoGlass
d1a7a0d9ebd71a62f54f4356a47a0eb6b98474ee
[ "Apache-2.0" ]
null
null
null
jni/sdk/v2_0_1/ARDroneLib/VP_SDK/VP_Stages/vp_stages_io_file.h
hatpick/DroneMyoGlass
d1a7a0d9ebd71a62f54f4356a47a0eb6b98474ee
[ "Apache-2.0" ]
null
null
null
/** * \brief VP Stages. File stage declaration * \author Sylvain Gaeremynck <sylvain.gaeremynck@parrot.fr> * \author Aurelien Morelle <aurelien.morelle@parrot.fr> * \author Thomas Landais <thomas.landais@parrot.fr> * \version 2.0 * \date first release 16/03/2007 * \date modification 19/03/2007 */ /////////////////////////////////////////////// // INCLUDES #ifndef _VP_STAGES_IO_FILE_H_ #define _VP_STAGES_IO_FILE_H_ #include <VP_Api/vp_api_picture.h> /** * @defgroup VP_SDK * @{ */ /** * @defgroup VP_Stages * @{ */ /** * @defgroup vp_stages_io_file input/output file stage * @{ */ #include <VP_Api/vp_api.h> #include <stdio.h> /////////////////////////////////////////////// // TYEPDEFS typedef struct _vp_stages_input_file_config_ { char *name; // initialise with input file bool_t loop; // to be initialised to 1 bool_t moving_picture; // =0:one still picture =1:several frames FILE *f; // initialised in open stage int width,height; // for input files, the resolution to use int nb_buffers; uint8_t ** buffers; uint8_t * data; uint32_t buffer_size; // initialised in open stage vp_api_picture_t vp_api_picture; // output image int preload; // if not 0, number of bytes to load from file to memory int current_buffer; } vp_stages_input_file_config_t; typedef struct _vp_stages_output_file_config_ { char *name; FILE *f; uint32_t flush_every_nb; } vp_stages_output_file_config_t; /////////////////////////////////////////////// // FUNCTIONS /** * @fn Open the input file stage * @param vp_stages_input_file_config_t *cfg * @todo A COMMENTER + Verification de l'open * @return VP_SUCCESS */ C_RESULT vp_stages_input_file_stage_open(vp_stages_input_file_config_t *cfg); /** * @fn Transform the input file stage * @param vp_stages_input_file_config_t *cfg * @param vp_api_io_data_t *in * @param vp_api_io_data_t *out * @todo A COMMENTER * @return VP_SUCCESS */ C_RESULT vp_stages_input_file_stage_transform(vp_stages_input_file_config_t *cfg, vp_api_io_data_t *in, vp_api_io_data_t *out); /** * @fn Close the input file stage * @param vp_stages_input_file_config_t *cfg * @todo A COMMENTER * @return VP_SUCCESS */ C_RESULT vp_stages_input_file_stage_close(vp_stages_input_file_config_t *cfg); /** * @fn Open the output file stage * @param vp_stages_output_file_config_t *cfg * @todo A COMMENTER * @return VP_SUCCESS */ C_RESULT vp_stages_output_file_stage_open(vp_stages_output_file_config_t *cfg); /** * @fn Open the output file stage * @param vp_stages_output_file_config_t *cfg * @param vp_api_io_data_t *in * @param vp_api_io_data_t *out * @todo A COMMENTER * @return VP_SUCCESS */ C_RESULT vp_stages_output_file_stage_transform(vp_stages_output_file_config_t *cfg, vp_api_io_data_t *in, vp_api_io_data_t *out); /** * @fn Open the output file stage * @param vp_stages_output_file_config_t *cfg * @todo A COMMENTER * @return VP_SUCCESS */ C_RESULT vp_stages_output_file_stage_close(vp_stages_output_file_config_t *cfg); // vp_stages_io_file /** @} */ // VP_Stages /** @} */ // VP_SDK /** @} */ #endif // ! _VP_STAGES_IO_FILE_H_
25.659091
120
0.657514
[ "transform" ]
7d5842c4b37277f609adf09d116acaab4b6d23e1
5,402
h
C
components/feed/core/v2/feed_store.h
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
components/feed/core/v2/feed_store.h
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
components/feed/core/v2/feed_store.h
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
// Copyright 2020 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. #ifndef COMPONENTS_FEED_CORE_V2_FEED_STORE_H_ #define COMPONENTS_FEED_CORE_V2_FEED_STORE_H_ #include <memory> #include <string> #include <vector> #include "base/containers/flat_set.h" #include "base/memory/weak_ptr.h" #include "base/sequenced_task_runner.h" #include "components/feed/core/proto/v2/store.pb.h" #include "components/feed/core/v2/types.h" #include "components/leveldb_proto/public/proto_database.h" #include "components/leveldb_proto/public/proto_database_provider.h" namespace feed { struct StreamModelUpdateRequest; class FeedStore { public: struct LoadStreamResult { LoadStreamResult(); ~LoadStreamResult(); LoadStreamResult(LoadStreamResult&&); LoadStreamResult& operator=(LoadStreamResult&&); LoadStreamResult(const LoadStreamResult&) = delete; LoadStreamResult& operator=(const LoadStreamResult&) = delete; bool read_error = false; feedstore::StreamData stream_data; std::vector<feedstore::StreamStructureSet> stream_structures; }; explicit FeedStore( std::unique_ptr<leveldb_proto::ProtoDatabase<feedstore::Record>> database); ~FeedStore(); FeedStore(const FeedStore&) = delete; FeedStore& operator=(const FeedStore&) = delete; void Initialize(base::OnceClosure initialize_complete); void LoadStream(base::OnceCallback<void(LoadStreamResult)> callback); // Stores the content of |update_request| in place of any existing stream // data. void OverwriteStream(std::unique_ptr<StreamModelUpdateRequest> update_request, base::OnceCallback<void(bool)> callback); // Stores the content of |update_request| as an update to existing stream // data. void SaveStreamUpdate( int32_t structure_set_sequence_number, std::unique_ptr<StreamModelUpdateRequest> update_request, base::OnceCallback<void(bool)> callback); void WriteOperations(int32_t sequence_number, std::vector<feedstore::DataOperation> operations); // Read StreamData and pass it to stream_data_callback, or nullptr on failure. void ReadStreamData( base::OnceCallback<void(std::unique_ptr<feedstore::StreamData>)> stream_data_callback); // Read Content and StreamSharedStates and pass them to content_callback, or // nullptrs on failure. void ReadContent( std::vector<feedwire::ContentId> content_ids, std::vector<feedwire::ContentId> shared_state_ids, base::OnceCallback<void(std::vector<feedstore::Content>, std::vector<feedstore::StreamSharedState>)> content_callback); void ReadActions( base::OnceCallback<void(std::vector<feedstore::StoredAction>)> callback); void WriteActions(std::vector<feedstore::StoredAction> actions, base::OnceCallback<void(bool)> callback); void RemoveActions(std::vector<LocalActionId> ids, base::OnceCallback<void(bool)> callback); // TODO(iwells): implement this // Deletes old records that are no longer needed // void RemoveOldData(base::OnceCallback<void(bool)> callback); bool IsInitializedForTesting() const; leveldb_proto::ProtoDatabase<feedstore::Record>* GetDatabaseForTesting() { return database_.get(); } base::WeakPtr<FeedStore> GetWeakPtr() { return weak_ptr_factory_.GetWeakPtr(); } private: void OnDatabaseInitialized(leveldb_proto::Enums::InitStatus status); bool IsInitialized() const; void Write(std::vector<feedstore::Record> records, base::OnceCallback<void(bool)> callback); void ReadSingle( const std::string& key, base::OnceCallback<void(bool, std::unique_ptr<feedstore::Record>)> callback); void ReadMany(const base::flat_set<std::string>& key_set, base::OnceCallback< void(bool, std::unique_ptr<std::vector<feedstore::Record>>)> callback); void OnSaveStreamEntriesUpdated( base::OnceCallback<void(bool)> complete_callback, bool ok); void OnLoadStreamFinished( base::OnceCallback<void(LoadStreamResult)> callback, bool success, std::unique_ptr<std::vector<feedstore::Record>> records); void OnReadContentFinished( base::OnceCallback<void(std::vector<feedstore::Content>, std::vector<feedstore::StreamSharedState>)> callback, bool success, std::unique_ptr<std::vector<feedstore::Record>> records); void OnReadActionsFinished( base::OnceCallback<void(std::vector<feedstore::StoredAction>)> callback, bool success, std::unique_ptr<std::vector<feedstore::Record>> records); void OnWriteFinished(base::OnceCallback<void(bool)> callback, bool success); // TODO(iwells): implement // bool OldRecordFilter(const std::string& key); // void OnRemoveOldDataFinished(base::OnceCallback<void(bool)> callback, // bool success); base::OnceClosure initialize_callback_; leveldb_proto::Enums::InitStatus database_status_; std::unique_ptr<leveldb_proto::ProtoDatabase<feedstore::Record>> database_; base::WeakPtrFactory<FeedStore> weak_ptr_factory_{this}; }; } // namespace feed #endif // COMPONENTS_FEED_CORE_V2_FEED_STORE_H_
36.255034
80
0.71418
[ "vector" ]
7d6c4dec302d43459ac7f208a072769a45199215
853
h
C
test/resources/glutapp/OpenGL.h
Manu343726/biicode-common
91b32c6fd1e4a72ce5451183f1766d313cd0e420
[ "MIT" ]
17
2015-04-15T09:40:23.000Z
2017-05-17T20:34:49.000Z
test/resources/glutapp/OpenGL.h
Manu343726/biicode-common
91b32c6fd1e4a72ce5451183f1766d313cd0e420
[ "MIT" ]
2
2015-04-22T11:29:36.000Z
2018-09-25T09:31:09.000Z
test/resources/glutapp/OpenGL.h
bowlofstew/common
45e9ca902be7bbbdd73dafe3ab8957bc4a006020
[ "MIT" ]
22
2015-04-15T09:46:00.000Z
2020-09-29T17:03:31.000Z
// OpenGL.h: interface for the OpenGL class. // ////////////////////////////////////////////////////////////////////// #if !defined(afx_opengl_h__2b1af605_baa9_4751_9d16_b7310454f0b6__included_) #define afx_opengl_h__2b1af605_baa9_4751_9d16_b7310454f0b6__included_ #if _msc_ver > 1000 #pragma once #endif // _msc_ver > 1000 #pragma warning (disable: 4786) #include <string> #include <vector> class OpenGL { public: OpenGL(); virtual ~OpenGL(); static void PrintText(char *mensaje, int x, int y, unsigned char r=255, unsigned char g=255, unsigned char b=255); static unsigned int LoadTexture(char* texture_file); static void DeleteTextures(); protected: static std::vector<std::string> nombre_texturas; static std::vector<unsigned int> id_texturas; }; #endif // !defined(afx_opengl_h__2b1af605_baa9_4751_9d16_b7310454f0b6__included_)
25.088235
115
0.713951
[ "vector" ]
7d6e2a92a082b07c0fdbc9b59cdb81102573acd8
1,470
h
C
Classes/PodPersistent.h
jerrykrinock/podbiceps
e1893df826aa35a9d5b92b852572ff6646345d4d
[ "Apache-2.0" ]
5
2015-12-10T14:25:44.000Z
2021-07-04T00:23:33.000Z
Classes/PodPersistent.h
jerrykrinock/podbiceps
e1893df826aa35a9d5b92b852572ff6646345d4d
[ "Apache-2.0" ]
null
null
null
Classes/PodPersistent.h
jerrykrinock/podbiceps
e1893df826aa35a9d5b92b852572ff6646345d4d
[ "Apache-2.0" ]
2
2021-03-31T02:43:23.000Z
2021-07-04T00:23:44.000Z
// PodPersistentOrder.h // Created by David Phillip Oster, DavidPhillipOster+podbiceps@gmail.com on 11/22/14. // Copyright (c) 2014 David Phillip Oster. // 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. #import <Foundation/Foundation.h> @class MPMediaItem; // This object saves the user's item order in ApplicationSupport. Deleted items too. @interface PodPersistent : NSObject + (instancetype)sharedInstance; - (void)rememberMediaItems:(NSArray *)mediaItems; // of MPMediaItem * // NSNotFound if we don't know. - (NSUInteger)indexOrderOfMediaItem:(MPMediaItem *)mediaItem; // put item on a permanent stoplist. - (void)deleteItem:(MPMediaItem *)mediaItem; - (BOOL)isDeletedItem:(MPMediaItem *)mediaItem; // 0 if unknown. - (NSTimeInterval)bookmarkTimeOfMediaItem:(MPMediaItem *)mediaItem; - (BOOL)hasBookmarkTimeOfMediaItem:(MPMediaItem *)mediaItem; - (void)setBookmarkTime:(NSTimeInterval)time ofMediaItem:(MPMediaItem *)mediaItem; @end
36.75
86
0.755782
[ "object" ]
7d831cb54d60e8c41dacaab238fc5dda397be46e
5,617
c
C
src/game.c
thejozhou/katamino
e9382484a120dc8d506733744efddecf36451d6a
[ "MIT" ]
null
null
null
src/game.c
thejozhou/katamino
e9382484a120dc8d506733744efddecf36451d6a
[ "MIT" ]
null
null
null
src/game.c
thejozhou/katamino
e9382484a120dc8d506733744efddecf36451d6a
[ "MIT" ]
null
null
null
#include "game.h" void init_game() { USER_EVENT = 0; // Empty the board int i = BOARD_HEIGHT * BOARD_WIDTH; while (i --> 0) { board[i] = EMPTY; } draw_game(); // PENTA game of 3 pieces Pentamino_Movement PentaF[] = { {PENTA_P,0,7,11}, {PENTA_U,0,11,15}, {PENTA_G,0,19,5}, }; // Initialize pentaminos and coordinates int k = 3; while (k --> 0) { Mino SetMino = {PentaF[k], {0}}; penta[k] = SetMino; } // Render initial pentaminos int l = 3; while (l --> 0) { current_mino = &penta[l]; current_mino_index = l; render_current_mino(); } } void handle_user_events() { SDL_Event event; // Poll for user events while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_QUIT: exit(0); break; case SDL_KEYDOWN: switch (event.key.keysym.sym) { case SDLK_ESCAPE: exit(0); break; case SDLK_s: case SDLK_DOWN: USER_EVENT = DOWN; break; case SDLK_d: case SDLK_RIGHT: USER_EVENT = RIGHT; break; case SDLK_a: case SDLK_LEFT: USER_EVENT = LEFT; break; case SDLK_w: case SDLK_UP: USER_EVENT = UP; break; case SDLK_r: USER_EVENT = RESTART; break; case SDLK_SPACE: USER_EVENT = SPACE; break; case SDLK_TAB: USER_EVENT = TAB; break; default: break; } break; case SDL_KEYUP: USER_EVENT = NONE; break; default: break; } } } void draw_game() { // Set rendering clear background color SDL_SetRenderDrawColor(render, 245, 245, 245, SDL_ALPHA_OPAQUE); // Clear render, set background color defined in SDL_SetRenderDrawColor SDL_RenderClear(render); int i = BOARD_HEIGHT * BOARD_WIDTH; while (i --> 0) set_board(i % BOARD_WIDTH, i / BOARD_WIDTH, board[i]); // Update the screen set_render_changed(); } void update_game() { // Check user action switch(USER_EVENT) { case NONE: break; case LEFT: // Decrement pentamino y current_mino->mino.x -= 1; render_current_mino(); break; case RIGHT: // Increment pentamino x current_mino->mino.x += 1; render_current_mino(); break; case UP: // Decrement pentamino y current_mino->mino.y -= 1; render_current_mino(); break; case DOWN: // Increment pentamino y current_mino->mino.y += 1; render_current_mino(); break; case SPACE: // Set rotation to next in array current_mino->mino.rotation = (current_mino->mino.rotation + 1) % 4; render_current_mino(); break; case RESTART: // Restart the game init_game(); break; case TAB: // Increment current mino index current_mino_index++; if (current_mino_index > 2) { current_mino_index = 0; } // Assign next pentamino in set as current current_mino = &penta[current_mino_index]; break; } USER_EVENT = 0; } bool can_render_mino(uint16_t render_queue[]) { uint16_t bit, piece; uint16_t row = 0, col = 0; piece = current_mino->mino.type.rotation[current_mino->mino.rotation]; uint16_t x = current_mino->mino.x; uint16_t y = current_mino->mino.y; // Iterate through pentamino data, get coordinates for rotation int i = 0; for (bit = 0x8000; bit > 0 && i < 10; bit = bit >> 1) { if (piece & bit) { uint16_t _x = x + col; uint16_t _y = y + row; if (get_board(_x, _y) != EMPTY) { return false; break; } if (render_queue != NULL) { render_queue[i * 2] = _x; render_queue[i * 2 + 1] = _y; } i++; } col++; col = col % 4; if (col == 0) { row++; } } return true; } bool render_current_mino() { uint16_t render_queue[10] = {0}; if (!can_render_mino(render_queue)) { return false; } // Clear previous pentamino position int i = 5; while(i --> 0) { uint8_t x_coord = i * 2; uint8_t y_coord = x_coord + 1; uint8_t _x = current_mino->current_coords[x_coord]; uint8_t _y = current_mino->current_coords[y_coord]; draw_block(_x, _y, EMPTY); } // Draw new pentamino squares i = 5; while(i --> 0) { uint8_t x_coord = i * 2; uint8_t y_coord = x_coord + 1; // store and draw new Pentamino position uint8_t _x = render_queue[x_coord]; uint8_t _y = render_queue[y_coord]; current_mino->current_coords[x_coord] = _x; current_mino->current_coords[y_coord] = _y; draw_block(_x, _y, current_mino->mino.type.color); } return true; } Color_Block get_board(uint8_t x, uint8_t y) { return board[(y * BOARD_WIDTH) + x]; } void set_board(uint8_t x, uint8_t y, Color_Block color) { board[(y * BOARD_WIDTH) + x] = color; draw_block(x, y, color); }
20.650735
75
0.5154
[ "render" ]
0431d2d5ac5e65d1b1de8b2a6ac6f47438c15a76
2,684
h
C
Middlewares/Third_Party/IOTA_C/client/api/v1/send_message.h
CIPop/x-cube-iota1
046032b513d882737ae0788308702f5d9e18652d
[ "Cube" ]
7
2021-04-14T07:29:23.000Z
2022-02-07T16:34:24.000Z
Middlewares/Third_Party/IOTA_C/client/api/v1/send_message.h
CIPop/x-cube-iota1
046032b513d882737ae0788308702f5d9e18652d
[ "Cube" ]
1
2021-12-16T22:25:20.000Z
2021-12-17T18:31:58.000Z
Middlewares/Third_Party/IOTA_C/client/api/v1/send_message.h
CIPop/x-cube-iota1
046032b513d882737ae0788308702f5d9e18652d
[ "Cube" ]
3
2021-04-14T07:29:16.000Z
2022-02-28T09:20:51.000Z
// Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 #ifndef __CLIENT_API_V1_SEND_MSG_H__ #define __CLIENT_API_V1_SEND_MSG_H__ #include <stdbool.h> #include <stdint.h> #include "client/api/message.h" #include "client/api/v1/response_error.h" #include "client/client_service.h" #include "core/models/models_message.h" #include "core/types.h" /** @addtogroup IOTA_C * @{ */ /** @addtogroup CLIENT * @{ */ /** @addtogroup API * @{ */ /** @defgroup SEND_MESSAGE Send Message * @{ */ /** @defgroup SEND_MESSAGE_EXPORTED_TYPES Exported Types * @{ */ /** * @brief The response of send message * */ typedef struct { bool is_error; ///< True if got an error from the node. union { res_err_t* error; ///< Error message if is_error is True char msg_id[IOTA_MESSAGE_ID_HEX_BYTES + 1]; ///< a message IDs string if is_error is False } u; } res_send_message_t; /** * @} */ #ifdef __cplusplus extern "C" { #endif /** @defgroup SEND_MESSAGE_EXPORTED_FUNCTIONS Exported Functions * @{ */ /** * @brief Deserialize the response of send_message * * @param[in] json_str The response string * @param[out] res The response object * @return int 0 on success */ int deser_send_message_response(char const* json_str, res_send_message_t* res); /** * @brief Serialize a indexation message * * @param[in] msg A message object * @param[out] buf A JSON string of the message object * @return int 0 on success */ int serialize_indexation(message_t* msg, byte_buf_t* buf); /** * @brief Send out an indexation message * * @param[in] conf The client endpoint configuration * @param[in] index The string of index * @param[in] data The string of data * @param[out] res The response object * @return int 0 on success */ int send_indexation_msg(iota_client_conf_t const* const conf, char const index[], char const data[], res_send_message_t* res); /** * @brief Send out a message object * * @param[in] conf The client endpoint configuration * @param[in] msg A message object * @param[out] res The response object * @return int 0 on success */ int send_message(iota_client_conf_t const* const conf, message_t* msg, res_send_message_t* res); /** * @brief Send message thought core message object * * @param[in] conf The client endpoint configuration * @param[in] msg A core message * @param[out] res An error or message ID * @return int 0 on success */ int send_core_message(iota_client_conf_t const* const conf, core_message_t* msg, res_send_message_t* res); /** * @} */ #ifdef __cplusplus } #endif /** * @} */ /** * @} */ /** * @} */ /** * @} */ #endif
19.881481
106
0.678465
[ "object" ]
0436e6493c96aaac1baed5ee422628573de7ef82
463
h
C
iOS/Frameworks/Plugins/iOS/Pubnative.framework/PrivateHeaders/PNAdModel+Fetching.h
pubnative/pubnative-unity-sdk
22f166813119681218a67594ed98c59169896260
[ "MIT" ]
null
null
null
iOS/Frameworks/Plugins/iOS/Pubnative.framework/PrivateHeaders/PNAdModel+Fetching.h
pubnative/pubnative-unity-sdk
22f166813119681218a67594ed98c59169896260
[ "MIT" ]
null
null
null
iOS/Frameworks/Plugins/iOS/Pubnative.framework/PrivateHeaders/PNAdModel+Fetching.h
pubnative/pubnative-unity-sdk
22f166813119681218a67594ed98c59169896260
[ "MIT" ]
null
null
null
// // PNAdModel+Fetching.h // sdk // // Created by David Martin on 28/07/2017. // Copyright © 2017 pubnative. All rights reserved. // #import "PNAdModel.h" @protocol PNAdModelFetchDelegate <NSObject> - (void)pubnativeAdFetchDidFinish:(PNAdModel *)model; - (void)pubnativeAdFetchDidFail:(PNAdModel *)model withError:(NSError *)error; @end @interface PNAdModel (Fetching) - (void)fetchAssetsWithDelegate:(NSObject<PNAdModelFetchDelegate>*)delegate; @end
20.130435
78
0.7473
[ "model" ]
043b5c0759dc6eb78ea6941447ee40be0c047ec1
18,178
h
C
study/start_tf_serving/apis/model_management.pb.h
taozhijiang/serving
dda80c25cb0bb203bef77757327bc000f249c06a
[ "Apache-2.0" ]
39
2019-09-06T13:42:24.000Z
2022-03-18T18:38:43.000Z
study/start_tf_serving/apis/model_management.pb.h
taozhijiang/serving
dda80c25cb0bb203bef77757327bc000f249c06a
[ "Apache-2.0" ]
9
2019-09-19T22:35:32.000Z
2022-02-24T18:04:57.000Z
study/start_tf_serving/apis/model_management.pb.h
taozhijiang/serving
dda80c25cb0bb203bef77757327bc000f249c06a
[ "Apache-2.0" ]
8
2019-10-16T21:09:14.000Z
2022-02-23T05:20:37.000Z
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: tensorflow_serving/apis/model_management.proto #ifndef PROTOBUF_INCLUDED_tensorflow_5fserving_2fapis_2fmodel_5fmanagement_2eproto #define PROTOBUF_INCLUDED_tensorflow_5fserving_2fapis_2fmodel_5fmanagement_2eproto #include <string> #include <google/protobuf/stubs/common.h> #if GOOGLE_PROTOBUF_VERSION < 3006001 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif #if 3006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/arena.h> #include <google/protobuf/arenastring.h> #include <google/protobuf/generated_message_table_driven.h> #include <google/protobuf/generated_message_util.h> #include <google/protobuf/inlined_string_field.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> #include <google/protobuf/repeated_field.h> // IWYU pragma: export #include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/unknown_field_set.h> #include "tensorflow_serving/config/model_server_config.pb.h" #include "tensorflow_serving/util/status.pb.h" // @@protoc_insertion_point(includes) #define PROTOBUF_INTERNAL_EXPORT_protobuf_tensorflow_5fserving_2fapis_2fmodel_5fmanagement_2eproto namespace protobuf_tensorflow_5fserving_2fapis_2fmodel_5fmanagement_2eproto { // Internal implementation detail -- do not use these members. struct TableStruct { static const ::google::protobuf::internal::ParseTableField entries[]; static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; static const ::google::protobuf::internal::ParseTable schema[2]; static const ::google::protobuf::internal::FieldMetadata field_metadata[]; static const ::google::protobuf::internal::SerializationTable serialization_table[]; static const ::google::protobuf::uint32 offsets[]; }; void AddDescriptors(); } // namespace protobuf_tensorflow_5fserving_2fapis_2fmodel_5fmanagement_2eproto namespace tensorflow { namespace serving { class ReloadConfigRequest; class ReloadConfigRequestDefaultTypeInternal; extern ReloadConfigRequestDefaultTypeInternal _ReloadConfigRequest_default_instance_; class ReloadConfigResponse; class ReloadConfigResponseDefaultTypeInternal; extern ReloadConfigResponseDefaultTypeInternal _ReloadConfigResponse_default_instance_; } // namespace serving } // namespace tensorflow namespace google { namespace protobuf { template<> ::tensorflow::serving::ReloadConfigRequest* Arena::CreateMaybeMessage<::tensorflow::serving::ReloadConfigRequest>(Arena*); template<> ::tensorflow::serving::ReloadConfigResponse* Arena::CreateMaybeMessage<::tensorflow::serving::ReloadConfigResponse>(Arena*); } // namespace protobuf } // namespace google namespace tensorflow { namespace serving { // =================================================================== class ReloadConfigRequest : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:tensorflow.serving.ReloadConfigRequest) */ { public: ReloadConfigRequest(); virtual ~ReloadConfigRequest(); ReloadConfigRequest(const ReloadConfigRequest& from); inline ReloadConfigRequest& operator=(const ReloadConfigRequest& from) { CopyFrom(from); return *this; } #if LANG_CXX11 ReloadConfigRequest(ReloadConfigRequest&& from) noexcept : ReloadConfigRequest() { *this = ::std::move(from); } inline ReloadConfigRequest& operator=(ReloadConfigRequest&& from) noexcept { if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); } return *this; } #endif inline ::google::protobuf::Arena* GetArena() const final { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const final { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const ReloadConfigRequest& default_instance(); static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const ReloadConfigRequest* internal_default_instance() { return reinterpret_cast<const ReloadConfigRequest*>( &_ReloadConfigRequest_default_instance_); } static constexpr int kIndexInFileMessages = 0; void UnsafeArenaSwap(ReloadConfigRequest* other); void Swap(ReloadConfigRequest* other); friend void swap(ReloadConfigRequest& a, ReloadConfigRequest& b) { a.Swap(&b); } // implements Message ---------------------------------------------- inline ReloadConfigRequest* New() const final { return CreateMaybeMessage<ReloadConfigRequest>(NULL); } ReloadConfigRequest* New(::google::protobuf::Arena* arena) const final { return CreateMaybeMessage<ReloadConfigRequest>(arena); } void CopyFrom(const ::google::protobuf::Message& from) final; void MergeFrom(const ::google::protobuf::Message& from) final; void CopyFrom(const ReloadConfigRequest& from); void MergeFrom(const ReloadConfigRequest& from); void Clear() final; bool IsInitialized() const final; size_t ByteSizeLong() const final; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) final; void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const final; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const final; int GetCachedSize() const final { return _cached_size_.Get(); } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(ReloadConfigRequest* other); protected: explicit ReloadConfigRequest(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // .tensorflow.serving.ModelServerConfig config = 1; bool has_config() const; void clear_config(); static const int kConfigFieldNumber = 1; private: const ::tensorflow::serving::ModelServerConfig& _internal_config() const; public: const ::tensorflow::serving::ModelServerConfig& config() const; ::tensorflow::serving::ModelServerConfig* release_config(); ::tensorflow::serving::ModelServerConfig* mutable_config(); void set_allocated_config(::tensorflow::serving::ModelServerConfig* config); void unsafe_arena_set_allocated_config( ::tensorflow::serving::ModelServerConfig* config); ::tensorflow::serving::ModelServerConfig* unsafe_arena_release_config(); // @@protoc_insertion_point(class_scope:tensorflow.serving.ReloadConfigRequest) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::tensorflow::serving::ModelServerConfig* config_; mutable ::google::protobuf::internal::CachedSize _cached_size_; friend struct ::protobuf_tensorflow_5fserving_2fapis_2fmodel_5fmanagement_2eproto::TableStruct; }; // ------------------------------------------------------------------- class ReloadConfigResponse : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:tensorflow.serving.ReloadConfigResponse) */ { public: ReloadConfigResponse(); virtual ~ReloadConfigResponse(); ReloadConfigResponse(const ReloadConfigResponse& from); inline ReloadConfigResponse& operator=(const ReloadConfigResponse& from) { CopyFrom(from); return *this; } #if LANG_CXX11 ReloadConfigResponse(ReloadConfigResponse&& from) noexcept : ReloadConfigResponse() { *this = ::std::move(from); } inline ReloadConfigResponse& operator=(ReloadConfigResponse&& from) noexcept { if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { if (this != &from) InternalSwap(&from); } else { CopyFrom(from); } return *this; } #endif inline ::google::protobuf::Arena* GetArena() const final { return GetArenaNoVirtual(); } inline void* GetMaybeArenaPointer() const final { return MaybeArenaPtr(); } static const ::google::protobuf::Descriptor* descriptor(); static const ReloadConfigResponse& default_instance(); static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY static inline const ReloadConfigResponse* internal_default_instance() { return reinterpret_cast<const ReloadConfigResponse*>( &_ReloadConfigResponse_default_instance_); } static constexpr int kIndexInFileMessages = 1; void UnsafeArenaSwap(ReloadConfigResponse* other); void Swap(ReloadConfigResponse* other); friend void swap(ReloadConfigResponse& a, ReloadConfigResponse& b) { a.Swap(&b); } // implements Message ---------------------------------------------- inline ReloadConfigResponse* New() const final { return CreateMaybeMessage<ReloadConfigResponse>(NULL); } ReloadConfigResponse* New(::google::protobuf::Arena* arena) const final { return CreateMaybeMessage<ReloadConfigResponse>(arena); } void CopyFrom(const ::google::protobuf::Message& from) final; void MergeFrom(const ::google::protobuf::Message& from) final; void CopyFrom(const ReloadConfigResponse& from); void MergeFrom(const ReloadConfigResponse& from); void Clear() final; bool IsInitialized() const final; size_t ByteSizeLong() const final; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) final; void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const final; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const final; int GetCachedSize() const final { return _cached_size_.Get(); } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const final; void InternalSwap(ReloadConfigResponse* other); protected: explicit ReloadConfigResponse(::google::protobuf::Arena* arena); private: static void ArenaDtor(void* object); inline void RegisterArenaDtor(::google::protobuf::Arena* arena); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return _internal_metadata_.arena(); } inline void* MaybeArenaPtr() const { return _internal_metadata_.raw_arena_ptr(); } public: ::google::protobuf::Metadata GetMetadata() const final; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // .tensorflow.serving.StatusProto status = 1; bool has_status() const; void clear_status(); static const int kStatusFieldNumber = 1; private: const ::tensorflow::serving::StatusProto& _internal_status() const; public: const ::tensorflow::serving::StatusProto& status() const; ::tensorflow::serving::StatusProto* release_status(); ::tensorflow::serving::StatusProto* mutable_status(); void set_allocated_status(::tensorflow::serving::StatusProto* status); void unsafe_arena_set_allocated_status( ::tensorflow::serving::StatusProto* status); ::tensorflow::serving::StatusProto* unsafe_arena_release_status(); // @@protoc_insertion_point(class_scope:tensorflow.serving.ReloadConfigResponse) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; template <typename T> friend class ::google::protobuf::Arena::InternalHelper; typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; ::tensorflow::serving::StatusProto* status_; mutable ::google::protobuf::internal::CachedSize _cached_size_; friend struct ::protobuf_tensorflow_5fserving_2fapis_2fmodel_5fmanagement_2eproto::TableStruct; }; // =================================================================== // =================================================================== #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif // __GNUC__ // ReloadConfigRequest // .tensorflow.serving.ModelServerConfig config = 1; inline bool ReloadConfigRequest::has_config() const { return this != internal_default_instance() && config_ != NULL; } inline const ::tensorflow::serving::ModelServerConfig& ReloadConfigRequest::_internal_config() const { return *config_; } inline const ::tensorflow::serving::ModelServerConfig& ReloadConfigRequest::config() const { const ::tensorflow::serving::ModelServerConfig* p = config_; // @@protoc_insertion_point(field_get:tensorflow.serving.ReloadConfigRequest.config) return p != NULL ? *p : *reinterpret_cast<const ::tensorflow::serving::ModelServerConfig*>( &::tensorflow::serving::_ModelServerConfig_default_instance_); } inline ::tensorflow::serving::ModelServerConfig* ReloadConfigRequest::release_config() { // @@protoc_insertion_point(field_release:tensorflow.serving.ReloadConfigRequest.config) ::tensorflow::serving::ModelServerConfig* temp = config_; if (GetArenaNoVirtual() != NULL) { temp = ::google::protobuf::internal::DuplicateIfNonNull(temp); } config_ = NULL; return temp; } inline ::tensorflow::serving::ModelServerConfig* ReloadConfigRequest::unsafe_arena_release_config() { // @@protoc_insertion_point(field_unsafe_arena_release:tensorflow.serving.ReloadConfigRequest.config) ::tensorflow::serving::ModelServerConfig* temp = config_; config_ = NULL; return temp; } inline ::tensorflow::serving::ModelServerConfig* ReloadConfigRequest::mutable_config() { if (config_ == NULL) { auto* p = CreateMaybeMessage<::tensorflow::serving::ModelServerConfig>(GetArenaNoVirtual()); config_ = p; } // @@protoc_insertion_point(field_mutable:tensorflow.serving.ReloadConfigRequest.config) return config_; } inline void ReloadConfigRequest::set_allocated_config(::tensorflow::serving::ModelServerConfig* config) { ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); if (message_arena == NULL) { delete reinterpret_cast< ::google::protobuf::MessageLite*>(config_); } if (config) { ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::MessageLite*>(config)->GetArena(); if (message_arena != submessage_arena) { config = ::google::protobuf::internal::GetOwnedMessage( message_arena, config, submessage_arena); } } else { } config_ = config; // @@protoc_insertion_point(field_set_allocated:tensorflow.serving.ReloadConfigRequest.config) } // ------------------------------------------------------------------- // ReloadConfigResponse // .tensorflow.serving.StatusProto status = 1; inline bool ReloadConfigResponse::has_status() const { return this != internal_default_instance() && status_ != NULL; } inline const ::tensorflow::serving::StatusProto& ReloadConfigResponse::_internal_status() const { return *status_; } inline const ::tensorflow::serving::StatusProto& ReloadConfigResponse::status() const { const ::tensorflow::serving::StatusProto* p = status_; // @@protoc_insertion_point(field_get:tensorflow.serving.ReloadConfigResponse.status) return p != NULL ? *p : *reinterpret_cast<const ::tensorflow::serving::StatusProto*>( &::tensorflow::serving::_StatusProto_default_instance_); } inline ::tensorflow::serving::StatusProto* ReloadConfigResponse::release_status() { // @@protoc_insertion_point(field_release:tensorflow.serving.ReloadConfigResponse.status) ::tensorflow::serving::StatusProto* temp = status_; if (GetArenaNoVirtual() != NULL) { temp = ::google::protobuf::internal::DuplicateIfNonNull(temp); } status_ = NULL; return temp; } inline ::tensorflow::serving::StatusProto* ReloadConfigResponse::unsafe_arena_release_status() { // @@protoc_insertion_point(field_unsafe_arena_release:tensorflow.serving.ReloadConfigResponse.status) ::tensorflow::serving::StatusProto* temp = status_; status_ = NULL; return temp; } inline ::tensorflow::serving::StatusProto* ReloadConfigResponse::mutable_status() { if (status_ == NULL) { auto* p = CreateMaybeMessage<::tensorflow::serving::StatusProto>(GetArenaNoVirtual()); status_ = p; } // @@protoc_insertion_point(field_mutable:tensorflow.serving.ReloadConfigResponse.status) return status_; } inline void ReloadConfigResponse::set_allocated_status(::tensorflow::serving::StatusProto* status) { ::google::protobuf::Arena* message_arena = GetArenaNoVirtual(); if (message_arena == NULL) { delete reinterpret_cast< ::google::protobuf::MessageLite*>(status_); } if (status) { ::google::protobuf::Arena* submessage_arena = reinterpret_cast<::google::protobuf::MessageLite*>(status)->GetArena(); if (message_arena != submessage_arena) { status = ::google::protobuf::internal::GetOwnedMessage( message_arena, status, submessage_arena); } } else { } status_ = status; // @@protoc_insertion_point(field_set_allocated:tensorflow.serving.ReloadConfigResponse.status) } #ifdef __GNUC__ #pragma GCC diagnostic pop #endif // __GNUC__ // ------------------------------------------------------------------- // @@protoc_insertion_point(namespace_scope) } // namespace serving } // namespace tensorflow // @@protoc_insertion_point(global_scope) #endif // PROTOBUF_INCLUDED_tensorflow_5fserving_2fapis_2fmodel_5fmanagement_2eproto
38.676596
154
0.730168
[ "object" ]
04444b96c7b9a6e658b0a7035cbe7a2c022d1692
14,823
h
C
introcore/include/intrinsics.h
hugmyndakassi/hvmi
fa49a34ba32b327c462224db1cf58d96a076a224
[ "Apache-2.0" ]
677
2020-07-30T13:59:36.000Z
2022-03-24T11:02:00.000Z
introcore/include/intrinsics.h
hugmyndakassi/hvmi
fa49a34ba32b327c462224db1cf58d96a076a224
[ "Apache-2.0" ]
38
2020-08-11T13:59:36.000Z
2022-02-17T15:03:48.000Z
introcore/include/intrinsics.h
fengjixuchui/hvmi
72488e8432d26547876a052d24ea44c3e18279a7
[ "Apache-2.0" ]
55
2020-07-30T14:11:03.000Z
2022-03-09T05:40:44.000Z
/* * Copyright (c) 2020 Bitdefender * SPDX-License-Identifier: Apache-2.0 */ #ifndef _INTRINSICS_H_ #define _INTRINSICS_H_ #include <stddef.h> #include <stdint.h> #ifndef INT_COMPILER_MSVC // // Bit Twiddling // static inline uint8_t _rotl8(uint8_t Value, uint8_t Shift) { Shift &= 0x7; return Shift ? (Value << Shift) | (Value >> (8 - Shift)) : Value; } static inline uint8_t _rotr8(uint8_t Value, uint8_t Shift) { Shift &= 0x7; return Shift ? (Value >> Shift) | (Value << (8 - Shift)) : Value; } static inline uint16_t _rtol16(uint16_t Value, uint8_t Shift) { Shift &= 0xf; return Shift ? (Value << Shift) | (Value >> (16 - Shift)) : Value; } static inline uint16_t _rotr16(uint16_t Value, uint8_t Shift) { Shift &= 0xf; return Shift ? (Value >> Shift) | (Value << (16 - Shift)) : Value; } // // Bit Counting and Testing // static inline uint8_t _BitScanForward(uint32_t *Index, uint32_t Mask) { if (!Mask) return 0; *Index = __builtin_ctzl(Mask); return 1; } static inline uint8_t _BitScanReverse(uint32_t *Index, uint32_t Mask) { if (!Mask) return 0; *Index = 31 - __builtin_clzl(Mask); return 1; } static inline uint32_t _mm_popcnt_u32(uint32_t Value) { return __builtin_popcount(Value); } static inline uint8_t _bittest(int32_t const *BitBase, int32_t BitPos) { return (*BitBase >> BitPos) & 1; } static inline uint8_t _bittestandcomplement(int32_t *BitBase, int32_t BitPos) { uint8_t _Res = (*BitBase >> BitPos) & 1; *BitBase = *BitBase ^ (1 << BitPos); return _Res; } static inline uint8_t _bittestandreset(int32_t *BitBase, int32_t BitPos) { uint8_t _Res = (*BitBase >> BitPos) & 1; *BitBase = *BitBase & ~(1 << BitPos); return _Res; } static inline uint8_t _bittestandset(int32_t *BitBase, int32_t BitPos) { uint8_t _Res = (*BitBase >> BitPos) & 1; *BitBase = *BitBase | (1 << BitPos); return _Res; } static inline uint8_t _BitScanForward64(uint32_t *Index, uint64_t Mask) { if (!Mask) return 0; *Index = __builtin_ctzll(Mask); return 1; } static inline uint8_t _BitScanReverse64(uint32_t *Index, uint64_t Mask) { if (!Mask) return 0; *Index = 63 - __builtin_clzll(Mask); return 1; } static inline uint64_t _mm_popcnt_u64(uint64_t Value) { return __builtin_popcountll(Value); } static inline uint8_t _bittest64(int64_t const *BitBase, int64_t BitPos) { return (*BitBase >> BitPos) & 1; } static inline uint8_t _bittestandcomplement64(int64_t *BitBase, int64_t BitPos) { uint8_t Res = (*BitBase >> BitPos) & 1; *BitBase = *BitBase ^ (1ll << BitPos); return Res; } static inline uint8_t _bittestandreset64(int64_t *BitBase, int64_t BitPos) { uint8_t Res = (*BitBase >> BitPos) & 1; *BitBase = *BitBase & ~(1ll << BitPos); return Res; } static inline uint8_t _bittestandset64(int64_t *BitBase, int64_t BitPos) { uint8_t Res = (*BitBase >> BitPos) & 1; *BitBase = *BitBase | (1ll << BitPos); return Res; } // // readfs, readgs // (Pointers in address space #256 and #257 are relative to the GS and FS // segment registers, respectively.) // #ifdef INT_COMPILER_CLANG #define __ptr_to_addr_space(__addr_space_nbr, __type, offset) \ ((volatile __type __attribute__((__address_space__(__addr_space_nbr)))*) \ (offset)) static inline uint8_t __readgsbyte(uint64_t offset) { return *__ptr_to_addr_space(256, uint8_t, offset); } static inline uint16_t __readgsword(uint64_t offset) { return *__ptr_to_addr_space(256, uint16_t, offset); } static inline uint32_t __readgsdword(uint64_t offset) { return *__ptr_to_addr_space(256, uint32_t, offset); } static inline uint64_t __readgsqword(uint64_t offset) { return *__ptr_to_addr_space(256, uint64_t, offset); } #undef __ptr_to_addr_space #endif // // movs, stos // static inline void __movsb(uint8_t *dst, uint8_t const *src, size_t n) { __asm__("rep movsb" : "+D"(dst), "+S"(src), "+c"(n)); } static inline void __movsd(uint32_t *dst, uint32_t const *src, size_t n) { __asm__("rep movsl" : "+D"(dst), "+S"(src), "+c"(n)); } static inline void __movsw(uint16_t *dst, uint16_t const *src, size_t n) { __asm__("rep movsh" : "+D"(dst), "+S"(src), "+c"(n)); } static inline void __stosb(uint8_t *dst, uint8_t x, size_t n) { __asm__("rep stosb" : "+D"(dst), "+c"(n) : "a"(x)); } static inline void __stosd(uint32_t *dst, uint32_t x, size_t n) { __asm__("rep stosl" : "+D"(dst), "+c"(n) : "a"(x)); } static inline void __stosw(uint16_t *dst, uint16_t x, size_t n) { __asm__("rep stosh" : "+D"(dst), "+c"(n) : "a"(x)); } static inline void __movsq(uint64_t *dst, uint64_t const *src, size_t n) { __asm__("rep movsq" : "+D"(dst), "+S"(src), "+c"(n)); } static inline void __stosq(uint64_t *dst, uint64_t x, size_t n) { __asm__("rep stosq" : "+D"(dst), "+c"(n) : "a"(x)); } // // Misc // static inline void * _AddressOfReturnAddress(void) { return (void *)((int8_t *)__builtin_frame_address(0) + sizeof(void *)); } static inline void * _ReturnAddress(void) { return __builtin_return_address(0); } static inline void __cpuid(int32_t info[4], int32_t level) { __asm__("cpuid" : "=a"(info[0]), "=b" (info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(level)); } static inline void __cpuidex(int32_t info[4], int32_t level, int32_t ecx) { __asm__("cpuid" : "=a"(info[0]), "=b" (info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(level), "c"(ecx)); } static inline uint64_t _xgetbv(uint32_t xcr_no) { uint32_t __eax, __edx; __asm__("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (xcr_no)); return ((uint64_t)__edx << 32) | __eax; } static inline void __halt(void) { __asm__ volatile ("hlt"); } // __builtin_prefetch expects a compile-time constant // and sometimes it won't detect it with __forceinline // The GCC's prefetch takes three arguments: address, readwrite and hint // It will generate a PREFETCH or PREFETCHW depending on readwrite // For now use only readwrite=0 (the default on MSVC) #define _mm_prefetch(p, i) __builtin_prefetch(p, 0, i) #ifndef INT_COMPILER_CLANG static inline void _mm_pause(void) { __asm__ __volatile__("pause"); } static inline uint64_t __rdtsc(void) { return __builtin_ia32_rdtsc(); } #endif // // Privileged intrinsics // static inline uint64_t __readmsr(uint32_t reg) { // Loads the contents of a 64-bit model specific register (MSR) specified in // the ECX register into registers EDX:EAX. The EDX register is loaded with // the high-order 32 bits of the MSR and the EAX register is loaded with the // low-order 32 bits. If less than 64 bits are implemented in the MSR being // read, the values returned to EDX:EAX in unimplemented bit locations are // undefined. uint32_t edx; uint32_t eax; __asm__("rdmsr" : "=d"(edx), "=a"(eax) : "c"(reg)); return (((uint64_t)edx) << 32) | (uint64_t)eax; } static inline uint64_t __readcr0(void) { uint64_t cr0_val; __asm__ __volatile__("mov %%cr0, %0" : "=q"(cr0_val) : : "memory"); return cr0_val; } static inline uint64_t __readcr3(void) { uint64_t cr3_val; __asm__ __volatile__("mov %%cr3, %0" : "=q"(cr3_val) : : "memory"); return cr3_val; } static inline uint64_t __readcr4(void) { uint64_t cr4_val; __asm__ __volatile__("mov %%cr4, %0" : "=q"(cr4_val) : : "memory"); return cr4_val; } static inline uint64_t __readcr8(void) { uint64_t cr8_val; __asm__ __volatile__("mov %%cr8, %0" : "=q"(cr8_val) : : "memory"); return cr8_val; } static inline void __writecr0(uint64_t cr0_val) { __asm__("mov %0, %%cr0" : : "q"(cr0_val) : "memory"); } static inline void __writecr3(uint64_t cr3_val) { __asm__("mov %0, %%cr3" : : "q"(cr3_val) : "memory"); } static inline void __writecr4(uint64_t cr4_val) { __asm__("mov %0, %%cr4" : : "q"(cr4_val) : "memory"); } static inline void __writecr8(uint64_t cr8_val) { __asm__("mov %0, %%cr8" : : "q"(cr8_val) : "memory"); } static inline void __invlpg(void *Address) { __asm__ __volatile__("invlpg (%0)" : : "b"(Address) : "memory"); } static inline uint8_t _interlockedbittestandset(int32_t volatile *BitBase, int32_t BitPos) { int32_t _PrevVal = __atomic_fetch_or(BitBase, 1l << BitPos, __ATOMIC_SEQ_CST); return (_PrevVal >> BitPos) & 1; } static inline uint8_t _interlockedbittestandreset(int32_t volatile *BitBase, int32_t BitPos) { int32_t _PrevVal = __atomic_fetch_and(BitBase, ~(1l << BitPos), __ATOMIC_SEQ_CST); return (_PrevVal >> BitPos) & 1; } static inline uint8_t _interlockedbittestandset64(int64_t volatile *BitBase, int64_t BitPos) { int64_t _PrevVal = __atomic_fetch_or(BitBase, 1ll << BitPos, __ATOMIC_SEQ_CST); return (_PrevVal >> BitPos) & 1; } // // Interlocked Exchange Add // static inline int8_t _InterlockedExchangeAdd8(int8_t volatile *Addend, int8_t Value) { return __atomic_fetch_add(Addend, Value, __ATOMIC_SEQ_CST); } static inline int16_t _InterlockedExchangeAdd16(int16_t volatile *Addend, int16_t Value) { return __atomic_fetch_add(Addend, Value, __ATOMIC_SEQ_CST); } static inline int64_t _InterlockedExchangeAdd64(int64_t volatile *Addend, int64_t Value) { return __atomic_fetch_add(Addend, Value, __ATOMIC_SEQ_CST); } // // Interlocked Increment // static inline int32_t _InterlockedIncrement(int32_t volatile *Value) { return __atomic_add_fetch(Value, 1, __ATOMIC_SEQ_CST); } static inline int16_t _InterlockedIncrement16(int16_t volatile *Value) { return __atomic_add_fetch(Value, 1, __ATOMIC_SEQ_CST); } static inline int64_t _InterlockedIncrement64(int64_t volatile *Value) { return __atomic_add_fetch(Value, 1, __ATOMIC_SEQ_CST); } // // Interlocked Decrement // static inline int32_t _InterlockedDecrement(int32_t volatile *Value) { return __atomic_sub_fetch(Value, 1, __ATOMIC_SEQ_CST); } static inline int16_t _InterlockedDecrement16(int16_t volatile *Value) { return __atomic_sub_fetch(Value, 1, __ATOMIC_SEQ_CST); } static inline int64_t _InterlockedDecrement64(int64_t volatile *Value) { return __atomic_sub_fetch(Value, 1, __ATOMIC_SEQ_CST); } // // Interlocked And // static inline int8_t _InterlockedAnd8(int8_t volatile *Value, int8_t Mask) { return __atomic_and_fetch(Value, Mask, __ATOMIC_SEQ_CST); } static inline int16_t _InterlockedAnd16(int16_t volatile *Value, int16_t Mask) { return __atomic_and_fetch(Value, Mask, __ATOMIC_SEQ_CST); } static inline int32_t _InterlockedAnd(int32_t volatile *Value, int32_t Mask) { return __atomic_and_fetch(Value, Mask, __ATOMIC_SEQ_CST); } static inline int64_t _InterlockedAnd64(int64_t volatile *Value, int64_t Mask) { return __atomic_and_fetch(Value, Mask, __ATOMIC_SEQ_CST); } // // Interlocked Or // static inline int8_t _InterlockedOr8(int8_t volatile *Value, int8_t Mask) { return __atomic_or_fetch(Value, Mask, __ATOMIC_SEQ_CST); } static inline int16_t _InterlockedOr16(int16_t volatile *Value, int16_t Mask) { return __atomic_or_fetch(Value, Mask, __ATOMIC_SEQ_CST); } static inline int32_t _InterlockedOr(int32_t volatile *Value, int32_t Mask) { return __atomic_or_fetch(Value, Mask, __ATOMIC_SEQ_CST); } static inline int64_t _InterlockedOr64(int64_t volatile *Value, int64_t Mask) { return __atomic_or_fetch(Value, Mask, __ATOMIC_SEQ_CST); } // // Interlocked Xor // static inline int8_t _InterlockedXor8(int8_t volatile *Value, int8_t Mask) { return __atomic_xor_fetch(Value, Mask, __ATOMIC_SEQ_CST); } static inline int16_t _InterlockedXor16(int16_t volatile *Value, int16_t Mask) { return __atomic_xor_fetch(Value, Mask, __ATOMIC_SEQ_CST); } static inline int32_t _InterlockedXor(int32_t volatile *Value, int32_t Mask) { return __atomic_xor_fetch(Value, Mask, __ATOMIC_SEQ_CST); } static inline int64_t _InterlockedXor64(int64_t volatile *Value, int64_t Mask) { return __atomic_xor_fetch(Value, Mask, __ATOMIC_SEQ_CST); } // // Interlocked Exchange // static inline int32_t _InterlockedExchange(int32_t volatile *Target, int32_t Value) { __atomic_exchange(Target, &Value, &Value, __ATOMIC_SEQ_CST); return Value; } static inline int8_t _InterlockedExchange8(int8_t volatile *Target, int8_t Value) { __atomic_exchange(Target, &Value, &Value, __ATOMIC_SEQ_CST); return Value; } static inline int16_t _InterlockedExchange16(int16_t volatile *Target, int16_t Value) { __atomic_exchange(Target, &Value, &Value, __ATOMIC_SEQ_CST); return Value; } static inline int64_t _InterlockedExchange64(int64_t volatile *Target, int64_t Value) { __atomic_exchange(Target, &Value, &Value, __ATOMIC_SEQ_CST); return Value; } // // Interlocked Compare Exchange // static inline int8_t _InterlockedCompareExchange8(int8_t volatile *Destination, int8_t Exchange, int8_t Comparand) { __atomic_compare_exchange(Destination, &Comparand, &Exchange, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); return Comparand; } static inline int16_t _InterlockedCompareExchange16(int16_t volatile *Destination, int16_t Exchange, int16_t Comparand) { __atomic_compare_exchange(Destination, &Comparand, &Exchange, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); return Comparand; } static inline int32_t _InterlockedCompareExchange(int32_t volatile *Destination, int32_t Exchange, int32_t Comparand) { __atomic_compare_exchange(Destination, &Comparand, &Exchange, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); return Comparand; } static inline int64_t _InterlockedCompareExchange64(int64_t volatile *Destination, int64_t Exchange, int64_t Comparand) { __atomic_compare_exchange(Destination, &Comparand, &Exchange, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); return Comparand; } static inline void * _InterlockedCompareExchangePointer(void volatile **Destination, void *Exchange, void *Comparand) { return (void *)_InterlockedCompareExchange64((int64_t volatile *)Destination, (int64_t)Exchange, (int64_t)Comparand); } // // Barriers // static inline void __attribute__((__deprecated__("use other intrinsics or C++11 atomics instead"))) _ReadWriteBarrier(void) { __asm__ volatile ("" : : : "memory"); } static inline void __attribute__((__deprecated__("use other intrinsics or C++11 atomics instead"))) _ReadBarrier(void) { __asm__ volatile ("" : : : "memory"); } static inline void __attribute__((__deprecated__("use other intrinsics or C++11 atomics instead"))) _WriteBarrier(void) { __asm__ volatile ("" : : : "memory"); } static inline void __faststorefence(void) { __asm__ volatile("lock orq $0, (%%rsp)" : : : "memory"); } #endif // INT_COMPILER_MSVC #endif // _INTRINSICS_H_
21.992582
121
0.703636
[ "model" ]
04510de074bfcea9d33ab9f6f6268fb7bdfaa31f
17,524
c
C
src/lib/ecore_wayland/ecore_wl.c
gfriloux/ecore
e1ca9832f8265db515837139a90c2995c1eca673
[ "BSD-2-Clause" ]
null
null
null
src/lib/ecore_wayland/ecore_wl.c
gfriloux/ecore
e1ca9832f8265db515837139a90c2995c1eca673
[ "BSD-2-Clause" ]
null
null
null
src/lib/ecore_wayland/ecore_wl.c
gfriloux/ecore
e1ca9832f8265db515837139a90c2995c1eca673
[ "BSD-2-Clause" ]
null
null
null
#ifdef HAVE_CONFIG_H # include <config.h> #endif #ifdef STDC_HEADERS # include <stdlib.h> # include <stddef.h> #else # ifdef HAVE_STDLIB_H # include <stdlib.h> # endif #endif #ifdef HAVE_ALLOCA_H # include <alloca.h> #elif !defined alloca # ifdef __GNUC__ # define alloca __builtin_alloca # elif defined _AIX # define alloca __alloca # elif defined _MSC_VER # include <malloc.h> # define alloca _alloca # elif !defined HAVE_ALLOCA # ifdef __cplusplus extern "C" # endif void *alloca (size_t); # endif #endif #include <fcntl.h> #include "ecore_wl_private.h" /* local function prototypes */ static Eina_Bool _ecore_wl_shutdown(Eina_Bool close); static Eina_Bool _ecore_wl_cb_idle_enterer(void *data); static Eina_Bool _ecore_wl_cb_handle_data(void *data, Ecore_Fd_Handler *hdl); static void _ecore_wl_cb_handle_global(void *data, struct wl_registry *registry, unsigned int id, const char *interface, unsigned int version __UNUSED__); static Eina_Bool _ecore_wl_xkb_init(Ecore_Wl_Display *ewd); static Eina_Bool _ecore_wl_xkb_shutdown(Ecore_Wl_Display *ewd); static void _ecore_wl_sync_wait(Ecore_Wl_Display *ewd); static void _ecore_wl_sync_callback(void *data, struct wl_callback *callback, uint32_t serial); /* local variables */ static int _ecore_wl_init_count = 0; static const struct wl_registry_listener _ecore_wl_registry_listener = { _ecore_wl_cb_handle_global, NULL // handle_global_remove }; static const struct wl_callback_listener _ecore_wl_sync_listener = { _ecore_wl_sync_callback }; /* external variables */ int _ecore_wl_log_dom = -1; Ecore_Wl_Display *_ecore_wl_disp = NULL; EAPI int ECORE_WL_EVENT_MOUSE_IN = 0; EAPI int ECORE_WL_EVENT_MOUSE_OUT = 0; EAPI int ECORE_WL_EVENT_FOCUS_IN = 0; EAPI int ECORE_WL_EVENT_FOCUS_OUT = 0; EAPI int ECORE_WL_EVENT_WINDOW_CONFIGURE = 0; EAPI int ECORE_WL_EVENT_DND_ENTER = 0; EAPI int ECORE_WL_EVENT_DND_POSITION = 0; EAPI int ECORE_WL_EVENT_DND_LEAVE = 0; EAPI int ECORE_WL_EVENT_DND_DROP = 0; EAPI int ECORE_WL_EVENT_DATA_SOURCE_TARGET = 0; EAPI int ECORE_WL_EVENT_DATA_SOURCE_SEND = 0; EAPI int ECORE_WL_EVENT_SELECTION_DATA_READY = 0; EAPI int ECORE_WL_EVENT_DATA_SOURCE_CANCELLED = 0; EAPI int ECORE_WL_EVENT_INTERFACES_BOUND = 0; /** * @defgroup Ecore_Wl_Init_Group Wayland Library Init and Shutdown Functions * * Functions that start and shutdown the Ecore Wayland Library. */ /** * Initialize the Wayland display connection to the given display. * * @param name Display target name. if @c NULL, the default display is * assumed. * @return The number of times the library has been initialized without being * shut down. 0 is returned if an error occurs. * * @ingroup Ecore_Wl_Init_Group */ EAPI int ecore_wl_init(const char *name) { LOGFN(__FILE__, __LINE__, __FUNCTION__); if (++_ecore_wl_init_count != 1) return _ecore_wl_init_count; if (!eina_init()) return --_ecore_wl_init_count; _ecore_wl_log_dom = eina_log_domain_register("ecore_wl", ECORE_WL_DEFAULT_LOG_COLOR); if (_ecore_wl_log_dom < 0) { EINA_LOG_ERR("Cannot create a log domain for Ecore Wayland"); eina_shutdown(); return --_ecore_wl_init_count; } if (!ecore_init()) { ERR("Could not initialize ecore"); eina_log_domain_unregister(_ecore_wl_log_dom); _ecore_wl_log_dom = -1; eina_shutdown(); return --_ecore_wl_init_count; } if (!ecore_event_init()) { ERR("Could not initialize ecore_event"); eina_log_domain_unregister(_ecore_wl_log_dom); _ecore_wl_log_dom = -1; ecore_shutdown(); eina_shutdown(); return --_ecore_wl_init_count; } if (!ECORE_WL_EVENT_MOUSE_IN) { ECORE_WL_EVENT_MOUSE_IN = ecore_event_type_new(); ECORE_WL_EVENT_MOUSE_OUT = ecore_event_type_new(); ECORE_WL_EVENT_FOCUS_IN = ecore_event_type_new(); ECORE_WL_EVENT_FOCUS_OUT = ecore_event_type_new(); ECORE_WL_EVENT_WINDOW_CONFIGURE = ecore_event_type_new(); ECORE_WL_EVENT_DND_ENTER = ecore_event_type_new(); ECORE_WL_EVENT_DND_POSITION = ecore_event_type_new(); ECORE_WL_EVENT_DND_LEAVE = ecore_event_type_new(); ECORE_WL_EVENT_DND_DROP = ecore_event_type_new(); ECORE_WL_EVENT_DATA_SOURCE_TARGET = ecore_event_type_new(); ECORE_WL_EVENT_DATA_SOURCE_SEND = ecore_event_type_new(); ECORE_WL_EVENT_SELECTION_DATA_READY = ecore_event_type_new(); ECORE_WL_EVENT_DATA_SOURCE_CANCELLED = ecore_event_type_new(); ECORE_WL_EVENT_INTERFACES_BOUND = ecore_event_type_new(); } if (!(_ecore_wl_disp = malloc(sizeof(Ecore_Wl_Display)))) { ERR("Could not allocate memory for Ecore_Wl_Display structure"); eina_log_domain_unregister(_ecore_wl_log_dom); _ecore_wl_log_dom = -1; ecore_event_shutdown(); ecore_shutdown(); eina_shutdown(); return --_ecore_wl_init_count; } memset(_ecore_wl_disp, 0, sizeof(Ecore_Wl_Display)); if (!(_ecore_wl_disp->wl.display = wl_display_connect(name))) { ERR("Could not connect to Wayland display"); eina_log_domain_unregister(_ecore_wl_log_dom); _ecore_wl_log_dom = -1; ecore_event_shutdown(); ecore_shutdown(); eina_shutdown(); return --_ecore_wl_init_count; } _ecore_wl_disp->fd = wl_display_get_fd(_ecore_wl_disp->wl.display); _ecore_wl_disp->fd_hdl = ecore_main_fd_handler_add(_ecore_wl_disp->fd, ECORE_FD_READ, _ecore_wl_cb_handle_data, _ecore_wl_disp, NULL, NULL); _ecore_wl_disp->idle_enterer = ecore_idle_enterer_add(_ecore_wl_cb_idle_enterer, _ecore_wl_disp); wl_list_init(&_ecore_wl_disp->inputs); wl_list_init(&_ecore_wl_disp->outputs); wl_list_init(&_ecore_wl_disp->globals); _ecore_wl_disp->wl.registry = wl_display_get_registry(_ecore_wl_disp->wl.display); wl_registry_add_listener(_ecore_wl_disp->wl.registry, &_ecore_wl_registry_listener, _ecore_wl_disp); wl_display_dispatch(_ecore_wl_disp->wl.display); if (!_ecore_wl_xkb_init(_ecore_wl_disp)) { ERR("Could not initialize XKB"); free(_ecore_wl_disp); eina_log_domain_unregister(_ecore_wl_log_dom); _ecore_wl_log_dom = -1; ecore_event_shutdown(); ecore_shutdown(); eina_shutdown(); return --_ecore_wl_init_count; } _ecore_wl_window_init(); return _ecore_wl_init_count; } /** * Shuts down the Ecore Wayland Library * * In shutting down the library, the Wayland display connection is terminated * and any event handlers for it are removed. * * @return The number of times the library has been initialized without * being shut down. * * @ingroup Ecore_Wl_Init_Group */ EAPI int ecore_wl_shutdown(void) { LOGFN(__FILE__, __LINE__, __FUNCTION__); return _ecore_wl_shutdown(EINA_TRUE); } /** * @defgroup Ecore_Wl_Flush_Group Wayland Synchronization Functions * * Functions that ensure that all commands which have been issued by the * Ecore Wayland library have been sent to the server. */ /** * Sends all Wayland commands to the Wayland Display. * * @ingroup Ecore_Wl_Flush_Group * @since 1.2 */ EAPI void ecore_wl_flush(void) { // LOGFN(__FILE__, __LINE__, __FUNCTION__); wl_display_flush(_ecore_wl_disp->wl.display); } /** * Flushes the command buffer and waits until all requests have been * processed by the server. * * @ingroup Ecore_Wl_Flush_Group * @since 1.2 */ EAPI void ecore_wl_sync(void) { // LOGFN(__FILE__, __LINE__, __FUNCTION__); _ecore_wl_sync_wait(_ecore_wl_disp); while (_ecore_wl_disp->sync_ref_count > 0) wl_display_dispatch(_ecore_wl_disp->wl.display); } /** * @defgroup Ecore_Wl_Display_Group Wayland Display Functions * * Functions that set and retrieve various information about the Wayland Display. */ /** * Retrieves the Wayland Shm Interface used for the current Wayland connection. * * @return The current wayland shm interface * * @ingroup Ecore_Wl_Display_Group * @since 1.2 */ EAPI struct wl_shm * ecore_wl_shm_get(void) { return _ecore_wl_disp->wl.shm; } /** * Retrieves the Wayland Display Interface used for the current Wayland connection. * * @return The current wayland display interface * * @ingroup Ecore_Wl_Display_Group * @since 1.2 */ EAPI struct wl_display * ecore_wl_display_get(void) { return _ecore_wl_disp->wl.display; } EAPI struct wl_list * ecore_wl_globals_get(void) { return &(_ecore_wl_disp->globals); } EAPI struct wl_registry * ecore_wl_registry_get(void) { return _ecore_wl_disp->wl.registry; } /** * Retrieves the size of the current screen. * * @param w where to return the width. May be NULL. Returns 0 on error. * @param h where to return the height. May be NULL. Returns 0 on error. * * @ingroup Ecore_Wl_Display_Group * @since 1.2 */ EAPI void ecore_wl_screen_size_get(int *w, int *h) { LOGFN(__FILE__, __LINE__, __FUNCTION__); if (w) *w = 0; if (h) *h = 0; if (!_ecore_wl_disp->output) ecore_wl_sync(); if (!_ecore_wl_disp->output) return; switch (_ecore_wl_disp->output->transform) { case WL_OUTPUT_TRANSFORM_90: case WL_OUTPUT_TRANSFORM_270: case WL_OUTPUT_TRANSFORM_FLIPPED_90: case WL_OUTPUT_TRANSFORM_FLIPPED_270: /* Swap width and height */ if (w) *w = _ecore_wl_disp->output->allocation.h; if (h) *h = _ecore_wl_disp->output->allocation.w; break; default: if (w) *w = _ecore_wl_disp->output->allocation.w; if (h) *h = _ecore_wl_disp->output->allocation.h; } } /* @since 1.2 */ EAPI void ecore_wl_pointer_xy_get(int *x, int *y) { LOGFN(__FILE__, __LINE__, __FUNCTION__); _ecore_wl_input_pointer_xy_get(x, y); } /** * Return the screen DPI * * This is a simplistic call to get DPI. It does not account for differing * DPI in the x and y axes nor does it account for multihead or xinerama and * xrandr where different parts of the screen may have different DPI etc. * * @return the general screen DPI (dots/pixels per inch). * * @since 1.2 */ EAPI int ecore_wl_dpi_get(void) { int w, mw; LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!_ecore_wl_disp->output) return 75; mw = _ecore_wl_disp->output->mw; if (mw <= 0) return 75; w = _ecore_wl_disp->output->allocation.w; /* FIXME: NB: Hrrrmmm, need to verify this. xorg code is using a different * formula to calc this */ return (((w * 254) / mw) + 5) / 10; } EAPI void ecore_wl_display_iterate(void) { wl_display_dispatch(_ecore_wl_disp->wl.display); } /** * Retrieves the requested cursor from the cursor theme * * @param cursor_name The desired cursor name to be looked up in the theme * @return the cursor or NULL if the cursor cannot be found * * @since 1.2 */ EAPI struct wl_cursor * ecore_wl_cursor_get(const char *cursor_name) { if ((!_ecore_wl_disp) || (!_ecore_wl_disp->cursor_theme)) return NULL; return wl_cursor_theme_get_cursor(_ecore_wl_disp->cursor_theme, cursor_name); } /* local functions */ static Eina_Bool _ecore_wl_shutdown(Eina_Bool close) { LOGFN(__FILE__, __LINE__, __FUNCTION__); if (--_ecore_wl_init_count != 0) return _ecore_wl_init_count; if (!_ecore_wl_disp) return _ecore_wl_init_count; _ecore_wl_window_shutdown(); if (_ecore_wl_disp->fd_hdl) ecore_main_fd_handler_del(_ecore_wl_disp->fd_hdl); if (_ecore_wl_disp->idle_enterer) ecore_idle_enterer_del(_ecore_wl_disp->idle_enterer); if (close) { Ecore_Wl_Output *out, *tout; Ecore_Wl_Input *in, *tin; Ecore_Wl_Global *global, *tglobal; wl_list_for_each_safe(out, tout, &_ecore_wl_disp->outputs, link) _ecore_wl_output_del(out); wl_list_for_each_safe(in, tin, &_ecore_wl_disp->inputs, link) _ecore_wl_input_del(in); wl_list_for_each_safe(global, tglobal, &_ecore_wl_disp->globals, link) { wl_list_remove(&global->link); free(global->interface); free(global); } _ecore_wl_xkb_shutdown(_ecore_wl_disp); if (_ecore_wl_disp->wl.shell) wl_shell_destroy(_ecore_wl_disp->wl.shell); if (_ecore_wl_disp->wl.shm) wl_shm_destroy(_ecore_wl_disp->wl.shm); if (_ecore_wl_disp->wl.data_device_manager) wl_data_device_manager_destroy(_ecore_wl_disp->wl.data_device_manager); if (_ecore_wl_disp->wl.compositor) wl_compositor_destroy(_ecore_wl_disp->wl.compositor); if (_ecore_wl_disp->wl.display) { wl_registry_destroy(_ecore_wl_disp->wl.registry); wl_display_flush(_ecore_wl_disp->wl.display); wl_display_disconnect(_ecore_wl_disp->wl.display); } free(_ecore_wl_disp); } ecore_event_shutdown(); ecore_shutdown(); eina_log_domain_unregister(_ecore_wl_log_dom); _ecore_wl_log_dom = -1; eina_shutdown(); return _ecore_wl_init_count; } static Eina_Bool _ecore_wl_cb_idle_enterer(void *data) { Ecore_Wl_Display *ewd; int ret; if (!(ewd = data)) return ECORE_CALLBACK_RENEW; ret = wl_display_flush(ewd->wl.display); if ((ret < 0) && (errno == EAGAIN)) { ecore_main_fd_handler_active_set(ewd->fd_hdl, (ECORE_FD_READ | ECORE_FD_WRITE)); } else if (ret < 0) { /* FIXME: need do error processing? */ } return ECORE_CALLBACK_RENEW; } static Eina_Bool _ecore_wl_cb_handle_data(void *data, Ecore_Fd_Handler *hdl) { Ecore_Wl_Display *ewd; int ret; /* LOGFN(__FILE__, __LINE__, __FUNCTION__); */ if (!(ewd = data)) return ECORE_CALLBACK_RENEW; /* FIXME: This should also catch ECORE_FD_ERROR and exit */ /* wl_display_dispatch_pending(ewd->wl.display); */ if (ecore_main_fd_handler_active_get(hdl, ECORE_FD_READ)) wl_display_dispatch(ewd->wl.display); else if (ecore_main_fd_handler_active_get(hdl, ECORE_FD_WRITE)) { ret = wl_display_flush(ewd->wl.display); if (ret == 0) ecore_main_fd_handler_active_set(hdl, ECORE_FD_READ); else if ((ret == -1) && (errno != EAGAIN)) { /* FIXME: need do error processing? */ } } return ECORE_CALLBACK_RENEW; } static void _ecore_wl_cb_handle_global(void *data, struct wl_registry *registry, unsigned int id, const char *interface, unsigned int version __UNUSED__) { Ecore_Wl_Display *ewd; Ecore_Wl_Global *global; LOGFN(__FILE__, __LINE__, __FUNCTION__); ewd = data; global = malloc(sizeof(*global)); memset(global, 0, sizeof(Ecore_Wl_Global)); global->id = id; global->interface = strdup(interface); global->version = version; wl_list_insert(ewd->globals.prev, &global->link); if (!strcmp(interface, "wl_compositor")) { ewd->wl.compositor = wl_registry_bind(registry, id, &wl_compositor_interface, 1); } else if (!strcmp(interface, "wl_output")) _ecore_wl_output_add(ewd, id); else if (!strcmp(interface, "wl_seat")) _ecore_wl_input_add(ewd, id); else if (!strcmp(interface, "wl_shell")) { ewd->wl.shell = wl_registry_bind(registry, id, &wl_shell_interface, 1); } else if (!strcmp(interface, "wl_shm")) { ewd->wl.shm = wl_registry_bind(registry, id, &wl_shm_interface, 1); /* FIXME: We should not hard-code a cursor size here, and we should * also import the theme name from a config or env variable */ ewd->cursor_theme = wl_cursor_theme_load(NULL, 32, ewd->wl.shm); } else if (!strcmp(interface, "wl_data_device_manager")) { ewd->wl.data_device_manager = wl_registry_bind(registry, id, &wl_data_device_manager_interface, 1); } if ((ewd->wl.compositor) && (ewd->wl.shm) && (ewd->wl.shell)) { Ecore_Wl_Event_Interfaces_Bound *ev; if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Interfaces_Bound)))) return; ev->compositor = (ewd->wl.compositor != NULL); ev->shm = (ewd->wl.shm != NULL); ev->shell = (ewd->wl.shell != NULL); ecore_event_add(ECORE_WL_EVENT_INTERFACES_BOUND, ev, NULL, NULL); } } static Eina_Bool _ecore_wl_xkb_init(Ecore_Wl_Display *ewd) { LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!(ewd->xkb.context = xkb_context_new(0))) return EINA_FALSE; return EINA_TRUE; } static Eina_Bool _ecore_wl_xkb_shutdown(Ecore_Wl_Display *ewd) { LOGFN(__FILE__, __LINE__, __FUNCTION__); xkb_context_unref(ewd->xkb.context); return EINA_TRUE; } struct wl_data_source * _ecore_wl_create_data_source(Ecore_Wl_Display *ewd) { return wl_data_device_manager_create_data_source(ewd->wl.data_device_manager); } static void _ecore_wl_sync_callback(void *data, struct wl_callback *callback, uint32_t serial EINA_UNUSED) { Ecore_Wl_Display *ewd = data; ewd->sync_ref_count--; wl_callback_destroy(callback); } static void _ecore_wl_sync_wait(Ecore_Wl_Display *ewd) { struct wl_callback *callback; ewd->sync_ref_count++; callback = wl_display_sync(ewd->wl.display); wl_callback_add_listener(callback, &_ecore_wl_sync_listener, ewd); }
27.59685
154
0.695218
[ "transform" ]
04620cf621e0e4cea761e32043ab28360a73c007
432
h
C
SSV/Source/SSV/Client/WindowChrome/WindowCaptionLabel.h
Shards-CP/SSV
5dda6d6e000114143f8d06606800e1aef3688079
[ "libpng-2.0" ]
null
null
null
SSV/Source/SSV/Client/WindowChrome/WindowCaptionLabel.h
Shards-CP/SSV
5dda6d6e000114143f8d06606800e1aef3688079
[ "libpng-2.0" ]
null
null
null
SSV/Source/SSV/Client/WindowChrome/WindowCaptionLabel.h
Shards-CP/SSV
5dda6d6e000114143f8d06606800e1aef3688079
[ "libpng-2.0" ]
null
null
null
#pragma once #include "Client/UI/TextLabel.h" namespace SSV::Client::WindowChrome { class WindowCaptionLabel : public UI::TextLabel { public: WindowCaptionLabel(const std::string& name, const int32_t zIndex, const std::wstring& text, const std::wstring& font, const float fontSize); ~WindowCaptionLabel() = default; virtual void Render(const Microsoft::WRL::ComPtr<ID2D1DeviceContext5>& deviceContext) override; }; }
27
142
0.75463
[ "render" ]
04629d29af9fdfb4d22ba13a9c45bd86086f9afa
4,443
h
C
MitaiSub.h
tvmanus/Mitel-Monitor
fb5929f3fefc3af1dcd65d059fda219b31bccec5
[ "BSD-3-Clause" ]
1
2020-03-13T15:24:08.000Z
2020-03-13T15:24:08.000Z
MitaiSub.h
tvmanus/Mitel-Monitor
fb5929f3fefc3af1dcd65d059fda219b31bccec5
[ "BSD-3-Clause" ]
null
null
null
MitaiSub.h
tvmanus/Mitel-Monitor
fb5929f3fefc3af1dcd65d059fda219b31bccec5
[ "BSD-3-Clause" ]
null
null
null
#ifndef _MiTAISub_H #define _MiTAISub_H #ifdef __cplusplus extern "C" { #include "mtai.h" } #endif /* __cplusplus */ #include "Poco/NumberFormatter.h" #include "Poco/Util/Subsystem.h" #include "Poco/Util/Application.h" #include "Poco/Notification.h" #include "Poco/NotificationQueue.h" #include "Poco/Task.h" #include "Poco/TaskManager.h" #include <vector> #include <string> #include <list> using Poco::NumberFormatter; using Poco::Util::Subsystem; using Poco::Util::Application; using Poco::Notification; using Poco::NotificationQueue; using Poco::Task; using Poco::TaskManager; using std::string; using std::vector; using std::list; #define DEF_KEEPALIVE_VALUE 40 #define RESULT_TIMEOUT 0 #define RESULT_SUCCESS 1 #define RESULT_FAIL 2 #define RESULT_INTERRUPT 3 /************************************************************************* PBX configuration structure IPAddress - string representation of IP Address of ICP TrunkNum - Vector of strings representing monitored trunks of ICP DNNum - Vecotor of strings representing monitored DNs (Directory Numbers) **************************************************************************/ typedef struct { string IPAddress; vector<string> TrunkNum; vector<string> DNNum; } TM_PBX_Conf ; /****************************************** MITAI monitor state strDN - trunk number or DN state - state code. See mitai.h for details *******************************************/ typedef struct { string strDN; DWORD state; } TM_PBX_MonitorState ; class TM_PBX; class TM_Session; /* TM_Address is a class for manipulating with MITAI monitors It is addressing a monitored object in ICP m_hMonitor - handle to MITAI monitor object. Generated by MiTAI stack SetMonitor - start monitoring a trunk or DN StopMonitor - stop monitoring a trunk or DN CallbackEventFromPBX - callback function called from MiTAI stack when we have a new event GetIPAddress - returns IP address of ICP where this monitor is set GetDN - returns trunk number or DN GetState - returns current state of trunk or DN. see mitai.h for details UpdateState - sending update when state is changing. Private variables m_strDN - monitored trunk number or DN *m_pSwitch - pointer to parent PBX object m_dwState - current state */ class TM_Address { public: TM_Address (string dn, TM_PBX* pPBX); ~TM_Address(); hMonitorObject m_hMonitor; DWORD SetMonitor(); DWORD StopMonitor(); static void CallbackEventFromPBX(SXEvent* pEvent, TM_Address* pAddress); string GetIPAddress(); string GetDN(); DWORD GetState(); void UpdateState(); private: string m_strDN; TM_PBX* m_pSwitch; DWORD m_dwState; string m_strANI; string m_strDNIS; }; /* TM_PBX is a class for manipulating */ class TM_PBX { public: TM_PBX (string ipAddress, TM_Session* pSession = NULL); ~TM_PBX (); hPbxObject m_hPBX; DWORD OpenPBX(); DWORD ClosePBX(); DWORD MonitorLine(string dn); void MonitorLines(vector<string> lines); DWORD StopAllMonitors(); static void CommErrorProc(hPbxObject hpbx_obj, void* lpData); string GetIPAddress(); void GetMonitorState(vector<TM_PBX_MonitorState> & MonState); private: string m_strIPAddress; TM_Session* m_pSession; vector<TM_Address*> m_vpAddress; }; class TM_Session { public: TM_Session (string ipAddress, vector<string> dn); ~TM_Session (); void OpenSession(); void CloseSession(); void RestartSession(); DWORD ConnectToICP(); DWORD DisconnectFromICP(); string GetIPAddress(); void GetSessionStatus(vector<TM_PBX_MonitorState> &MonState); BOOL m_bNeverConnected; private: TM_PBX* m_pMiPBX; string m_strIPAddress; vector<string> m_strDN; BOOL m_bInit; }; class MiTAISub: public Subsystem { public: MiTAISub(); ~MiTAISub(); virtual void initialize(Application &app); const char* name() const; virtual void uninitialize(); bool isInitialized(); void run(); vector<TM_Session*> m_vpMiSession; protected: vector<TM_PBX_Conf> TM_Config; //Session manager. Maintains PBX sessions in separate tasks. TaskManager SessionManager; private: BOOL m_bInit; }; class MiTAINotification: public Notification { public: MiTAINotification(std::string data); std::string data() const; private: std::string _data; }; #endif _MiTAISub_H
22.902062
90
0.686248
[ "object", "vector" ]
0481082ca6dc4ae077d5e8096283ebd7452d63c5
9,410
h
C
ogsCore/GeoLib/GEOObjects.h
Yonghui56/NCP
29680706b7d8dd9b78d51c10d4a36799eb24c38f
[ "BSD-4-Clause" ]
null
null
null
ogsCore/GeoLib/GEOObjects.h
Yonghui56/NCP
29680706b7d8dd9b78d51c10d4a36799eb24c38f
[ "BSD-4-Clause" ]
1
2016-07-08T03:44:02.000Z
2016-07-08T08:59:45.000Z
ogsCore/GeoLib/GEOObjects.h
Yonghui56/NCP
29680706b7d8dd9b78d51c10d4a36799eb24c38f
[ "BSD-4-Clause" ]
null
null
null
/** * Copyright (c) 2012, OpenGeoSys Community (http://www.opengeosys.com) * Distributed under a Modified BSD License. * See accompanying file LICENSE.txt or * http://www.opengeosys.com/LICENSE.txt * * * \file GEOObjects.h * * Created on 2010-01-21 by Thomas Fischer / Karsten Rink */ #ifndef GEOOBJECTS_H_ #define GEOOBJECTS_H_ #include <map> #include <string> #include <vector> #include "Point.h" #include "PointVec.h" #include "Polyline.h" #include "PolylineVec.h" #include "Surface.h" #include "SurfaceVec.h" #include "GeoDomain.h" namespace GeoLib { /// /** * \defgroup GEOLIB This module consists of classes governing geometric objects * and related algorithms. */ /** * \brief Container class for geometric objects. * * This class contains all the methods necessary for the I/O of geometric objects. * Said objects are Points, polylines, Surfaces and Stations and they are stored in * vectors (arrays) which are identified by a unique name. * For a hierarchical definition, surfaces are bounded by polylines and polylines * are defined by points. Therefore, a vector of surfaces references a vector polylines * and a vector of polylines references a vector of points, respectively. For * identification purposes, all of these vectors have the same name, i.e. the polyline- * vector named "aaa" references a point vector "aaa". However, this name ("aaa") is * unique among all the vectors of the same class, i.e. there exists only one point- * vector with this name, etc. * Note: The fact that vectors are uniquely named and the same name is assigned to * related objects is automatically handled by this class. * * For each of these object-classes exists an "add", "remove" and "get"-method which * allows for loading/unloading as well as accessing the data, respectively. * E.g. for points these methods are "addPointVec(name)", "getPointVec(name)" and * "removePointVec(name)". For some objects, additional methods might exist if * necessary. */ class GEOObjects { public: /** * Adds a vector of points with the given name to GEOObjects. * @param points vector of pointers to points * @param name the project name * @param pnt_names vector of the names corresponding to the points */ virtual void addPointVec(std::vector<Point*> *points, std::string &name, std::map<std::string, size_t>* pnt_names = NULL); /** copies the pointers to the points in the vector to the PointVec with provided name. * the pointers are managed by the GEOObjects, i.e. GEOObjects will delete the Points at the * end of its scope * \param points the vector with points * \param name the name of the internal PointVec * \param ids On return the vector holds the ids of the inserted points within the internal vector. * In case the ids are not needed it is possible to give a NULL pointer (default value). * \return true if the points are appended, false if the a PointVec with the * corresponding name does not exist * */ virtual bool appendPointVec(const std::vector<Point*> &points, std::string const &name, std::vector<size_t>* ids = NULL); /** * Returns the point vector with the given name. */ const std::vector<Point*> *getPointVec(const std::string &name) const; /** * search and returns the PointVec object with the given name. * @param name the name of the PointVec object * @return the PointVec object stored in GEOObjects */ const PointVec* getPointVecObj(const std::string &name) const; /** If there exists no dependencies the point vector with the given * name from GEOObjects will be removed and the method returns true, * else the return value is false. */ virtual bool removePointVec(const std::string &name); /** * Adds a vector of polylines with the given name to GEOObjects. * @param lines The lines vector. * @param name The given name. * @param ply_names vector of the names corresponding to the polylines */ virtual void addPolylineVec(std::vector<Polyline*> *lines, const std::string &name, std::map<std::string,size_t>* ply_names = NULL); /** copies the pointers to the polylines in the vector to the PolylineVec with provided name. * the pointers are managed by the GEOObjects, i.e. GEOObjects will delete the Polylines at the * end of its scope * \param polylines the vector with polylines * \param name the name of the internal PolylineVec * \return true if the polylines are appended, false if the PolylineVec with the * corresponding name does not exist * */ virtual bool appendPolylineVec(const std::vector<Polyline*> &polylines, const std::string &name); /** * Returns the polyline vector with the given name. * */ const std::vector<Polyline*> *getPolylineVec(const std::string &name) const; /** * Returns a pointer to a PolylineVec object for the given name as a const. * @param name the name of the vector of polylines * @return PolylineVec object */ const PolylineVec* getPolylineVecObj(const std::string &name) const; /// Returns a pointer to a PolylineVec object for the given name. PolylineVec* getPolylineVecObj(const std::string &name) { return const_cast<PolylineVec*>(static_cast<const GEOObjects&>(*this).getPolylineVecObj(name)); }; /** * If no Surfaces depends on the vector of Polylines with the given * name it will be removed and the method returns true, * else the return value is false. */ virtual bool removePolylineVec(const std::string &name); /** Adds a vector of surfaces with the given name to GEOObjects. */ virtual void addSurfaceVec(std::vector<Surface*> *surfaces, const std::string &name, std::map<std::string, size_t>* sfc_names = NULL); /** * Copies the surfaces in the vector to the SurfaceVec with the given name. * \param surfaces the vector with surfaces * \param name the name of the internal PolylineVec * \return true if the surfaces are appended, false if the SurfaceVec with the * corresponding name does not exist * */ virtual bool appendSurfaceVec(const std::vector<Surface*> &surfaces, const std::string &name); /// Returns the surface vector with the given name as a const. const std::vector<Surface*> *getSurfaceVec(const std::string &name) const; /// Returns the surface vector with the given name. SurfaceVec* getSurfaceVecObj(const std::string &name) { return const_cast<SurfaceVec*>(static_cast<const GEOObjects&>(*this).getSurfaceVecObj(name)); }; /** removes the vector of Surfaces with the given name */ virtual bool removeSurfaceVec(const std::string &name); /** * Returns a pointer to a SurfaceVec object for the given name. The class * SurfaceVec stores the relation between surfaces and the names of the surfaces. * @param name the name of the vector of surfaces (the project name) * @return SurfaceVec object */ const SurfaceVec* getSurfaceVecObj(const std::string &name) const; /** * Returns a pointer to a GeoDomain object * @return GeoDomain object */ const GeoDomain* getDomainObj() const {return &_geo_domain;}; /// Returns the names of all geometry vectors. void getGeometryNames (std::vector<std::string>& names) const; /** * merge geometries * @param names the names of the geometries that are to be merged * @param merged_geo_name the name of the resulting geometry */ void mergeGeometries (std::vector<std::string> const & names, std::string &merged_geo_name); /** * Returns geometric object with the given name * @param unique_geo_name the project name * @param geo_type_name the geometry type name * @param geo_name the geometry name * @return a pointer to a geometric object */ const GeoObject* searchGeoByName(const std::string &unique_geo_name, const std::string &geo_type_name, const std::string &geo_name) const; /** constructor */ GEOObjects(); /** destructor */ virtual ~GEOObjects(); protected: /** * Determines if the given name is unique among all the names in point vectors and creates a * new name if this is not the case. The new name is then simply "name + x", where x>1 is * the smallest number that creates a unique name (i.e. "name-2", "name-3", etc.) * \param name Original name of the list, this name might be changed within this method if necessary. * \return true if the name was unique, false if a new name has been generated */ bool isUniquePointVecName(std::string &name); /// Checks if the point vector with the given name is referenced in a polyline- or surface vector. bool isPntVecUsed (const std::string &name) const; /** * vector manages pointers to PointVec objects */ std::vector<PointVec*> _pnt_vecs; /** vector manages pointers to PolylineVec objects */ std::vector<PolylineVec*> _ply_vecs; /** vector manages pointers to SurfaceVec objects */ std::vector<SurfaceVec*> _sfc_vecs; /** domain object */ GeoDomain _geo_domain; }; } // end namespace #endif /* GEOOBJECTS_H_ */
39.872881
142
0.690436
[ "geometry", "object", "vector" ]
0482ae2bf725b1ba0a9cd92feab64a867dfc5998
6,951
h
C
ui/aura/client/aura_constants.h
zipated/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
2,151
2020-04-18T07:31:17.000Z
2022-03-31T08:39:18.000Z
ui/aura/client/aura_constants.h
cangulcan/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
395
2020-04-18T08:22:18.000Z
2021-12-08T13:04:49.000Z
ui/aura/client/aura_constants.h
cangulcan/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
338
2020-04-18T08:03:10.000Z
2022-03-29T12:33:22.000Z
// Copyright (c) 2012 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. #ifndef UI_AURA_CLIENT_AURA_CONSTANTS_H_ #define UI_AURA_CLIENT_AURA_CONSTANTS_H_ #include <string> #include "base/strings/string16.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/aura/aura_export.h" #include "ui/aura/window.h" #include "ui/base/ui_base_types.h" namespace ui { namespace mojom { enum class WindowType; } } namespace aura { namespace client { class FocusClient; enum class WindowEmbedType { NONE, EMBED_IN_OWNER, TOP_LEVEL_IN_WM, }; // Alphabetical sort. // A property key to store whether accessibility focus falls back to widget or // not. AURA_EXPORT extern const WindowProperty<bool>* const kAccessibilityFocusFallsbackToWidgetKey; // A property key to store whether accessibility touch exploration gets handled // by the window and all touches pass through directly. AURA_EXPORT extern const WindowProperty<bool>* const kAccessibilityTouchExplorationPassThrough; // A property key to store whether activation on pointer event is enabled or // not. The default value is true, which means windows are activated when a // pointer down event occurs on them. AURA_EXPORT extern const WindowProperty<bool>* const kActivateOnPointerKey; // A property key to store always-on-top flag. AURA_EXPORT extern const WindowProperty<bool>* const kAlwaysOnTopKey; // A property key to store whether animations are disabled for the window. Type // of value is an int. AURA_EXPORT extern const WindowProperty<bool>* const kAnimationsDisabledKey; // A property key to store the app icon, typically larger for shelf icons, etc. AURA_EXPORT extern const WindowProperty<gfx::ImageSkia*>* const kAppIconKey; // A property key to store the type of window that will be used to record // pointer metrics. See AppType in ash/public/cpp/app_types.h for more details. AURA_EXPORT extern const WindowProperty<int>* const kAppType; // A property key to store the avatar icon that will be displayed on the window // frame to indicate the owner of the window when needed. AURA_EXPORT extern const WindowProperty<gfx::ImageSkia*>* const kAvatarIconKey; // A property key to store if a window is a constrained window or not. AURA_EXPORT extern const WindowProperty<bool>* const kConstrainedWindowKey; // A property key to store if a window was created by a user gesture. AURA_EXPORT extern const WindowProperty<bool>* const kCreatedByUserGesture; // A property key to indicate that a window should show that it deserves // attention. AURA_EXPORT extern const WindowProperty<bool>* const kDrawAttentionKey; // A property key to store the focus client on the window. AURA_EXPORT extern const WindowProperty<FocusClient*>* const kFocusClientKey; // A bool property key to specify if the window has a icon set for displaying in // overivew mode. AURA_EXPORT extern const WindowProperty<bool>* const kHasOverviewIcon; // A property key to store the host window of a window. This lets // WebContentsViews find the windows that should constrain NPAPI plugins. AURA_EXPORT extern const WindowProperty<Window*>* const kHostWindowKey; // A property key to indicate that a window should be in immersive mode when the // window enters the fullscreen mode. The immersive fullscreen mode is slightly // different from the normal fullscreen mode by allowing the user to reveal the // top portion of the window through a touch / mouse gesture. AURA_EXPORT extern const WindowProperty<bool>* const kImmersiveFullscreenKey; // A property key to store the minimum size of the window. AURA_EXPORT extern const WindowProperty<gfx::Size*>* const kMinimumSize; // A property key to indicate that a window is being "mirrored" and its contents // should render regardless of its actual visibility state. AURA_EXPORT extern const WindowProperty<bool>* const kMirroringEnabledKey; // The modal parent of a child modal window. AURA_EXPORT extern const WindowProperty<Window*>* const kChildModalParentKey; // A property key to store the window modality. AURA_EXPORT extern const WindowProperty<ui::ModalType>* const kModalKey; // A property key to store the name of the window; mostly used for debugging. AURA_EXPORT extern const WindowProperty<std::string*>* const kNameKey; // A property key to store the preferred size of the window. AURA_EXPORT extern const WindowProperty<gfx::Size*>* const kPreferredSize; // A property key to store ui::WindowShowState for restoring a window from // minimized show state. // Used in Ash to remember the show state before the window was minimized. AURA_EXPORT extern const WindowProperty<ui::WindowShowState>* const kPreMinimizedShowStateKey; // A property key to store ui::WindowShowState for restoring a window from // fullscreen show state. // Used in Ash to remember the show state before the window was fullscreen. AURA_EXPORT extern const WindowProperty<ui::WindowShowState>* const kPreFullscreenShowStateKey; // A property key to store the resize behavior, which is a bitmask of the // ui::mojom::kResizeBehavior values. AURA_EXPORT extern const WindowProperty<int32_t>* const kResizeBehaviorKey; // A property key to store the restore bounds in screen coordinates for a // window. AURA_EXPORT extern const WindowProperty<gfx::Rect*>* const kRestoreBoundsKey; // A property key to store ui::WindowShowState for a window. // See ui/base/ui_base_types.h for its definition. AURA_EXPORT extern const WindowProperty<ui::WindowShowState>* const kShowStateKey; // A property key to store the title of the window; sometimes shown to users. AURA_EXPORT extern const WindowProperty<base::string16*>* const kTitleKey; // The inset of the topmost view in the client view from the top of the // non-client view. The topmost view depends on the window type. The topmost // view is the tab strip for tabbed browser windows, the toolbar for popups, // the web contents for app windows and varies for fullscreen windows. AURA_EXPORT extern const WindowProperty<int>* const kTopViewInset; // The color of the window header. AURA_EXPORT extern const WindowProperty<SkColor>* const kTopViewColor; // A property key to store the window icon, typically 16x16 for title bars. AURA_EXPORT extern const WindowProperty<gfx::ImageSkia*>* const kWindowIconKey; // Indicates the type of embedding within the given window. AURA_EXPORT extern const WindowProperty<WindowEmbedType>* const kEmbedType; // The corner radius of a window in DIPs. Currently only used for shadows. // Default is -1, meaning "unspecified". 0 Ensures corners are square. AURA_EXPORT extern const WindowProperty<int>* const kWindowCornerRadiusKey; AURA_EXPORT extern const WindowProperty<ui::mojom::WindowType>* const kWindowTypeKey; // Alphabetical sort. } // namespace client } // namespace aura #endif // UI_AURA_CLIENT_AURA_CONSTANTS_H_
41.130178
80
0.791253
[ "render" ]
0489f3dbfef1bd11983c685d3937bf70e47e0bba
1,381
h
C
include/engine/interface/PolygonContainer.h
smithy545/engine
1818a1acafdbc2550b10ef74a215aa41d94edf0f
[ "MIT" ]
null
null
null
include/engine/interface/PolygonContainer.h
smithy545/engine
1818a1acafdbc2550b10ef74a215aa41d94edf0f
[ "MIT" ]
null
null
null
include/engine/interface/PolygonContainer.h
smithy545/engine
1818a1acafdbc2550b10ef74a215aa41d94edf0f
[ "MIT" ]
null
null
null
// // Created by Philip Smith on 12/14/21. // #ifndef ENGINE_POLYGONCONTAINER_H #define ENGINE_POLYGONCONTAINER_H #include "ShapeComponent.h" #include <engine/InstanceList.h> #include <engine/interface/InterfaceEntity.h> #include <engine/sprite/ShapeSprite.h> #include <glm/gtx/transform.hpp> #include <vector> namespace engine { class PolygonContainer : public ShapeComponent, public InterfaceEntity { public: PTR(PolygonContainer); PolygonContainer(float x, float y, const std::vector<glm::vec2>& vertices, glm::vec3 color = glm::vec3(.5, .5, .5)) : ShapeElement(x, y, vertices), m_color(color) {} entt::entity register_with(entt::registry& registry) override { ShapeSprite sprite; for(auto v: verts) { sprite.vertices.emplace_back(v.x - c.x, v.y - c.y); sprite.colors.push_back(m_color); } for(auto i = 1; i < count - 1; i++) { sprite.indices.push_back(0); sprite.indices.push_back(i+1); sprite.indices.push_back(i); } if(m_entity == entt::null) m_entity = registry.create(); registry.emplace_or_replace<ShapeSprite>(m_entity, sprite); registry.patch<InstanceList>(m_entity, [&](auto &instance_list) { instance_list.add_instance(glm::translate(glm::mat4(1), glm::vec3(c.x, c.y, 0))); }); return m_entity; } private: glm::vec3 m_color; }; } // namespace engine #endif //ENGINE_POLYGONCONTAINER_H
27.078431
117
0.700941
[ "vector", "transform" ]
0491e5e8f43482b701872ceae08c617e9036ed1a
1,684
h
C
src/matrix.h
swartzy4/Craft-1
90ffb5ed978fdbba684cbfd957f05960819cd3c4
[ "MIT" ]
1
2020-04-24T02:23:24.000Z
2020-04-24T02:23:24.000Z
src/matrix.h
swartzy4/Craft-1
90ffb5ed978fdbba684cbfd957f05960819cd3c4
[ "MIT" ]
3
2020-02-26T03:21:19.000Z
2020-05-04T00:45:22.000Z
src/matrix.h
swartzy4/Craft-1
90ffb5ed978fdbba684cbfd957f05960819cd3c4
[ "MIT" ]
1
2020-02-25T21:01:25.000Z
2020-02-25T21:01:25.000Z
#ifndef _matrix_h_ #define _matrix_h_ void normalize(float *x, float *y, float *z); void mat_identity(float *matrix); void mat_translate(float *matrix, float dx, float dy, float dz); void mat_rotate(float *matrix, float x, float y, float z, float angle); void mat_vec_multiply(float *vector, float *a, float *b); void mat_multiply(float *matrix, float *a, float *b); void mat_apply(float *data, float *matrix, int count, int offset, int stride); void frustum_planes(float planes[6][4], int radius, float *matrix); void mat_frustum( float *matrix, float left, float right, float bottom, float top, float znear, float zfar); void mat_perspective( float *matrix, float fov, float aspect, float near, float far); void mat_ortho( float *matrix, float left, float right, float bottom, float top, float near, float far); void set_matrix_2d(float *matrix, int width, int height); void set_matrix_3d( float *matrix, int width, int height, float x, float y, float z, float rx, float ry, float fov, int ortho, int radius); ///Function: set_matrix_sun ///Traces to Requirement #3: "Sun for a reference light source" ///Params: matrix, window width, window height /// x, y, z = player positions /// rx, ry = player cursor positions /// fov, ortho, radius = field of view, orthogonal conditional, render radius, respectively /// time = (time_of_day() * 24) -6 void set_matrix_sun( float *matrix, int width, int height, float x, float y, float z, float rx, float ry, float fov, int ortho, int radius, int time); void set_matrix_item(float *matrix, int width, int height, int scale); #endif
39.162791
102
0.691211
[ "render", "vector" ]
049441cf5cd9275122262d762a3cc39f7c92522a
776
h
C
src/epub/ZYKit/ZYImageView.h
Willsen888/test
970ce8b49493932b7f57c4490b90c7147e8bc059
[ "Unlicense" ]
205
2015-01-05T00:47:31.000Z
2021-09-03T13:55:55.000Z
src/epub/ZYKit/ZYImageView.h
DeanCarter/epub-master
4fb97d5c64f4b99474faa9d7debb705d9372459f
[ "Unlicense" ]
2
2016-12-13T09:12:57.000Z
2017-10-30T04:04:01.000Z
src/epub/ZYKit/ZYImageView.h
DeanCarter/epub-master
4fb97d5c64f4b99474faa9d7debb705d9372459f
[ "Unlicense" ]
55
2015-01-10T10:24:08.000Z
2021-04-19T07:25:08.000Z
// // ZYImageView.h // scaffold // // Created by zzy on 5/10/12. // Copyright (c) 2012 __MyCompanyName__. All rights reserved. // #import <Foundation/Foundation.h> #import "ASIHTTPRequest.h" #import "CacheHelper.h" #import <QuartzCore/QuartzCore.h> @interface ZYImageView : UIView @property (nonatomic, retain) UIActivityIndicatorView *loader; @property (nonatomic, retain) NSString *requestUrl; @property (nonatomic, retain) NSURL *reqUrl; @property (nonatomic, retain) ASIHTTPRequest *request; @property (nonatomic, retain) UIImageView *img; @property (nonatomic, retain) UILabel *label; @property (nonatomic) int cornerRadius; @property (nonatomic) long expires; @property (nonatomic) float padding; -(void)load:(NSString *)url; -(void)render:(NSData *)data; @end
25.866667
62
0.747423
[ "render" ]
0b998c1ead6fabb6b425d0551f946a954c11e577
456
h
C
Ren/include/graphics/entityrenderer.h
hesom/Ren
7e02eacb50d548d6b5993bfae4bd6690a67ccdfd
[ "MIT" ]
null
null
null
Ren/include/graphics/entityrenderer.h
hesom/Ren
7e02eacb50d548d6b5993bfae4bd6690a67ccdfd
[ "MIT" ]
null
null
null
Ren/include/graphics/entityrenderer.h
hesom/Ren
7e02eacb50d548d6b5993bfae4bd6690a67ccdfd
[ "MIT" ]
null
null
null
#pragma once #include <memory> #include <string> #include "graphics/camera.h" #include "graphics/shaderprogram.h" namespace ren { class EntityRenderer { private: static std::string m_defaultShader; public: static auto setDefaultShader(const std::string& shader) -> void; static auto getDefaultShader() -> decltype(m_defaultShader); static auto render(const std::shared_ptr<Camera>& camera) -> void; }; }
25.333333
74
0.679825
[ "render" ]
0b9e84adf645993a1bc2c0597e163044775c032c
2,984
h
C
5.unordered_map_project/IntPair.h
imontese/accelerated-computer-science-fundamentals-specialization
722acccb63ebdf15a98d86d86c374953314c81b4
[ "MIT" ]
37
2020-01-04T08:27:54.000Z
2022-03-28T07:37:16.000Z
5.unordered_map_project/IntPair.h
imontese/accelerated-computer-science-fundamentals-specialization
722acccb63ebdf15a98d86d86c374953314c81b4
[ "MIT" ]
null
null
null
5.unordered_map_project/IntPair.h
imontese/accelerated-computer-science-fundamentals-specialization
722acccb63ebdf15a98d86d86c374953314c81b4
[ "MIT" ]
25
2020-04-29T18:37:01.000Z
2022-03-20T13:15:34.000Z
/** * @file IntPair.h * University of Illinois CS 400, MOOC 3, Week 1: Unordered Map * * @author Eric Huber * **/ #pragma once #include <functional> // for std::hash #include <utility> // for std::pair #include <string> // for std::string // We don't have to define an entire IntPair class ourselves since // C++ provides a templated pair type already. // We define IntPair as a type alias for convenience. using IntPair = std::pair<int, int>; // In the C++ standard library, classes like std::unordered_map and // std::unordered_set use the default hashing object std::hash internally. // However, std::hash doesn't natively support all possible types, // just a few of the primitive C++ types like int and std::string. // For more specific types, such as std::pair<int, int>, or for custom // classes you make yourself, you need to specify a hashing function. // Since std::hash is templated, we can add new cases for it using // what is called "template specialization". // In addition, custom class types made by users will also need to define // their equivalence relation function, operator==, for this to work. // Fortunately, std::pair<int,int> already gives us that automatically. // ------------------------------------------------------------------ // Reference: https://en.cppreference.com/w/cpp/utility/hash // We're adding more content to the standard namespace. // (This isn't normally something you should do casually.) namespace std { // A minor detail: std::hash is a struct, not a class. // In C++, a struct is very similar to a class, but it has public // members by default. // The "template <>" syntax indicates that we are specializing an existing // template for std::hash. template <> struct hash<IntPair> { // By overriding the () "operator", we can make an instance of a class // respond to similar syntax as if it were merely a function name. // The std::hash type is intended to work this way, as a "function object". // See also: https://en.cppreference.com/w/cpp/utility/functional // The () operator definition is where we will essentially define // our custom hashing function, and it returns the actual hash // as a std::size_t value (which is an integral type). std::size_t operator() (const IntPair& p) const { // We know that std::string has a well-defined hasher already, // so we'll turn our pair of ints into a unique string representation, // and then just hash that. We'll turn each integer into a string // and concatenate them with "##" in the middle, which should make // a unique string for any given pair of ints. std::string uniqueIntPairString = std::to_string(p.first) + "##" + std::to_string(p.second); // Get the default hashing function object for a std::string. std::hash<std::string> stringHasher; // Use the string hasher on our unique string. return stringHasher(uniqueIntPairString); } }; }
38.25641
98
0.682641
[ "object" ]
0bab73c18fca14604cccc59a6ca29e2c285d9ccc
13,214
h
C
lib/solver_interface/pyoptsolver/src/ipopt-interface/include/ipoptWrapper.h
paperstiger/trajOptLib
5e86a33537d89c0d1e35df7a436f9266fe817c49
[ "MIT" ]
6
2020-04-29T05:02:30.000Z
2021-04-19T15:42:35.000Z
lib/solver_interface/pyoptsolver/src/ipopt-interface/include/ipoptWrapper.h
paperstiger/trajOptLib
5e86a33537d89c0d1e35df7a436f9266fe817c49
[ "MIT" ]
null
null
null
lib/solver_interface/pyoptsolver/src/ipopt-interface/include/ipoptWrapper.h
paperstiger/trajOptLib
5e86a33537d89c0d1e35df7a436f9266fe817c49
[ "MIT" ]
null
null
null
/* * ipoptWrapper.h * Copyright (C) 2019 motion <motion@motion-MS-7971> * * Distributed under terms of the MIT license. */ #ifndef IPOPTWRAPPER_H #define IPOPTWRAPPER_H #include <coin/IpTNLP.hpp> #include <coin/IpIpoptApplication.hpp> #include <coin/IpSolveStatistics.hpp> #include "utils.h" #include <vector> #include <string> using std::string; extern bool VERBOSE; inline void print_array(const char msg[], const double *x, int n) { if(VERBOSE){ printf("%s ", msg); for(int i = 0; i < n; i++) printf("%f ", x[i]); printf("\n"); } } inline void print_array(const char msg[], const int *x, int n) { if(VERBOSE) { printf("%s ", msg); for(int i = 0; i < n; i++) printf("%d ", x[i]); printf("\n"); } } namespace Ipopt{ /** * @brief An adaptor that takes ProblemFun type and wrap into Ipopt * * Given an optimization probleme defined accordinG to SNOPT style, * implement a class that is suitable to be solved by Ipopt * */ class IpoptAdapter : public TNLP { public: IpoptAdapter(ProblemFun &prob_, const double *x0_) : prob(prob_), x0(x0_) { // at this stage, call to fill in rows, cols int n = prob.nx, m = prob.nf; F.resize(m); sol.resize(n); mu.resize(n); lmd.resize(m); c.resize(m); G.resize(prob.nG); rows.resize(prob.nG); cols.resize(prob.nG); cMapV Mx(x0_, n); if(prob.ipStyle) { #ifdef ENABLEIP if(prob_.grad) prob.evalJac(Mx, G, rows, cols, true); #endif } else{ prob.operator()(Mx, F, G, rows, cols, true, true); std::cout << "nG = " << prob.nG << std::endl; for(int i = 0; i < prob.nG; i++) if(rows(i) == 0) g_obj_index.push_back(i); std::cout << "nA = " << prob.Aval.size() << std::endl; for(int i = 0; i < prob.Aval.size(); i++) if(prob.Arow(i) == 0) a_obj_index.push_back(i); } } VX sol, lmd, mu, c; double cost; virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g, Index& nnz_h_lag, IndexStyleEnum& index_style) { n = prob.nx; m = prob.nf; nnz_jac_g = prob.nG + prob.Aval.size(); if(prob.hess_nnz > 0) nnz_h_lag = prob.hess_nnz; else nnz_h_lag = n * (n + 1) / 2; index_style = C_STYLE; return true; } virtual bool get_bounds_info(Index n, double* x_lower, double* x_upper, Index m, double* g_l, double* g_u) { for (uint c=0; c < prob.nx; ++c) { x_lower[c] = prob.xlb(c); x_upper[c] = prob.xub(c); } // specific bounds dependinG on equality and inequality constraints for (uint c=0; c<prob.nf; ++c) { g_l[c] = prob.lb(c); g_u[c] = prob.ub(c); } print_array("xlow", x_lower, prob.nx); print_array("xup", x_upper, prob.nx); print_array("cl", g_l, prob.nf); print_array("cu", g_u, prob.nf); return true; } virtual bool get_starting_point(Index n, bool init_x, double* x, bool init_z, double* z_L, double* z_U, Index m, bool init_lambda, double* lambda) { // Here, we assume we only have startinG values for x assert(init_x == true); assert(init_z == false); assert(init_lambda == false); MapV(x, prob.nx) = cMapV(x0, prob.nx); print_array("start x0", x, n); return true; } virtual void receive_new_x(const double *x, bool needg) { if(VERBOSE) std::cout << "receive new x\n"; cMapV Mx(x, prob.nx); VXl row(1), col(1); F.array() = 0; // prob(Mx, F, G, row, col, false, needg); prob.callg(Mx, F, G, row, col, false, needg); last_has_grad = needg; // plus the array for(int i = 0; i < prob.Aval.size(); i++) { F(prob.Arow(i)) += prob.Aval(i) * x[prob.Acol(i)]; } } virtual bool eval_f(Index n, const double* x, bool new_x, double& obj_value) { if(VERBOSE) std::cout << "evalf\n"; if(prob.ipStyle){ #ifdef ENABLEIP cMapV Mx(x, n); double value = prob.evalF(Mx); // printf("obj = %f\n", value); obj_value = value; #endif return true; } else{ if(new_x) receive_new_x(x, false); obj_value = F(0); print_array("x=", x, n); // printf("f = %f\n", obj_value); return true; } } virtual bool eval_grad_f(Index n, const double* x, bool new_x, double* grad_f) { if(VERBOSE) std::cout << "grad f\n"; if(prob.ipStyle) { #ifdef ENABLEIP cMapV Mx(x, n); MapV grad(grad_f, n); bool ret = prob.evalGrad(Mx, grad); print_array("grad=", grad_f, n); return ret; #endif return true; } else{ if(new_x) receive_new_x(x, false); for(int i = 0; i < n; i++) grad_f[i] = 0; for(auto &idx : g_obj_index) grad_f[cols[idx]] = G[idx]; for(auto &idx : a_obj_index) grad_f[prob.Acol[idx]] = prob.Aval[idx]; print_array("x=", x, n); print_array("grad=", grad_f, n); return true; } } virtual bool eval_g(Index n, const double* x, bool new_x, Index m, double* g) { if(VERBOSE) std::cout << "eval g\n"; if(prob.ipStyle) { #ifdef ENABLEIP cMapV Mx(x, n); MapV gfun(g, m); gfun.array() = 0; int ret = prob.evalG(Mx, gfun); for(int i = 0; i < prob.Aval.size(); i++) gfun(prob.Arow(i)) += prob.Aval(i) * x[prob.Acol(i)]; print_array("g=", g, m); #endif return true; } else{ if(new_x || !last_has_grad) receive_new_x(x, true); MapV(g, m) = F; print_array("g=", g, m); return true; } } virtual bool eval_jac_g(Index n, const double* x, bool new_x, Index m, Index nele_jac, Index* iRow, Index *jCol, double* values) { if(VERBOSE) std::cout << "jac g\n"; // defines the positions of the nonzero elements of the jacobian if (values == NULL) { // first copy nonlinear part for(int i = 0; i < prob.nG; i++) { iRow[i] = rows(i); jCol[i] = cols(i); } // then copy linear part, if any int nnz_a = prob.Aval.size(); for(int i = 0; i < nnz_a; i++) { iRow[prob.nG + i] = prob.Arow(i); jCol[prob.nG + i] = prob.Acol(i); } print_array("row=", iRow, prob.nG + prob.Arow.size()); print_array("col=", jCol, prob.nG + prob.Arow.size()); } else { if(prob.ipStyle){ #ifdef ENABLEIP cMapV Mx(x, n); MapV G(values, prob.nG); VXl row(0), col(0); int ret = prob.evalJac(Mx, G, row, col, false); MapV(values + prob.nG, prob.Aval.size()) = prob.Aval; print_array("jac=", values, prob.nG + prob.Aval.size()); #endif } else{ // only gets used if "jacobian_approximation finite-difference-values" is not set if(new_x || !last_has_grad) receive_new_x(x, true); // first copy nonlinear part MapV(values, prob.nG) = G; MapV(values + prob.nG, prob.Aval.size()) = prob.Aval; print_array("jac=", values, prob.nG + prob.Aval.size()); } } return true; } virtual bool eval_h(Index n, const Number* x, bool new_x, Number obj_factor, Index m, const Number *lambda, bool new_lambda, Index nele_hess, Index* iRow, Index* jCol, Number* values) { std::cout << "Entering hessian evaluation\n"; cMapV Mx(x, n); cMapV lmd(lambda, m); MapV G(values, nele_hess); MapVi row(iRow, nele_hess); MapVi col(jCol, nele_hess); #ifdef ENABLEIP if (values == NULL) { VXl hrows(nele_hess), hcols(nele_hess); prob.evalHess(Mx, obj_factor, lmd, G, hrows, hcols, true); row = hrows.cast<int>(); col = hcols.cast<int>(); } else { VXl hrows(0), hcols(0); prob.evalHess(Mx, obj_factor, lmd, G, hrows, hcols, false); } #endif return true; } /** This method is called when the algorithm is complete so the TNLP can * store/write the solution */ virtual void finalize_solution(SolverReturn status, Index n, const double* x, const double* z_L, const double* z_U, Index m, const double* g, const double* lambda, double obj_value, const IpoptData* ip_data, IpoptCalculatedQuantities* ip_cq){ sol = cMapV(x, n); lmd = cMapV(lambda, m); cost = obj_value; mu = cMapV(z_U, n) - cMapV(z_L, n); c = cMapV(g, m); } private: ProblemFun &prob; // this stores the vector const double *x0; // store the pointer to initial guess VX F, G; std::vector<int> a_obj_index, g_obj_index; // record which entries are in first row VXl rows, cols; bool last_has_grad = false; }; }; class IpoptConfig : public SolverConfig{ public: int print_level = 5; int print_frequency_iter = 10; int max_iter = 1000; string linear_solver = "mumps"; string hessian_approximation = "limited-memory"; string jacobian_approximation = "exact"; bool deriv_check_enabled = false; string derivative_test = "none"; double tol = 1e-6; double constr_viol_tol = 1e-6; double max_cpu_time = 1e6; void setup_app(Ipopt::IpoptApplication *app) { auto opt = app->Options(); opt->SetIntegerValue("print_level", print_level); opt->SetIntegerValue("print_frequency_iter", print_frequency_iter); opt->SetIntegerValue("max_iter", max_iter); opt->SetStringValue("linear_solver", linear_solver.c_str()); opt->SetStringValue("hessian_approximation", hessian_approximation.c_str()); opt->SetStringValue("jacobian_approximation", jacobian_approximation.c_str()); if(deriv_check_enabled) opt->SetStringValue("derivative_test", "first-order"); //derivative_test.c_str()); else opt->SetStringValue("derivative_test", "none"); opt->SetStringValue("print_timing_statistics", "no"); opt->SetStringValue("print_user_options", "no"); opt->SetNumericValue("tol", tol); opt->SetNumericValue("constr_viol_tol", constr_viol_tol); opt->SetNumericValue("max_cpu_time", max_cpu_time); for(auto &icfg : intOptions){ opt->SetIntegerValue(std::get<0>(icfg).c_str(), std::get<1>(icfg)); } for(auto &fcfg : floatOptions){ opt->SetNumericValue(std::get<0>(fcfg).c_str(), std::get<1>(fcfg)); } for(auto &scfg : pairStringOptions){ opt->SetStringValue(std::get<0>(scfg).c_str(), std::get<1>(scfg).c_str()); } } virtual void setMajorIter(int iter) { max_iter = iter; } virtual void setOptTol(double tol) { this->tol = tol; } virtual void setFeaTol(double tol) { constr_viol_tol = tol; } virtual int setPrintLevel(int lvl) { print_level = lvl; } virtual void enableDerivCheck(int lvl=3) { if(lvl <= 0) deriv_check_enabled = false; else deriv_check_enabled = true; } void setPrintFreq(int freq) { print_frequency_iter = freq; } void setLinearSolver(std::string &stri) { linear_solver = stri; } void enableExactHessian() { hessian_approximation = "exact"; } void enableFDJacobian() { jacobian_approximation = "finite-difference-values"; } }; optResult solve_problem(ProblemFun &prob, IpoptConfig &config, cRefV x0); class IpoptSolver { public: IpoptSolver(ProblemFun &prob_, IpoptConfig &config_) { prob = &prob_; config = &config_; if(!prob->grad) { config->enableFDJacobian(); } } optResult solve_rand() { VX x0 = prob->randomGenX(); return solve_problem(*prob, *config, x0); } optResult solve_guess(cRefV x0) { return solve_problem(*prob, *config, x0); } private: ProblemFun *prob; IpoptConfig *config; }; #endif /* !IPOPTWRAPPER_H */
30.16895
97
0.528682
[ "vector" ]
0bbb243eca6e51fada95b77f185128513158884e
3,772
c
C
main/duktape_spiffs.c
mozeal/duktape-esp32
ea5380e0cfa0e1442bf9acc90d0c0a728683284c
[ "Apache-2.0" ]
232
2016-11-24T07:14:15.000Z
2022-03-29T05:42:12.000Z
main/duktape_spiffs.c
mozeal/duktape-esp32
ea5380e0cfa0e1442bf9acc90d0c0a728683284c
[ "Apache-2.0" ]
36
2016-12-01T07:40:38.000Z
2020-11-09T03:04:22.000Z
main/duktape_spiffs.c
mozeal/duktape-esp32
ea5380e0cfa0e1442bf9acc90d0c0a728683284c
[ "Apache-2.0" ]
45
2016-12-27T00:06:19.000Z
2021-12-01T08:41:20.000Z
/** * SPIFFs documentation can be found at https://github.com/pellepl/spiffs */ #include "duktape_spiffs.h" #include <esp_log.h> #include <fcntl.h> #include <errno.h> #include <duktape.h> #include <dirent.h> #include "sdkconfig.h" #include "logging.h" LOG_TAG("duktape_spiffs"); #define DUKTAPE_SPIFFS_MOUNTPOINT "/spiffs" static const char *typeToString(char type) { switch(type) { case DT_DIR: return "Dir"; case DT_REG: return "File"; default: return "Unknown"; } } // typeToString /** * Create a JS array on the value stack which contains objects. Each * object represents one file entry. Each object contains: * { * name: <file name> * size: <file size> * } */ void esp32_duktape_dump_spiffs_array(duk_context *ctx) { DIR* dir = opendir(DUKTAPE_SPIFFS_MOUNTPOINT); struct dirent *dirEnt; const char rootPath[] = "/"; LOGD(">> esp32_duktape_dump_spiffs_array: rootPath=\"%s\"", rootPath); duk_push_array(ctx); if (dir == NULL) { LOGD("Unable to open %s dir", rootPath); } else { int arrayIndex = 0; while((dirEnt = readdir(dir))) { int len = strlen((char *)dirEnt->d_name); // Skip files that end with "/." if (len>=2 && strcmp((char *)(dirEnt->d_name + len -2), "/.") == 0) { continue; } duk_push_object(ctx); duk_push_string(ctx, (char *)dirEnt->d_name); duk_put_prop_string(ctx, -2, "name"); duk_put_prop_index(ctx, -2, arrayIndex); arrayIndex++; } closedir(dir); } LOGD("<< esp32_duktape_dump_spiffs_array"); return; } // esp32_duktape_dump_spiffs_json void esp32_duktape_dump_spiffs() { DIR* dir = opendir(DUKTAPE_SPIFFS_MOUNTPOINT); struct dirent *dirEnt; const char rootPath[] = "/"; LOGD(">> dump_fs: %s", rootPath); if (dir == NULL) { LOGD("Unable to open %s dir", rootPath); } else { while ((dirEnt = readdir(dir))) { LOGD("name=%s, id=%x, type=%s", dirEnt->d_name, dirEnt->d_ino, typeToString(dirEnt->d_type)); } closedir(dir); } LOGD("<< dump_fs"); } // dump_fs /** * Mount & register virtual filesystem. */ void esp32_duktape_spiffs_mount() { esp_vfs_spiffs_conf_t conf = { .base_path = DUKTAPE_SPIFFS_MOUNTPOINT, .partition_label = NULL, .max_files = 5, .format_if_mount_failed = false }; esp_err_t ret = esp_vfs_spiffs_register(&conf); if (ret != ESP_OK) { if (ret == ESP_FAIL) { LOGE("Failed to mount or format filesystem"); } else if (ret == ESP_ERR_NOT_FOUND) { LOGE("Failed to find SPIFFS partition"); } else { LOGE("Failed to initialize SPIFFS (%d)", ret); } return; } size_t total = 0, used = 0; ret = esp_spiffs_info(NULL, &total, &used); if (ret != ESP_OK) { LOGE("Failed to get SPIFFS partition information"); } else { LOGI("Partition size: total: %d, used: %d", total, used); } } // esp32_duktape_spiffs_mount /* static int spiffsErrMap(spiffs *fs) { int errorCode = SPIFFS_errno(fs); switch (errorCode) { case SPIFFS_ERR_FULL: return ENOSPC; case SPIFFS_ERR_NOT_FOUND: return ENOENT; case SPIFFS_ERR_FILE_EXISTS: return EEXIST; case SPIFFS_ERR_NOT_A_FILE: return EBADF; case SPIFFS_ERR_OUT_OF_FILE_DESCS: return ENFILE; default: { ESP_LOGE(tag, "We received SPIFFs error code %d but didn't know how to map to an errno", errorCode); return ENOMSG; } } } // spiffsErrMap */
26.751773
112
0.587222
[ "object" ]
0bc5826744eb6e6d2bf47efb8953e6a9b76f84da
5,666
h
C
include/nuttx/lcd/ssd1351.h
eenurkka/incubator-nuttx
5c3d6bba6d9ec5015896c3019cd2064696373210
[ "Apache-2.0" ]
1,006
2019-12-17T23:45:41.000Z
2022-03-31T19:42:44.000Z
include/nuttx/lcd/ssd1351.h
eenurkka/incubator-nuttx
5c3d6bba6d9ec5015896c3019cd2064696373210
[ "Apache-2.0" ]
2,661
2019-12-21T15:16:09.000Z
2022-03-31T22:30:04.000Z
include/nuttx/lcd/ssd1351.h
eenurkka/incubator-nuttx
5c3d6bba6d9ec5015896c3019cd2064696373210
[ "Apache-2.0" ]
613
2019-12-21T10:17:37.000Z
2022-03-28T09:42:20.000Z
/**************************************************************************** * include/nuttx/lcd/ssd1351.h * * 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 __INCLUDE_NUTTX_LCD_SSD1351_H #define __INCLUDE_NUTTX_LCD_SSD1351_H /**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> #ifdef CONFIG_LCD_SSD1351 /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ /* SSD1351 configuration settings: * CONFIG_SSD1351_PARALLEL8BIT - 8-bit parallel interface * CONFIG_SSD1351_SPI3WIRE - 3-wire SPI interface * CONFIG_SSD1351_SPI4WIRE - 4-wire SPI interface * CONFIG_SSD1351_SPIMODE - SPI mode * CONFIG_SSD1351_SPIFREQ - SPI frequency * CONFIG_SSD1351_NINTERFACES - number of physical devices supported * CONFIG_SSD1351_XRES - X resolution * CONFIG_SSD1351_YRES - Y resolution * CONFIG_SSD1351_MIRRORX - mirror along the X axis * CONFIG_SSD1351_MIRRORY - mirror along the Y axis * CONFIG_SSD1351_INVERT - invert the display * CONFIG_SSD1351_VDDEXT - external VDD * CONFIG_SSD1351_TRST - reset period * CONFIG_SSD1351_TPRECHG1 - first pre-charge period * CONFIG_SSD1351_PERFENHANCE - enhance display performance * CONFIG_SSD1351_CLKDIV - clock divider * CONFIG_SSD1351_OSCFREQ - oscillator frequency * CONFIG_SSD1351_TPRECHG2 - second pre-charge period * CONFIG_SSD1351_VPRECHG - pre-charge voltage level * CONFIG_SSD1351_VCOMH - COM deselect voltage level * CONFIG_SSD1351_CONTRASTA - color A contrast * CONFIG_SSD1351_CONTRASTB - color B contrast * CONFIG_SSD1351_CONTRASTC - color C contrast * CONFIG_SSD1351_MSTRCONTRAST - master contrast ratio * * Required LCD driver settings: * CONFIG_LCD_SSD1351 - enables SSD1351 support * CONFIG_LCD_MAXPOWER - maximum power, must be 1 * * Additional LCD driver settings: * CONFIG_LCD_LANDSCAPE - landscape * CONFIG_LCD_RLANDSCAPE - reverse landscape * CONFIG_LCD_PORTRAIT - portrait * CONFIG_LCD_RPORTRAIT - reverse portrait * * Required SPI driver settings: * CONFIG_SPI - enables support for SPI * CONFIG_SPI_CMDDATA - enables support for cmd/data selection * (if using 4-wire SPI) * * NX settings that must be undefined: * CONFIG_NX_DISABLE_16BPP - disables 16 bpp support */ /**************************************************************************** * Public Types ****************************************************************************/ #ifdef CONFIG_SSD1351_PARALLEL8BIT struct ssd1351_lcd_s { void (*cmd)(FAR struct ssd1351_lcd_s *lcd, uint8_t cmd); #ifndef CONFIG_LCD_NOGETRUN uint8_t (*read)(FAR struct ssd1351_lcd_s *lcd); #endif void (*write)(FAR struct ssd1351_lcd_s *lcd, uint8_t data); }; #elif defined(CONFIG_SSD1351_SPI3WIRE) || defined(CONFIG_SSD1351_SPI4WIRE) struct spi_dev_s; #endif /**************************************************************************** * Public Function Prototypes ****************************************************************************/ #ifdef __cplusplus extern "C" { #endif /**************************************************************************** * Name: ssd1351_initialize * * Description: * Initialize the video hardware. The initial state of the device * is fully initialized, display memory cleared, and ready to use, * but with the power setting at 0 (full off == sleep mode). * * Input Parameters: * lcd - A reference to the platform-specific interface. * spi - A reference to the SPI driver instance. * devno - A value in the range of 0 through CONFIG_SSD1351_NINTERFACES-1. * This allows support for multiple devices. * * Returned Value: * On success, this function returns a reference to the LCD object for the * specified device. NULL is returned on failure. * ****************************************************************************/ #ifdef CONFIG_SSD1351_PARALLEL8BIT FAR struct lcd_dev_s *ssd1351_initialize(FAR struct ssd1351_lcd_s *lcd, unsigned int devno); #elif defined(CONFIG_SSD1351_SPI3WIRE) || defined(CONFIG_SSD1351_SPI4WIRE) FAR struct lcd_dev_s *ssd1351_initialize(FAR struct spi_dev_s *spi, unsigned int devno); #endif #ifdef __cplusplus } #endif #endif /* CONFIG_LCD_SSD1351 */ #endif /* __INCLUDE_NUTTX_LCD_SSD1351_H */
39.622378
78
0.594599
[ "object" ]
0bc6e28f4775efd3e379a01d5d977ce06109661a
6,307
h
C
patches/llvm/src/include/llvm/Analysis/LoopNestingTree.h
systems-nuts/popcorn-compiler-alpine
5c225c7d3055db83dc654b6b5525c34bbdacded1
[ "Linux-OpenIB" ]
30
2019-04-07T14:58:31.000Z
2021-05-24T19:07:20.000Z
patches/llvm/src/include/llvm/Analysis/LoopNestingTree.h
XRDevIEEE/popcorn-compiler
2cb2eccc0c75b5963d9fec26ad80a7b881316b1d
[ "Linux-OpenIB" ]
11
2018-07-24T19:31:26.000Z
2020-09-03T08:56:23.000Z
patches/llvm/src/include/llvm/Analysis/LoopNestingTree.h
XRDevIEEE/popcorn-compiler
2cb2eccc0c75b5963d9fec26ad80a7b881316b1d
[ "Linux-OpenIB" ]
17
2018-08-26T12:43:15.000Z
2022-03-18T12:08:40.000Z
/* * Loop-nesting tree for a loop. The root of a loop-nesting tree is the loop * header of the outermost loop. The children of any given node (including the * root) are the basic blocks contained within the loop and the loop headers of * nested loops. * * Note: we assume that the control-flow graphs are reducible * * Author: Rob Lyerly <rlyerly@vt.edu> * Date: 5/23/2016 */ #ifndef _LOOP_NESTING_TREE_H #define _LOOP_NESTING_TREE_H #include <list> #include <vector> #include <queue> #include "llvm/IR/BasicBlock.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Support/raw_ostream.h" class LoopNestingTree { private: /* * Tree node object. */ class Node { public: /** * Construct a node for a basic block. * @param _bb a basic block * @param _parent the parent of this node, i.e. the loop header of the * containing loop * @param _isLoopHeader is the basic block a loop header? */ Node(const llvm::BasicBlock *_bb, const Node *_parent, bool _isLoopHeader) : bb(_bb), parent(_parent), isLoopHeader(_isLoopHeader) {} /** * Add a child to the node. * @param child a child to add to the node */ void addChild(Node *child) { children.push_back(child); } const llvm::BasicBlock *bb; /* Basic block encapsulated by the node. */ const Node *parent; /* Parent node, i.e. header of containing loop. */ std::list<Node *> children; /* Regular child nodes in the tree. */ bool isLoopHeader; /* Is the basic block a loop header? */ }; unsigned _size; /* Number of nodes (i.e., basic blocks) in the tree. */ unsigned _depth; /* Number of nested loops in the tree. */ Node *_root; /* Root of the tree, i.e. loop header of outermost loop. */ /** * Print a node & its children. Recurses into nested loops. * @param O an output stream on which to print the tree * @param node a node to print * @param depth the current depth */ void print(llvm::raw_ostream &O, Node *node, unsigned depth) const; /** * Delete the node's children & the node itself. Recurses into nested loops. * @param node the node being deleted */ void deleteRecursive(Node *node); public: /** * Construct a loop-nesting tree from a strongly-connected component of the * control-flow graph. * @param SCC a strongly-connected component of the control-flow graph * @param LI analysis from the loop info pass */ LoopNestingTree(const std::vector<llvm::BasicBlock *> &SCC, const llvm::LoopInfo &LI); /** * Destroy a loop-nesting tree. */ ~LoopNestingTree() { deleteRecursive(this->_root); } /** * Return the size of the loop-nesting tree, that is the number of nodes in * the loop (and all nested loops). * @return the number of nodes in the tree */ unsigned size() const { return this->_size; } /** * Return the depth of the loop-nesting tree, that is the number of nested * loops. A value of one indicates that there are no nested loops. * @return the number of nested loops in the tree */ unsigned depth() const { return this->_depth; } /** * Print the tree. * @param O the output stream on which to print the tree */ void print(llvm::raw_ostream &O) const { print(O, this->_root, 0); } /* * Loop-node iterator object. Delivers loop nodes in breadth-first order. */ class loop_iterator { public: typedef loop_iterator self_type; typedef const llvm::BasicBlock *value_type; typedef value_type& reference; typedef value_type* pointer; typedef std::forward_iterator_tag iterator_category; self_type operator++(void); self_type operator++(int junk); reference operator*(void) { return cur->bb; } pointer operator->(void) { return &cur->bb; } bool operator==(const self_type& rhs) { return cur == rhs.cur; } bool operator!=(const self_type& rhs) { return cur != rhs.cur; } friend class LoopNestingTree; friend class child_iterator; private: Node *cur; std::queue<Node *> remaining; loop_iterator(Node *start) : cur(start) { addLoopHeaders(); } void addLoopHeaders(void); }; /* * Child iterator object. Traverses children of tree nodes. */ class child_iterator { public: typedef child_iterator self_type; typedef const llvm::BasicBlock *value_type; typedef value_type& reference; typedef value_type* pointer; typedef std::forward_iterator_tag iterator_category; enum location { BEGIN, END }; self_type operator++(void) { self_type me = *this; it.operator++(); return me; } self_type operator++(int junk) { it.operator++(junk); return *this; } reference operator*(void) { return (*it)->bb; } pointer operator->(void) { return &(*it)->bb; } bool operator==(const self_type& rhs) { return it == rhs.it; } bool operator!=(const self_type& rhs) { return it != rhs.it; } friend class LoopNestingTree; private: std::list<Node *>::const_iterator it; child_iterator(loop_iterator &parent, enum location loc); }; /** * Return an iterator for traversing all loop nodes (i.e., loop header basic * blocks) in the tree. Delivers nodes in a breadth-first ordering. * @return an iterator to traverse the loop nodes in the tree */ loop_iterator loop_begin() const { loop_iterator it(_root); return it; }; /** * Return an iterator marking the end of the loop nodes in the tree. * @return an iterator marking the end of the traversal */ loop_iterator loop_end() const { loop_iterator it(nullptr); return it; }; /** * Return an iterator for traversing the children of a loop node. * @param an iterator associated with a loop node * @return an iterator to traverse the children of a loop node */ child_iterator children_begin(loop_iterator &parent) const { child_iterator it(parent, child_iterator::BEGIN); return it; } /** * Return an iterator marking the end of the children of a loop node. * @param an iterator associated with a loop node * @return an iterator marking the end of the traversal */ child_iterator children_end(loop_iterator &parent) const { child_iterator it(parent, child_iterator::END); return it; } }; #endif /* _LOOP_NESTING_TREE_H */
32.848958
79
0.67433
[ "object", "vector" ]
0bcc1ee8c915e6820d06d73e6ad7be9f82025a1f
2,063
h
C
src/ArduinoComponents/Components/RF/RF_Interface.h
gilmaimon/ArduinoComponents
f676639e1f6eb56ba3752f9ed6749b37eba4b5d6
[ "MIT" ]
17
2018-10-06T16:10:21.000Z
2021-07-08T16:16:21.000Z
src/ArduinoComponents/Components/RF/RF_Interface.h
aelmendorf/ArduinoComponents
f676639e1f6eb56ba3752f9ed6749b37eba4b5d6
[ "MIT" ]
10
2018-10-06T18:58:50.000Z
2020-08-30T19:57:53.000Z
src/ArduinoComponents/Components/RF/RF_Interface.h
aelmendorf/ArduinoComponents
f676639e1f6eb56ba3752f9ed6749b37eba4b5d6
[ "MIT" ]
1
2021-04-07T04:39:40.000Z
2021-04-07T04:39:40.000Z
#ifdef EXPERIMENTAL_RF #ifndef RFINTERFACE_H_ #define RFINTERFACE_H_ #include <stdint.h> #include <string.h> #include "../../Helpers/Function.h" #include "../../Helpers/Vector.h" #include "../Component.h" namespace components { struct Message { Message() : Message("") {} Message(const char* str) { len = strlen(str); memcpy(data, (uint8_t*) str, len); } static const uint16_t MAX_LENGTH = 128; uint8_t data[MAX_LENGTH]; uint16_t len; }; /* rf.onMessage([](const Message& msg){ return true; // msg was handled and should not be dispatched any more }); rf.onMessage(ContentFilter("ABCDEFGHIJKLMNOP"), [](const Message& msg){ return false; // keep sending this msg to handlers }); */ enum Status : bool { Status_Success = false, Status_Failure = true }; typedef Function<bool(const Message&)> FilterFunction; typedef Function<bool(const Message&)> HandlerFunction; class RfInterface : public Component { public: RfInterface(Ref<Component> parent) : Component(parent) {} virtual bool send(Message& msg) = 0; void onMessage(FilterFunction filter, HandlerFunction handler) { _handlers.push(FilterHandlerPair{ filter, handler }); } void onMessage(HandlerFunction handler) { _handlers.push(FilterHandlerPair{ [](const Message&){ return true; }, handler }); } virtual ~RfInterface() {} protected: void disptachMessageToHandlers(const Message& msg) { for(unsigned i = 0; i < _handlers.size(); i++) { if(_handlers.get(i).filter(msg)) { bool handled = _handlers.get(i).handler(msg); if(handled) return; } } } private: struct FilterHandlerPair { FilterHandlerPair( FilterFunction filterFunction = [](const Message&){ return false; }, HandlerFunction handlerFunction = [](const Message&){ return false; } ) : filter(filterFunction), handler(handlerFunction) {} FilterFunction filter; HandlerFunction handler; }; Vector<FilterHandlerPair> _handlers; }; }; #endif //RFINTERFACE_H_ #endif //EXPERIMENTAL_RF
22.67033
73
0.681532
[ "vector" ]
0bd24304795afdb0a2059bbb226bc0d48afb5538
4,557
c
C
src/seamule-sdk.c
pablo-co/seamule-sdk-c
a70777bd205d7008d6220c1d85f81ea705241682
[ "MIT" ]
null
null
null
src/seamule-sdk.c
pablo-co/seamule-sdk-c
a70777bd205d7008d6220c1d85f81ea705241682
[ "MIT" ]
null
null
null
src/seamule-sdk.c
pablo-co/seamule-sdk-c
a70777bd205d7008d6220c1d85f81ea705241682
[ "MIT" ]
null
null
null
/* * Copyright (c) 2015-2015 Pablo Cárdenas <pcardenasoliveros@gmail.com> * * SeaMule is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See LICENSE for details. */ #include <jansson.h> #include <string.h> #include "seamule-sdk.h" struct seamule_t *seamule_easy_init() { SEAMULE_CODE result = SEAMULE_OK; struct seamule_t *data; result = seamule_open(&data); if (result) { fprintf(stderr, "Error: seamule_open failed\n"); return NULL; } return data; } SEAMULE_CODE seamule_easy_cleanup(struct seamule_t *seamule) { close_seamule(seamule); return SEAMULE_OK; } SEAMULE_CODE seamule_open(struct seamule_t **seamule) { SEAMULE_CODE result = SEAMULE_OK; struct seamule_t *data; /* Very simple start-up: alloc the struct, init it with zeroes and return */ data = calloc(1, sizeof(struct seamule_t)); if (!data) { fprintf(stderr, "Error: calloc of seamule_t failed\n"); return SEAMULE_OUT_OF_MEMORY; } init_seamule(data); seamule_easy_setopt(data, SEAMULEOPT_PROTOCOL, SEAMULE_API_PROTOCOL); seamule_easy_setopt(data, SEAMULEOPT_DOMAIN, SEAMULE_API_DOMAIN); seamule_easy_setopt(data, SEAMULEOPT_PATH, SEAMULE_API_PATH); *seamule = data; return result; } SEAMULE_CODE seamule_easy_setopt(struct seamule_t *data, SEAMULE_OPTION option, ...) { va_list arg; SEAMULE_CODE result; if (!data) { return SEAMULE_CANCELLED; } va_start(arg, option); result = seamule_setopt(data, option, arg); va_end(arg); return result; } SEAMULE_CODE seamule_setopt(struct seamule_t *data, SEAMULE_OPTION option, va_list param) { SEAMULE_CODE result = SEAMULE_OK; switch (option) { case SEAMULEOPT_PROTOCOL: if (data->protocol_alloc) { free(data->protocol); data->protocol = NULL; } data->protocol_alloc = 1; result = set_str_opt(&data->protocol, va_arg(param, char *)); break; case SEAMULEOPT_DOMAIN: if (data->domain_alloc) { free(data->domain); data->domain = NULL; } data->domain_alloc = 1; result = set_str_opt(&data->domain, va_arg(param, char *)); break; case SEAMULEOPT_PATH: if (data->path_alloc) { free(data->path); data->path = NULL; } data->path_alloc = 1; result = set_str_opt(&data->path, va_arg(param, char *)); break; case SEAMULEOPT_BUFFER_SIZE: data->buffer_size = va_arg(param, long); break; } return result; } int seamule_easy_main(struct seamule_t *seamule, int argc, char *argv[], seamule_process *process) { json_t *jobs = NULL; json_t *first_job = NULL; json_t *payload = NULL; json_t *id = NULL; json_t *result = NULL; json_error_t error; jobs = request_jobs(seamule); if (!jobs) { fprintf(stderr, "error: on line %d: %s\n", error.line, error.text); goto error; } if (!json_is_array(jobs)) { fprintf(stderr, "error: root is not an array\n"); goto error; } if (json_array_size(jobs) == 0) { first_job = create_job(seamule); } else { first_job = json_array_get(jobs, 0); } if (!first_job) { fprintf(stderr, "error: root is empty\n"); goto error; } if (!json_is_object(first_job)) { fprintf(stderr, "error: job %d is not an object\n", 1); goto error; } id = json_object_get(first_job, "id"); if (!json_is_string(id)) { fprintf(stderr, "error: job id is not a string\n"); goto error; } payload = json_object_get(first_job, "payload"); result = process(payload); if (result) { send_result(seamule, json_string_value(id), result); json_decref(result); } json_decref(id); json_decref(jobs); json_decref(first_job); json_decref(payload); return 0; error: if (id) json_decref(id); if (jobs) json_decref(jobs); if (first_job) json_decref(first_job); return 1; } SEAMULE_CODE set_str_opt(char **char_pointer, char *string) { if (string) { string = strdup(string); if (!string) { return SEAMULE_OUT_OF_MEMORY; } *char_pointer = string; } return SEAMULE_OK; }
25.176796
100
0.602809
[ "object" ]
0402b74a8042890f5999fdeecb01048551f3608d
2,417
h
C
C/source/base/c_mempool.h
jesson3264/OpenCC
41a80bb102dde718b13f8b363515278c2292fdf9
[ "MIT" ]
null
null
null
C/source/base/c_mempool.h
jesson3264/OpenCC
41a80bb102dde718b13f8b363515278c2292fdf9
[ "MIT" ]
null
null
null
C/source/base/c_mempool.h
jesson3264/OpenCC
41a80bb102dde718b13f8b363515278c2292fdf9
[ "MIT" ]
null
null
null
/* * The MIT License (MIT) * * Copyright (c) 2020 邓俊兴 (Deng Junxing) * Email : jesson3264@163.com * * 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. */ #ifndef MEMORY_C_MEMPOOL_H #define MEMORY_C_MEMPOOL_H #include <stdint.h> #include <stddef.h> #include "scl_double_list.h" #include "c_memcomm.h" /** 后续可使用内存创建函数 */ #define MALLOC malloc #define FREE free enum { MAX_BYTES = 128 }; enum { NFREELISTS = MAX_BYTES/ALIGN }; /** * @brief 存储已经分配的块内存链表 * */ typedef struct AllocatedList { d_node_t list; char* addr; }AllocatedList; typedef struct CMemPool { union obj* free_list[NFREELISTS]; char* start_free; char* end_free; size_t heap_size; /** 记录分配的内存块 */ AllocatedList alloc_list; }CMemPool; /** * @brief Create a Mempool object * * @param memsize * @return CMemPool* */ CMemPool* CreateMempool(size_t memsize); /** * @brief * * @param mp */ void DestroyMempool(CMemPool* mp); /** * @brief * @return SCL_SUCCESS success, other failured. * */ void* Allocate(CMemPool* mp, size_t n); /** TODO: 需再 要分配的n 前面加上一个头部,返回的时候,只返回头部后面的数据 */ void DeAllocate(CMemPool* mp, void* p, size_t n); /** FOR DEBUG. */ void ShowMempoolInfo(CMemPool* mp); void* refill(CMemPool* mp, size_t n); char* ChunkAlloc(CMemPool* mp, size_t size, int* nobjs); #endif
24.917526
83
0.693008
[ "object" ]
040516ff710fae80cb97abd980403ac72025b6a3
1,791
h
C
test/sandbox/Benchmarks/Kernel/Divergence/legacy/BlockProcessor.h
cselab/CubismNova
cbd6876ae9b5864f82f3470b564132c92e0f2e00
[ "BSD-2-Clause" ]
9
2020-01-27T01:17:19.000Z
2022-02-26T12:20:17.000Z
test/sandbox/Benchmarks/Kernel/Divergence/legacy/BlockProcessor.h
cselab/CubismNova
cbd6876ae9b5864f82f3470b564132c92e0f2e00
[ "BSD-2-Clause" ]
null
null
null
test/sandbox/Benchmarks/Kernel/Divergence/legacy/BlockProcessor.h
cselab/CubismNova
cbd6876ae9b5864f82f3470b564132c92e0f2e00
[ "BSD-2-Clause" ]
1
2021-04-01T07:48:39.000Z
2021-04-01T07:48:39.000Z
// File : BlockProcessor.h // Date : Fri 01 Apr 2016 05:52:01 PM CEST // Author : Fabian Wermelinger // Description: Process all blocks // Copyright 2016 ETH Zurich. All Rights Reserved. #ifndef BLOCKPROCESSORMPI_H_IKFSZWUJ #define BLOCKPROCESSORMPI_H_IKFSZWUJ #include <vector> #ifdef _OPENMP #include <omp.h> #endif /* _OPENMP */ #include "Types.h" #include <iostream> using namespace std; template <typename TLab, typename Operator, typename TGrid> inline void BlockProcessor(Operator rhs, TGrid &grid, const Real t = 0, const bool record = false) { vector<BlockInfo> avail0; #ifdef _OPENMP const int nthreads = omp_get_max_threads(); #else const int nthreads = 1; #endif /* _OPENMP */ TLab * labs = new TLab[nthreads]; // Setup the static stencil information for this kernel (operator) const int ss[3] = {rhs.stencil.sx, rhs.stencil.sy, rhs.stencil.sz}; const int se[3] = {rhs.stencil.ex, rhs.stencil.ey, rhs.stencil.ez}; for (int i = 0; i < nthreads; ++i) labs[i].prepare(grid, ss, se, rhs.stencil.tensorial); // process inner blocks avail0 = grid.getBlocksInfo(); BlockInfo * ary0 = &avail0.front(); #pragma omp parallel num_threads(nthreads) { #ifdef _OPENMP int tid = omp_get_thread_num(); #else int tid = 0; #endif /* _OPENMP */ TLab& mylab = labs[tid]; #pragma omp for schedule(dynamic,1) for (size_t i = 0; i < avail0.size(); i++) { mylab.load(ary0[i], t); rhs(mylab, ary0[i], *(FluidBlock*)ary0[i].ptrBlock); } } // clean up if(labs!=NULL) { delete[] labs; labs=NULL; } } #endif /* BLOCKPROCESSORMPI_H_IKFSZWUJ */
25.585714
71
0.61139
[ "vector" ]
040f584cff9ec3ba55053ee778a79161ff1e5dbc
3,927
h
C
hackathon/Changhao/cross_structure_detection_3D/neuron_tools.h
zzhmark/vaa3d_tools
3ca418add85a59ac7e805d55a600b78330d7e53d
[ "MIT" ]
1
2021-12-27T19:14:03.000Z
2021-12-27T19:14:03.000Z
hackathon/Changhao/cross_structure_detection_3D/neuron_tools.h
zzhmark/vaa3d_tools
3ca418add85a59ac7e805d55a600b78330d7e53d
[ "MIT" ]
null
null
null
hackathon/Changhao/cross_structure_detection_3D/neuron_tools.h
zzhmark/vaa3d_tools
3ca418add85a59ac7e805d55a600b78330d7e53d
[ "MIT" ]
null
null
null
#ifndef NEURON_TOOLS_H #define NEURON_TOOLS_H #include "./../../../v3d_external/released_plugins_more/v3d_plugins/pruning_swc/my_surf_objs.h" #include "basic_surf_objs.h" #include "v3d_interface.h" vector<MyMarker*> NeuronTree2vectorofMyMarker(NeuronTree nt); NeuronTree vectorofMyMarker2NeuronTree ( vector<MyMarker*> swc ); LocationSimple MyMarker2LocationSimple(MyMarker* marker); LocationSimple MyMarker2LocationSimple(MyMarker marker); MyMarker* LocationSimple2MyMarkerP(LocationSimple s); MyMarker LocationSimple2MyMarker(LocationSimple s); void merge_two_neuron(vector<MyMarker*> & swc ,NeuronTree nt); void merge_two_neuron(vector<MyMarker*> & swc_main ,vector<MyMarker*> & swc); void merge_two_neuron(NeuronTree nt1 ,NeuronTree nt2, NeuronTree &nt_merged); NeuronTree merge_two_neuron(NeuronTree swc1 , NeuronTree nt); QList <ImageMarker> LandmarkListQList_ImageMarker(LandmarkList marker_l); vector<MyMarker*> readSWC_file1(string swc_file); NeuronTree readSWC_file1(const QString& filename); bool writeSWC_file1(const QString& filename, const NeuronTree& nt); bool saveSWC_file1(string swc_file, vector<MyMarker*> & outmarkers); LandmarkList QList_ImageMarker2LandmarkList(QList <ImageMarker> markers); LandmarkList Readdata_from_TMI_result(QString img_name); LandmarkList Match_leaf_tip(LandmarkList leaf_swc,LandmarkList real_tip,double threshold=5,bool ignore_z=false); LandmarkList FromTreeGetBranch(NeuronTree nt); LandmarkList getCalcuMarker(LandmarkList markerFromMarkerFile); void getCalcuMarker(LandmarkList markerFromMarkerFile, LandmarkList &calcuMarker); void getCalcuMarker(LandmarkList markerFromMarkerFile, vector<MyMarker> &calcuMarker); void displayMarker(V3DPluginCallback2 &callback, v3dhandle windows, LandmarkList calcuMarker); LandmarkList mergeLandmark(LandmarkList a, LandmarkList b); vector<LocationSimple> LandmarkList2vectorLocationSimple(LandmarkList a); LandmarkList vectorLocationSimple2LandmarkList(vector<LocationSimple> a); LandmarkList calibrate_tipPoints(V3DPluginCallback2 &callback, LandmarkList original_tipPoint, int raidus3D, int bkg_thres); bool saveSoma(QString path,LocationSimple SOMA); void ComputemaskImage(NeuronTree neurons,unsigned char* pImMask,V3DLONG sx,V3DLONG sy,V3DLONG sz, double margin); void ComputemaskImage(NeuronTree neurons,unsigned char* pImMask,V3DLONG sx,V3DLONG sy,V3DLONG sz, double margin, LandmarkList missedBranchPoint); void ComputemaskImage(V3DPluginCallback2 &callback, NeuronTree neurons,unsigned char* pImMask,V3DLONG sx,V3DLONG sy,V3DLONG sz, double margin, LandmarkList missedBranchPoint); QHash<V3DLONG, V3DLONG> NeuronNextPn(const NeuronTree &neurons); void Erosion(unsigned char* image, unsigned char* res, int nHeight, int nWidth); void Dilation(unsigned char* image, unsigned char* res, int nHeight, int nWidth); void Closeoperations(unsigned char* image, unsigned char* res, int nHeight, int nWidth); void Openoperations(unsigned char* image, unsigned char* res, int nHeight, int nWidth); void gaussian_filter(unsigned char * data1d, V3DLONG *in_sz, unsigned int Wx, unsigned int Wy, unsigned int Wz, unsigned int c, double sigma, float * &outimg); double dist(MyMarker a, LocationSimple b); double dist(LocationSimple a, MyMarker b); double dist(LocationSimple a, LocationSimple b); double dist(NeuronSWC a, LocationSimple b); void nt_processing_for_mask(NeuronTree nt, LandmarkList pointSet, NeuronTree &nt_new, double margin); bool saveSWC_file_app2(string swc_file, vector<MyMarker*> & outmarkers, list<string> & infostring); QStringList importFileList_addnumbersort(const QString & curFilePath, int method_code); #endif // NEURON_TOOLS_H
59.5
175
0.772345
[ "vector" ]
042668639c27d8ad1f628452e25362de3dc29d12
990
h
C
DESIRE-Engine/src/Engine/Script/NativeScriptComponent.h
nyaki-HUN/DESIRE
dd579bffa77bc6999266c8011bc389bb96dee01d
[ "BSD-2-Clause" ]
1
2020-10-04T18:50:01.000Z
2020-10-04T18:50:01.000Z
DESIRE-Engine/src/Engine/Script/NativeScriptComponent.h
nyaki-HUN/DESIRE
dd579bffa77bc6999266c8011bc389bb96dee01d
[ "BSD-2-Clause" ]
null
null
null
DESIRE-Engine/src/Engine/Script/NativeScriptComponent.h
nyaki-HUN/DESIRE
dd579bffa77bc6999266c8011bc389bb96dee01d
[ "BSD-2-Clause" ]
1
2018-09-18T08:03:33.000Z
2018-09-18T08:03:33.000Z
#pragma once #include "Engine/Script/IScript.h" #include "Engine/Script/ScriptComponent.h" #include "Engine/Script/ScriptSystem.h" class NativeScriptComponent : public ScriptComponent { public: NativeScriptComponent(GameObject& object, ScriptSystem::ScriptFactory::Func_t scriptFactoryFunc); ~NativeScriptComponent() override; void CallByType(EBuiltinFuncType funcType) override; private: bool PrepareFunctionCall(const String& functionName) override; void ExecuteFunctionCall() override; bool AddFunctionCallArg(int32_t arg) override; bool AddFunctionCallArg(float arg) override; bool AddFunctionCallArg(double arg) override; bool AddFunctionCallArg(bool arg) override; bool AddFunctionCallArg(void* pArg) override; bool AddFunctionCallArg(const String& string) override; std::unique_ptr<IScript> m_spScript; std::function<void(std::array<IScript::Arg, 6>)> m_functionToCall = nullptr; std::array<IScript::Arg, 6> m_functionArgs; size_t m_numFunctionCallArgs = 0; };
30.9375
98
0.80404
[ "object" ]
04266f306c4bc43605cf39f5e735a6fe585abe14
1,940
h
C
observationSim/Spacecraft.h
fermi-lat/observationSim
102bfe8b0fefb40900b06845f238d7b418c1a819
[ "BSD-3-Clause" ]
null
null
null
observationSim/Spacecraft.h
fermi-lat/observationSim
102bfe8b0fefb40900b06845f238d7b418c1a819
[ "BSD-3-Clause" ]
2
2019-03-22T07:44:40.000Z
2020-12-08T17:55:47.000Z
observationSim/Spacecraft.h
fermi-lat/observationSim
102bfe8b0fefb40900b06845f238d7b418c1a819
[ "BSD-3-Clause" ]
null
null
null
/** * @file Spacecraft.h * @brief Declaration of Spacecraft base class. * @author J. Chiang * * $Header: /nfs/slac/g/glast/ground/cvs/ScienceTools-scons/observationSim/observationSim/Spacecraft.h,v 1.8 2006/11/06 23:59:58 jchiang Exp $ */ #ifndef observationSim_Spacecraft_h #define observationSim_Spacecraft_h #include <vector> #include "astro/SkyDir.h" namespace observationSim { /** * @class Spacecraft * * @brief An abstract base class that defines the interface for * objects that provide information on spacecraft position and * attitude. * * @author J. Chiang * * $Header: /nfs/slac/g/glast/ground/cvs/ScienceTools-scons/observationSim/observationSim/Spacecraft.h,v 1.8 2006/11/06 23:59:58 jchiang Exp $ */ class Spacecraft { public: Spacecraft() : m_livetimeFrac(1) {} virtual ~Spacecraft() {} /// Spacecraft z-axis in J2000 coordinates. virtual astro::SkyDir zAxis(double time) = 0; /// Spacecraft x-axis in J2000 coordinates. virtual astro::SkyDir xAxis(double time) = 0; /// Earth longitude in degrees. virtual double EarthLon(double time) = 0; /// Earth latitude in degrees. virtual double EarthLat(double time) = 0; /// Rotation matrix from instrument to J2000 coordinates virtual CLHEP::HepRotation InstrumentToCelestial(double time) = 0; /// true if in SAA virtual bool inSaa(double time) = 0; /// Spacecraft position in geocentric coordinates (km) virtual void getScPosition(double time, std::vector<double> & scPosition) = 0; virtual void getZenith(double time, double & ra, double & dec) = 0; virtual double livetimeFrac(double time) const { (void)(time); return m_livetimeFrac; } virtual void setLivetimeFrac(double livetimeFrac) { m_livetimeFrac = livetimeFrac; } private: double m_livetimeFrac; }; } // namespace observationSim #endif // observationSim_Spacecraft_h
24.556962
142
0.702062
[ "vector" ]
042bf3b7cd5a38ed20251092f83d054b3df50003
25,736
c
C
private/windows/shell/accessib/osk/msswch/msswch/swchlist.c
King0987654/windows2000
01f9c2e62c4289194e33244aade34b7d19e7c9b8
[ "MIT" ]
11
2017-09-02T11:27:08.000Z
2022-01-02T15:25:24.000Z
private/windows/shell/accessib/osk/msswch/msswch/swchlist.c
King0987654/windows2000
01f9c2e62c4289194e33244aade34b7d19e7c9b8
[ "MIT" ]
null
null
null
private/windows/shell/accessib/osk/msswch/msswch/swchlist.c
King0987654/windows2000
01f9c2e62c4289194e33244aade34b7d19e7c9b8
[ "MIT" ]
14
2019-01-16T01:01:23.000Z
2022-02-20T15:54:27.000Z
/**************************************************************************** Switch Input Library DLL Copyright (c) 1992-1997 Bloorview MacMillan Centre SWCHLIST.C - Dynamic List of switch devices Think of the specific switch device modules as objects. Then this module performs the "method overloading" by distributing the general calls to the respective specific device objects. Who needs C++ objects when you can just add another case to each of a dozen switch() statements? :-) We could solve this by adding a list of function pointers to the data structure of each object, but that adds another layer of complexity to create, debug, and maintain. In addition this module keeps the list of devices and manipulates the registry entries for each device. Assumptions: For now the Switch List is a static shared memory location. In the future it will become a dynamic shared memory mapped file, probably as a linked list. The registry entries are contiguously numbered, one for each switch device. While we are running, the position of a device in the Switch List is the same as its position in the Registry List. TODO: Some of the swcList functions are called by each other, but there is some overhead in testing for valid parameters each time. This should be eliminated, by creating "Unchecked" functions. *******************************************************************************/ #include <windows.h> #include <assert.h> #include <tchar.h> #include <conio.h> #include <stdio.h> #include <msswch.h> #include "msswchh.h" #include "msswcher.h" #include "dbg.h" #include "dbgerr.h" /***** Internal Prototypes *****/ BOOL swcListIsValidHsd( HSWITCHDEVICE hsd ); BOOL swcListIsValidDevice( UINT uiDeviceType, UINT uiDeviceNumber ); BOOL XswcListInitSwitchDevice( HSWITCHDEVICE hsd ); swcListRegSetValue( DWORD dwPos, PSWITCHCONFIG psc); HKEY swcListRegCreateKey( void ); DWORD swcListFindInList( HSWITCHDEVICE hsd ); BOOL swcListHsdInUse( HSWITCHDEVICE hsd ); DWORD swcListAddToList( HSWITCHDEVICE hsd ); BOOL swcListPostSwitches( HSWITCHDEVICE hsd, DWORD dwPrevStatus, DWORD dwNewStatus ); #pragma data_seg("sh_data") /***** start of shared data segment *****/ // all shared variables must be initialized or they will not be shared // For now the "dynamic" list is static, since we are lazy and the number of // possible devices is known. When USB is added, this must // be made dynamic, probably through a memory mapped file. Have fun! // 4 Com + 3 Lpt + 2 Joystick + 1 Key = 10 devices. #define MAX_SWITCHDEVICES 10 // This is mirrored from MSSWCH.H // If there are changes, they must be reflected in the INTERNALSWITCHLIST struct. /* typedef struct _SWITCHLIST { DWORD dwSwitchCount; HSWITCHDEVICE hsd[ANYSIZE_ARRAY]; } SWITCHLIST, *PSWITCHLIST; PSWITCHLIST pSwitchList = NULL; */ // In the future we will probably use a memory-mapped file. // For now static will do. // This is the same as the SWITCHLIST structure, with the array // size specified at compile time. // The position of a switch device in the list is the same // as its postion in the registry. typedef struct _INTERNALSWITCHLIST { DWORD dwSwitchCount; HSWITCHDEVICE hsd[MAX_SWITCHDEVICES]; } INTERNALSWITCHLIST, *PINTERNALSWITCHLIST; INTERNALSWITCHLIST SwitchList = {0}; // Synchronize/Protect the dwSwitchCount field #define SZMUTEXSWITCHLIST _TEXT("MutexSwitchList") DWORD dwCurrentCount = 0; DWORD dwCurrentSize = 0; DWORD sw[NUM_SWITCHES] = // Array of bit field constants { SWITCH_1, SWITCH_2, SWITCH_3, SWITCH_4, SWITCH_5, SWITCH_6 }; DWORD swDown[NUM_SWITCHES] = // Array of DOWN messages { SW_SWITCH1DOWN, SW_SWITCH2DOWN, SW_SWITCH3DOWN, SW_SWITCH4DOWN, SW_SWITCH5DOWN, SW_SWITCH6DOWN }; DWORD swUp[NUM_SWITCHES] = // Array of UP messages { SW_SWITCH1UP, SW_SWITCH2UP, SW_SWITCH3UP, SW_SWITCH4UP, SW_SWITCH5UP, SW_SWITCH6UP }; /* Synchronize configuration XswcListInit, swcListGetList, swcListGetConfig, XswcListSetConfig These are protected by the "MutexConfig" at the msswch.c level, before they are called, so that internal to swchlist.c they can call each other. Alternatively, swchlist.c could have two levels of the functions, non-synched and synched. */ #pragma data_seg() /***** end of shared data segment *****/ /**************************************************************************** FUNCTION: XswcListInit() DESCRIPTION: Called in the context of the helper window Individual devices are initialized during GetSwitchDevice, and are added to the switch list during SetConfig. Protected by "MutexConfig" when called from msswch.c. ****************************************************************************/ BOOL XswcListInit( void ) { HKEY hKey; DWORD dwAllocSize; PBYTE pData; LONG lError; TCHAR szName[20]; DWORD dwNameSize = 20; DWORD dwDataSize; DWORD ui; HSWITCHDEVICE hsd; SWITCHCONFIG sc; // When we go dynamic, use something like this: //dwCurrentSize = sizeof( DWORD ) + MAX_SWITCHDEVICES * sizeof( HSWITCHDEVICE ); // For now we are cheating: dwCurrentSize = sizeof( INTERNALSWITCHLIST ); hKey = swcListRegCreateKey(); // In future, get maximum list size from registry. // For now, assume it is MAX_SWITCHDEVICES //RegQueryKeyInfo(); dwAllocSize = sizeof(SWITCHCONFIG); pData = (PBYTE) LocalAlloc( LPTR, dwAllocSize ); // Enumerate through the registry, configuring appropriate switches and // adding them to the switch list. if (pData) { for (ui=0; ui<MAX_SWITCHDEVICES; ui++ ) { dwDataSize = dwAllocSize; lError = RegEnumValue( hKey, ui, szName, &dwNameSize, NULL, NULL, pData, &dwDataSize ); DBGMSG( TEXT("EnumReg> %d Error:%d\n"), ui, lError ); if ( (ERROR_SUCCESS == lError) || (ERROR_MORE_DATA == lError) ) { memcpy( &sc, pData, sizeof(SWITCHCONFIG) ); // Note that this depends on the correctness of the stored // uiDeviceType and uiDeviceNumber. We can handle a variable // uiDeviceNumber, but the uiDeviceType cannot vary. // GetSwitchDevice also calls InitSwitchDevice hsd = swcListGetSwitchDevice( NULL, sc.uiDeviceType, sc.uiDeviceNumber ); XswcListSetConfig( NULL, hsd, &sc ); } else { break; } } LocalFree( pData ); } RegCloseKey( hKey ); return TRUE; } /**************************************************************************** FUNCTION: XswcListEnd() DESCRIPTION: Iterate through the list of switches and release all resources for each switch. Called in the context of the helper window ****************************************************************************/ BOOL XswcListEnd() { PINTERNALSWITCHLIST pSwitchList; HSWITCHDEVICE hsd; BOOL bRtn; UINT ui; pSwitchList = &SwitchList; for (ui=0; ui<pSwitchList->dwSwitchCount; ui++ ) { hsd = pSwitchList->hsd[ui]; switch (swcListGetDeviceType( NULL, hsd )) { case SC_TYPE_COM: bRtn = XswcComEnd( hsd ); break; case SC_TYPE_LPT: bRtn = XswcLptEnd( hsd ); break; case SC_TYPE_JOYSTICK: bRtn = XswcJoyEnd( hsd ); break; case SC_TYPE_KEYS: bRtn = XswcKeyEnd( hsd ); break; default: bRtn = FALSE; break; } } return bRtn; } /**************************************************************************** FUNCTION: swcListGetList() DESCRIPTION: Returns the list of switch device handles (hsd's). Currently this is a static list with a count of the active elements in it. Protected by "MutexConfig" when called from msswch.c. ****************************************************************************/ BOOL swcListGetList( HSWITCHPORT hSwitchPort, PSWITCHLIST pSL, DWORD dwSize, PDWORD pdwReturnSize ) { PINTERNALSWITCHLIST pSwitchList; pSwitchList = &SwitchList; *pdwReturnSize = dwCurrentSize; if (!pSL || !pSwitchList) return FALSE; if (dwSize < *pdwReturnSize) return FALSE; memcpy( pSL, pSwitchList, *pdwReturnSize ); return TRUE; } /**************************************************************************** FUNCTION: swcListGetSwitchDevice() DESCRIPTION: Return a handle to a switch device, given the PortType and PortNumber. If the device is not in use yet, initialize it. The current way to create the handle is to put the PortType in the HIWORD and the PortNumber in the LOWORD, but that is not a documented part of the specification. In the future it may become a real handle and we will need to search for it or create it. Creation will require allocation of config buffers for each device. and will probably occur as part of the initialization. This dynamic hsd will have to be created and kept in a "created" list, separate from the "active" list, until it gets added to the active list. ****************************************************************************/ HSWITCHDEVICE swcListGetSwitchDevice( HSWITCHPORT hSwitchPort, UINT uiDeviceType, UINT uiDeviceNumber ) { HSWITCHDEVICE hsd; if (swcListIsValidDevice( uiDeviceType, uiDeviceNumber )) { hsd = (HSWITCHDEVICE) ( MAKELONG( (WORD)uiDeviceNumber, (WORD)uiDeviceType ) ); if (!swcListHsdInUse( hsd )) // It's a new one XswcListInitSwitchDevice( hsd ); } else { hsd = 0; // SetLastError has been called by swcListIsValidDevice } return hsd; } /**************************************************************************** FUNCTION: swcListIsValidHsd() DESCRIPTION: Check if the hsd is valid. This routine is currently only for non-dynamically allocated devices COM, LPT, KEYS, and JOYSTICK. For dynamic Hsd's the validity of the Hsd will have to be checked from the lists of active or created hsd's. Sets LastError. ****************************************************************************/ BOOL swcListIsValidHsd( HSWITCHDEVICE hsd ) { if (!swcListIsValidDevice( (UINT)(HIWORD( (DWORD)((DWORD_PTR)hsd) )), // type (UINT)(LOWORD( (DWORD)((DWORD_PTR)hsd) )) // number )) { XswchStoreLastError( NULL, SWCHERROR_INVALID_HSD ); return FALSE; } return TRUE; } /**************************************************************************** FUNCTION: swcListIsValidDevice() DESCRIPTION: Check if the uiDeviceType and uiDeviceNumber are valid. This routine is currently only for non-dynamically allocated devices COM, LPT, KEYS, and JOYSTICK. For dynamic Hsd's the validity of the Hsd will have to be checked from the lists of active or created hsd's. Sets LastError. ****************************************************************************/ BOOL swcListIsValidDevice( UINT uiDeviceType, UINT uiDeviceNumber ) { BOOL bTypeOK; BOOL bNumberOK = FALSE; // Need to add better error checking for valid parameters here. switch (uiDeviceType) { case SC_TYPE_COM: bTypeOK = TRUE; if (uiDeviceNumber >= 1 && uiDeviceNumber <= 4) bNumberOK = TRUE; break; case SC_TYPE_LPT: bTypeOK = TRUE; if (uiDeviceNumber >= 1 && uiDeviceNumber <= 3) bNumberOK = TRUE; break; case SC_TYPE_JOYSTICK: bTypeOK = TRUE; if (uiDeviceNumber >= 1 && uiDeviceNumber <= 2) bNumberOK = TRUE; break; case SC_TYPE_KEYS: bTypeOK = TRUE; if (1 == uiDeviceNumber) bNumberOK = TRUE; break; default: bTypeOK = FALSE; bNumberOK = FALSE; } if (!bTypeOK) { XswchStoreLastError( NULL, SWCHERROR_INVALID_DEVICETYPE ); return FALSE; } if (!bNumberOK) { XswchStoreLastError( NULL, SWCHERROR_INVALID_DEVICENUMBER ); return FALSE; } return TRUE; } /**************************************************************************** FUNCTION: swcListGetDeviceType() DESCRIPTION: Return the PortType value given the handle to the switch device. Currently the handle is implemented with the HIWORD as the Type. In the future we may wish to access the SWITCHCONFIG information instead. ****************************************************************************/ UINT swcListGetDeviceType( HSWITCHPORT hSwitchPort, HSWITCHDEVICE hsd ) { if (!swcListIsValidHsd( hsd )) return 0; else return (UINT)(HIWORD( (DWORD)((UINT_PTR)hsd) )); } /**************************************************************************** FUNCTION: swcListGetDeviceNumber() DESCRIPTION: Return the PortNumber value, given the handle to the switch device. Currently the handle is implemented with the LOWORD as the Number. In the future we may wish to access the SWITCHCONFIG information instead. ****************************************************************************/ UINT swcListGetDeviceNumber( HSWITCHPORT hSwitchPort, HSWITCHDEVICE hsd ) { if (!swcListIsValidHsd( hsd )) return 0; else return (UINT)(LOWORD( hsd )); } /**************************************************************************** FUNCTION: swcListGetConfig() DESCRIPTION: Return the configuration information for the specified device. Protected by "MutexConfig" when called from msswch.c. ****************************************************************************/ BOOL swcListGetConfig( HSWITCHPORT hSwitchPort, HSWITCHDEVICE hsd, PSWITCHCONFIG psc ) { BOOL bRtn; switch (swcListGetDeviceType( hSwitchPort, hsd )) { case SC_TYPE_COM: bRtn = swcComGetConfig( hsd, psc ); break; case SC_TYPE_LPT: bRtn = swcLptGetConfig( hsd, psc ); break; case SC_TYPE_JOYSTICK: bRtn = swcJoyGetConfig( hsd, psc ); break; case SC_TYPE_KEYS: bRtn = swcKeyGetConfig( hsd, psc ); break; default: bRtn = FALSE; } return bRtn; } /**************************************************************************** FUNCTION: XswcListSetConfig() DESCRIPTION: Called in the context of the helper window Set the device configuration. If successful: If not in list, add to list Set registry value For a device to be in the registry, it must have had at least one successful config. This is also the "gatekeeper" for the uiDeviceType and uiDeviceNumber fields. These fields are "readonly" and cannot be changed by the user. Protected by "MutexConfig" when called from msswch.c. ****************************************************************************/ BOOL XswcListSetConfig( HSWITCHPORT hSwitchPort, HSWITCHDEVICE hsd, PSWITCHCONFIG psc ) { BOOL bRtn; DWORD dwRegPosition; // assume cbSize error checking has been done in swchSetConfig in msswch.c // we'll be doing "lazy copies" later, so make sure the user doesn't overwrite // this. psc->cbSize = sizeof(SWITCHCONFIG); // make sure the user doesn't overwrite these psc->uiDeviceType = swcListGetDeviceType( hSwitchPort, hsd ); psc->uiDeviceNumber = swcListGetDeviceNumber( hSwitchPort, hsd ); switch ( psc->uiDeviceType ) { case SC_TYPE_COM: bRtn = XswcComSetConfig( hsd, psc ); break; case SC_TYPE_LPT: bRtn = XswcLptSetConfig( hsd, psc ); break; case SC_TYPE_JOYSTICK: bRtn = XswcJoySetConfig( hsd, psc ); break; case SC_TYPE_KEYS: bRtn = XswcKeySetConfig( hsd, psc ); break; default: bRtn = FALSE; break; } DBGMSG( TEXT("listsetconfig>\n") ); if (bRtn) { if (swcListHsdInUse( hsd )) { dwRegPosition = swcListFindInList( hsd ); } else // It's a new one { dwRegPosition = swcListAddToList( hsd ); } swcListRegSetValue( dwRegPosition, psc ); swchPostConfigChanged(); } return bRtn; } /**************************************************************************** FUNCTION: XswcListPollSwitches() DESCRIPTION: Polls the status of all possible switches and returns the bitwise OR combined status of the polled switch devices. Causes messages to be posted for any changed switches of any device. Currently, we check the previous switch status of each device before it is polled and changed. When any devices go to an interrupt driven mechanism, this will need to be changed. Must be called in the context of the helper window. ****************************************************************************/ DWORD XswcListPollSwitches( void ) { PINTERNALSWITCHLIST pSwitchList; SWITCHCONFIG SwitchConfig; HSWITCHDEVICE hsd; DWORD dwPrevStatus; DWORD dwNewStatus; DWORD dwAllPolledStatus; HANDLE hMutex; UINT ui; dwAllPolledStatus = 0; pSwitchList = &SwitchList; hMutex = CreateMutex( NULL, FALSE, SZMUTEXSWITCHLIST ); WaitForSingleObject( hMutex, INFINITE ); for (ui=0; ui<pSwitchList->dwSwitchCount; ui++ ) { // For each switch device, get the old status before we poll it and // it changes to its new status. hsd = pSwitchList->hsd[ui]; swcListGetConfig( NULL, hsd, &SwitchConfig ); if (SC_FLAG_ACTIVE & SwitchConfig.dwFlags) { //DBGMSG( "list> polling: %4.4X\n", hsd ); dwPrevStatus = SwitchConfig.dwSwitches; switch (swcListGetDeviceType( NULL, hsd )) { case SC_TYPE_COM: dwNewStatus = XswcComPollStatus( hsd ); break; case SC_TYPE_LPT: dwNewStatus = XswcLptPollStatus( hsd ); break; case SC_TYPE_JOYSTICK: dwNewStatus = XswcJoyPollStatus( hsd ); break; case SC_TYPE_KEYS: dwNewStatus = XswcKeyPollStatus( hsd ); break; default: dwNewStatus = 0; break; } swcListPostSwitches( hsd, dwPrevStatus, dwNewStatus ); dwAllPolledStatus |= dwNewStatus; } } // for ui (dwSwitchCount) ReleaseMutex( hMutex ); CloseHandle( hMutex ); return dwAllPolledStatus; } /**************************************************************************** FUNCTION: XswcListInitSwitchDevice() DESCRIPTION: Called in GetSwitchDevice to initialize a new hsd. Called in the context of the helper window ****************************************************************************/ BOOL XswcListInitSwitchDevice( HSWITCHDEVICE hsd ) { BOOL bRtn; switch (swcListGetDeviceType( NULL, hsd )) { case SC_TYPE_COM: bRtn = XswcComInit( hsd ); break; case SC_TYPE_LPT: bRtn = XswcLptInit( hsd ); break; case SC_TYPE_JOYSTICK: bRtn = XswcJoyInit( hsd ); break; case SC_TYPE_KEYS: bRtn = XswcKeyInit( hsd ); break; default: bRtn = FALSE; } return bRtn; } /**************************************************************************** FUNCTION: swcListRegSetValue() DESCRIPTION: Stores the given config structure in the registry. Note that the structure is actually two structures, with a pointer from the base structure to the More Info structure. We simply copy both structures to the registry, concatenating them. The position in the registry and the position in the switch list are kept in sync. *** Note *** The correctness of this information is dependent on a side effect of the XswcListSetConfig function, which verifies the correctness of the read-only uiDeviceType and uiDeviceNumber fields of the config structure. ****************************************************************************/ swcListRegSetValue( DWORD dwPos, PSWITCHCONFIG psc) { HKEY hKey; DWORD dwAllocSize; PBYTE pData; TCHAR szValue[10]; // Sanity checks for developers and testers assert( sizeof(HSWITCHDEVICE) == sizeof(DWORD) ); dwAllocSize = sizeof(SWITCHCONFIG); pData = (PBYTE) LocalAlloc( LPTR, dwAllocSize ); if (pData) { memcpy( pData, psc, sizeof(SWITCHCONFIG)); DBGMSG( TEXT("list> setvalue psc: %4.4X %4.4X %4.4X\n"), psc->uiDeviceType, psc->uiDeviceNumber, psc->dwFlags ); hKey = swcListRegCreateKey(); // Create incrementing value names: "0000", "0001", "0002", etc. wsprintf( szValue, TEXT("%4.4d"), dwPos ); RegSetValueEx( hKey, szValue, 0, REG_BINARY, pData, dwAllocSize ); RegCloseKey( hKey ); } if (pData) LocalFree( pData ); return 0; } /**************************************************************************** FUNCTION: swcListRegCreateKey() DESCRIPTION: Creates/Opens the registry key associated with the MSSWITCH entries. Temporary keys used to traverse the tree are closed again. The open key returned from this function must be closed by the caller. Currently the key opened is: HKEY_CURRENT_USER/Software/Microsoft/MS Switch ****************************************************************************/ HKEY swcListRegCreateKey( void ) { LONG lResult; DWORD dwDisposition; HKEY hKey1, hKey2, hKey3; lResult = RegCreateKeyEx( HKEY_CURRENT_USER, _TEXT("Software"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, // security &hKey1, &dwDisposition ); //DBGMSG( "CreateKey1> hkey:%X lResult:%d disp:%X\n", hKey1, lResult, dwDisposition ); lResult = RegCreateKeyEx( hKey1, _TEXT("Microsoft"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, // security &hKey2, &dwDisposition ); //DBGMSG( "CreateKey2> hkey:%X lResult:%d disp:%X\n", hKey2, lResult, dwDisposition ); lResult = RegCreateKeyEx( hKey2, _TEXT("MS Switch"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, // security &hKey3, &dwDisposition ); //DBGMSG( "CreateKey3> hkey:%X lResult:%d disp:%X\n", hKey3, lResult, dwDisposition ); RegCloseKey( hKey1 ); RegCloseKey( hKey2 ); return hKey3; } /**************************************************************************** FUNCTION: swcListFindInList() DESCRIPTION: Find the list position of the given switchdevice. We assume the list position is the same in the SwitchList and in the Registry List. Returns the zero based position or -1 if there is an error. If this changes, synchronize with ListHsdInList. Should we mutex this to synchronize with swcAddToList()? ****************************************************************************/ DWORD swcListFindInList( HSWITCHDEVICE hsd ) { PINTERNALSWITCHLIST pSwitchList; DWORD ui; pSwitchList = &SwitchList; for (ui=0; ui < pSwitchList->dwSwitchCount; ui++) { if (hsd == pSwitchList->hsd[ui]) break; } // if not found, return error if (ui == pSwitchList->dwSwitchCount) { ui = (DWORD)-1; } return ui; } /**************************************************************************** FUNCTION: swcListHsdInUse() DESCRIPTION: Return TRUE if the Hsd is one of the devices that is already initialized and in use. ****************************************************************************/ BOOL swcListHsdInUse( HSWITCHDEVICE hsd ) { return (DWORD)-1 != swcListFindInList( hsd ); } /**************************************************************************** FUNCTION: swcListAddToList() DESCRIPTION: Adds the switch device to our list, returning its new position in the list. This assumes that swcListFindInList has been called first or some other check has been made to make sure the device is not already there. ****************************************************************************/ DWORD swcListAddToList( HSWITCHDEVICE hsd ) { PINTERNALSWITCHLIST pSwitchList; HANDLE hMutex; hMutex = CreateMutex( NULL, FALSE, SZMUTEXSWITCHLIST ); WaitForSingleObject( hMutex, INFINITE ); // When we go dynamic: // pSwitchList = MapViewOfFileEx(); // For now, cheat: pSwitchList = &SwitchList; pSwitchList->hsd[pSwitchList->dwSwitchCount] = hsd; pSwitchList->dwSwitchCount++; ReleaseMutex( hMutex ); CloseHandle( hMutex ); return pSwitchList->dwSwitchCount - 1; } /**************************************************************************** FUNCTION: swcListPostSwitches() DESCRIPTION: For each switch up or down that has occured, request that a message gets posted to all apps which requested messages. ****************************************************************************/ BOOL swcListPostSwitches( HSWITCHDEVICE hsd, DWORD dwPrevStatus, DWORD dwNewStatus ) { int i; DWORD dwBit; // look at one bit at a time DWORD dwChg = dwPrevStatus ^ dwNewStatus; // Isolate changes //DBGMSG( "list> posting: %X\n", dwChg ); for (i=0; i<NUM_SWITCHES; i++) // For each bit, check for a change { dwBit = dwChg & sw[i]; if (dwBit) // This switch has changed { if (!(dwBit & dwNewStatus)) // ... to "up" { swchPostSwitches( hsd, swUp[i] ); } } } for (i=0; i<NUM_SWITCHES; i++) // For each bit, check for a change { dwBit = dwChg & sw[i]; if (dwBit) // This switch has changed { if (dwBit & dwNewStatus) // ... to "down" { swchPostSwitches( hsd, swDown[i] ); } } } return TRUE; }
26.341863
88
0.596907
[ "object" ]
47ea39190e46a7574b218f510ea419504f94290a
1,888
h
C
Sources/Elastos/Frameworks/Droid/Base/Core/inc/elastos/droid/webkit/WebIconDatabase.h
jingcao80/Elastos
d0f39852356bdaf3a1234743b86364493a0441bc
[ "Apache-2.0" ]
7
2017-07-13T10:34:54.000Z
2021-04-16T05:40:35.000Z
Sources/Elastos/Frameworks/Droid/Base/Core/inc/elastos/droid/webkit/WebIconDatabase.h
jingcao80/Elastos
d0f39852356bdaf3a1234743b86364493a0441bc
[ "Apache-2.0" ]
null
null
null
Sources/Elastos/Frameworks/Droid/Base/Core/inc/elastos/droid/webkit/WebIconDatabase.h
jingcao80/Elastos
d0f39852356bdaf3a1234743b86364493a0441bc
[ "Apache-2.0" ]
9
2017-07-13T12:33:20.000Z
2021-06-19T02:46:48.000Z
//========================================================================= // Copyright (C) 2012 The Elastos 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. //========================================================================= #ifndef __ELASTOS_DROID_WEBKIT_WEBICONDATABASE_H__ #define __ELASTOS_DROID_WEBKIT_WEBICONDATABASE_H__ #include "elastos/droid/ext/frameworkext.h" #include "elastos/droid/webkit/WebViewFactory.h" using Elastos::Droid::Graphics::IBitmap; using Elastos::Droid::Content::IContentResolver; namespace Elastos { namespace Droid { namespace Webkit { /** * Functions for manipulating the icon database used by WebView. * These functions require that a WebView be constructed before being invoked * and WebView.getIconDatabase() will return a WebIconDatabase object. This * WebIconDatabase object is a single instance and all methods operate on that * single object. */ class WebIconDatabase { public: /** * Get the global instance of WebIconDatabase. * @return A single instance of WebIconDatabase. It will be the same * instance for the current process each time this method is * called. */ static CARAPI_(AutoPtr<IWebIconDatabase>) GetInstance(); }; } // namespace Webkit } // namespace Droid } // namespace Elastos #endif //__ELASTOS_DROID_WEBKIT_WEBICONDATABASE_H__
34.962963
78
0.692267
[ "object" ]
47ec80b03039123197e39ed03a93ea9355f42c45
12,390
h
C
Graphics/Archiver/interface/ArchiverFactory.h
AnomalousMedical/DiligentCore
5751cdba04373ced8c49ef40ce6a9dffb41a141e
[ "Apache-2.0" ]
null
null
null
Graphics/Archiver/interface/ArchiverFactory.h
AnomalousMedical/DiligentCore
5751cdba04373ced8c49ef40ce6a9dffb41a141e
[ "Apache-2.0" ]
null
null
null
Graphics/Archiver/interface/ArchiverFactory.h
AnomalousMedical/DiligentCore
5751cdba04373ced8c49ef40ce6a9dffb41a141e
[ "Apache-2.0" ]
null
null
null
/* * Copyright 2019-2022 Diligent Graphics LLC * * 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. * * In no event and under no legal theory, whether in tort (including negligence), * contract, or otherwise, unless required by applicable law (such as deliberate * and grossly negligent acts) or agreed to in writing, shall any Contributor be * liable for any damages, including any direct, indirect, special, incidental, * or consequential damages of any character arising as a result of this License or * out of the use or inability to use the software (including but not limited to damages * for loss of goodwill, work stoppage, computer failure or malfunction, or any and * all other commercial damages or losses), even if such Contributor has been advised * of the possibility of such damages. */ #pragma once /// \file /// Defines Diligent::IArchiverFactory interface and related structures. #include "../../../Primitives/interface/Object.h" #include "../../../Primitives/interface/DebugOutput.h" #include "SerializationDevice.h" DILIGENT_BEGIN_NAMESPACE(Diligent) // {F20B91EB-BDE3-4615-81CC-F720AA32410E} static const INTERFACE_ID IID_ArchiverFactory = {0xf20b91eb, 0xbde3, 0x4615, {0x81, 0xcc, 0xf7, 0x20, 0xaa, 0x32, 0x41, 0xe}}; #define DILIGENT_INTERFACE_NAME IArchiverFactory #include "../../../Primitives/interface/DefineInterfaceHelperMacros.h" #define IArchiverFactoryInclusiveMethods \ IObjectInclusiveMethods; \ IArchiverFactoryMethods ArchiverFactory // clang-format off /// Serialization device attributes for Direct3D11 backend struct SerializationDeviceD3D11Info { /// Direct3D11 feature level Version FeatureLevel DEFAULT_INITIALIZER(Version(11, 0)); #if DILIGENT_CPP_INTERFACE /// Tests if two structures are equivalent constexpr bool operator==(const SerializationDeviceD3D11Info& RHS) const { return FeatureLevel == RHS.FeatureLevel; } constexpr bool operator!=(const SerializationDeviceD3D11Info& RHS) const { return !(*this == RHS); } #endif }; typedef struct SerializationDeviceD3D11Info SerializationDeviceD3D11Info; /// Serialization device attributes for Direct3D12 backend struct SerializationDeviceD3D12Info { /// Shader version supported by the device Version ShaderVersion DEFAULT_INITIALIZER(Version(6, 0)); /// DX Compiler path const Char* DxCompilerPath DEFAULT_INITIALIZER(nullptr); #if DILIGENT_CPP_INTERFACE /// Tests if two structures are equivalent bool operator==(const SerializationDeviceD3D12Info& RHS) const { return ShaderVersion == RHS.ShaderVersion && SafeStrEqual(DxCompilerPath, RHS.DxCompilerPath); } bool operator!=(const SerializationDeviceD3D12Info& RHS) const { return !(*this == RHS); } #endif }; typedef struct SerializationDeviceD3D12Info SerializationDeviceD3D12Info; /// Serialization device attributes for Vulkan backend struct SerializationDeviceVkInfo { /// Vulkan API version Version ApiVersion DEFAULT_INITIALIZER(Version(1, 0)); /// Indicates whether the device supports SPIRV 1.4 or above Bool SupportsSpirv14 DEFAULT_INITIALIZER(False); /// Path to DX compiler for Vulkan const Char* DxCompilerPath DEFAULT_INITIALIZER(nullptr); #if DILIGENT_CPP_INTERFACE /// Tests if two structures are equivalent bool operator==(const SerializationDeviceVkInfo& RHS) const { return ApiVersion == RHS.ApiVersion && SupportsSpirv14 == RHS.SupportsSpirv14 && SafeStrEqual(DxCompilerPath, RHS.DxCompilerPath); } bool operator!=(const SerializationDeviceVkInfo& RHS) const { return !(*this == RHS); } #endif }; typedef struct SerializationDeviceVkInfo SerializationDeviceVkInfo; /// Serialization device attributes for Metal backend struct SerializationDeviceMtlInfo { /// Additional compilation options for Metal command-line compiler for MacOS. const Char* CompileOptionsMacOS DEFAULT_INITIALIZER("-sdk macosx metal"); /// Additional compilation options for Metal command-line compiler for iOS. const Char* CompileOptionsiOS DEFAULT_INITIALIZER("-sdk iphoneos metal"); /// Name of the command-line application that is used to preprocess Metal shader source before compiling to bytecode. const Char* MslPreprocessorCmd DEFAULT_INITIALIZER(nullptr); /// Optional directory to dump converted MSL source code and temporary files produced by the Metal toolchain. const Char* DumpDirectory DEFAULT_INITIALIZER(nullptr); #if DILIGENT_CPP_INTERFACE /// Tests if two structures are equivalent bool operator==(const SerializationDeviceMtlInfo& RHS) const { return SafeStrEqual(CompileOptionsMacOS, RHS.CompileOptionsMacOS) && SafeStrEqual(CompileOptionsiOS, RHS.CompileOptionsiOS) && SafeStrEqual(MslPreprocessorCmd, RHS.MslPreprocessorCmd); } bool operator!=(const SerializationDeviceMtlInfo& RHS) const { return !(*this == RHS); } #endif }; typedef struct SerializationDeviceMtlInfo SerializationDeviceMtlInfo; /// Serialization device creation information struct SerializationDeviceCreateInfo { /// Device info, contains enabled device features. /// Can be used to validate shader, render pass, resource signature and pipeline state. /// /// \note For OpenGL that does not support separable programs, disable the SeparablePrograms feature. RenderDeviceInfo DeviceInfo; /// Adapter info, contains device parameters. /// Can be used to validate shader, render pass, resource signature and pipeline state. GraphicsAdapterInfo AdapterInfo; /// Direct3D11 attributes, see Diligent::SerializationDeviceD3D11Info. SerializationDeviceD3D11Info D3D11; /// Direct3D12 attributes, see Diligent::SerializationDeviceD3D12Info. SerializationDeviceD3D12Info D3D12; /// Vulkan attributes, see Diligent::SerializationDeviceVkInfo. SerializationDeviceVkInfo Vulkan; /// Metal attributes, see Diligent::SerializationDeviceMtlInfo. SerializationDeviceMtlInfo Metal; #if DILIGENT_CPP_INTERFACE SerializationDeviceCreateInfo() noexcept { DeviceInfo.Features = DeviceFeatures{DEVICE_FEATURE_STATE_ENABLED}; AdapterInfo.Features = DeviceFeatures{DEVICE_FEATURE_STATE_ENABLED}; // Disable subpass framebuffer fetch by default to allow backwards compatibility on Metal. DeviceInfo.Features.SubpassFramebufferFetch = DEVICE_FEATURE_STATE_DISABLED; } #endif }; typedef struct SerializationDeviceCreateInfo SerializationDeviceCreateInfo; /// Archiver factory interface DILIGENT_BEGIN_INTERFACE(IArchiverFactory, IObject) { /// Creates a serialization device. /// \param [in] CreateInfo - Serialization device create information, see Diligent::SerializationDeviceCreateInfo. /// \param [out] ppDevice - Address of the memory location where a pointer to the /// device interface will be written. VIRTUAL void METHOD(CreateSerializationDevice)(THIS_ const SerializationDeviceCreateInfo REF CreateInfo, ISerializationDevice** ppDevice) PURE; /// Creates an archiver. /// \param [in] pDevice - Pointer to the serialization device. /// \param [out] ppArchiver - Address of the memory location where a pointer to the /// archiver interface will be written. VIRTUAL void METHOD(CreateArchiver)(THIS_ ISerializationDevice* pDevice, IArchiver** ppArchiver) PURE; /// Creates a default shader source input stream factory /// \param [in] SearchDirectories - Semicolon-separated list of search directories. /// \param [out] ppShaderSourceStreamFactory - Memory address where a pointer to the shader source /// stream factory will be written. VIRTUAL void METHOD(CreateDefaultShaderSourceStreamFactory)( THIS_ const Char* SearchDirectories, struct IShaderSourceInputStreamFactory** ppShaderSourceFactory) CONST PURE; /// Removes device-specific data from the archive and writes a new archive to the stream. /// \param [in] pSrcArchive - Source archive from which device specific-data will be removed. /// \param [in] DeviceFlags - Combination of device types that will be removed. /// \param [in] pStream - Destination file stream. VIRTUAL Bool METHOD(RemoveDeviceData)(THIS_ IArchive* pSrcArchive, ARCHIVE_DEVICE_DATA_FLAGS DeviceFlags, IFileStream* pStream) CONST PURE; /// Copies device-specific data from the source archive to the destination and writes a new archive to the stream. /// \param [in] pSrcArchive - Source archive to which new device-specific data will be added. /// \param [in] DeviceFlags - Combination of device types that will be copied. /// \param [in] pDeviceArchive - Archive that contains the same common data and additional device-specific data. /// \param [in] pStream - Destination file stream. VIRTUAL Bool METHOD(AppendDeviceData)(THIS_ IArchive* pSrcArchive, ARCHIVE_DEVICE_DATA_FLAGS DeviceFlags, IArchive* pDeviceArchive, IFileStream* pStream) CONST PURE; /// Prints archive content for debugging and validation. VIRTUAL Bool METHOD(PrintArchiveContent)(THIS_ IArchive* pArchive) CONST PURE; /// Sets a user-provided debug message callback. /// \param [in] MessageCallback - Debug message callback function to use instead of the default one. VIRTUAL void METHOD(SetMessageCallback)(THIS_ DebugMessageCallbackType MessageCallback) CONST PURE; }; DILIGENT_END_INTERFACE #include "../../../Primitives/interface/UndefInterfaceHelperMacros.h" #if DILIGENT_C_INTERFACE # define IArchiverFactory_CreateArchiver(This, ...) CALL_IFACE_METHOD(ArchiverFactory, CreateArchiver, This, __VA_ARGS__) # define IArchiverFactory_CreateSerializationDevice(This, ...) CALL_IFACE_METHOD(ArchiverFactory, CreateSerializationDevice, This, __VA_ARGS__) # define IArchiverFactory_CreateDefaultShaderSourceStreamFactory(This, ...) CALL_IFACE_METHOD(ArchiverFactory, CreateDefaultShaderSourceStreamFactory, This, __VA_ARGS__) # define IArchiverFactory_RemoveDeviceData(This, ...) CALL_IFACE_METHOD(ArchiverFactory, RemoveDeviceData, This, __VA_ARGS__) # define IArchiverFactory_AppendDeviceData(This, ...) CALL_IFACE_METHOD(ArchiverFactory, AppendDeviceData, This, __VA_ARGS__) # define IArchiverFactory_PrintArchiveContent(This, ...) CALL_IFACE_METHOD(ArchiverFactory, PrintArchiveContent, This, __VA_ARGS__) # define IArchiverFactory_SetMessageCallback(This, ...) CALL_IFACE_METHOD(ArchiverFactory, SetMessageCallback, This, __VA_ARGS__) #endif DILIGENT_END_NAMESPACE // namespace Diligent
44.092527
173
0.685553
[ "render", "object" ]
47fef46db0d17f2dcec72d8b3bc1e32938471cfe
824
h
C
DirectZobEngine/Behaviors/ZobBehaviorLight.h
zeralph/directZob
7682ec0b77b697659be157cce62413e3ee877ee4
[ "WTFPL" ]
2
2019-06-12T18:11:36.000Z
2022-01-19T00:26:00.000Z
DirectZobEngine/Behaviors/ZobBehaviorLight.h
zeralph/directZob
7682ec0b77b697659be157cce62413e3ee877ee4
[ "WTFPL" ]
null
null
null
DirectZobEngine/Behaviors/ZobBehaviorLight.h
zeralph/directZob
7682ec0b77b697659be157cce62413e3ee877ee4
[ "WTFPL" ]
1
2019-10-05T02:44:47.000Z
2019-10-05T02:44:47.000Z
#pragma once #undef min #undef max #undef None #include "../tinyxml/tinyxml.h" #include "ZobBehavior.h" #include <string> #include <vector> class ZobBehaviorLight : public ZobBehavior { friend class ZobBehaviorFactory; public: ~ZobBehaviorLight() override; void Init() override; void PreUpdate(float dt) override; void PostUpdate() override; void UpdateBeforeObject(float dt) override; void UpdateAfterObject(float dt) override; void QueueForDrawing(const Camera* camera, Engine* engine) override; void EditorUpdate() override; private: ZobBehaviorLight(ZobObject* zobObject, bool bEditorZobBehavior); ZobColor m_lightColor; float m_intensity; float m_distance; float m_spotAngleRad; bool m_active; bool m_inFrtustrum; //eLightType m_lightType; Box m_OBB; Box m_AABB; };
21.128205
73
0.75
[ "vector" ]
9a02e3bac5a87f505dca9c17ad1314fa95e73a3b
1,758
h
C
projects/custom/src/john_collections/john_object_pool.h
johnlee175/medias
d940cb7d2fcc32a7c2d520106d6290035a86f809
[ "Apache-2.0" ]
1
2018-08-14T14:01:25.000Z
2018-08-14T14:01:25.000Z
projects/custom/src/john_collections/john_object_pool.h
johnlee175/medias
d940cb7d2fcc32a7c2d520106d6290035a86f809
[ "Apache-2.0" ]
null
null
null
projects/custom/src/john_collections/john_object_pool.h
johnlee175/medias
d940cb7d2fcc32a7c2d520106d6290035a86f809
[ "Apache-2.0" ]
null
null
null
/* * 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. */ /** * @author John Kenrinus Lee * @version 2017-11-10 */ #ifndef __JOHN_OBJECT_POOL_H__ #define __JOHN_OBJECT_POOL_H__ #ifdef __cplusplus extern "C" { #endif #include <stdbool.h> #include <stdint.h> typedef struct JohnObjectDelegate { void *user_client_params; void *(*create_func)(void *user_client_params); void (*destroy_func)(void *object, void *user_client_params); void (*reset_func)(void *object, void *user_client_params); } JohnObjectDelegate; typedef struct JohnObjectPool JohnObjectPool; JohnObjectPool *john_object_pool_create(uint32_t max_size, uint32_t pool_size, uint32_t prepare_size, JohnObjectDelegate *delegate); void john_object_pool_destroy(JohnObjectPool *object_pool); void *john_object_pool_obtain(JohnObjectPool *object_pool); void john_object_pool_recycle(JohnObjectPool *object_pool, void *object); #ifdef __cplusplus } #endif #endif /* __JOHN_OBJECT_POOL_H__ */
33.807692
101
0.75711
[ "object" ]
9a03f70068db3126b5bf70c2c8af75bac5298fea
2,631
h
C
vendor/mysql-connector-c++-1.1.3/test/common/stringutils.h
caiqingfeng/libmrock
bb7c94482a105e92b6d3e8640b13f9ff3ae49a83
[ "Apache-2.0" ]
1
2015-12-01T04:16:54.000Z
2015-12-01T04:16:54.000Z
vendor/mysql-connector-c++-1.1.3/test/common/stringutils.h
caiqingfeng/libmrock
bb7c94482a105e92b6d3e8640b13f9ff3ae49a83
[ "Apache-2.0" ]
null
null
null
vendor/mysql-connector-c++-1.1.3/test/common/stringutils.h
caiqingfeng/libmrock
bb7c94482a105e92b6d3e8640b13f9ff3ae49a83
[ "Apache-2.0" ]
null
null
null
/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. The MySQL Connector/C++ is licensed under the terms of the GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors. There are special exceptions to the terms and conditions of the GPLv2 as it is applied to this software, see the FLOSS License Exception <http://www.mysql.com/about/legal/licensing/foss-exception.html>. 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; version 2 of the License. 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __CCPP_STRINGUTILS_H #define __CCPP_STRINGUTILS_H #include "ccppTypes.h" namespace StringUtils { template <class StdStringType> unsigned _split ( std::vector<StdStringType> & list , const StdStringType & str , const StdStringType & delim , bool trimItems= true , bool includeEmpty= false); // just a shortcut for split<String>() unsigned split ( List & list , const String & str , const String & delim , bool trimItems= true , bool includeEmpty= false); template <class StdStringType> StdStringType & _trim ( StdStringType & victim ); /* Unlike Java's trim, this trims only blank spaces */ String & trim ( String & victim ); int toInt ( const String & str, bool isNull = false ); bool toBoolean ( const String & str, bool isNull = false ); long long toLong ( const String & str, bool isNull = false ); float toFloat ( const String & str, bool isNull = false ); double toDouble ( const String & str, bool isNull = false ); const String & defaultIfEmpty ( const String & str, const String & defStr ); String toHexString( char c, bool leading0x= false ); String toHexString( const char * c, int count, bool leading0x= false ); String & concatSeparated( String & to, const String & add, const String & separator= " " ); } #endif
36.541667
93
0.661726
[ "vector" ]
9a099f5abcd98f2e048a8dd93347e44056adb482
835
h
C
src/Molassembler/IO/Base64.h
Dom1L/molassembler
dafc656b1aa846b65b1fd1e06f3740ceedcf22db
[ "BSD-3-Clause" ]
17
2020-11-27T14:59:34.000Z
2022-03-28T10:31:25.000Z
src/Molassembler/IO/Base64.h
Dom1L/molassembler
dafc656b1aa846b65b1fd1e06f3740ceedcf22db
[ "BSD-3-Clause" ]
null
null
null
src/Molassembler/IO/Base64.h
Dom1L/molassembler
dafc656b1aa846b65b1fd1e06f3740ceedcf22db
[ "BSD-3-Clause" ]
6
2020-12-09T09:21:53.000Z
2021-08-22T15:42:21.000Z
/*!@file * @copyright This code is licensed under the 3-clause BSD license. * Copyright ETH Zurich, Laboratory of Physical Chemistry, Reiher Group. * See LICENSE.txt for details. * @brief Base 64 encoding and decoding between strings and vectors of uint_8 */ #ifndef INCLUDE_BASE_64_ENCODING_H #define INCLUDE_BASE_64_ENCODING_H #include <string> #include <vector> namespace Scine { namespace base64 { /** @brief Encode binary data as a string * * @complexity{@math{\Theta(N)}} * * @param inputBuffer binary data */ std::string encode(const std::vector<std::uint8_t>& inputBuffer); /** @brief Decode base 64 string data to binary * * @complexity{@math{\Theta(N)}} * * @param input base 64 string */ std::vector<std::uint8_t> decode(const std::string& input); } // namespace base64 } // namespace Scine #endif
22.567568
77
0.717365
[ "vector" ]
9a230e0d93c231f40644a5f7d8722c03f85d827a
961
h
C
inc/PointLight.h
diegomacario/Manta-Ray-Tracer
39fca8343f682ca318119ffd220af0234597bf9d
[ "MIT" ]
124
2017-10-24T00:11:02.000Z
2021-12-06T17:19:09.000Z
inc/PointLight.h
diegomacario/Manta-Ray-Tracer
39fca8343f682ca318119ffd220af0234597bf9d
[ "MIT" ]
5
2017-10-24T21:11:47.000Z
2020-03-19T19:34:15.000Z
inc/PointLight.h
diegomacario/Manta-Ray-Tracer
39fca8343f682ca318119ffd220af0234597bf9d
[ "MIT" ]
6
2017-10-24T20:29:25.000Z
2021-10-19T08:13:35.000Z
#ifndef POINT_LIGHT_H #define POINT_LIGHT_H #include "Light.h" /* Description: The PointLight class inherits from the Light class and is used to represent point lights. This type of light is placed at a specific location and can be affected by constant, linear and quadratic attenuation. */ class PointLight : public Light { public: PointLight(const Point& lightPosition, const Attenuation& attenuation, const Colour& colour); ~PointLight(); Colour calculateContributionOfLight(const Point& eye, const Intersection* const intersection) const; bool checkForObstacleBetweenPointAndLight(const Point& point, std::vector<GeometricShape*>::iterator objectIteratorBegin, const std::vector<GeometricShape*>::iterator objectIteratorEnd) const; private: Point lightPosition; Attenuation attenuation; }; #endif
27.457143
122
0.679501
[ "vector" ]
9a38a5882803e8b313de5bb7dad4c1898b97c2ec
1,709
h
C
source/items/MerchantView.h
jrbeck/longshot
5dde65a5331ca7bf133b1188bfd6160da4ffc649
[ "MIT" ]
null
null
null
source/items/MerchantView.h
jrbeck/longshot
5dde65a5331ca7bf133b1188bfd6160da4ffc649
[ "MIT" ]
null
null
null
source/items/MerchantView.h
jrbeck/longshot
5dde65a5331ca7bf133b1188bfd6160da4ffc649
[ "MIT" ]
null
null
null
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // * MerchantView // * // * desc: // * // * // * // * // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #pragma once #include <vector> #include "../game/GameMenu.h" #include "../items/Inventory.h" #include "../player/Player.h" enum { MERCHANT_MODE_SELL, MERCHANT_MODE_BUY }; enum { MERCHANT_BUTTON_END_TRANSACTION = 1, MERCHANT_BUTTON_SELL_MODE, MERCHANT_BUTTON_BUY_MODE, MERCHANT_BUTTON_SELL, MERCHANT_BUTTON_BUY, MERCHANT_BUTTON_ITEM_BEGIN = 100 }; // TODO: move this into it's own header/cpp files class Merchant { public: void save(FILE *file); void load(FILE *file); vector<size_t> mInventoryList; size_t mCredits; }; class MerchantView { public: MerchantView(); ~MerchantView(); // this begins the interaction with a merchant void engageMerchant(Player& player, ItemManager& itemManager); void setupMerchant(Merchant& merchant, ItemManager& itemManager); int update(Player& player, ItemManager& itemManager); void setupMenu(Player& player, ItemManager& itemManager); void setupSellMenu(Player& player, ItemManager& itemManager); void setupBuyMenu(Merchant& merchant, ItemManager& itemManager); void addSelectedItemInfo(ItemManager& itemManager); void setupInventoryList(ItemManager& itemManager); void draw(); // MEMBERS * * * * * * * * * * GameMenu* mMenu; int mMode; int mSelectedItem; vector<size_t> tempList; GLfloat colorWhite[4]; GLfloat colorBackground[4]; GLfloat colorSelection[4]; v2d_t fontSize; // TODO: this is for testing only Merchant* mMerchant; };
18.78022
94
0.634289
[ "vector" ]
9a46ef37314d531e85d0817211eb05cf5a5fd1fc
188,740
w
C
src/solvers/funcsat/src/funcsat.w
weaversa/sbsat
f4401a723c95140110faa02cba401200c68f87f3
[ "BSD-3-Clause" ]
1
2020-05-24T13:45:15.000Z
2020-05-24T13:45:15.000Z
src/solvers/funcsat/src/funcsat.w
weaversa/sbsat
f4401a723c95140110faa02cba401200c68f87f3
[ "BSD-3-Clause" ]
null
null
null
src/solvers/funcsat/src/funcsat.w
weaversa/sbsat
f4401a723c95140110faa02cba401200c68f87f3
[ "BSD-3-Clause" ]
null
null
null
% -*- mode: cweb -*- % Copyright 2012 Sandia Corporation. Under the 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. \def\todo{TODO COMMAND} \let\ifpdf=\relax \def\NULL{{\tt NULL}} %I think the default greek thing is confusing \input eplain \beginpackages \usepackage{url} \usepackage[dvipsnames]{color} \endpackages \enablehyperlinks \hlopts{bwidth=0} \hlopts[url]{colormodel=named,color=BlueViolet} \def\numberedmarker{{\fam1\teni \number\itemnumber}} \def\numberedprintmarker#1{\llap{#1 \listmarkerspace}} \def\unorderedmarker{---} \listleftindent=\parindent \listleftindent=2\parindent \abovelistskipamount=0pt \belowlistskipamount=0pt \interitemskipamount=0pt \def\osf#1{{\fam1 \teni #1}} \let\footnote=\numberedfootnote \input font_palatino \baselineskip=12pt %10/12 \let\cmntfont=\sl \let\mainfont=\rm \mainfont \def\paragraphit#1{{\it #1\/}\hskip\parindent} \def\funcsat{{\caps funcsat}} \def\minisat{{\caps minisat}} \def\picosat{{\caps picosat}} \def\acro#1{{\twelvecaps #1}} \def\textit#1{{\it #1\/}} \def\SAT{\acro{sat}} \def\UNSAT{\acro{unsat}} \def\UIP{\acro{uip}} \def\LBD{\acro{lbd}} \def\BCP{\acro{bcp}} \let\or\vee \let\and\hat % Important sections for this WEB: % External types -- goes into <file>.h % External declarations -- goes into <file>.h after External ty... % Internal types -- goes into <file>_internal.h % Internal declarations -- goes into <file>_internal.h after Internal ty... % Global definitions -- goes into <file>.c after Internal decl... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % IT BEGINS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @* Introduction. \funcsat\ is a CDCL SAT solver, written by Denis Bueno \url{denis.bueno@@sandia.gov} at Sandia National Labs. It was developed under LDRD funding. It is written in ANSI \CEE/99. Copyright 2012 Sandia Corporation. Under the 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. \funcsat's main goal is {\it flexibility}. It has a bunch of features, blah blah. @s uintmax_t int @s intmax_t int @s clause int @s funcsat int @s literal int @s variable int @s uint64_t int @s uint32_t int @s uint16_t int @s uint8_t char @s int64_t int @s int32_t int @s int16_t int @s int8_t char @s fs_ifdbg if @s forVector for @s forVectorRev for @s mbool bool @s funcsat_config int @s for_watchlist for @s for_watchlist_continue for @s for_clause for @s for_head_tail for @s funcsat_result int @s hashtable int @s fibheap int @s binvec_t int @s watchlist int @s watchlist_elt int @s all_watches int @s head_tail int @s new numVars @s uintptr_t int @s bh_node int @s vec_ptr int @s for_vec_ptr for @s for_vec_ptr99 for @s vec_intmax int @s for_vec_intmax for @s for_vec_intmax99 for @s vec_uintmax int @s for_vec_uintmax for @s for_vec_uintmax99 for @s vec_uintptr int @s for_vec_uintptr for @s for_vec_uintptr99 for @* The Client. Information in the {\tt funcsat.h} header file should give you all you need to begin using \funcsat. We provide methods for the following: \numberedlist \li Creating (|funcsatInit|) and destroying (|funcsatDestroy|) a SAT solver \li Adding instance clauses (|funcsatAddClause|) \li Solving (|funcsatSolve|) SAT instances. \endnumberedlist \funcsat\ is an extensible SAT solver. This means SAT instances can be solved under unit assumptions. \numberedlist \li In order to add a unit assumption, use |funcsatPushAssumption|. \li {\bf You must check the return value}. If it returns |FS_UNSAT|, the assumption is not actually pushed because your problem is trivially unsatisfiable. \li At this point, if you call |funcsatSolve|, the SAT instance is restricted to solutions where every push assumption is true. \li In order to relieve assumptions, call |funcsatPopAssumptions|. Assumptions are kept on a LIFO stack and {\it push} and {\it pop} have LIFO semantics. \endnumberedlist @* The Developer. The second category of user is going to want to modify funcsat. What follows is an overview of all data structures in \funcsat. @ Vocab and data types. \numberedlist \li The order of inferences (implied literals) is kept in the |funcsat->trail|, a chronological list of the current (partial) assignment. \li The |funcsat->model| tells whether a variable is assigned given the variable's index in the trail. A variables assignment (either True or False) is called its {\it phase}. \li The |funcsat->level| of each variable is the decision level at which the variable was set: if the variable was set at decision level 0, that means it's True for all time. \li The |funcsat->decisions| tells whether a particular variable is a {\it decision variable} (a choice point, a branch) or not. A variable that is not a decision is an {\it inference}, or currently unassigned. Each inference has a {\it reason} (a clause sometimes called an antecedent) stored in |funcsat->reason|. \li Each clause can either be original or learned; a learned clause is implied by the SAT instance. \endnumberedlist @ Generic data types. There are some datatypes used everywhere in funcsat: \unorderedlist \li |variable|, |literal|: just typedefs for |uintmax_t| and |intmax_t|, resp. \li |vec_ptr|: a growable, sized array of pointers. It can act as an efficient \acro{lifo} stack. In fact, there is a whole family of vectors with essentially the same semantics, differing only in the underlying element type. \li |clause|: a clause; or just a growable, sized array of |intmax_t| \li |mbool|: a three-value Boolean, or ``multi-Bool''. Possible values are |true|, |false|, and |unknown|. \li |clause_head| and |clause_block|. You can read about these in the Clauses section (page~\refn{pg-clauses}). \endunorderedlist Other available data types: \unorderedlist \li |struct hashtable|: just a direct chained hash table \li |fibheap|: fibonacci heap (prio queue impl) \endunorderedlist @ If you want to add some new solver state... The core solver state is in this file; the data type is |funcsat|. For example, when I added phase saving I needed a new vector to store the last phase. So, \unorderedlist \li I added a |funcsat->phase| into |funcsat|. \li Next, I allocated the state in |funcsatInit| \li and free'd the state in |funcsatDestroy| \li Finally, I added the incremental resizing of the state in |funcsatResize|. \endunorderedlist {\bf Do not allocate during solving.} Allocate only during |funcsatInit| and |funcsatResize|. Allocating during solving is bad. Of course we have to allocate when learning a new learned clause. But we often do not have to call |malloc(1)| when this happens -- because there is a pool of clauses that get recycled. @ If you want to add a new user-settable parameter... All such parameters are part of the |funcsat_config|, which is stored per-solver in |funcsat->conf|. @ If you want to change the clause learning... See the learning on page \refn{pg-clause-learn}. It's a really nasty loop that calculates all the UIPs of the current conflict graph, or at least all the UIPs the user wants. It does resolution to figure out which clause to learn. It does conflict clause minimisation using Van Gelder's DFS-based minimisation algorithm. It does only-the-fly self-subsuming resolution with each resolvent produced during learning. @ If you want to add a new stat... Put it in |funcsat|. Then you'll probably want to change |funcsatPrintStats|, too (and possibly even |funcsatPrintColumnStats|). @ If you want to add a new argument... Probably you should be exposing some option in |funcsat->conf|. In any case, you need to look in {\tt main.c} to see how getopt is used to handle the existing options. Then hack yours in. Create a new \funcsat\ instance. \funcsat\ is designed to be thread-safe so one process may create as many solvers as it likes. Get your default config from |funcsatConfigInit|. @* Implementation. This file was originally not literate. I'm converting it to literate style bit by bit. Be patient. First, the public header file is pretty simple. @d swap(ty, x, y) ty _swap_tmp ## ty = (x); (x) = (y), (y) = _swap_tmp ## ty; @(funcsat.h@>= #ifndef funcsat_h_included #define funcsat_h_included #include <stdio.h> #include <stdlib.h> #include <inttypes.h> #include <stdbool.h> #include "funcsat/vec_bool.h" #include "funcsat/vec_uint64.h" @<External types@>@; @<External declarations@>@; #endif @ The internal header file is where our internal types and declarations go @(funcsat_internal.h@>= #ifndef funcsat_internal_h_included #define funcsat_internal_h_included #include "funcsat/vec_ptr.h" #include "funcsat/vec_intmax.h" #include <funcsat/fibheap.h> @<Conditional macros@>@; @<Internal types@>@; @<Main \funcsat\ type@>@; @<Internal declarations@>@; #endif @ All the external types need the basic \funcsat\ types. @<External ty...@>= #include "funcsat/system.h" #include "funcsat/vec_uintmax.h" #include "funcsat/hashtable.h" @ Next comes \funcsat! I've put all the includes here, for simplicity. Note that this file has no {\tt main} function---we only define \funcsat's internals and API here. See {\tt main.c} for the grungy details of exposing all of \funcsat's options on the command-line. It's pretty gross. @c #include "funcsat/config.h" #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <assert.h> #include <string.h> #include <float.h> #include <math.h> #include <sys/resource.h> #include <sys/stat.h> #include <inttypes.h> #include <errno.h> #include <funcsat/hashtable.h> #include <funcsat/system.h> #include <zlib.h> #include <ctype.h> #include "funcsat.h" #include "funcsat_internal.h" #include "funcsat/vec_uintptr.h" @<Global definitions@>@; @ I use the following macros for memory management, just because. @<External decl...@>= #define FS_CALLOC(ptr, n, size) \ do { \ ptr = calloc((n), (size)); \ if (!ptr) perror("FS_CALLOC"), abort(); \ } while (0); #define FS_MALLOC(ptr, n, size) \ do { \ ptr = malloc((n)*(size)); \ if (!ptr) perror("FS_MALLOC"), abort(); \ } while (0); #define FS_MALLOC_TY(ty, ptr, n, size) \ do { \ ptr = (ty) malloc((n)*(size)); \ if (!ptr) perror("FS_MALLOC_TY"), abort(); \ } while (0); #define FS_REALLOC(ptr, n, size) \ do { \ void *tmp_funcsat_ptr__; \ tmp_funcsat_ptr__ = realloc(ptr, (n)*(size)); \ if (!tmp_funcsat_ptr__) free(ptr), perror("FS_REALLOC"), abort(); \ ptr = tmp_funcsat_ptr__; \ } while (0); #define FS_REFS_CALLOC(p,o,n,sz) \ do { \ assert((n) >= (o)); \ void *tmp_funcsat_ptr__; \ tmp_funcsat_ptr__ = realloc(p, (n)*(sz)); \ if (!tmp_funcsat_ptr__) perror("FS_REFS_CALLOC"), abort(); \ memset(tmp_funcsat_ptr__ + ((o)*(sz)), 0, ((n)-(o))*(sz)); \ (p) = tmp_funcsat_ptr__; \ } while (0); @*1 Top-level solver. This is the top-level solving loop. You should read this. It's really short! it should stay that way. It should fit on a page. It serves as a pretty easy-to-grasp example that can be referred to for writing a custom search strategy using \funcsat\ components. The main parameters of the solver allow configuring a wide range of search behavior. Note how the loop runs until the solver ``runs out of resources.'' This allows one to use \funcsat\ to do cheap probing for properties, allowing the solver to return ``unknown'' if it needs to. As another example, |isTimeToRestart| allows one to insert a custom restart strategy. @<Global def...@>= funcsat_result funcsatSolve(funcsat *f) { if (FS_UNSAT == (f->lastResult = startSolving(f))) goto Done; if (!bcpAndJail(f)) goto Unsat; while (!f->conf->isResourceLimitHit(f, f->conf->user)) { fs_ifdbg(f, "solve", 3) fs_print_state(f, fs_dbgout(f)); if (!bcp(f)) { if (0 == f->decisionLevel) goto Unsat; if (!analyze_conflict(f)) goto Unsat; if (f->conf->gc) f->conf->sweepClauses(f, f->conf->user); continue; } if (f->trail.size != f->numVars && f->conf->isTimeToRestart(f, f->conf->user)) { fslog(f, "solve", 1, "restarting\n"); ++f->numRestarts; backtrack(f, 0, NULL, true); continue; } if (!funcsatMakeDecision(f, f->conf->user)) { f->lastResult = FS_SAT; goto Done; } } Unsat: f->lastResult = FS_UNSAT; Done: fslog(f, "solve", 1, "instance is %s\n", funcsatResultAsString(f->lastResult)); assert(f->lastResult != FS_SAT || f->trail.size == f->numVars); finishSolving(f); return f->lastResult; } @ Some notes about the external API. Funcsat returns results using the following datatype. The codes are the typical codes used for \SAT\ solvers in the \SAT\ competition. @<External ty...@>= typedef enum { FS_UNKNOWN = 0, FS_SAT = 10, FS_UNSAT = 20 } funcsat_result; @ @<External decl...@>= void funcsatCheck(funcsat *f, funcsat_result r); @ @<Global def...@>= void funcsatCheck(funcsat *f, funcsat_result r) { assert(r == f->lastResult); if (r == FS_SAT) { for_vec_uintptr (ix_cl, f->orig_clauses) { @<Check that |ix_cl| is satisfied@>@; } for_vec_uintptr (ix_cl, f->learned_clauses) { @<Check that |ix_cl| is satisfied@>@; } } } @ @<Check that |ix_cl| is satisfied@>= struct clause_iter it; bool sat = false; clause_iter_init(f, *ix_cl, &it); for (literal *p = clause_iter_next(f, &it); p; p = clause_iter_next(f, &it)) { assert(funcsatValue(f, *p) != unknown); if (funcsatValue(f, *p) == true) { sat = true; break; } } assert(sat); @*2 Solver type. \funcsat\ has a bunch of members. @d Unassigned (-1) @<Main \funcsat\ type@>= struct funcsat_config; struct clause_head; struct clause_block; struct funcsat { struct funcsat_config *conf; /*Added by SEAN!!!*/ uint8_t (*Backtrack_hook)(uintptr_t *_SM, uintmax_t level); uint8_t (*BCP_hook)(uintptr_t *_SM, uintmax_t nVariable, uint8_t bPolarity); void (*MakeDecision_hook)(uintptr_t *_SM); intmax_t (*ExternalHeuristic_hook)(uintptr_t *_SM); clause assumptions; /* assumptions as given by the user */ funcsat_result lastResult; /* result of the last incremental call */ uintmax_t decisionLevel; /* current decision level */ uintmax_t propq; /* Unit propagation queue, which is an index into |funcsat->trail|. The element pointed at by |propq| is the first literal to propagate. {\it Invariant:} If |propq| is |funcsat->trail.size|, then the queue is empty. */ clause trail; /* Current (partial) assignment stack. */ struct vec_uintmax model; /* If a variable is assigned (see |funcsat->level|), contains the index of the literal in the trail. \todo\ bitpack */ clause phase; /* Stores the current, or last, phase of each variable (for phase saving). */ clause level; /* Records the decision level of each variable. If a variable is unset, its |level| is |Unassigned|. */ struct vec_uintmax decisions; /* For each decision variable, this maps to its decision level. A non-decision variable maps to 0. */ struct vec_uintptr *reason; /* Maps a variable to the (index for the) |struct reason| that became unit to cause a variable assignment (see |funcsat->reason_infos|). The reason is |NO_CLS| if the variable is a decision variable. */ struct vec_ptr reason_hooks; /* Indexed by types, returns a function pointer that calculates a clause given a |funcsat| and a |literal|. */ struct vec_reason_info *reason_infos; /* It is not safe to take pointers of these values because this vector can be realloc'd. */ uintptr_t reason_infos_freelist; /* index of first free |reason_info| */ head_tail *unit_facts; /* Indexed by variable, each each |head_tail| list points to a linked list of clauses. */ uintmax_t unit_facts_size; uintmax_t unit_facts_capacity; head_tail *jail; /* Indexed by variable, each mapped to a |head_tail| list. Each list contains only clauses currently satisfied by the associated variable. */ all_watches watches; /* Indexed from literals (using |fs_lit2idx|) into a |watcherlist|. */ struct vec_uintptr *orig_clauses; /* A list of all the original clauses. */ struct vec_uintptr *learned_clauses; /* A list of all the learned clauses. */ uintmax_t numVars; struct clause_head_pool clheads; struct clause_block_pool clblocks; uintptr_t conflict_clause; /* When unit propagation discovers a conflicting clause, its index is stashed here. */ struct litpos litpos_uip; /* used during conflict analysis */ clause uipClause; /* Working area for the clause we will eventually learn during conflict analysis. */ struct vec_ptr subsumed; /* list of subsumed clauses. used by clause learning. */ uintmax_t LBD_count; /* \LBD\ heuristic stuff -- see |LBD_compute_score| */ struct vec_uint64 LBD_levels; /* \LBD\ heuristic stuff -- see |LBD_compute_score| */ struct vec_uint64 LBD_histogram; uint64_t LBD_last_num_conflicts; uint64_t LBD_base; uint64_t LBD_increment; double claDecay; /* clause activities */ double claInc; double learnedSizeFactor; /* when doing clause-activity based gc, this is the initial limit for learned clauses, a fraction of the original clauses (as in minisat 2.2.0) */ double maxLearned; double learnedSizeAdjustConfl; uint64_t learnedSizeAdjustCnt; uint64_t learnedSizeAdjustInc; double learnedSizeInc; struct vec_uintmax seen; /* conflict clause minimisation stuff */ struct vec_intmax analyseToClear; struct vec_uintmax analyseStack; /* dfs stack */ struct vec_uintmax allLevels; /* set of the levels-of-vars that occur in the clause */ double varInc; /* dynamic variable order stuff */ double varDecay; struct bh_node *binvar_heap; /* binary heap of variables */ uintmax_t binvar_heap_size; /* number of elements in |binvar_heap| */ uintmax_t *binvar_pos; /* locations of each var in the heap */ int64_t lrestart; /* luby restart stuff -- cribbed from \picosat */ uint64_t lubycnt; uint64_t lubymaxdelta; bool waslubymaxdelta; struct drand48_data *rand; uint64_t numSolves; /* Number of calls to ::funcsatSolve */ uint64_t numLearnedClauses; /* How many learned clauses */ uint64_t numSweeps; /* How many times we deleted learned clauses */ uint64_t numLearnedDeleted; /* How many learned clauses we deleted */ uint64_t numLiteralsDeleted; /* How many literals deleted from learned clauses as we simplify them */ uint64_t numProps; /* How many unit propagations */ uint64_t numUnitFactProps; uint64_t numJails; uint64_t numConflicts; /* How many conflicts */ uint64_t numResolutions; uint64_t numRestarts; /* How many restarts */ uint64_t numDecisions; /* How many decisions */ uint64_t numSubsumptions; /* How many times a clause was simplified due to self-subsuming resolution */ uint64_t numSubsumedOrigClauses; /* How many subsumption simplifications were done for original clauses */ uint64_t numSubsumptionUips; }; @*2 Adding clauses. The main solver interface is just a few functions. @<Global def...@>= funcsat_result funcsatAddClause(funcsat *f, clause *c) { variable maxVar = 0; uintptr_t ix_cl; struct clause_head *cl; funcsatReset(f); if (c->size > 1) { /* a few trivial clause simplifications */ uintmax_t size = c->size; literal *i, *j, *end; sortClause(c); /* i is current, j is target */ for (i = j = (literal *)c->data, end = i + c->size; i != end; i++) { literal p = *i, q = *j; if (i != j) { if (p == q) { /* duplicate literal */ size--; continue; } else if (p == -q) { /* trivial clause */ clauseDestroy(c); goto Done; } else *(++j) = p; } } c->size = size; } for (variable k = 0; k < c->size; k++) { variable v = fs_lit2var(c->data[k]); maxVar = v > maxVar ? v : maxVar; } funcsatResize(f, maxVar); ix_cl = clause_head_alloc_from_clause(f,c); cl = clause_head_ptr(f, ix_cl); cl->is_learned = false; cl->is_reason = false; cl->lbd_score = LBD_SCORE_MAX; cl->activity = 0.f; f->conf->bumpOriginal(f, ix_cl); fs_ifdbg (f, "solve", 2) { fslog(f, "solve", 2, "adding %ju ", funcsatNumClauses(f)+1); fs_clause_print(f, fs_dbgout(f), c); fprintf(fs_dbgout(f), "\n"); } funcsat_result clauseResult = addClause(f, ix_cl); if (f->lastResult != FS_UNSAT) { f->lastResult = clauseResult; } vec_uintptr_push(f->orig_clauses, ix_cl); Done: return f->lastResult; } @ When adding a clause we need to allocate an internal |clause_head| for it. This function creates a new clause with exactly the same literals (in the same order) as |c|. It returns the new |clause_head|'s index. @<Global def...@>= inline uintptr_t clause_head_alloc_from_clause(funcsat *f, clause *c) { uintmax_t sz_orig = c->size; uintptr_t ix_cl = clause_head_mk(f, c->size); struct clause_head *cl = clause_head_ptr(f, ix_cl); intmax_t sz_copied = 0; /* use this index to keep the order of |c| */ for (int i = 0; i < CLAUSE_HEAD_SIZE && sz_copied < c->size; i++) { /* copy head literals */ cl->lits[i] = c->data[sz_copied++]; cl->sz++; } if (sz_copied < c->size) { /* create first block */ uintptr_t ix_bl = clause_block_from_clause(f, c, cl, &sz_copied); cl->nx = ix_bl; while (sz_copied < c->size) { /* create additional blocks */ struct clause_block *bl; uintptr_t ix_bl_nx = clause_block_from_clause(f, c, cl, &sz_copied); bl = clause_block_ptr(f, ix_bl); bl->nx = ix_bl = ix_bl_nx; } } assert(cl->sz == sz_orig); return ix_cl; } @ Copies literals (up to |CLAUSE_BLOCK_SIZE| of them) from |c| beginning at |sz_copied| into a fresh block, whose index is returned. @<Global def...@>= static inline uintptr_t clause_block_from_clause(funcsat *f, clause *c, struct clause_head *cl, intmax_t *sz_copied) { uintptr_t ix_bl = clause_block_mk(f); struct clause_block *bl = clause_block_ptr(f, ix_bl); for (int i = 0; i < CLAUSE_BLOCK_SIZE && *sz_copied < c->size; i++) { bl->lits[i] = c->data[(*sz_copied)++]; cl->sz++; } return ix_bl; } @ @<Internal decl...@>= static inline uintptr_t clause_block_from_clause(funcsat *f, clause *c, struct clause_head *cl, intmax_t *ix_clause); @ Prototype. @<External decl...@>= funcsat_result funcsatAddClause(funcsat *func, clause *clause); extern uintptr_t clause_head_alloc_from_clause(funcsat *f, clause *c); @ Add the initialized internal clause to the watcher or unit fact lists. This may cause the solver to be in conflict. Precondition: the decision level is 0. @<Global def...@>= static inline funcsat_result addClause(funcsat *f, uintptr_t ix_cl) { struct clause_head *h = clause_head_ptr(f, ix_cl); funcsat_result result = FS_UNKNOWN; assert(f->decisionLevel == 0); h->is_learned = false; if (h->sz == 0) { f->conflict_clause = ix_cl; result = FS_UNSAT; } else if (h->sz == 1) { mbool val = funcsatValue(f, h->lits[0]); if (val == false) { f->conflict_clause = ix_cl; result = FS_UNSAT; } else { if (val == unknown) { trailPush(f, h->lits[0], reason_info_mk(f, ix_cl)); head_tail_add(f, &f->unit_facts[fs_lit2var(h->lits[0])], ix_cl); } } } else addWatch(f, ix_cl); return result; } @ @<Internal decl...@>= static inline funcsat_result addClause(funcsat *f, uintptr_t ix_cl); @*2 Unit assumptions. \funcsat\ supports solving under any number of unit assumptions, like similar solvers such as \minisat\ and \picosat. But our interface behaves a bit differently. \numberedlist \li |funcsatPushAssumption(f,x)| adds a unit assumption |x|. This means that every time |funcsatSolve| is called from now on (unless you manipulate the assumptions again), all satisfying assignments must have |x| set to true. If the solver returns |FS_UNSAT|, that means there exists no satisfying assignment where |x| holds. It says {\it nothing} about satisfying assignments where |-x| holds. {\bf You must check the return value of |funcsatPushAssumption|!} If it ever returns |FS_UNSAT|, it means the assumption was false and you should take appropriate action before solving. \li |funcsatPopAssumption| will remove the last unit assumption pushed (call it |x|). All subsequent calls (unless you manipulate the assumptions again) will not be sensitive to any particular assignment to |x|. \li Therefore, assumptions are ordered in a LIFO stack. \li Unlike \picosat, the solver \textit{never} implicitly removes assumptions after a call to |funcsatSolve|. \endnumberedlist @<Global def...@>= funcsat_result funcsatPushAssumption(funcsat *f, literal p) { if(p == 0) { /*This is a hack to get the assumption stacks of bitfunc and funcsat to be the same size*/ clausePush(&f->assumptions, 0); return FS_UNKNOWN; } f->conf->minimizeLearnedClauses = false; backtrack(f, 0UL, NULL, true); /* in a weird case, there are no clauses but some assumptions, so resize */ funcsatResize(f, fs_lit2var(p)); if (funcsatValue(f, p) == false) { return FS_UNSAT; } else if (funcsatValue(f, p) == unknown) { /* copy over assumptions that matter */ clausePush(&f->assumptions, p); trailPush(f, p, NO_CLS); } else { clausePush(&f->assumptions, 0); } return FS_UNKNOWN; } funcsat_result funcsatPushAssumptions(funcsat *f, clause *c) { for(uintmax_t i = 0; i < c->size; i++) { if(funcsatPushAssumption(f, c->data[i]) == FS_UNSAT) { funcsatPopAssumptions(f, i); return FS_UNSAT; } } return FS_UNKNOWN; } @ @<Global def...@>= void funcsatPopAssumptions(funcsat *f, uintmax_t num) { head_tail facts; head_tail_clear(&facts); assert(num <= f->assumptions.size); backtrack(f, 0, NULL, true); for (uintmax_t i = 0; i < num; i++) { literal p = clausePop(&f->assumptions); if (p == 0) return; literal t = trailPop(f, &facts); while (p != t) { t = trailPop(f, &facts); } } restore_facts(f, &facts); } @ At any point during solving, we can forcibly reset the solver state using this function. It does {\it not} remove any assumptions. @<Global def...@>= void funcsatReset(funcsat *f) { f->conflict_clause = NO_CLS; backtrack(f, 0UL, NULL, true); f->propq = 0; f->lastResult = FS_UNKNOWN; } @*1 Clauses. \definexref{pg-clauses}{\folio}{page}Clauses, as the client sees them, are represented thusly. @<External ty...@>= typedef struct clause { literal *data; uint32_t size; uint32_t capacity; uint32_t isLearnt : 1; uint32_t isReason : 1; uint32_t is_watched : 1; /* in the watched literals for the first 2 literals of the clause */ double activity; struct clause *nx; } clause; @ Function prototypes for allocation, mutation, and deletion of clauses. @<External decl...@>= clause *clauseAlloc(uint32_t capacity); /* creates empty clause */ void clauseInit(clause *v, uint32_t capacity); /* initializes manually malloc'd clause */ void clauseDestroy(clause *); /* Frees the underlying literal buffer and resets clause metadata. Does not free the given pointer. */ void clauseFree(clause *);/* Calls |clauseDestroy| then frees the clause. */ void clauseClear(clause *v); /* Clear the contents of the clause. Does not touch reference count or list links. */ void clausePush(clause *v, literal data); /* Allocates space (if necessary) for another literal; then appends the given literal. */ void clausePushAt(clause *v, literal data, uint32_t i); void clauseGrowTo(clause *v, uint32_t newCapacity); literal clausePop(clause *v); literal clausePopAt(clause *v, uint32_t i); literal clausePeek(clause *v); void clauseCopy(clause *dst, clause *src); /* Copies all the literals and associated metadata, but the |dst| reference count is 1. */ #define forClause(elt, vec) for (elt = (vec)->data; elt != (vec)->data + (vec)->size; elt++) #define for_clause(elt, cl) for (elt = (cl)->data; elt != (cl)->data + (cl)->size; elt++) #define for_clause99(elt, cl) for (literal *elt = (cl)->data; \ elt != (cl)->data + (cl)->size; elt++) @ @<Global def...@>= void clauseInit(clause *v, uint32_t capacity) { uint32_t c = capacity > 0 ? capacity : 4; FS_CALLOC(v->data, c, sizeof(*v->data)); v->size = 0; v->capacity = c; v->isLearnt = false; v->nx = NULL; v->is_watched = false; v->isReason = false; v->activity = 0.f; } void clauseFree(clause *v) { clauseDestroy(v); free(v); } void clauseDestroy(clause *v) { free(v->data); v->data = NULL; v->size = 0; v->capacity = 0; v->isLearnt = false; } void clauseClear(clause *v) { v->size = 0; v->isLearnt = false; } void clausePush(clause *v, literal data) { if (v->capacity <= v->size) { while (v->capacity <= v->size) { v->capacity = v->capacity*2+1; } FS_REALLOC(v->data, v->capacity, sizeof(*v->data)); } v->data[v->size++] = data; } void clausePushAt(clause *v, literal data, uint32_t i) { uint32_t j; assert(i <= v->size); if (v->capacity <= v->size) { while (v->capacity <= v->size) { v->capacity = v->capacity*2+1; } FS_REALLOC(v->data, v->capacity, sizeof(*v->data)); } v->size++; for (j = v->size-(uint32_t)1; j > i; j--) { v->data[j] = v->data[j-1]; } v->data[i] = data; } void clauseGrowTo(clause *v, uint32_t newCapacity) { if (v->capacity < newCapacity) { v->capacity = newCapacity; FS_REALLOC(v->data, v->capacity, sizeof(*v->data)); } assert(v->capacity >= newCapacity); } literal clausePop(clause *v) { assert(v->size != 0); return v->data[v->size-- - 1]; } literal clausePopAt(clause *v, uint32_t i) { uint32_t j; assert(v->size != 0); literal res = v->data[i]; for (j = i; j < v->size-(uint32_t)1; j++) { v->data[j] = v->data[j+1]; } v->size--; return res; } literal clausePeek(clause *v) { assert(v->size != 0); if(v->size == 0) { v->size = 1; return 0; } return v->data[v->size-1]; } void clauseSet(clause *v, uint32_t i, literal p) { v->data[i] = p; } void clauseCopy(clause *dst, clause *src) { literal i; for (i = 0; i < src->size; i++) { clausePush(dst, src->data[i]); } dst->isLearnt = src->isLearnt; } @ @<Global def...@>= void fs_clause_print(funcsat *f, FILE *out, clause *c) { if (!out) out = stderr; literal *p; for_clause (p,c) { fprintf(out, "%ji_%ji%s ", *p, levelOf(f, fs_lit2var(*p)), (funcsatValue(f, *p) == true ? "T" : (funcsatValue(f, *p) == false ? "F" : "U"))); } } @ Print |clause|. @<Global def...@>= void dimacsPrintClause(FILE *out, clause *c) { literal *p; if (!out) out = stderr; for_clause (p, c) { fprintf(out, "%ji ", *p); } fprintf(out, "0"); } @ @<Internal decl...@>= void fs_clause_print(funcsat *f, FILE *out, clause *c); void dimacsPrintClause(FILE *out, clause *c); @*2 Internal clauses. \numberedlist \li Clause heads will be separate from the ``rest'' of the clause. In fact, all clauses will be chunked into head and body parts. There is one head and various body parts. Each clause is referred to by a single index, a |uintptr_t|. See the macros |clause_head_ptr| and |clause_block_ptr|. \li The activity and the score need to be unified. First of all, the \LBD\ score has way too many bits. After about \osf{5} bits of information all the \LBD s blend together. The activity is slightly murkier because it's a float. Either I need to (\osf{1}) create custom float operations packed into 28 bits or (\osf{2}) using the int and make the activity recording work anyway. Not sure at the moment how to do either but I know \picosat\ does (\osf{1}). (Can I get away with fixed-point floats?) \endnumberedlist So here's the new |clause_head| data structure. The |lits| is |CLAUSE_HEAD_SIZE| literals. |nx| is an index it's an index into |f->clblocks|. The |clause_block| is similar. If the clause terminates in this block, then |nx| is |NO_CLS|. If there is a spot for it, the literal after the last literal in the clause is a 0. If there isn't a spot for it, then |lits| just has all the literals. Each clause block will be allocated from the huge array, |f->clblocks|. When due to simplification or garbage collection a clause block is released, it is put back onto the freelist of clause blocks. |f->block_freelist| is the index of the first free |clause_block| in the freelist. @s clause_head int @s clause_block int @s clause_state int @<Internal ty...@>= #ifndef CLAUSE_HEAD_SIZE # define CLAUSE_HEAD_SIZE 7 /* odd because of |clause_head->nx| */ #endif #ifndef CLAUSE_BLOCK_SIZE # define CLAUSE_BLOCK_SIZE 7 /* odd because of |clause_block->nx| */ #endif enum clause_state { CLAUSE_WATCHED=1, /* in watchlist */ CLAUSE_JAILED, /* in jail */ CLAUSE_UNIT /* in unit facts, don't GC */ }; #define NO_CLS UINTPTR_MAX #define LBD_SCORE_MAX 0x3f struct clause_head { literal lits[CLAUSE_HEAD_SIZE]; /* first few literals */ uintptr_t nx; /* index of first block, or |NO_CLS| if none */ uintptr_t link; /* used by |head_tail| lists. |NO_CLS| initially */ uint32_t is_learned : 1; uint32_t is_reason : 1; /* pinned, don't GC */ uint32_t where : 2; /* see |clause_state| */ uint32_t lbd_score : 6; /* also |LBD_SCORE_MAX| */ uint32_t sz : 22; /* max num lits is 2**22 */ float activity; }; #include "funcsat/vec_clause_head.h" struct clause_block { literal lits[CLAUSE_BLOCK_SIZE]; uintptr_t nx; /* index of next block, or |NO_CLS| if none */ }; #include "funcsat/vec_clause_block.h" @ In the |funcsat| type we need to store a vector of clause heads/blocks along with a freelist pointer. @<Internal ty...@>= struct clause_head_pool { uintptr_t freelist; struct vec_clause_head *heads; }; struct clause_block_pool { uintptr_t freelist; struct vec_clause_block *blocks; }; @ What is the lifecycle of a clause? And why should you care? If the lifecycle is in one place, it's easy to figure out whether later clause modifications will efficiently support the needed operations. \unorderedlist \li While the client is constructing the CNF instance (or it's being read from disk), the clause is being built and eventually is given to |funcsatAddClause|. \orderedlist \li If the clause is empty, the solver becomes immediately conflicted. \li If the clause is singleton, we put it on the trail and attach it as a {\it unit fact} to the newly-added trail literal. \li If it's binary, it's put in the binary watcher list and it will never be garbage collected. \li Otherwise, it's put in the normal watchlist for the clause. \endorderedlist \li Once all the clauses are added the search begins. At this point a clause can become the {\it reason} for an inference. This means the clause was unit at the time it implied a literal. \li During backtracking a clause (especially learned) may transition to a unit fact list which is eventually associated with a particular literal on the trail. It may stay on a unit fact list across other decisions, inferences, and backtracks. (But not across restarts unless it's a singleton.) \li During \BCP\ a clause can be {\it jailed}, meaning it's removed from its watchlists and put into a shadow watchlist while it's satisfied. It is restored to the watchlists once it becomes unsatisfied. (It does {\it not} go through any unit fact list.) \li A literal could be completely deleted from a clause if a literal in the clause becomes true at decision level 0. \endunorderedlist When a garbage collection is triggered, the clause could be in any of these states. Assuming the clause is not pinned, it is returned to the clause pool. A clause is {\it pinned} when any of the following hold: \unorderedlist \li The clause is in a unit fact list. \li The clause is currently the {\it reason} for an inference. \li The clause is binary (we keep them all around). \endunorderedlist @ Initialize the pools for heads and blocks. @d INITIAL_CLAUSE_POOL 1024 @<Initialize func...@>= f->clheads.freelist = NO_CLS; f->clheads.heads = vec_clause_head_init(INITIAL_CLAUSE_POOL); f->clblocks.freelist = NO_CLS; f->clblocks.blocks = vec_clause_block_init(INITIAL_CLAUSE_POOL); for (uintptr_t i = 0; i < INITIAL_CLAUSE_POOL; i++) { clause_head_release(f,i); clause_block_release(f,i); } @ Free the pools. @<Destroy func...@>= vec_clause_head_destroy(f->clheads.heads); vec_clause_block_destroy(f->clblocks.blocks); f->clheads.freelist = NO_CLS; f->clheads.freelist = NO_CLS; @ Retrieving new clauses. The |capacity| of the vec is how many blocks are initially available; if we need to allocate more, we simply allocate more memory. The |size| field is ignored. @<Internal decl...@>= static inline struct clause_head *clause_head_ptr(funcsat *f, uintptr_t i) { return (assert((i) < (f)->clheads.heads->capacity),(f)->clheads.heads->data+(i)); } static inline struct clause_block *clause_block_ptr(funcsat *f, uintptr_t i) { return (assert((i) < (f)->clblocks.blocks->capacity),(f)->clblocks.blocks->data+(i)); } @ To allocate a clause head we find the first head in the freelist, allocating new space if necessary. In the fast case, when there is a free head available, this operation takes constant time. In the slow case we allocate a bunch of new heads and put them into the freelist. @<Global def...@>= static inline uintptr_t clause_head_mk(funcsat *f, uint32_t sz_hint) { const uintptr_t cap = f->clheads.heads->capacity; uintptr_t freelist = f->clheads.freelist; if (freelist >= cap) { /* resize if necessary */ vec_clause_head_grow_to(f->clheads.heads, cap*2); for (uintptr_t i = cap; i < f->clheads.heads->capacity; i++) { clause_head_release(f,i); } } struct clause_head *h = clause_head_ptr(f, freelist = f->clheads.freelist); f->clheads.freelist = h->nx; /* use |h->nx| before we clobber it */ memset(h, 0, sizeof(*h)); h->nx = h->link = NO_CLS; return freelist; } static inline uintptr_t clause_block_mk(funcsat *f) { const uintptr_t cap = f->clblocks.blocks->capacity; uintptr_t freelist = f->clblocks.freelist; if (freelist >= cap) { /* resize if necessary */ vec_clause_block_grow_to(f->clblocks.blocks, cap*2); for (uintptr_t i = cap; i < f->clblocks.blocks->capacity; i++) { clause_block_release(f,i); } } struct clause_block *h = clause_block_ptr(f, freelist = f->clblocks.freelist); f->clblocks.freelist = h->nx; /* use |h->nx| before we clobber it */ memset(h, 0, sizeof(*h)); h->nx = NO_CLS; return freelist; } @ Return the clause to the pool. @<Global def...@>= static inline void clause_head_release(funcsat *f, uintptr_t ix) { assert(ix < f->clheads.heads->capacity); struct clause_head *h = clause_head_ptr(f,ix); assert(memset(h, 0, sizeof(struct clause_head))); h->nx = f->clheads.freelist, f->clheads.freelist = ix; } static inline void clause_block_release(funcsat *f, uintptr_t ix) { assert(ix < f->clblocks.blocks->capacity); struct clause_block *h = clause_block_ptr(f,ix); assert(memset(h, 0, sizeof(struct clause_block))); h->nx = f->clblocks.freelist, f->clblocks.freelist = ix; } @ To return a complete clause, blocks and everything, to the pool. @<Global def...@>= static inline void clause_release(funcsat *f, uintptr_t ix) { struct clause_head *h = clause_head_ptr(f, ix); struct clause_block *b; uintptr_t nx = h->nx; clause_head_release(f, ix); while (nx != NO_CLS) { uintptr_t nx_nx = clause_block_ptr(f, nx)->nx; clause_block_release(f, nx); nx = nx_nx; } } @ Iterating over clauses. The iterator type is somewhat complex, unfortunately. @<Internal ty...@>= struct clause_iter { int16_t l_ix; /* can be tiny because it only indexes into a block at a time */ bool is_head; uint32_t sz; union { struct clause_head *h; struct clause_block *b; }; }; @ Steps for iterating: \unorderedlist \li |clause_iter_init(f,i,it)|: initialize an iterator |it|. You must call |clause_iter_next| to get the next element. \li |clause_iter_next|: if it returns a non-|NULL| pointer, then it points to a |literal|. \endunorderedlist @<Global def...@>= void clause_iter_init(funcsat *f, uintptr_t ix_clause_head, struct clause_iter *it) { struct clause_head *h = clause_head_ptr(f, ix_clause_head); it->l_ix = -1; it->is_head = true; it->h = h; it->sz = h->sz; } #define clause_iter_lit_ptr(f, it) ((it)->is_head ? \ (it)->h->lits+(it)->l_ix : \ (it)->b->lits+(it)->l_ix) literal *clause_iter_next(funcsat *f, struct clause_iter *it) { literal *lit = NULL; if (it->sz == 0) return NULL; ++it->l_ix; if (it->is_head) { if (it->l_ix >= CLAUSE_HEAD_SIZE) { /* go to first block */ assert(it->h->nx != NO_CLS); it->is_head = false; it->b = clause_block_ptr(f, it->h->nx); it->l_ix = 0; } } else { if (it->l_ix >= CLAUSE_BLOCK_SIZE) { /* go to next block */ assert(it->b->nx != NO_CLS); it->b = clause_block_ptr(f, it->b->nx); it->l_ix = 0; } } lit = clause_iter_lit_ptr(f, it); it->sz--; return lit; } @ Make printing convenient. @<Global def...@>= void fs_clause_head_print(funcsat *f, FILE *out, uintptr_t ix) { if (!out) out = stderr; struct clause_iter it; clause_iter_init(f, ix, &it); for (literal *p = clause_iter_next(f, &it); p; p = clause_iter_next(f, &it)) { fprintf(out, "%ji_%ji%s ", *p, levelOf(f, fs_lit2var(*p)), (funcsatValue(f, *p) == true ? "T" : (funcsatValue(f, *p) == false ? "F" : "U"))); } } void clause_head_print_dimacs(funcsat *f, FILE *out, uintptr_t ix) { struct clause_iter it; if (!out) out = stderr; if (ix == NO_CLS) { fprintf(out, "(NULL CLAUSE)"); return; } clause_iter_init(f, ix, &it); for (literal *p = clause_iter_next(f, &it); p; p = clause_iter_next(f, &it)) { fprintf(out, "%ji ", *p); } fprintf(out, "0"); } void vec_clause_head_print_dimacs(funcsat *f, FILE *stream, struct vec_uintptr *clauses) { for_vec_uintptr (ix, clauses) { clause_head_print_dimacs(f, stream, *ix); fprintf(stream, "\n"); } } @ Prototypes. @<Internal decl...@>= static inline uintptr_t clause_head_mk(funcsat *f, uint32_t sz_hint); static inline uintptr_t clause_block_mk(funcsat *f); static inline void clause_head_release(funcsat *f, uintptr_t ix); static inline void clause_block_release(funcsat *f, uintptr_t ix); static inline void clause_releas(funcsat *f, uintptr_t ix); void clause_iter_init(funcsat *f, uintptr_t ix_clause_head, struct clause_iter *it); literal *clause_iter_next(funcsat *f, struct clause_iter *it); void fs_clause_head_print(funcsat *f, FILE *out, uintptr_t ix); void clause_head_print_dimacs(funcsat *f, FILE *out, uintptr_t); void vec_clause_head_print_dimacs(funcsat *f, FILE *out, struct vec_uintptr *); @ @<Initialize func...@>= f->orig_clauses = vec_uintptr_init(2); f->learned_clauses = vec_uintptr_init(2); @ Destroy @<Destroy func...@>= vec_uintptr_destroy(f->orig_clauses); vec_uintptr_destroy(f->learned_clauses); @*2 Head-tail lists. Sometimes we use a head-tail representation for lists of clauses. The |head_tail| structure points at the initial clause and the last clause. The clauses in between the head and the tail are found by walking each |clause->nx| pointer. Using these scheme we can append two such lists in constant time. @<Internal ty...@>= typedef struct head_tail { uintptr_t hd; /* |NO_CLS| used if empty */ uintptr_t tl; } head_tail; @ Clearing and testing for emptiness should be clear (ha!) enough. @<Global def...@>= static inline void head_tail_clear(head_tail *ht) { ht->hd = ht->tl = NO_CLS; } static inline bool head_tail_is_empty(head_tail *ht) { return ht->hd == NO_CLS && ht->tl == NO_CLS; } @ The result will be stored in |ht1|. If we think of |ht1| as a list $x_1\rightarrow\cdots\rightarrow x_m$ and |ht2| as a list $y_1\rightarrow\cdots\rightarrow y_n$ then we want to make |ht1| the list $x_1\rightarrow\cdots\rightarrow x_m\rightarrow y_1\rightarrow\cdots\rightarrow y_n$ in that order. The complication is that either or both lists may be empty. But we need to: \unorderedlist \li If $m>0$, adjust $x_m$'s |link| to be $y_1$. (If $n=0$, this will simply reinforce that $x_m$|->link| is |NO_CLS|.) \li If $n>0$, adjust |ht1|'s |tl| to be $y_n$. (And if |ht1| is empty we make sure to make it start at $y_1$. \endunorderedlist @<Global def...@>= static inline void head_tail_append(funcsat *f, head_tail *ht1, head_tail *ht2) { if (ht1->tl != NO_CLS) clause_head_ptr(f, ht1->tl)->link = ht2->hd; if (ht2->tl != NO_CLS) { ht1->tl = ht2->tl; if (ht1->hd == NO_CLS) ht1->hd = ht2->hd; } head_tail_clear(ht2); #if 0 if (!head_tail_is_empty(ht2)) { if (head_tail_is_empty(ht1)) { ht1->hd = ht2->hd; } else { struct clause_head *cl_tl = clause_head_ptr(f, ht1->tl); assert(ht1->hd != NO_CLS); assert(cl_tl->link == NO_CLS); cl_tl->link = ht2->hd; } ht1->tl = ht2->tl; } #endif } @ Adding a single clause to the list is a special case of |head_tail_append|. @<Global def...@>= static inline void head_tail_add(funcsat *f, head_tail *ht1, uintptr_t ix) { head_tail ht2; ht2.hd = ht2.tl = ix; head_tail_append(f, ht1, &ht2); #if 0 struct clause_head *c = clause_head_ptr(f, ix); c->link = ht1->hd; ht1->hd = ix; if (ht1->tl == NO_CLS) { ht1->tl = ix; } #endif } @ @<Internal decl...@>= static inline void head_tail_clear(head_tail *ht); static inline bool head_tail_is_empty(head_tail *ht); static inline void head_tail_append(funcsat *f, head_tail *ht1, head_tail *ht2); static inline void head_tail_add(funcsat *f, head_tail *ht1, uintptr_t); @ Iterating over a |head_tail| list is slightly tricky. The common case is iterating and doing something to each element, without removing it. That's pretty easy. But often we want to preserve some elements in the list and delete others, while we iterate. That's what |head_tail_iter_rm| is for. It deletes the |curr| element from the list and sets |curr->nx| to |NULL|. The iterator can therefore detect that |curr| has been deleted (by testing its link field) and not update the |prev| pointer when that happens. @d for_head_tail(f, ht, prev, curr, next) /* iterate over all the clauses in the list */ for (prev = next = NO_CLS, curr = (ht)->hd, ((curr != NO_CLS) ? next = clause_head_ptr(f, (curr))->link : 0);@/ (curr != NO_CLS);@/ (clause_head_ptr(f, (curr))->link != NO_CLS ? prev = (curr) : 0), curr = (next), ((curr != NO_CLS) ? next = clause_head_ptr(f, (curr))->link : 0)) @d head_tail_iter_rm(f, ht, prev, curr, next) /* delete |curr| from iteration */ if ((ht)->hd == (curr)) { /* fix up |hd| and |tl| fields */ (ht)->hd = (next); } if ((ht)->tl == (curr)) { (ht)->tl = (prev); } if (prev != NO_CLS) { clause_head_ptr(f, (prev))->link = (next); } clause_head_ptr(f, (curr))->link = NO_CLS; @c @ @<Global def...@>= inline void head_tail_print(funcsat *f, FILE *out, head_tail *l) { if (!out) out = stderr; if (l->hd) { uintptr_t p, c, nx; for_head_tail (f, l, p, c, nx) { struct clause_head *h = clause_head_ptr(f,c); if (h->link == NO_CLS && l->tl != c) { fprintf(out, "warning: tl is not last clause\n"); } fs_clause_head_print(f, out, c); fprintf(out, "\n"); } } else if (l->tl != NO_CLS) { fprintf(out, "warning: hd unset but tl set!\n"); } } @ @<Internal decl...@>= extern void head_tail_print(funcsat *f, FILE *out, head_tail *l); @*1 BCP. How does \funcsat's \BCP\ work? Here's the signature. @<Internal decl...@>= bool bcp(funcsat *f); @ First, there's this notion of a {\it propagation queue} (|funcsat->propq|). It is an index into the trail. It is the index of the earliest literal on the trail that should be examined by \BCP. \BCP\ examines each literal, beginning with the first in the propagation queue, until there are no more inferences or it finds a conflict. If we discover a conflict, |bcp| returns |false| and sets |funcsat->conflictClause| to the clause that is false. Otherwise it returns |true|. @<Global def...@>= bool bcp(funcsat *f) { bool isConsistent = true; while (f->propq < f->trail.size) { @<\BCP\ clauses@>@; if(f->BCP_hook) { if(f->BCP_hook((uintptr_t *)f->conf->user, imaxabs(p), p > 0) == FS_UNSAT) { isConsistent = false; goto bcp_conflict; } } } bcp_conflict: return isConsistent; } @ We put learned clauses in our normal watchlists. Each clause knows whether it's learned or not. \numberedlist \li Con: when garbage collection is done, the learned watchlists are entirely recreated. This is easiest because the GC can sort all the clauses by score, delete the worst half, and recreate the watchlists. How could this be resolved? \numberedlist \li Can I add some information to the clauses themselves and GC them during \BCP? (This might be bad because it might make \BCP\ slow. But let's have some faith in branch prediction on processors, shall we?) \li At first, I'll ignore cleaning learned clauses. Next, I'll do a special walk over the whole watcher list and clean out certain of the learned clauses. Next, I'll think of some queue-of-craptastry in order to drop clauses more dynamically and in a fine-grained way. \endnumberedlist \li Pro: every single watched literal operation does not have to be duplicated for the original and learned lists, in the other representation. This is annoying. \endnumberedlist @ Here we are using a representation inspired by the ``Cache-conscious SAT'' paper. The watched literal structure is indexed by literals. At each index is stored a |watchlist|, which points to a number of |watchlist_elt|s. The meaning of a |watchlist_elt| differs depending on the clause: \numberedlist \li For large clauses: a literal from the clause (|lit|), clause index (|cls|). (This is different from the paper. I can't figure out how they managed to keep the {\it first} literal in the |watchlist_elt| at all times!) \li For binary clauses: the other literal (|lit|), clause index (|cls|). (This situation is different from the paper; there the clause index was unused. We need it because we always store a clause index to each clauses that is a {\it reason} for an inference.) \endnumberedlist @<Internal ty...@>= struct watchlist_elt { literal lit; uintptr_t cls; }; @ Here's the |watchlist|, which represents the list of clauses associated with a single watched literal. Each |watchlist| stores a small number of clauses in its head, because often the watch lists are small. If the watch list is small, we don't need to fetch anything else from memory in order to propagate this watch list. I chose a size of 12 for |WATCHLIST_HEAD_SIZE_MAX| because I felt like it. And because it was in the paper. @<Internal ty...@>= #ifndef WATCHLIST_HEAD_SIZE_MAX # define WATCHLIST_HEAD_SIZE_MAX 4 #endif struct watchlist { uint32_t size; /* of |watchlist->elts + watchlist->rest| */ uint32_t capacity; /* of |watchlist->rest| */ struct watchlist_elt elts[WATCHLIST_HEAD_SIZE_MAX]; struct watchlist_elt *rest; }; @ Traversing the watchlists. Using these macros makes the |bcp| code a bit cleaner. @d watchlist_next_elt(elt, wl) ((elt) + 1 == (wl)->elts + WATCHLIST_HEAD_SIZE_MAX ? elt = (wl)->rest : (elt)++) @d for_watchlist(elt, dump, wl) /* |elt| ptr has to transition from head list to rest */ for (elt = dump = (wl)->elts; (watchlist_is_elt_in_head(elt, (wl)) ? elt < watchlist_head_size_ptr(wl) : elt < watchlist_rest_size_ptr(wl)); watchlist_next_elt(elt, (wl))) @ The |all_watches| is the vector of all the watcher lists for every literal. @<Internal ty...@>= typedef struct all_watches { struct watchlist *wlist; /* indexed by |fs_lit2idx(i)| */ uintmax_t size; uintmax_t capacity; } all_watches; @ Initializing. @<Global def...@>= static inline void all_watches_init(funcsat *f) { FS_CALLOC(f->watches.wlist, 1<<7, sizeof(*f->watches.wlist)); f->watches.size = 2; f->watches.capacity = 1<<7; } @ @<Global def...@>= static inline void all_watches_destroy(funcsat *f) { free(f->watches.wlist); } @ These used to be macros, but then GDB on OS X wouldn't let me call them no matter how many funny {\tt -g} options I passed to gcc. So I made them functions. @<Internal decl...@>= static inline bool watchlist_is_elt_in_head(struct watchlist_elt *elt, struct watchlist *wl) { return (elt >= wl->elts && elt < (wl)->elts + WATCHLIST_HEAD_SIZE_MAX); } static inline uint32_t watchlist_head_size(struct watchlist *wl) { return ((wl)->size > WATCHLIST_HEAD_SIZE_MAX ? WATCHLIST_HEAD_SIZE_MAX : (wl)->size); } static inline struct watchlist_elt *watchlist_head_size_ptr(struct watchlist *wl) { return ((wl)->elts + watchlist_head_size(wl)); } static inline uint32_t watchlist_rest_size(struct watchlist *wl) { return ((wl)->size > WATCHLIST_HEAD_SIZE_MAX ? (wl)->size - WATCHLIST_HEAD_SIZE_MAX : 0); } static inline struct watchlist_elt *watchlist_rest_size_ptr(struct watchlist *wl) { return ((wl)->rest + watchlist_rest_size(wl)); } @ @<Internal decl...@>= static inline void all_watches_init(funcsat *f); static inline void all_watches_destroy(funcsat *f); @ @<Incrementally resize internal...@>= if (f->watches.capacity <= f->watches.size+2) { while (f->watches.capacity <= f->watches.size) { f->watches.capacity = f->watches.capacity*2+2; } FS_REALLOC(f->watches.wlist, f->watches.capacity, sizeof(*f->watches.wlist)); } @<Initialize wlist bucket...@>@; f->watches.size++; @<Initialize wlist bucket...@>@; f->watches.size++; assert(f->watches.size <= f->watches.capacity); @ @<Initialize wlist bucket at |f->watches.size|@>= f->watches.wlist[f->watches.size].size = 0; f->watches.wlist[f->watches.size].capacity = 0; for (uint32_t i = 0; i < WATCHLIST_HEAD_SIZE_MAX; i++) { f->watches.wlist[f->watches.size].elts[i].lit = 0; f->watches.wlist[f->watches.size].elts[i].cls = NO_CLS; } f->watches.wlist[f->watches.size].rest = NULL; assert(0 == watchlist_head_size(&f->watches.wlist[f->watches.size])); assert(0 == watchlist_rest_size(&f->watches.wlist[f->watches.size])); @ Destroy the watcher lists. @<Destroy func...@>= for (variable i = 1; i <= f->numVars; i++) { free(f->watches.wlist[fs_lit2idx((literal)i)].rest); free(f->watches.wlist[fs_lit2idx(-(literal)i)].rest); } free(f->watches.wlist); @ @<Global def...@>= static int compare_pointer(const void *x, const void *y) { uintptr_t xp = (uintptr_t)*(clause **)x; uintptr_t yp = (uintptr_t)*(clause **)y; if (xp < yp) return -1; else if (xp > yp) return 1; else return 0; } @ @<Internal decl...@>= static int compare_pointer(const void *x, const void *y); @ The watchlist invariants can be checked with this function. @<Global def...@>= static inline void watchlist_check(funcsat *f, literal l) { literal false_lit = -l; struct watchlist *wl = &f->watches.wlist[fs_lit2idx(l)]; struct watchlist_elt *elt, *dump; struct vec_ptr *clauses = vec_ptr_init(wl->size); for_watchlist (elt, dump, wl) { struct clause_head *c = clause_head_ptr(f, elt->cls); literal *chkl; bool chk_in_cls = false; struct clause_iter it; vec_ptr_push(clauses, c); clause_iter_init(f, elt->cls, &it); for (literal *p = clause_iter_next(f, &it); p; p = clause_iter_next(f, &it)) { /* ensure |elt->lit| is in |c| */ if (*p == elt->lit) { chk_in_cls = true; break; } } assert(chk_in_cls && "watched lit not in clause"); assert((c->lits[0] == false_lit || c->lits[1] == false_lit) && "watched lit not in first 2"); uint32_t num_not_false = 0; /* not-false literals are ``safe'' to watch */ clause_iter_init(f, elt->cls, &it); for (literal *p = clause_iter_next(f, &it); p; p = clause_iter_next(f, &it)) { if (tentativeValue(f, *p) != false) { num_not_false++; if (funcsatValue(f, *p) == true) { num_not_false = 0; break; } } } if (num_not_false >= 1) { /* ensure we're watching ``safe'' literals */ assert((tentativeValue(f, c->lits[0]) != false || tentativeValue(f, c->lits[1]) != false) && "watching bad literals"); if (num_not_false >= 2) { assert(tentativeValue(f, c->lits[0]) != false && tentativeValue(f, c->lits[1]) != false && "watching bad literals"); } } } qsort(clauses->data, clauses->size, sizeof(struct clause_head *), compare_pointer); for (uintmax_t i = 0, j = 1; j < clauses->size; i++, j++) { /* find duplicate clauses */ assert(clauses->data[i] != clauses->data[j] && "duplicate clause"); } vec_ptr_destroy(clauses); } @ We can check all the watchlists at once. @<Global def...@>= static inline void watches_check(funcsat *f) { for (variable v = 1; v <= f->numVars; v++) { literal pos = (literal)v; literal neg = -(literal)v; watchlist_check(f, pos); watchlist_check(f, neg); } } @ @<Internal decl...@>= static inline void watchlist_check(funcsat *f, literal l); static inline void watches_check(funcsat *f); @ With all this machinery we can now handle discovering unit inferences and propagating them. @<\BCP\ clauses@>= literal p = f->trail.data[f->propq]; #ifndef NDEBUG watchlist_check(f,p); #endif fs_ifdbg (f, "bcp", 3) { fslog(f, "bcp", 3, "bcp on %ji\n", p); } const literal false_lit = -p; struct watchlist *wl = &f->watches.wlist[fs_lit2idx(p)]; struct watchlist_elt *elt, *dump; uint32_t new_size = 0; ++f->numProps; dopen(f, "bcp"); for_watchlist (elt, dump, wl) { struct clause_head *c = clause_head_ptr(f, elt->cls); literal otherlit; /* the other watched lit in |c| */ mbool litval; fs_ifdbg (f, "bcp", 9) { fslog(f, "bcp", 9, "visit "); fs_clause_head_print(f, fs_dbgout(f), elt->cls); fprintf(fs_dbgout(f), " %" PRIuPTR "\n", elt->cls); } assert((false_lit == c->lits[0] || false_lit == c->lits[1])); assert((c->link == NO_CLS)); @<Check |elt->lit| for quick SAT clause@>@; @<Ensure false lit...@>@; otherlit = c->lits[0]; @<Look for new, unfalsified literal to watch, removing |elt| if found@>@; litval = funcsatValue(f, otherlit); if (litval == true) goto watch_continue; if (litval == false) { @<Record conflict and return@>@; } else { @<Record new unit inference@>@; } watch_continue: *dump = *elt, watchlist_next_elt(dump, wl); /* keep |elt| in this |wl| */ new_size++; skip_watchelt_copy:; } f->propq++; wl->size = new_size; dclose(f, "bcp"); @ The |watchlist_elt| is in the cache line. We have stored a literal from the clause in there so that we can quickly test whether it's true; if it is, we can ignore the current clause and go on to the next one. @<Check |elt->lit| for quick SAT...@>= if (funcsatValue(f, elt->lit) == true) goto watch_continue; /* If |elt->lit| is |true|, clause already satisfied */ @ Just for organization's sake, we put the watched literal (which is false) into |c->lits[1]|. @<Ensure false literal is in |c->lits[1]|@>= if (c->lits[0] == false_lit) { literal tmp = c->lits[0]; elt->lit = c->lits[0] = c->lits[1], c->lits[1] = tmp; assert(c->lits[1] == false_lit); fs_ifdbg (f, "bcp", 10) { fslog(f, "bcp", 9, "swapped "); fs_clause_head_print(f, fs_dbgout(f), elt->cls), fprintf(fs_dbgout(f), "\n"); } } assert(c->lits[1] == false_lit); @ Our goal is to discover whether the clause |c| is \textit{unit} or not. To do that we check the clause (excepting the two first literals) for any literal that is not false. If we fail to find one, since we have ensured that the first literal is in |c->lits[1]| (see |@<\BCP\ cl...@>|), the clause is unit or false. @<Look for new, unfalsified...@>= struct clause_iter it; clause_iter_init(f, elt->cls, &it); clause_iter_next(f, &it), clause_iter_next(f, &it); for (literal *p = clause_iter_next(f, &it); p; p = clause_iter_next(f, &it)) { mbool v = funcsatValue(f, *p); if (v != false) { c->lits[1] = *p, *p = false_lit; watch_l1(f, elt->cls); fs_ifdbg (f, "bcp", 9) { fslog(f, "bcp", 9, "moved "); fs_clause_head_print(f, fs_dbgout(f), elt->cls), NEWLINE(fs_dbgout(f)); } elt->cls = NO_CLS; elt->lit = 0; goto skip_watchelt_copy; } } @ Recording the conflict should be straightforward, but we have to be careful about the clauses after the conflict clause in this |watchlist|. The loop below ensures they're copied back into the current |watchlist| before we stop \BCP. |for_watchlist_continue| simply omits the initialization part of |for_watchlist|, but is otherwise identical. At this point we have found a false clause (a conflict) and need to make sure not to drop the other watched clauses down the disposal. @d for_watchlist_continue(elt, dump, wl) for (; (watchlist_is_elt_in_head(elt, wl) ? elt < watchlist_head_size_ptr(wl) : elt < watchlist_rest_size_ptr(wl)); watchlist_next_elt(elt, wl)) @<Record conflict...@>= isConsistent = false; f->conflict_clause = elt->cls; for_watchlist_continue (elt, dump, wl) { /* save rest of watched clauses */ *dump = *elt, watchlist_next_elt(dump, wl); new_size++; } wl->size = new_size; dclose(f, "bcp"); goto bcp_conflict; @ It's simple, really. @<Record new unit...@>= fslog(f, "bcp", 2, " => %ji (%s:%d)\n", otherlit, __FILE__, __LINE__); trailPush(f, otherlit, reason_info_mk(f, elt->cls)); f->conf->bumpUnitClause(f, elt->cls); @ We have a few helpers for watching literals 0 and 1 of a clause. @<Global def...@>= static inline struct watchlist_elt *watch_lit(funcsat *f, struct watchlist *wl, uintptr_t ix) { struct watchlist_elt *ret; if (watchlist_head_size(wl) < WATCHLIST_HEAD_SIZE_MAX) { assert(watchlist_rest_size(wl) == 0); ret = &wl->elts[watchlist_head_size(wl)]; wl->elts[watchlist_head_size(wl)].cls = ix; } else { assert(watchlist_head_size(wl) >= WATCHLIST_HEAD_SIZE_MAX); @q/*@>@<Allocate and/or grow |wl|'s watchlist element capacity@>@;@q*/@> ret = &wl->rest[watchlist_rest_size(wl)]; wl->rest[watchlist_rest_size(wl)].cls = ix; } wl->size++; return ret; } static inline void watch_l0(funcsat *f, uintptr_t ix) { struct clause_head *c = clause_head_ptr(f, ix); struct watchlist *wl = &f->watches.wlist[fs_lit2idx(-c->lits[0])]; struct watchlist_elt *elt = watch_lit(f, wl, ix); elt->lit = (c->sz == 2 ? c->lits[1] : c->lits[0]); } static inline void watch_l1(funcsat *f, uintptr_t ix) { struct clause_head *c = clause_head_ptr(f, ix); struct watchlist *wl = &f->watches.wlist[fs_lit2idx(-c->lits[1])]; struct watchlist_elt *elt = watch_lit(f, wl, ix); elt->lit = (c->sz == 2 ? c->lits[1] : c->lits[0]); } @ @<Allocate and/or grow |wl|'s watchlist element capacity@>= if (wl->capacity > 0) { if (watchlist_rest_size(wl) >= wl->capacity) { FS_REALLOC(wl->rest, wl->capacity*2, sizeof(*wl->rest)); wl->capacity *= 2; } } else { FS_CALLOC(wl->rest, 8, sizeof(*wl->rest)); wl->capacity = 8; } @ @<Internal decl...@>= static inline void watch_l0(funcsat *f, uintptr_t ix); static inline void watch_l1(funcsat *f, uintptr_t ix); @ When a clause is initially added, we watch it with |addWatch|. This ensures an invariant holds (see |makeWatchable|) and then adds the clause into the watcher lists. @d NEWLINE(s) fprintf((!(s) ? stderr : (s)), "\n") @<Global def...@>= void addWatch(funcsat *f, uintptr_t ix) { makeWatchable(f, ix); addWatchUnchecked(f, ix); } static inline void addWatchUnchecked(funcsat *f, uintptr_t ix) { struct clause_head *c = clause_head_ptr(f, ix); fslog(f, "bcp", 1, "watching %li and %li in ", c->lits[0], c->lits[1]); fs_ifdbg (f, "bcp", 1) {fs_clause_head_print(f, fs_dbgout(f), ix), NEWLINE(fs_dbgout(f));} assert(c->sz > 1); watch_l0(f, ix); watch_l1(f, ix); c->where = CLAUSE_WATCHED; } @ A clause which is about we be watched must obey an invariant: that the first (up to) two literals in the clause must be not false, if there are any such literals. @<Global def...@>= void makeWatchable(funcsat *f, uintptr_t ix) { struct clause_head *c = clause_head_ptr(f, ix); struct clause_iter pit, qit; clause_iter_init(f, ix, &pit), clause_iter_init(f, ix, &qit); variable swap_cnt = 0; for (literal *p = clause_iter_next(f, &pit), *q = clause_iter_next(f, &qit); p && q && swap_cnt < 2; p = clause_iter_next(f, &pit)) { mbool v = funcsatValue(f, *p); if (v != false && p != q) { literal tmp = *q; *q = *p, *p = tmp; swap_cnt++; q = clause_iter_next(f, &qit); } } #if 0 assert(is_watchable(f,c)); #endif } @ A clause is watchable if it has at least two literals and the first two literals are not |false|. The \BCP\ code when propagating $-l$ (and the other literal is $p$) will break if: \numberedlist \li $p$ is false and there is another literal in the clause (aside from $-l$) that is not false \endnumberedlist @<Global def...@>= static inline bool is_watchable(funcsat *f, struct clause_head *c) { if (c->sz < 2) return false; return funcsatValue(f, c->lits[0]) != false && funcsatValue(f, c->lits[1]) != false; } @ @<Internal decl...@>= void addWatch(funcsat *f, uintptr_t ix); static inline void addWatchUnchecked(funcsat *f, uintptr_t ix); void makeWatchable(funcsat *f, uintptr_t ix); static inline bool is_watchable(funcsat *f, struct clause_head *c); @ @<Global def...@>= static void fs_watches_print(funcsat *f, FILE *out, literal p) { if (!out) out = stderr; fprintf(out, "watcher list for %ji:\n", p); struct watchlist *wl = &f->watches.wlist[fs_lit2idx(p)]; struct watchlist_elt *elt, *dump; for_watchlist (elt, dump, wl) { struct clause_head *c = clause_head_ptr(f, elt->cls); if (c) { fprintf(out, "[%ji", elt->lit); bool in_clause = false; struct clause_iter it; clause_iter_init(f, elt->cls, &it); for (literal *q = clause_iter_next(f, &it); q; q = clause_iter_next(f, &it)) { if (*q == elt->lit) { in_clause = true; break; } } if (!in_clause) { fprintf(out, " oh noes!"); } fprintf(out, "] "); fs_clause_head_print(f, out, elt->cls), NEWLINE(out); } else { fprintf(out, "[EMPTY SLOT]\n"); } } } @*2 Reasons. We allow dynamic calculation of reason clauses. @<External ty...@>= enum reason_ty { REASON_CLS_TY }; @ Reasons are represented internally with this |struct|. |reason_info|s are store in a pool, like other data structures in \funcsat. When the |reason_info| is free, the |ty| is the index of the next |reason_info| in the freelist. Otherwise it indicates the type of the |reason_info| (see |enum reason_ty|). @<Internal ty...@>= struct reason_info { uintptr_t ty; /* |enum reason_ty|, but can be others too */ uintptr_t cls; /* index of |clause_head| */ }; #include "funcsat/vec_reason_info.h" @ Getting a reason can now invoke whatever frontend is driving \funcsat, if that frontend will dynamically calculate a reason clause. Note that this is invoked \textit{at learning time}, not at inference time. This way other inference procedures (not based on clauses and \BCP) can infer literals and only if that inference causes a conflict will a reason clause be required. @<Global def...@>= static inline uintptr_t getReason(funcsat *f, literal l) { uintptr_t reason_idx = f->reason->data[fs_lit2var(l)]; if (reason_idx != NO_CLS) { struct reason_info *r = reason_info_ptr(f, reason_idx); if (r->ty == REASON_CLS_TY) return r->cls; uintptr_t (*get_reason_clause)(funcsat *, literal) = f->reason_hooks.data[r->ty]; r->ty = REASON_CLS_TY; /* cache reason clause */ return r->cls = get_reason_clause(f,l); } else return NO_CLS; } @ @<Internal decl...@>= static inline uintptr_t getReason(funcsat *f, literal l); @ The |reason| and |reason_hooks| need to be initialized. @<Initialize func...@>= f->reason = vec_uintptr_init(2); vec_uintptr_push(f->reason, NO_CLS); vec_ptr_mk(&f->reason_hooks, 2); @ Clients should use this to add a hook for generating reasons. @<Global def...@>= void funcsatAddReasonHook(funcsat *f, uintptr_t ty, uintptr_t (*hook)(funcsat *f, literal l)) { vec_ptr_push(&f->reason_hooks, hook); } @ Declaration. @<External decl...@>= void funcsatAddReasonHook(funcsat *f, uintptr_t ty, uintptr_t (*hook)(funcsat *f, literal l)); @ When an inference is discovered, we need to set its reason using a fresh |reason_info|. But of course we shouldn't allocate it. That would slow down solving. We have a freelist of |reason_info|s and we pick the next free one. @d reason_info_ptr(f,i) (&((f)->reason_infos->data[i])) @<Global def...@>= static inline uintptr_t reason_info_mk(funcsat *f, uintptr_t ix) { assert(f->reason_infos_freelist < f->reason_infos->size); uintptr_t ret = f->reason_infos_freelist; struct reason_info *r = reason_info_ptr(f, ret); f->reason_infos_freelist = r->ty; r->ty = REASON_CLS_TY; r->cls = ix; return ret; } @ To reclaim the |reason_info|, we assign it to the head of the freelist and its next to the current freelist head. @d reason_info_idx(f,r) ((r) - (f)->reason_infos->data) @<Global def...@>= static inline void reason_info_release(funcsat *f, uintptr_t ri) { struct reason_info *r = reason_info_ptr(f,ri); r->ty = f->reason_infos_freelist; /* |ty| becomes the next index */ f->reason_infos_freelist = ri; } @ Allocate and initialize the freelist. @<Initialize func...@>= f->reason_infos_freelist = UINTMAX_MAX; /* empty */ f->reason_infos = vec_reason_info_init(2); f->reason_infos->size = 0; @ Just grow and add the new elements to the freelist. @<Resize internal...@>= vec_reason_info_grow_to(f->reason_infos, numVars); for (uintptr_t i = f->reason_infos->size; i < numVars; i++) { reason_info_release(f,i); } f->reason_infos->size = numVars; @ For each new variable, push that it has no reason. @<Incrementally resize...@>= vec_uintptr_push(f->reason, NO_CLS); @ Destroy. @<Destroy func...@>= vec_uintptr_destroy(f->reason); vec_reason_info_destroy(f->reason_infos); vec_ptr_unmk(&f->reason_hooks); @*2 Trail. The trail is managed pretty simply with |trailPush| and |trailPop|. |trailPush| is for adding a new literal to the trail (inferred or decided). @<Global def...@>= void trailPush(funcsat *f, literal p, uintptr_t reason_info_idx) { variable v = fs_lit2var(p); assert(v <= f->numVars); #ifndef NDEBUG if (f->model.data[v] < f->trail.size) { assert(f->trail.data[f->model.data[v]] != p); } #endif clausePush(&f->trail, p); f->model.data[v] = f->trail.size-(uintmax_t)1; f->phase.data[v] = p; f->level.data[v] = (literal)f->decisionLevel; if (reason_info_idx != NO_CLS) { struct reason_info *r = reason_info_ptr(f, reason_info_idx); if (r->ty == REASON_CLS_TY) { struct clause_head *h = clause_head_ptr(f, r->cls); h->is_reason = true; } f->reason->data[v] = reason_info_idx; } } @ |trailPop| is for removing the last pushed literal from the trail. The |literal| is returned. In order to pop the trail, you usually want to make sure you don't lose any facts we have around for the literal you're popping. If that is true, supply a list to merge with. If facts is |NULL|, any facts are released. @<Global def...@>= literal trailPop(funcsat *f, head_tail *facts) { literal p = clausePeek(&f->trail); variable v = fs_lit2var(p); uintptr_t reason_ix; if (facts && !head_tail_is_empty(&f->unit_facts[v])) head_tail_append(f, facts, &f->unit_facts[v]); #if 0 exonerateClauses(f, v); #endif if (f->decisions.data[v] != 0) { /*Added by SEAN!!!*/ if(f->Backtrack_hook) f->Backtrack_hook((uintptr_t *)f->conf->user, f->decisionLevel); f->decisionLevel--; f->decisions.data[v] = 0; } /* no need to clear model */ /* |f->model.data[v] = 0;| */ f->level.data[v] = Unassigned; reason_ix = f->reason->data[v]; if (reason_ix != NO_CLS) { struct reason_info *r = reason_info_ptr(f, reason_ix); if (r->ty == REASON_CLS_TY) { struct clause_head *h = clause_head_ptr(f, r->cls); h->is_reason = false; } reason_info_release(f, reason_ix); f->reason->data[v] = NO_CLS; } if (!bh_is_in_heap(f,v)) { #ifndef NDEBUG bh_check(f); #endif bh_insert(f,v); } clausePop(&f->trail); if (f->propq >= f->trail.size) f->propq = f->trail.size; return p; } @ @<Global def...@>= static inline literal trailPeek(funcsat *f) { literal p = clausePeek(&f->trail); return p; } @ The prototypes. @<Internal decl...@>= void trailPush(funcsat *f, literal p, uintptr_t reason_info_idx); literal trailPop(funcsat *f, head_tail *facts); static inline literal trailPeek(funcsat *f); static inline uintptr_t reason_info_mk(funcsat *f, uintptr_t ix); @*2 Jailing and exoneration. Clause jailing is simply stashing clauses that we can easily prove BCP won't ever need to consider (in a particular part of the search tree). Right now it's turned off. Preconditions: \unorderedlist \li the clause is alone through the 1st literal \li |trueLit| is true \li the clause is (2-watch) linked through the 0th literal \endunorderedlist @<Global def...@>= static void jailClause(funcsat *f, literal trueLit, clause *c) { #if 0 ++f->numJails; dopen(f, "jail"); assert(funcsatValue(f, trueLit) == true); const variable trueVar = fs_lit2var(trueLit); dmsg(f, "jail", 7, false, "jailed for %ju: ", trueVar); clauseUnSpliceWatch((clause **) &watches->data[fs_lit2idx(-c->data[0])], c, 0); clause *cell = &f->jail.data[trueVar]; clauseSplice1(c, &cell); dclose(f, "jail"); assert(!c->is_watched); #endif } static void exonerateClauses(funcsat *f, variable v) { uintptr_t p, c, nx; for_head_tail (f, &f->jail[v], p, c, nx) { struct clause_head *h = clause_head_ptr(f, c); h->link = NO_CLS; addWatchUnchecked(f, c); } head_tail tmp; head_tail_clear(&tmp); memcpy(&f->jail[v], &tmp, sizeof(tmp)); } @*1 Decisions. We use a heap to organize our unassigned variables. Then a decision is made based on their priority. The heap needs to have in it at least all unassigned variables, though it may have assigned variables in it. \paragraphit{\it Digression.} % I originally wrote a fibonacci heap because I believe it would be the fastest for this application. (Asymptotically, it is very fast.) But there are a few problems with it: \numberedlist \li It is big. Each node needs something like four pointers, and even though I allocate all the nodes contiguously, that's big. It's going to affect the cache behavior. An array-backed binary heap one pointer for each heap element: the pointer points to the node associated with its position in the heap. The ``pointers'' to the child elements are just array index expressions. \li I've since learned about pairing heaps, which are alleged to be just as fast (or faster) than fibheaps, and much cheaper to implement. From what I've read, it looks like you can get a pairing heap with only two pointers per node (instead of four). I wonder, though, if people use pairing heaps chiefly because they're afraid of trying to implement a fibonacci heap. \endnumberedlist \hfill{\it End Digression.} Anyway, back to this code. This is how we decide on the next branching variable: \numberedlist \li We extract the highest priority variable. It might be assigned or not, so we have to check for that. If it is assigned, we keep picking variables until (1)~we can't anymore or (2)~we find an unassigned one. \li We check which phase the variable should get. (This should be made more general. Probably we should have a heap of literals, not variables.) \li Once we have a literal to set to true, we put it on the trail and adjust a few other data structures. \endnumberedlist @<Global def...@>= literal funcsatMakeDecision(funcsat *f, void *p) { literal l = 0; if(f->ExternalHeuristic_hook != NULL) { l = f->ExternalHeuristic_hook((uintptr_t *)f->conf->user); variable v = fs_lit2var(l); ++f->numDecisions; trailPush(f, l, NO_CLS); f->level.data[v] = (intmax_t)++f->decisionLevel; f->decisions.data[v] = f->decisionLevel; fslog(f, "solve", 2, "branched on %ji\n", l); } else { while (bh_size(f) > 0) { fslog(f, "decide", 5, "extracting\n"); variable v = bh_pop(f); #ifndef NDEBUG bh_check(f); #endif fslog(f, "decide", 5, "extracted %ju\n", v); literal p = -fs_var2lit(v); if (funcsatValue(f,p) == unknown) { if (f->conf->usePhaseSaving) l = f->phase.data[v]; else l = p; ++f->numDecisions; trailPush(f, l, NO_CLS); f->level.data[v] = (intmax_t)++f->decisionLevel; f->decisions.data[v] = f->decisionLevel; fslog(f, "solve", 2, "branched on %ji\n", l); break; } } assert(l != 0 || bh_size(f) == 0); } /*Added by SEAN!!!*/ if (f->MakeDecision_hook) f->MakeDecision_hook((uintptr_t *)f->conf->user); return l; } @ @<Internal decl...@>= literal funcsatMakeDecision(funcsat *, void *); @ Because the variable ordering is dynamic, we can choose strategic points at which to ``bump'' the priority of a variable. So if at some point during solving we decide that a given variable is a but more important, we call |varBumpScore|. @<Global def...@>= inline void varBumpScore(funcsat *f, variable v) { double *activity_v = bh_var2act(f,v); double origActivity, activity; origActivity = activity = *activity_v; if ((activity += f->varInc) > 1e100) { /* rescale */ for (variable j = 1; j <= f->numVars; j++) { double *m = bh_var2act(f,j); fslog(f, "decide", 5, "old activity %f, rescaling\n", *m); *m *= 1e-100; } double oldVarInc = f->varInc; f->varInc *= 1e-100; fslog(f, "decide", 1, "setting varInc from %f to %f\n", oldVarInc, f->varInc); activity *= 1e-100; } if (bh_is_in_heap(f, v)) { bh_increase_activity(f, v, activity); } else { *activity_v = activity; } fslog(f, "decide", 5, "bumped %ju from %.30f to %.30f\n", v, origActivity, *activity_v); } @ Activities are stored as |double|s. Comparing them always returns 1 if the first activity is {\it more active} than the second (and therefore should be branched on first). @<Global def...@>= static inline int activity_compare(double x, double y) { if (x > y) return 1; else if (x < y) return -1; else return 0; } @ @<Internal decl...@>= static inline int activity_compare(double x, double y); @*2 Binary decision variable heap. This basic data structure is what Minisat uses. This implementation, however, is original. The idea is pretty simple. The heap (|f->binvar_heap|) is represented as a single array of nodes. Each possible heap node is stored at some index of an array, {\it whether it's in the heap or not}. If the node is not in the heap, it is stored after the |f->binvar_heap_size| index. If the node is in the heap, its children are stored at known offsets of the parent. We can do this since we know the array must be of size |f->numVars|. The heap invariant is that a heap node is no smaller than each of its children. Each heap node is 16 bytes: \numberedlist \li a |double| priority (can we make this a |float|?) \li a |variable| variable (needed to find out which var to return on a |bh_pop|) \endnumberedlist The auxiliary array of {\it positions} (|f->binvar_pos|) maps a |variable| to its current position in the heap. This way when we adjust a |variable|'s priority we can easily find the variable in the heap. The |f->binvar_pos| invariant is that |f->binvar_pos[v]| is the index of the heap node corresponding to variable |v|. @<Internal ty...@>= struct bh_node { variable var; double act; }; @ Returns the index into |f->binvar_heap| that gives the current variable's priority. @<Global def...@>= static inline uintmax_t bh_var2pos(funcsat *f, variable v) { return f->binvar_pos[v]; } static inline bool bh_is_in_heap(funcsat *f, variable v) { assert(bh_var2pos(f,v) > 0); return bh_var2pos(f,v) <= f->binvar_heap_size; } static inline bool bh_node_is_in_heap(funcsat *f, struct bh_node *n) { assert(n >= f->binvar_heap); return (uintmax_t)(n - f->binvar_heap) <= f->binvar_heap_size; } @ |bh_increase_activity| needs to adjust the priority---the following function is used for this. @<Global def...@>= static inline double *bh_var2act(funcsat *f, variable v) { return &f->binvar_heap[bh_var2pos(f,v)].act; } @ The following functions allow one to traverse heap: to obtain the children and the parent of a given node. Note, as with other |variable| data structures, the first node of the heap is at index 1, leaving index 0 unused. @<Global def...@>= static inline struct bh_node *bh_top(funcsat *f) { return f->binvar_heap + 1; } static inline struct bh_node *bh_bottom(funcsat *f) { return f->binvar_heap + f->binvar_heap_size; } static inline bool bh_is_top(funcsat *f, struct bh_node *v) { return bh_top(f) == v; } static inline struct bh_node *bh_left(funcsat *f, struct bh_node *v) { return f->binvar_heap + (2 * (v - f->binvar_heap)); } static inline struct bh_node *bh_right(funcsat *f, struct bh_node *v) { return f->binvar_heap + (2 * (v - f->binvar_heap) + 1); } static inline struct bh_node *bh_parent(funcsat *f, struct bh_node *v) { return f->binvar_heap + ((v - f->binvar_heap) / 2); } static inline uintmax_t bh_size(funcsat *f) { return f->binvar_heap_size; } @ Getting the node location in the heap for an arbitrary |variable| is accomplished with the help of |f->binvar_pos|, which records exactly that information. @<Global def...@>= static inline struct bh_node *bh_node_get(funcsat *f, variable v) { return f->binvar_heap + f->binvar_pos[v]; } @ decls @<Internal decl...@>= static inline uintmax_t bh_var2pos(funcsat *f, variable v); static inline bool bh_is_in_heap(funcsat *f, variable v); static inline bool bh_node_is_in_heap(funcsat *f, struct bh_node *); static inline double *bh_var2act(funcsat *f, variable v); static inline struct bh_node *bh_top(funcsat *f); static inline struct bh_node *bh_bottom(funcsat *f); static inline bool bh_is_top(funcsat *f, struct bh_node *v); static inline struct bh_node *bh_left(funcsat *f, struct bh_node *v); static inline struct bh_node *bh_right(funcsat *f, struct bh_node *v); static inline struct bh_node *bh_parent(funcsat *f, struct bh_node *v); static inline uintmax_t bh_size(funcsat *f); static inline variable bh_pop(funcsat *f); static inline void bh_insert(funcsat *f, variable v); @ Insert. After incrementing the heap size, the to insert is placed at the last free location of the heap. Then it gets bubbled up to the location where the heap invariant holds again. Insertion and deletion need often to swap two elements of the heap. |bh_swap| helps with this. @<Global def...@>= static inline void bh_swap(funcsat *f, struct bh_node **x, struct bh_node **y) { struct bh_node tmp = **x, *tmpp = *x; **x = **y, **y = tmp; *x = *y, *y = tmpp; /* swap the pointers, too */ f->binvar_pos[(*x)->var] = *x - f->binvar_heap; f->binvar_pos[(*y)->var] = *y - f->binvar_heap; } static inline void bh_bubble_up(funcsat *f, struct bh_node *e) { while (!bh_is_top(f, e)) { struct bh_node *p = bh_parent(f, e); if (activity_compare(p->act, e->act) < 0) { bh_swap(f, &p, &e); } else break; } } static inline void bh_insert(funcsat *f, variable v) { assert(bh_size(f)+1 <= f->numVars); assert(bh_var2pos(f,v) > f->binvar_heap_size); struct bh_node *node = &f->binvar_heap[bh_var2pos(f,v)]; assert(node->var == v); f->binvar_heap_size++; struct bh_node *last = &f->binvar_heap[f->binvar_heap_size]; bh_swap(f, &node, &last); bh_bubble_up(f, node); assert(f->binvar_heap[bh_var2pos(f,v)].var == v); /* invariant */ } @ Extract Max. We take the bottom element of the heap and replace the top with it. Then we bubble it down until the heap property holds again. @<Global def...@>= static inline void bh_bubble_down(funcsat *f, struct bh_node *e) { struct bh_node *l, *r; goto bh_bd_begin; while (bh_node_is_in_heap(f,l)) { if (bh_node_is_in_heap(f,r)) { if (activity_compare(l->act, r->act) < 0) l = r; /* put max child in |l| */ } if (activity_compare(e->act, l->act) < 0) { bh_swap(f, &e, &l); } else break; bh_bd_begin: l = bh_left(f,e), r = bh_right(f,e); } } static inline variable bh_pop(funcsat *f) { assert(f->binvar_heap_size > 0); struct bh_node *top = bh_top(f); struct bh_node *bot = bh_bottom(f); bh_swap(f, &top, &bot); f->binvar_heap_size--; bh_bubble_down(f, bh_top(f)); return top->var; } @ decls @<Global def...@>= static inline void bh_increase_activity(funcsat *f, variable v, double act_new) { double *act_curr = bh_var2act(f,v); struct bh_node *n = bh_node_get(f, v); assert(n->var == v); assert(*act_curr <= act_new); *act_curr = act_new; bh_bubble_up(f, n); } @ decl @<Internal decl...@>= static inline void bh_increase_activity(funcsat *f, uintmax_t node_pos, double new_act); @ we should check the heap property! @<Global def...@>= static void bh_check_node(funcsat *f, struct bh_node *x) { struct bh_node *l = bh_left(f,x), *r = bh_right(f,x); if (bh_node_is_in_heap(f,l)) { assert(activity_compare(l->act, x->act) <= 0); bh_check_node(f,l); } if (bh_node_is_in_heap(f,r)) { assert(activity_compare(r->act, x->act) <= 0); bh_check_node(f,r); } } static void bh_check(funcsat *f) { struct bh_node *root = bh_top(f); if (bh_node_is_in_heap(f, root)) { bh_check_node(f, root); } for (uintmax_t i = 1; i < f->numVars; i++) { assert(bh_node_get(f, i)->var == i); } } @ @<Internal decl...@>= static void bh_check(funcsat *f); @ Initializing is easy. @<Initialize funcsat...@>= FS_CALLOC(f->binvar_heap, 2, sizeof(*f->binvar_heap)); FS_CALLOC(f->binvar_pos, 2, sizeof(*f->binvar_pos)); f->binvar_heap_size = 0; @ Destroying. @<Destroy func...@>= free(f->binvar_heap); free(f->binvar_pos); f->binvar_heap_size = 0; @ Allocating is easy. @<Resize internal data...@>= FS_REALLOC(f->binvar_heap, numVars+1, sizeof(*f->binvar_heap)); FS_REALLOC(f->binvar_pos, numVars+1, sizeof(*f->binvar_pos)); @ Initializing each activity is also easy. @<Incrementally resize internal data...@>= f->binvar_heap[v].var = v; f->binvar_heap[v].act = f->conf->getInitialActivity(&v); f->binvar_pos[v] = v; bh_insert(f, v); assert(f->binvar_pos[v] != 0); @ Print the heap. @<Global def...@>= static void bh_padding(funcsat *f, const char *s, int x) { while (x-- > 0) { fprintf(fs_dbgout(f), "%s", s); } } static bool bh_print_levels(funcsat *f, FILE *dotfile, struct bh_node *r, int level) { assert(r); if (bh_node_is_in_heap(f, r)) { bool lf, ri; lf = bh_print_levels(f, dotfile, bh_left(f, r), level+1); ri = bh_print_levels(f, dotfile, bh_right(f, r), level+1); if (lf) fprintf(dotfile, "%ju -> %ju [label=\"L\"];\n", r->var, bh_left(f,r)->var); if (ri) fprintf(dotfile, "%ju -> %ju [label=\"R\"];\n", r->var, bh_right(f,r)->var); fprintf(dotfile, "%ju [label=\"%ju%s, %.1f\"];\n", r->var, r->var, (funcsatValue(f, r->var) == true ? "T" : (funcsatValue(f, r->var) == false ? "F" : "?")), r->act); return true; } else { return false; } } static void bh_print(funcsat *f, const char *path, struct bh_node *r) { if (!r) r = bh_top(f); FILE *dotfile; if (NULL == (dotfile = fopen(path, "w"))) perror("fopen"), exit(1); fprintf(dotfile, "digraph G {\n"); bh_print_levels(f, dotfile, r, 0); fprintf(dotfile, "}\n"); if (0 != fclose(dotfile)) perror("fclose"); fprintf(fs_dbgout(f), "\n"); } @ @<Internal decl...@>= static void bh_print(funcsat *f, const char *path, struct bh_node *r); @*2 Backtracking. @<Global def...@>= void backtrack(funcsat *f, variable newLevel, head_tail *facts, bool isRestart) { head_tail restart_facts; if (isRestart) { assert(newLevel == 0UL), assert(!facts); facts = &restart_facts; head_tail_clear(&restart_facts); } while (f->decisionLevel != newLevel) trailPop(f, facts); if (isRestart) { literal top; /*Added by SEAN!!!*/ if(f->Backtrack_hook) f->Backtrack_hook((uintptr_t *)f->conf->user, 0); if(f->MakeDecision_hook) f->MakeDecision_hook((uintptr_t *)f->conf->user); f->propq = 0; restore_facts(f, facts); if (f->trail.size > 0) { top = trailPeek(f); head_tail_append(f, &f->unit_facts[fs_lit2var(top)], facts); } } } static void restore_facts(funcsat *f, head_tail *facts) { uintptr_t prev, curr, next; for_head_tail (f, facts, prev, curr, next) { /* if the clause was subsumed, it could be here but not learned */ struct clause_head *h = clause_head_ptr(f, curr); assert(h->sz >= 1); if (h->sz == 1) { literal p = h->lits[0]; mbool val = funcsatValue(f,p); assert(val != false); if (val == unknown) { trailPush(f, p, reason_info_mk(f, curr)); fslog(f, "bcp", 5, " => %ji\n", p); } } else { head_tail_iter_rm(f, facts, prev, curr, next); addWatchUnchecked(f, curr); #ifndef NDEBUG watches_check(f); #endif } } } @ @<Internal decl...@>= static void restore_facts(funcsat *f, head_tail *facts); @*1 Clause learning.\definexref{pg-clause-learn}{\folio}{page} \funcsat\ learns unique implication point (UIP) clauses. It can learn any number of them, starting with the first. The top-level procedure is |analyze_conflict|, which assumes: \numberedlist \li the solver is in conflict (|f->conflict_clause| is set) \li the literals in |f->conflict_clause| are all |false| (under |funcsatValue|) \endnumberedlist Initially the conflict clause is unset. @<Initialize fun...@>= f->conflict_clause = NO_CLS; @ This function is just a wrapper around the real work. It makes sure that we approximate how much of the space we've explored and returns whether we have proven the problem unsat to the caller. The real work is done in |find_uips|. @<Global def...@>= bool analyze_conflict(funcsat *f) { struct clause_iter it; variable i, c = 0; /* c -- count current-decision-level literals in the learned clause */ literal *p; head_tail facts; literal uipLit = 0; ++f->numConflicts; assert(f->uipClause.size == 0); clause_iter_init(f, f->conflict_clause, &it); for (literal *p = clause_iter_next(f, &it); p; p = clause_iter_next(f, &it)) { clausePush(&f->uipClause, *p); } #if !defined(NDEBUG) && defined(PRINT_IMPL_GRAPH) print_dot_impl_graph(f, &f->uipClause); #endif head_tail_clear(&facts); litpos_clear(&f->litpos_uip); litpos_init_from_uip_clause(f); for_clause (p, &f->uipClause) if ((uintmax_t)levelOf(f, fs_lit2var(*p)) == f->decisionLevel) c++; int64_t entrydl = (int64_t)f->decisionLevel; #ifndef NDEBUG watches_check(f); #endif bool isUnsat = find_uips(f, c, &facts, &uipLit); if (isUnsat) { fslog(f, "solve", 1, "find_uips returned isUnsat\n"); f->conflict_clause = NO_CLS; return false; } f->conf->decayAfterConflict(f); f->conflict_clause = NO_CLS; f->uipClause.size = 0; #ifndef NDEBUG watches_check(f); #endif if (!propagateFacts(f, &facts, uipLit)) { return analyze_conflict(f); } else { return true; } } @ |find_uips| does the heavy lifting of forming the \UIP\ clauses. Returns |true| only if the \SAT\ instance is \UNSAT. If we don't learn all the \UIP s that we could then there may be literals after the decision literal on the trail. So we need to pop them; finally we pop the decision literal. @<Global def...@>= bool find_uips(funcsat *f, uintmax_t c, head_tail *facts, literal *lit_uip) { uint32_t num_uips_learned = 0, num_uips_to_learn = f->conf->numUipsToLearn; uint32_t num_resolutions = 0; literal p; fs_ifdbg (f, "find_uips", 1) { fslog(f, "find_uips", 1, "conflict@@%ju (#%" PRIu64 ") with ", f->decisionLevel, f->numConflicts); fs_clause_print(f, fs_dbgout(f), &f->uipClause); fprintf(fs_dbgout(f), "\n"); } dopen(f, "find_uips"); do { @<Find the next \UIP\ clause @>@; } while (num_uips_learned < num_uips_to_learn); *lit_uip = p; while (!isDecision(f, fs_lit2var(trailPeek(f)))) trailPop(f, facts); p = trailPop(f, facts); /* pop decision literal */ fslog(f, "find_uips", 5, "learned %" PRIu32 " UIPs\n", num_uips_learned); dclose(f, "find_uips"); fslog(f, "find_uips", 5, "done\n"); return false; } @ Initially, there might be some junk on the trail that hasn't been used for propagation yet. We need to undo trail assignments until the top of the trail is in the clause. This allows us to pick the most recently inferred literal and resolve it out of the conflict clause. After a single resolution step, one a few things has happened: \orderedlist \li In the common case we will have added some new literals from the current level, keeping |c>1|. We will want to keep resolving. However, it often happens that there are literals on the trail that don't occur in |f->uipClause| (the clause we're building). We want to ignore those so we need to pop literals from the trail until we find one that's in the conflict clause. \li In the \UIP\ case, we find a \UIP: |c==1| and we need to add the new \UIP\ clause to the clause database. In this case it's also desirable to pop literals from the trail until we find one in the conflict clause. \li It can happen that we resolve all current-level literals out and, although the clause isn't empty, |c==0|. This means a decision level really wasn't responsible for the current conflict and we need to backtrack over it until we find something in the conflict clause (I think?). \endorderedlist During learning, there are a few conditions which mean we proved the problem \UNSAT: (\osf{1}) if we backtrack to decision level 0 or (\osf{2}) if the \UIP\ clause becomes empty. We check these in the loop conditions. Finally, if our \UIP\ literal is a decision variable, we need to stop learning \UIP s -- so we check for that at the very end of this section. @<Find the next \UIP...@>= while (!litpos_contains(&f->litpos_uip, p = trailPeek(f))) trailPop(f, facts); do { uintptr_t ix_reason; uintmax_t num_new_lits; /* new current-level lits */ @<Check \UIP\ learning invariants if |NDEBUG| is not present@>@; assert(litpos_contains(&f->litpos_uip, p)); ix_reason = getReason(f,p); num_new_lits = pop_and_resolve(f, ix_reason, facts); num_resolutions++; c = c - 1 + num_new_lits; while (f->trail.size > 0 && !litpos_contains(&f->litpos_uip, p = trailPeek(f))) trailPop(f, facts); if (c == 0) { /* reset count cuz we backtracked */ literal *q; for_clause (q, &f->uipClause) if (levelOf(f, fs_lit2var(*q)) == (literal) f->decisionLevel) c++; fslog(f, "find_uips", 6, "c=0, backtracked to level %" PRIu64 ", c = %" PRIu32 ", p = %ji\n", f->decisionLevel, c, p); } } while (c != 1 && f->uipClause.size > 0 && f->decisionLevel > 0); num_uips_learned++; @<Allocate and add the new \UIP...@>@; if (isDecision(f, fs_lit2var(p))) num_uips_to_learn = num_uips_learned; @ Check loop invariants to at least \textit{try} to be careful. \orderedlist \li Top of the trail must be in the clause. \li Count |c| must be the number of current-decision-level literals. \endorderedlist These invariants should guarantee that there is at least one more UIP literal to learn. @<Check \UIP\ learning invariants...@>= #ifndef NDEBUG { literal *q; uint32_t inner_cnt = 0; assert(litpos_contains(&f->litpos_uip, trailPeek(f))); for_clause (q, &f->uipClause) { if (levelOf(f, fs_lit2var(*q)) == (literal) f->decisionLevel) inner_cnt++; } assert(inner_cnt == c); } #endif @ At each step during learning a clause we perform a clause resolution. We will always resolve away the variable at the top of the trail. As a result, the clause may shrink or expand in size. @<Global def...@>= static inline uintmax_t pop_and_resolve(funcsat *f, uintptr_t ix_reason, head_tail *facts) { literal p; fs_ifdbg (f, "find_uips", 6) { fslog(f, "find_uips", 6, "resolving "); fs_clause_print(f, fs_dbgout(f), &f->uipClause); fprintf(fs_dbgout(f), " with "); fs_clause_head_print(f, fs_dbgout(f), ix_reason); fprintf(fs_dbgout(f), "\n"); } p = trailPop(f, facts); f->conf->bumpReason(f, ix_reason); @<Resolve |f->uipClause| with reason...@>@; } @ Here the actual resolution step is performed. This code performs a resolution on the literal |p| using the position list, which is stored in |funcsat->litPos|. The code copies over all literals not currently in |f->uipClause|; then, it deletes |-p| from |f->uipClause|. Preconditions: \unorderedlist \li |ix_reason| is the clause index for |p|'s reason \li |p| is in |ix_reason| \li |-p| is in |f->uipClause| \endunorderedlist Returns the number of current-decision-level literals found in the |ix_reason| clause. @<Resolve |f->uipClause| with reason for |p| and count literals@>= variable i, c = 0, pvar = fs_lit2var(p); uintptr_t pos_p; struct clause_iter it; ++f->numResolutions; clause_iter_init(f, ix_reason, &it); for (literal *q = clause_iter_next(f, &it); q; q = clause_iter_next(f, &it)) { literal l = *q; if (!litpos_contains(&f->litpos_uip, l)) { literal *new_lit; clausePush(&f->uipClause, l); new_lit = f->uipClause.data + f->uipClause.size - 1; assert(*new_lit == l); litpos_set(&f->litpos_uip, new_lit); litpos_check(&f->litpos_uip); if (levelOf(f, fs_lit2var(l)) == (literal)f->decisionLevel) c++; } } @<Delete |-p| from |f->uipClause|...@>@; return c; @ Swap |-p| and the last element of |f->uipClause| and decrement the clause size. Simple. @<Delete |-p| from |f->uipClause| after resolution@>= literal *data = f->uipClause.data; pos_p = litpos_pos(&f->litpos_uip, p); swap(literal, data[pos_p], data[f->uipClause.size-1]); litpos_set(&f->litpos_uip, data + pos_p); litpos_unset(&f->litpos_uip, data[f->uipClause.size-1]); f->uipClause.size--; litpos_check(&f->litpos_uip); @ @<Internal decl...@>= static inline uintmax_t pop_and_resolve(funcsat *f, uintptr_t ix_reason, head_tail *facts); @ You might think that allocating a new internal clause from the new \UIP\ clause would be straightforward. But you would be wrong. The first bit of (slight) complexity is that since we might generate more than one learned clause per conflict, we need a list to store them. We use the unit fact list at the current UIP literal |p| for our storage. The second bit of complexity is that the order if literals in the learned clause matters. (See the section |@<Order unit fact...@>| for details.) @<Allocate and add the new \UIP\ clause to the unit facts for |fs_lit2var(p)|@>= fs_ifdbg (f, "find_uips", 6) { fslog(f, "find_uips", 6, "found raw UIP: "); fs_clause_print(f, fs_dbgout(f), &f->uipClause); fprintf(fs_dbgout(f), "\n"); } @<Check for \UNSAT\ after...@>@; @<Order unit fact literals...@>@; uintptr_t ix_uip = clause_head_alloc_from_clause(f, &f->uipClause); struct clause_head *h_uip = clause_head_ptr(f, ix_uip); f->conf->bumpLearned(f, ix_uip); fs_ifdbg (f, "find_uips", 5) { fslog(f, "find_uips", 5, "found min UIP: "); fs_clause_head_print(f, fs_dbgout(f), ix_uip); fprintf(fs_dbgout(f), "\n"); } h_uip->is_learned = true; h_uip->where = CLAUSE_UNIT; head_tail_add(f, &f->unit_facts[fs_lit2var(p)], ix_uip); vec_uintptr_push(f->learned_clauses, ix_uip); ++f->numLearnedClauses; @ After we have learned a \UIP\ we may have discovered that the \SAT\ instance is unsatisfiable. This can happen when we backtrack all the way to decision level 0 or if we resolve the empty clause directly. @<Check for \UNSAT\ after learning@>= if (f->decisionLevel == 0 || f->uipClause.size == 0) return true; @ While munging the unit facts, we need to ensure that the invariant on |f->unitFacts| for |propagateFacts| holds for this clause: the \UIP\ literal needs to be the first literal in the clause, and the second literal is the one that was most recently inferred. We minimize the learned clause here, too. @<Order unit fact literals and minimize the learned clause@>= literal watch2 = 0, watch2_level = -1; uintmax_t pPos = litpos_pos(&f->litpos_uip, p); swap(literal, f->uipClause.data[0], f->uipClause.data[pPos]); litpos_set(&f->litpos_uip, &f->uipClause.data[0]); litpos_set(&f->litpos_uip, &f->uipClause.data[pPos]); if (f->conf->minimizeLearnedClauses) minimizeUip(f, (&f->uipClause)); for (variable i = 1; i < (&f->uipClause)->size; i++) { /* find max level literal */ literal lev = levelOf(f, fs_lit2var((&f->uipClause)->data[i])); if (watch2_level < lev) { watch2_level = lev; watch2 = (literal) i; } if (lev == (literal) f->decisionLevel) break; } if (watch2_level != -1) { swap(literal, f->uipClause.data[1], f->uipClause.data[watch2]); litpos_set(&f->litpos_uip, &f->uipClause.data[1]); litpos_set(&f->litpos_uip, &f->uipClause.data[watch2]); } @ During learning we may discover learned (intermediate or \UIP) clauses that subsume existing clauses. If so, we should take that information and strengthen our clause database. @<Deal with subsumed clauses@>= #if 0 if (f->conf->useSelfSubsumingResolution) { for_vec_ptr99 (clause **, it, &f->subsumed) { bool subsumedByUip = (bool)*it; ++it; fs_ifdbg (f, "subsumption", 1) { fprintf(dbgout(f), "removing clause due to subsumption: "); clause_head_print_dimacs(dbgout(f), *it); fprintf(dbgout(f), "\n"); } if ((*it)->isLearnt) { clause *removedClause = funcsatRemoveClause(f, *it); assert(removedClause); if (subsumedByUip) clauseFree(removedClause); else { removedClause->data[0] = removedClause->data[--removedClause->size]; vec_ptr_push(&f->learnedClauses, removedClause); fs_ifdbg (f, "subsumption", 1) { fprintf(dbgout(f), "new adjusted clause: "); clause_head_print_dimacs(dbgout(f), removedClause); fprintf(dbgout(f), "\n"); } if (removedClause->is_watched) { addWatch(f, removedClause); } } } } f->subsumed.size = 0; } #endif @ Prototypes. @<Internal decl...@>= static inline bool isAssumption(funcsat *f, variable v); @ Learned clauses often contain redundant literals. Use Van Gelder's algorithm to remove them. @ @<Initialize func...@>= vec_uintmax_mk(&f->seen, 2); vec_uintmax_push(&f->seen, false); vec_intmax_mk(&f->analyseToClear, 2); vec_intmax_push(&f->analyseToClear, 0); vec_uintmax_mk(&f->analyseStack, 2); vec_uintmax_push(&f->analyseStack, 0); vec_uintmax_mk(&f->allLevels, 2); vec_uintmax_push(&f->allLevels, false); @ @<Incrementally resize internal...@>= vec_uintmax_push(&f->seen, false); vec_uintmax_push(&f->allLevels, false); @ @<Resize internal...@>= vec_intmax_grow_to(&f->analyseToClear, numVars); vec_uintmax_grow_to(&f->analyseStack, numVars); @ @<Destroy func...@>= vec_uintmax_unmk(&f->allLevels); vec_uintmax_unmk(&f->analyseStack); vec_intmax_unmk(&f->analyseToClear); vec_uintmax_unmk(&f->seen); @ @<Global def...@>= static void cleanSeen(funcsat *f, variable top) { while (f->analyseToClear.size > top) { variable v = fs_lit2var(vec_intmax_pop(&f->analyseToClear)); f->seen.data[v] = false; } } static inline bool isAssumption(funcsat *f, variable v) { literal *it; for_clause (it, &f->assumptions) { if (fs_lit2var(*it) == v) { return true; } } return false; } /** * Performs a depth-first search of the conflict graph beginning at q0. */ static bool litRedundant(funcsat *f, literal q0) { if (levelOf(f, fs_lit2var(q0)) == 0) return false; if (isDecision(f, fs_lit2var(q0))) return false; assert(!isAssumption(f, fs_lit2var(q0))); /*fprintf(f->conf->debugStream, "literal %jd is not trivally redundant\n", q0);*/ vec_uintmax_clear(&f->analyseStack); vec_uintmax_push(&f->analyseStack, fs_lit2var(q0)); variable top = f->analyseToClear.size; /*fprintf(f->conf->debugStream, "pushing literal %jd to stack\n", q0);*/ while (f->analyseStack.size > 0) { variable p = vec_uintmax_pop(&f->analyseStack); /*fprintf(f->conf->debugStream, "popping variable %ju from stack to get reason clause\n", p);*/ uintptr_t ix = getReason(f, (literal)p); /*fs_clause_head_print(f, fs_dbgout(f), ix);*/ struct clause_iter it; literal *q; clause_iter_init(f, ix, &it); /* q = clause_iter_next(f, &it);*/ /* if (q) {*/ /* begins at 1 because |fs_lit2var(c->data[0])==p| */ for (q = clause_iter_next(f, &it); q; q = clause_iter_next(f, &it)) { /*fprintf(f->conf->debugStream, "considering literal %jd from clause\n", *q);*/ /*assert(q0 != *q);*/ if(*q == q0) continue; variable v = fs_lit2var(*q); literal lev = levelOf(f, v); if (!f->seen.data[v] && lev > 0) { if (!isDecision(f, fs_lit2var(*q)) && f->allLevels.data[lev]) { vec_uintmax_push(&f->analyseStack, v); vec_intmax_push(&f->analyseToClear, *q); f->seen.data[v] = true; } else { cleanSeen(f, top); return false; } } } /*}*/ } return true; } @ |minimizeUip| assumes that the \UIP\ literal is at the first position in the clause. @<Global def...@>= void minimizeUip(funcsat *f, clause *learned) { /** todo use integer to denote the levels in the set, then just increment */ variable i, j; for (i = 0; i < learned->size; i++) { literal l = levelOf(f, fs_lit2var(learned->data[i])); assert(l != Unassigned); f->allLevels.data[l] = true; } vec_intmax_clear(&f->analyseToClear); literal *it; forClause (it, learned) { vec_intmax_push(&f->analyseToClear, *it); } /* |memset(f->seen.data, 0, f->seen.capacity * sizeof(*f->seen.data));| */ for (i = 0; i < learned->size; i++) { f->seen.data[fs_lit2var(learned->data[i])] = true; } /* uip literal is assumed to be in |learned->data[0]|, so skip it by starting at * |i=1| */ fslog(f, "minimizeUip", 6, "searching learned clause for redundant literals\n"); /*fs_clause_print(f, fs_dbgout(f), learned);*/ for (i = 1, j = 1; i < learned->size; i++) { literal p = learned->data[i]; /*fprintf(f->conf->debugStream, "considering literal %jd\n", p);*/ if (!litRedundant(f, p)) { learned->data[j] = p; litpos_set(&f->litpos_uip, learned->data+j); j++; } else { assert(!isAssumption(f, fs_lit2var(p))); litpos_unset(&f->litpos_uip, p); fslog(f, "minimizeUip", 5, "deleted %ji\n", p); ++f->numLiteralsDeleted; } } learned->size -= i - j; /* specialised |cleanSeen(f, 0)| to include clearing of |allLevels| */ while (f->analyseToClear.size > 0) { literal l = vec_intmax_pop(&f->analyseToClear); variable v = fs_lit2var(l); f->seen.data[v] = false; f->allLevels.data[levelOf(f,v)] = false; } } @ @<Find the most recent...@>= while (!litpos_contains(&f->litpos_uip, p = trailPeek(f))) { trailPop(f, facts); } @ @<Internal decl...@>= static void print_dot_impl_graph(funcsat *f, clause *cc); @ It is convenient to be able to dump the implication graph to a dot file so we can render it in graphviz. @<Global def...@>= static char *dot_lit2label(literal p) { static char buf[64]; sprintf(buf, "lit%ji", fs_lit2var(p)); return buf; } static void print_dot_impl_graph_rec(funcsat *f, FILE *dotfile, struct vec_bool *seen, literal p) { if (seen->data[fs_lit2var(p)] == false) { fprintf(dotfile, "%s ", dot_lit2label(p)); fprintf(dotfile, "[label=\"%ji @@ %ju%s\"%s];\n", (funcsatValue(f,p) == false ? -p : p), levelOf(f, fs_lit2var(p)), (funcsatValue(f,p)==unknown ? "*" : ""), (levelOf(f, fs_lit2var(p))==(literal)f->decisionLevel ? ",color=green" : "")); seen->data[fs_lit2var(p)] = true; bool isdec = isDecision(f, fs_lit2var(p)); if (!isdec) { uintptr_t ix_r = getReason(f,p); struct clause_iter it; clause_iter_init(f, ix_r, &it); fprintf(dotfile, "/* reason for %ji: ", p); fs_clause_head_print(f, dotfile, ix_r); fprintf(dotfile, "*/\n"); for (literal *q = clause_iter_next(f, &it); q; q = clause_iter_next(f, &it)) { if (*q != -p) { fprintf(dotfile, "%s", dot_lit2label(*q)); fprintf(dotfile, " -> "); fprintf(dotfile, "%s;\n", dot_lit2label(p)); } } clause_iter_init(f, ix_r, &it); for (literal *q = clause_iter_next(f, &it); q; q = clause_iter_next(f, &it)) { print_dot_impl_graph_rec(f, dotfile, seen, *q); } } else { fprintf(dotfile, "/* no reason for %ji */\n", p); } } } static void print_dot_impl_graph(funcsat *f, clause *cc) { literal *p, *q; struct vec_bool *seen = vec_bool_init(f->numVars+1); seen->size = f->numVars+1; char buf[64]; snprintf(buf, 64, "conflict%" PRIu64 ".dot", f->numConflicts), buf[63] = 0; FILE *dotfile = fopen(buf, "w"); fprintf(dotfile, "digraph G {\n"); fprintf(dotfile, "/* conflict clause: "); fs_clause_print(f, dotfile, cc); fprintf(dotfile, "*/\n"); buf[strlen(buf)-strlen(".dot")]=0; fprintf(dotfile, "%s [shape=note];\n", buf); fprintf(dotfile, "cclause [shape=note,label=\""); /* conflict clause */ for_clause (p, cc) { fprintf(dotfile, "%ji%s ",*p,(funcsatValue(f,*p)==unknown ? "*" : "")); } fprintf(dotfile, "\"];\n"); for_clause (p, cc) print_dot_impl_graph_rec(f, dotfile, seen, *p); fprintf(dotfile, "lambda [label=L];\n"); for_clause (p, cc) { fprintf(dotfile, "%s", dot_lit2label(*p)); fprintf(dotfile, " -> "); fprintf(dotfile, "lambda [color=\"red\"];\n"); } fprintf(dotfile, "\n}"); vec_bool_destroy(seen); fclose(dotfile); } @ @<Internal decl...@>= #include "funcsat/vec_bool.h" @*2 Unit facts. At the end of learning we have a list of new clauses. We need to propagate them, and more importantly shunt them into {\it unit fact lists}. @<Internal decl...@>= bool find_uips(funcsat *f, uintmax_t c, head_tail *facts, literal *uipLit); bool propagateFacts(funcsat *f, head_tail *facts, literal uipLit); static uintmax_t resetLevelCount(funcsat *f, uintmax_t c, head_tail *facts); static void checkSubsumption( funcsat *f, literal p, clause *learn, clause *reason, bool learnIsUip); @ The following function propagates the given unit facts. Each clause is either: % \numberedlist \li unit \li or has at least two unassigned literals. \endnumberedlist In the first case, we immediately make an assignment, but this function will ignore that assignment for the purposes of detecting a conflict. In the latter case, we add the clause to the watched literals lists. The uips not added to the watched literal lists are attached as unit facts to the variable dec. It is possible that propagateFacts may discover a conflict. If so, it returns |false|. @ The following code is wrapped around the crucial node, |@<Propagate single unit...@>|. @<Global def...@>= bool propagateFacts(funcsat *f, head_tail *facts, literal uipLit) { bool isConsistent = true; variable uipVar = fs_lit2var(uipLit); uintmax_t cnt = 0; dopen(f, "bcp"); /* Assign each unit fact */ uintptr_t ix_prev, ix_curr, ix_next; for_head_tail (f, facts, ix_prev, ix_curr, ix_next) { ++f->numUnitFactProps, ++cnt; @<Propagate single unit fact@>@; if (!isConsistent) break; } dclose(f, "bcp"); fslog(f, "bcp", 1, "propagated %ju facts\n", cnt); if (f->conflict_clause != NO_CLS) { if (funcsatValue(f, uipLit) == unknown) { if (f->decisionLevel > 0) { uipVar = fs_lit2var(f->trail.data[f->trail.size-1]); } else goto ReallyDone; } } #if 0 assert(!head || funcsatValue(f, fs_var2lit(uipVar)) != unknown); assert(clauseIsAlone(&f->unitFacts.data[uipVar], 0)); #endif /* if var@@0, then all learns are SAT@@0 */ if (levelOf(f, uipVar) != 0) { head_tail_append(f, &f->unit_facts[uipVar], facts); } ReallyDone: return isConsistent; } @ Using the list of |facts|, |curr| and |prev|, we can propagate a single unit fact. If we detect an inconsistency we set |isConsistent| to |false|. @<Propagate single unit...@>= fs_ifdbg (f, "bcp", 5) { fslog(f, "bcp", 5, ""); /* logging label */ fs_clause_head_print(f, fs_dbgout(f), ix_curr); fprintf(fs_dbgout(f), "\n"); } struct clause_head *h_curr = clause_head_ptr(f, ix_curr); if (h_curr->sz == 0) goto Conflict; else if (h_curr->sz == 1) { literal p = h_curr->lits[0]; mbool val = funcsatValue(f,p); if (val == false) goto Conflict; else if (val == unknown) { trailPush(f, p, reason_info_mk(f, ix_curr)); fslog(f, "bcp", 1, " => %ji\n", p); } continue; } literal p = h_curr->lits[0], q = h_curr->lits[1]; assert(p != 0 && q != 0 && "unset literals"); assert(p != q && "did not find distinct literals"); mbool vp = tentativeValue(f,p), vq = tentativeValue(f,q); /* if |(vp==true && vq == true)| (if jailing, put in jailed list for data[1], * else put in watcher list) */ if (vp == true && vq == true) { head_tail_iter_rm(f, facts, ix_prev, ix_curr, ix_next); addWatchUnchecked(f, ix_curr); fslog(f, "bcp", 5, " => watched\n"); } else if (vp == true || vq == true) { /* clause is SAT */ ; /* leave in unit facts */ fslog(f, "bcp", 5, " => unmolested\n"); } else if (vp == unknown && vq == unknown) { head_tail_iter_rm(f, facts, ix_prev, ix_curr, ix_next); addWatchUnchecked(f, ix_curr); fslog(f, "bcp", 5, " => watched\n"); } else if (vp == unknown) { if (funcsatValue(f,p) == false) goto Conflict; assert(h_curr->lits[0] == p); trailPush(f, p, reason_info_mk(f, ix_curr)); /* clause is unit, implying p */ f->conf->bumpUnitClause(f, ix_curr); fslog(f, "bcp", 1, " => %ji\n", p); } else if (vq == unknown) { if (funcsatValue(f,q) == false) goto Conflict; assert(h_curr->lits[1] == q); h_curr->lits[0] = q, h_curr->lits[1] = p; trailPush(f, q, reason_info_mk(f, ix_curr)); /* clause is unit, implying q */ fslog(f, "bcp", 1, " => %ji\n", q); f->conf->bumpUnitClause(f, ix_curr); } else { Conflict: /* clause is UNSAT */ isConsistent = false; f->conflict_clause = ix_curr; fslog(f, "bcp", 1, " => X\n"); } @ A slightly thorny case, that I can't explain yet, is why we use |tentativeValue| here instead of |funcsatValue|. |tentativeValue| works just like its counterpart, only looks at values that have been {\it already propagated} by BCP. This can be fewer, but never more, than those that are assigned. @<Global def...@>= static inline mbool tentativeValue(funcsat *f, literal p) { variable v = fs_lit2var(p); literal *valLoc = &f->trail.data[f->model.data[v]]; bool isTentative = valLoc >= f->trail.data + f->propq; if (levelOf(f,v) != Unassigned && !isTentative) return p == *valLoc; else return unknown; } @ @<Internal decl...@>= static inline mbool tentativeValue(funcsat *f, literal p); @ We need to initialize the unit facts. @<Initialize funcsat type@>= FS_CALLOC(f->unit_facts, 2, sizeof(*f->unit_facts)); f->unit_facts_size = 1; f->unit_facts_capacity = 2; @ And grow them. @<Incrementally resize internal data structures...@>= if (f->unit_facts_size >= f->unit_facts_capacity) { FS_REALLOC(f->unit_facts, f->unit_facts_capacity*2, sizeof(*f->unit_facts)); f->unit_facts_capacity *= 2; } head_tail_clear(&f->unit_facts[f->unit_facts_size]); f->unit_facts_size++; @ And free them. @<Destroy func...@>= free(f->unit_facts); @ @<Internal decl...@>= void minimizeUip(funcsat *f, clause *learned); @*2 |litpos|. The |litpos| structure maintains a mapping of literals to indices -- so that one can quickly query, ``is this literal in this clause?'' The |indices| field is literally just a table indexed by |literal|s and mapping to associated clause indices. @d NO_POS UINTPTR_MAX @<Internal ty...@>= struct litpos { clause *c; /* associated clause */ struct vec_uintptr *indices; /* size is normally |f->numVars| */ }; @ @<Global def...@>= static inline void litpos_init(struct litpos *r) { r->c = NULL; r->indices = vec_uintptr_init(2); } static inline void litpos_destroy(struct litpos *lp) { vec_uintptr_destroy(lp->indices); } @ Maps the literal |*p| to its index in the current clause. We require a pointer to ``prove'' that the literal is in the clause. @<Global def...@>= static inline void litpos_set(struct litpos *lp, literal *p) { assert(lp->c->data <= p); assert(p < lp->c->data + lp->c->size); lp->indices->data[fs_lit2var(*p)] = (uintptr_t)(p - lp->c->data); } @ Various ways to test/get a literal. @<Global def...@>= static inline literal *litpos_lit(struct litpos *lp, literal l) { return &lp->c->data[litpos_pos(lp, l)]; } static inline uintptr_t litpos_pos(struct litpos *lp, literal l) { return lp->indices->data[fs_lit2var(l)]; } static inline bool litpos_contains(struct litpos *lp, literal l) { return lp->indices->data[fs_lit2var(l)] != NO_POS; } @ Removes the mapping for |literal| |p|. We don't take a pointer because |p| may not be in the clause. @<Global def...@>= static inline void litpos_unset(struct litpos *lp, literal p) { lp->indices->data[fs_lit2var(p)] = NO_POS; } @ Clears all positions and removes clause association. @<Global def...@>= static inline void litpos_clear(struct litpos *lp) { for_vec_uintptr (up, lp->indices) *up = NO_POS; } @ Check invariant. @<Global def...@>= inline void litpos_check(struct litpos *lp) { #ifndef NDEBUG literal *p; for_clause (p, lp->c) assert(lp->c->data[litpos_pos(lp, *p)] == *p); #endif } @ The next few sections deal with how |litpos| is used during solving. When a new |funcsat| gets instantiated, we need to make sure it has a |litpos| in it. @<Initialize func...@>= litpos_init(&f->litpos_uip); f->litpos_uip.c = &f->uipClause; vec_uintptr_grow_to(f->litpos_uip.indices, f->numVars+1); vec_uintptr_push(f->litpos_uip.indices, NO_POS); @ When resizing, resize with no new position info. @<Incrementally resize internal...@>= vec_uintptr_push(f->litpos_uip.indices, NO_POS); @ When a new |funcsat| is destroy, we free. @<Destroy func...@>= litpos_destroy(&f->litpos_uip); @ When conflict analysis begins, we will initialize our (already-allocated) |litpos| with the positions of all literals in the conflicting clause. @<Global def...@>= static inline void litpos_init_from_uip_clause(funcsat *f) { literal *p; struct litpos *lp = &f->litpos_uip; assert(f->numVars+1 == lp->indices->size); assert(lp->c == &f->uipClause); for_clause (p, lp->c) litpos_set(lp, p); } @ @<Internal decl...@>= static inline void litpos_init(struct litpos *); static inline void litpos_destroy(struct litpos *lp); static inline void litpos_init_from_uip_clause(funcsat *f); static inline void litpos_set(struct litpos *lp, literal *p); static inline void litpos_unset(struct litpos *lp, literal p); static inline literal *litpos_lit(struct litpos *pos, literal l); static inline uintptr_t litpos_pos(struct litpos *lp, literal l); static inline bool litpos_contains(struct litpos *pos, literal l); static inline void litpos_clear(struct litpos *lp); extern void litpos_check(struct litpos *lp); @*1 Clause sweeping. It turns you need to sweep the clause database from time to time. \funcsat\ exposes several strategios for sweeping. @*2 glucose strategy. The first strategy we discuss is the \textit{literal blocks distance} (\LBD) heuristic first introduced by glucose. (In this paper: ``Predicting Learnt Clauses Quality in Modern SAT Solvers'' by Audemard and Simon.) The \LBD\ score of a clause is the number of different decision levels of the literals that participate in a clause. For example, for the clause $(-5 \or 6 \or 7)$, if $-5$ and $6$ were set at level 1 and $7$ at level 2, then the \LBD\ of the clause is 2. Incidentally, clauses with \LBD\ 2 are special -- they are called \textit{glue clauses} because they glue decision levels together. We compute the \LBD\ score by walking over the clause and counting levels. But we use a trick borrowed from lookahead solvers: if a literal of level $d$ occurs in the clause, we map that level $d$ to a counter value $c$. If there is a level in the map that is mapped to something other than $c$, we know it didn't occur in this clause. This makes ``clearing'' the map trivial -- we simply increment the counter (which is done on entry to this function). Our auxiliary map is |f->LBD_levels|. |f->LBD_levels.data[d] == f->LBD_count| iff we've seen a literal l in |c| whose level is |d|. |f->LBD_count| is our counter. Things to do: \orderedlist \li I may eventually add a callback to adjust the \LBD\ of clauses as they are unit propagated. \endorderedlist @<Global def...@>= static inline uint8_t LBD_compute_score(funcsat *f, uintptr_t ix) { uint8_t score = 0; struct clause_iter it; #ifndef NDEBUG struct clause_head *h = clause_head_ptr(f, ix); /* only used by |assert| */ #endif f->LBD_count++; /* effectively zeros |f->LBD_levels| */ clause_iter_init(f, ix, &it); for (literal *p = clause_iter_next(f, &it); p; p = clause_iter_next(f, &it)) { literal level = levelOf(f, fs_lit2var(*p)); assert(level != Unassigned); if (f->LBD_levels.data[level] != f->LBD_count) { f->LBD_levels.data[level] = f->LBD_count; score++; } if (score > LBD_SCORE_MAX) break; /* who cares if the score is big. */ } assert(h->sz == 0 || score != 0); /* |sz!=0| implies |score!=0| */ return score; } @ Like many data structures, auxiliary \LBD\ structures need to be initialized, resized, and destroyed. The next few sections take care of this. @<Initialize func...@>= vec_uint64_mk(&f->LBD_levels, 2); vec_uint64_push(&f->LBD_levels, 0); @ @<Incrementally resize internal...@>= vec_uint64_push(&f->LBD_levels, 0); @ @<Destroy func...@>= vec_uint64_unmk(&f->LBD_levels); @ @<Global def...@>= void LBD_decay_after_conflict(funcsat *f) { #if 0 varDecayActivity(f); #endif } @ Each time a new, minimized clause is learned, this function is used to adjust its \LBD\ heuristic value. @<Global def...@>= void LBD_bump_learned(funcsat *f, uintptr_t ix) { struct clause_iter it; struct clause_head *h = clause_head_ptr(f, ix); h->lbd_score = LBD_compute_score(f, ix); clause_iter_init(f, ix, &it); for (literal *p = clause_iter_next(f, &it); p; p = clause_iter_next(f, &it)) { varBumpScore(f, fs_lit2var(*p)); } varDecayActivity(f); } @ As clauses are being learned, we encounter various ``reason'' clauses that participate in the conflict. This function will be called on each of them to adjust their priority. @<Global def...@>= void LBD_bump_reason(funcsat *f, uintptr_t ix) { struct clause_iter it; clause_iter_init(f, ix, &it); for (literal *p = clause_iter_next(f, &it); p; p = clause_iter_next(f, &it)) { variable v = fs_lit2var(*p); #if 0 uintptr_t r = getReason(f, (literal)v); if (r != NO_CLS) { struct clause_head *h = clause_head_ptr(f,r); if (h->lbd_score == 2) { /* bump twice for glue */ varBumpScore(f, fs_lit2var(h->lits[0])); } } #endif varBumpScore(f, fs_lit2var(*p)); } } @ The first task of |LBD_sweep| is to figure out if it's time to perform a sweep. We use essentially the same test as in glucose. @<Global def...@>= void LBD_sweep(funcsat *f, void *user) { uint64_t diffConfl = f->numConflicts - f->LBD_last_num_conflicts; #if 0 uint64_t avg = diffConfl==0 ? 1 : Max(1, diffLearn/diffConfl); #endif uint64_t next = f->LBD_base + f->LBD_increment*f->numSweeps; /* in the glucose paper they used 20000+500*num */ assert(next > 0); if (diffConfl > next) { ++f->numSweeps; @<Sweep clauses with \LBD...@>@; } } @ Settings from the glucose paper. @<Initialize func...@>= f->LBD_base = 20000; f->LBD_increment = 500; @ Both original and learned clauses are in the same watcher list data structure. It would be nice not to have to entirely recreate that structure every time we want to delete clauses. First, compute the max number of clauses to delete, $m$. Let $M$ be |LBD_SCORE_MAX|. Second, compute a histogram of \LBD\ scores. For each score (in ascending order) from $n \in [1,M]$, count how many clauses have that score. Beginning from $M$, compute a running sum $x$ until $x+n > m$. This way all clauses with score greater than the threshold $n$ will surely be deleted (unless they are pinned -- more later); scores $n$ and lower contain some clauses that may be deleted and others that won't. Basically, we've computed a loose percentile of the clauses to delete. Next, walk over the learned clauses again and mark to delete those beyond the threshold. And walk over the watchlists to delete the references to them. Guess what -- we don't have to sort the learned clauses by priority! Now if only I can get away with not walking over the watchlists.... @<Sweep clauses with \LBD\ heuristic@>= uint64_t bad_clauses; /* num. clauses worse than threshold */ uint8_t del_score; /* deletion threshold */ uint64_t max_del = f->learned_clauses->size/2, num_del = 0; fslog(f, "sweep", 1, "%ju learned clauses\n", f->learned_clauses->size); fslog(f, "sweep", 1, "max_del is %" PRIu64 "\n", max_del); @<Create histogram...@>@; fslog(f, "sweep", 2, "bad_clauses is %" PRIu64 "\n", bad_clauses); fslog(f, "sweep", 2, "del_score is %" PRIu8 "\n", del_score); if (del_score > 2) { @<Delete clauses worse than \LBD...@>@; @<Delete middling clauses by \LBD@>@; } fslog(f, "sweep", 1, "deleted %" PRIu64 " clauses\n", num_del); f->LBD_last_num_conflicts = f->numConflicts; @ @<Create histogram of \LBD\ scores and compute |del_score| and |bad_clauses|@>= del_score = 0, bad_clauses = 0; vec_uint64_zero(&f->LBD_histogram); for_vec_uintptr (ix_cls, f->learned_clauses) { assert(clause_head_ptr(f, *ix_cls)->lbd_score > 0); f->LBD_histogram.data[clause_head_ptr(f, *ix_cls)->lbd_score]++; } for (uint8_t s = LBD_SCORE_MAX; s > 0; s--) { if (bad_clauses + f->LBD_histogram.data[s] > max_del) { del_score = s; break; } bad_clauses += f->LBD_histogram.data[s]; } assert(del_score); @ @<We can mark head |h| for deletion@>= (h->is_learned && !h->is_reason && h->where==CLAUSE_WATCHED && h->lbd_score > del_score) @ Same as previous section except we assume the clause is learned. @<We can mark learned head |h| for deletion@>= (!h->is_reason && h->where==CLAUSE_WATCHED && h->lbd_score > del_score) @ Deleting the clauses has two steps. First we walk the watchlist to delete the corresponding watches. Second we walk the learned clauses free them globally -- this way we don't have dangling pointers. @<Delete clauses worse than \LBD\ score of |del_score|@>= if (bad_clauses) { uintptr_t i, new_size; for (variable v = 1; v <= f->numVars; v++) { struct watchlist_elt *elt, *dump; struct watchlist *wl; wl = &f->watches.wlist[fs_lit2idx((literal)v)], new_size = wl->size; for_watchlist (elt, dump, wl) { @<Delete watchlist |elt| if...@>@; } wl->size = new_size; wl = &f->watches.wlist[fs_lit2idx(-(literal)v)], new_size = wl->size; for_watchlist (elt, dump, wl) { @<Delete watchlist |elt| if...@>@; } wl->size = new_size; } for (i = 0, new_size = 0; i < f->learned_clauses->size; i++) { uintptr_t elt = f->learned_clauses->data[i]; struct clause_head *h = clause_head_ptr(f, elt); if (@<We can mark learned head |h|...@>) { num_del++, bad_clauses--; f->numLearnedDeleted++; fslog(f, "sweep", 6, "deleted %" PRIuPTR "\n", elt); clause_release(f, elt); } else f->learned_clauses->data[new_size++] = elt; } f->learned_clauses->size = new_size; } @ @<Delete watchlist |elt| if score no less than |del_score|@>= struct clause_head *h = clause_head_ptr(f, elt->cls); if (@<We can mark head |h|...@>) { fs_ifdbg(f, "sweep", 5) { fslog(f, "sweep", 5, "marked clause "); fs_clause_head_print(f, fs_dbgout(f), elt->cls); fprintf(fs_dbgout(f), " score is %x", (unsigned)clause_head_ptr(f, elt->cls)->lbd_score); NEWLINE(fs_dbgout(f)); } new_size--; continue; /* means to delete this |watchlist_elt| */ } *dump = *elt, watchlist_next_elt(dump, wl); /* keep |elt| in this |wl| */ @ This isn't implemented yet. @<Delete middling clauses by \LBD@>= @ Obviously we should initialize the histogram when \funcsat\ starts up. @<Initialize func...@>= vec_uint64_mk(&f->LBD_histogram, LBD_SCORE_MAX+1); f->LBD_histogram.size = LBD_SCORE_MAX+1; @ @<Destroy func...@>= vec_uint64_unmk(&f->LBD_histogram); @ @<Global def...@>= static int LBD_compare_rev(void *fp, const void *cl1, const void *cl2) { funcsat *f = (funcsat *)fp; struct clause_head *c1 = clause_head_ptr(f, *(uintptr_t *)cl1); struct clause_head *c2 = clause_head_ptr(f, *(uintptr_t *)cl2); uint64_t s1 = c1->lbd_score, s2 = c2->lbd_score; if (s1 == s2) return 0; else if (s1 > s2) return -1; else return 1; } @ @<Internal decl...@>= static int compareByActivityRev(const void *cl1, const void *cl2); static int LBD_compare_rev(void *f, const void *cl1, const void *cl2); void LBD_bump_reason(funcsat *f, uintptr_t c); void LBD_bump_learned(funcsat *f, uintptr_t C); static inline uint8_t LBD_compute_score(funcsat *f, uintptr_t c); void LBD_decay_after_conflict(funcsat *f); void LBD_sweep(funcsat *f, void *user); @ In order to use the \LBD\ strategy, we expose a client function. @<Global def...@>= void funcsatSetupLbdGc(funcsat_config *conf) { conf->gc = true; conf->sweepClauses = LBD_sweep; conf->bumpReason = LBD_bump_reason; conf->bumpLearned = LBD_bump_learned; conf->decayAfterConflict = LBD_decay_after_conflict; } @ @<External decl...@>= void funcsatSetupLbdGc(funcsat_config *); @*2 activity strategy. @<Global def...@>= void claActivitySweep(funcsat *f, void *user) { static uint64_t num = 0, lastNumConflicts = 0, lastNumLearnedClauses = 0; #if 0 const uint64_t diffConfl = f->numConflicts - lastNumConflicts; const uint64_t diffLearn = f->numLearnedClauses - lastNumLearnedClauses; uint64_t size = f->learnedClauses.size; double extraLim = f->claInc / (size*1.f); if (f->numLearnedClauses*1.f >= f->maxLearned) { ++f->numSweeps; uint64_t numDeleted = 0; /* sort by activity and delete half */ qsort(f->learnedClauses.data, f->learnedClauses.size, sizeof(clause *), compareByActivityRev); fs_ifdbg (f, "sweep", 5) { uint64_t dupCount = 0; int32_t lastLbd = LBD_SCORE_MAX; FILE *out = f->conf->debugStream; fprintf(out, "sorted:\n"); clause **it; forVectorRev (clause **, it, &f->learnedClauses) { if ((*it)->lbdScore == lastLbd) { dupCount++; } else { if (dupCount > 0) { fprintf(out, "(repeats %" PRIu64 " times) %d ", dupCount, (*it)->lbdScore); } else { fprintf(out, "%d ", (*it)->lbdScore); } dupCount = 0; lastLbd = (*it)->lbdScore; } } if (dupCount > 0) { fprintf(out, "%d (repeats %" PRIu64 " times) ", lastLbd, dupCount); } fprintf(out, "done\n"); } /* restore proper clause ids after sort. |funcsatRemoveClause| depends on this. */ for (uintmax_t i = 0; i < f->learnedClauses.size; i++) { clause *c = f->learnedClauses.data[i]; } /* remove clauses with 0 activity */ #if 0 for (variable i = 0; i < f->learnedClauses.size; i++) { clause *c = f->learnedClauses.data[i]; if (c->activity == 0.f) { clause *rmClause = funcsatRemoveClause(f, c); if (rmClause) { clauseFree(c); --f->numLearnedClauses, ++f->numLearnedDeleted, ++numDeleted; } } else break; } #endif const uint64_t max = f->learnedClauses.size/2; fslog(f, "sweep", 1, "deleting at most %" PRIu64 " clauses (of %ju)\n", max, f->learnedClauses.size); for (variable i = 0; i < f->learnedClauses.size && f->learnedClauses.size > max; i++) { clause *c = f->learnedClauses.data[i]; if (c->size > 2) { clause *rmClause = funcsatRemoveClause(f, c); if (rmClause) { clauseFree(c); --f->numLearnedClauses, ++f->numLearnedDeleted, ++numDeleted; } } } fslog(f, "sweep", 1, ">>> deleted %" PRIu64 " clauses\n", numDeleted); num++; lastNumLearnedClauses = f->numLearnedClauses; lastNumConflicts = f->numConflicts; } #endif } @ More bupming. @<Global def...@>= void bumpReasonByActivity(funcsat *f, uintptr_t ix) { struct clause_iter it; bumpClauseByActivity(f, ix); clause_iter_init(f, ix, &it); for (literal *p = clause_iter_next(f, &it); p; p = clause_iter_next(f, &it)) { varBumpScore(f, fs_lit2var(*p)); } } void bumpLearnedByActivity(funcsat *f, uintptr_t ix) { struct clause_iter it; bumpClauseByActivity(f, ix); clause_iter_init(f, ix, &it); for (literal *p = clause_iter_next(f, &it); p; p = clause_iter_next(f, &it)) { varBumpScore(f, fs_lit2var(*p)); varBumpScore(f, fs_lit2var(*p)); } if (--f->learnedSizeAdjustCnt == 0) { f->learnedSizeAdjustConfl *= f->learnedSizeAdjustInc; f->learnedSizeAdjustCnt = (uint64_t)f->learnedSizeAdjustConfl; f->maxLearned *= f->learnedSizeInc; fslog(f, "sweep", 1, "update: ml %f\n", f->maxLearned); } varDecayActivity(f); claDecayActivity(f); } void lbdBumpActivity(funcsat *f, uintptr_t ix) { struct clause_iter it; clause_iter_init(f, ix, &it); for (literal *p = clause_iter_next(f, &it); p; p = clause_iter_next(f, &it)) { variable v = fs_lit2var(*p); uintptr_t reason = getReason(f, (literal)v); struct clause_head *h = clause_head_ptr(f, reason); if (reason != NO_CLS && h->lbd_score == 2) { varBumpScore(f,v); } } } @ @<Global def...@>= static void bumpClauseByActivity(funcsat *f, uintptr_t ix) { struct clause_iter it; struct clause_head *h = clause_head_ptr(f, ix); /* if the clause's activity is too large, rescale */ if ((h->activity += f->claInc) > 1e20) { fslog(f, "sweep", 5, "rescale for activity %f\n", h->activity); for_vec_uintptr (ix_cl, f->learned_clauses) { struct clause_head *h_cl = clause_head_ptr(f, *ix_cl); double oldActivity = h_cl->activity; h_cl->activity *= 1e-20; fslog(f, "sweep", 5, "setting activity from %f to %f\n", oldActivity, h_cl->activity); } double oldClaInc = f->claInc; f->claInc *= 1e-20; fslog(f, "sweep", 5, "setting claInc from %f to %f\n", oldClaInc, f->claInc); } } static inline void varDecayActivity(funcsat *f) { f->varInc *= (1 / f->varDecay); } static void claDecayActivity(funcsat *f) { double oldClaInc = f->claInc; f->claInc *= (1 / f->claDecay); fslog(f, "sweep", 9, "decaying claInc from %f to %f\n", oldClaInc, f->claInc); } @*1 Restart functions. @<Global def...@>= void incLubyRestart(funcsat *f, bool skip); bool funcsatNoRestart(funcsat *f, void *p) { return false; } bool funcsatLubyRestart(funcsat *f, void *p) { if ((intmax_t)f->numConflicts >= f->lrestart && f->decisionLevel > 2) { incLubyRestart(f, false); return true; } return false; } bool funcsatInnerOuter(funcsat *f, void *p) { static uint64_t inner = 100UL, outer = 100UL, conflicts = 1000UL; if (f->numConflicts >= conflicts) { conflicts += inner; if (inner >= outer) { outer *= 1.1; inner = 100UL; } else { inner *= 1.1; } return true; } return false; } bool funcsatMinisatRestart(funcsat *f, void *p) { static uint64_t cutoff = 100UL; if (f->numConflicts >= cutoff) { cutoff *= 1.5; return true; } return false; } /* This stuff was cribbed from \picosat\ and changed a smidge just to get bigger * integers. */ int64_t luby(int64_t i) { int64_t k; for (k = 1; k < (int64_t)sizeof(k); k++) if (i == (1 << k) - 1) return 1 << (k - 1); for (k = 1;; k++) if ((1 << (k - 1)) <= i && i < (1 << k) - 1) return luby (i - (1 << (k-1)) + 1); } void incLubyRestart(funcsat *f, bool skip) { uint64_t delta; /* Luby calculation takes a really long time around 255? */ if (f->lubycnt > 250) { f->lubycnt = 0; f->lubymaxdelta = 0; f->waslubymaxdelta = false; } delta = 100 * (uint64_t)luby((int64_t)++f->lubycnt); f->lrestart = (int64_t)(f->numConflicts + delta); /* if (waslubymaxdelta) */ /* report (1, skip ? 'N' : 'R'); */ /* else */ /* report (2, skip ? 'n' : 'r'); */ if (delta > f->lubymaxdelta) { f->lubymaxdelta = delta; f->waslubymaxdelta = 1; } else { f->waslubymaxdelta = 0; } } @*1 Configuration. \funcsat\ is configurable in many ways. The |funcsat_config| type is responsible for \funcsat's configuration. @<Internal decl...@>= void myDecayAfterConflict(funcsat *f); @ @<Global def...@>= funcsat_config funcsatDefaultConfig = { .user = NULL, .name = NULL, .usePhaseSaving = true, .useSelfSubsumingResolution = false, .minimizeLearnedClauses = true, .numUipsToLearn = UINT32_MAX, .gc = true, .maxJailDecisionLevel = 0, .logSyms = NULL, .printLogLabel = true, .debugStream = NULL, .isTimeToRestart = funcsatLubyRestart, .isResourceLimitHit = funcsatIsResourceLimitHit, .preprocessNewClause = funcsatPreprocessNewClause, .preprocessBeforeSolve = funcsatPreprocessBeforeSolve, .getInitialActivity = funcsatDefaultStaticActivity, .sweepClauses = LBD_sweep, .bumpOriginal = bumpOriginal, .bumpReason = LBD_bump_reason, .bumpLearned = LBD_bump_learned, .bumpUnitClause = bumpUnitClauseByActivity, .decayAfterConflict = LBD_decay_after_conflict, }; @ We have the option of bumping the priority of variables as clauses are added to \funcsat. @<Global def...@>= void bumpOriginal(funcsat *f, uintptr_t ix_clause) { struct clause_head *h = clause_head_ptr(f, ix_clause); double orig_varInc = f->varInc; struct clause_iter it; f->varInc += 2.*(1./(double)h->sz); clause_iter_init(f, ix_clause, &it); for (literal *p = clause_iter_next(f, &it); p; p = clause_iter_next(f, &it)) { varBumpScore(f, fs_lit2var(*p)); } f->varInc = orig_varInc; #if 0 forClause (it, c) { varBumpScore(f, fs_lit2var(*it)); } #endif } double funcsatDefaultStaticActivity(variable *v) { return 1.f; } void myDecayAfterConflict(funcsat *f) { varDecayActivity(f); claDecayActivity(f); } void bumpUnitClauseByActivity(funcsat *f, uintptr_t ix) { bumpClauseByActivity(f, ix); } @ Prototypes. @<Internal decl...@>= void bumpOriginal(funcsat *f, uintptr_t c); void bumpReasonByActivity(funcsat *f, uintptr_t c); void bumpLearnedByActivity(funcsat *f, uintptr_t c); void bumpUnitClauseByActivity(funcsat *f, uintptr_t c); void lbdBumpActivity(funcsat *f, uintptr_t c); static inline void varDecayActivity(funcsat *f); static void claDecayActivity(funcsat *f); static void bumpClauseByActivity(funcsat *f, uintptr_t c); extern void varBumpScore(funcsat *f, variable v); @ @<Internal decl...@>= void claActivitySweep(funcsat *f, void *user); @*1 Initialization. Requires an initialized configuration. @<Initialize parameters@>= f->varInc = 1.f; f->varDecay = 0.95f; /* or 0.999f; */ f->claInc = 1.f; f->claDecay = 0.9999f; /* or 0.95f; */ f->learnedSizeFactor = 1.f / 3.f; f->learnedSizeAdjustConfl = 25000; /* see |startSolving| */ f->learnedSizeAdjustCnt = 25000; f->maxLearned = 20000.f; f->learnedSizeAdjustInc = 1.5f; f->learnedSizeInc = 1.1f; @ Initially allocates a |funcsat| object. @c funcsat *funcsatInit(funcsat_config *conf) { funcsat *f; FS_CALLOC(f, 1, sizeof(*f)); f->conf = conf; f->propq = 0; @<Initialize parameters@>@; fslog(f, "sweep", 1, "set maxLearned to %f\n", f->maxLearned); fslog(f, "sweep", 1, "set 1/f->claDecoy to %f\n", 1.f/f->claDecay); f->lrestart = 1; f->lubycnt = 0; f->lubymaxdelta = 0; f->waslubymaxdelta = false; f->numVars = 0; @<Initialize funcsat type@>@; clauseInit(&f->assumptions, 0); vec_uintmax_mk(&f->model, 2); vec_uintmax_push(&f->model, 0); clauseInit(&f->phase, 2); clausePush(&f->phase, 0); clauseInit(&f->level, 2); clausePush(&f->level, Unassigned); vec_uintmax_mk(&f->decisions, 2); vec_uintmax_push(&f->decisions, 0); clauseInit(&f->trail, 2); all_watches_init(f); clauseInit(&f->uipClause, 100); vec_ptr_mk(&f->subsumed, 10); return f; } @ Initializes a |funcsat| configuration. @c funcsat_config *funcsatConfigInit(void *userData) { funcsat_config *conf = malloc(sizeof(*conf)); memcpy(conf, &funcsatDefaultConfig, sizeof(*conf)); #ifdef FUNCSAT_LOG conf->logSyms = create_hashtable(16, hashString, stringEqual); vec_uintmax_mk(&conf->logStack, 2); vec_uintmax_push(&conf->logStack, 0); conf->debugStream = stderr; #endif return conf; } void funcsatConfigDestroy(funcsat_config *conf) { #ifdef FUNCSAT_LOG hashtable_destroy(conf->logSyms, true, true); vec_uintmax_unmk(&conf->logStack); #endif free(conf); } @ For incrementality, \funcsat\ resizes for a given predicted or known number of variables. It just goes through and grows every data structure to fit |numVars|. @c void funcsatResize(funcsat *f, variable numVars) { assert(f->decisionLevel == 0); /* so we can fix up unit facts */ if (numVars > f->numVars) { const variable old = f->numVars, new = numVars; f->numVars = new; variable i; clauseGrowTo(&f->uipClause, numVars); @<Resize internal data structures up to new |numVars|@>@; for (i = old; i < new; i++) { variable v = i+1; @<Incrementally resize internal data structures up to new |numVars|@>@; #if 0 literal l = fs_var2lit(v); #endif vec_uintmax_push(&f->model, UINTMAX_MAX); clausePush(&f->phase, -fs_var2lit(v)); clausePush(&f->level, Unassigned); vec_uintmax_push(&f->decisions, 0); } uintmax_t highestIdx = fs_lit2idx(-(literal)numVars)+1; assert(f->model.size == numVars+1); assert(!f->conf->usePhaseSaving || f->phase.size == numVars+1); assert(f->level.size == numVars+1); assert(f->decisions.size == numVars+1); assert(f->reason->size == numVars+1); assert(f->unit_facts_size == numVars+1); assert(f->uipClause.capacity >= numVars); assert(f->allLevels.size == numVars+1); assert(f->watches.size == highestIdx); if (numVars > f->trail.capacity) { FS_REALLOC(f->trail.data, numVars, sizeof(*f->trail.data)); f->trail.capacity = numVars; } } } @ Destroys a |funcsat|. @c void funcsatDestroy(funcsat *f) { literal i; while (f->trail.size > 0) trailPop(f, NULL); @<Destroy funcsat type@>@; clauseDestroy(&f->assumptions); vec_uintmax_unmk(&f->model); clauseDestroy(&f->phase); clauseDestroy(&f->level); vec_uintmax_unmk(&f->decisions); clauseDestroy(&f->trail); clauseDestroy(&f->uipClause); vec_ptr_unmk(&f->subsumed); free(f); } @ @c void funcsatSetupActivityGc(funcsat_config *conf) { conf->gc = true; conf->sweepClauses = claActivitySweep; conf->bumpReason = bumpReasonByActivity; conf->bumpLearned = bumpLearnedByActivity; conf->decayAfterConflict = myDecayAfterConflict; } funcsat_result funcsatResult(funcsat *f) { return f->lastResult; } @ These two functions are for sanity's sake. @c funcsat_result startSolving(funcsat *f) { f->numSolves++; if (f->conflict_clause != NO_CLS) { struct clause_head *h = clause_head_ptr(f, f->conflict_clause); if(h->sz == 0) { return FS_UNSAT; } else { f->conflict_clause = NO_CLS; } } backtrack(f, 0UL, NULL, true); f->lastResult = FS_UNKNOWN; assert(f->decisionLevel == 0); return FS_UNKNOWN; } /** * Call me whenever (incremental) solving is done, whether because of a timeout * or whatever. */ static void finishSolving(funcsat *f) { } @ Another break. @c static bool bcpAndJail(funcsat *f) { if (!bcp(f)) { fslog(f, "solve", 2, "returning false at toplevel\n"); return false; } fslog(f, "solve", 1, "bcpAndJail trailsize is %ju\n", f->trail.size); clause **cIt; struct vec_ptr *watches; uint64_t numJails = 0; #if 0 forVector (clause **, cIt, &f->origClauses) { if ((*cIt)->is_watched) { literal *lIt; bool allFalse = true; forClause (lIt, *cIt) { mbool value = funcsatValue(f, *lIt); if (value == false) continue; allFalse = false; if (value == true) { /* jail the clause, it is satisfied */ clause **w0 = (clause **) &watches->data[fs_lit2idx(-(*cIt)->data[0])]; /* assert(watcherFind(*cIt, w0, 0)); */ clause **w1 = (clause **) &watches->data[fs_lit2idx(-(*cIt)->data[1])]; /* assert(watcherFind(*cIt, w1, 0)); */ /* clauseUnSpliceWatch(w0, *cIt, 0); */ clauseUnSpliceWatch(w1, *cIt, 1); jailClause(f, *lIt, *cIt); numJails++; break; } } if (allFalse) { fslog(f, "solve", 2, "returning false at toplevel\n"); return false; } } } #endif fslog(f, "solve", 2, "jailed %" PRIu64 " clauses at toplevel\n", numJails); return true; } bool funcsatIsResourceLimitHit(funcsat *f, void *p) { return false; } funcsat_result funcsatPreprocessNewClause(funcsat *f, void *p, clause *c) { return (f->lastResult = FS_UNKNOWN); } funcsat_result funcsatPreprocessBeforeSolve(funcsat *f, void *p) { return (f->lastResult = FS_UNKNOWN); } @ Rest of stuff. @c void funcsatPrintStats(FILE *stream, funcsat *f) { fprintf(stream, "c %" PRIu64 " decisions\n", f->numDecisions); fprintf(stream, "c %" PRIu64 " propagations (%" PRIu64 " unit)\n", f->numProps + f->numUnitFactProps, f->numUnitFactProps); fprintf(stream, "c %" PRIu64 " jailed clauses\n", f->numJails); fprintf(stream, "c %" PRIu64 " conflicts\n", f->numConflicts); fprintf(stream, "c %" PRIu64 " learned clauses\n", f->numLearnedClauses); fprintf(stream, "c %" PRIu64 " learned clauses removed\n", f->numLearnedDeleted); fprintf(stream, "c %" PRIu64 " learned clause deletion sweeps\n", f->numSweeps); if (!f->conf->minimizeLearnedClauses) { fprintf(stream, "c (learned clause minimisation off)\n"); } else { fprintf(stream, "c %" PRIu64 " redundant learned clause literals\n", f->numLiteralsDeleted); } if (!f->conf->useSelfSubsumingResolution) { fprintf(stream, "c (on-the-fly self-subsuming resolution off)\n"); } else { fprintf(stream, "c %" PRIu64 " subsumptions\n", f->numSubsumptions); fprintf(stream, "c - %" PRIu64 " original clauses\n", f->numSubsumedOrigClauses); fprintf(stream, "c - %" PRIu64 " UIPs (%2.2lf%%)\n", f->numSubsumptionUips, (double)f->numSubsumptionUips*100./(double)f->numSubsumptions); } fprintf(stream, "c %" PRIu64 " restarts\n", f->numRestarts); fprintf(stream, "c %d assumptions\n", f->assumptions.size); fprintf(stream, "c %ju original clauses\n", f->orig_clauses->size); } void funcsatPrintColumnStats(FILE *stream, funcsat *f) { struct rusage usage; getrusage(RUSAGE_SELF, &usage); double uTime = ((double)usage.ru_utime.tv_sec) + ((double)usage.ru_utime.tv_usec)/1000000; double sTime = ((double)usage.ru_stime.tv_sec) + ((double)usage.ru_stime.tv_usec)/1000000; fprintf(stream, "Name,NumDecisions,NumPropagations,NumUfPropagations," "NumLearnedClauses,NumLearnedClausesRemoved," "NumLearnedClauseSweeps,NumConflicts,NumSubsumptions," "NumSubsumedOrigClauses,NumSubsumedUips,NumRestarts," "UserTimeSeconds,SysTimeSeconds\n"); fprintf(stream, "%s,", f->conf->name); fprintf(stream, "%" PRIu64 ",%" PRIu64 ",%" PRIu64 ",%" PRIu64 ",%" PRIu64 ",%" PRIu64 ",%" PRIu64 ",%" PRIu64 ",%" PRIu64 ",%" PRIu64 ",%" PRIu64 ",%.2lf,%.2lf\n", f->numDecisions, f->numProps + f->numUnitFactProps, f->numUnitFactProps, f->numLearnedClauses, f->numLearnedDeleted, f->numSweeps, f->numConflicts, f->numSubsumptions, f->numSubsumedOrigClauses, f->numSubsumptionUips, f->numRestarts, uTime, sTime); } void funcsatBumpLitPriority(funcsat *f, literal p) { varBumpScore(f, fs_lit2var(p)); } /* FORMERLY INTERNAL.H */ /* defaults */ literal levelOf(funcsat *f, variable v) { return f->level.data[v]; } literal fs_var2lit(variable v) { literal result = (literal) v; assert((variable) result == v); return result; } inline variable fs_lit2var(literal l) { if (l < 0) { l = -l; } return (variable) l; } uintmax_t fs_lit2idx(literal l) { /* just move sign bit into the lowest bit instead of the highest */ variable v = fs_lit2var(l); v <<= 1; v |= (l < 0); return v; } inline bool isDecision(funcsat *f, variable v) { return 0 != f->decisions.data[v]; } #if 0 void singlesPrint(FILE *stream, clause *begin) { clause *c = begin; if (c) { do { clause *next = c->next[0]; clause *prev = c->prev[0]; if (!next) { fprintf(stream, "next is NULL"); return; } if (!prev) { fprintf(stream, "prev is NULL"); return; } if (next->prev[0] != c) fprintf(stream, "n*"); if (prev->next[0] != c) fprintf(stream, "p*"); clause_head_print_dimacs(stream, c); c = next; if (c != begin) fprintf(stream, ", "); } while (c != begin); } else { fprintf(stream, "NULL"); } } #endif #if 0 void watcherPrint(FILE *stream, clause *c, uint8_t w) { if (!c) { fprintf(stream, "EMPTY\n"); return; } clause *begin = c; literal data = c->data[w]; fprintf(stream, "watcher list containing lit %ji\n", c->data[w]); do { uint8_t i = c->data[0]==data ? 0 : 1; clause *next = c->next[i]; if (!next) { fprintf(stream, "next is NULL\n"); return; } if (!(next->prev[ next->data[0]==c->data[i] ? 0 : 1 ] == c)) { fprintf(stream, "*"); } clause_head_print_dimacs(stream, c); fprintf(stream, "\n"); c = next; } while (c != begin); } bool watcherFind(clause *c, clause **watches, uint8_t w) { clause *curr = *watches, *nx, *end; uint8_t wi; bool foundEnd; forEachWatchedClause(curr, c->data[w], wi, nx, end, foundEnd) { if (curr == c) return true; } return false; } void binWatcherPrint(FILE *stream, funcsat *f) { variable v; uintmax_t i; for (v = 1; v <= f->numVars; v++) { binvec_t *bv = f->watchesBin.data[fs_lit2idx(fs_var2lit(v))]; if (bv->size > 0) { fprintf(stream, "%5ji -> ", fs_var2lit(v)); for (i = 0; i < bv->size; i++) { literal imp = bv->data[i].implied; fprintf(stream, "%ji", imp); if (i+1 != bv->size) fprintf(stream, ", "); } fprintf(stream, "\n"); } bv = f->watchesBin.data[fs_lit2idx(-fs_var2lit(v))]; if (bv->size > 0) { fprintf(stream, "%5ji -> ", -fs_var2lit(v)); for (i = 0; i < bv->size; i++) { literal imp = bv->data[i].implied; fprintf(stream, "%ji", imp); if (i+1 != bv->size) fprintf(stream, ", "); } fprintf(stream, "\n"); } } } #endif uintmax_t funcsatNumClauses(funcsat *f) { return f->orig_clauses->size; } uintmax_t funcsatNumVars(funcsat *f) { return f->numVars; } @ @c void funcsatPrintHeuristicValues(FILE *p, funcsat *f) { for (variable i = 1; i <= f->numVars; i++) { double *value = bh_var2act(f,i); fprintf(p, "%ju = %4.2lf\n", i, *value); } fprintf(p, "\n"); } void fs_print_state(funcsat *f, FILE *p) { variable i; literal *it; if (!p) p = stderr; fprintf(p, "assumptions: "); forClause (it, &f->assumptions) { fprintf(p, "%ji ", *it); } fprintf(p, "\n"); fprintf(p, "dl %ju (%" PRIu64 " X, %" PRIu64 " d, %" PRIu64 " r)\n", f->decisionLevel, f->numConflicts, f->numDecisions, f->numRestarts); if (f->conflict_clause != NO_CLS) fprintf(p, "cc %" PRIuPTR "\n", f->conflict_clause); if (f->uipClause.size > 0) fprintf(p, "uipc "), fs_clause_print(f, p, &f->uipClause), fprintf(p, "\n"); fprintf(p, "trail (%" PRIu32 "): ", f->trail.size); for (i = 0; i < f->trail.size; i++) { fprintf(p, "%2ji", f->trail.data[i]); if (f->decisions.data[fs_lit2var(f->trail.data[i])] != 0) { fprintf(p, "@@%ju", f->decisions.data[fs_lit2var(f->trail.data[i])]); } if (!head_tail_is_empty(&f->unit_facts[fs_lit2var(f->trail.data[i])])) { fprintf(p, "*"); } #if 0 if (!clauseIsAlone(&f->jail.data[fs_lit2var(f->trail.data[i])], 0)) { fprintf(p, "!"); } #endif fprintf(p, " "); } fprintf(p, "\n"); fprintf(p, "model: "); for (i = 1; i <= f->numVars; i++) { if (levelOf(f, i) != Unassigned) { fprintf(p, "%3ji@@%ji ", f->trail.data[f->model.data[i]], levelOf(f, i)); } } fprintf(p, "\n"); fprintf(p, "pq: %ju (-> %ji)\n", f->propq, f->trail.data[f->propq]); } @ @c void funcsatPrintConfig(FILE *stream, funcsat *f) { funcsat_config *conf = f->conf; if (NULL != conf->user) fprintf(stream, "Has user data\n"); if (NULL != conf->name) fprintf(stream, "Name: %s\n", conf->name); conf->usePhaseSaving ? fprintf(stream, "phsv\t") : fprintf(stream, "NO phsv\t"); conf->useSelfSubsumingResolution ? fprintf(stream, "ssr\t") : fprintf(stream, "NO ssr\t"); conf->minimizeLearnedClauses ? fprintf(stream, "min\t") : fprintf(stream, "NO min\t"); // TODO MAL check if (true == conf->gc) { if (LBD_sweep == conf->sweepClauses) { fprintf(stream, "gc glucose\t"); } else if (claActivitySweep == conf->sweepClauses) { fprintf(stream, "gc minisat\t"); } else { abort(); /* impossible */ } } else { fprintf(stream, "NO gc\t\t"); assert(NULL == conf->sweepClauses); } if (funcsatLubyRestart == conf->isTimeToRestart) { fprintf(stream, "restart luby\t"); } else if (funcsatNoRestart == conf->isTimeToRestart) { fprintf(stream, "restart none\t"); } else if (funcsatInnerOuter == conf->isTimeToRestart) { fprintf(stream, "restart inout\t"); } else if (funcsatMinisatRestart == conf->isTimeToRestart) { fprintf(stream, "restart minisat\t"); } else { abort(); /* impossible */ } fprintf(stream, "learn %" PRIu32 " uips\t\t", conf->numUipsToLearn); // TODO MAL this is how to print? fprintf(stream, "Jail up to %" PRIuMAX " uips\n", conf->maxJailDecisionLevel); #if 0 if (funcsatIsResourceLimitHit == conf->isResourceLimitHit) { fprintf(stream, " resource hit default\n"); } else { abort(); } if (funcsatPreprocessNewClause == conf->preprocessNewClause) { fprintf(stream, " UNUSED preprocess new clause default\n"); } else { abort(); } if (funcsatPreprocessBeforeSolve == conf->preprocessBeforeSolve) { fprintf(stream, " UNUSED preprocess before solve default\n"); } else { abort(); } if (funcsatDefaultStaticActivity == conf->getInitialActivity) { fprintf(stream, " initial activity static (default)\n"); } else { abort(); } #endif } void funcsatPrintCnf(FILE *stream, funcsat *f, bool learned) { fprintf(stream, "c clauses: %ju original", funcsatNumClauses(f)); if (learned) { fprintf(stream, ", %ju learned", f->learned_clauses->size); } fprintf(stream, "\n"); uintmax_t num_assumptions = 0; for (uintmax_t i = 0; i < f->assumptions.size; i++) { if(f->assumptions.data[i] != 0) num_assumptions++; } fprintf(stream, "c %ju assumptions\n", num_assumptions); uintmax_t numClauses = funcsatNumClauses(f) + (learned ? f->learned_clauses->size : 0) + num_assumptions; fprintf(stream, "p cnf %ju %ju\n", funcsatNumVars(f), numClauses); for (uintmax_t i = 0; i < f->assumptions.size; i++) { if(f->assumptions.data[i] != 0) fprintf(stream, "%ji 0\n", f->assumptions.data[i]); } vec_clause_head_print_dimacs(f, stream, f->orig_clauses); if (learned) { fprintf(stream, "c learned\n"); vec_clause_head_print_dimacs(f, stream, f->learned_clauses); } } void funcsatClearStats(funcsat *f) { f->numSweeps = 0; f->numLearnedDeleted = 0; f->numLiteralsDeleted = 0; f->numProps = 0; f->numUnitFactProps = 0; f->numConflicts = 0; f->numRestarts = 0; f->numDecisions = 0; f->numSubsumptions = 0; f->numSubsumedOrigClauses = 0; f->numSubsumptionUips = 0; } char *funcsatResultAsString(funcsat_result result) { switch (result) { case FS_UNKNOWN: return "UNKNOWN"; case FS_SAT: return "SATISFIABLE"; case FS_UNSAT: return "UNSATISFIABLE"; default: abort(); /* impossible */ } } bool isUnitClause(funcsat *f, clause *c) { variable i, numUnknowns = 0, numFalse = 0; for (i = 0; i < c->size; i++) { if (funcsatValue(f, c->data[i]) == unknown) { numUnknowns++; } else if (funcsatValue(f, c->data[i]) == false) { numFalse++; } } return numUnknowns==1 && numFalse==c->size-(uintmax_t)1; } int varOrderCompare(fibkey *a, fibkey *b) { fibkey k = *a, l = *b; if (k > l) { return -1; } else if (k < l) { return 1; } else { return 0; } } clause *funcsatRemoveClause(funcsat *f, clause *c) { return NULL; } #if 0 { assert(c->isLearnt); if (c->isReason) return NULL; if (c->is_watched) { /* remove \& release from the two watchers we had */ clause **w0 = (clause **) &f->watches.data[fs_lit2idx(-c->data[0])]; clause **w1 = (clause **) &f->watches.data[fs_lit2idx(-c->data[1])]; clauseUnSpliceWatch(w0, c, 0); clauseUnSpliceWatch(w1, c, 1); } else { /* clause is in unit facts or jailed */ clause *copy = c; clauseUnSplice(&copy, 0); } vector *clauses; if (c->isLearnt) { clauses = &f->learnedClauses; } else { clauses = &f->origClauses; } clauses->size--; return c; } #endif extern int DebugSolverLoop; static char *dups(const char *str) { char *res; FS_CALLOC(res, strlen(str)+1, sizeof(*str)); strcpy(res, str); return res; } bool funcsatDebug(funcsat *f, char *label, int level) { #ifdef FUNCSAT_LOG int *levelp; FS_MALLOC(levelp, 1, sizeof(*levelp)); *levelp = level; hashtable_insert(f->conf->logSyms, dups(label), levelp); return true; #else return false; #endif } @ @<Internal decl...@>= extern mbool funcsatValue(funcsat *f, literal p); @ @<External declarations@>= struct funcsat_config; funcsat *funcsatInit(funcsat_config *conf); funcsat_config *funcsatConfigInit(void *userData); void funcsatConfigDestroy(funcsat_config *); void funcsatResize(funcsat *f, variable numVars); void funcsatDestroy(funcsat *); funcsat_result funcsatPushAssumption(funcsat *f, literal p); funcsat_result funcsatPushAssumptions(funcsat *f, clause *c); void funcsatPopAssumptions(funcsat *f, uintmax_t num); funcsat_result funcsatSolve(funcsat *func); uintmax_t funcsatNumClauses(funcsat *func); uintmax_t funcsatNumVars(funcsat *func); void funcsatPrintStats(FILE *stream, funcsat *f); void funcsatPrintColumnStats(FILE *stream, funcsat *f); void funcsatClearStats(funcsat *f); void funcsatBumpLitPriority(funcsat *f, literal p); void funcsatPrintCnf(FILE *stream, funcsat *f, bool learned); funcsat_result funcsatResult(funcsat *f); clause *funcsatSolToClause(funcsat *f); intmax_t funcsatSolCount(funcsat *f, clause subset, clause *lastSolution); void funcsatReset(funcsat *f); void funcsatSetupActivityGc(funcsat_config *); bool funcsatDebug(funcsat *f, char *label, int level); clause *funcsatRemoveClause(funcsat *f, clause *c); @* Parsing CNF. @<Global def...@>= #include "funcsat/vec_char.h" int64_t readHeader(int (*getChar)(void *), void *, funcsat *func); funcsat_result readClauses( int (*getChar)(void *), void *, funcsat *func, uint64_t numClauses); int fgetcWrapper(void *stream) { return fgetc((FILE *) stream); } funcsat_result parseDimacsCnf(const char *path, funcsat *f) { struct stat buf; if (-1 == stat(path, &buf)) perror("stat"), exit(1); if (!S_ISREG(buf.st_mode)) { fprintf(stderr, "Error: '%s' not a regular file\n", path); exit(1); } int (*getChar)(void *); void *stream; const char *opener; funcsat_result result; bool isGz = 0 == strcmp(".gz", path + (strlen(path)-strlen(".gz"))); if (isGz) { #ifdef HAVE_LIBZ # if 0 fprintf(stderr, "c found .gz file\n"); # endif getChar = (int(*)(void *))gzgetc; stream = gzopen(path, "r"); opener = "gzopen"; #else fprintf(stderr, "cannot read gzip'd file\n"); exit(1); #endif } else { getChar = fgetcWrapper; stream = fopen(path, "r"); opener = "fopen"; } if (!stream) { perror(opener); exit(1); } uint64_t num_clauses = (uint64_t)readHeader(getChar, stream, f); fslog(f, "solve", 2, "read %" PRIu64 " clauses from header\n", num_clauses); result = readClauses(getChar, stream, f, num_clauses); if (isGz) { #ifdef HAVE_LIBZ if (Z_OK != gzclose(stream)) perror("gzclose"), exit(1); #else assert(0 && "no libz and this shouldn't happen"); #endif } else { if (0 != fclose(stream)) perror("fclose"), exit(1); } return result; } static literal readLiteral( int (*getChar)(void *stream), void *stream, struct vec_char *tmp, uint64_t numClauses); int64_t readHeader(int (*getChar)(void *stream), void *stream, funcsat *func) { char c; Comments: while (isspace(c = getChar(stream))); /* skip leading spaces */ if ('c' == c) { while ('\n' != (c = getChar(stream))); } if ('p' != c) { goto Comments; } while ('c' != (c = getChar(stream))); assert(c == 'c'); c = getChar(stream); assert(c == 'n'); c = getChar(stream); assert(c == 'f'); struct vec_char *tmp = vec_char_init(4); readLiteral(getChar, stream, tmp, 0); uintmax_t numClauses = (uintmax_t) readLiteral(getChar, stream, tmp, 0); vec_char_destroy(tmp); #if 0 fprintf(stderr, "c read header 'p cnf %ju %ju'\n", numVariables, numClauses); #endif return (intmax_t) numClauses; } funcsat_result readClauses( int (*getChar)(void *stream), void *stream, funcsat *func, uint64_t numClauses) { clause *clause; funcsat_result result = FS_UNKNOWN; struct vec_char *tmp = vec_char_init(4); if (numClauses > 0) { do { clause = clauseAlloc(5); literal literal = readLiteral(getChar, stream, tmp, numClauses); while (literal != 0) { clausePush(clause, literal); literal = readLiteral(getChar, stream, tmp, numClauses); } #if 0 clause_head_print_dimacs(stderr, clause); fprintf(stderr, "\n"); #endif if (FS_UNSAT == funcsatAddClause(func, clause)) { result = FS_UNSAT; clauseFree(clause); break; } else clauseFree(clause); } while (--numClauses > 0); } vec_char_destroy(tmp); return result; } static literal readLiteral( int (*getChar)(void *stream), void *stream, struct vec_char *tmp, uint64_t numClauses) { char c; bool begun; vec_char_clear(tmp); literal literal; begun = false; while (1) { c = getChar(stream); if (isspace(c) || EOF == c) { if (begun) { break; } else if (EOF == c) { fprintf(stderr, "readLiteral error: too few clauses (after %" PRIu64 " clauses)\n", numClauses); exit(1); } else { continue; } } begun = true; vec_char_push(tmp, c); } vec_char_push(tmp, '\0'); literal = strtol((char *) tmp->data, NULL, 10); return literal; } @ @<External decl...@>= funcsat_result parseDimacsCnf(const char *path, funcsat *f); @* Debugging support. @<External decl...@>= char *funcsatResultAsString(funcsat_result result); @ We want to print the variable interaction graph. I think that's what it's called. @<External decl...@>= void fs_vig_print(funcsat *f, const char *path); @ @<Global def...@>= void fs_vig_print(funcsat *f, const char *path) { FILE *dot; char buf[256]; if (NULL == (dot = fopen(path, "w"))) perror("fopen"), exit(1); fprintf(dot, "graph G {\n"); fprintf(dot, "// variables\n"); for (variable i = 1; i <= f->numVars; i++) { fprintf(dot, "%ju;\n", i); } fprintf(dot, "// clauses\n"); uintmax_t cnt = 0; for_vec_uintptr (ix_cl, f->orig_clauses) { struct clause_iter it; char *bufptr = buf; clause_iter_init(f, *ix_cl, &it); for (literal *p = clause_iter_next(f, &it); p; p = clause_iter_next(f, &it)) { bufptr += sprintf(bufptr, "%ji ", *p); } fprintf(dot, "clause%ju [shape=box,label=\"%s\",fillcolor=black,shape=box];\n", cnt, buf); clause_iter_init(f, *ix_cl, &it); for (literal *p = clause_iter_next(f, &it); p; p = clause_iter_next(f, &it)) { fprintf(dot, "clause%ju -- %ju [%s];\n", cnt, fs_lit2var(*p), (*p < 0 ? "color=red" : "color=green")); } cnt++; } fprintf(dot, "}\n"); if (0 != fclose(dot)) perror("fclose"); } @ The \funcsat\ configuration. @<External ty...@>= typedef struct funcsat funcsat; typedef struct funcsat_config { void *user; /* clients can use this */ char *name; /* Name of the currently running sat problem. (May be null) */ struct hashtable *logSyms; /* for logging */ struct vec_uintmax logStack; bool printLogLabel; FILE *debugStream; bool usePhaseSaving; /* whether to save variable phases */ bool useSelfSubsumingResolution; bool minimizeLearnedClauses; uint32_t numUipsToLearn; bool gc; /* If false, all learned clauses are kept for all time. */ uintmax_t maxJailDecisionLevel; /* Only jail clauses that occur at or below this decision level. */ bool (*isTimeToRestart)(funcsat *, void *); /* This function is called after a conflict is discovered and analyzed. If it function returns |true|, \funcsat\ backtracks to decision level 0 and recommences. */ bool (*isResourceLimitHit)(funcsat *, void *); /* This function is called after any learned clause is added but before beginning the next step of unit propagation. If it returns |true|, \funcsat\ solver terminates whether the problem has been solved or not. */ funcsat_result (*preprocessNewClause)(funcsat *, void *, clause *); /* UNUSED */ funcsat_result (*preprocessBeforeSolve)(funcsat *, void *); /* UNUSED */ double (*getInitialActivity)(variable *); /* Gets the initial activity for the given variable. */ void (*bumpOriginal)(funcsat *, uintptr_t ix_cl); /* Called on original clauses. */ void (*bumpReason)(funcsat *, uintptr_t); /* Called on clauses that are resolved on during learning. */ void (*bumpLearned)(funcsat *, uintptr_t); /* Called on the new UIP clause after the conflict is analyzed. */ void (*bumpUnitClause)(funcsat *, uintptr_t); /* Called when a clause implies a unit literal. */ void (*decayAfterConflict)(funcsat *f); /* Called after a conflict is analyzed. */ void (*sweepClauses)(funcsat *, void *); /* Implements a policy for deleting learned clauses immediately after a restart. */ } funcsat_config; /* |uint64_t funcsatDebugSet;| in main.c*/ /* Descriptions for these options can be found in |debugDescriptions[Option]| */ @ When debugging \funcsat, it is convenient to be able to minimize a test case. Armin Biere has been kind enough to write {\sc cnfdd}, which is a delta-debugging algorithm for CNF files. The macro |assertExit| lets one quickly change a failing |assert| into one with exits with a particular code. So when \funcsat\ fails a particular |assert(x)|, change it to |assertExit(2, x)| and run {\sc cnfdd} to produce a minimal test case. @<Conditional mac...@>= #ifndef NDEBUG #define assertExit(code, cond) \ ((cond) ? (void)0 : exit(code)) #else #define assertExit(code, cond) #endif @ The following are functions used for logging messages to the console (if |FUNCSAT_LOG| is enabled). @d fs_dbgout(f) (f)->conf->debugStream @<Conditional mac...@>= #ifdef FUNCSAT_LOG #ifndef SWIG DECLARE_HASHTABLE(fsLogMapInsert, fsLogMapSearch, fsLogMapRemove, char, int) #endif /*#define fs_ifdbg(f, label, level) if (true)*/ #define fs_ifdbg(f, label, level) \ if ((f)->conf->logSyms && \ fsLogMapSearch(f->conf->logSyms, (void *) (label)) && \ (level) <= *fsLogMapSearch((f)->conf->logSyms, (void *) (label))) #else /*#define fs_ifdbg(f, label, level) if (true)*/ #define fs_ifdbg(f, label, level) if (false) #endif static inline int fslog(const struct funcsat *, const char *label, int level, const char *format, ...); static inline int dopen(const struct funcsat *, const char *label); static inline int dclose(const struct funcsat *, const char *label); @ @<Global def...@>= DEFINE_HASHTABLE(fsLogMapInsert, fsLogMapSearch, fsLogMapRemove, char, int) int fslog(const funcsat *f, const char *label, int msgLevel, const char *format, ...) { int pr = 0; int *logLevel; va_list ap; if (f->conf->logSyms && (logLevel = hashtable_search(f->conf->logSyms, (void *) label))) { if (msgLevel <= *logLevel) { uintmax_t indent = vec_uintmax_peek(&f->conf->logStack), i; for (i = 0; i < indent; i++) fprintf(f->conf->debugStream, " "); if (f->conf->printLogLabel) pr += fprintf(f->conf->debugStream, "%s %d: ", label, msgLevel); va_start(ap, format); pr += vfprintf(f->conf->debugStream, format, ap); va_end(ap); } } return pr; } int dopen(const funcsat *f, const char *label) { if (f->conf->logSyms && hashtable_search(f->conf->logSyms, (void *) label)) { uintmax_t indent = vec_uintmax_peek(&f->conf->logStack)+2; vec_uintmax_push(&f->conf->logStack, indent); } return 0; } int dclose(const funcsat *f, const char *label) { if (f->conf->logSyms && hashtable_search(f->conf->logSyms, (void *) label)) { vec_uintmax_pop(&f->conf->logStack); } return 0; } @ @<Global def...@>= /** * Searches in the clause for the literal with the maximum decision level, * beginning at startIdx. If found, that literal is swapped with * reason[swapIdx]. This preserves the necessary invariant for the unit facts * list. */ static void swapInMaxLevelLit(funcsat *f, clause *reason, uintmax_t swapIdx, uintmax_t startIdx) { literal secondWatch = 0, swLevel = -1; /* find max level lit, swap with lit[1] */ for (variable i = startIdx; i < reason->size; i++) { literal lev = levelOf(f, fs_lit2var(reason->data[i])); fslog(f, "subsumption", 9, "level of %ji = %ju\n", reason->data[i], levelOf(f, fs_lit2var(reason->data[i]))); if (swLevel < lev) swLevel = lev, secondWatch = (literal) i; /* TODO Does this speed stuff up? */ if (lev == fs_var2lit(f->decisionLevel)) break; } if (swLevel != -1) { literal tmp = reason->data[swapIdx]; reason->data[swapIdx] = reason->data[secondWatch], reason->data[secondWatch] = tmp; } } /* this function must be called after the resolution operation */ static void checkSubsumption( funcsat *f, literal p, clause *learn, clause *reason, bool learnIsUip) { #if 0 /* This is the test suggested in the paper "On-the-fly clause improvement" in * SAT09. */ if (learn->size == reason->size-1 && reason->size > 1 && /* learn subsumes reason */ learn->size > 2) { ++f->numSubsumptions; fs_ifdbg (f, "subsumption", 1) { FILE *out = f->conf->debugStream; clause_head_print_dimacs(f, out, learn); fprintf(out, " subsumes "); clause_head_print_dimacs(f, out, reason); fprintf(out, "\n"); } assert(!reason->isReason); if (learnIsUip) vectorPush(&f->subsumed, (void *)1); else vectorPush(&f->subsumed, (void *)0); vectorPush(&f->subsumed, reason); } #endif } static void minimizeClauseMinisat1(funcsat *f, clause *learned) { uintmax_t i, j; for (i = j = 1; i < learned->size; i++) { variable x = fs_lit2var(learned->data[i]); if (getReason(f, (literal)x) == NO_CLS) learned->data[j++] = learned->data[i]; else { uintptr_t r = getReason(f, learned->data[i]); struct clause_iter it; clause_iter_init(f, r, &it); clause_iter_next(f, &it); for (literal *p = clause_iter_next(f, &it); p; p = clause_iter_next(f, &it)) { #if 0 if (!seen[var(c[k])] && level(var(c[k])) > 0) { learned[j++] = learned[i]; break; } #endif } } } } /* utilities */ /************************************************************************/ static int compareByActivityRev(const void *cl1, const void *cl2) { clause *c1 = *(clause **) cl1; clause *c2 = *(clause **) cl2; double s1 = c1->activity, s2 = c2->activity; if (s1 == s2) return 0; else if (s1 > s2) return -1; else return 1; } @ @d otherWatchIdx(watchIdx) ((watchIdx) == 0 ? 1 : 0) /*Gets the index of the other watch given the index of the current watch.*/ @d forEachWatchedClause(c, p, wi, nx, end, foundEnd) if (c) for (wi = (c->data[0] == p ? 0 : 1), end = c->prev[wi], nx = c->next[wi], foundEnd = false; !foundEnd; foundEnd = (c == end), c = nx, wi = (c->data[0] == p ? 0 : 1), nx = c->next[wi]) @d forEachClause(c, nx, end, foundEnd) if (c) for (end = c->prev[0], nx = c->next[0], foundEnd = false; !foundEnd; foundEnd = (c == end), c = nx, nx = c->next[0]) @<Global def...@>= unsigned int fsLitHash(void *lIn) { /* TODO get better hash function */ literal l = *(literal *) lIn; return (unsigned int) l; } int fsLitEq(void *a, void *b) { literal p = *(literal *) a, q = *(literal *) b; return p == q; } unsigned int fsVarHash(void *lIn) { /* TODO get better hash function */ literal l = *(literal *) lIn; return (unsigned int) fs_lit2var(l); } int fsVarEq(void *a, void *b) { literal p = *(literal *) a, q = *(literal *) b; return fs_lit2var(p) == fs_lit2var(q); } int litCompare(const void *l1, const void *l2) { literal x = *(literal *) l1, y = *(literal *) l2; if (fs_lit2var(x) != fs_lit2var(y)) { return fs_lit2var(x) < fs_lit2var(y) ? -1 : 1; } else { if (x == y) { return 0; } else { return x < y ? -1 : 1; } } } #if 0 int clauseCompare(const void *cp1, const void *cp2) { const clause *c = *(clause **) cp1, *d = *(clause **) cp2; if (c->size != d->size) { return c->size < d->size ? -1 : 1; } else { /* lexicographically compare */ uint32_t i; for (i = 0; i < c->size; i++) { int ret; if (0 != (ret = litCompare(&c->data[i], &d->data[i]))) { return ret; } } return 0; } } #endif void sortClause(clause *clause) { qsort(clause->data, clause->size, sizeof(*clause->data), litCompare); } literal findLiteral(literal p, clause *clause) { literal min = 0, max = clause->size-1, mid = -1; int res = -1; /* comparison */ while (!(res == 0 || min > max)) { mid = min + ((max-min) / 2); res = litCompare(&p, &clause->data[mid]); if (res > 0) { min = mid + 1; } else { max = mid - 1; } } return res == 0 ? mid : -1; } literal findVariable(variable v, clause *clause) { literal min = 0, max = clause->size-1, mid = -1; int res = -1; /* comparison */ while (!(res == 0 || min > max)) { mid = min + ((max-min) / 2); if (v == fs_lit2var(clause->data[mid])) { res = 0; } else { literal p = fs_var2lit(v); res = litCompare(&p, &clause->data[mid]); } if (res > 0) { min = mid + 1; } else { max = mid - 1; } } return res == 0 ? mid : -1; } /* Low level clause manipulations. */ clause *clauseAlloc(uint32_t capacity) { clause *c; FS_MALLOC(c, 1, sizeof(*c)); clauseInit(c, capacity); return c; } @ @<Global def...@>= /** * Generates a clause that is * 1) satisfied if a given literal violates the current assignment and * 2) falsified only under the current assignment. */ clause *funcsatSolToClause(funcsat *f) { clause *c = clauseAlloc(f->trail.size); for(uintmax_t i = 0; i < f->trail.size; i++) clausePush(c, -f->trail.data[i]); return c; } funcsat_result funcsatFindAnotherSolution(funcsat *f) { clause *cur_sol = funcsatSolToClause(f); funcsat_result res = funcsatAddClause(f, cur_sol); if(res == FS_UNSAT) return FS_UNSAT; res = funcsatSolve(f); return res; } intmax_t funcsatSolCount(funcsat *f, clause subset, clause *lastSolution) { assert(f->assumptions.size == 0); intmax_t count = 0; for (uintmax_t i = 0; i < subset.size; i++) { funcsatResize(f, fs_lit2var(subset.data[i])); } clause assumptions; clauseInit(&assumptions, subset.size); uintmax_t twopn = (uintmax_t) round(pow(2., (double)subset.size)); fslog(f, "countsol", 1, "%ju incremental problems to solve\n", twopn); for (uintmax_t i = 0; i < twopn; i++) { fslog(f, "countsol", 2, "%ju: ", i); clauseClear(&assumptions); clauseCopy(&assumptions, &subset); /* negate literals that are 0 in n. */ uintmax_t n = i; for (uintmax_t j = 0; j < subset.size; j++) { /* 0 bit */ if ((n % 2) == 0) assumptions.data[j] *= -1; n >>= 1; } if (funcsatPushAssumptions(f, &assumptions) == FS_UNSAT) { continue; } if (FS_SAT == funcsatSolve(f)) { count++; if (lastSolution) { clauseClear(lastSolution); clauseCopy(lastSolution, &f->trail); } } funcsatPopAssumptions(f, f->assumptions.size); } clauseDestroy(&assumptions); return count; } @*1 Rest. @<Internal decl...@>= static void finishSolving(funcsat *func); static bool bcpAndJail(funcsat *f); bool funcsatLubyRestart(funcsat *f, void *p); bool funcsatNoRestart(funcsat *, void *); bool funcsatInnerOuter(funcsat *f, void *p); bool funcsatMinisatRestart(funcsat *f, void *p); /** * Undoes the given set of unit assumptions. Assumes the decision level is 0. */ void undoAssumptions(funcsat *func, clause *assumptions); funcsat_result startSolving(funcsat *f); /** * Analyses conflict, produces learned clauses, backtracks, and asserts the * learned clauses. If returns false, this means the SAT problem is unsat; if * it returns true, it means the SAT problem is not known to be unsat. */ bool analyze_conflict(funcsat *func); /** * Undoes the trail and assignments so that the new decision level is * ::newDecisionLevel. The lowest decision level is 0. * * @@param func * @@param newDecisionLevel * @@param isRestart * @@param facts same as in ::trailPop */ void backtrack(funcsat *func, variable newDecisionLevel, head_tail *facts, bool isRestart); /* Mutators */ void fs_print_state(funcsat *, FILE *); void funcsatPrintConfig(FILE *f, funcsat *); bool funcsatIsResourceLimitHit(funcsat *, void *); funcsat_result funcsatPreprocessNewClause(funcsat *, void *, clause *); funcsat_result funcsatPreprocessBeforeSolve(funcsat *, void *); variable funcsatLearnClauses(funcsat *, void *); int varOrderCompare(fibkey *, fibkey *); double funcsatDefaultStaticActivity(variable *v); void singlesPrint(FILE *stream, clause *begin); bool watcherFind(clause *c, clause **watches, uint8_t w); void watcherPrint(FILE *stream, clause *c, uint8_t w); void singlesPrint(FILE *stream, clause *begin); void binWatcherPrint(FILE *stream, funcsat *f); /** * FOR DEBUGGING */ bool isUnitClause(funcsat *f, clause *c); /** * Returns the decision level of the given variable. */ literal levelOf(funcsat *f, variable v); extern variable fs_lit2var(literal l); /** * Returns the positive literal of the given variable. */ literal fs_var2lit(variable v); /** * Converts lit to int suitable for array indexing */ uintmax_t fs_lit2idx(literal l); extern bool isDecision(funcsat *, variable); /* sorted clause manipulation */ /** * Sorts the literals in a clause. Useful for performing clause operations * (::findLiteral, ::findVariable, ::clauseRemove, and * resolution) in logarithmic time in the size of the clause. */ void sortClause(clause *c); /** * Finds a literal using binary search on the given clause. Returns the * literal's index (0 .. clause->size-1) if found, -1 otherwise. */ literal findLiteral(literal l, clause *); /** * Same as ::findLiteral but works on variables. */ literal findVariable(variable l, clause *); unsigned int fsLitHash(void *); int fsLitEq(void *, void *); int litCompare(const void *l1, const void *l2); @ @<Global def...@>= extern mbool funcsatValue(funcsat *f, literal p) { variable v = fs_lit2var(p); if (f->level.data[v] == Unassigned) return unknown; literal value = f->trail.data[f->model.data[v]]; return p == value; } @ Prototype. @<External decl...@>= funcsat_result fs_parse_dimacs_solution(funcsat *f, FILE *solutionFile); @ Parse solution. @<Global def...@>= static char parse_read_char(funcsat *f, FILE *solutionFile) { char c; c = fgetc(solutionFile); #if 0 bf_log(b, "bf", 8, "Read character '%c'\n", c); #endif return c; } static const char *s_SATISFIABLE = "SATISFIABLE\n"; static const char *s_UNSATISFIABLE = "UNSATISFIABLE\n"; funcsat_result fs_parse_dimacs_solution(funcsat *f, FILE *solutionFile) { char c; literal var; bool truth; funcsat_result result = FS_UNKNOWN; bool have_var = false; const char *cur; state_new_line: while (true) { c = parse_read_char(f, solutionFile); switch (c) { case EOF: goto state_eof; case 'c': goto state_comment; case 's': goto state_satisfiablility; case 'v': goto state_variables; default: fslog(f, "fs", 1, "unknown line type '%c' in solution file\n", c); goto state_error; } } state_comment: while (true) { c = parse_read_char(f, solutionFile); switch (c) { case EOF: goto state_eof; case '\n': goto state_new_line; default: break; } } state_satisfiablility: cur = NULL; funcsat_result pending = FS_UNKNOWN; while (true) { c = parse_read_char(f, solutionFile); switch (c) { case ' ': case '\t': continue; case EOF: goto state_eof; default: ungetc(c, solutionFile); break; } break; } while (true) { c = parse_read_char(f, solutionFile); if (cur == NULL) { switch (c) { case 'S': cur = &s_SATISFIABLE[1]; pending = FS_SAT; break; case 'U': cur = &s_UNSATISFIABLE[1]; pending = FS_UNSAT; break; case EOF: goto state_eof; default: fslog(f, "fs", 1, "unknown satisfiability\n"); goto state_error; } } else { if (c == EOF) { goto state_eof; } else if (c != *cur) { fslog(f, "fs", 1, "reading satisfiability, got '%c', expected '%c'\n", c, *cur); goto state_error; } if (c == '\n') { result = pending; goto state_new_line; } ++cur; } } state_variables: while (true) { c = parse_read_char(f, solutionFile); switch (c) { case '\n': goto state_new_line; case ' ': case '\t': break; case EOF: goto state_eof; default: ungetc(c, solutionFile); goto state_sign; } } state_sign: have_var = false; truth = true; c = parse_read_char(f, solutionFile); if (c == '-') { truth = false; } else { ungetc(c, solutionFile); } var = 0; goto state_variable; state_variable: while (true) { c = parse_read_char(f, solutionFile); switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': have_var = true; var = var * 10 + (c - '0'); break; default: ungetc(c, solutionFile); goto state_record_variable; } } state_record_variable: if (have_var) { if (var == 0) { /* sometimes the SAT solver will be told ``there are 47000 variables but * I'm only going to use 100 of them in the instance.'' {\bf some solvers} * (lingeling) will say ``ah well i can get rid of 46000 variables! i have * been so helpful today!'' which is all well and good except that then it * outputs the solution on only the 100 of them that are used. in this * case, we log what happened and hope that giving an arbitrary assignment * (false) to the rest of the inputs is the right thing. */ /* we assume this doesn't happen */ goto state_exit; } else { variable v = fs_lit2var(var); funcsatPushAssumption(f, (truth ? (literal)v : -(literal)v)); } goto state_variables; } else { abort(); fslog(f, "fs", 1, "expected variable, but didn't get one\n"); goto state_error; } state_eof: if (ferror(solutionFile)) { abort(); fslog(f, "fs", 1, "IO error reading solution file: %s", strerror(errno)); goto state_error; } else { goto state_exit; } state_error: result = FS_UNKNOWN; goto state_exit; state_exit: return result; } @ @(funcsat_test.c@>= #include "funcsat.h"
28.736297
99
0.653105
[ "render", "object", "shape", "vector", "model" ]
a41fccac18da63c425674f884adc8153af144834
1,614
h
C
DFA.h
lucageatti/Syft-safety
6b85bee9b6b1a5e32136f07c7c1e67d2efa87fb9
[ "MIT" ]
1
2022-03-24T15:03:45.000Z
2022-03-24T15:03:45.000Z
DFA.h
lucageatti/Syft-safety
6b85bee9b6b1a5e32136f07c7c1e67d2efa87fb9
[ "MIT" ]
1
2020-07-06T06:47:14.000Z
2020-07-06T06:47:14.000Z
DFA.h
lucageatti/Syft-safety
6b85bee9b6b1a5e32136f07c7c1e67d2efa87fb9
[ "MIT" ]
1
2020-07-02T12:01:50.000Z
2020-07-02T12:01:50.000Z
#include "Common.h" #ifndef DFA_H #define DFA_H using namespace std; using namespace CUDD; typedef vector<int> item; typedef vector<BDD> vbdd; class DFA { public: DFA(); virtual ~DFA(); void initialize(string filename, string partfile); //void initialize(string filename, string partfile, Cudd& manager); vector<item> bdd; void print_vec( vector <item> & v ); void construct_bdd(); void bdd2dot(); void dumpdot(BDD &b, string filename); int nbits; int init; int nstates; int nvars; vector<int> finalstates; vector<BDD> res; vector<BDD> bddvars; vector<int> input; vector<int> output; //new bdd constructer void construct_bdd_new(); Cudd* mgr; protected: private: int nodes; vector<int> behaviour; vector<string> variables; vector<item> smtbdd; void read_from_file(string filename); //read the ltlf formula void read_partfile(string partfile); //read the partfile void get_bdd(); void recur(int index, item tmp); void recur_left(int index, item tmp, int v); void recur_right(int index, item tmp, int v); void print( vector <string> & v ); void print_int( vector <int> & v ); bool strfind(string str, string target); void push_states(int i, item& tmp); string state2bin(int n); BDD var2bddvar(int v, int index); //new bdd constructer vector<vbdd> tBDD; vbdd try_get(int index); }; #endif // DFA_H
24.454545
75
0.598513
[ "vector" ]
a427331d00d007665bd966b821ea56e9584bc007
10,542
h
C
blt/generic/bltTable.h
crazy-max/expect-nt
63986978ccd301f996bf0bbab4ae4e1e372e7a62
[ "TCL" ]
5
2019-06-22T08:11:47.000Z
2022-03-10T13:11:07.000Z
blt/generic/bltTable.h
crazy-max/expect-nt
63986978ccd301f996bf0bbab4ae4e1e372e7a62
[ "TCL" ]
null
null
null
blt/generic/bltTable.h
crazy-max/expect-nt
63986978ccd301f996bf0bbab4ae4e1e372e7a62
[ "TCL" ]
3
2019-06-22T08:11:48.000Z
2022-03-10T13:11:08.000Z
/* * bltTable.h -- * * This file contains declarations for BLT's "table" geometry manager. * * Copyright (c) 1993-1997 by AT&T Bell Laboratories. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #ifndef _BLTTABLE_H #define _BLTTABLE_H typedef struct Editor Editor; typedef void (EditorDrawProc) _ANSI_ARGS_((Editor *editor)); typedef void (EditorDestroyProc) _ANSI_ARGS_((Editor *editor)); struct Editor { int gridLineWidth; int buttonHeight; int cubiclePad; int minSize; /* Minimum size to allow any partition */ EditorDrawProc *drawProc; EditorDestroyProc *destroyProc; }; #define numRows rows.length #define rowArr rows.array #define numCols columns.length #define colArr columns.array /* * Limits -- * * Defines the bounding of a size (width or height) in the table. * It may be related to the partition, cubicle, or table size. The * window pointers are used to associate * sizes with the requested * size of other windows. * */ typedef struct { int flags; /* Flags indicate whether using default * values for limits or not. See flags * below. */ int max, min; /* Values for respective limits */ int nom; /* Nominal starting value */ Tk_Window maxWin, minWin; /* If non-NULL, represents windows whose * requested sizes will be set as limits */ Tk_Window nomWin; /* If non-NULL represents window whose * requested size will be the nominal size */ } Limits; #define LIMITS_SET_BIT 1 #define LIMITS_SET_MIN (LIMITS_SET_BIT<<0) #define LIMITS_SET_MAX (LIMITS_SET_BIT<<1) #define LIMITS_SET_NOM (LIMITS_SET_BIT<<2) #define LIMITS_DEF_MIN 0 /* Default minimum limit */ #define LIMITS_DEF_MAX SHRT_MAX/* Default maximum limit */ #define LIMITS_DEF_NOM -1000 /* Default nomimal value. Indicates if a * partition has received any space yet */ typedef int (LimitsProc) _ANSI_ARGS_((int value, Limits *limitsPtr)); /* * Resize -- * * These flags indicate in what ways each partition in a table * can be resized from its normal dimensions. The normal size * of a partition is the amount of space needed to contain the * slave windows that span it. The table may then be stretched * or shrunk depending if the master window is larger or smaller * than the table. This can occur if 1) the user resizes the * toplevel window, or 2) the master window is in turn packed * into a larger window and the "fill" option is set. * * RESIZE_NONE - No resizing from normal size. * RESIZE_EXPAND - Do not allow the size to decrease. * The size may increase however. * RESIZE_SHRINK - Do not allow the size to increase. * The size may decrease however. * RESIZE_BOTH - Allow the size to increase or * decrease from the normal size. * */ typedef enum { RESIZE_NONE, RESIZE_EXPAND, RESIZE_SHRINK, RESIZE_BOTH } Resize; #define EXCLUDE_PAD 0 #define INCLUDE_PAD 1 /* * Default values for slave window attributes. */ #define DEF_FILL FILL_NONE #define DEF_COLUMN_SPAN 1 #define DEF_ROW_SPAN 1 #define DEF_ANCHOR TK_ANCHOR_CENTER struct Table; /* * Cubicle -- * * A cubicle is the frame which contains a slave window and its * padding. It may span multiple partitions and have requested * limits which constrain the size of it. Multiple cubicles can * start at any location in the table, but a cubicle contains only * one window. */ typedef struct { Tk_Window tkwin; /* Slave window */ struct Table *tablePtr; /* Table managing this window */ int extBW; /* Last known border width of slave window */ Limits reqWidth, reqHeight; /* Configurable bounds for width and height * requests made by the slave window */ int rowSpan; /* Number of rows spanned by slave */ int rowIndex; /* Starting row of span */ int colSpan; /* Number of columns spanned by slave */ int colIndex; /* Starting column of span */ Tk_Anchor anchor; /* Anchor type: indicates how the window is * positioned if extra space is available in * the cubicle */ Pad padX; /* Extra horizontal padding around the slave */ Pad padY; /* Extra vertical padding around the slave */ int ipadX, ipadY; /* Extra padding inside of the slave window * (in addition to the requested size of * the window) */ Fill fill; /* Indicates how the slave window should fill * the cubicle */ int originX, originY; /* Origin of the slave window wrt master * window */ /* * The following are the saved locations of the cubicle in each of the * three lists which are used by the table to track the cubicle. The * item pointers are used to cleanup when the cubicle is no longer * needed. */ Blt_ListItem *rowPtr; /* Pointer into list of row spans.*/ Blt_ListItem *colPtr; /* Pointer into list of column spans. */ Blt_ListItem *slavePtr; /* Pointer into list of slave windows. */ } Cubicle; /* * Partition -- * * A partition creates a definable space (row or column) in the * table. It may have both requested minimum or maximum values which * constrain the size of it. * */ typedef struct { int index; /* Index of row or column */ int size; /* Current size of the partition. This size * is bounded by minSize and maxSize. */ /* * nomSize and size perform similar duties. I need to keep track of * the amount of space allocated to the partition (using size). But * at the same time, I need to indicate that space can be parcelled * out to this partition. If a nominal size was set for this * partition, I don't want to add space. */ int nomSize; /* The nominal size (neither expanded nor * shrunk) of the partition based upon the * requested sizes of the slave windows * spanning this partition. */ int minSize, maxSize; /* Size constraints on the partition */ int offset; /* Offset of the partition (in pixels) from * the origin of the master window */ int minSpan; /* Minimum spanning window in partition. Used * for bookkeeping when growing a span of * partitions */ Cubicle *control; /* Pointer to the cubicle containing the slave * window spanning this partition which * controls its size. This is used to * know when a partition is used or not. */ Resize resize; /* Indicates if the partition should shrink * or expand from its nominal size. */ Pad pad; /* Pads the partition beyond its nominal * size */ Limits reqSize; /* Requested bounds for the size of the * partition. The partition will not expand * or shrink beyond these limits, regardless * of how it was specified (max slave size). * This includes any extra padding which may * be specified. */ int maxSpan; /* Maximum spanning window to consider when * growing a span of partitions. A value of * zero indicates that all spans should be * considered. */ } Partition; #define DEF_TBL_RESIZE "both" #define DEF_TBL_PAD "0" #define DEF_TBL_MAXSPAN "0" /* * This is the default number of elements in the statically pre-allocated * column and row arrays. This number should reflect a useful number of * row and columns, which fit most applications. */ #define DEF_ARRAY_SIZE 32 typedef Cubicle *(CubicleSearchProc) _ANSI_ARGS_((Tcl_Interp *interp, Tk_Window tkwin, int flags)); /* * RowCol -- * * Manages an array of partitions. The array of partitions represents * either the rows or the columns in the table. * */ typedef struct { char *type; /* String identifying the type of partition: * "row" or "column". */ int length; /* Number of partitions currently used */ int size; /* Number of partitions allocated */ Partition *array; /* Pointer to array of partition information: * Initially points to defSpace */ /* Pre-allocated array of partitions. */ Partition defSpace[DEF_ARRAY_SIZE]; Tk_ConfigSpec *configSpecs; } RowCol; /* * Table structure */ typedef struct Table { int flags; /* See the flags definitions below. */ Tk_Window searchWin; /* Main window of window hierarchy */ Tk_Window tkwin; /* The master window in which the slave * windows are arranged. */ Tcl_Interp *interp; /* Interpreter associated with all windows */ Blt_List cubicles; /* List of cubicles in the table. The * key is the address of the slave tkwin */ Blt_List rowSpans; /* Linked list of bins of windows of * increasing row span. */ Blt_List colSpans; /* Linked list of bins of windows of * increasing column span. */ Pad padX, padY; int propagate; /* If non-zero, the table will make a * geometry request on behalf of the * master window. */ int editorTablePad, editorCubiclePad, editorPartitionPad; RowCol columns, rows; /* Manages row and column partitions */ int masterWidth; /* Last known width of the master window */ int masterHeight; /* Last known height of the master window */ int normalWidth; /* Normal width of the table */ int normalHeight; /* Normal height of the table */ Limits reqWidth, reqHeight; /* Constraints on the table's normal * width and height */ Editor *editPtr; /* If non-NULL, indicates that the table * is currently being edited */ Tk_IdleProc *arrangeProc; CubicleSearchProc *findCubicleProc; } Table; /* * Table flags definitions */ #define ARRANGE_PENDING (1<<0) /* A call to ArrangeTable is pending. This * flag allows multiple layout changes to * be requested before the table is * actually reconfigured. */ #define REQUEST_LAYOUT (1<<1) /* Get the requested sizes of the slave * windows before expanding/shrinking the * size of the master window. It's * necessary to recompute the layout every * time a partition or cubicle is added, * reconfigured, or deleted, but not when * the master window is resized. */ #define NON_PARENT (1<<2) /* The table is managing slaves which are * not children of the master window. This * requires that they are moved when the * master window is moved (a definite * performance hit). */ /* * Forward declarations */ extern Table *Blt_FindTable _ANSI_ARGS_((Tcl_Interp *interp, char *pathName, Tk_Window searchWin, int flags)); #endif /* _BLTTABLE_H */
32.841121
77
0.686587
[ "geometry" ]
a42f83ca4e57cab4822878dcbeeb3599b9c1e20b
5,102
h
C
src/platform/msgmgr/MessageHandlerList.h
shorton3/dashingplatforms
f461c967827b92c8bcf872c365afa64e56871aba
[ "Apache-2.0" ]
null
null
null
src/platform/msgmgr/MessageHandlerList.h
shorton3/dashingplatforms
f461c967827b92c8bcf872c365afa64e56871aba
[ "Apache-2.0" ]
null
null
null
src/platform/msgmgr/MessageHandlerList.h
shorton3/dashingplatforms
f461c967827b92c8bcf872c365afa64e56871aba
[ "Apache-2.0" ]
null
null
null
/****************************************************************************** * * File name: MessageHandlerList.h * Subsystem: Platform Services * Description: The MessageHandlerList class maintains a mapping between each * specific Message (based on MessageId) and its corresponding * Message Handler method. * * Name Date Release * -------------------- ---------- --------------------------------------------- * Stephen Horton 01/01/2014 Initial release * * ******************************************************************************/ #ifndef _PLAT_MESSAGE_HANDLER_LIST_H_ #define _PLAT_MESSAGE_HANDLER_LIST_H_ //----------------------------------------------------------------------------- // System include files, includes 3rd party libraries. //----------------------------------------------------------------------------- #include <map> #include <ace/Thread_Mutex.h> using namespace std; //----------------------------------------------------------------------------- // Component includes, includes elements of our system. //----------------------------------------------------------------------------- #include "Callback.h" //----------------------------------------------------------------------------- // Forward Declarations. //----------------------------------------------------------------------------- class MessageBase; // For C++ class declarations, we have one (and only one) of these access // blocks per class in this order: public, protected, and then private. // // Inside each block, we declare class members in this order: // 1) nested classes (if applicable) // 2) static methods // 3) static data // 4) instance methods (constructors/destructors first) // 5) instance data // /** * MessageHandlerList class maintains a mapping between each specific Message * (based on MessageId) and its corresponding Message Handler method. * <p> * MessageHandlerList uses Functors to turn c-style functions into objects. * These function objects (or Functors) can then be registered using a key * (the MessageId) to associate the handler function to the receipt of a * particular message. * <p> * MessageHandlerList does not implement any type of thread safety mechanisms. * This means that the application developer must build the handler list * from a SINGLE THREAD. DO NOT ATTEMPT to add message handlers from multiple * threads! * <p> * $Author: Stephen Horton$ * $Revision: 1$ */ /** * Currently only use function pointers that accept a single MessageBase * parameter and return an int */ typedef CBFunctor1wRet<MessageBase *, int> MessageHandler; /** Map is used to maintain the message handler registry */ typedef map<unsigned short, MessageHandler, less<unsigned short> > MessageHandlerRegistryType; class MessageHandlerList { public: /** Constructor */ MessageHandlerList(); /** Virtual Destructor */ virtual ~MessageHandlerList(); /** * Perform the mapping between message Id and handler function * @returns true if the mapping was successful */ bool add(unsigned short messageId, const MessageHandler& handler); /** Remove the mapping between message Id and handler function */ void remove(unsigned short messageId); /** * Return a handler for a given message Id. * @returns default handler if message Id could not be found */ const MessageHandler& find(unsigned short messageId); /** Change the default handler */ void setDefault(MessageHandler& defaultHandler); /** Restore the default message handler */ void restoreDefault(); /** List all mappings between message Id and handler functions */ void listAllMessageHandlers(); /** * String'ized debugging method * @return string representation of the contents of this object */ string toString(); protected: private: /** * Copy Constructor declared private so that default automatic * methods aren't used. */ MessageHandlerList(const MessageHandlerList& rhs); /** * Assignment operator declared private so that default automatic * methods aren't used. */ MessageHandlerList& operator= (const MessageHandlerList& rhs); /** Default message handler */ int defaultMessageHandler(MessageBase* messagePtr); /** The functor object that contains the default message handler function */ MessageHandler defaultHandler_; /** * The functor object that contains the default message handler that is * currently active. */ MessageHandler currentDefaultHandler_; /** Map is used to maintain the message handler registry list. */ MessageHandlerRegistryType messageHandlerList_; /** Non-recursive Ace Thread Mutex that protects/guards this list */ ACE_Thread_Mutex listMutex_; }; #endif
32.916129
108
0.581929
[ "object" ]
a43db3c6cbb14e88347a9025bcbbacdcbbc1cdf9
28,323
c
C
rtklibros/src/todo/atmos.c
StanleyHusai/mapping
60c984437c75e8eead95a8fb649e72066f8e5e8f
[ "Unlicense" ]
11
2015-11-10T07:27:09.000Z
2021-07-09T01:20:06.000Z
rtklibros/src/todo/atmos.c
yxw027/GNSS-INS
e5c5b7901b270a9c4d3a0ffd5555843d969f4018
[ "Unlicense" ]
1
2015-08-04T03:46:52.000Z
2015-08-17T12:34:10.000Z
rtklibros/src/todo/atmos.c
yxw027/GNSS-INS
e5c5b7901b270a9c4d3a0ffd5555843d969f4018
[ "Unlicense" ]
18
2015-02-23T14:29:19.000Z
2020-06-07T11:08:43.000Z
/*------------------------------------------------------------------------------ * atmos.c : atmospheric function * * Copyright (C) 2010 by T.TAKASU, All rights reserved. * * reference : * [1] A.E.Niell, Global mapping functions for the atmosphere delay at radio * wavelengths, Jounal of geophysical research, 1996 * * [2] J. Boehm, R. Heinkelmann, and H. Schuh, Global Pressure and * Temperature (GPT): A spherical harmonics expansion of annual pressure * and temperature variations for geodetic applications, Journal of * Geodesy, 2006 * [3] J. Boehm, A.E. Niell, P. Tregoning, H. Schuh, Global Mapping Functions * (GMF): A new empirical mapping function based on numerical weather * model data, Geoph. Res. Letters, 2006 * [4] IS-GPS-200D, Navstar GPS Space Segment/Navigation User Interfaces, * 7 March, 2006 * * (* original paper has bugs in eq.(4) and (5). the corrected paper is * obtained from: ftp://web.haystack.edu/pub/aen/nmf/NMF_JGR.pdf) * * version : $Revision:$ $Date:$ * history : 2010/09/11 1.0 new *-----------------------------------------------------------------------------*/ #include "rtklib.h" static const char rcsid[]="$Id:$"; /* constants/macros ----------------------------------------------------------*/ #define MIN(x,y) ((x)<(y)?(x):(y)) #define NMAX 9 /* max degree of spherical harmonics */ #define NP (NMAX+1)*(NMAX+2)/2 /* number of spherical harmonics */ /* legendre functions --------------------------------------------------------*/ static void legendre(double t, double P[][NMAX+1]) { double sum,fac[2*NMAX+2]={1.0}; int i,j,ir,k; for (i=1;i<=2*NMAX+1;i++) { fac[i]=fac[i-1]*i; } for (i=0;i<=NMAX;i++) for (j=0;j<=MIN(i,NMAX);j++) { ir=(i-j)/2; sum=0.0; for (k=0;k<=ir;k++) { sum+=(-1)**k*fac[2*i-2*k]/fac[k]/fac[i-k]/fac[i-j-2*k]*t**[i-j-2*k]; } /* Legendre functions moved by 1 */ P(i + 1,j + 1) = 1.d0/2**i*dsqrt((1 - t**2)**(j))*sum } } /* spherical harmonics -------------------------------------------------------*/ static void sphharmonic(const double pos, double *aP, double *bP) { double P[NMAX+1][NMAX+1],cosm[NMAX+1],sinm[NMAX+1]; int i=0,n,m; legendre(sin(pos[0]),P); for (m=0;m<=NMAX;m++) { cosm[m]=cos(m*pos[1]); sinm[m]=sin(m*pos[1]); } for (n=0;n<=NMAX;n++) for (m=0;m<=n;m++) { aP[i ]=P[n][m]*cosm[m]; bP[i++]=P[n][m]*sinm[m]; } } /* mapping function ----------------------------------------------------------*/ static double mapf(double el, double a, double b, double c) { double sinel=sin(el); return (1.0+a/(1.0+b/(1.0+c)))/(sinel+(a/(sinel+b/(sinel+c)))); } /* pressure and temperature by standard atmosphere ---------------------------*/ static void atmos_std(gtime_t time, const double *pos, double *pres, double *temp) { double hgt=pos[2]<0.0?0.0:pos[2]; *pres=1013.25*pow(1.0-2.2557E-5*hgt,5.2568); *temp=15.0-6.5E-3*hgt+273.16; } /* pressure and temperature by GPT -------------------------------------------*/ static void atmos_gpt(gtime_t time, const double *pos, double *pres, double *temp) { const double a_geoid[]={ -5.6195E-001,-6.0794E-002,-2.0125E-001,-6.4180E-002,-3.6997E-002, +1.0098E+001,+1.6436E+001,+1.4065E+001,+1.9881E+000,+6.4414E-001, -4.7482E+000,-3.2290E+000,+5.0652E-001,+3.8279E-001,-2.6646E-002, +1.7224E+000,-2.7970E-001,+6.8177E-001,-9.6658E-002,-1.5113E-002, +2.9206E-003,-3.4621E+000,-3.8198E-001,+3.2306E-002,+6.9915E-003, -2.3068E-003,-1.3548E-003,+4.7324E-006,+2.3527E+000,+1.2985E+000, +2.1232E-001,+2.2571E-002,-3.7855E-003,+2.9449E-005,-1.6265E-004, +1.1711E-007,+1.6732E+000,+1.9858E-001,+2.3975E-002,-9.0013E-004, -2.2475E-003,-3.3095E-005,-1.2040E-005,+2.2010E-006,-1.0083E-006, +8.6297E-001,+5.8231E-001,+2.0545E-002,-7.8110E-003,-1.4085E-004, -8.8459E-006,+5.7256E-006,-1.5068E-006,+4.0095E-007,-2.4185E-008 }; const double b_geoid[]={ +0.0000E+000,+0.0000E+000,-6.5993E-002,+0.0000E+000,+6.5364E-002, -5.8320E+000,+0.0000E+000,+1.6961E+000,-1.3557E+000,+1.2694E+000, +0.0000E+000,-2.9310E+000,+9.4805E-001,-7.6243E-002,+4.1076E-002, +0.0000E+000,-5.1808E-001,-3.4583E-001,-4.3632E-002,+2.2101E-003, -1.0663E-002,+0.0000E+000,+1.0927E-001,-2.9463E-001,+1.4371E-003, -1.1452E-002,-2.8156E-003,-3.5330E-004,+0.0000E+000,+4.4049E-001, +5.5653E-002,-2.0396E-002,-1.7312E-003,+3.5805E-005,+7.2682E-005, +2.2535E-006,+0.0000E+000,+1.9502E-002,+2.7919E-002,-8.1812E-003, +4.4540E-004,+8.8663E-005,+5.5596E-005,+2.4826E-006,+1.0279E-006, +0.0000E+000,+6.0529E-002,-3.5824E-002,-5.1367E-003,+3.0119E-005, -2.9911E-005,+1.9844E-005,-1.2349E-006,-7.6756E-009,+5.0100E-008 }; const double ap_mean[]={ +1.0108E+003,+8.4886E+000,+1.4799E+000,-1.3897E+001,+3.7516E-003, -1.4936E-001,+1.2232E+001,-7.6615E-001,-6.7699E-002,+8.1002E-003, -1.5874E+001,+3.6614E-001,-6.7807E-002,-3.6309E-003,+5.9966E-004, +4.8163E+000,-3.7363E-001,-7.2071E-002,+1.9998E-003,-6.2385E-004, -3.7916E-004,+4.7609E+000,-3.9534E-001,+8.6667E-003,+1.1569E-002, +1.1441E-003,-1.4193E-004,-8.5723E-005,+6.5008E-001,-5.0889E-001, -1.5754E-002,-2.8305E-003,+5.7458E-004,+3.2577E-005,-9.6052E-006, -2.7974E-006,+1.3530E+000,-2.7271E-001,-3.0276E-004,+3.6286E-003, -2.0398E-004,+1.5846E-005,-7.7787E-006,+1.1210E-006,+9.9020E-008, +5.5046E-001,-2.7312E-001,+3.2532E-003,-2.4277E-003,+1.1596E-004, +2.6421E-007,-1.3263E-006,+2.7322E-007,+1.4058E-007,+4.9414E-009 }; const double bp_mean[]={ +0.0000E+000,+0.0000E+000,-1.2878E+000,+0.0000E+000,+7.0444E-001, +3.3222E-001,+0.0000E+000,-2.9636E-001,+7.2248E-003,+7.9655E-003, +0.0000E+000,+1.0854E+000,+1.1145E-002,-3.6513E-002,+3.1527E-003, +0.0000E+000,-4.8434E-001,+5.2023E-002,-1.3091E-002,+1.8515E-003, +1.5422E-004,+0.0000E+000,+6.8298E-001,+2.5261E-003,-9.9703E-004, -1.0829E-003,+1.7688E-004,-3.1418E-005,+0.0000E+000,-3.7018E-001, +4.3234E-002,+7.2559E-003,+3.1516E-004,+2.0024E-005,-8.0581E-006, -2.3653E-006,+0.0000E+000,+1.0298E-001,-1.5086E-002,+5.6186E-003, +3.2613E-005,+4.0567E-005,-1.3925E-006,-3.6219E-007,-2.0176E-008, +0.0000E+000,-1.8364E-001,+1.8508E-002,+7.5016E-004,-9.6139E-005, -3.1995E-006,+1.3868E-007,-1.9486E-007,+3.0165E-010,-6.4376E-010 }; const double ap_amp[]={ -1.0444E-001,+1.6618E-001,-6.3974E-002,+1.0922E+000,+5.7472E-001, -3.0277E-001,-3.5087E+000,+7.1264E-003,-1.4030E-001,+3.7050E-002, +4.0208E-001,-3.0431E-001,-1.3292E-001,+4.6746E-003,-1.5902E-004, +2.8624E+000,-3.9315E-001,-6.4371E-002,+1.6444E-002,-2.3403E-003, +4.2127E-005,+1.9945E+000,-6.0907E-001,-3.5386E-002,-1.0910E-003, -1.2799E-004,+4.0970E-005,+2.2131E-005,-5.3292E-001,-2.9765E-001, -3.2877E-002,+1.7691E-003,+5.9692E-005,+3.1725E-005,+2.0741E-005, -3.7622E-007,+2.6372E+000,-3.1165E-001,+1.6439E-002,+2.1633E-004, +1.7485E-004,+2.1587E-005,+6.1064E-006,-1.3755E-008,-7.8748E-008, -5.9152E-001,-1.7676E-001,+8.1807E-003,+1.0445E-003,+2.3432E-004, +9.3421E-006,+2.8104E-006,-1.5788E-007,-3.0648E-008,+2.6421E-010 }; const double bp_amp[]={ +0.0000E+000,+0.0000E+000,+9.3340E-001,+0.0000E+000,+8.2346E-001, +2.2082E-001,+0.0000E+000,+9.6177E-001,-1.5650E-002,+1.2708E-003, +0.0000E+000,-3.9913E-001,+2.8020E-002,+2.8334E-002,+8.5980E-004, +0.0000E+000,+3.0545E-001,-2.1691E-002,+6.4067E-004,-3.6528E-005, -1.1166E-004,+0.0000E+000,-7.6974E-002,-1.8986E-002,+5.6896E-003, -2.4159E-004,-2.3033E-004,-9.6783E-006,+0.0000E+000,-1.0218E-001, -1.3916E-002,-4.1025E-003,-5.1340E-005,-7.0114E-005,-3.3152E-007, +1.6901E-006,+0.0000E+000,-1.2422E-002,+2.5072E-003,+1.1205E-003, -1.3034E-004,-2.3971E-005,-2.6622E-006,+5.7852E-007,+4.5847E-008, +0.0000E+000,+4.4777E-002,-3.0421E-003,+2.6062E-005,-7.2421E-005, +1.9119E-006,+3.9236E-007,+2.2390E-007,+2.9765E-009,-4.6452E-009 }; const double at_mean[]={ +1.6257E+001,+2.1224E+000,+9.2569E-001,-2.5974E+001,+1.4510E+000, +9.2468E-002,-5.3192E-001,+2.1094E-001,-6.9210E-002,-3.4060E-002, -4.6569E+000,+2.6385E-001,-3.6093E-002,+1.0198E-002,-1.8783E-003, +7.4983E-001,+1.1741E-001,+3.9940E-002,+5.1348E-003,+5.9111E-003, +8.6133E-006,+6.3057E-001,+1.5203E-001,+3.9702E-002,+4.6334E-003, +2.4406E-004,+1.5189E-004,+1.9581E-007,+5.4414E-001,+3.5722E-001, +5.2763E-002,+4.1147E-003,-2.7239E-004,-5.9957E-005,+1.6394E-006, -7.3045E-007,-2.9394E+000,+5.5579E-002,+1.8852E-002,+3.4272E-003, -2.3193E-005,-2.9349E-005,+3.6397E-007,+2.0490E-006,-6.4719E-008, -5.2225E-001,+2.0799E-001,+1.3477E-003,+3.1613E-004,-2.2285E-004, -1.8137E-005,-1.5177E-007,+6.1343E-007,+7.8566E-008,+1.0749E-009 }; const double bt_mean[]={ +0.0000E+000,+0.0000E+000,+1.0210E+000,+0.0000E+000,+6.0194E-001, +1.2292E-001,+0.0000E+000,-4.2184E-001,+1.8230E-001,+4.2329E-002, +0.0000E+000,+9.3312E-002,+9.5346E-002,-1.9724E-003,+5.8776E-003, +0.0000E+000,-2.0940E-001,+3.4199E-002,-5.7672E-003,-2.1590E-003, +5.6815E-004,+0.0000E+000,+2.2858E-001,+1.2283E-002,-9.3679E-003, -1.4233E-003,-1.5962E-004,+4.0160E-005,+0.0000E+000,+3.6353E-002, -9.4263E-004,-3.6762E-003,+5.8608E-005,-2.6391E-005,+3.2095E-006, -1.1605E-006,+0.0000E+000,+1.6306E-001,+1.3293E-002,-1.1395E-003, +5.1097E-005,+3.3977E-005,+7.6449E-006,-1.7602E-007,-7.6558E-008, +0.0000E+000,-4.5415E-002,-1.8027E-002,+3.6561E-004,-1.1274E-004, +1.3047E-005,+2.0001E-006,-1.5152E-007,-2.7807E-008,+7.7491E-009 }; const double at_amp[]={ -1.8654E+000,-9.0041E+000,-1.2974E-001,-3.6053E+000,+2.0284E-002, +2.1872E-001,-1.3015E+000,+4.0355E-001,+2.2216E-001,-4.0605E-003, +1.9623E+000,+4.2887E-001,+2.1437E-001,-1.0061E-002,-1.1368E-003, -6.9235E-002,+5.6758E-001,+1.1917E-001,-7.0765E-003,+3.0017E-004, +3.0601E-004,+1.6559E+000,+2.0722E-001,+6.0013E-002,+1.7023E-004, -9.2424E-004,+1.1269E-005,-6.9911E-006,-2.0886E+000,-6.7879E-002, -8.5922E-004,-1.6087E-003,-4.5549E-005,+3.3178E-005,-6.1715E-006, -1.4446E-006,-3.7210E-001,+1.5775E-001,-1.7827E-003,-4.4396E-004, +2.2844E-004,-1.1215E-005,-2.1120E-006,-9.6421E-007,-1.4170E-008, +7.8720E-001,-4.4238E-002,-1.5120E-003,-9.4119E-004,+4.0645E-006, -4.9253E-006,-1.8656E-006,-4.0736E-007,-4.9594E-008,+1.6134E-009 }; const double bt_amp[]={ +0.0000E+000,+0.0000E+000,-8.9895E-001,+0.0000E+000,-1.0790E+000, -1.2699E-001,+0.0000E+000,-5.9033E-001,+3.4865E-002,-3.2614E-002, +0.0000E+000,-2.4310E-002,+1.5607E-002,-2.9833E-002,-5.9048E-003, +0.0000E+000,+2.8383E-001,+4.0509E-002,-1.8834E-002,-1.2654E-003, -1.3794E-004,+0.0000E+000,+1.3306E-001,+3.4960E-002,-3.6799E-003, -3.5626E-004,+1.4814E-004,+3.7932E-006,+0.0000E+000,+2.0801E-001, +6.5640E-003,-3.4893E-003,-2.7395E-004,+7.4296E-005,-7.9927E-006, -1.0277E-006,+0.0000E+000,+3.6515E-002,-7.4319E-003,-6.2873E-004, -8.2461E-005,+3.1095E-005,-5.3860E-007,-1.2055E-007,-1.1517E-007, +0.0000E+000,+3.1404E-002,+1.5580E-002,-1.1428E-003,+3.3529E-005, +1.0387E-005,-1.9378E-006,-2.7327E-007,+7.5833E-009,-9.2323E-009 }; double t,undu,hort,apm,apa,pres0,atm,ata,temp0,aP[NP],bP[NP]; int i; t=time2doy(time)-28.0; /* spherical harmonics */ sphharmonic(pos,aP,bP); /* geoidal height */ undu=0.0; for (i=0;i<NP;i++) { undu+=a_geoid[i]*aP[i]+b_geoid[i]*bP[i]; } /* orthometric height */ hort=hgt-undu; /* surface pressure on the geoid */ apm=apa=0.0; for (i=0;i<NP;i++) { apm+=ap_mean[i]*aP[i]+bp_mean[i]*bP[i]; apa+=ap_amp [i]*aP[i]+bp_amp [i]*bP[i]; } pres0=apm+apa*cos(t/365.25*2.0*PI); /* height correction for pressure */ *pres=pres0*pow(1.0-0.0000226*hort,5.225); /* surface temperature on the geoid */ atm=ata=0.0; for (i=0;i<NP;i++) { atm+=at_mean[i]*aP[i]+bt_mean[i]*bP[i]; ata+=at_amp [i]*aP[i]+bt_amp [i]*bP[i]; } temp0=atm+ata*cos(t/365.25*2.0*PI); /* height correction for temperature */ *temp=temp0-0.0065*hort; } /* interpolation of coeffincients --------------------------------------------*/ static double interpc(const double coef[], double lat) { int i=(int)(lat/15.0); if (i<1) return coef[0]; else if (i>4) return coef[4]; return coef[i-1]*(1.0-lat/15.0+i)+coef[i]*(lat/15.0-i); } /* troposphere mapping function NMF (ref [1]) --------------------------------*/ static double tropmapf_nmf(gtime_t time, const double *pos, const double *azel, double *mapfw) { /* hydro-ave-a,b,c, hydro-amp-a,b,c, wet-a,b,c at latitude 15,30,45,60,75 */ const double coef[][5]={ { 1.2769934E-3, 1.2683230E-3, 1.2465397E-3, 1.2196049E-3, 1.2045996E-3}, { 2.9153695E-3, 2.9152299E-3, 2.9288445E-3, 2.9022565E-3, 2.9024912E-3}, { 62.610505E-3, 62.837393E-3, 63.721774E-3, 63.824265E-3, 64.258455E-3}, { 0.0000000E-0, 1.2709626E-5, 2.6523662E-5, 3.4000452E-5, 4.1202191E-5}, { 0.0000000E-0, 2.1414979E-5, 3.0160779E-5, 7.2562722E-5, 11.723375E-5}, { 0.0000000E-0, 9.0128400E-5, 4.3497037E-5, 84.795348E-5, 170.37206E-5}, { 5.8021897E-4, 5.6794847E-4, 5.8118019E-4, 5.9727542E-4, 6.1641693E-4}, { 1.4275268E-3, 1.5138625E-3, 1.4572752E-3, 1.5007428E-3, 1.7599082E-3}, { 4.3472961E-2, 4.6729510E-2, 4.3908931E-2, 4.4626982E-2, 5.4736038E-2} }; const double aht[]={ 2.53E-5, 5.49E-3, 1.14E-3}; /* height correction */ double y,cosy,ah[3],aw[3],dm; double az=azel[0],el=azel[1],lat=pos[0]*R2D,lon=pos[1]*R2D,hgt=pos[2]; int i; trace(3,"tropmapf_nmf: pos=%10.6f %11.6f %6.1f azel=%5.1f %4.1f\n", pos[0]*R2D,pos[1]*R2D,pos[2],azel[0]*R2D,azel[1]*R2D); if (el<=0.0) { if (mapfw) *mapfw=0.0; return 0.0; } /* year from doy 28, added half a year for southern latitudes */ y=(time2doy(time)-28.0)/365.25+(lat<0.0?0.5:0.0); cosy=cos(2.0*PI*y); lat=fabs(lat); for (i=0;i<3;i++) { ah[i]=interpc(coef[i ],lat)-interpc(coef[i+3],lat)*cosy; aw[i]=interpc(coef[i+6],lat); } /* ellipsoidal height is used instead of height above sea level */ dm=(1.0/sin(el)-mapf(el,aht[0],aht[1],aht[2]))*hgt/1E3; if (mapfw) *mapfw=mapf(el,aw[0],aw[1],aw[2]); return mapf(el,ah[0],ah[1],ah[2])+dm; } /* troposphere mapping function GMF (ref [2]) --------------------------------*/ static double tropmapf_gmf(gtime_t time, const double *pos, const double *azel, double *mapfw) { const double ah_mean[]={ +1.2517E+02, +8.503E-01, +6.936E-02, -6.760E+00, +1.771E-01, +1.130E-02, +5.963E-01, +1.808E-02, +2.801E-03, -1.414E-03, -1.212E+00, +9.300E-02, +3.683E-03, +1.095E-03, +4.671E-05, +3.959E-01, -3.867E-02, +5.413E-03, -5.289E-04, +3.229E-04, +2.067E-05, +3.000E-01, +2.031E-02, +5.900E-03, +4.573E-04, -7.619E-05, +2.327E-06, +3.845E-06, +1.182E-01, +1.158E-02, +5.445E-03, +6.219E-05, +4.204E-06, -2.093E-06, +1.540E-07, -4.280E-08, -4.751E-01, -3.490E-02, +1.758E-03, +4.019E-04, -2.799E-06, -1.287E-06, +5.468E-07, +7.580E-08, -6.300E-09, -1.160E-01, +8.301E-03, +8.771E-04, +9.955E-05, -1.718E-06, -2.012E-06, +1.170E-08, +1.790E-08, -1.300E-09, +1.000E-10 }; const double bh_mean[]={ +0.000E+00, +0.000E+00, +3.249E-02, +0.000E+00, +3.324E-02, +1.850E-02, +0.000E+00, -1.115E-01, +2.519E-02, +4.923E-03, +0.000E+00, +2.737E-02, +1.595E-02, -7.332E-04, +1.933E-04, +0.000E+00, -4.796E-02, +6.381E-03, -1.599E-04, -3.685E-04, +1.815E-05, +0.000E+00, +7.033E-02, +2.426E-03, -1.111E-03, -1.357E-04, -7.828E-06, +2.547E-06, +0.000E+00, +5.779E-03, +3.133E-03, -5.312E-04, -2.028E-05, +2.323E-07, -9.100E-08, -1.650E-08, +0.000E+00, +3.688E-02, -8.638E-04, -8.514E-05, -2.828E-05, +5.403E-07, +4.390E-07, +1.350E-08, +1.800E-09, +0.000E+00, -2.736E-02, -2.977E-04, +8.113E-05, +2.329E-07, +8.451E-07, +4.490E-08, -8.100E-09, -1.500E-09, +2.000E-10 }; const double ah_amp[]={ -2.738E-01, -2.837E+00, +1.298E-02, -3.588E-01, +2.413E-02, +3.427E-02, -7.624E-01, +7.272E-02, +2.160E-02, -3.385E-03, +4.424E-01, +3.722E-02, +2.195E-02, -1.503E-03, +2.426E-04, +3.013E-01, +5.762E-02, +1.019E-02, -4.476E-04, +6.790E-05, +3.227E-05, +3.123E-01, -3.535E-02, +4.840E-03, +3.025E-06, -4.363E-05, +2.854E-07, -1.286E-06, -6.725E-01, -3.730E-02, +8.964E-04, +1.399E-04, -3.990E-06, +7.431E-06, -2.796E-07, -1.601E-07, +4.068E-02, -1.352E-02, +7.282E-04, +9.594E-05, +2.070E-06, -9.620E-08, -2.742E-07, -6.370E-08, -6.300E-09, +8.625E-02, -5.971E-03, +4.705E-04, +2.335E-05, +4.226E-06, +2.475E-07, -8.850E-08, -3.600E-08, -2.900E-09, +0.000E+00 }; const double bh_amp[]={ +0.000E+00, +0.000E+00, -1.136E-01, +0.000E+00, -1.868E-01, -1.399E-02, +0.000E+00, -1.043E-01, +1.175E-02, -2.240E-03, +0.000E+00, -3.222E-02, +1.333E-02, -2.647E-03, -2.316E-05, +0.000E+00, +5.339E-02, +1.107E-02, -3.116E-03, -1.079E-04, -1.299E-05, +0.000E+00, +4.861E-03, +8.891E-03, -6.448E-04, -1.279E-05, +6.358E-06, -1.417E-07, +0.000E+00, +3.041E-02, +1.150E-03, -8.743E-04, -2.781E-05, +6.367E-07, -1.140E-08, -4.200E-08, +0.000E+00, -2.982E-02, -3.000E-03, +1.394E-05, -3.290E-05, -1.705E-07, +7.440E-08, +2.720E-08, -6.600E-09, +0.000E+00, +1.236E-02, -9.981E-04, -3.792E-05, -1.355E-05, +1.162E-06, -1.789E-07, +1.470E-08, -2.400E-09, -4.000E-10 }; const double aw_mean[]={ +5.640E+01, +1.555E+00, -1.011E+00, -3.975E+00, +3.171E-02, +1.065E-01, +6.175E-01, +1.376E-01, +4.229E-02, +3.028E-03, +1.688E+00, -1.692E-01, +5.478E-02, +2.473E-02, +6.059E-04, +2.278E+00, +6.614E-03, -3.505E-04, -6.697E-03, +8.402E-04, +7.033E-04, -3.236E+00, +2.184E-01, -4.611E-02, -1.613E-02, -1.604E-03, +5.420E-05, +7.922E-05, -2.711E-01, -4.406E-01, -3.376E-02, -2.801E-03, -4.090E-04, -2.056E-05, +6.894E-06, +2.317E-06, +1.941E+00, -2.562E-01, +1.598E-02, +5.449E-03, +3.544E-04, +1.148E-05, +7.503E-06, -5.667E-07, -3.660E-08, +8.683E-01, -5.931E-02, -1.864E-03, -1.277E-04, +2.029E-04, +1.269E-05, +1.629E-06, +9.660E-08, -1.015E-07, -5.000E-10 }; const double bw_mean[]={ +0.000E+00, +0.000E+00, +2.592E-01, +0.000E+00, +2.974E-02, -5.471E-01, +0.000E+00, -5.926E-01, -1.030E-01, -1.567E-02, +0.000E+00, +1.710E-01, +9.025E-02, +2.689E-02, +2.243E-03, +0.000E+00, +3.439E-01, +2.402E-02, +5.410E-03, +1.601E-03, +9.669E-05, +0.000E+00, +9.502E-02, -3.063E-02, -1.055E-03, -1.067E-04, -1.130E-04, +2.124E-05, +0.000E+00, -3.129E-01, +8.463E-03, +2.253E-04, +7.413E-05, -9.376E-05, -1.606E-06, +2.060E-06, +0.000E+00, +2.739E-01, +1.167E-03, -2.246E-05, -1.287E-04, -2.438E-05, -7.561E-07, +1.158E-06, +4.950E-08, +0.000E+00, -1.344E-01, +5.342E-03, +3.775E-04, -6.756E-05, -1.686E-06, -1.184E-06, +2.768E-07, +2.730E-08, +5.700E-09 }; const double aw_amp[]={ +1.023E-01, -2.695E+00, +3.417E-01, -1.405E-01, +3.175E-01, +2.116E-01, +3.536E+00, -1.505E-01, -1.660E-02, +2.967E-02, +3.819E-01, -1.695E-01, -7.444E-02, +7.409E-03, -6.262E-03, -1.836E+00, -1.759E-02, -6.256E-02, -2.371E-03, +7.947E-04, +1.501E-04, -8.603E-01, -1.360E-01, -3.629E-02, -3.706E-03, -2.976E-04, +1.857E-05, +3.021E-05, +2.248E+00, -1.178E-01, +1.255E-02, +1.134E-03, -2.161E-04, -5.817E-06, +8.836E-07, -1.769E-07, +7.313E-01, -1.188E-01, +1.145E-02, +1.011E-03, +1.083E-04, +2.570E-06, -2.140E-06, -5.710E-08, +2.000E-08, -1.632E+00, -6.948E-03, -3.893E-03, +8.592E-04, +7.577E-05, +4.539E-06, -3.852E-07, -2.213E-07, -1.370E-08, +5.800E-09 }; const double bw_amp[]={ +0.000E+00, +0.000E+00, -8.865E-02, +0.000E+00, -4.309E-01, +6.340E-02, +0.000E+00, +1.162E-01, +6.176E-02, -4.234E-03, +0.000E+00, +2.530E-01, +4.017E-02, -6.204E-03, +4.977E-03, +0.000E+00, -1.737E-01, -5.638E-03, +1.488E-04, +4.857E-04, -1.809E-04, +0.000E+00, -1.514E-01, -1.685E-02, +5.333E-03, -7.611E-05, +2.394E-05, +8.195E-06, +0.000E+00, +9.326E-02, -1.275E-02, -3.071E-04, +5.374E-05, -3.391E-05, -7.436E-06, +6.747E-07, +0.000E+00, -8.637E-02, -3.807E-03, -6.833E-04, -3.861E-05, -2.268E-05, +1.454E-06, +3.860E-07, -1.068E-07, +0.000E+00, -2.658E-02, -1.947E-03, +7.131E-04, -3.506E-05, +1.885E-07, +5.792E-07, +3.990E-08, +2.000E-08, -5.700E-09 }; double doy,bh,c0h,phh,c11h,c10h,ch,ahm,aha,ah,bw,cw,awm,awa,aw,mapfh; double sine,beta,gamma,topcon,a_ht,b_ht,c_ht,hs_km,ht_corr_coef,ht_corr; double aP[NP],bP[NP]; doy=time2doy(time); /* spherical harmonics */ sphharmonic(pos,aP,bP); /* hydrostatic mapping function */ bh=0.0029; c0h=0.062; if (lat<0.0) { /* southern hemisphere */ phh=PI; c11h=0.007; c10h=0.002; } else { /* northern hemisphere */ phh=0.0; c11h=0.005; c10h=0.001; } ch=c0h+((cos(doy/365.25*2.0*PI+phh)+1.0)*c11h/2.0+c10h)*(1.0-cos(pos[0])); ahm=aha=0.0; for (i=0;i<NP;i++) { ahm+=(ah_mean[i]*aP[i]+bh_mean[i]*bP[i])*1E-5; aha+=(ah_amp [i]*aP[i]+bh_amp [i]*bP[i])*1E-5; } ah=ahm+aha*cos(doy/365.25*2.0*PI); mapfh=mapf(azel[1],ah,bh,ch); /* height correction by NMF */ a_ht=2.53E-5; b_ht=5.49E-3; c_ht=1.14E-3; hs_km=dhgt/1000.0; beta =b_ht/(sine+c_ht); gamma=a_ht/(sine+beta); topcon=(1.0+a_ht/(1.0+b_ht/(1.0+c_ht))); ht_corr_coef=1.0/sine-topcon/(sine+gamma); ht_corr=ht_corr_coef * hs_km maph+=ht_corr; /* wet mapping function */ if (mapfw) { bw=0.00146; cw=0.04391; awm=awa=0.0; for (i=0;i<NP;i++) { awm+=(aw_mean[i]*aP[i]+bw_mean[i]*bP[i])*1E-5; awa+=(aw_amp [i]*aP[i]+bw_amp [i]*bP[i])*1E-5; } aw=awm+awa*cos(doy/365.25*2.0*PI); *mapfw=mapf(azel[1],aw,bw,cw); } return mapfh; } /* troposphere mapping function ------------------------------------------------ * compute tropospheric mapping function by NMF * args : gtime_t time I time * double *pos I receiver position {lat,lon,h} (rad,m) * double *azel I azimuth/elevation angle {az,el} (rad) * int opt I option (0:NMF,1:GMF,2:VMF1 (reserved)) * double *mapfw IO wet mapping function (NULL: not output) * return : dry mapping function *-----------------------------------------------------------------------------*/ extern double tropmapf(gtime_t time, const double *pos, const double *azel, int opt, double *mapfw) { trace(3,"tropmapf: pos=%10.6f %11.6f %6.1f azel=%5.1f %4.1f opt=%d\n", pos[0]*R2D,pos[1]*R2D,pos[2],azel[0]*R2D,azel[1]*R2D,opt); switch (opt) { case TRPMAPF_NMF: return tropmapf_nmf(time,pos,azel,mapfw); case TRPMAPF_GMF: return tropmapf_gmf(time,pos,azel,mapfw); } return 0.0; } /* troposphere model ----------------------------------------------------------- * compute tropospheric delay by standard atmosphere and saastamoinen model * args : double *pos I receiver position {lat,lon,h} (rad,m) * double *azel I azimuth/elevation angle {az,el} (rad) * double humi I relative humidity * return : tropospheric delay (m) *-----------------------------------------------------------------------------*/ extern double tropmodel(const double *pos, const double *azel, double humi) { double hgt,pres,temp,e,z,trph,trpw; if (pos[2]<-100.0||1E4<pos[2]||azel[1]<=0) return 0.0; /* standard atmosphere */ hgt=pos[2]<0.0?0.0:pos[2]; pres=1013.25*pow(1.0-2.2557E-5*hgt,5.2568); temp=15.0-6.5E-3*hgt+273.16; e=6.108*humi*exp((17.15*temp-4684.0)/(temp-38.45)); /* saastamoninen model */ z=PI/2.0-azel[1]; trph=0.0022768*pres/(1.0-0.00266*cos(2.0*pos[0])-0.00028*hgt/1E3)/cos(z); trpw=0.002277 *(1255.0/temp+0.05)*e/cos(z); return trph+trpw; } /* ionosphere model ------------------------------------------------------------ * compute ionospheric delay by broadcast ionosphere model (klobuchar model) * args : gtime_t t I time (gpst) * double *ion I iono model parameters {a0,a1,a2,a3,b0,b1,b2,b3} * double *pos I receiver position {lat,lon,h} (rad,m) * double *azel I azimuth/elevation angle {az,el} (rad) * return : ionospheric delay (L1) (m) * notes : ref [3] *-----------------------------------------------------------------------------*/ extern double ionmodel(gtime_t t, const double *ion, const double *pos, const double *azel) { const double ion_default[]={ /* 2004/1/1 */ 0.1118E-07,-0.7451E-08,-0.5961E-07, 0.1192E-06, 0.1167E+06,-0.2294E+06,-0.1311E+06, 0.1049E+07 }; double tt,f,psi,phi,lam,amp,per,x; int week; if (pos[2]<-1E3||azel[1]<=0) return 0.0; if (norm(ion,8)<=0.0) ion=ion_default; /* earth centered angle (semi-circle) */ psi=0.0137/(azel[1]/PI+0.11)-0.022; /* subionospheric latitude/longitude (semi-circle) */ phi=pos[0]/PI+psi*cos(azel[0]); if (phi> 0.416) phi= 0.416; else if (phi<-0.416) phi=-0.416; lam=pos[1]/PI+psi*sin(azel[0])/cos(phi*PI); /* geomagnetic latitude (semi-circle) */ phi+=0.064*cos((lam-1.617)*PI); /* local time (s) */ tt=43200.0*lam+time2gpst(t,&week); tt-=floor(tt/86400.0)*86400.0; /* 0<=tt<86400 */ /* slant factor */ f=1.0+16.0*pow(0.53-azel[1]/PI,3.0); /* ionospheric delay */ amp=ion[0]+phi*(ion[1]+phi*(ion[2]+phi*ion[3])); per=ion[4]+phi*(ion[5]+phi*(ion[6]+phi*ion[7])); amp=amp< 0.0? 0.0:amp; per=per<72000.0?72000.0:per; x=2.0*PI*(tt-50400.0)/per; return CLIGHT*f*(fabs(x)<1.57?5E-9+amp*(1.0+x*x*(-0.5+x*x/24.0)):5E-9); } /* ionosphere mapping function ------------------------------------------------- * compute ionospheric delay mapping function by single layer model * args : double *pos I receiver position {lat,lon,h} (rad,m) * double *azel I azimuth/elevation angle {az,el} (rad) * return : ionospheric mapping function *-----------------------------------------------------------------------------*/ extern double ionmapf(const double *pos, const double *azel) { if (pos[2]>=HION) return 1.0; return 1.0/cos(asin((RE_WGS84+pos[2])/(RE_WGS84+HION)*sin(PI/2.0-azel[1]))); }
48.005085
81
0.533559
[ "model" ]
a44f27e2102c63cde1f375f4e1741e7acd7a2463
552
h
C
src/Camera.h
PMFU/Vic2-Save-Analyzer
452d0c8aacdf75094586e4d79fb9ab29f743ef80
[ "MIT" ]
null
null
null
src/Camera.h
PMFU/Vic2-Save-Analyzer
452d0c8aacdf75094586e4d79fb9ab29f743ef80
[ "MIT" ]
null
null
null
src/Camera.h
PMFU/Vic2-Save-Analyzer
452d0c8aacdf75094586e4d79fb9ab29f743ef80
[ "MIT" ]
null
null
null
#pragma once #include <Engine.h> class Camera : public bs::Transform { public: Camera(); //Get the view matrix of the camera bs::mat4 getViewMatrix() const; //Get the projection matrix for the scene bs::mat4 getProjMatrix() const; //Capture a transform to follow void follow(bs::Transform& entity); //Self evident void update(); ~Camera() = default; private: float lerp; //Mode 0 is default, 1 is Left Eye, 2 is Right Eye //Or now ig for other stuff THE BOBSTER does int mode; bs::mat4 proj; bs::Transform* entityPos; };
16.727273
96
0.688406
[ "transform" ]
a45030c29338ecbee0cf2ec55ff87e8f7eca84dc
1,955
h
C
src/TextImp.h
esrille/escudo
1ba68f6930f1ddb97385a5b488644b6dfa132152
[ "Apache-2.0" ]
29
2015-01-25T15:12:02.000Z
2021-12-01T17:58:17.000Z
src/TextImp.h
esrille/escudo
1ba68f6930f1ddb97385a5b488644b6dfa132152
[ "Apache-2.0" ]
null
null
null
src/TextImp.h
esrille/escudo
1ba68f6930f1ddb97385a5b488644b6dfa132152
[ "Apache-2.0" ]
7
2015-04-15T02:05:21.000Z
2020-06-16T03:53:37.000Z
/* * Copyright 2010-2015 Esrille 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. */ #ifndef ORG_W3C_DOM_BOOTSTRAP_TEXTIMP_H_INCLUDED #define ORG_W3C_DOM_BOOTSTRAP_TEXTIMP_H_INCLUDED #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <org/w3c/dom/Text.h> #include "CharacterDataImp.h" namespace org { namespace w3c { namespace dom { namespace bootstrap { class TextImp : public ObjectMixin<TextImp, CharacterDataImp> { public: TextImp(DocumentImp* ownerDocument, const std::u16string& data) : ObjectMixin(ownerDocument, data) { nodeName = u"#text"; } // Node - override virtual Node cloneNode(bool deep = true) { auto node = std::make_shared<TextImp>(*this); if (deep) node->cloneChildren(this); return node; } virtual unsigned short getNodeType(); // Text virtual Text splitText(unsigned int offset); virtual std::u16string getWholeText(); // Text-51 bool getSerializeAsCDATA(); void setSerializeAsCDATA(bool serializeAsCDATA); // Object virtual Any message_(uint32_t selector, const char* id, int argc, Any* argv) { return Text::dispatch(this, selector, id, argc, argv); } static const char* const getMetaData() { return Text::getMetaData(); } }; typedef std::shared_ptr<TextImp> TextPtr; }}}} // org::w3c::dom::bootstrap #endif // ORG_W3C_DOM_BOOTSTRAP_TEXTIMP_H_INCLUDED
27.928571
80
0.69821
[ "object" ]
a451fbc5c78c6812f7b306431ba8701f4c800ff2
12,240
h
C
src/sedml/SedListOfModels.h
AMDmi3/libSEDML
a59c87df9298c8d72b199531f96b531bf4b4d9bb
[ "BSD-2-Clause" ]
7
2016-01-12T03:53:45.000Z
2019-10-17T21:23:37.000Z
src/sedml/SedListOfModels.h
AMDmi3/libSEDML
a59c87df9298c8d72b199531f96b531bf4b4d9bb
[ "BSD-2-Clause" ]
138
2015-05-29T19:18:34.000Z
2022-03-07T08:32:44.000Z
src/sedml/SedListOfModels.h
AMDmi3/libSEDML
a59c87df9298c8d72b199531f96b531bf4b4d9bb
[ "BSD-2-Clause" ]
12
2015-02-24T23:37:26.000Z
2021-11-02T17:11:27.000Z
/** * @file SedListOfModels.h * @brief Definition of the SedListOfModels class. * @author DEVISER * * <!-------------------------------------------------------------------------- * This file is part of libSEDML. Please visit http://sed-ml.org for more * information about SED-ML. The latest version of libSEDML can be found on * github: https://github.com/fbergmann/libSEDML/ * * Copyright (c) 2013-2019, Frank T. Bergmann * 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. * * 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. A copy of the license agreement is provided in the * file named "LICENSE.txt" included with this software distribution and also * available online as http://sbml.org/software/libsbml/license.html * ------------------------------------------------------------------------ --> * * @class SedListOfModels * @sbmlbrief{sedml} TODO:Definition of the SedListOfModels class. */ #ifndef SedListOfModels_H__ #define SedListOfModels_H__ #include <sedml/common/extern.h> #include <sedml/common/sedmlfwd.h> #ifdef __cplusplus #include <string> #include <sedml/SedListOf.h> #include <sedml/SedModel.h> #include <sbml/common/libsbml-namespace.h> LIBSEDML_CPP_NAMESPACE_BEGIN class LIBSEDML_EXTERN SedListOfModels : public SedListOf { public: /** * Creates a new SedListOfModels using the given SED-ML Level and @ p version * values. * * @param level an unsigned int, the SED-ML Level to assign to this * SedListOfModels. * * @param version an unsigned int, the SED-ML Version to assign to this * SedListOfModels. * * @copydetails doc_note_setting_lv_pkg */ SedListOfModels(unsigned int level = SEDML_DEFAULT_LEVEL, unsigned int version = SEDML_DEFAULT_VERSION); /** * Creates a new SedListOfModels using the given SedNamespaces object @p * sedmlns. * * @param sedmlns the SedNamespaces object. * * @copydetails doc_note_setting_lv_pkg */ SedListOfModels(SedNamespaces *sedmlns); /** * Copy constructor for SedListOfModels. * * @param orig the SedListOfModels instance to copy. */ SedListOfModels(const SedListOfModels& orig); /** * Assignment operator for SedListOfModels. * * @param rhs the SedListOfModels object whose values are to be used as the * basis of the assignment. */ SedListOfModels& operator=(const SedListOfModels& rhs); /** * Creates and returns a deep copy of this SedListOfModels object. * * @return a (deep) copy of this SedListOfModels object. */ virtual SedListOfModels* clone() const; /** * Destructor for SedListOfModels. */ virtual ~SedListOfModels(); /** * Get a SedModel from the SedListOfModels. * * @param n an unsigned int representing the index of the SedModel to * retrieve. * * @return the nth SedModel in this SedListOfModels or @c NULL if no such * object exists. * * @copydetails doc_returned_unowned_pointer * * @see addModel(const SedModel* object) * @see createModel() * @see get(const std::string& sid) * @see getNumModels() * @see remove(const std::string& sid) * @see remove(unsigned int n) */ virtual SedModel* get(unsigned int n); /** * Get a SedModel from the SedListOfModels. * * @param n an unsigned int representing the index of the SedModel to * retrieve. * * @return the nth SedModel in this SedListOfModels or @c NULL if no such * object exists. * * @copydetails doc_returned_unowned_pointer * * @see addModel(const SedModel* object) * @see createModel() * @see get(const std::string& sid) * @see getNumModels() * @see remove(const std::string& sid) * @see remove(unsigned int n) */ virtual const SedModel* get(unsigned int n) const; /** * Get a SedModel from the SedListOfModels based on its identifier. * * @param sid a string representing the identifier of the SedModel to * retrieve. * * @return the SedModel in this SedListOfModels with the given @p sid or * @c NULL if no such SedModel exists. * * @copydetails doc_returned_unowned_pointer * * @see addModel(const SedModel* object) * @see createModel() * @see get(unsigned int n) * @see getNumModels() * @see remove(const std::string& sid) * @see remove(unsigned int n) */ virtual SedModel* get(const std::string& sid); /** * Get a SedModel from the SedListOfModels based on its identifier. * * @param sid a string representing the identifier of the SedModel to * retrieve. * * @return the SedModel in this SedListOfModels with the given @p sid or * @c NULL if no such SedModel exists. * * @copydetails doc_returned_unowned_pointer * * @see addModel(const SedModel* object) * @see createModel() * @see get(unsigned int n) * @see getNumModels() * @see remove(const std::string& sid) * @see remove(unsigned int n) */ virtual const SedModel* get(const std::string& sid) const; /** * Removes the nth SedModel from this SedListOfModels and returns a pointer * to it. * * @param n an unsigned int representing the index of the SedModel to remove. * * @return a pointer to the nth SedModel in this SedListOfModels. * * @copydetails doc_warning_returns_owned_pointer * * @see addModel(const SedModel* object) * @see createModel() * @see get(const std::string& sid) * @see get(unsigned int n) * @see getNumModels() * @see remove(const std::string& sid) */ virtual SedModel* remove(unsigned int n); /** * Removes the SedModel from this SedListOfModels based on its identifier and * returns a pointer to it. * * @param sid a string representing the identifier of the SedModel to remove. * * @return the SedModel in this SedListOfModels based on the identifier or * NULL if no such SedModel exists. * * @copydetails doc_warning_returns_owned_pointer * * @see addModel(const SedModel* object) * @see createModel() * @see get(const std::string& sid) * @see get(unsigned int n) * @see getNumModels() * @see remove(unsigned int n) */ virtual SedModel* remove(const std::string& sid); /** * Adds a copy of the given SedModel to this SedListOfModels. * * @param sm the SedModel object to add. * * @copydetails doc_returns_success_code * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} * @li @sedmlconstant{LIBSEDML_OPERATION_FAILED, OperationReturnValues_t} * @li @sedmlconstant{LIBSEDML_INVALID_OBJECT, OperationReturnValues_t} * @li @sedmlconstant{LIBSEDML_LEVEL_MISMATCH, OperationReturnValues_t} * @li @sedmlconstant{LIBSEDML_VERSION_MISMATCH, OperationReturnValues_t} * @li @sedmlconstant{LIBSEDML_PKG_VERSION_MISMATCH, OperationReturnValues_t} * @li @sedmlconstant{LIBSEDML_DUPLICATE_OBJECT_ID, OperationReturnValues_t} * * @copydetails doc_note_object_is_copied * * @see createModel() * @see get(const std::string& sid) * @see get(unsigned int n) * @see getNumModels() * @see remove(const std::string& sid) * @see remove(unsigned int n) */ int addModel(const SedModel* sm); /** * Get the number of SedModel objects in this SedListOfModels. * * @return the number of SedModel objects in this SedListOfModels. * * @see addModel(const SedModel* object) * @see createModel() * @see get(const std::string& sid) * @see get(unsigned int n) * @see remove(const std::string& sid) * @see remove(unsigned int n) */ unsigned int getNumModels() const; /** * Creates a new SedModel object, adds it to this SedListOfModels object and * returns the SedModel object created. * * @return a new SedModel object instance. * * @copydetails doc_returned_unowned_pointer * * @see addModel(const SedModel* object) * @see get(const std::string& sid) * @see get(unsigned int n) * @see getNumModels() * @see remove(const std::string& sid) * @see remove(unsigned int n) */ SedModel* createModel(); /** * Returns the XML element name of this SedListOfModels object. * * For SedListOfModels, the XML element name is always @c "listOfModels". * * @return the name of this element, i.e. @c "listOfModels". */ virtual const std::string& getElementName() const; /** * Returns the libSEDML type code for this SedListOfModels object. * * @copydetails doc_what_are_typecodes * * @return the SED-ML type code for this object: * @sedmlconstant{SEDML_LIST_OF, SedTypeCode_t}. * * @copydetails doc_warning_typecodes_not_unique */ virtual int getTypeCode() const; /** * Returns the libSEDML type code for the SED-ML objects contained in this * SedListOfModels object. * * @copydetails doc_what_are_typecodes * * @return the SED-ML typecode for the objects contained in this * SedListOfModels: * @sedmlconstant{SEDML_MODEL, SedTypeCode_t}. * * @copydetails doc_warning_typecodes_not_unique * * @see getElementName() */ virtual int getItemTypeCode() const; #ifndef SWIG #endif /* !SWIG */ protected: /** @cond doxygenLibSEDMLInternal */ /** * Creates a new SedModel in this SedListOfModels */ virtual SedBase* createObject(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLInputStream& stream); /** @endcond */ }; LIBSEDML_CPP_NAMESPACE_END #endif /* __cplusplus */ #ifndef SWIG LIBSEDML_CPP_NAMESPACE_BEGIN BEGIN_C_DECLS /** * Get a SedModel_t from the SedListOf_t. * * @param slo the SedListOf_t structure to search. * * @param n an unsigned int representing the index of the SedModel_t to * retrieve. * * @return the nth SedModel_t in this SedListOf_t or @c NULL if no such object * exists. * * @copydetails doc_returned_unowned_pointer * * @memberof SedListOfModels_t */ LIBSEDML_EXTERN SedModel_t* SedListOfModels_getModel(SedListOf_t* slo, unsigned int n); /** * Get a SedModel_t from the SedListOf_t based on its identifier. * * @param slo the SedListOf_t structure to search. * * @param sid a string representing the identifier of the SedModel_t to * retrieve. * * @return the SedModel_t in this SedListOf_t with the given @p sid or @c NULL * if no such SedModel_t exists. * * @copydetails doc_returned_unowned_pointer * * @memberof SedListOfModels_t */ LIBSEDML_EXTERN SedModel_t* SedListOfModels_getById(SedListOf_t* slo, const char *sid); /** * Removes the nth SedModel_t from this SedListOf_t and returns a pointer to * it. * * @param slo the SedListOf_t structure to search. * * @param n an unsigned int representing the index of the SedModel_t to remove. * * @return a pointer to the nth SedModel_t in this SedListOf_t. * * @copydetails doc_warning_returns_owned_pointer * * @memberof SedListOfModels_t */ LIBSEDML_EXTERN SedModel_t* SedListOfModels_remove(SedListOf_t* slo, unsigned int n); /** * Removes the SedModel_t from this SedListOf_t based on its identifier and * returns a pointer to it. * * @param slo the SedListOf_t structure to search. * * @param sid a string representing the identifier of the SedModel_t to remove. * * @return the SedModel_t in this SedListOf_t based on the identifier or NULL * if no such SedModel_t exists. * * @copydetails doc_warning_returns_owned_pointer * * @memberof SedListOfModels_t */ LIBSEDML_EXTERN SedModel_t* SedListOfModels_removeById(SedListOf_t* slo, const char* sid); END_C_DECLS LIBSEDML_CPP_NAMESPACE_END #endif /* !SWIG */ #endif /* !SedListOfModels_H__ */
24.578313
79
0.694281
[ "object" ]
a452f4eb798fb30096bc49a89a4d918e18d20648
3,022
h
C
source/Senses/View/UIWindow.h
fstudio/Phoenix
28a7c6a3932fd7d6fea12770d0aa1e20bc70db7d
[ "MIT" ]
8
2015-01-23T05:41:46.000Z
2019-11-20T05:10:27.000Z
source/Senses/View/UIWindow.h
fstudio/Phoenix
28a7c6a3932fd7d6fea12770d0aa1e20bc70db7d
[ "MIT" ]
null
null
null
source/Senses/View/UIWindow.h
fstudio/Phoenix
28a7c6a3932fd7d6fea12770d0aa1e20bc70db7d
[ "MIT" ]
4
2015-05-05T05:15:43.000Z
2020-03-07T11:10:56.000Z
/********************************************************************************************************* * UIWindow.hpp * Note: UIWindow.hpp * Date: @2015.01 * E-mail:<forcemz@outlook.com> * Copyright (C) 2015 The ForceStudio All Rights Reserved. **********************************************************************************************************/ #ifndef PHOENIX_UI_H #define PHOENIX_UI_H #ifndef _SENSES_VIEW_WINDOWINC_ #include "WindowInc.h" #endif #include <string> #include <vector> /* CalculatePopupWindowPosition Calculate Popup Window Point BOOL WINAPI CalculatePopupWindowPosition( _In_ const POINT *anchorPoint, _In_ const SIZE *windowSize, _In_ UINT flags, _In_opt_ RECT *excludeRect, _Out_ RECT *popupWindowPosition ); URL:https://msdn.microsoft.com/en-us/library/windows/desktop/dd565861(v=vs.85).aspx CreateWindowInBand //// CreateWindowIndirect +... HWND GUIAPI CreateMainWindowIndirect(PDLGTEMPLATE pDlgTemplate,HWND hOwner,WNDPROC WndProc); BOOL GUIAPI DestroyMainWindowIndirect(HWND hMainWin); ... UpdateLayeredWindowIndirect BOOL WINAPI ChangeWindowMessageFilterEx( _In_ HWND hWnd, _In_ UINT message, _In_ DWORD action, _Inout_opt_ PCHANGEFILTERSTRUCT pChangeFilterStruct ); URL:https://msdn.microsoft.com/en-us/library/windows/desktop/dd388202(v=vs.85).aspx In Search Window. UINT WINAPI GetWindowModuleFileName( _In_ HWND hwnd, _Out_ LPTSTR lpszFileName, _In_ UINT cchFileNameMax ); Layout: int MapWindowPoints( _In_ HWND hWndFrom, _In_ HWND hWndTo, _Inout_ LPPOINT lpPoints, _In_ UINT cPoints ); */ ////UI Tab class UITab{ public: UITab(); bool ReSize(); }; class UIWindow:public CWindowImpl<UIWindow, CWindow, CFrameWinTraits>{ private: size_t Id; public: UIWindow(); DECLARE_WND_CLASS(UIWINDOWCLASS) BEGIN_MSG_MAP(UIWindow) MESSAGE_HANDLER(WM_PAINT,OnPaint) MESSAGE_HANDLER(WM_CREATE,OnCreate) MESSAGE_HANDLER(WM_DESTROY,OnDestory) MESSAGE_HANDLER(WM_SIZE,OnSize) END_MSG_MAP() unsigned Runable(); private: std::vector<std::wstring> tab; bool InitializeUI(); void ProcessMouseMessage(UINT message, LPARAM lParam); public: HRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled); HRESULT OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled); HRESULT OnDestory(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled); HRESULT OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled); }; typedef COMDLG_FILTERSPEC FilterSpec; bool FileOpenWindowProvider( HWND hParent, std::wstring &filename, std::vector<FilterSpec> *vSuffix, const wchar_t *pszDefaultSuffix, const wchar_t *pszWindowTitle); bool FileSaveWindowProvider( HWND hParent, std::wstring &filename, std::vector<FilterSpec> *vSuffix, const wchar_t *pszDefaultSuffix, const wchar_t *pszDefaultFileName, const wchar_t *pszWindowTitle); #endif
26.051724
107
0.682991
[ "vector" ]
a4578f1687966d1bc1c8283e001b517d6f5f59d8
4,688
h
C
ext/dsent/tech/TechModel.h
hyu-iot/gem5
aeccc8bd8e9a86f96fc7a6f40d978f8494337fc5
[ "BSD-3-Clause" ]
765
2015-01-14T16:17:04.000Z
2022-03-28T07:46:28.000Z
ext/dsent/tech/TechModel.h
hyu-iot/gem5
aeccc8bd8e9a86f96fc7a6f40d978f8494337fc5
[ "BSD-3-Clause" ]
148
2018-07-20T00:58:36.000Z
2021-11-16T01:52:33.000Z
ext/dsent/tech/TechModel.h
hyu-iot/gem5
aeccc8bd8e9a86f96fc7a6f40d978f8494337fc5
[ "BSD-3-Clause" ]
807
2015-01-06T09:55:38.000Z
2022-03-30T10:23:36.000Z
/* Copyright (c) 2012 Massachusetts Institute of Technology * * 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. */ #ifndef __DSENT_TECH_TECH_MODEL_H__ #define __DSENT_TECH_TECH_MODEL_H__ #include <vector> #include <set> #include "libutil/Config.h" #include "libutil/String.h" namespace DSENT { class StdCellLib; using std::set; using std::vector; using LibUtil::String; class TechModel { public: typedef std::set<String>::const_iterator ConstWireLayerIterator; public: TechModel(); virtual ~TechModel(); public: // Get the value_ corresponding to the key_ const String& get(const String& key_) const; // Set the pointer to a standard cell library void setStdCellLib(const StdCellLib* std_cell_lib_); // Get the pointer to the standard cell library const StdCellLib* getStdCellLib() const; // Return a cloned copy of this instance virtual TechModel* clone() const; // Override readFile function to include multiple technology files virtual void readFile(const String& filename_); // Transistor // Returns the leakage current of NMOS transistors, given the transistor stakcing, transistor widths, and input combination double calculateNmosLeakageCurrent(unsigned int num_stacks_, double uni_stacked_mos_width_, unsigned int input_vector_) const; double calculateNmosLeakageCurrent(unsigned int num_stacks_, const vector<double>& stacked_mos_widths_, unsigned int input_vector_) const; // Returns the leakage current of PMOS transistors, given the transistor stakcing, transistor widths, and input combination double calculatePmosLeakageCurrent(unsigned int num_stacks_, double uni_stacked_mos_width_, unsigned int input_vector_) const; double calculatePmosLeakageCurrent(unsigned int num_stacks_, const vector<double>& stacked_mos_widths_, unsigned int input_vector_) const; // Returns the leakage current, given the transistor stakcing, transistor widths, input combination, // and technology information (vdd, subthreshold swing, subthreshold dibl swing) double calculateLeakageCurrentFactor(unsigned int num_stacks_, const vector<double>& stacked_mos_widths_, unsigned int input_vector_, double vdd_, double subthreshold_swing_, double dibl_swing_) const; // Wire // Check if the wire layer exist bool isWireLayerExist(const String& layer_name_) const; const std::set<String>* getAvailableWireLayers() const; // Return wire capacitance for given wire layer, wire width, wire spacing, and wire length double calculateWireCapacitance(const String& layer_name_, double width_, double spacing_, double length_) const; // Return wire resistance for given wire layer, wire width, and wire length double calculateWireResistance(const String& layer_name_, double width_, double length_) const; private: // Private copy constructor. Use clone to perform copy operation TechModel(const TechModel& tech_model_); private: // A pointer to a standard cell library const StdCellLib* m_std_cell_lib_; // A set of available wire layers std::set<String>* m_available_wire_layers_; // A map of model's parameters std::map<String, String> params; }; // class TechModel } // namespace DSENT #endif // __DSENT_TECH_TECH_MODEL_H__
48.329897
213
0.706271
[ "vector", "model" ]
a45b17102e3179f4bfa25c1f49b0c347a9a0aa33
1,144
h
C
MCEModelEditingProxy/MCEModelEditingProxy.h
milancermak/MCEModelEditingProxy
b052a6eba2cc5a820b6570e5e806b50bfeb0ba44
[ "MIT" ]
3
2016-03-07T18:54:19.000Z
2019-09-15T11:48:22.000Z
MCEModelEditingProxy/MCEModelEditingProxy.h
milancermak/MCEModelEditingProxy
b052a6eba2cc5a820b6570e5e806b50bfeb0ba44
[ "MIT" ]
null
null
null
MCEModelEditingProxy/MCEModelEditingProxy.h
milancermak/MCEModelEditingProxy
b052a6eba2cc5a820b6570e5e806b50bfeb0ba44
[ "MIT" ]
null
null
null
// // MCEModelEditingProxy.h // MCEModelEditingProxy // // Created by Milan Cermak on 1. 12. 2013. // Copyright (c) 2013 Milan Cermak. All rights reserved. // #import <Foundation/Foundation.h> @protocol MCEModelEditing <NSObject> - (id)modelProxy; // The following optional methods are to silence the compiler // when the class is used (see README for details). You don't // need to implement any of them. They mimick the actual interface // of the MCEModelEditingProxy class and "expose" it on your models. @optional - (void)commit; - (BOOL)isUpdated; - (NSDictionary *)newValues; - (void)reset; @end @interface MCEModelEditingProxy : NSProxy @property (nonatomic, getter=isUpdated, readonly) BOOL updates; - (id)initWithModel:(id<MCEModelEditing>)modelObject; // Calling commit sets the new values, that have been so far // set only on the proxy, on the original model. - (void)commit; // Returns an NSDictionary holding new values of properties // that were set on the model since initialization. - (NSDictionary *)newValues; // Call this method to throw away all recorded changes // made to the model. - (void)reset; @end
23.833333
68
0.738636
[ "model" ]
a46779a9ea9e31cc04b9a8e2390fb25e46f70b95
2,226
h
C
src/one_hot.h
dbueno/euforia
1833ce6d6c645ca41fb21026ec87e896d9e5257d
[ "MIT" ]
1
2021-10-06T23:23:35.000Z
2021-10-06T23:23:35.000Z
src/one_hot.h
dbueno/euforia
1833ce6d6c645ca41fb21026ec87e896d9e5257d
[ "MIT" ]
null
null
null
src/one_hot.h
dbueno/euforia
1833ce6d6c645ca41fb21026ec87e896d9e5257d
[ "MIT" ]
null
null
null
// Copyright 2021 National Technology & Engineering Solutions of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software. See LICENSE.txt for details. // // Author: Denis Bueno #ifndef one_hot_hpp #define one_hot_hpp #include <memory> #include "checker_types.h" #include "supp/expr_supp.h" namespace euforia { /// Knows how to efficiently express a one hot encoding for the (mutable) set of bools given. class OneHotConstraints { ExprSet bools; public: struct Config { enum { kNaive, kCommander } encoding_type; int commander_max_size; /// Configures for naive encoding Config() : encoding_type(kNaive) {} /// Configures for commander encoding with given max size Config(int max_size) : encoding_type(kCommander), commander_max_size(max_size) {} static Config Naive() { return Config(); } static Config Commander(const int max_size) { return Config(max_size); } }; OneHotConstraints(z3::context& c); OneHotConstraints(const OneHotConstraints&); OneHotConstraints& operator=(const OneHotConstraints&) = delete; OneHotConstraints(OneHotConstraints&&) = delete; OneHotConstraints& operator=(OneHotConstraints&&); ~OneHotConstraints(); const ExprSet& getBools() const { return bools; } const ExprSet& commander_vars() const; template <typename Iter> void insert(Iter it, Iter ie) { while (it != ie) { addBool(*it++); } } void Insert(const z3::expr& e) { return addBool(e); } /// Add a Boolean state var to this one-hot set void addBool(const z3::expr& e) { assert(e.is_bool()); bools.emplace(std::cref(e)); } /// Get one-hot constraints to assert z3::expr at_most(const Config& c); /// Get the list of constraints that force the Bools to be exactly one-hot std::vector<z3::expr> constraintsExactly() const; /// Get the list of constraints that force the Bools to be at-most-one hot std::vector<z3::expr> constraintsAtMost() const; z3::context& ctx() const { z3::expr b = *bools.begin(); return b.ctx(); } private: class Impl; std::unique_ptr<Impl> pimpl_; }; } #endif /* one_hot_hpp */
26.819277
228
0.692273
[ "vector" ]
a46fa0e8ad4854dbc79230a90e2edefb56c05924
5,880
h
C
src/redland/redland-1.0.17/src/rdf_statement.h
aram148/libOmexMeta
331a0a48570a212aaa2b6cb3fe72b9f43ac828af
[ "Apache-2.0" ]
6
2020-07-07T11:23:29.000Z
2021-11-19T09:49:02.000Z
src/redland/redland-1.0.17/src/rdf_statement.h
aram148/libOmexMeta
331a0a48570a212aaa2b6cb3fe72b9f43ac828af
[ "Apache-2.0" ]
79
2020-06-23T15:32:44.000Z
2022-02-23T06:46:43.000Z
src/redland/redland-1.0.17/src/rdf_statement.h
aram148/libOmexMeta
331a0a48570a212aaa2b6cb3fe72b9f43ac828af
[ "Apache-2.0" ]
5
2020-11-29T04:29:54.000Z
2021-08-17T15:55:41.000Z
/* -*- Mode: c; c-basic-offset: 2 -*- * * rdf_statement.h - RDF Statement definition * * Copyright (C) 2000-2008, David Beckett http://www.dajobe.org/ * Copyright (C) 2000-2004, University of Bristol, UK http://www.bristol.ac.uk/ * * This package is Free Software and part of Redland http://librdf.org/ * * It is licensed under the following three licenses as alternatives: * 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version * 2. GNU General Public License (GPL) V2 or any newer version * 3. Apache License, V2.0 or any newer version * * You may not use this file except in compliance with at least one of * the above three licenses. * * See LICENSE.html or LICENSE.txt at the top of this package for the * complete terms and further detail along with the license texts for * the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively. * * */ #ifndef LIBRDF_STATEMENT_H #define LIBRDF_STATEMENT_H #ifdef LIBRDF_INTERNAL #include <rdf_statement_internal.h> #endif #ifdef __cplusplus extern "C" { #endif /** * librdf_statement_part: * @LIBRDF_STATEMENT_SUBJECT: Subject of a statement. * @LIBRDF_STATEMENT_PREDICATE: Predicate of a statement. * @LIBRDF_STATEMENT_OBJECT: Object of a statement. * @LIBRDF_STATEMENT_ALL: All parts of a statement. * * Flags that are or-ed to indicate statement parts. * * Used in fields arguments to methods such as the public * librdf_statement_encode_parts() librdf_statement_decode_parts() * librdf_new_stream_from_node_iterator(). */ typedef enum { LIBRDF_STATEMENT_SUBJECT = 1 << 0, LIBRDF_STATEMENT_PREDICATE = 1 << 1, LIBRDF_STATEMENT_OBJECT = 1 << 2, /* must be a combination of all of the above */ LIBRDF_STATEMENT_ALL = (LIBRDF_STATEMENT_SUBJECT | LIBRDF_STATEMENT_PREDICATE | LIBRDF_STATEMENT_OBJECT) } librdf_statement_part; /* initialising functions / constructors */ /* Create a new Statement. */ REDLAND_EXPORT librdf_statement *librdf_new_statement(librdf_world *world); /* Create a new Statement from an existing Statement - DEEP CLONE */ REDLAND_EXPORT librdf_statement *librdf_new_statement_from_statement(librdf_statement *statement); /* Create a new Statement from an existing Statement - SHALLOW CLONE */ REDLAND_EXPORT librdf_statement *librdf_new_statement_from_statement2(librdf_statement *statement); /* Create a new Statement from existing Nodes */ REDLAND_EXPORT librdf_statement * librdf_new_statement_from_nodes(librdf_world *world, librdf_node *subject, librdf_node *predicate, librdf_node *object); /* Init a statically allocated statement */ REDLAND_EXPORT void librdf_statement_init(librdf_world *world, librdf_statement *statement); /* Clear a statically allocated statement */ REDLAND_EXPORT void librdf_statement_clear(librdf_statement *statement); /* destructor */ REDLAND_EXPORT void librdf_free_statement(librdf_statement *statement); REDLAND_EXPORT void librdf_free_statement2(librdf_statement *statement); /* functions / methods */ REDLAND_EXPORT librdf_node *librdf_statement_get_subject(librdf_statement *statement); REDLAND_EXPORT void librdf_statement_set_subject(librdf_statement *statement, librdf_node *node); REDLAND_EXPORT librdf_node *librdf_statement_get_predicate(librdf_statement *statement); REDLAND_EXPORT void librdf_statement_set_predicate(librdf_statement *statement, librdf_node *node); REDLAND_EXPORT librdf_node *librdf_statement_get_object(librdf_statement *statement); REDLAND_EXPORT void librdf_statement_set_object(librdf_statement *statement, librdf_node *node); /* if statement has all fields */ REDLAND_EXPORT int librdf_statement_is_complete(librdf_statement *statement); /* convert to a string */ REDLAND_EXPORT REDLAND_DEPRECATED unsigned char *librdf_statement_to_string(librdf_statement *statement); /* print it prettily */ REDLAND_EXPORT int librdf_statement_write(librdf_statement *statement, raptor_iostream *iostr); REDLAND_EXPORT void librdf_statement_print(librdf_statement *statement, FILE *fh); /* compare two statements */ REDLAND_EXPORT int librdf_statement_equals(librdf_statement *statement1, librdf_statement *statement2); /* match statement against one with partial content */ REDLAND_EXPORT int librdf_statement_match(librdf_statement *statement, librdf_statement *partial_statement); /* serialising/deserialising */ REDLAND_EXPORT REDLAND_DEPRECATED size_t librdf_statement_encode(librdf_statement *statement, unsigned char *buffer, size_t length); REDLAND_EXPORT size_t librdf_statement_encode2(librdf_world *world, librdf_statement *statement, unsigned char *buffer, size_t length); REDLAND_EXPORT REDLAND_DEPRECATED size_t librdf_statement_encode_parts(librdf_statement *statement, librdf_node *context_node, unsigned char *buffer, size_t length, librdf_statement_part fields); REDLAND_EXPORT size_t librdf_statement_encode_parts2(librdf_world *world, librdf_statement *statement, librdf_node *context_node, unsigned char *buffer, size_t length, librdf_statement_part fields); REDLAND_EXPORT REDLAND_DEPRECATED size_t librdf_statement_decode(librdf_statement *statement, unsigned char *buffer, size_t length); REDLAND_EXPORT size_t librdf_statement_decode2(librdf_world *world, librdf_statement *statement, librdf_node **context_node, unsigned char *buffer, size_t length); REDLAND_EXPORT REDLAND_DEPRECATED size_t librdf_statement_decode_parts(librdf_statement *statement, librdf_node **context_node, unsigned char *buffer, size_t length); #ifdef __cplusplus } #endif #endif
37.21519
121
0.759864
[ "object" ]
a46fa93e4fd096b9234c37d5efebf3a30e388cac
596
h
C
Sources/Internal/Base/BaseMath.h
stinvi/dava.engine
2b396ca49cdf10cdc98ad8a9ffcf7768a05e285e
[ "BSD-3-Clause" ]
26
2018-09-03T08:48:22.000Z
2022-02-14T05:14:50.000Z
Sources/Internal/Base/BaseMath.h
ANHELL-blitz/dava.engine
ed83624326f000866e29166c7f4cccfed1bb41d4
[ "BSD-3-Clause" ]
null
null
null
Sources/Internal/Base/BaseMath.h
ANHELL-blitz/dava.engine
ed83624326f000866e29166c7f4cccfed1bb41d4
[ "BSD-3-Clause" ]
45
2018-05-11T06:47:17.000Z
2022-02-03T11:30:55.000Z
#pragma once #include <cmath> /** \defgroup math Math */ #include "Math/MathConstants.h" #include "Math/Math2D.h" #include "Math/Vector.h" #include "Math/Rect.h" #include "Math/Circle.h" #include "Math/Sphere.h" #include "Math/Matrix2.h" #include "Math/Matrix3.h" #include "Math/Matrix4.h" #include "Math/MathHelpers.h" #include "Math/Quaternion.h" #include "Math/Plane.h" #include "Math/Polygon3.h" #include "Math/Polygon2.h" #include "Math/AABBox2.h" #include "Math/AABBox3.h" #include "Math/Spline.h" #include "Math/BezierSpline.h" #include "Math/Color.h" #include "Render/RGBColor.h"
18.625
31
0.719799
[ "render", "vector" ]
a471e6bd3e8ebd2970d575a26c24febd59ca43b9
14,676
c
C
ncd/modules/foreach.c
offlinehacker/NCD
b5762ae6026f06e9a3940a182218a6c7c4bb49c3
[ "BSD-3-Clause" ]
3
2018-12-24T09:20:44.000Z
2021-01-03T22:30:00.000Z
ncd/modules/foreach.c
gonzopancho/NCD
b5762ae6026f06e9a3940a182218a6c7c4bb49c3
[ "BSD-3-Clause" ]
null
null
null
ncd/modules/foreach.c
gonzopancho/NCD
b5762ae6026f06e9a3940a182218a6c7c4bb49c3
[ "BSD-3-Clause" ]
1
2016-04-19T22:18:18.000Z
2016-04-19T22:18:18.000Z
/** * @file foreach.c * @author Ambroz Bizjak <ambrop7@gmail.com> * * @section LICENSE * * 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 author 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 AUTHOR 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. * * @section DESCRIPTION * * Synopsis: * foreach(list list, string template, list args) * * Description: * Initializes a template process for each element of list, sequentially, * obeying to the usual execution model of NCD. * It's equivalent to (except for special variables): * * call(template, args); * ... * call(template, args); # one call() for every element of list * * Template process specials: * * _index - index of the list element corresponding to the template process, * as a decimal string, starting from zero * _elem - element of list corresponding to the template process * _caller.X - X as seen from the foreach() statement */ #include <stdlib.h> #include <misc/balloc.h> #include <misc/string_begins_with.h> #include <system/BReactor.h> #include <ncd/NCDModule.h> #include <generated/blog_channel_ncd_foreach.h> #define ModuleLog(i, ...) NCDModuleInst_Backend_Log((i), BLOG_CURRENT_CHANNEL, __VA_ARGS__) #define RETRY_TIME 5000 #define ISTATE_WORKING 1 #define ISTATE_UP 2 #define ISTATE_WAITING 3 #define ISTATE_TERMINATING 4 #define ESTATE_FORGOTTEN 1 #define ESTATE_DOWN 2 #define ESTATE_UP 3 #define ESTATE_WAITING 4 #define ESTATE_TERMINATING 5 struct element; struct instance { NCDModuleInst *i; char *template_name; NCDValue *args; BTimer timer; size_t num_elems; struct element *elems; size_t gp; // good pointer size_t ip; // initialized pointer int state; }; struct element { struct instance *inst; size_t i; NCDValue *value; NCDModuleProcess process; int state; }; static void assert_state (struct instance *o); static void work (struct instance *o); static void advance (struct instance *o); static void timer_handler (struct instance *o); static void element_process_handler_event (struct element *e, int event); static int element_process_func_getspecialobj (struct element *e, const char *name, NCDObject *out_object); static int element_caller_object_func_getobj (struct element *e, const char *name, NCDObject *out_object); static int element_index_object_func_getvar (struct element *e, const char *name, NCDValue *out_value); static int element_elem_object_func_getvar (struct element *e, const char *name, NCDValue *out_value); static void instance_free (struct instance *o); static void assert_state (struct instance *o) { ASSERT(o->gp <= o->num_elems) ASSERT(o->ip <= o->num_elems) ASSERT(o->gp <= o->ip) #ifndef NDEBUG // check GP for (size_t i = 0; i < o->gp; i++) { if (i == o->gp - 1) { ASSERT(o->elems[i].state == ESTATE_UP || o->elems[i].state == ESTATE_DOWN || o->elems[i].state == ESTATE_WAITING) } else { ASSERT(o->elems[i].state == ESTATE_UP) } } // check IP size_t ip = o->num_elems; while (ip > 0 && o->elems[ip - 1].state == ESTATE_FORGOTTEN) { ip--; } ASSERT(o->ip == ip) // check gap for (size_t i = o->gp; i < o->ip; i++) { if (i == o->ip - 1) { ASSERT(o->elems[i].state == ESTATE_UP || o->elems[i].state == ESTATE_DOWN || o->elems[i].state == ESTATE_WAITING || o->elems[i].state == ESTATE_TERMINATING) } else { ASSERT(o->elems[i].state == ESTATE_UP || o->elems[i].state == ESTATE_DOWN || o->elems[i].state == ESTATE_WAITING) } } #endif } static void work (struct instance *o) { assert_state(o); // stop timer BReactor_RemoveTimer(o->i->params->reactor, &o->timer); if (o->state == ISTATE_WAITING) { return; } if (o->state == ISTATE_UP && !(o->gp == o->ip && o->gp == o->num_elems && (o->gp == 0 || o->elems[o->gp - 1].state == ESTATE_UP))) { // signal down NCDModuleInst_Backend_Down(o->i); // set state waiting o->state = ISTATE_WAITING; return; } if (o->gp < o->ip) { // get last element struct element *le = &o->elems[o->ip - 1]; ASSERT(le->state != ESTATE_FORGOTTEN) // start terminating if not already if (le->state != ESTATE_TERMINATING) { // request termination NCDModuleProcess_Terminate(&le->process); // set element state terminating le->state = ESTATE_TERMINATING; } return; } if (o->state == ISTATE_TERMINATING) { // finally die instance_free(o); return; } if (o->gp == o->num_elems && (o->gp == 0 || o->elems[o->gp - 1].state == ESTATE_UP)) { if (o->state == ISTATE_WORKING) { // signal up NCDModuleInst_Backend_Up(o->i); // set state up o->state = ISTATE_UP; } return; } if (o->gp > 0 && o->elems[o->gp - 1].state == ESTATE_WAITING) { // get last element struct element *le = &o->elems[o->gp - 1]; // continue process NCDModuleProcess_Continue(&le->process); // set state down le->state = ESTATE_DOWN; return; } if (o->gp > 0 && o->elems[o->gp - 1].state == ESTATE_DOWN) { return; } ASSERT(o->gp == 0 || o->elems[o->gp - 1].state == ESTATE_UP) advance(o); return; } static void advance (struct instance *o) { assert_state(o); ASSERT(o->gp == o->ip) ASSERT(o->gp < o->num_elems) ASSERT(o->gp == 0 || o->elems[o->gp - 1].state == ESTATE_UP) ASSERT(o->elems[o->gp].state == ESTATE_FORGOTTEN) // get next element struct element *e = &o->elems[o->gp]; // copy arguments NCDValue args; if (!NCDValue_InitCopy(&args, o->args)) { ModuleLog(o->i, BLOG_ERROR, "NCDValue_InitCopy failed"); goto fail; } // init process if (!NCDModuleProcess_Init(&e->process, o->i, o->template_name, args, e, (NCDModuleProcess_handler_event)element_process_handler_event)) { ModuleLog(o->i, BLOG_ERROR, "NCDModuleProcess_Init failed"); NCDValue_Free(&args); goto fail; } // set special functions NCDModuleProcess_SetSpecialFuncs(&e->process, (NCDModuleProcess_func_getspecialobj)element_process_func_getspecialobj); // set element state down e->state = ESTATE_DOWN; // increment GP and IP o->gp++; o->ip++; return; fail: // set timer BReactor_SetTimer(o->i->params->reactor, &o->timer); } static void timer_handler (struct instance *o) { assert_state(o); ASSERT(o->gp == o->ip) ASSERT(o->gp < o->num_elems) ASSERT(o->gp == 0 || o->elems[o->gp - 1].state == ESTATE_UP) ASSERT(o->elems[o->gp].state == ESTATE_FORGOTTEN) advance(o); return; } static void element_process_handler_event (struct element *e, int event) { struct instance *o = e->inst; assert_state(o); ASSERT(e->i < o->ip) ASSERT(e->state != ESTATE_FORGOTTEN) switch (event) { case NCDMODULEPROCESS_EVENT_UP: { ASSERT(e->state == ESTATE_DOWN) ASSERT(o->gp == o->ip) ASSERT(o->gp == e->i + 1) // set element state up e->state = ESTATE_UP; } break; case NCDMODULEPROCESS_EVENT_DOWN: { ASSERT(e->state == ESTATE_UP) // set element state waiting e->state = ESTATE_WAITING; // bump down GP if (o->gp > e->i + 1) { o->gp = e->i + 1; } } break; case NCDMODULEPROCESS_EVENT_TERMINATED: { ASSERT(e->state == ESTATE_TERMINATING) ASSERT(o->gp < o->ip) ASSERT(o->ip == e->i + 1) // free process NCDModuleProcess_Free(&e->process); // set element state forgotten e->state = ESTATE_FORGOTTEN; // decrement IP o->ip--; } break; default: ASSERT(0); } work(o); return; } static int element_process_func_getspecialobj (struct element *e, const char *name, NCDObject *out_object) { struct instance *o = e->inst; ASSERT(e->state != ESTATE_FORGOTTEN) if (!strcmp(name, "_caller")) { *out_object = NCDObject_Build(NULL, e, NULL, (NCDObject_func_getobj)element_caller_object_func_getobj); return 1; } if (!strcmp(name, "_index")) { *out_object = NCDObject_Build(NULL, e, (NCDObject_func_getvar)element_index_object_func_getvar, NULL); return 1; } if (!strcmp(name, "_elem")) { *out_object = NCDObject_Build(NULL, e, (NCDObject_func_getvar)element_elem_object_func_getvar, NULL); return 1; } return 0; } static int element_caller_object_func_getobj (struct element *e, const char *name, NCDObject *out_object) { struct instance *o = e->inst; ASSERT(e->state != ESTATE_FORGOTTEN) return NCDModuleInst_Backend_GetObj(o->i, name, out_object); } static int element_index_object_func_getvar (struct element *e, const char *name, NCDValue *out_value) { struct instance *o = e->inst; ASSERT(e->state != ESTATE_FORGOTTEN) if (strcmp(name, "")) { return 0; } char str[64]; snprintf(str, sizeof(str), "%zu", e->i); if (!NCDValue_InitString(out_value, str)) { ModuleLog(o->i, BLOG_ERROR, "NCDValue_InitString failed"); return 0; } return 1; } static int element_elem_object_func_getvar (struct element *e, const char *name, NCDValue *out_value) { struct instance *o = e->inst; ASSERT(e->state != ESTATE_FORGOTTEN) if (strcmp(name, "")) { return 0; } if (!NCDValue_InitCopy(out_value, e->value)) { ModuleLog(o->i, BLOG_ERROR, "NCDValue_InitCopy failed"); return 0; } return 1; } static void func_new (NCDModuleInst *i) { // allocate instance struct instance *o = malloc(sizeof(*o)); if (!o) { ModuleLog(i, BLOG_ERROR, "failed to allocate instance"); goto fail0; } NCDModuleInst_Backend_SetUser(i, o); // init arguments o->i = i; // read arguments NCDValue *arg_list; NCDValue *arg_template; NCDValue *arg_args; if (!NCDValue_ListRead(i->args, 3, &arg_list, &arg_template, &arg_args)) { ModuleLog(i, BLOG_ERROR, "wrong arity"); goto fail1; } if (NCDValue_Type(arg_list) != NCDVALUE_LIST || NCDValue_Type(arg_template) != NCDVALUE_STRING || NCDValue_Type(arg_args) != NCDVALUE_LIST ) { ModuleLog(i, BLOG_ERROR, "wrong type"); goto fail1; } o->template_name = NCDValue_StringValue(arg_template); o->args = arg_args; // init timer BTimer_Init(&o->timer, RETRY_TIME, (BTimer_handler)timer_handler, o); // count elements o->num_elems = NCDValue_ListCount(arg_list); // allocate elements if (!(o->elems = BAllocArray(o->num_elems, sizeof(o->elems[0])))) { ModuleLog(i, BLOG_ERROR, "BAllocArray failed"); goto fail1; } NCDValue *ev = NCDValue_ListFirst(arg_list); for (size_t i = 0; i < o->num_elems; i++) { struct element *e = &o->elems[i]; // set instance e->inst = o; // set index e->i = i; // set value e->value = ev; // set state forgotten e->state = ESTATE_FORGOTTEN; ev = NCDValue_ListNext(arg_list, ev); } // set GP and IP zero o->gp = 0; o->ip = 0; // set state working o->state = ISTATE_WORKING; work(o); return; fail1: free(o); fail0: NCDModuleInst_Backend_SetError(i); NCDModuleInst_Backend_Dead(i); } static void instance_free (struct instance *o) { NCDModuleInst *i = o->i; ASSERT(o->gp == 0) ASSERT(o->ip == 0) // free elements BFree(o->elems); // free timer BReactor_RemoveTimer(o->i->params->reactor, &o->timer); // free instance free(o); NCDModuleInst_Backend_Dead(i); } static void func_die (void *vo) { struct instance *o = vo; assert_state(o); ASSERT(o->state != ISTATE_TERMINATING) // set GP zero o->gp = 0; // set state terminating o->state = ISTATE_TERMINATING; work(o); return; } static void func_clean (void *vo) { struct instance *o = vo; if (o->state != ISTATE_WAITING) { return; } // set state working o->state = ISTATE_WORKING; work(o); return; } static const struct NCDModule modules[] = { { .type = "foreach", .func_new = func_new, .func_die = func_die, .func_clean = func_clean }, { .type = NULL } }; const struct NCDModuleGroup ncdmodule_foreach = { .modules = modules };
27.380597
142
0.598664
[ "model" ]
a478eaeaa68d6f5d1abef5cac8003d21adfd1151
347
h
C
engine-input/InputManager.h
geoffwhitehead/snooker-game
54c607bbfc31cfe2f6adbec488f408a6d49f1d8d
[ "MIT" ]
null
null
null
engine-input/InputManager.h
geoffwhitehead/snooker-game
54c607bbfc31cfe2f6adbec488f408a6d49f1d8d
[ "MIT" ]
null
null
null
engine-input/InputManager.h
geoffwhitehead/snooker-game
54c607bbfc31cfe2f6adbec488f408a6d49f1d8d
[ "MIT" ]
null
null
null
#pragma once #include "../engine-base/SubSystem.h" #include "../engine-base/SystemManager.h" #include <vector> using namespace std; class InputManager : public SystemManager { public: InputManager(); ~InputManager(); void update(float); void destroy(); void init(); void addSubSystem(SubSystem*); vector<SubSystem*> sub_systems; };
14.458333
41
0.717579
[ "vector" ]
a47967968a86c10546c59688105171f3bdf8491b
2,996
c
C
src/Time.c
javierherrer/reversi
a3f99340786d504b6f8c60704c51468a752f809a
[ "MIT" ]
null
null
null
src/Time.c
javierherrer/reversi
a3f99340786d504b6f8c60704c51468a752f809a
[ "MIT" ]
null
null
null
src/Time.c
javierherrer/reversi
a3f99340786d504b6f8c60704c51468a752f809a
[ "MIT" ]
null
null
null
/******************************************************************************/ /* This file is part of the uVision/ARM development tools */ /* Copyright KEIL ELEKTRONIK GmbH 2002-2004 */ /******************************************************************************/ /* */ /* TIME.C: Time Functions for 100Hz Clock Tick */ /* */ /******************************************************************************/ #include <LPC210X.H> // LPC21XX Peripheral Registers #include "Timer.h" #include "pulsacion.h" volatile long timeval0, timeval1; void tc0 (void) __irq; // Generate Interrupt void tc1 (void) __irq; // Generate Interrupt /* Setup the Timer Counter 0 Interrupt */ void init_timer0 (void) { // configuration of Timer 0 T0MR0 = 149999; // 10mSec = 150.000-1 counts T0MCR = 3; // Generates an interrupt and resets the count when the value of MR0 is reached T0TCR = 1; // Timer0 Enable // configuration of the IRQ slot number 0 of the VIC for Timer 0 Interrupt VICVectAddr0 = (unsigned long)tc0; // set interrupt vector in 0 // 0x20 bit 5 enables vectored IRQs. // 4 is the number of the interrupt assigned. Number 4 is the Timer 0 (see table 40 of the LPC2105 user manual VICVectCntl0 = 0x20 | 4; VICIntEnable = VICIntEnable | 0x00000010; // Enable Timer0 Interrupt } /* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */ void tc0 (void) __irq { timeval0++; T0IR = 1; // Clear interrupt flag VICVectAddr = 0; // Acknowledge Interrupt } /* Setup the Timer Counter 0 Interrupt */ void init_timer1 (void) { // configuration of Timer 0 T1MR0 = 14999; // 1mSec = 15.000-1 counts T1MCR = 5; // Generates an interrupt and stops the count when the value of MR1 is reached T1TCR = 1; // Timer1 Enable // configuration of the IRQ slot number 1 of the VIC for Timer 0 Interrupt VICVectAddr1 = (unsigned long)tc1; // set interrupt vector in 0 // 0x20 bit 5 enables vectored IRQs. // 5 is the number of the interrupt assigned. Number 5 is the Timer 1 (see table 40 of the LPC2105 user manual VICVectCntl1 = 0x20 | 5; VICIntEnable = VICIntEnable | 0x00000020; // Enable Timer0 Interrupt } /* Timer Counter 1 Interrupt executes each 1ms @ 60 MHz CPU Clock */ void tc1 (void) __irq { timeval1++; T1IR = 1; // Clear interrupt flag VICVectAddr = 0; // Acknowledge Interrupt }
47.555556
114
0.496328
[ "vector" ]
a47f479d2fffa03892cc5764ed384388a0839167
20,625
c
C
nitan/kungfu/skill/dugu-jiujian.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
1
2019-03-27T07:25:16.000Z
2019-03-27T07:25:16.000Z
nitan/kungfu/skill/dugu-jiujian.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
nitan/kungfu/skill/dugu-jiujian.c
cantona/NT6
073f4d491b3cfe6bfbe02fbad12db8983c1b9201
[ "MIT" ]
null
null
null
// This program is a part of NITAN MudLIB // dugu-jiujian.c 獨孤九劍 #include <ansi.h> #include <combat.h> inherit SKILL; string *parry_msg = ({ "卻見$n踏前一步,劍式斜指你的右臂,想要使$P閃身而退。\n", "$n以攻為守,以進為退,凝神運氣向$P猛攻快打地揮出方位大異的泰山「快活三」三劍。\n", "$n劍法突變,劍勢伸縮不定,奔騰矯夭,逆使嵩山劍法的「天外玉龍」企圖迫使$P變招。\n", "$n突然一劍點向$P的$l,雖一劍卻暗藏無數後着,$P手足無措,攻勢不由自主停了下來。\n" "$n不閃不避,舉劍閃電般使出「疊翠浮青」反削$P的$l,想擋過你此招。\n", "$n突然使出青城派松風劍法的「鴻飛冥冥」,長劍對着$P一絞,企圖突破$P的攻勢。\n" "$n挺劍一招象是「白雲出岫」回刺$P的$l,企圖將$P的攻勢化解。\n", "只見$n不退反進,身如飄風,一式「天柱雲氣」動向無定,擋住了$P的\n進攻。\n", "$n不退反進,使出恆山劍招「綿裏藏針」,森森劍氣充溢四周!架開了$P的這招\n", }); mapping *action = ({ ([ "action": HIW "但見$N挺身而上,$w" + HIW "一旋,一招彷彿泰山劍法的「來鶴清泉」直刺$n的$l" NOR, "attack": 70, "dodge" : 60, "parry" : 70, "damage": 120, "lvl" : 0, "damage_type" : "刺傷" ]), ([ "action": YEL "$N奇詭地向$n揮出「泉鳴芙蓉」、「鶴翔紫蓋」、「石廩書聲」、「天柱雲氣」及「雁回祝融」衡山五神劍" NOR, "attack": 71, "parry" : 72, "dodge" : 60, "damage": 120, "lvl" : 10, "damage_type" : "刺傷" ]), ([ "action": GRN "$N劍隨身轉,續而刺出十九劍,竟然是華山「玉女十九劍」,\n但奇的是這十九劍便如一招,手法之快,直是匪夷所思" NOR, "attack": 72, "dodge" : 64, "parry" : 78, "damage": 150, "lvl" : 20, "damage_type" : "刺傷" ]), ([ "action": BLU "$N劍勢忽緩而不疏,劍意有餘而不盡,化恆山劍法為一劍,向$n慢慢推去" NOR, "parry" : 73, "attack": 73, "dodge" : 65, "damage": 125, "lvl" : 30, "damage_type" : "刺傷" ]), ([ "action": HIR "$N劍意突煥氣象森嚴,便似千軍萬馬奔馳而來,長槍大戟,黃沙千里,盡括嵩山劍勢擊向$n的$l" NOR, "parry" : 74, "attack": 74, "dodge" : 68, "damage": 130, "lvl" : 40, "damage_type" : "刺傷" ]), ([ "action": CYN "卻見$N身隨劍走,左邊一拐,右邊一彎,劍招也是越轉越加狠辣,竟化「泰山十八盤」為一劍攻向$n" NOR, "attack": 75, "parry" : 75, "dodge" : 60, "damage": 120, "lvl" : 50, "damage_type" : "刺傷" ]), ([ "action": HIY "$N劍招突變,使出衡山的「一劍落九雁」,削向$n的$l" + HIY ",\n怎知劍到中途,突然轉向,大出$n意料之外" NOR, "attack": 76, "parry" : 76, "dodge" : 64, "damage": 120, "lvl" : 60, "damage_type" : "刺傷" ]), ([ "action": MAG "$N吐氣開聲,一招似是「獨劈華山」,手中$w" + MAG "向下斬落,直劈向$n的$l" NOR, "attack": 77, "dodge" : 67, "parry" : 77, "damage": 140, "lvl" : 70, "damage_type" : "刺傷" ]), ([ "action": HIB "$N手中$w" + HIB "越轉越快,使的居然是衡山的「百變千幻雲霧十三式」,\n劍式有如雲卷霧湧,旁觀者不由得目為之眩" NOR, "attack": 78, "dodge" : 60, "parry" : 78, "damage": 140, "lvl" : 80, "damage_type" : "刺傷" ]), ([ "action": HIM "$N滿場遊走,東刺一劍,西刺一劍,令$n莫明其妙,分不出$N劍法的虛實" NOR, "attack": 79, "dodge" : 65, "parry" : 79, "damage": 160, "lvl" : 90, "damage_type" : "刺傷" ]), ([ "action": HIC "$N抱劍旋身,轉到$n身後,雜亂無章地向$n刺出一劍,不知使的是什麼劍法" NOR, "attack": 80, "parry" : 80, "dodge" : 65, "damage": 160, "lvl" : 100, "damage_type" : "刺傷" ]), ([ "action": HIW "$N突然一劍點向$n的$l,雖一劍卻暗藏無數後着,$n手足無措,不知如何是好" NOR, "attack": 81, "parry" : 81, "dodge" : 66, "damage": 170, "lvl" : 110, "damage_type" : "刺傷" ]), ([ "action": RED "$N劍挾刀勢,大開大闔地亂砍一通,但招招皆擊在$n攻勢的破綻,迫得$n不得不守" NOR, "attack": 82, "dodge" : 71, "parry" : 82, "damage": 175, "lvl" : 120, "damage_type" : "刺傷" ]), ([ "action": YEL "$N反手橫劍刺向$n的$l,這似有招似無招的一劍,威力竟然奇大,$n難以看清劍招來勢" NOR, "attack": 83, "dodge" : 70, "parry" : 83, "damage": 180, "lvl" : 130, "damage_type" : "刺傷" ]), ([ "action": HIR "$N舉劍狂揮,迅速無比地點向$n的$l,卻令人看不出其所用是什麼招式" NOR, "attack": 84, "parry" : 84, "dodge" : 60, "damage": 170, "lvl" : 140, "damage_type" : "刺傷" ]), ([ "action": HIM "$N隨手一劍指向$n,落點正是$n的破綻所在,端的是神妙無倫,不可思議" NOR, "attack": 85, "parry" : 85, "dodge" : 64, "damage": 180, "lvl" : 150, "damage_type" : "刺傷" ]), ([ "action": CYN "$N臉上突現笑容,似乎已看破$n的武功招式,胸有成竹地一劍刺向$n的$l" NOR, "attack": 86, "dodge" : 60, "parry" : 86, "damage": 180, "lvl" : 160, "damage_type" : "刺傷" ]), ([ "action": RED "$N將$w"+ RED "隨手一擺,但見$n自己向$w"+ RED "撞將上來,神劍之威,實人所難測" NOR, "attack": 90, "dodge" : 70, "parry" : 90, "damage": 200, "lvl" : 170, "damage_type" : "刺傷" ]) }); mapping *action2 = ({ ([ "action" : HIW "但見$N手中$w破空長吟,平平一劍刺向$n,毫無招式可言" NOR, "force" : 300, "attack": 120, "dodge" : 120, "parry" : 120, "damage": 180, "damage_type" : "刺傷" ]), ([ "action" : HIW "$N揉身欺近,輕描淡寫間隨意刺出一劍,簡單之極,無招無式" NOR, "force" : 300, "attack": 130, "dodge" : 130, "parry" : 130, "damage": 190, "damage_type" : "刺傷" ]), ([ "action" : HIW "$N身法飄逸,神態怡然,劍意藏於胸中,手中$w隨意揮灑而出,獨孤" "九劍已到了收發自如的境界" NOR, "force" : 300, "attack": 140, "dodge" : 140, "parry" : 140, "damage": 200, "damage_type" : "刺傷" ]), }); int double_attack() { return 1; } int valid_enable(string usage) { return usage == "sword" || usage == "parry"; } int valid_learn(object me) { object ob; if( !(ob=query_temp("weapon", me) ) || query("skill_type", ob) != "sword" ) return notify_fail("你必須先找一把劍才能練劍法。\n"); if( query("int", me)<34 ) return notify_fail("你的天資不足,無法理解獨孤九劍的劍意。\n"); // if (me->query("dugu-jiujian/nothing") && if ( query("con", me)<26 ) return notify_fail("你先天根骨不足,無法理解獨孤九劍的劍意。\n"); if( query("character", me) == "心狠手辣" ) return notify_fail("你一心想殺盡敵人,沒能理解獨孤九劍的的真正含義。\n"); if( query("character", me) == "陰險奸詐" ) return notify_fail("你一心想怎麼學好劍法去害人,結果沒能理解獨孤九劍。\n"); if( query("character", me) == "光明磊落" ) return notify_fail("你心中暗道:什麼獨孤九劍,亂七八糟的,沒有半點氣勢。\n"); if (me->query_skill("sword", 1) < 100) return notify_fail("你的基本劍法造詣太淺,無法理解獨孤九劍。\n"); if (me->query_skill("sword", 1) < me->query_skill("dugu-jiujian", 1)) return notify_fail("你的基本劍法造詣有限,無法理解更高深的獨孤九劍。\n"); return 1; } mapping query_action(object me, object weapon) { int i, level; level = (int) me->query_skill("dugu-jiujian", 1); if( query("dugu-jiujian/nothing", me) ) return action2[random(sizeof(action2))]; if( objectp(weapon) && query("id", weapon) == "xuantiejian" ) { if (me->query_str() >= 60 && me->query_int() >= 36 && random(level) > 120 && me->query_skill("force")>150 && query("neili", me)>400 ) { addn("neili", -100, me); return ([ "action": HIR "$N臉色凝重虔誠,緩緩舉起玄鐵重劍,突然躍起身劍合一," "馭劍化為一道黑氣向$n衝刺而去" NOR, "damage": 400, "attack": 100, "dodge" : 80, "parry" : 80, "damage_type" : "刺傷" ]); } } for (i = sizeof(action); i > 0; i--) if (level > action[i - 1]["lvl"]) return action[NewRandom(i, 5, level / 5)]; } int practice_skill(object me) { return notify_fail("獨孤九劍只能通過「"+RED+"總訣式"+NOR+"」來演練。\n"); } string perform_action_file(string action) { return __DIR__"dugu-jiujian/" + action; } int query_effect_parry(object attacker, object me) { object weapon; int lvl; if( !objectp(weapon=query_temp("weapon", me)) || query("skill_type", weapon) != "sword" ) return 0; lvl = me->query_skill("dugu-jiujian", 1); if (lvl < 90) return 0; if (lvl < 100) return 50; if (lvl < 125) return 55; if (lvl < 150) return 60; if (lvl < 175) return 65; if (lvl < 200) return 70; if (lvl < 225) return 75; if (lvl < 250) return 80; if (lvl < 275) return 90; if (lvl < 325) return 100; if (lvl < 350) return 110; return 120; } void skill_improved(object me) { int lvl, i; i=query("int", me)/3; lvl = me->query_skill("dugu-jiujian", 1); if (lvl > 120 && query("can_perform/dugu/qi", me) <= 100 ) { if( me->add("can_perform/dugu/qi",random(i))<100 ) { tell_object(me, HIC "你對獨孤九劍「" HIW "破氣式" HIC "」有了新的領悟。\n" NOR); } else { tell_object(me, HIC "你通曉了獨孤九劍「" HIW "破" "氣式" HIC "」的奧祕。\n" NOR); me->improve_skill("martial-cognize", 1500000); me->improve_skill("martial-cognize", 1500000); me->improve_skill("martial-cognize", 1500000); } } if (lvl > 150 && query("can_perform/dugu/po", me) <= 100 ) { if( me->add("can_perform/dugu/po",random(i))<100 ) { tell_object(me, HIC "你對獨孤九劍「" HIR "總破式" HIC "」有了新的領悟。\n" NOR); } else { tell_object(me, HIC "你通曉了獨孤九劍「" HIR "總" "破式" HIC "」的奧祕。\n" NOR); me->improve_skill("martial-cognize", 1500000); me->improve_skill("martial-cognize", 1500000); me->improve_skill("martial-cognize", 1500000); } } if (lvl > 200 && query("can_perform/dugu/yi", me) <= 100 ) { if( me->add("can_perform/dugu/yi",random(i))<100 ) { tell_object(me, HIC "你對獨孤九劍「" HIR "劍意" HIC "」有了新的領悟。\n" NOR); } else { tell_object(me, HIC "你通曉了獨孤九劍「" HIR "劍" "意" HIC "」的奧祕。\n" NOR); me->improve_skill("martial-cognize", 1500000); me->improve_skill("martial-cognize", 1500000); me->improve_skill("martial-cognize", 1500000); } } } int difficult_level() { object me = this_object(); if( query("dugu-jiujian/nothing", me) ) return 300; else return 200; } mixed valid_damage(object ob, object me, int damage, object weapon) { mixed result; int ap, dp, mp; object m_weapon; if ((int) me->query_skill("dugu-jiujian", 1) < 120 || !(m_weapon=query_temp("weapon", me) ) || ! living(me) || query("skill_type", m_weapon) != "sword" ) return; mp = ob->query_skill("count", 1); ap = ob->query_skill("parry") + mp; dp = me->query_skill("parry", 1) / 2 + me->query_skill("dugu-jiujian", 1); // 無招 if( query("dugu-jiujian/nothing", me) ) { if (me->query_skill("sword") * 2 / 3 + random(me->query_skill("sword")) > ob->query_skill("parry")) { result = ([ "damage": -damage ]); result += (["msg" : HIC "$n" HIC "突然舉劍一刺,劍招隨意無章," "卻莫明奇妙地突破了$N的攻勢,大出$N意料。\n" "$n一轉劍勢,劍招源源而出,對$N發動攻勢!\n" NOR]); COMBAT_D->do_attack(me,ob,query_temp("weapon", me)); COMBAT_D->do_attack(me,ob,query_temp("weapon", me)); COMBAT_D->do_attack(me,ob,query_temp("weapon", me)); if (! ob->is_busy()) ob->start_busy(1 + random(2)); return result; } } if (ap / 2 + random(ap) < dp) { result = ([ "damage": -damage ]); switch (random(6)) { case 0: result += (["msg" : HIC "$n" HIC "突然舉劍一刺,劍招隨意無章," "卻莫明奇妙地突破了$N的攻勢,大出$N意料。\n" "$n一轉劍勢,劍招源源而出,對$N發動攻勢!\n" NOR]); COMBAT_D->do_attack(me,ob,query_temp("weapon", me)); COMBAT_D->do_attack(me,ob,query_temp("weapon", me)); COMBAT_D->do_attack(me,ob,query_temp("weapon", me)); break; case 1: result += (["msg" : HIC "$n" HIC "舉劍反攻,後發先至地刺向$N,不僅把" "$N招術封死,更進一步發出攻擊!\n" NOR]); COMBAT_D->do_attack(me,ob,query_temp("weapon", me)); break; case 2: result += (["msg" : HIC "$n" HIC "提劍回刺,落點正是$N的破綻," "$N不得不撤招嚴守,身形一晃間已退出丈許!\n" NOR]); break; case 3: result += (["msg" : HIC "卻見$n" HIC "踏前一步,劍式斜指$P" HIC "右臂,招式迅捷無比,使得$N" HIC "閃身而退" "。\n" NOR]); break; case 4: result += (["msg" : HIC "$n" HIC "突然一劍點向$N" HIC ",雖一劍" "卻暗藏無數後着,$N" HIC "頓時手足無措,攻" "勢不由自主停了下來。\n" NOR]); break; default: result += (["msg" : HIC "$n" HIC "眼見避無可避,只好提劍亂刺一通," "居然出乎意料地將$N的攻擊接去。\n" NOR]); break; } return result; } else if (mp >= 100) { switch (random(3)) { case 0: result = HIY "$n" HIY "一抖手中的" + m_weapon->name() + HIY ",中攻直進一劍挺進,可是$N" HIY "反招更快" ",進襲$n" HIY "!\n" NOR; break; case 1: result = HIY "$n" HIY "手中" + m_weapon->name() + "輕挑" "," HIY "正指向$N" HIY "攻勢中的破綻,可是$N" HIY "身形一變,破綻立刻不成為破綻。\n" NOR; break; default: result = HIY "$n" HIY "手中" + m_weapon->name() + HIY "續變換數種劍招,然而$N" HIY "理也不理,再次攻" "出,絲毫不受$n" HIY "的迷惑。\n" NOR; break; } COMBAT_D->set_bhinfo(result); } } mixed hit_ob(object me, object victim, int damage_bonus) { mixed result; int lvl; object weapon, weapon2; int i, ap, dpp, dpd, dpf; string type, msg, msg1; lvl = me->query_skill("dugu-jiujian", 1); if( query("neili", me)<300 || me->query_skill_mapped("sword") != "dugu-jiujian" || !objectp(weapon=query_temp("weapon", me) ) || query("skill_type", weapon) != "sword" || !query("dugu-jiujian/nothing", me) ) return 0; ap = me->query_skill("sword"); dpp = victim->query_skill("parry"); dpd = victim->query_skill("dodge"); dpf = victim->query_skill("force"); switch(random(3)) { case 1: if (ap * 3 / 4 + random(ap) > dpp) { addn("neili", -100, me); result = ([ "damage" : damage_bonus / 2 ]); msg1 = random(2) ? HIR "$N" HIR "一劍攻出,劍氣橫飛," + weapon->name() + HIR "時若游龍穿空,時若驚鴻渡雲,卻不知這普通的" "一劍之中竟藴藏着如此威力。\n" NOR: HIR "$N" HIR "手中" + weapon->name() + HIR "猶" "如生了眼睛一般,一劍隨意揮出,竟直刺向$n" HIR "小腹,看似平淡,但方位、力道卻拿捏得恰倒好處。\n" NOR; result += ([ "msg" : msg1 ]); return result; } break; case 2: message_vision(HIC "\n$N" HIC "隨意揮灑手中的" + weapon->name() + HIC ",招招從出其不意的方位直指$n" HIC "招式中的" "破綻!\n" NOR, me, victim); if (! me->is_busy()) { weapon=query_temp("weapon", me); weapon2=query_temp("weapon", victim); if( weapon2)type=query("skill_type", weapon2); if (ap * 3 / 4 + random(ap) >= dpf && weapon2 && type != "pin") { msg = HIW "$n" HIW "覺得眼前眼花繚亂,手中" "的" + weapon2->name() + HIW "一時竟" "然拿捏不住,脱手而出!\n" NOR; weapon2->move(environment(me)); addn("neili", -100, me); } else { msg = HIY "$n" HIY "略得空隙喘息,一時間卻" "也無力反擊。\n" NOR; addn("neili", -40, me); } }else if (ap * 4 / 5 + random(ap) > dpd) { msg = HIY "$n" HIY "連忙抵擋,一時間不禁手忙腳亂," "無暇反擊。\n" NOR; if (! victim->is_busy()) victim->start_busy(1 + random(lvl / 30)); } else { msg = HIC "$N" HIC "隨意揮灑着手中的" + weapon->name() + HIC "刺向$n" HIC ",不過$n" HIC "防守的異常嚴密,$N" HIC "一時竟然無法找到破綻。\n" NOR; if (! victim->is_busy()) victim->start_busy(1); } message_combatd(msg, me, victim); break; default : if (ap * 2 / 3 + random(ap) > dpd && ! me->is_busy() && !query_temp("dugu-jiujian/lian", me) ) { weapon=query_temp("weapon", me); message_sort(HIY "\n$N" HIY "胸藏劍意,手中" + weapon->name() + HIY "隨意揮灑而出,速度之快,方位之準,顯是獨孤九劍已達到" "收發自如的境界。\n" NOR, me, victim); addn("neili", -270, me); set_temp("dugu-jiujian/lian", 1, me); for (i = 0; i < 5; i++) { if (! me->is_fighting(victim)) break; if (! victim->is_busy() && random(2) == 1) victim->start_busy(1); COMBAT_D->do_attack(me, victim, weapon, 0); } delete_temp("dugu-jiujian/lian", me); } break; } }
34.663866
92
0.38497
[ "object" ]
a4804c3f1233b5871d35e538918c00a9215d4cbb
42,561
h
C
clicks/proxfusion3/lib/include/proxfusion3.h
StrahinjaJacimovic/mikrosdk_click_v2
f8002047c96605f340957a0d3fdbde33706d02ac
[ "MIT" ]
31
2020-10-02T14:15:14.000Z
2022-03-24T08:33:21.000Z
clicks/proxfusion3/lib/include/proxfusion3.h
greghol/mikrosdk_click_v2
76e5dec265dce5fca72c4b93f77afd668dde5dfa
[ "MIT" ]
4
2020-10-27T14:05:00.000Z
2022-03-10T09:38:57.000Z
clicks/proxfusion3/lib/include/proxfusion3.h
greghol/mikrosdk_click_v2
76e5dec265dce5fca72c4b93f77afd668dde5dfa
[ "MIT" ]
32
2020-11-28T07:56:42.000Z
2022-03-14T19:42:29.000Z
/**************************************************************************** ** Copyright (C) 2020 MikroElektronika d.o.o. ** Contact: https://www.mikroe.com/contact ** ** 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. ****************************************************************************/ /*! * @file proxfusion3.h * @brief This file contains API for ProxFusion 3 Click Driver. */ #ifndef PROXFUSION3_H #define PROXFUSION3_H #ifdef __cplusplus extern "C"{ #endif #include "drv_digital_out.h" #include "drv_digital_in.h" #include "drv_i2c_master.h" /*! * @addtogroup proxfusion3 ProxFusion 3 Click Driver * @brief API for configuring and manipulating ProxFusion 3 Click driver. * @{ */ /** * @defgroup proxfusion3_reg ProxFusion 3 Registers List * @brief List of registers of ProxFusion 3 Click driver. */ /** * @addtogroup proxfusion3_reg * @{ */ /** * @brief ProxFusion 3 description register. * @details Specified register for description of ProxFusion 3 Click driver. */ /** * @brief ProxFusion 3 Device Information register. * @details Specified register for Device Information of ProxFusion 3 Click driver. */ #define PROXFUSION3_DEVICE_INFO 0x00 /** * @brief ProxFusion 3 Flags register. * @details Specified register for Flags of ProxFusion 3 Click driver. */ #define PROXFUSION3_SYS_FLAGS 0x02 /** * @brief ProxFusion 3 Slider flags register. * @details Specified register for Slider flags of ProxFusion 3 Click driver. */ #define PROXFUSION3_GESTURE_FLAGS 0x03 /** * @brief ProxFusion 3 Channel Prox and Touch Flags register. * @details Specified register for Channel Prox and Touch Flags of ProxFusion 3 Click driver. */ #define PROXFUSION3_CH_PROX_STATE 0x04 #define PROXFUSION3_CH_TOUCH_STATE 0x05 /** * @brief ProxFusion 3 Channel Counts Bytes register. * @details Specified register for Channel Counts Bytes of ProxFusion 3 Click driver. */ #define PROXFUSION3_ACF_CH0 0x08 #define PROXFUSION3_ACF_CH1 0x0A #define PROXFUSION3_ACF_CH2 0x0C #define PROXFUSION3_ACF_CH3 0x0E #define PROXFUSION3_ACF_CH4 0x10 #define PROXFUSION3_ACF_CH5 0x12 #define PROXFUSION3_ACF_CH6 0x14 #define PROXFUSION3_ACF_CH7 0x16 /** * @brief ProxFusion 3 Channel LTA Bytes register. * @details Specified register for Channel LTA Bytes of ProxFusion 3 Click driver. */ #define PROXFUSION3_LTA_CH0 0x09 #define PROXFUSION3_LTA_CH1 0x0B #define PROXFUSION3_LTA_CH2 0x0D #define PROXFUSION3_LTA_CH3 0x0F #define PROXFUSION3_LTA_CH4 0x11 #define PROXFUSION3_LTA_CH5 0x13 #define PROXFUSION3_LTA_CH6 0x15 #define PROXFUSION3_LTA_CH7 0x17 /** * @brief ProxFusion 3 Channel Delta Bytes register. * @details Specified register for Channel Delta Bytes of ProxFusion 3 Click driver. */ #define PROXFUSION3_DELTA_CH0 0x18 #define PROXFUSION3_DELTA_CH1 0x19 #define PROXFUSION3_DELTA_CH2 0x1A #define PROXFUSION3_DELTA_CH3 0x1B #define PROXFUSION3_DELTA_CH4 0x1C #define PROXFUSION3_DELTA_CH5 0x1D #define PROXFUSION3_DELTA_CH6 0x1E #define PROXFUSION3_DELTA_CH7 0x1F /** * @brief ProxFusion 3 Reference Channel Delta Bytes register. * @details Specified register for Reference Channel Delta Bytes of ProxFusion 3 Click driver. */ #define PROXFUSION3_REFDELTA_CH0 0x20 #define PROXFUSION3_REFDELTA_CH1 0x21 #define PROXFUSION3_REFDELTA_CH2 0x22 #define PROXFUSION3_REFDELTA_CH3 0x23 #define PROXFUSION3_REFDELTA_CH4 0x24 #define PROXFUSION3_REFDELTA_CH5 0x25 #define PROXFUSION3_REFDELTA_CH6 0x26 #define PROXFUSION3_REFDELTA_CH7 0x27 /** * @brief ProxFusion 3 Slider coordinates register. * @details Specified register for Reference Channel Delta Bytes of ProxFusion 3 Click driver. */ #define PROXFUSION3_COORDINATES 0x30 /** * @brief ProxFusion 3 Capacitance Measurement Variables register. * @details Specified register for Capacitance Measurement Variables of ProxFusion 3 Click driver. */ #define PROXFUSION3_CAP_ABS_BASE 0x31 #define PROXFUSION3_CAP_ABS_CS 0x32 #define PROXFUSION3_CAP_ABS_CS_CAP0 0x33 #define PROXFUSION3_CAP_ABS_CS_CAP1 0x34 /** * @brief ProxFusion 3 Power mode settings Bytes register. * @details Specified register for Power mode settings Bytes of ProxFusion 3 Click driver. */ #define PROXFUSION3_PMU_SETTINGS 0x80 #define PROXFUSION3_ACTIVE_CHANNELS 0x81 #define PROXFUSION3_CH_RESEED 0x82 /** * @brief ProxFusion 3 Report Rate Bytes register. * @details Specified register for Report Rate Bytes of ProxFusion 3 Click driver. */ #define PROXFUSION3_REPORT_RATES 0x83 #define PROXFUSION3_ULP_MODE_RATES 0x84 #define PROXFUSION3_TIMEOUT_PERIODS 0x85 /** * @brief ProxFusion 3 General Settings register. * @details Specified register for General Settings of ProxFusion 3 Click driver. */ #define PROXFUSION3_GEN_SETINGS 0x86 #define PROXFUSION3_REF_SETTINGS 0x87 #define PROXFUSION3_EVENT_SETTINGS 0x88 /** * @brief ProxFusion 3 Gesture Settings register. * @details Specified register for Gesture Settings of ProxFusion 3 Click driver. */ #define PROXFUSION3_SLIDER0_CH 0x89 #define PROXFUSION3_TAP_SETTINGS 0x8A #define PROXFUSION3_SWIPE_SETTINGS 0x8B /** * @brief ProxFusion 3 Channel settings register. * @details Specified register for Channel settings of ProxFusion 3 Click driver. */ #define PROXFUSION3_CH0_SETTINGS 0x8C #define PROXFUSION3_CH1_SETTINGS 0x93 #define PROXFUSION3_CH3_SETTINGS 0x9A #define PROXFUSION3_CH4_SETTINGS 0xA1 #define PROXFUSION3_CH5_SETTINGS 0xA8 #define PROXFUSION3_CH6_SETTINGS 0xAF #define PROXFUSION3_CH7_SETTINGS 0xB6 #define PROXFUSION3_CH8_SETTINGS 0xBD #define PROXFUSION3_CHx_REF_ASSOC 0x92 #define PROXFUSION3_CH6_PROX_SETTINGS 0xB7 #define PROXFUSION3_CH6_ATI_MIRROR 0xB9 #define PROXFUSION3_CH7_ATI_MIRROR 0xC0 #define PROXFUSION3_ATI_TARGETS 0x8E /** * @brief ProxFusion 3 Engineering settings register. * @details Specified register for Engineering settings of ProxFusion 3 Click driver. */ #define PROXFUSION3_ENG_DIRECT_ADDRESS 0xF0 #define PROXFUSION3_ENG_DIRECT_DATA 0xF1 #define PROXFUSION3_ENG_I2C_SETTINGS 0xF2 #define PROXFUSION3_ENG_LAST_CONV_LSB 0xF3 #define PROXFUSION3_ENG_LAST_CONV_MSB 0xF4 #define PROXFUSION3_ENG_PXS_DETECTION 0xF5 /*! @} */ // proxfusion3_reg /** * @defgroup proxfusion3_set ProxFusion 3 Registers Settings * @brief Settings for registers of ProxFusion 3 Click driver. */ /** * @addtogroup proxfusion3_set * @{ */ /** * @brief ProxFusion 3 description setting. * @details Specified setting for description of ProxFusion 3 Click driver. */ #define PROXFUSION3_PRODUCT_NUM 0x4F #define PROXFUSION3_SW_NUM_V1 0x02 #define PROXFUSION3_SW_NUM_V2 0x03 /** * @brief ProxFusion 3 System Flags Byte Bits setting. * @details Specified setting for System Flags Byte Bits of ProxFusion 3 Click driver. */ #define PROXFUSION3_NP_SEG_ACTIVE_BIT 0x01 #define PROXFUSION3_GO_TO_NP_BIT 0x02 #define PROXFUSION3_IN_ATI_BIT 0x04 #define PROXFUSION3_NP_MODE_BITS 0x00 #define PROXFUSION3_LP_MODE_BITS 0x08 #define PROXFUSION3_ULP_MODE_BITS 0x10 #define PROXFUSION3_HALT_MODE_BITS 0x18 #define PROXFUSION3_SHOW_RESET_BIT 0x80 /** * @brief ProxFusion 3 Event Byte Bits setting. * @details Specified setting for Event Byte Bits of ProxFusion 3 Click driver. */ #define PROXFUSION3_PROX_EVENT_BIT 0x01 #define PROXFUSION3_TOUCH_EVENT_BIT 0x02 #define PROXFUSION3_DEEP_EVENT_BIT 0x04 #define PROXFUSION3_GESTURE_EVENT_BIT 0x08 #define PROXFUSION3_MOV_EVENT_BIT 0x10 #define PROXFUSION3_REF_EVENT_BIT 0x20 #define PROXFUSION3_SYS_EVENT_BIT 0x40 #define PROXFUSION3_LP_EVENT_BIT 0x80 /** * @brief ProxFusion 3 Gesture Byte Bits setting. * @details Specified setting for Gesture Byte Bits of ProxFusion 3 Click driver. */ #define PROXFUSION3_TAP0_BIT 0x01 #define PROXFUSION3_HOLD0_BIT 0x02 #define PROXFUSION3_SWIPE_UP_BIT 0x04 #define PROXFUSION3_SWIPE_DOWN_BIT 0x08 #define PROXFUSION3_TAP1_BIT 0x10 #define PROXFUSION3_HOLD1_BIT 0x20 #define PROXFUSION3_SWIPE_LEFT_BIT 0x40 #define PROXFUSION3_SWIPE_RIGHT_BIT 0x80 /** * @brief ProxFusion 3 Utility Bits setting. * @details Specified setting for Utility Bits of ProxFusion 3 Click driver. */ #define PROXFUSION3_ACK_RESET_BIT 0x01 #define PROXFUSION3_SOFT_RESET_BIT 0x02 #define PROXFUSION3_REDO_ATI_BIT 0x04 #define PROXFUSION3_EVENT_MODE_BIT 0x20 /** * @brief ProxFusion 3 Setting Bits setting. * @details Specified setting for Setting Bits of ProxFusion 3 Click driver. */ #define PROXFUSION3_DISABLE_CH6_ATI 0xA0 #define PROXFUSION3_ENABLE_ABSCAP_UI 0x08 #define PROXFUSION3_ENABLE_4MHZ_FOSC 0x80 #define PROXFUSION3_DISABLE_AUTO_MODE 0x20 /** * @brief ProxFusion 3 Channel select, Power mode & System setting. * @details Specified setting for the Channel select, Power mode & System Settings * of ProxFusion 3 Click driver. */ #define PROXFUSION3_PMU_GENERAL_SETTINGS 0x41 #define PROXFUSION3_I2C_GENERAL_SETTINGS 0x00 #define PROXFUSION3_SYS_CHB_ACTIVE 0xFF #define PROXFUSION3_ACF_LTA_FILTER_SETTINGS 0xC4 #define PROXFUSION3_LTA_CHB_RESEED_ENABLED 0xFF #define PROXFUSION3_UIS_GLOBAL_EVENTS_MASK 0x00 /** * @brief ProxFusion 3 Report Rates and Timing setting. * @details Specified setting for the Report Rates and Timing * of ProxFusion 3 Click driver. */ #define PROXFUSION3_PMU_REPORT_RATE_NP 0x10 #define PROXFUSION3_PMU_REPORT_RATE_LP 0xA0 #define PROXFUSION3_PMU_REPORT_RATE_ULP 0x0D #define PROXFUSION3_PMU_MODE_TIMOUT 0x0A #define PROXFUSION3_I2C_WINDOW_TIMEOUT 0x14 #define PROXFUSION3_LTA_HALT_TIMEOUT 0x14 /** * @brief ProxFusion 3 Global setting. * @details Specified setting for the Global Settings * of ProxFusion 3 Click driver. */ #define PROXFUSION3_PXS_GENERAL_SETTINGS0 0x00 #define PROXFUSION3_PXS_GENERAL_SETTINGS1 0x00 #define PROXFUSION3_UIS_ABSOLUTE_CAPACITANCE 0x00 #define PROXFUSION3_UIS_DCF_GENERAL_SETTINGS 0x11 #define PROXFUSION3_GEM_CHB_BLOCK_NFOLLOW 0x00 #define PROXFUSION3_MOV_CHB_MOVEMENT_CHANNEL 0x00 #define PROXFUSION3_UIS_CHB_SLIDER0 0x78 #define PROXFUSION3_UIS_CHB_SLIDER1 0x06 #define PROXFUSION3_UIS_GESTURE_TAP_TIMEOUT 0x40 #define PROXFUSION3_UIS_GESTURE_SWIPE_TIMEOUT 0xBB #define PROXFUSION3_UIS_GESTURE_THRESHOLD 0x80 #define PROXFUSION3_LTA_CHB_RESEED 0x00 /** * @brief ProxFusion 3 CH0 Settings setting. * @details Specified setting for the CH0 Settings * of ProxFusion 3 Click driver. */ #define PROXFUSION3_PXS_CRXSEL_CH0 0xFF #define PROXFUSION3_PXS_CTXSEL_CH0 0xFF #define PROXFUSION3_PXS_PROXCTRL_CH0 0xA3 #define PROXFUSION3_PXS_PROXCFG0_CH0 0x40 #define PROXFUSION3_PXS_PROXCFG1_TESTREG0_CH0 0x06 #define PROXFUSION3_ATI_BASE_AND_TARGET_CH0 0x90 #define PROXFUSION3_ATI_MIRROR_CH0 0x2C #define PROXFUSION3_ATI_PCC_CH0 0xCD #define PROXFUSION3_PXS_PROX_THRESHOLD_CH0 0x04 #define PROXFUSION3_PXS_TOUCH_THRESHOLD_CH0 0x09 #define PROXFUSION3_PXS_DEEP_THRESHOLD_CH0 0x10 #define PROXFUSION3_PXS_HYSTERESIS_CH0 0x04 #define PROXFUSION3_DCF_CHB_ASSOCIATION_CH0 0x00 #define PROXFUSION3_DCF_WEIGHT_CH0 0x00 /** * @brief ProxFusion 3 CH1 Settings setting. * @details Specified setting for the CH1 Settings * of ProxFusion 3 Click driver. */ #define PROXFUSION3_PXS_CRXSEL_CH1 0x3A #define PROXFUSION3_PXS_CTXSEL_CH1 0xFF #define PROXFUSION3_PXS_PROXCTRL_CH1 0xA3 #define PROXFUSION3_PXS_PROXCFG0_CH1 0x40 #define PROXFUSION3_PXS_PROXCFG1_TESTREG0_CH1 0x06 #define PROXFUSION3_ATI_BASE_AND_TARGET_CH1 0x90 #define PROXFUSION3_ATI_MIRROR_CH1 0x29 #define PROXFUSION3_ATI_PCC_CH1 0xC6 #define PROXFUSION3_PXS_PROX_THRESHOLD_CH1 0x04 #define PROXFUSION3_PXS_TOUCH_THRESHOLD_CH1 0x09 #define PROXFUSION3_PXS_DEEP_THRESHOLD_CH1 0x10 #define PROXFUSION3_PXS_HYSTERESIS_CH1 0x04 #define PROXFUSION3_DCF_CHB_ASSOCIATION_CH1 0x00 #define PROXFUSION3_DCF_WEIGHT_CH1 0x00 /** * @brief ProxFusion 3 CH2 Settings setting. * @details Specified setting for the CH2 Settings * of ProxFusion 3 Click driver. */ #define PROXFUSION3_PXS_CRXSEL_CH2 0xC5 #define PROXFUSION3_PXS_CTXSEL_CH2 0xFF #define PROXFUSION3_PXS_PROXCTRL_CH2 0xA3 #define PROXFUSION3_PXS_PROXCFG0_CH2 0x40 #define PROXFUSION3_PXS_PROXCFG1_TESTREG0_CH2 0x06 #define PROXFUSION3_ATI_BASE_AND_TARGET_CH2 0x90 #define PROXFUSION3_ATI_MIRROR_CH2 0x29 #define PROXFUSION3_ATI_PCC_CH2 0xC0 #define PROXFUSION3_PXS_PROX_THRESHOLD_CH2 0x04 #define PROXFUSION3_PXS_TOUCH_THRESHOLD_CH2 0x09 #define PROXFUSION3_PXS_DEEP_THRESHOLD_CH2 0x10 #define PROXFUSION3_PXS_HYSTERESIS_CH2 0x04 #define PROXFUSION3_DCF_CHB_ASSOCIATION_CH2 0x00 #define PROXFUSION3_DCF_WEIGHT_CH2 0x00 /** * @brief ProxFusion 3 CH3 Settings setting. * @details Specified setting for the CH3 Settings * of ProxFusion 3 Click driver. */ #define PROXFUSION3_PXS_CRXSEL_CH3 0x90 #define PROXFUSION3_PXS_CTXSEL_CH3 0xFF #define PROXFUSION3_PXS_PROXCTRL_CH3 0xA3 #define PROXFUSION3_PXS_PROXCFG0_CH3 0x40 #define PROXFUSION3_PXS_PROXCFG1_TESTREG0_CH3 0x06 #define PROXFUSION3_ATI_BASE_AND_TARGET_CH3 0x90 #define PROXFUSION3_ATI_MIRROR_CH3 0x1E #define PROXFUSION3_ATI_PCC_CH3 0xC8 #define PROXFUSION3_PXS_PROX_THRESHOLD_CH3 0x0A #define PROXFUSION3_PXS_TOUCH_THRESHOLD_CH3 0x10 #define PROXFUSION3_PXS_DEEP_THRESHOLD_CH3 0x30 #define PROXFUSION3_PXS_HYSTERESIS_CH3 0x04 #define PROXFUSION3_DCF_CHB_ASSOCIATION_CH3 0x00 #define PROXFUSION3_DCF_WEIGHT_CH3 0x00 /** * @brief ProxFusion 3 CH4 Settings setting. * @details Specified setting for the CH4 Settings * of ProxFusion 3 Click driver. */ #define PROXFUSION3_PXS_CRXSEL_CH4 0x42 #define PROXFUSION3_PXS_CTXSEL_CH4 0xFF #define PROXFUSION3_PXS_PROXCTRL_CH4 0xA3 #define PROXFUSION3_PXS_PROXCFG0_CH4 0x40 #define PROXFUSION3_PXS_PROXCFG1_TESTREG0_CH4 0x06 #define PROXFUSION3_ATI_BASE_AND_TARGET_CH4 0x90 #define PROXFUSION3_ATI_MIRROR_CH4 0x1E #define PROXFUSION3_ATI_PCC_CH4 0xCA #define PROXFUSION3_PXS_PROX_THRESHOLD_CH4 0x0A #define PROXFUSION3_PXS_TOUCH_THRESHOLD_CH4 0x10 #define PROXFUSION3_PXS_DEEP_THRESHOLD_CH4 0x30 #define PROXFUSION3_PXS_HYSTERESIS_CH4 0x04 #define PROXFUSION3_DCF_CHB_ASSOCIATION_CH4 0x00 #define PROXFUSION3_DCF_WEIGHT_CH4 0x00 /** * @brief ProxFusion 3 CH5 Settings setting. * @details Specified setting for the CH5 Settings * of ProxFusion 3 Click driver. */ #define PROXFUSION3_PXS_CRXSEL_CH5 0x21 #define PROXFUSION3_PXS_CTXSEL_CH5 0xFF #define PROXFUSION3_PXS_PROXCTRL_CH5 0xA3 #define PROXFUSION3_PXS_PROXCFG0_CH5 0x40 #define PROXFUSION3_PXS_PROXCFG1_TESTREG0_CH5 0x06 #define PROXFUSION3_ATI_BASE_AND_TARGET_CH5 0x90 #define PROXFUSION3_ATI_MIRROR_CH5 0x1E #define PROXFUSION3_ATI_PCC_CH5 0xD0 #define PROXFUSION3_PXS_PROX_THRESHOLD_CH5 0x0A #define PROXFUSION3_PXS_TOUCH_THRESHOLD_CH5 0x10 #define PROXFUSION3_PXS_DEEP_THRESHOLD_CH5 0x30 #define PROXFUSION3_PXS_HYSTERESIS_CH5 0x04 #define PROXFUSION3_DCF_CHB_ASSOCIATION_CH5 0x00 #define PROXFUSION3_DCF_WEIGHT_CH5 0x00 /** * @brief ProxFusion 3 CH6 Settings setting. * @details Specified setting for the CH6 Settings * of ProxFusion 3 Click driver. */ #define PROXFUSION3_PXS_CRXSEL_CH6 0x0C #define PROXFUSION3_PXS_CTXSEL_CH6 0xFF #define PROXFUSION3_PXS_PROXCTRL_CH6 0xA3 #define PROXFUSION3_PXS_PROXCFG0_CH6 0x40 #define PROXFUSION3_PXS_PROXCFG1_TESTREG0_CH6 0x06 #define PROXFUSION3_ATI_BASE_AND_TARGET_CH6 0x90 #define PROXFUSION3_ATI_MIRROR_CH6 0x26 #define PROXFUSION3_ATI_PCC_CH6 0xCB #define PROXFUSION3_PXS_PROX_THRESHOLD_CH6 0x0A #define PROXFUSION3_PXS_TOUCH_THRESHOLD_CH6 0x10 #define PROXFUSION3_PXS_DEEP_THRESHOLD_CH6 0x30 #define PROXFUSION3_PXS_HYSTERESIS_CH6 0x04 #define PROXFUSION3_DCF_CHB_ASSOCIATION_CH6 0x00 #define PROXFUSION3_DCF_WEIGHT_CH6 0x00 /** * @brief ProxFusion 3 CH7 Settings setting. * @details Specified setting for the CH7 Settings * of ProxFusion 3 Click driver. */ #define PROXFUSION3_PXS_CRXSEL_CH7 0x01 #define PROXFUSION3_PXS_CTXSEL_CH7 0xFF #define PROXFUSION3_PXS_PROXCTRL_CH7 0xA3 #define PROXFUSION3_PXS_PROXCFG0_CH7 0xDE #define PROXFUSION3_PXS_PROXCFG1_TESTREG0_CH7 0x01 #define PROXFUSION3_ATI_BASE_AND_TARGET_CH7 0xD0 #define PROXFUSION3_ATI_MIRROR_CH7 0x57 #define PROXFUSION3_ATI_PCC_CH7 0x60 #define PROXFUSION3_PXS_PROX_THRESHOLD_CH7 0x0A #define PROXFUSION3_PXS_TOUCH_THRESHOLD_CH7 0x08 #define PROXFUSION3_PXS_DEEP_THRESHOLD_CH7 0x1A #define PROXFUSION3_PXS_HYSTERESIS_CH7 0x04 #define PROXFUSION3_DCF_CHB_ASSOCIATION_CH7 0x00 #define PROXFUSION3_DCF_WEIGHT_CH7 0x00 // /** * @brief ProxFusion 3 CRX selection for Channels setting. * @details Specified setting for the CRX selection for Channels * of ProxFusion 3 Click driver. */ #define PROXFUSION3_CH0_CRX 0x8C #define PROXFUSION3_CH1_CRX 0x93 #define PROXFUSION3_CH2_CRX 0x9A #define PROXFUSION3_CH3_CRX 0xA1 #define PROXFUSION3_CH4_CRX 0xA8 #define PROXFUSION3_CH5_CRX 0xAF #define PROXFUSION3_CH6_CRX 0xB6 #define PROXFUSION3_CH7_CRX 0xBD /** * @brief ProxFusion 3 touch number data. * @details Specified touch number data of ProxFusion 3 Click driver. */ #define PROXFUSION3_TOUCH_NUMB_1 0x13 #define PROXFUSION3_TOUCH_NUMB_2 0x27 #define PROXFUSION3_TOUCH_NUMB_3 0x4E #define PROXFUSION3_TOUCH_NUMB_4 0x0C #define PROXFUSION3_TOUCH_NUMB_5 0x30 #define PROXFUSION3_TOUCH_NUMB_6 0x70 #define PROXFUSION3_TOUCH_NUMB_7 0x60 #define PROXFUSION3_TOUCH_NUMB_8 0x40 /** * @brief ProxFusion 3 channel of touch. * @details Specified channel of touch of ProxFusion 3 Click driver. */ #define PROXFUSION3_TOUCH_CRX_0 0x01 #define PROXFUSION3_TOUCH_CRX_1 0x02 #define PROXFUSION3_TOUCH_CRX_2 0x04 #define PROXFUSION3_TOUCH_CRX_3 0x08 #define PROXFUSION3_TOUCH_CRX_4 0x10 #define PROXFUSION3_TOUCH_CRX_5 0x20 #define PROXFUSION3_TOUCH_CRX_6 0x40 #define PROXFUSION3_TOUCH_CRX_7 0x80 /** * @brief ProxFusion 3 position of touch. * @details Specified position of touch of ProxFusion 3 Click driver. */ #define PROXFUSION3_TOUCH_POS_NO_TOUCH 0x00 #define PROXFUSION3_TOUCH_POS_1 0x01 #define PROXFUSION3_TOUCH_POS_2 0x02 #define PROXFUSION3_TOUCH_POS_3 0x03 #define PROXFUSION3_TOUCH_POS_4 0x04 #define PROXFUSION3_TOUCH_POS_5 0x05 #define PROXFUSION3_TOUCH_POS_6 0x06 #define PROXFUSION3_TOUCH_POS_7 0x07 #define PROXFUSION3_TOUCH_POS_8 0x08 /** * @brief ProxFusion 3 Channel Prox and Touch Threshold settings register. * @details Specified register forChannel Prox and Touch Threshold of ProxFusion 3 Click driver. */ #define PROXFUSION3_CH0_PT_T 0x90 #define PROXFUSION3_CH1_PT_T 0x97 #define PROXFUSION3_CH2_PT_T 0x9E #define PROXFUSION3_CH3_PT_T 0xA5 #define PROXFUSION3_CH4_PT_T 0xAC #define PROXFUSION3_CH5_PT_T 0xB3 #define PROXFUSION3_CH6_PT_T 0xBA #define PROXFUSION3_CH7_PT_T 0xC1 /** * @brief ProxFusion 3 Channel Deep Touch Threshold settings register. * @details Specified register forChannel Deep Touch Threshold of ProxFusion 3 Click driver. */ #define PROXFUSION3_CH0_DT_T 0x91 #define PROXFUSION3_CH1_DT_T 0x98 #define PROXFUSION3_CH2_DT_T 0x9F #define PROXFUSION3_CH3_DT_T 0xA6 #define PROXFUSION3_CH4_DT_T 0xAD #define PROXFUSION3_CH5_DT_T 0xB4 #define PROXFUSION3_CH6_DT_T 0xBB #define PROXFUSION3_CH7_DT_T 0xC2 /** * @brief ProxFusion 3 Check touch event. * @details Specified check touch event of ProxFusion 3 Click driver. */ #define PROXFUSION3_EVENT_NO_TOUCH 0x00 #define PROXFUSION3_EVENT_TOUCH 0x01 /** * @brief ProxFusion 3 device address setting. * @details Specified setting for device slave address selection of * ProxFusion 3 Click driver. */ #define PROXFUSION3_SET_DEV_ADDR 0x44 /** * @brief ProxFusion 3 pin setting function. * @details Specified setting for the target pin state of * ProxFusion 3 Click driver. */ #define PROXFUSION3_SET_PIN_STATE_LOW 0x00 #define PROXFUSION3_SET_PIN_STATE_HIGH 0x01 /** * @brief ProxFusion 3 threshold setting. * @details Specified setting for the proximity, touch and deep touch thresholds * of ProxFusion 3 Click driver. */ #define PROXFUSION3_PROX_THRESHOLD 10 #define PROXFUSION3_TOUCH_THRESHOLD_CH0 22 #define PROXFUSION3_TOUCH_THRESHOLD_CH1 20 #define PROXFUSION3_TOUCH_THRESHOLD_CH2 10 #define PROXFUSION3_TOUCH_THRESHOLD_CH3 10 #define PROXFUSION3_TOUCH_THRESHOLD_CH4 22 #define PROXFUSION3_TOUCH_THRESHOLD_CH5 20 #define PROXFUSION3_TOUCH_THRESHOLD_CH6 12 #define PROXFUSION3_TOUCH_THRESHOLD_CH7 10 #define PROXFUSION3_DEEP_TOUCH_THRESHOLD_CH0 32 #define PROXFUSION3_DEEP_TOUCH_THRESHOLD_CH1 26 #define PROXFUSION3_DEEP_TOUCH_THRESHOLD_CH2 26 #define PROXFUSION3_DEEP_TOUCH_THRESHOLD_CH3 26 #define PROXFUSION3_DEEP_TOUCH_THRESHOLD_CH4 32 #define PROXFUSION3_DEEP_TOUCH_THRESHOLD_CH5 26 #define PROXFUSION3_DEEP_TOUCH_THRESHOLD_CH6 26 #define PROXFUSION3_DEEP_TOUCH_THRESHOLD_CH7 26 #define PROXFUSION3_TOUCH_CH_RX_THRESHOLD_7 16384 /*! @} */ // proxfusion3_set /** * @defgroup proxfusion3_map ProxFusion 3 MikroBUS Map * @brief MikroBUS pin mapping of ProxFusion 3 Click driver. */ /** * @addtogroup proxfusion3_map * @{ */ /** * @brief MikroBUS pin mapping. * @details Mapping pins of ProxFusion 3 Click to the selected MikroBUS. */ #define PROXFUSION3_MAP_MIKROBUS( cfg, mikrobus ) \ cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \ cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \ cfg.gp = MIKROBUS( mikrobus, MIKROBUS_PWM ); \ cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT ) /*! @} */ // proxfusion3_map /*! @} */ // proxfusion3 /** * @brief ProxFusion 3 Click context object. * @details Context object definition of ProxFusion 3 Click driver. */ typedef struct { // Output pins digital_out_t int_pin; /**< Indicate windows for communication from master. */ // Input pins digital_in_t gp; /**< Touch output for CH0 from the POR event. */ // Modules i2c_master_t i2c; /**< I2C driver object. */ // I2C slave address uint8_t slave_address; /**< Device slave address (used for I2C driver). */ } proxfusion3_t; /** * @brief ProxFusion 3 Click configuration object. * @details Configuration object definition of ProxFusion 3 Click driver. */ typedef struct { pin_name_t scl; /**< Clock pin descriptor for I2C driver. */ pin_name_t sda; /**< Bidirectional data pin descriptor for I2C driver. */ pin_name_t gp; /**< Touch output for CH0 from the POR event. */ pin_name_t int_pin; /**< Indicate windows for communication from master. */ uint32_t i2c_speed; /**< I2C serial speed. */ uint8_t i2c_address; /**< I2C slave address. */ } proxfusion3_cfg_t; /*! * @addtogroup proxfusion3 ProxFusion 3 Click Driver * @brief API for configuring and manipulating ProxFusion 3 Click driver. * @{ */ /** * @brief ProxFusion 3 configuration object setup function. * @details This function initializes click configuration structure to initial * values. * @param[out] cfg : Click configuration structure. * See #proxfusion3_cfg_t object definition for detailed explanation. * @return Nothing. * @note The all used pins will be set to unconnected state. * * @endcode */ void proxfusion3_cfg_setup ( proxfusion3_cfg_t *cfg ); /** * @brief ProxFusion 3 initialization function. * @details This function initializes all necessary pins and peripherals used * for this click board. * @param[out] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @param[in] cfg : Click configuration structure. * See #proxfusion3_cfg_t object definition for detailed explanation. * @return @li @c 0 - Success, * @li @c -1 - Error. * * See #err_t definition for detailed explanation. * @note None. * * @endcode */ err_t proxfusion3_init ( proxfusion3_t *ctx, proxfusion3_cfg_t *cfg ); /** * @brief ProxFusion 3 default configuration function. * @details This function executes a default configuration of ProxFusion 3 * click board. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @return @li @c 0 - Success, * @li @c -1 - Error. * * See #err_t definition for detailed explanation. * @note This function can consist any necessary configuration or setting to put * device into operating mode. The delay is approximately 600 milliseconds. * * @endcode */ err_t proxfusion3_default_cfg ( proxfusion3_t *ctx ); /** * @brief ProxFusion 3 INT pin setting function. * @details This function sets the INT pin state to the desired level * ProxFusion 3 click board. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @param[in] pin_state : * @li @c 0x00 ( PROXFUSION3_SET_PIN_STATE_LOW ) - Set INT pin on the low level, * @li @c 0x01 ( PROXFUSION3_SET_PIN_STATE_HIGH ) - Set INT pin on the high level. * @return Nothing. * @note None. */ void proxfusion3_set_state_int_pin ( proxfusion3_t *ctx, uint8_t pin_state ); /** * @brief ProxFusion 3 get state of GP pin function. * @details This function get State of GP pin * on ProxFusion 3 click board. * @param[out] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @return * @li @c 0x00 - Low, * @li @c 0x01 - High. * * @note None. */ uint8_t proxfusion3_get_state_gp_pin ( proxfusion3_t *ctx ); /** * @brief ProxFusion 3 I2C writing function. * @details This function writes a desired number of data bytes starting from * the selected register by using I2C serial interface. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @param[in] reg : Start register address. * @param[in] tx_buf : Data to be written. * @param[in] tx_len : Number of bytes to be written. * @return @li @c 0 - Success, * @li @c -1 - Error. * * See #err_t definition for detailed explanation. * @note None. * * @endcode */ err_t proxfusion3_generic_write ( proxfusion3_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len ); /** * @brief ProxFusion 3 I2C reading function. * @details This function reads a desired number of data bytes starting from * the selected register by using I2C serial interface. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @param[in] reg : Start register address. * @param[out] rx_buf : Output read data. * @param[in] rx_len : Number of bytes to be read. * @return @li @c 0 - Success, * @li @c -1 - Error. * * See #err_t definition for detailed explanation. * @note None. * * @endcode */ err_t proxfusion3_generic_read ( proxfusion3_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len ); /** * @brief ProxFusion 3 I2C register writing function. * @details This function register writes a 16-bit data * to the selected register by using I2C serial interface. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @param[in] reg : Register address. * @param[in] tx_buf : 16-bit data to be written. * @return Nothing. * * @note None. * * @endcode */ void proxfusion3_write_reg ( proxfusion3_t *ctx, uint8_t reg, uint16_t tx_data ); /** * @brief ProxFusion 3 I2C register reading function. * @details This function reads a 16-bit data * from the selected register by using I2C serial interface. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @param[in] reg : Register address. * @return 16-bit read data. * * @note None. * * @endcode */ uint16_t proxfusion3_read_reg ( proxfusion3_t *ctx, uint8_t reg ); /** * @brief ProxFusion 3 get version info data function. * @details This function reads a version info data * by using I2C serial interface. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @param[out] product_number : Output product number data. * @param[out] software_version : Output software version data. * @return @li @c 0 - Success, * @li @c -1 - Error. * * See #err_t definition for detailed explanation. * @note None. * * @endcode */ err_t proxfusion3_get_version_info ( proxfusion3_t *ctx, uint8_t *product_number, uint8_t *software_version ); /** * @brief ProxFusion 3 software reset function. * @details This function is a method which clears the Show Reset bit * by writing it to a 0 * of the IQS269A 8 Channel capacitive touch and proximity controller * on the ProxFusion 3 click board. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @return Nothing. * * @note None. * * @endcode */ void proxfusion3_sw_reset ( proxfusion3_t *ctx ); /** * @brief ProxFusion 3 enable channels function. * @details This function is a method which enables all channels * of the IQS269A 8 Channel capacitive touch and proximity controller * on the ProxFusion 3 click board. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @return Nothing. * * @note None. * * @endcode */ void proxfusion3_enable_channels ( proxfusion3_t *ctx ); /** * @brief ProxFusion 3 channel remap function. * @details This function is remap the channels * of the IQS269A 8 Channel capacitive touch and proximity controller * on the ProxFusion 3 click board. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @return Nothing. * * @note None. * * @endcode */ void proxfusion3_channel_remap ( proxfusion3_t *ctx ); /** * @brief ProxFusion 3 adjust touch thresholds function. * @details This function adjust touch thresholds * of the IQS269A 8 Channel capacitive touch and proximity controller * on the ProxFusion 3 click board. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @return Nothing. * * @note None. * * @endcode */ void proxfusion3_adjust_touch_thresholds ( proxfusion3_t *ctx ); /** * @brief ProxFusion 3 adjust deep touch thresholds function. * @details This function adjust deep touch thresholds * of the IQS269A 8 Channel capacitive touch and proximity controller * on the ProxFusion 3 click board. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @return Nothing. * * @note None. * * @endcode */ void proxfusion3_adjust_deep_touch_thresholds ( proxfusion3_t *ctx ); /** * @brief ProxFusion 3 auto tune function. * @details This function force the device to run the * Automatic Tuning Implementation (ATI) routine * of the IQS269A 8 Channel capacitive touch and proximity controller * on the ProxFusion 3 click board. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @return Nothing. * * @note None. * * @endcode */ void proxfusion3_auto_tune ( proxfusion3_t *ctx ); /** * @brief ProxFusion 3 set event function. * @details This function set desired event * of the IQS269A 8 Channel capacitive touch and proximity controller * on the ProxFusion 3 click board. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @param[in] event : * @li @c 0x01 ( PROXFUSION3_PROX_EVENT_BIT ) - Proxy event, * @li @c 0x02 ( PROXFUSION3_TOUCH_EVENT_BIT ) - Touch event, * @li @c 0x04 ( PROXFUSION3_DEEP_EVENT_BIT ) - Deep event, * @li @c 0x08 ( PROXFUSION3_GESTURE_EVENT_BIT ) - Gesture event, * @li @c 0x10 ( PROXFUSION3_MOV_EVENT_BIT ) - Mov event, * @li @c 0x20 ( PROXFUSION3_REF_EVENT_BIT ) - Reference event, * @li @c 0x40 ( PROXFUSION3_SYS_EVENT_BIT ) - System event, * @li @c 0x80 ( PROXFUSION3_LP_EVENT_BIT ) - LP event. * @return Nothing. * * @note None. * * @endcode */ void proxfusion3_set_event ( proxfusion3_t *ctx, uint8_t event ); /** * @brief ProxFusion 3 get absolute measurement function. * @details This function read the absolute capacitance registers * and calculate the absolute capacitance * of the IQS269A 8 Channel capacitive touch and proximity controller * on the ProxFusion 3 click board. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @return absolute capacitance. * * @note None. * * @endcode */ float proxfusion3_get_absolute_measurement ( proxfusion3_t *ctx ); /** * @brief ProxFusion 3 read channel delta function. * @details This function reads and returns the Delta value of a specific channel * of the IQS269A 8 Channel capacitive touch and proximity controller * on the ProxFusion 3 click board. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @param[in] channel : The enumerator which specifes which channel's Delta value to return. * @return 16-bit Delta value of the channel. * * @note None. * * @endcode */ uint16_t proxfusion3_read_channel_delta ( proxfusion3_t *ctx, uint8_t channel ); /** * @brief ProxFusion 3 check touch event function. * @details This function reads and check touch event * of the IQS269A 8 Channel capacitive touch and proximity controller * on the ProxFusion 3 click board. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @return @li @c 0x00 ( PROXFUSION3_EVENT_NO_TOUCH ) - No Touch event, * @li @c 0x01 ( PROXFUSION3_EVENT_TOUCH ) - Touch event. * * @note None. * * @endcode */ uint8_t proxfusion3_check_touch_event ( proxfusion3_t *ctx ); /** * @brief ProxFusion 3 get touch function. * @details This function reads and returns the position of the touch * of the IQS269A 8 Channel capacitive touch and proximity controller * on the ProxFusion 3 click board. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @return position of the touch: * @li @c 0x01 - Number 1, * @li @c 0x02 - Number 2, * @li @c 0x03 - Number 3, * @li @c 0x04 - Number 4, * @li @c 0x05 - Number 5, * @li @c 0x06 - Number 6, * @li @c 0x07 - Number 7, * @li @c 0x08 - Number 8. * * @note None. * * @endcode */ uint8_t proxfusion3_get_touch ( proxfusion3_t *ctx ); /** * @brief ProxFusion 3 enables the absolute capacitiance function. * @details This function is a method which enables * the absolute capacitiance UI * of the IQS269A 8 Channel capacitive touch and proximity controller * on the ProxFusion 3 click board. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @return Nothing. * * @note None. * * @endcode */ void proxfusion3_en_abs_cap ( proxfusion3_t *ctx ); /** * @brief ProxFusion 3 set even mode function. * @details This function set the desire even mode * of the IQS269A 8 Channel capacitive touch and proximity controller * on the ProxFusion 3 click board. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @param[in] mode : * @li @c 0x01 ( PROXFUSION3_PROX_EVENT_BIT ) - Proxy event, * @li @c 0x02 ( PROXFUSION3_TOUCH_EVENT_BIT ) - Touch event, * @li @c 0x04 ( PROXFUSION3_DEEP_EVENT_BIT ) - Deep event, * @li @c 0x08 ( PROXFUSION3_GESTURE_EVENT_BIT ) - Gesture event, * @li @c 0x10 ( PROXFUSION3_MOV_EVENT_BIT ) - Mov event, * @li @c 0x20 ( PROXFUSION3_REF_EVENT_BIT ) - Reference event, * @li @c 0x40 ( PROXFUSION3_SYS_EVENT_BIT ) - System event, * @li @c 0x80 ( PROXFUSION3_LP_EVENT_BIT ) - LP event. * @return Nothing. * * @note None. * * @endcode */ void proxfusion3_set_even_mode ( proxfusion3_t *ctx, uint8_t mode ); /** * @brief ProxFusion 3 get events function. * @details This function reads and returns the byte which holds the event flags * of the IQS269A 8 Channel capacitive touch and proximity controller * on the ProxFusion 3 click board. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @return Byte which contains the event flags. * * @note None. * * @endcode */ uint8_t proxfusion3_get_events ( proxfusion3_t *ctx ); /** * @brief ProxFusion 3 get gestures function. * @details This function reads and returns the byte which holds the gesture flags * of the IQS269A 8 Channel capacitive touch and proximity controller * on the ProxFusion 3 click board. * @param[in] ctx : Click context object. * See #proxfusion3_t object definition for detailed explanation. * @return Byte which contains the gesture flags. * * @note The user must determine which gestures occurred by use of the gesture bit definitions. * It is up to the user to decide which one to use. * * @endcode */ uint8_t proxfusion3_get_gestures ( proxfusion3_t *ctx ); #ifdef __cplusplus } #endif #endif // PROXFUSION3_H /*! @} */ // proxfusion3 // ------------------------------------------------------------------------ END
37.865658
110
0.687789
[ "object" ]
a48425904c2c6e359a1210acdf52b01ce5a410ff
3,159
h
C
qqtw/qqheaders7.2/BCardDetailViewModel.h
onezens/QQTweak
04b9efd1d93eba8ef8fec5cf9a20276637765777
[ "MIT" ]
5
2018-02-20T14:24:17.000Z
2020-08-06T09:31:21.000Z
qqtw/qqheaders7.2/BCardDetailViewModel.h
onezens/QQTweak
04b9efd1d93eba8ef8fec5cf9a20276637765777
[ "MIT" ]
1
2020-06-10T07:49:16.000Z
2020-06-12T02:08:35.000Z
qqtw/qqheaders7.2/BCardDetailViewModel.h
onezens/SmartQQ
04b9efd1d93eba8ef8fec5cf9a20276637765777
[ "MIT" ]
null
null
null
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import "NSObject.h" @class BCardInfoModel, NSMutableArray, NSMutableDictionary, NSString; @interface BCardDetailViewModel : NSObject { _Bool _isEditedStatus; _Bool _isMine; NSString *_remarkNameOrigin; NSString *_remarkNameFinish; BCardInfoModel *_cardModelFinish; BCardInfoModel *_cardModel; NSMutableArray *_unEditPhones; unsigned long long _qqCardSrc; NSMutableArray *_arrayBottomModel; unsigned long long _bcardControllerSrc; NSMutableDictionary *_dicCellModel; } - (void).cxx_destruct; - (void)addCardDetailTelephoneOrQQ:(long long)arg1; @property(retain, nonatomic) NSMutableArray *arrayBottomModel; // @synthesize arrayBottomModel=_arrayBottomModel; @property(nonatomic) unsigned long long bcardControllerSrc; // @synthesize bcardControllerSrc=_bcardControllerSrc; @property(retain, nonatomic) BCardInfoModel *cardModel; // @synthesize cardModel=_cardModel; @property(retain, nonatomic) BCardInfoModel *cardModelFinish; // @synthesize cardModelFinish=_cardModelFinish; - (void)convertDicCellModelToBCardInfoModel:(Class)arg1; @property(retain, nonatomic) NSMutableDictionary *dicCellModel; // @synthesize dicCellModel=_dicCellModel; - (id)getArrayBottomView; - (id)getCellModel; - (id)getQQArray; - (long long)getQQSameCountAtArrayTheme:(long long)arg1 theme:(id)arg2 currentType:(long long)arg3; - (long long)getSameType:(long long)arg1; - (id)getSection0; - (id)getSection0EditStatus:(_Bool)arg1; - (id)getSection0FinishStatus; - (id)getSection1; - (id)getSection1EditStatus; - (id)getSection1FinishStatus; - (id)getSection2; - (id)getSection2EditStatus; - (id)getSection2FinishStatus; - (id)getSection3; - (id)initWithViewModel:(id)arg1 isEditStatus:(_Bool)arg2 remark:(id)arg3 src:(unsigned long long)arg4 isMine:(_Bool)arg5; - (id)initWithViewModel:(id)arg1 isEditStatus:(_Bool)arg2 src:(unsigned long long)arg3 class:(Class)arg4 isMine:(_Bool)arg5; - (id)initWithViewModel:(id)arg1 isEditStatus:(_Bool)arg2 src:(unsigned long long)arg3 class:(Class)arg4 remarkName:(id)arg5 isMine:(_Bool)arg6; - (_Bool)isBCardInfoModelChange:(Class)arg1; - (_Bool)isCardImageSection:(unsigned long long)arg1; @property(nonatomic) _Bool isEditedStatus; // @synthesize isEditedStatus=_isEditedStatus; @property(nonatomic) _Bool isMine; // @synthesize isMine=_isMine; - (_Bool)isNeedQQSection:(long long)arg1; - (void)joinBCardDescs:(id)arg1; - (id)newBCardDetailCellModel:(long long)arg1 model:(id)arg2 cardQQmodel:(id)arg3 indexInSameArray:(long long)arg4; @property(nonatomic) unsigned long long qqCardSrc; // @synthesize qqCardSrc=_qqCardSrc; @property(copy, nonatomic) NSString *remarkNameFinish; // @synthesize remarkNameFinish=_remarkNameFinish; @property(copy, nonatomic) NSString *remarkNameOrigin; // @synthesize remarkNameOrigin=_remarkNameOrigin; - (void)resetArrayBottom:(Class)arg1; - (void)resetViewModelDataSource; - (void)setDicCellModelSeperatorHalf; @property(retain, nonatomic) NSMutableArray *unEditPhones; // @synthesize unEditPhones=_unEditPhones; @end
45.782609
144
0.787591
[ "model" ]
a489a665c57ece9d19254611b8ae0832e10b168b
6,868
c
C
src/core/memstore_exec.c
androdev4u/sysdb
1cdd09f260f6130eb7b486707b1816329c5979a7
[ "BSD-2-Clause" ]
30
2015-01-03T20:57:35.000Z
2018-08-24T19:54:48.000Z
src/core/memstore_exec.c
androdev4u/sysdb
1cdd09f260f6130eb7b486707b1816329c5979a7
[ "BSD-2-Clause" ]
3
2015-02-27T15:48:28.000Z
2017-10-22T10:39:27.000Z
src/core/memstore_exec.c
androdev4u/sysdb
1cdd09f260f6130eb7b486707b1816329c5979a7
[ "BSD-2-Clause" ]
5
2015-05-13T09:00:19.000Z
2019-01-23T04:43:27.000Z
/* * SysDB - src/core/memstore_exec.c * Copyright (C) 2014-2015 Sebastian 'tokkee' Harl <sh@tokkee.org> * 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. * * 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 HOLDERS 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 "core/object.h" #include "core/plugin.h" #include "core/memstore-private.h" #include "frontend/connection.h" #include "parser/ast.h" #include "utils/error.h" #include <errno.h> #include <arpa/inet.h> #include <stdlib.h> #include <string.h> /* * private helper functions */ typedef struct { sdb_memstore_obj_t *current_host; sdb_store_writer_t *w; sdb_object_t *wd; } iter_t; static int maybe_emit_host(iter_t *iter, sdb_memstore_obj_t *obj) { if ((obj->type == SDB_HOST) || (obj->type == SDB_ATTRIBUTE)) return 0; if (iter->current_host == obj->parent) return 0; iter->current_host = obj->parent; return sdb_memstore_emit(obj->parent, iter->w, iter->wd); } /* maybe_emit_host */ static int list_tojson(sdb_memstore_obj_t *obj, sdb_memstore_matcher_t __attribute__((unused)) *filter, void *user_data) { iter_t *iter = user_data; maybe_emit_host(iter, obj); return sdb_memstore_emit(obj, iter->w, iter->wd); } /* list_tojson */ static int lookup_tojson(sdb_memstore_obj_t *obj, sdb_memstore_matcher_t *filter, void *user_data) { iter_t *iter = user_data; maybe_emit_host(iter, obj); return sdb_memstore_emit_full(obj, filter, iter->w, iter->wd); } /* lookup_tojson */ /* * query implementations */ static int exec_fetch(sdb_memstore_t *store, sdb_store_writer_t *w, sdb_object_t *wd, sdb_strbuf_t *errbuf, int type, const char *hostname, int parent_type, const char *parent, const char *name, bool full, sdb_memstore_matcher_t *filter) { sdb_memstore_obj_t *host, *p = NULL, *obj; int status = 0; if (type == SDB_HOST) hostname = name; host = sdb_memstore_get_host(store, hostname); if ((! host) || (filter && (! sdb_memstore_matcher_matches(filter, host, NULL)))) { sdb_strbuf_sprintf(errbuf, "Failed to fetch %s %s: " "host %s not found", SDB_STORE_TYPE_TO_NAME(type), name, hostname); sdb_object_deref(SDB_OBJ(host)); return -1; } obj = host; if (type != SDB_HOST) { if (parent) { p = sdb_memstore_get_child(obj, parent_type, parent); if ((! p) || (filter && (! sdb_memstore_matcher_matches(filter, p, NULL)))) { sdb_strbuf_sprintf(errbuf, "Failed to fetch %s %s.%s.%s: " "%s not found", SDB_STORE_TYPE_TO_NAME(type), hostname, parent, name, parent); status = -1; } obj = p; } if (! status) { obj = sdb_memstore_get_child(obj, type, name); if ((! obj) || (filter && (! sdb_memstore_matcher_matches(filter, obj, NULL)))) { sdb_strbuf_sprintf(errbuf, "Failed to fetch %s %s.%s: " "%s not found", SDB_STORE_TYPE_TO_NAME(type), hostname, name, name); status = -1; } } } if (! status) { if (type != SDB_HOST) status = sdb_memstore_emit(host, w, wd); if ((! status) && parent) status = sdb_memstore_emit(p, w, wd); if (! status) { if (full) status = sdb_memstore_emit_full(obj, filter, w, wd); else status = sdb_memstore_emit(obj, w, wd); } if (status) { sdb_log(SDB_LOG_ERR, "memstore: Failed to serialize " "%s %s.%s to JSON", SDB_STORE_TYPE_TO_NAME(type), hostname, name); sdb_strbuf_sprintf(errbuf, "Out of memory"); status = -1; } } if (host != obj) sdb_object_deref(SDB_OBJ(host)); if (p != obj) sdb_object_deref(SDB_OBJ(p)); sdb_object_deref(SDB_OBJ(obj)); if (status) return status; return SDB_CONNECTION_DATA; } /* exec_fetch */ static int exec_list(sdb_memstore_t *store, sdb_store_writer_t *w, sdb_object_t *wd, sdb_strbuf_t *errbuf, int type, sdb_memstore_matcher_t *filter) { iter_t iter = { NULL, w, wd }; if (sdb_memstore_scan(store, type, /* m = */ NULL, filter, list_tojson, &iter)) { sdb_log(SDB_LOG_ERR, "memstore: Failed to serialize " "store to JSON"); sdb_strbuf_sprintf(errbuf, "Out of memory"); return -1; } return SDB_CONNECTION_DATA; } /* exec_list */ static int exec_lookup(sdb_memstore_t *store, sdb_store_writer_t *w, sdb_object_t *wd, sdb_strbuf_t *errbuf, int type, sdb_memstore_matcher_t *m, sdb_memstore_matcher_t *filter) { iter_t iter = { NULL, w, wd }; if (sdb_memstore_scan(store, type, m, filter, lookup_tojson, &iter)) { sdb_log(SDB_LOG_ERR, "memstore: Failed to lookup %ss", SDB_STORE_TYPE_TO_NAME(type)); sdb_strbuf_sprintf(errbuf, "Failed to lookup %ss", SDB_STORE_TYPE_TO_NAME(type)); return -1; } return SDB_CONNECTION_DATA; } /* exec_lookup */ /* * public API */ int sdb_memstore_query_execute(sdb_memstore_t *store, sdb_memstore_query_t *q, sdb_store_writer_t *w, sdb_object_t *wd, sdb_strbuf_t *errbuf) { sdb_ast_node_t *ast; if (! q) return -1; if (! q->ast) { sdb_log(SDB_LOG_ERR, "memstore: Invalid empty query"); return -1; } ast = q->ast; switch (ast->type) { case SDB_AST_TYPE_FETCH: return exec_fetch(store, w, wd, errbuf, SDB_AST_FETCH(ast)->obj_type, SDB_AST_FETCH(ast)->hostname, SDB_AST_FETCH(ast)->parent_type, SDB_AST_FETCH(ast)->parent, SDB_AST_FETCH(ast)->name, SDB_AST_FETCH(ast)->full, q->filter); case SDB_AST_TYPE_LIST: return exec_list(store, w, wd, errbuf, SDB_AST_LIST(ast)->obj_type, q->filter); case SDB_AST_TYPE_LOOKUP: return exec_lookup(store, w, wd, errbuf, SDB_AST_LOOKUP(ast)->obj_type, q->matcher, q->filter); default: sdb_log(SDB_LOG_ERR, "memstore: Invalid query of type %s", SDB_AST_TYPE_TO_STRING(ast)); return -1; } return 0; } /* sdb_memstore_query_execute */ /* vim: set tw=78 sw=4 ts=4 noexpandtab : */
28.497925
82
0.703262
[ "object" ]
a4970dd7db1d8cd01b3e79525feeaf1e52ad3d42
271
h
C
src/basis/atom_basis.h
Samthos/MC-MPn-Direct
cdf05c7ce7b33bf1b86b80f57f800634822c9cc6
[ "MIT" ]
1
2021-04-06T05:01:47.000Z
2021-04-06T05:01:47.000Z
src/basis/atom_basis.h
spec-org/MC-MPn-Direct
cdf05c7ce7b33bf1b86b80f57f800634822c9cc6
[ "MIT" ]
null
null
null
src/basis/atom_basis.h
spec-org/MC-MPn-Direct
cdf05c7ce7b33bf1b86b80f57f800634822c9cc6
[ "MIT" ]
3
2020-06-09T23:53:28.000Z
2022-03-02T05:44:55.000Z
#ifndef ATOM_BASIS_H_ #define ATOM_BASIS_H_ #include "shell.h" struct AtomBasis { AtomBasis() { atomCharge = -1; } std::string basisName; std::string basisType; std::string atomName; std::vector<SHELL::Shell> shell; int atomCharge; }; #endif // ATOM_BASIS_H_
20.846154
34
0.715867
[ "vector" ]
a4ae5f86b16885c66e897906dc4d8d5ae7715eea
7,912
c
C
lib/flow.c
Melab/gvmt
566eac01724b687bc5e11317e44230faab15f895
[ "MIT" ]
null
null
null
lib/flow.c
Melab/gvmt
566eac01724b687bc5e11317e44230faab15f895
[ "MIT" ]
null
null
null
lib/flow.c
Melab/gvmt
566eac01724b687bc5e11317e44230faab15f895
[ "MIT" ]
1
2021-12-04T15:59:58.000Z
2021-12-04T15:59:58.000Z
#include "bitset.h" #include "flow.h" #include <string.h> #include <assert.h> #include <stdio.h> #include "arena.h" void fatal(char* format, ...); GVMT_FlowGraph new_flowgraph(Arena arena) { GVMT_FlowGraph flow_graph = gvmt_allocate(sizeof(struct gvmt_flow_graph), arena); flow_graph->arena = arena; flow_graph->edges.end = flow_graph->edges.start = gvmt_allocate(sizeof(struct gvmt_edge) * 64, arena); flow_graph->edges.limit = flow_graph->edges.start + 64; flow_graph->edge_sets.end = flow_graph->edge_sets.start = gvmt_allocate(sizeof(struct gvmt_edge) * 32, arena); flow_graph->edge_sets.limit = flow_graph->edge_sets.start + 32; return flow_graph; } void gvmt_edge_vector_expand_buffer(GVMT_EdgeVector v, Arena arena) { GVMT_Edge new_edges = gvmt_allocate(sizeof(struct gvmt_edge) * 2 * ((v)->end - (v)->start), arena); int new_size = (v->limit - v->start) * 2; memcpy(new_edges, v->start, sizeof(struct gvmt_edge) * (v->limit - v->start)); v->end += new_edges - v->start; v->limit = new_edges + new_size; v->start = new_edges; } void gvmt_edge_set_vector_expand_buffer(GVMT_EdgeSetVector v, Arena arena) { GVMT_EdgeSet new_edgesets = gvmt_allocate(sizeof(struct gvmt_edge_set) * 2 * ((v)->end - (v)->start), arena); int new_size = (v->limit - v->start) * 2; memcpy(new_edgesets, v->start, sizeof(struct gvmt_edge_set) * (v->limit - v->start)); v->end += new_edgesets - v->start; v->limit = new_edgesets + new_size; v->start = new_edgesets; } void gvmt_add_edge_set(BitSet parents, BitSet children, GVMT_EdgeSetVector v, Arena arena) { if (v->end == v->limit) gvmt_edge_set_vector_expand_buffer(v, arena); v->end->parents = parents; v->end->children = children; v->end->stack = 0; v->end++; } void gvmt_add_edge(int start, int end, GVMT_EdgeVector vector, Arena arena) { assert(((unsigned)start) < 100000); assert(((unsigned)end) < 100000); if (vector->end == vector->limit) { gvmt_edge_vector_expand_buffer(vector, arena); } vector->end->predecessor = start; vector->end->successor = end; vector->end++; } /** Binary search algorithm from NIST - Public domain. */ int get_block_ending_at(int end, GVMT_BlockVector blocks) { int n = blocks->end - blocks->start; int high, i, low; for ( low=(-1), high=n-1; high-low > 1;) { i = (high+low) / 2; if ( end <= blocks->start[i].end ) high = i; else low = i; } if (end == blocks->start[high].end ) return( high ); else fatal("Cannot find block ending at: %d\n", end); return -1; } /** Binary search algorithm from NIST - Public domain. */ int get_block_starting_at(int start, GVMT_BlockVector blocks) { int n = blocks->end - blocks->start; int high, i, low; for ( low=(-1), high=n-1; high-low > 1;) { i = (high+low) / 2; if ( start <= blocks->start[i].start ) high = i; else low = i; } if (start == blocks->start[high].start ) return( high ); else fatal("Cannot find block starting at: %d\n", start); return -1; } void process_edge(GVMT_Edge e, GVMT_BlockVector blocks) { int from = get_block_ending_at(e->predecessor, blocks); int to = get_block_starting_at(e->successor, blocks); assert(from < blocks->end - blocks->start); assert(to < blocks->end - blocks->start); set_add(blocks->start[from].successors, to); set_add(blocks->start[to].predecessors, from); } void process_edges(GVMT_EdgeVector edges, GVMT_BlockVector blocks) { GVMT_Edge e; for (e = edges->start; e < edges->end; e++) { process_edge(e, blocks); } } #define SWAP(a,b) do { BitSet t = a; a = b; b = t; } while(0) static int edge_sets = 0; void build_edge_set(int seed_parent, GVMT_BlockVector blocks, BitSet parents, BitSet children, int block_count, Arena arena) { BitSet work_parents = set_new(block_count, arena); BitSet next_parents = set_new(block_count, arena); BitSet work_children = set_new(block_count, arena); BitSet next_children = set_new(block_count, arena); assert(set_empty(parents)); assert(set_empty(children)); int i; set_add(work_parents, seed_parent); do { FOR_EACH(i, work_parents) set_addSet(next_children, blocks->start[i].successors); FOR_EACH(i, work_children) set_addSet(next_parents, blocks->start[i].predecessors); set_addSet(parents, work_parents); set_addSet(children, work_children); set_removeSet(next_parents, parents); set_removeSet(next_children, children); if (set_empty(next_parents) && set_empty(next_children)) { printf("Edge set %d built\n", ++edge_sets); return; } SWAP(work_parents, next_parents); SWAP(work_children, next_children); set_clear(next_parents); set_clear(next_children); } while(1); } void add_edge_sets_to_blocks(GVMT_EdgeSetVector edge_sets, GVMT_BlockVector blocks) { GVMT_EdgeSet es; int i; for (es = edge_sets->start; es < edge_sets->end; es++) { FOR_EACH(i, es->parents) blocks->start[i].edge_set = es; } } GVMT_EdgeSet gvmt_get_edge_set_for_ip(int offset, GVMT_BlockVector blocks) { int block = get_block_ending_at(offset, blocks); return blocks->start[block].edge_set; } static void print_block(GVMT_Block b, FILE *out) { fprintf(out, "block_%d [\n", b->start); fprintf(out, "label = \"{"); fprintf(out, "Start: %d|", b->start); fprintf(out, "End: %d}\"\n", b->end); fprintf(out, "shape = \"record\"\n];\n"); } static void print_edge(GVMT_Edge e, FILE *out) { fprintf(out, "edge_%d [\n", e->predecessor); fprintf(out, "label = \"{"); fprintf(out, "Pre: %d|", e->predecessor); fprintf(out, "Succ: %d}\"\n", e->successor); fprintf(out, "shape = \"record\"\n];\n"); } void print_flowgraph(GVMT_FlowGraph graph, char* name) { FILE *out; char buf[100]; sprintf(buf, "/tmp/%s.dot", name); out = fopen(buf, "w"); fprintf(out, "digraph g { \n"); fprintf(out, "graph [ \n"); fprintf(out, "rankdir = \"TB\" \n"); fprintf(out, "ratio = \"2\" \n"); fprintf(out, "]; \n"); fprintf(out, "node [ \n"); fprintf(out, "fontsize = \"8\" \n"); fprintf(out, "shape = \"rectangle\" \n"); fprintf(out, "]; \n"); fprintf(out, "edge [ \n"); fprintf(out, "]; \n"); for(GVMT_Block b = graph->blocks.start; b < graph->blocks.end; b++) { print_block(b, out); } for(GVMT_Block b = graph->blocks.start; b < graph->blocks.end; b++) { if (b->successors) { int i; FOR_EACH(i, b->successors) { fprintf(out, "block_%d -> block_%d\n", b->start, graph->blocks.start[i].start); } } } // for(GVMT_Edge e = graph->edges.start; e < graph->edges.end; e++) { // print_edge(e, out); // } fprintf(out, "}\n"); } void depth_first_recursive(GVMT_FlowGraph graph, GVMT_Block b, BitSet visited, block_func func, void *prev) { void* next = func(b, prev); int i; FOR_EACH(i, b->successors) { if (!set_contains(visited, i)) { set_add(visited, i); depth_first_recursive(graph, &graph->blocks.start[i], visited, func, next); } } } void depth_first(GVMT_FlowGraph graph, block_func func, void* start) { BitSet visited = set_new(graph->blocks.end - graph->blocks.start, graph->arena); set_add(visited, 0); depth_first_recursive(graph, graph->blocks.start, visited, func, start); }
35.479821
126
0.606547
[ "shape", "vector" ]
cc80fc33e7fce097d3e79eef1e7db13b97b2e54c
3,689
h
C
ProcessLib/TES/TESLocalAssembler.h
norihiro-w/ogs
ac990b1aa06a583dba3e32efa3009ef0c6f46ae4
[ "BSD-4-Clause" ]
null
null
null
ProcessLib/TES/TESLocalAssembler.h
norihiro-w/ogs
ac990b1aa06a583dba3e32efa3009ef0c6f46ae4
[ "BSD-4-Clause" ]
25
2015-02-04T20:34:21.000Z
2018-12-10T20:19:57.000Z
ProcessLib/TES/TESLocalAssembler.h
norihiro-w/ogs
ac990b1aa06a583dba3e32efa3009ef0c6f46ae4
[ "BSD-4-Clause" ]
null
null
null
/** * \copyright * Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org) * Distributed under a Modified BSD License. * See accompanying file LICENSE.txt or * http://www.opengeosys.org/project/license * */ #ifndef PROCESS_LIB_TES_FEM_H_ #define PROCESS_LIB_TES_FEM_H_ #include <memory> #include <vector> #include "TESAssemblyParams.h" #include "TESLocalAssemblerInner-fwd.h" #include "NumLib/Extrapolation/Extrapolator.h" namespace ProcessLib { namespace TES { template <typename GlobalMatrix, typename GlobalVector> class TESLocalAssemblerInterface : public NumLib::Extrapolatable<GlobalVector, TESIntPtVariables> { public: virtual ~TESLocalAssemblerInterface() = default; virtual void assemble(double const t, std::vector<double> const& local_x) = 0; virtual void addToGlobal( NumLib::LocalToGlobalIndexMap::RowColumnIndices const&, GlobalMatrix& M, GlobalMatrix& K, GlobalVector& b) const = 0; virtual bool checkBounds(std::vector<double> const& local_x, std::vector<double> const& local_x_prev_ts) = 0; }; template <typename ShapeFunction_, typename IntegrationMethod_, typename GlobalMatrix, typename GlobalVector, unsigned GlobalDim> class TESLocalAssembler final : public TESLocalAssemblerInterface<GlobalMatrix, GlobalVector> { public: using ShapeFunction = ShapeFunction_; using ShapeMatricesType = ShapeMatrixPolicyType<ShapeFunction, GlobalDim>; using ShapeMatrices = typename ShapeMatricesType::ShapeMatrices; TESLocalAssembler(MeshLib::Element const& e, std::size_t const local_matrix_size, unsigned const integration_order, AssemblyParams const& asm_params); void assemble(double const t, std::vector<double> const& local_x) override; void addToGlobal( NumLib::LocalToGlobalIndexMap::RowColumnIndices const& indices, GlobalMatrix& M, GlobalMatrix& K, GlobalVector& b) const override; Eigen::Map<const Eigen::VectorXd> getShapeMatrix( const unsigned integration_point) const override { auto const& N = _shape_matrices[integration_point].N; // assumes N is stored contiguously in memory return Eigen::Map<const Eigen::VectorXd>(N.data(), N.size()); } bool checkBounds(std::vector<double> const& local_x, std::vector<double> const& local_x_prev_ts) override; std::vector<double> const& getIntegrationPointValues( TESIntPtVariables const var, std::vector<double>& cache) const override; private: std::vector<ShapeMatrices> _shape_matrices; using LAT = LocalAssemblerTraits<ShapeMatricesType, ShapeFunction::NPOINTS, NODAL_DOF, GlobalDim>; TESLocalAssemblerInner<LAT> _d; using NodalMatrixType = typename LAT::LocalMatrix; using NodalVectorType = typename LAT::LocalVector; static_assert( std::is_same<NodalMatrixType, typename LAT::LocalMatrix>::value, "local matrix and data traits matrix do not coincide"); static_assert( std::is_same<NodalVectorType, typename LAT::LocalVector>::value, "local vector and data traits vector do not coincide"); // TODO Change VectorMatrixAssembler s.t. these can be omitted. NodalMatrixType _local_M; NodalMatrixType _local_K; NodalVectorType _local_b; // TODO Use the value from Process unsigned const _integration_order; }; } // namespace TES } // namespace ProcessLib #include "TESLocalAssembler-impl.h" #endif // PROCESS_LIB_TES_FEM_H_
32.9375
80
0.701274
[ "vector" ]
cca3e43159e9bc77cd4d5977594307c0bc2b4146
334,415
c
C
plugin/proto/pluginproto.c
bsed/zimbuw32
19afa781012818ed756f86a2af31090e57d51bbc
[ "Apache-2.0" ]
3
2021-04-29T08:20:15.000Z
2021-08-07T13:06:40.000Z
plugin/proto/pluginproto.c
bsed/zimbuw32
19afa781012818ed756f86a2af31090e57d51bbc
[ "Apache-2.0" ]
null
null
null
plugin/proto/pluginproto.c
bsed/zimbuw32
19afa781012818ed756f86a2af31090e57d51bbc
[ "Apache-2.0" ]
null
null
null
/* * Generated from Zimbu file plugin/proto/pluginproto.zu */ #include <string.h> #include <errno.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <ctype.h> #include <stdio.h> #include <signal.h> #if defined(__MINGW32__) || defined(_MSC_VER) # define GC_SIG SIGABRT # include <excpt.h> #else # define GC_SIG SIGUSR2 #endif #include <sys/time.h> #include <time.h> /* * TYPEDEFS */ #ifdef __MINGW32__ # define ZINT_FORMAT "%I64d" # define ZNAT_FORMAT "%I64u" # define ZINT_XFORMAT "%I64x" #else # define ZINT_FORMAT "%lld" # define ZNAT_FORMAT "%llu" # define ZINT_XFORMAT "%llx" #endif #define ZFLOAT_FORMAT "%g" typedef long long Ti; /* int */ typedef short Ti16; /* int16 */ typedef int Ti32; /* int32 */ typedef unsigned long long Tu; /* nat */ typedef unsigned char Tc; /* byte */ typedef unsigned short Tu16; /* nat16 */ typedef unsigned int Tu32; /* nat32 */ typedef double Tf; /* float */ typedef float Tf32; /* float32 */ typedef __INTPTR_TYPE__ Tip; /* int for pointer */ typedef long long Tbb; /* big BITS */ typedef int Tbs; /* small BITS */ typedef int Tb; /* bool */ typedef int Ts; /* status */ typedef int Te; /* enum */ typedef struct Zref__S Tr; /* object ref */ typedef struct Zobj__S To; /* object description */ typedef union { Ti ival; Tf fval; void *ptr; } Tz; /* dyn value */ typedef struct Ztype__S Tt; /* type */ typedef struct Ztypeo__S Tto; /* type with To pointer */ #define ZOH_OFF 0 typedef struct ZforList__S Tfl; /* FOR in list */ typedef struct ZforRange__S Tfr; /* FOR in range */ typedef struct CArray__S Ta; /* array head */ typedef struct CListHead__S Tl; /* list head */ typedef unsigned long Zhashtype; typedef struct CDictItem__S CDictItem; typedef struct CDictHead__S Td; /* including TIMEModule typedefs */ typedef struct Y2KX__S Y2KX; /* MTIMEModule.Values */ /* TIMEModule done */ /* including EModule typedefs */ typedef struct Ytlm__S Ytlm; /* MEModule.Exception */ typedef struct YEro__S YEro; /* MEModule.Exit */ typedef struct YKhn__S YKhn; /* MEModule.OutOfMemory */ typedef struct Y1uN__S Y1uN; /* MEModule.NilAccess */ typedef struct YAxe__S YAxe; /* MEModule.MemoryAccess */ typedef struct YVNj__S YVNj; /* MEModule.Init */ typedef struct Yalz__S Yalz; /* MEModule.BadValue */ typedef struct Yw3O__S Yw3O; /* MEModule.OutOfRange */ typedef struct Y2EX__S Y2EX; /* MEModule.KeyNotFound */ typedef struct YX0i__S YX0i; /* MEModule.KeyExists */ typedef struct YP_P__S YP_P; /* MEModule.IllegalByte */ typedef struct YzSI__S YzSI; /* MEModule.DivideByZero */ typedef struct YXKl__S YXKl; /* MEModule.IOError */ typedef struct YuDC__S YuDC; /* MEModule.WrongType */ typedef struct YrHq__S YrHq; /* MEModule.Internal */ /* EModule done */ /* including ZModule typedefs */ typedef struct YkxB__S YkxB; /* MZModule.Pos */ /* ZModule done */ /* including IOModule typedefs */ typedef struct Yw8L__S Yw8L; /* MIOModule.File */ typedef struct YjUM__S YjUM; /* MIOModule.StringWriter */ /* IOModule done */ /* including SETModule typedefs */ typedef struct Yhqr__S Yhqr; /* MSETModule.Set__t1 */ typedef struct Ygqr__S Ygqr; /* MSETModule.Set__t2 */ /* SETModule done */ /* including ARGModule typedefs */ typedef struct YnU5__S YnU5; /* MARGModule.Status */ typedef struct YuMQ__S YuMQ; /* MARGModule.Usage */ typedef struct Y86c__S Y86c; /* MARGModule.Bool */ typedef struct YJQu__S YJQu; /* MARGModule.Int */ typedef struct YzqH__S YzqH; /* MARGModule.String */ typedef struct Y_SI__S Y_SI; /* MARGModule.StringList */ /* ARGModule done */ /* including ParseProto typedefs */ /* including EnumItem typedefs */ typedef struct Y2Kp__S Y2Kp; /* EnumItem */ typedef struct YFk1__S YFk1; /* CEnumItem.Value */ /* EnumItem done */ /* including MessageItem typedefs */ /* including FieldItem typedefs */ typedef struct Y0uC__S Y0uC; /* FieldItem */ /* FieldItem done */ /* including OptionItem typedefs */ /* including PToken typedefs */ typedef struct Ykeq__S Ykeq; /* PToken */ /* PToken done */ typedef struct Yswy__S Yswy; /* OptionItem */ /* OptionItem done */ typedef struct YRAB__S YRAB; /* MessageItem */ /* MessageItem done */ /* including ProtoFile typedefs */ typedef struct YP_l__S YP_l; /* ProtoFile */ /* ProtoFile done */ /* including ServiceItem typedefs */ /* including RpcItem typedefs */ typedef struct YlM3__S YlM3; /* RpcItem */ /* RpcItem done */ typedef struct YNW5__S YNW5; /* ServiceItem */ /* ServiceItem done */ /* including PTokenInput typedefs */ /* including Input typedefs */ typedef struct YeYq__S YeYq; /* Input */ /* Input done */ typedef struct YuI4__S YuI4; /* PTokenInput */ /* PTokenInput done */ /* ParseProto done */ /* * STRUCTS */ /* IO.eof */ #define Y3QJ EOF typedef struct { int line; int col; } Tcpos; typedef struct { Ti offset; Tc *fileName; Tc *methodName; Tcpos *table; } Tcode; void *Za(size_t size); void *ZaNm(size_t size); void *ZaNmi(size_t size); void *Zran(void *op, size_t osize, size_t nsize); void *ZranNm(void *op, size_t osize, size_t nsize); void ZthrowOutOfMemory(Ti size); char *emergencyAlloc = NULL; size_t emergencyAllocUsed = 0; void ZthrowDeadly(int nr); Tc *ZnewString(Tc *p, Ti len); void ZthrowCstringNil(char *text); void ZthrowCstringBadValue(char *msg); void ZthrowInternal(Tc *t); Tc *Zenum2string(char **names, Te n); char *ZgetCstring(Tc *s); struct ZforList__S { Tl *l; Ti i; Ti *keyp; void *valp; }; struct ZforRange__S { Ti idx; Ti step; Ti last; }; void ZthrowObject(Tr *eo); void ZthrowIobject(Tr eo); struct Zref__S { void *ptr; Tc **table; int type; }; Tr trZero = {NULL,NULL,0}; struct Zobj__S { int off; Tt *type; }; struct Ztype__S { int nr; Tc *name; void *ToString; }; struct Ztypeo__S { int nr; Tc *name; void *ToString; To *to; }; extern Tt bool__T; extern Tt byte__T; extern Tt byteString__T; extern Tt float128__T; extern Tt float32__T; extern Tt float80__T; extern Tt float__T; extern Tt int16__T; extern Tt int32__T; extern Tt int8__T; extern Tt int__T; extern Tt nat16__T; extern Tt nat32__T; extern Tt nat__T; extern Tt status__T; extern Tt string__T; extern Tt type__T; extern Tt array__T; extern Tt list__T; extern Tt dict__T; extern Tt iobj__T; struct CArray__S { void *ptr; int dim; Ti size[3]; Tt *itemType; int itemSize; int tosNr; }; void ZfreeArray(Ta *head); Ta *ZnewArray(Tt *itemType, int itemSize, Ti size); struct CListHead__S { Tt *itemType; void **items; Ti empty; Ti space; Ti itemCount; int itemSize; int tosNr; }; Tl *ZLa(Tl *head, Ti after, Tz val); Tl *ZnewList(Tt *itemType, Ti size); Tl *ZLap(Tl *head, Tz val); void *ZListGetPtr(Tl *head, Ti idx); void *ZListRemovePtrItem(Tl *head, Ti idx); #define HT_INIT_SIZE 16 #define PERTURB_SHIFT 5 #define DTYPE_ORDERED 1 /* dict with list to keep order of items */ #define CDI_FLAG_USED 1 #define CDI_FLAG_DEL 2 struct CDictItem__S { Zhashtype hash; union { Tz key; Tr iokey; }; union { Tz item; Tr ioitem; }; CDictItem *lnext; CDictItem *lprev; int flags; }; struct CDictHead__S { Zhashtype mask; Zhashtype used; Zhashtype extra; Zhashtype filled; int tosNr; int type; CDictItem *array; CDictItem smallArray[HT_INIT_SIZE]; Tt *keyType; Tt *itemType; int (*eqfunc)(void *i, Tz *v); CDictItem *first; CDictItem *last; }; YkxB *MZ__callerPos(void); Tl *MZ__backtrace(Ti zkip, Ti limit); YkxB *MZ__posnr2pos(YkxB *t, Ti pos); typedef struct { char text[5]; } Zs5; /* including TIMEModule structs */ typedef struct { char text[3]; } Zs3; struct Y2KX__S { Ti Vusec; Ti Vsec; Ti Vmin; Ti Vhour; Ti Vday; Ti Vmonth; Ti Vyear; Ti VweekDay; Ti VyearDay; Te Vdst; }; extern Tto Y2KX__T; typedef struct { char text[8]; } Zs8; /* TIMEModule done */ /* including EModule structs */ typedef struct { char text[4]; } Zs4; typedef struct { char text[13]; } Zs13; typedef struct { char text[11]; } Zs11; typedef struct { char text[39]; } Zs39; typedef struct { char text[12]; } Zs12; struct Ytlm__S { Tc *Vmessage; YkxB *Vpos; Tl *Vbacktrace; }; extern Tto Ytlm__T; typedef struct { char text[7]; } Zs7; struct YEro__S { Tc *Vmessage; YkxB *Vpos; Tl *Vbacktrace; Ti Vvalue; }; extern Tto YEro__T; typedef struct { char text[6]; } Zs6; typedef struct { char text[28]; } Zs28; typedef struct { char text[9]; } Zs9; struct YKhn__S { Tc *Vmessage; YkxB *Vpos; Tl *Vbacktrace; }; extern Tto YKhn__T; struct Y1uN__S { Tc *Vmessage; YkxB *Vpos; Tl *Vbacktrace; }; extern Tto Y1uN__T; struct YAxe__S { Tc *Vmessage; YkxB *Vpos; Tl *Vbacktrace; }; extern Tto YAxe__T; typedef struct { char text[14]; } Zs14; struct YVNj__S { Tc *Vmessage; YkxB *Vpos; Tl *Vbacktrace; }; extern Tto YVNj__T; struct Yalz__S { Tc *Vmessage; YkxB *Vpos; Tl *Vbacktrace; }; extern Tto Yalz__T; typedef struct { char text[10]; } Zs10; struct Yw3O__S { Tc *Vmessage; YkxB *Vpos; Tl *Vbacktrace; }; extern Tto Yw3O__T; struct Y2EX__S { Tc *Vmessage; YkxB *Vpos; Tl *Vbacktrace; }; extern Tto Y2EX__T; typedef struct { char text[17]; } Zs17; typedef struct { char text[18]; } Zs18; struct YX0i__S { Tc *Vmessage; YkxB *Vpos; Tl *Vbacktrace; }; extern Tto YX0i__T; typedef struct { char text[22]; } Zs22; typedef struct { char text[23]; } Zs23; struct YP_P__S { Tc *Vmessage; YkxB *Vpos; Tl *Vbacktrace; }; extern Tto YP_P__T; struct YzSI__S { Tc *Vmessage; YkxB *Vpos; Tl *Vbacktrace; }; extern Tto YzSI__T; struct YXKl__S { Tc *Vmessage; YkxB *Vpos; Tl *Vbacktrace; }; extern Tto YXKl__T; typedef struct { char text[15]; } Zs15; struct YuDC__S { Tc *Vmessage; YkxB *Vpos; Tl *Vbacktrace; }; extern Tto YuDC__T; struct YrHq__S { Tc *Vmessage; YkxB *Vpos; Tl *Vbacktrace; }; extern Tto YrHq__T; /* EModule done */ /* including ZModule structs */ typedef struct { char text[16]; } Zs16; struct YkxB__S { Tc *Vfilename; Ti Vlnum; Ti Vcol; Tc *Vtext; }; extern Tto YkxB__T; /* ZModule done */ /* including IOModule structs */ typedef struct { char text[27]; } Zs27; typedef struct { char text[30]; } Zs30; typedef struct { char text[19]; } Zs19; struct Yw8L__S { FILE * Vfd; Tc *Vname; }; extern Tto Yw8L__T; typedef struct { char text[2]; } Zs2; typedef struct { char text[53]; } Zs53; struct YjUM__S { Ti VsLen; Ta *Vs; Tc *Vx; }; extern Tto YjUM__T; /* IOModule done */ /* including LOGModule structs */ typedef struct { char text[45]; } Zs45; /* LOGModule done */ /* including SETModule structs */ struct Yhqr__S { Td *Vdict; }; extern Tto Yhqr__T; struct Ygqr__S { Td *Vdict; }; extern Tto Ygqr__T; /* SETModule done */ /* including ARGModule structs */ struct YnU5__S { }; extern Tto YnU5__T; typedef struct { char text[51]; } Zs51; typedef struct { char text[56]; } Zs56; typedef struct { char text[20]; } Zs20; typedef struct { char text[29]; } Zs29; typedef struct { char text[31]; } Zs31; typedef struct { char text[43]; } Zs43; typedef struct { char text[21]; } Zs21; typedef struct { char text[24]; } Zs24; struct YuMQ__S { Tc *Vtext; }; extern Tto YuMQ__T; typedef struct { char text[42]; } Zs42; typedef struct { char text[50]; } Zs50; typedef struct { char text[52]; } Zs52; typedef struct { char text[32]; } Zs32; struct Y86c__S { Tc *VshortName; Tc *VlongName; Tc *Vdoc; Tc *VargName; Ti VsetCount; Tb VcanRepeat; Tb VnoCompactVal; Tb VargOpt; YkxB *Vpos; Tb Vcurrent; Tb Vdefault; }; extern Tto Y86c__T; struct YJQu__S { Tc *VshortName; Tc *VlongName; Tc *Vdoc; Tc *VargName; Ti VsetCount; Tb VcanRepeat; Tb VnoCompactVal; Tb VargOpt; YkxB *Vpos; Ti Vcurrent; Ti Vdefault; Tl *VtheValueList; }; extern Tto YJQu__T; struct YzqH__S { Tc *VshortName; Tc *VlongName; Tc *Vdoc; Tc *VargName; Ti VsetCount; Tb VcanRepeat; Tb VnoCompactVal; Tb VargOpt; YkxB *Vpos; Tc *Vcurrent; Tc *Vdefault; Tl *VtheValueList; }; extern Tto YzqH__T; struct Y_SI__S { Tc *VshortName; Tc *VlongName; Tc *Vdoc; Tc *VargName; Ti VsetCount; Tb VcanRepeat; Tb VnoCompactVal; Tb VargOpt; YkxB *Vpos; Tl *Vcurrent; Tl *Vdefault; }; extern Tto Y_SI__T; /* ARGModule done */ /* including ParseProto structs */ /* including EnumItem structs */ struct YFk1__S { Tc *Vid; Ti Vnr; YkxB *Vpos; }; extern Tto YFk1__T; typedef struct { char text[26]; } Zs26; struct Y2Kp__S { Tc *Vname; Tl *Vmembers; }; extern Tto Y2Kp__T; /* EnumItem done */ /* including MessageItem structs */ /* including FieldItem structs */ /* including Proto structs */ char *MProto__EType[] = { (char*)20, "unknown", "bool", "bytes", "enum", "fixed32", "fixed64", "float", "double", "group", "int", "int32", "int64", "message", "sfixed32", "sfixed64", "sint32", "sint64", "string", "uint32", "uint64", }; char *MProto__EType__name(Te n) { return (n < 0 || n >= (Te)(size_t)MProto__EType[0]) ? "INVALID" : MProto__EType[n + 1]; }; /* Proto done */ struct Y0uC__S { Tc *Vname; Te Vtype; Tc *VtypeName; Tb Vrequired; Tb Vrepeated; Ti Vnr; Tc *Vdefault; YkxB *Vpos; }; extern Tto Y0uC__T; /* FieldItem done */ /* including OptionItem structs */ /* including PToken structs */ struct Ykeq__S { Te Vtype; Tc *Vvalue; YkxB *VstartPos; YkxB *VendPos; }; extern Tto Ykeq__T; /* PToken done */ struct Yswy__S { Tc *Vname; YkxB *Vpos; Te Vtype; Tc *Vvalue; }; extern Tto Yswy__T; /* OptionItem done */ typedef struct { char text[25]; } Zs25; struct YRAB__S { Tr Vparent; Tc *Vname; Tl *Vfields; Tl *Vitems; Tl *VoptionList; }; extern Tto YRAB__T; /* MessageItem done */ /* including ProtoFile structs */ struct YP_l__S { Tc *Vpackage; Tl *Vimports; Tl *VitemList; Td *VitemDict; }; extern Tto YP_l__T; /* ProtoFile done */ /* including ServiceItem structs */ /* including RpcItem structs */ struct YlM3__S { Tc *Vname; Tc *VrequestName; Tc *VresponseName; }; extern Tto YlM3__T; /* RpcItem done */ struct YNW5__S { Tc *Vname; Tl *Vrpcs; }; extern Tto YNW5__T; /* ServiceItem done */ /* including PTokenInput structs */ /* including Input structs */ struct YeYq__S { Tr Vfd; Tc *Vtext; Ti VtextIdx; YkxB *Vpos; Ti VprevLineCol; Tl *VcharStack; Tc *Vindent; Tb VallowTabs; YjUM *VrecordWriter; }; extern Tto YeYq__T; /* Input done */ struct YuI4__S { YeYq *Vinput; Tl *VtokenStack; }; extern Tto YuI4__T; /* PTokenInput done */ typedef struct { char text[33]; } Zs33; typedef struct { char text[35]; } Zs35; /* ParseProto done */ /* including WriteZimbu structs */ typedef struct { char text[40]; } Zs40; typedef struct { char text[61]; } Zs61; typedef struct { char text[72]; } Zs72; typedef struct { char text[57]; } Zs57; typedef struct { char text[47]; } Zs47; typedef struct { char text[55]; } Zs55; typedef struct { char text[48]; } Zs48; typedef struct { char text[46]; } Zs46; typedef struct { char text[78]; } Zs78; typedef struct { char text[54]; } Zs54; typedef struct { char text[65]; } Zs65; typedef struct { char text[62]; } Zs62; typedef struct { char text[69]; } Zs69; typedef struct { char text[38]; } Zs38; typedef struct { char text[34]; } Zs34; typedef struct { char text[49]; } Zs49; typedef struct { char text[41]; } Zs41; /* WriteZimbu done */ /* * DECLARE FUNCTIONS AND GLOBALS */ Zs5 ZNilString = {"\003NIL\000"}; /* including TIMEModule declarations */ Ti Y9Rj(); /* MTIMEModule.current */ Y2KX *YgaY(Y2KX *t); /* MTIMEModule__CValues.NEW */ Y2KX *YgaYb(Y2KX *t, Ti Ausec); /* MTIMEModule__CValues.NEW */ Tc *YYTs(Y2KX *t); /* MTIMEModule__CValues.ToString */ Zs3 YV = {"\001/\000"}; Zs5 Y6O7 = {"\00302d\000"}; Zs3 YG = {"\001 \000"}; Zs3 Y5 = {"\001:\000"}; To ToY2KX[1]; Zs8 YeCO = {"\006Values\000"}; Tt MTIMEModule__EDst__T = {23, 0, 0}; /* TIMEModule done */ /* including EModule declarations */ void YxaJ(Ytlm *t, Tr Aw); /* MEModule__CException.writeTo */ Zs4 YFDa = {"\002: \000"}; Zs13 YHbP = {"\013Exception: \000"}; Zs11 YDGe = {"\011Exception\000"}; void YxaJa(Ytlm *t, Tb Averbose, Tr Aw); /* MEModule__CException.writeTo */ Zs39 Y62e = {"\045\nStack backtrace (last called first):\000"}; Zs12 Yv6_ = {"\012\n(unknown)\000"}; Zs3 Yk = {"\001\n\000"}; To ToYtlm[4]; void YXHSa(YEro *t, Tr Aw); /* MEModule__CExit.writeTo */ Zs7 YxJ1 = {"\005EXIT \000"}; void YEro__YxaJa(YEro *t, Tb Averbose, Tr Aw); /* MEModule__CExit.writeTo__p1 */ To ToYEro[4]; Zs6 YJMo = {"\004Exit\000"}; YKhn *YDNob(YKhn *t, Ti Asize, Ti Alimit); /* MEModule__COutOfMemory.NEW */ Zs28 YIBz = {"\032Out of memory (allocating \000"}; Zs9 YDSH = {"\007 bytes)\000"}; void YKhn__YwtA__YxaJa(YKhn *t, Tb Averbose, Tr Aw); /* MEModule__COutOfMemory.writeTo__p2 */ void YKhn__YwtA__YxaJ(YKhn *t, Tr Aw); /* MEModule__COutOfMemory.writeTo__p2 */ Tc *YKhn__Ytlm_I_imt[14]; To ToYKhn[4]; Zs13 Y9Fv = {"\013OutOfMemory\000"}; void Y1KV(Ti Asize); /* MEModule.throwOutOfMemorySize */ Y1uN *Y1uN__YwtA__YRHR(Y1uN *t, Tc *Amsg); /* MEModule__CNilAccess.NEW__p2 */ void Y1uN__YwtA__YxaJa(Y1uN *t, Tb Averbose, Tr Aw); /* MEModule__CNilAccess.writeTo__p2 */ void Y1uN__YwtA__YxaJ(Y1uN *t, Tr Aw); /* MEModule__CNilAccess.writeTo__p2 */ Tc *Y1uN__Ytlm_I_imt[14]; To ToY1uN[4]; Zs11 Y4wO = {"\011NilAccess\000"}; void YvdV(YkxB *Apos, Tc *Atext); /* MEModule.throwNil */ YAxe *YAxe__YwtA__YRHR(YAxe *t, Tc *Amsg); /* MEModule__CMemoryAccess.NEW__p2 */ void YAxe__YwtA__YxaJa(YAxe *t, Tb Averbose, Tr Aw); /* MEModule__CMemoryAccess.writeTo__p2 */ void YAxe__YwtA__YxaJ(YAxe *t, Tr Aw); /* MEModule__CMemoryAccess.writeTo__p2 */ Tc *YAxe__Ytlm_I_imt[14]; To ToYAxe[4]; Zs14 Y4QW = {"\014MemoryAccess\000"}; void YE93(Ti Anr); /* MEModule.throwDeadly */ Zs13 YkfG = {"\013signal SEGV\000"}; Zs12 YoEx = {"\012signal FPE\000"}; Zs12 YQNH = {"\012signal BUS\000"}; Zs9 YpCZ = {"\007signal \000"}; YVNj *YVNj__YwtA__YRHRa(YVNj *t, YkxB *Apos, Tc *Amsg); /* MEModule__CInit.NEW__p2 */ YVNj *YVNj__YwtA__YRHR(YVNj *t, Tc *Amsg); /* MEModule__CInit.NEW__p2 */ void YVNj__YwtA__YxaJa(YVNj *t, Tb Averbose, Tr Aw); /* MEModule__CInit.writeTo__p2 */ void YVNj__YwtA__YxaJ(YVNj *t, Tr Aw); /* MEModule__CInit.writeTo__p2 */ Tc *YVNj__Ytlm_I_imt[14]; To ToYVNj[4]; Zs6 Ysqt = {"\004Init\000"}; void Y3w6(Tc *Atext); /* MEModule.throwInit */ Yalz *Yalz__YwtA__YRHR(Yalz *t, Tc *Amsg); /* MEModule__CBadValue.NEW__p2 */ void Yalz__YwtA__YxaJa(Yalz *t, Tb Averbose, Tr Aw); /* MEModule__CBadValue.writeTo__p2 */ void Yalz__YwtA__YxaJ(Yalz *t, Tr Aw); /* MEModule__CBadValue.writeTo__p2 */ Tc *Yalz__Ytlm_I_imt[14]; To ToYalz[4]; Zs10 YEZq = {"\010BadValue\000"}; void Yaez(Tc *Atext); /* MEModule.throwBadValue */ Yw3O *Yw3O__Yalz__YwtA__YRHR(Yw3O *t, Tc *Amsg); /* MEModule__COutOfRange.NEW__p3 */ void Yw3O__Yalz__YwtA__YxaJ(Yw3O *t, Tr Aw); /* MEModule__COutOfRange.writeTo__p3 */ void Yw3O__Yalz__YwtA__YxaJa(Yw3O *t, Tb Averbose, Tr Aw); /* MEModule__COutOfRange.writeTo__p3 */ Tc *Yw3O__Ytlm_I_imt[14]; To ToYw3O[4]; Zs12 YFK2 = {"\012OutOfRange\000"}; void Y6NT(Ti Aindex, Tc *Amsg); /* MEModule.throwOutOfRange */ Y2EX *Y2EX__Yalz__YwtA__YRHR(Y2EX *t, Tc *Amsg); /* MEModule__CKeyNotFound.NEW__p3 */ void Y2EX__Yalz__YwtA__YxaJ(Y2EX *t, Tr Aw); /* MEModule__CKeyNotFound.writeTo__p3 */ void Y2EX__Yalz__YwtA__YxaJa(Y2EX *t, Tb Averbose, Tr Aw); /* MEModule__CKeyNotFound.writeTo__p3 */ Tc *Y2EX__Ytlm_I_imt[14]; To ToY2EX[4]; Zs13 YRiW = {"\013KeyNotFound\000"}; void Yxmk(Ti Akey, Tc *Amsg); /* MEModule.throwIntKeyNotFound */ Zs17 Ym6C = {"\017Key not found: \000"}; void Y5LT(Tc *Akey, Tc *Amsg); /* MEModule.throwStringKeyNotFound */ Zs18 YJ3Y = {"\020Key not found: \"\000"}; Zs3 YI = {"\001\"\000"}; YX0i *YX0i__Yalz__YwtA__YRHRa(YX0i *t, YkxB *Apos, Tc *Amsg); /* MEModule__CKeyExists.NEW__p3 */ YX0i *YX0i__Yalz__YwtA__YRHR(YX0i *t, Tc *Amsg); /* MEModule__CKeyExists.NEW__p3 */ void YX0i__Yalz__YwtA__YxaJ(YX0i *t, Tr Aw); /* MEModule__CKeyExists.writeTo__p3 */ void YX0i__Yalz__YwtA__YxaJa(YX0i *t, Tb Averbose, Tr Aw); /* MEModule__CKeyExists.writeTo__p3 */ Tc *YX0i__Ytlm_I_imt[14]; To ToYX0i[4]; Zs11 Y9_h = {"\011KeyExists\000"}; void YL9Z(Ti Akey, Tc *Amsg); /* MEModule.throwIntKeyExists */ Zs22 Y9qa = {"\024Key already exists: \000"}; void YEeX(Tc *Akey, Tc *Amsg); /* MEModule.throwStringKeyExists */ Zs23 YMKM = {"\025Key already exists: \"\000"}; YP_P *YP_P__Yalz__YwtA__YRHR(YP_P *t, Tc *Amsg); /* MEModule__CIllegalByte.NEW__p3 */ void YP_P__Yalz__YwtA__YxaJ(YP_P *t, Tr Aw); /* MEModule__CIllegalByte.writeTo__p3 */ void YP_P__Yalz__YwtA__YxaJa(YP_P *t, Tb Averbose, Tr Aw); /* MEModule__CIllegalByte.writeTo__p3 */ Tc *YP_P__Ytlm_I_imt[14]; To ToYP_P[4]; Zs13 Ydbm = {"\013IllegalByte\000"}; YzSI *YzSI__Ylz1__YwtA__YRHR(YzSI *t, Tc *Amsg); /* MEModule__CDivideByZero.NEW__p3 */ void YzSI__Ylz1__YwtA__YxaJ(YzSI *t, Tr Aw); /* MEModule__CDivideByZero.writeTo__p3 */ void YzSI__Ylz1__YwtA__YxaJa(YzSI *t, Tb Averbose, Tr Aw); /* MEModule__CDivideByZero.writeTo__p3 */ Tc *YzSI__Ytlm_I_imt[14]; To ToYzSI[4]; Zs14 YxFl = {"\014DivideByZero\000"}; YXKl *YXKl__YwtA__YRHR(YXKl *t, Tc *Amsg); /* MEModule__CIOError.NEW__p2 */ void YXKl__YwtA__YxaJa(YXKl *t, Tb Averbose, Tr Aw); /* MEModule__CIOError.writeTo__p2 */ void YXKl__YwtA__YxaJ(YXKl *t, Tr Aw); /* MEModule__CIOError.writeTo__p2 */ Tc *YXKl__Ytlm_I_imt[14]; To ToYXKl[4]; Zs9 YTj3 = {"\007IOError\000"}; YuDC *YdhH(YuDC *t); /* MEModule__CWrongType.NEW */ Zs15 Ynjz = {"\015Type mismatch\000"}; void YuDC__YwtA__YxaJa(YuDC *t, Tb Averbose, Tr Aw); /* MEModule__CWrongType.writeTo__p2 */ void YuDC__YwtA__YxaJ(YuDC *t, Tr Aw); /* MEModule__CWrongType.writeTo__p2 */ Tc *YuDC__Ytlm_I_imt[14]; To ToYuDC[4]; Zs11 YCoZ = {"\011WrongType\000"}; void YTuG(Ti Apos); /* MEModule.throwWrongType */ YrHq *YrHq__YwtA__YRHR(YrHq *t, Tc *Amsg); /* MEModule__CInternal.NEW__p2 */ void YrHq__YwtA__YxaJa(YrHq *t, Tb Averbose, Tr Aw); /* MEModule__CInternal.writeTo__p2 */ void YrHq__YwtA__YxaJ(YrHq *t, Tr Aw); /* MEModule__CInternal.writeTo__p2 */ Tc *YrHq__Ytlm_I_imt[14]; To ToYrHq[4]; Zs10 YVki = {"\010Internal\000"}; void YUSH(YkxB *Apos, Tc *Atext); /* MEModule.throwInternal */ void YxIS(Tr Ae); /* MEModule.unhandledException */ void YvL0(Tr Ae); /* MEModule.writeToStderr */ void YQar(Tr A0, Tb A1, Tr A2); /* Ytlm_I__MwriteTo_I__bool__Yw8L_I */ /* EModule done */ /* including ZModule declarations */ YkxB *Ypp_(YkxB *t, Tc *Afilename); /* MZModule__CPos.NEW */ YkxB *Ypp_a(YkxB *t, Tc *Afilename, Ti Alnum, Ti Acol); /* MZModule__CPos.NEW */ YkxB *Y83A(YkxB *t); /* MZModule__CPos.copy */ void YnS4(YkxB *t); /* MZModule__CPos.nextLine */ Tc *YpI_(YkxB *t); /* MZModule__CPos.ToString */ Zs16 YKo1 = {"\016[unknown file]\000"}; Zs8 YBpY = {"\006 line \000"}; Zs7 Y8ES = {"\005 col \000"}; To ToYkxB[3]; Zs5 YBCs = {"\003Pos\000"}; /* ZModule done */ /* including IOModule declarations */ Ti Y3QJ__NOT = -1 /* MIOModule.eof */; Tr Y59X = {NULL}; /* MIOModule.stdin */ Tr Yb0q = {NULL}; /* MIOModule.stdout */ Tr YeNQ = {NULL}; /* MIOModule.stderr */ Tr Yd89(); /* MIOModule.newStdin */ Tr Yvyt(); /* MIOModule.newStdout */ Tr YsM3(); /* MIOModule.newStderr */ Tc **YdXi__imtt[4]; Ti YFeQ(Yw8L *t); /* MIOModule__CFile.readByte */ Zs18 YQe8 = {"\020File is not open\000"}; Ti YAPp(Yw8L *t); /* MIOModule__CFile.readChar */ Zs27 YPHa = {"\031first byte out of range: \000"}; Zs30 YKzT = {"\034found EOF when getting byte \000"}; Zs7 Ymwv = {"\005byte \000"}; Zs15 YPfW = {"\015 out of range\000"}; Zs19 Y8Gn = {"\021overlong sequence\000"}; Ts YwHoa(Yw8L *t, Tc *Atext); /* MIOModule__CFile.write */ Ts YGmp(Yw8L *t); /* MIOModule__CFile.flush */ Ts YrF8(Yw8L *t); /* MIOModule__CFile.close */ Ts Yw8L__YHhZb(Yw8L *t, Ti Anumber); /* MIOModule__CFile.write__p1 */ Ts Yw8L__YRt7(Yw8L *t, Tc *Atext); /* MIOModule__CFile.print__p1 */ Ts Yw8L__YRt7g(Yw8L *t); /* MIOModule__CFile.print__p1 */ Tc *Yw8L__Yw8L_I_imt[38]; Tc *Yw8L__YdXi_imt[3]; To ToYw8L[2]; Zs6 YtTU = {"\004File\000"}; Tr YsGz(Tc *AfileName); /* MIOModule.fileReader */ Tr YiBk(Tc *AfileName, Tb Atruncate); /* MIOModule.fileWriter */ Ts Yvcu(Tc *Atext); /* MIOModule.write */ Ts Yl0k(Tc *Atext); /* MIOModule.print */ Ts Ylxt(); /* MIOModule.flush */ Ts YJqza(YjUM *t, Tc *Atext); /* MIOModule__CStringWriter.write */ Tc *YbNW(YjUM *t); /* MIOModule__CStringWriter.ToString */ Zs2 Ya = {"\000\000"}; Ti Y6jW(YjUM *t); /* MIOModule__CStringWriter.remove */ Ts YjUM__YHhZb(YjUM *t, Ti Anumber); /* MIOModule__CStringWriter.write__p1 */ Ts YjUM__Ydti(YjUM *t, Ti Achar); /* MIOModule__CStringWriter.writeChar__p1 */ Zs53 Yv8w = {"\063UTF-8 character must be in range 0 - 0x10ffff, got \000"}; Ts YjUM__YRt7(YjUM *t, Tc *Atext); /* MIOModule__CStringWriter.print__p1 */ Tc *YjUM__YdXi_imt[3]; To ToYjUM[3]; Zs14 YE4c = {"\014StringWriter\000"}; int JIOModule(int round); /* IOModule done */ /* including LOGModule declarations */ Zs3 YLa = {"\001d\000"}; Zs7 YGwH = {"\005debug\000"}; Zs12 YhpM = {"\012Debug mode\000"}; Y86c *YU8T = 0; /* MLOGModule.debugFlag */ Zs3 Y2a = {"\001v\000"}; Zs9 YUsn = {"\007verbose\000"}; Zs45 YSuP = {"\053Verbose messages, repeat for more verbosity\000"}; Y86c *YlUb = 0; /* MLOGModule.verboseFlag */ Tt MLOGModule__ELevel__T = {23, 0, 0}; Zs7 YuXA = {"\005Flags\000"}; Tt MLOGModule__BFlags__T = {25, ((Tc*)&YuXA), 0}; Td *Ytd2 = NULL; /* MLOGModule.counts */ Ti Yrpn = 0; /* MLOGModule.errorCount */ void YDli(Tc *Amsg, YkxB *Apos, Tbs Aflags); /* MLOGModule.error */ void Y2oO(Tc *Amsg, YkxB *Apos, Tbs Aflags); /* MLOGModule.internal */ Tc *YmaW = ((Tc*)&Ya) /* MLOGModule.extraLead */; void Ygkj(Te Alevel, Tc *Amsg, YkxB *Apos, Tbs Aflags); /* MLOGModule.log */ Zs11 YJ5p = {"\011INTERNAL \000"}; Zs11 Yyq1 = {"\011Warning: \000"}; Zs9 Y27a = {"\007ERROR: \000"}; Zs16 Y3l3 = {"\016SEVERE ERROR: \000"}; Zs15 YmM8 = {"\015FATAL ERROR: \000"}; Zs3 YU = {"\001.\000"}; Zs5 YwV7 = {"\00306d\000"}; void YwlF(Tr Aout); /* MLOGModule.reportStack */ Zs12 YDzC = {"\012Backtrace:\000"}; Ti YvW3 = 0; /* MLOGModule.lastFlush */ Ti YOwl = 300000 /* MLOGModule.flushInterval */; void Y7LJ(); /* MLOGModule.flush */ Tr Yz2b = {NULL}; /* MLOGModule.logFile */ Tb YiAD = 1 /* MLOGModule.useTimeStamp */; int JLOGModule(int round); /* LOGModule done */ /* including SETModule declarations */ int Ypau__r = 0; /* MSETModule__CSet__t1.Ready */ Yhqr *Ypau(Yhqr *t); /* MSETModule__CSet__t1.Init */ Yhqr *Yh95(Yhqr *t); /* MSETModule__CSet__t1.NEW */ Tb YyHa(Yhqr *t, Ti Akey); /* MSETModule__CSet__t1.has */ Yhqr *YGMT(Yhqr *t, Ti Akey); /* MSETModule__CSet__t1.add */ Zs23 YLLX = {"\025key already present: \000"}; To ToYhqr[2]; Zs9 Yehz = {"\007Set__t1\000"}; int YuFZ__r = 0; /* MSETModule__CSet__t2.Ready */ Ygqr *YuFZ(Ygqr *t); /* MSETModule__CSet__t2.Init */ Ygqr *YGrg(Ygqr *t); /* MSETModule__CSet__t2.NEW */ Tb YXZk(Ygqr *t, Tc *Akey); /* MSETModule__CSet__t2.has */ Ygqr *Y432(Ygqr *t, Tc *Akey); /* MSETModule__CSet__t2.add */ To ToYgqr[2]; Zs9 Yfhz = {"\007Set__t2\000"}; /* SETModule done */ /* including ARGModule declarations */ Tc *YzvW = NULL; /* MARGModule.rawName */ Tl *Y1p3 = NULL; /* MARGModule.rawArgs */ Tl *Y6fX = NULL; /* MARGModule.cleanArgs */ Tb YQpY = 0; /* MARGModule.stopFlag */ Tb YUBd = 0; /* MARGModule.disabled */ Tb YhUP = 0; /* MARGModule.disableGiveHelp */ Tb Y_kI = 0; /* MARGModule.disableCompactVal */ Ti YMLU = 1 /* MARGModule.exitVal */; YuMQ *Yun4 = 0; /* MARGModule.theUsage */ int Ytu___r = 0; /* MARGModule.Ready */ Ts Ytu_(); /* MARGModule.Init */ Ti Yd2Z(); /* MARGModule.Size */ Tc *YtgL(Ti Aindex); /* MARGModule.get */ To ToYnU5[1]; Zs8 Yr32 = {"\006Status\000"}; void YY8i(); /* MARGModule.initCheck */ Zs51 YeBP = {"\061Using command line flag before they are available\000"}; void YZH8(); /* MARGModule.init */ Zs56 Y7T_ = {"\066ARG.disable() used but command line flags were defined\000"}; Zs3 YT = {"\001-\000"}; Zs4 Y1ia = {"\002--\000"}; Zs6 YqzQ = {"\004help\000"}; Zs10 Y3vi = {"\010morehelp\000"}; Zs10 Yll7 = {"\010helpmore\000"}; Zs4 YhZb = {"\002no\000"}; Zs20 YcW8 = {"\022Invalid argument: \000"}; Zs29 Y2hB = {"\033Unknown command line flag: \000"}; Zs31 YcLH = {"\035Duplicate command line flag: \000"}; Zs5 YjK7 = {"\003yes\000"}; Zs6 YsfP = {"\004true\000"}; Zs7 YvpX = {"\005false\000"}; Zs43 YHSJ = {"\051Expected 'yes', 'no', 'true' or 'false': \000"}; Zs19 Y6QK = {"\021Unexpected = in: \000"}; Zs28 Y_ju = {"\032Missing argument for flag \000"}; Zs29 YjTs = {"\033INTERNAL: unknown flag type\000"}; void YSUO(Tc *Amsg); /* MARGModule.error */ Zs22 YkFE = {"\024To list flags use: '\000"}; Zs10 Y15F = {"\010 --help'\000"}; void Yfj5(Tb Averbose); /* MARGModule.displayHelp */ Zs21 YaBy = {"\023Command line flags:\000"}; Zs13 YwXF = {"\013--morehelp \000"}; Zs24 YEcf = {"\026show more verbose help\000"}; Zs8 Yy2p = {"\006number\000"}; Zs8 YanE = {"\006string\000"}; Zs12 YDci = {"\012string ...\000"}; Zs6 YulU = {"\004 ...\000"}; Zs4 YVZ = {"\002 [\000"}; Zs3 YEa = {"\001]\000"}; Zs4 Yq_ = {"\002 {\000"}; Zs3 Y9a = {"\001}\000"}; Zs5 Y_y2 = {"\003...\000"}; Zs6 Y2yA = {"\004... \000"}; Zs13 Ym4c = {"\013Defined in \000"}; void YTlu(Tc *Alead, Ti AmaxLeadLen); /* MARGModule.writeLead */ Tc *YAMW(YuMQ *t); /* MARGModule__CUsage.get */ Zs5 YMtG = {"\003%0%\000"}; To ToYuMQ[2]; Zs7 Y6qT = {"\005Usage\000"}; Td *Y7be = NULL; /* MARGModule.shortFlags */ Td *YBQy = NULL; /* MARGModule.longFlags */ Y86c *YttT(Y86c *t, Tc *AshortName, Tc *AlongName, Tb Adefault, Tc *Adoc); /* MARGModule__CBool.NEW */ void YEqoa(Y86c *t); /* MARGModule__CBool.setToDefault */ Tb YHoR(Y86c *t); /* MARGModule__CBool.get */ Tb YuOS(Y86c *t); /* MARGModule__CBool.value */ Y86c *Y86c__YcLu(Y86c *t, Tc *AshortName, Tc *AlongName, Tc *Adoc, YkxB *Apos); /* MARGModule__CBool.NEW__p1 */ Zs42 Yc_h = {"\050Adding command line flag after using one\000"}; Zs50 Y6pY = {"\060Command line flag must have a short or long name\000"}; Zs52 Y9CP = {"\062short command line flag name must be one character\000"}; void Y86c__YofP(Y86c *t, Tc *Aname, Tr Aflag, YkxB *Apos); /* MARGModule__CBool.throwDuplicate__p1 */ Zs9 YbbH = {"\007unknown\000"}; Zs32 YtzG = {"\036Duplicate command line flag: '\000"}; Zs17 YDyy = {"\017' also used at \000"}; Ti Y86c__Ye9f(Y86c *t); /* MARGModule__CBool.presentCount__p1 */ Tc *Y86c__YuQR_I_imt[19]; To ToY86c[6]; Zs6 YZ1F = {"\004Bool\000"}; void Y49ga(YJQu *t); /* MARGModule__CInt.setToDefault */ To ToYJQu[7]; Zs5 YzBa = {"\003Int\000"}; void YJaza(YzqH *t); /* MARGModule__CString.setToDefault */ To ToYzqH[9]; Zs8 YDAE = {"\006String\000"}; void YSkKa(Y_SI *t); /* MARGModule__CStringList.setToDefault */ To ToY_SI[8]; Zs12 Ygf5 = {"\012StringList\000"}; int JARGModule(int round); /* ARGModule done */ /* including ParseProto declarations */ /* including EnumItem declarations */ Y2Kp *YIur(Y2Kp *t); /* CEnumItem.NEW */ void Y_Nc(Y2Kp *t, Tc *Aname, Ti Anr, YkxB *Apos); /* CEnumItem.addValue */ To ToYFk1[3]; Zs7 YmNk = {"\005Value\000"}; Ts YXXO(Y2Kp *t); /* CEnumItem.checkErrors */ Zs26 Y_xt = {"\030Enum number used again: \000"}; Tc *Y2Kp__YuXI_imt[2]; To ToY2Kp[3]; Zs10 Ym3J = {"\010EnumItem\000"}; /* EnumItem done */ /* including MessageItem declarations */ /* including FieldItem declarations */ /* including Proto declarations */ Tt MProto__EType__T = {23, 0, MProto__EType__name}; /* Proto done */ Tc *YULH(Y0uC *t); /* CFieldItem.memberName */ Zs5 YliF = {"\003$f_\000"}; Tc *YFlx(Y0uC *t); /* CFieldItem.hasMemberName */ Zs7 YZYy = {"\005$has_\000"}; Tc *YqGL(Y0uC *t); /* CFieldItem.funcName */ Zs5 Y1Qt = {"\003int\000"}; Zs7 YrQi = {"\005int32\000"}; Zs8 YJyN = {"\006uint32\000"}; Zs7 YhVi = {"\005int64\000"}; Zs8 YzDN = {"\006uint64\000"}; Zs7 Yt7n = {"\005float\000"}; Zs8 Ygep = {"\006double\000"}; Zs6 YtPw = {"\004bool\000"}; Td *YGNu = NULL; /* CFieldItem__X.typeDict */ Te YKJX(Tc *AtypeName); /* CFieldItem__X.getType */ To ToY0uC[5]; Zs11 Y5D2a = {"\011FieldItem\000"}; int JFieldItem(int round); /* FieldItem done */ /* including OptionItem declarations */ /* including PToken declarations */ Tt CPToken__EType__T = {23, 0, 0}; To ToYkeq[4]; Zs8 YgVD = {"\006PToken\000"}; /* PToken done */ To ToYswy[4]; Zs12 YcBr = {"\012OptionItem\000"}; /* OptionItem done */ YRAB *YI6R(YRAB *t); /* CMessageItem.NEW */ void YNVJ(YRAB *t, Yswy *Aoption); /* CMessageItem.addOption */ Zs12 YLP5 = {"\012extensible\000"}; Tr YBZe(YRAB *t, Tc *Aname); /* CMessageItem.findItem */ Ts YbaL(YRAB *t); /* CMessageItem.checkErrors */ Zs27 YUra = {"\031Field number used again: \000"}; Zs25 Yy3i = {"\027Field name used again: \000"}; Tc *YRAB__YuXI_imt[2]; Tc *YRAB__Ytv2_imt[2]; To ToYRAB[6]; Zs13 YQoy = {"\013MessageItem\000"}; int JMessageItem(int round); /* MessageItem done */ /* including ProtoFile declarations */ YP_l *Yy3W(YP_l *t); /* CProtoFile.NEW */ void YhB6(YP_l *t, Tr Aitem); /* CProtoFile.addItem */ void YYPi(YP_l *t, Yswy *Aoption); /* CProtoFile.addOption */ Tr YKwR(YP_l *t, Tc *Aname); /* CProtoFile.findItem */ Tc *YP_l__Ytv2_imt[2]; To ToYP_l[5]; Zs11 YU8M = {"\011ProtoFile\000"}; /* ProtoFile done */ /* including ServiceItem declarations */ /* including RpcItem declarations */ YlM3 *YwLI(YlM3 *t, Tc *Aname); /* CRpcItem.NEW */ Tc *YlM3__YuXI_imt[2]; To ToYlM3[4]; Zs9 YWB_ = {"\007RpcItem\000"}; /* RpcItem done */ YNW5 *Y_oR(YNW5 *t); /* CServiceItem.NEW */ void YBM3(YNW5 *t, YlM3 *Arpc); /* CServiceItem.add */ Tr Y96y(YNW5 *t, Tc *Aname); /* CServiceItem.findItem */ Tc *YNW5__YuXI_imt[2]; To ToYNW5[3]; Zs13 YMK2 = {"\013ServiceItem\000"}; /* ServiceItem done */ /* including PTokenInput declarations */ /* including Input declarations */ YeYq *YOdr(YeYq *t, Tr Afd, Tc *Afname, Tc *Aindent, Tb Arecord); /* CInput.NEW */ Ti YAit(YeYq *t); /* CInput.get */ Zs21 YrKy = {"\023found NUL character\000"}; Zs21 YemR = {"\023found Tab character\000"}; Zs25 Y3Pw = {"\027found control character\000"}; void YmK2(YeYq *t, Ti Ac); /* CInput.push */ To ToYeYq[7]; Zs7 YVUW = {"\005Input\000"}; /* Input done */ /* including PTokenize declarations */ Ykeq *Y7Z3(YuI4 *Ain); /* MPTokenize.get */ Zs22 YD4M = {"\024missing double quote\000"}; Zs22 YYrm = {"\024missing single quote\000"}; Zs27 YtNZ = {"\031Unrecognized character: '\000"}; Zs3 YN = {"\001'\000"}; void YVn_(YuI4 *Ain); /* MPTokenize.skipWhite */ Tb YdpE(Ti Ac); /* MPTokenize.isIdChar */ Zs9 YpLJ = {"\007default\000"}; Zs6 Y89Q = {"\004enum\000"}; Zs9 YL0B = {"\007message\000"}; Zs8 YXqe = {"\006option\000"}; Zs10 Yveu = {"\010optional\000"}; Zs9 Yg9u = {"\007package\000"}; Zs10 Ygug = {"\010repeated\000"}; Zs10 YJcg = {"\010required\000"}; Zs9 Yiu9 = {"\007returns\000"}; Zs5 Yf1Q = {"\003rpc\000"}; Zs9 YmU3 = {"\007service\000"}; Td *YwVY = NULL; /* MPTokenize.keywords */ int JPTokenize(int round); /* PTokenize done */ YuI4 *YW5n(YuI4 *t, Tr Afd, Tc *Afname, Tc *Aindent); /* CPTokenInput.NEW */ Ti YIaq(YuI4 *t); /* CPTokenInput.get */ void YCer(YuI4 *t, Ti Ac); /* CPTokenInput.push */ Ykeq *YVoF(YuI4 *t); /* CPTokenInput.getToken */ void Y4Sj(YuI4 *t, Ykeq *Atoken); /* CPTokenInput.pushToken */ To ToYuI4[3]; Zs13 Ytw1 = {"\013PTokenInput\000"}; int JPTokenInput(int round); /* PTokenInput done */ YP_l *YSOt(Tc *Afname); /* MParseProto.parse */ Zs27 YdgR = {"\031Cannot open for reading: \000"}; Zs21 YJWm = {"\023Unrecognized item: \000"}; void YjA8(YuI4 *Ain, YP_l *Apfile); /* MParseProto.parsePackage */ Zs23 Y2by = {"\025Expected package name\000"}; Zs31 YHnJ = {"\035Only one package name allowed\000"}; Yswy *YDgP(YuI4 *Ain); /* MParseProto.parseOption */ Zs22 Y6FG = {"\024Expected option name\000"}; Zs29 Y82z = {"\033Expected string value or ID\000"}; Zs33 Y0Xz = {"\037Missing semicolor or equal sign\000"}; Tr YpkI(YuI4 *Ain, YP_l *Apfile); /* MParseProto.parseService */ Zs23 YJUj = {"\025Expected service name\000"}; Zs11 YlMg = {"\011Missing {\000"}; Zs16 YT_h = {"\016Expected \"rpc\"\000"}; Zs19 YImx = {"\021Expected rpc name\000"}; Zs12 YZG7 = {"\012Expected (\000"}; Zs23 Yq4F = {"\025Expected request name\000"}; Zs12 Y_G7 = {"\012Expected )\000"}; Zs20 YMrT = {"\022Expected \"returns\"\000"}; Zs24 YXcR = {"\026Expected response name\000"}; Tr YOrf(YuI4 *Ain); /* MParseProto.parseMessage */ Zs23 YmWM = {"\025Expected message name\000"}; Zs19 Y8wy = {"\021Unexpected item: \000"}; Y0uC *YFuL(Ykeq *Atoken, YuI4 *Ain); /* MParseProto.parseField */ Zs20 Yhu6 = {"\022Expected type name\000"}; Zs21 Yoyn = {"\023Expected field name\000"}; Zs6 YKIS = {"\004_has\000"}; Zs35 Ye1M = {"\041Field name cannot start with _has\000"}; Zs21 YHNV = {"\023Expected equal sign\000"}; Zs20 YG5z = {"\022Expected 'default'\000"}; Zs24 Y8XM = {"\026Expected default value\000"}; Zs7 Y2cy = {"\005FALSE\000"}; Zs6 YHoE = {"\004TRUE\000"}; Zs28 YItG = {"\032Expected 'false' or 'true'\000"}; Zs11 YSLg = {"\011Missing ]\000"}; Tr YCm2(YuI4 *Ain); /* MParseProto.parseEnum */ Zs20 YyCj = {"\022Expected enum name\000"}; Zs15 YTWr = {"\015Expected name\000"}; void YYYx(YuI4 *Ain); /* MParseProto.checkSemiColon */ Zs19 Ybzg = {"\021Missing semicolon\000"}; Tb YtEy(Ykeq *At); /* MParseProto.checkEof */ Zs24 YF0E = {"\026Unexpected end of file\000"}; Ti YeT_(YuI4 *Ain); /* MParseProto.parseNumber */ Zs17 YNZb = {"\017Expected number\000"}; void YUys(YP_l *A0, Tr A1); /* YP_l__MaddItem_I__YuXI_I */ int JParseProto(int round); /* ParseProto done */ /* including WriteZimbu declarations */ void YCCA(YP_l *Apfile, Tc *AinFileName, Tc *AoutFileName); /* MWriteZimbu.write */ Zs27 Y32K = {"\031Cannot open for writing: \000"}; Zs19 Y_ZB = {"\021# Generated from \000"}; Zs33 YR1d = {"\037IMPORT \"$PLUGIN/proto/Proto.zu\"\000"}; Zs35 YGq9 = {"\041IMPORT \"$PLUGIN/proto/Message.zu\"\000"}; Zs9 YoyN = {"\007MODULE \000"}; Zs24 Y7Qg = {"\026 @public @items=public\000"}; Zs4 YZY = {"\002 \000"}; Zs19 YoBQ = {"\021unknown item type\000"}; void YxvA(YRAB *Amsg, Tr Aout, Tc *Aindent); /* MWriteZimbu.writeClass */ Zs8 YB_i = {"\006CLASS \000"}; Zs40 YxMq = {"\046 EXTENDS Message @public @items=public\000"}; Zs18 Yfgk = {"\020 dyn $extension\000"}; Zs9 YXgq = {"\007 NEW()\000"}; Zs5 YVet = {"\003 }\000"}; Zs43 Yow3 = {"\051 FUNC $name() string @replace @primitive\000"}; Zs14 YlWb = {"\014 RETURN \"\000"}; Zs16 Ysxb = {"\016Unknown type: \000"}; Zs10 YW8X = {"\010.unknown\000"}; Zs4 Ywla = {"\002.e\000"}; Zs3 YW = {"\0010\000"}; Zs7 YDFy = {"\005nat32\000"}; Zs5 YNmG = {"\003nat\000"}; Zs9 YdsC = {"\007float32\000"}; Zs33 Yl1o = {"\037SORRY, type not supported yet: \000"}; Zs7 Y9Ra = {"\005list<\000"}; Zs4 Y4Ja = {"\002> \000"}; Zs7 Y8Y5 = {"\005bool \000"}; Zs5 YWXt = {"\003 = \000"}; Zs6 YG4L = {"\004$has\000"}; Zs4 YXaa = {"\002()\000"}; Zs26 YJaV = {"\030PROC $clear() @primitive\000"}; Zs10 YRRN = {"\010 = FALSE\000"}; Zs31 Yzw4 = {"\035FUNC $valid() bool @primitive\000"}; Zs9 YZ35 = {"\007RETURN \000"}; Zs6 Y4zz = {"\004 && \000"}; Zs4 Yd1 = {"\002\"\"\000"}; Zs61 YcBy = {"\073FUNC $fieldSpecs() list<Proto.FieldSpec> @define @primitive\000"}; Zs19 Y1Dj = {"\021RETURN fieldSpecs\000"}; Zs72 YyUd = {"\106FUNC $mergeFromReader(Proto.FileFormat format, Proto.I_Reader reader) \000"}; Zs57 YKEm = {"\067Proto.mergeFromFields(THIS, format, fieldSpecs, reader)\000"}; Zs13 Y_Lu = {"\013RETURN THIS\000"}; Zs47 Y4Tv = {"\055FUNC $mergeFromBinary(Proto.I_Reader reader) \000"}; Zs55 YYQ8 = {"\065Proto.mergeFromBinaryFields(THIS, fieldSpecs, reader)\000"}; Zs48 YgCV = {"\056FUNC $mergeFromBinary(IO.I_ByteReader reader) \000"}; Zs51 Yew9 = {"\061$mergeFromBinary(Proto.Reader.NEW(reader, FALSE))\000"}; Zs53 YK2S = {"\063FUNC $mergeFromBinaryDeref(IO.I_ByteReader reader) \000"}; Zs50 Y0Sk = {"\060$mergeFromBinary(Proto.Reader.NEW(reader, TRUE))\000"}; Zs45 YwRP = {"\053FUNC $mergeFromText(Proto.I_Reader reader) \000"}; Zs53 Y4vI = {"\063Proto.mergeFromTextFields(THIS, fieldSpecs, reader)\000"}; Zs45 Yk1Y = {"\053FUNC $mergeFromJson(Proto.I_Reader reader) \000"}; Zs53 YwU4 = {"\063Proto.mergeFromJsonFields(THIS, fieldSpecs, reader)\000"}; Zs46 Yevx = {"\054FUNC $mergeFromJson(IO.I_CharReader reader) \000"}; Zs78 YlR1 = {"\114Proto.mergeFromJsonFields(THIS, fieldSpecs, Proto.Reader.NEW(reader, FALSE))\000"}; Zs8 YuOB = {"\006SHARED\000"}; Zs27 YaU5 = {"\031FUNC newMessage() Message\000"}; Zs8 YyLL = {"\006.NEW()\000"}; Zs8 Yjby = {"\006Binary\000"}; Zs6 Y27q = {"\004Text\000"}; Zs6 Yz0N = {"\004Json\000"}; Zs17 Yts2 = {"\017FUNC createFrom\000"}; Zs17 YIIp = {"\017IO.I_ByteReader\000"}; Zs17 YDa5 = {"\017IO.I_CharReader\000"}; Zs3 YO = {"\001(\000"}; Zs11 YYDR = {"\011 reader) \000"}; Zs18 Yvx0 = {"\020.NEW().mergeFrom\000"}; Zs35 YPYp = {"\041(Proto.Reader.NEW(reader, FALSE))\000"}; Zs10 Yqfe = {"\010(reader)\000"}; Zs24 YKhU = {"\026FUNC createMessageFrom\000"}; Zs18 Y52_ = {"\020 reader) Message\000"}; Zs19 YGO0 = {"\021RETURN createFrom\000"}; Zs8 YZix = {"\006Deref(\000"}; Zs15 Yvyf = {"\015Deref(reader)\000"}; Zs53 YD3Q = {"\063FUNC createFromBinaryDeref(IO.I_ByteReader reader) \000"}; Zs56 YNfH = {"\066.NEW().mergeFromBinary(Proto.Reader.NEW(reader, TRUE))\000"}; Zs51 Y8OQ = {"\061FUNC createFromJsonDeref(IO.I_CharReader reader) \000"}; Zs54 Y55l = {"\064.NEW().mergeFromJson(Proto.Reader.NEW(reader, TRUE))\000"}; void YHzx(Tc *Atype, Tc *AretType, Tl *Afields, Tc *Adefault, Tc *Aindent, Tr Aout); /* MWriteZimbu.writeGetSet */ Zs8 YMja = {"\006FUNC $\000"}; Zs17 YQBH = {"\017Get(int fieldNr\000"}; Zs11 YNcD = {"\011, int idx\000"}; Zs4 Ypca = {"\002) \000"}; Zs22 YYx8 = {"\024 @replace @primitive\000"}; Zs18 Y3Rg = {"\020 SWITCH fieldNr\000"}; Zs11 Y4Qg = {"\011 CASE \000"}; Zs11 YBII = {"\011; RETURN \000"}; Zs7 YxsN = {"\005[idx]\000"}; Zs6 YbT7 = {"\004from\000"}; Zs7 Y14u = {"\0052int[\000"}; Zs7 Y9Ud = {"\005 == 2\000"}; Zs11 YKKn = {"\011 RETURN \000"}; Zs31 YTzv = {"\035FUNC $enumNameGet(int fieldNr\000"}; Zs30 Y5Bw = {"\034) string @replace @primitive\000"}; Zs12 YBXc = {"\012 string s\000"}; Zs8 YuV2 = {"\006; s = \000"}; Zs53 YgZi = {"\063.ToString(); RETURN s == \"unknown\" ? s : s.slice(1)\000"}; Zs13 YfaF = {"\013 RETURN \"\"\000"}; Zs8 YmYN = {"\006PROC $\000"}; Zs19 Y5KZ = {"\021Set(int fieldNr, \000"}; Zs29 YmiC = {"\033 value) @replace @primitive\000"}; Zs4 YgFa = {"\002; \000"}; Zs6 YO9t = {"\004$add\000"}; Zs6 Yxtk = {"\004int2\000"}; Zs16 YoJI = {"\016.has(value) ? \000"}; Zs12 Y9CL = {"\012[value] : \000"}; Zs7 Y37y = {"\005value\000"}; Zs17 YHfx = {"\017(value ? 2 : 1)\000"}; Zs9 YPKf = {"\007value; \000"}; Zs9 YKf1 = {"\007 = TRUE\000"}; Zs3 YP = {"\001)\000"}; Zs65 Ygbr = {"\077PROC $enumNameSet(int fieldNr, string name) @replace @primitive\000"}; Zs26 Y4s5 = {"\030.FromString(\"e\" .. name)\000"}; Tb YTU9(Tl *Afields); /* MWriteZimbu.hasRepeated */ Tb YADt(Tl *Afields); /* MWriteZimbu.hasNotRepeated */ void YwAg(Tl *Afields, Tc *Aindent, Tr Aout); /* MWriteZimbu.writeWriteMerge */ Zs30 YO3G = {"\034FUNC $messageGet(int fieldNr\000"}; Zs31 YRua = {"\035) Message @replace @primitive\000"}; Zs14 Yzrg = {"\014 RETURN NIL\000"}; Zs62 YhqR = {"\074PROC $messageAdd(int fieldNr, Message m) @replace @primitive\000"}; Zs62 YfRA = {"\074PROC $messageSet(int fieldNr, Message m) @replace @primitive\000"}; Zs5 Y6y9 = {"\003IF \000"}; Zs11 YNM4 = {"\011 == NIL; \000"}; Zs13 YI0U = {"\013 = NEW(); }\000"}; Zs14 YR8A = {"\014 \000"}; Zs9 YVtc = {"\007.add(m)\000"}; Zs6 YRyv = {"\004 = m\000"}; Zs69 YfXS = {"\103FUNC $mergeMessageFromReader(int fieldNr, Proto.FileFormat format, \000"}; Zs38 Yf3o = {"\044Proto.I_Reader reader) bool @replace\000"}; Zs8 Ya8x = {"\006 \000"}; Zs9 YgCk = {"\007 == NIL\000"}; Zs10 YII0 = {"\010 = NEW()\000"}; Zs12 Yi_6 = {"\012 m = NEW()\000"}; Zs18 Yt1y = {"\020reader.addRef(m)\000"}; Zs35 YU62 = {"\041m.mergeFromReader(format, reader)\000"}; Zs16 YG9J = {"\016reader.addRef(\000"}; Zs34 YDFV = {"\040.mergeFromReader(format, reader)\000"}; Zs13 YdMU = {"\013RETURN TRUE\000"}; Zs16 YwAl = {"\016 RETURN FALSE\000"}; void YYCV(Tl *Afields, Tc *Aindent, Tr Aout); /* MWriteZimbu.writeHasField */ Zs54 YpN1 = {"\064FUNC $hasField(int fieldNr) bool @replace @primitive\000"}; Zs15 YpgF = {"\015; RETURN $has\000"}; void Yg8t(YRAB *Amsg, Tc *Aindent, Tr Aout); /* MWriteZimbu.writeCopy */ Zs24 YcuF = {"\026FUNC $copy(bool deep) \000"}; Zs14 YEsj = {"\014 ret = NEW()\000"}; Zs6 Y2C2 = {"\004ret.\000"}; Zs9 YGbi = {"\007IF deep\000"}; Zs7 YiHe = {"\005 IF \000"}; Zs9 Y2Nk = {"\007 != NIL\000"}; Zs10 Y5Fk = {"\010 ret.\000"}; Zs15 YAGs = {"\015 FOR i IN \000"}; Zs12 YO9y = {"\012 ret.\000"}; Zs20 YR9A = {"\022.add(i.copy(deep))\000"}; Zs9 Yvnc = {"\007.add(i)\000"}; Zs7 Y6my = {"\005 }\000"}; Zs6 Yc7A = {"\004ELSE\000"}; Zs8 YhLg = {"\006 ret.\000"}; Zs12 YRQE = {"\012 = deep ? \000"}; Zs16 Ybf2 = {"\016.copy(deep) : \000"}; Zs12 Yxe8 = {"\012RETURN ret\000"}; void Ycma(Tl *Afields, Tc *Aindent, Tr Aout); /* MWriteZimbu.writeSize */ Zs49 YvCR = {"\057FUNC $size(int fieldNr) int @replace @primitive\000"}; Zs16 YG_R = {"\016 == NIL ? 0 : \000"}; Zs9 YZY7 = {"\007.Size()\000"}; Zs12 Yc_G = {"\012 RETURN 0\000"}; void YMWy(Tl *Afields, Tc *Aindent, Tr Aout); /* MWriteZimbu.writeFieldTable */ Zs38 YMvm = {"\044list<Proto.FieldSpec> fieldSpecs = [\000"}; Zs9 YQgq = {"\007 NEW(\"\000"}; Zs5 YwFy = {"\003\", \000"}; Zs15 YqQF = {"\015, Proto.Type.\000"}; Zs4 Ydha = {"\002, \000"}; Zs4 YBca = {"\002),\000"}; void Y1M2(Tc *Aclass, Y0uC *Afield, Tc *Atype, Tc *AinitVal, Tc *AdefaultVal, Tc *Aindent, Tr Aout); /* MWriteZimbu.writeSetGetHas */ Zs11 Yctj = {"\011FUNC $set\000"}; Zs6 YxgQ = {"\004 v) \000"}; Zs13 YNOm = {"\013 @primitive\000"}; Zs14 Ybd2 = {"\014 = v ? 2 : 1\000"}; Zs6 Y_yv = {"\004 = v\000"}; Zs15 YYwn = {"\015 RETURN THIS\000"}; Zs11 YEC6 = {"\011FUNC $new\000"}; Zs5 Ye0N = {"\003() \000"}; Zs11 Y9CPa = {"\011FUNC $get\000"}; Zs8 YwS1 = {"\006 IF !\000"}; Zs6 Y7gw = {"\004 == \000"}; Zs13 YG_k = {"\013 RETURN \000"}; Zs18 YQIB = {"\020 RETURN FALSE\000"}; Zs15 YJGx = {"\015 RETURN \"\"\000"}; Zs14 YzWb = {"\014 RETURN 0\000"}; Zs13 YdiJ = {"\013 THROW \"\000"}; Zs15 YTKi = {"\015 was not set\"\000"}; Zs11 YE5R = {"\011FUNC $has\000"}; Zs20 YBMj = {"\022() bool @primitive\000"}; Zs6 Yljn = {"\004 != \000"}; Zs13 YnyF = {"\013FUNC $clear\000"}; void YsmR(Tc *Aclass, Y0uC *Afield, Tc *Atype, Tc *AdefaultVal, Tc *Aindent, Tr Aout); /* MWriteZimbu.writeAddGetHas */ Zs11 YMaA = {"\011FUNC $add\000"}; Zs6 YW_j = {"\004 \000"}; Zs9 YlIc = {"\007.add(v)\000"}; Zs14 YEnH = {"\014FUNC $addNew\000"}; Zs12 Y0_k = {"\012 v = NEW()\000"}; Zs8 Y2hI = {"\006 $add\000"}; Zs5 YPYP = {"\003(v)\000"}; Zs12 Y5YG = {"\012 RETURN v\000"}; Zs10 Y7in = {"\010(int i) \000"}; Zs16 YD5t = {"\016 IF i < 0 || \000"}; Zs18 YAGJ = {"\020 == NIL || i >= \000"}; Zs41 YOn3 = {"\047 THROW \"list index out of range for \000"}; Zs10 YEpL = {"\010: \" .. i\000"}; Zs5 YLJU = {"\003[i]\000"}; Zs14 Ynjc = {"\014List() list<\000"}; Zs14 Yp5Q = {"\014> @primitive\000"}; Zs12 YCj9 = {"\012List(list<\000"}; Zs7 YWFy = {"\005> l) \000"}; Zs6 YQyv = {"\004 = l\000"}; Zs12 YgyZ = {"\012FUNC $size\000"}; Zs19 Y3FL = {"\021() int @primitive\000"}; Zs13 YIgG = {"\013 != NIL && \000"}; Zs13 YW_F = {"\013.Size() > 0\000"}; Zs25 YwnZ = {"\027(int i) bool @primitive\000"}; Zs21 YBWs = {"\023 RETURN i >= 0 && \000"}; Zs17 YEqC = {"\017 != NIL && i < \000"}; Zs8 YsTa = {"\006 = NIL\000"}; void Yk4Q(YNW5 *Aservice, Tr Aout, Tc *Aindent); /* MWriteZimbu.writeService */ Zs11 Y9d4 = {"\011 MODULE \000"}; Zs10 YZZg = {"\010 # rpc \000"}; Zs12 YOlD = {"\012) returns \000"}; Zs13 YHny = {"\013 FUNC call\000"}; Zs12 Y8Bf = {"\012 request, \000"}; Zs35 YJ4N = {"\041proc<RPC.Control, Message> done) \000"}; Zs13 Y84u = {"\013RPC.Control\000"}; Zs21 YclF = {"\023IF !request.valid()\000"}; Zs22 YI05 = {"\024 RETURN Proto.rpc(\"\000"}; Zs14 YnFL = {"\014\", request, \000"}; Zs28 YQuz = {"\032GENERATE_IF Z.lang == \"JS\"\000"}; Zs41 Y9Ba = {"\047.createMessageFromJsonDeref, NIL, done)\000"}; Zs31 YKC8 = {"\035GENERATE_ELSEIF Z.lang == \"C\"\000"}; Zs7 YZeO = {"\005NIL, \000"}; Zs38 YihP = {"\044.createMessageFromBinaryDeref, done)\000"}; Zs15 Yuso = {"\015GENERATE_ELSE\000"}; Zs29 YIzR = {"\033 GENERATE_IF Z.lang == \"C\"\000"}; Zs22 Yhls = {"\024Proto.RpcInfo handle\000"}; Zs10 YBI0 = {"\010 = NEW(\"\000"}; Zs31 YJQW = {"\035.createMessageFromJsonDeref, \000"}; Zs14 YNbo = {"\014.newMessage)\000"}; void Y8RG(Y2Kp *Aenum, Tr Aout, Tc *Aindent); /* MWriteZimbu.writeEnum */ Zs7 Ywwj = {"\005ENUM \000"}; Zs10 YAId = {"\010 @public\000"}; Zs11 YXRY = {"\011 unknown\000"}; Zs5 Yxet = {"\003 e\000"}; Zs7 Yfpd = {"\005dict<\000"}; Zs13 Yj9U = {"\013, int> from\000"}; Zs10 Y9UL = {"\0102int = [\000"}; Zs15 Yu8y = {"\015.unknown: -1,\000"}; Zs3 YS = {"\001,\000"}; Zs12 Yxa6 = {"\012dict<int, \000"}; Zs8 Y9oy = {"\006> int2\000"}; Zs6 Yzyv = {"\004 = [\000"}; void YCOQ(Tc *AinFileName, Tc *AoutFileName); /* MWriteZimbu.writeError */ Zs17 YK3s = {"\017Error handling \000"}; /* WriteZimbu done */ Zs9 YZVC = {"\007Usage: \000"}; Zs26 YWbL = {"\030 infile.proto outfile.zu\000"}; Zs8 YnKK = {"\006.proto\000"}; Zs42 YwwA = {"\050ERROR: Input name must end in '.proto': \000"}; Zs5 YYv4 = {"\003.zu\000"}; Zs40 YIhh = {"\046ERROR: output name must end in '.zu': \000"}; Tt bool__T = {21, 0, 0}; Tt byte__T = {11, 0, 0}; Tt byteString__T = {201, 0, 0}; Tt float128__T = {83, 0, 0}; Tt float32__T = {81, 0, 0}; Tt float80__T = {82, 0, 0}; Tt float__T = {80, 0, 0}; Tt int16__T = {2, 0, 0}; Tt int32__T = {3, 0, 0}; Tt int8__T = {1, 0, 0}; Tt int__T = {0, 0, 0}; Tt nat16__T = {12, 0, 0}; Tt nat32__T = {13, 0, 0}; Tt nat__T = {10, 0, 0}; Tt status__T = {22, 0, 0}; Tt string__T = {200, 0, 0}; Tt type__T = {101, 0, 0}; Tt array__T = {300, 0, 0}; Tt list__T = {301, 0, 0}; Tt dict__T = {302, 0, 0}; Tt iobj__T = {391, 0, 0}; int ZglobInit(int round); typedef struct Zfo__S { int off; Tt *type; } Zfo; typedef struct Zsf__S { volatile int pos; struct Zsf__S *prev; Zfo *frof; } Zsf; #define POS_MASK 0x3fffffff typedef struct Senv__S { int tosNr; } Tn; /* per-thread environemnt */ Zsf *topFrame = NULL; int inZa = 0; int ZaEntered = 0; Tn Zenv = {0}; void beforeExit() { } Tc *Zstr(char *s) { return ZnewString((Tc*)s, strlen(s)); } /* allocate memory */ void *Za(size_t size) { void *p = NULL; if (!inZa) { inZa = 1; p = calloc(1, size); inZa = 0; } if (p == NULL) { if (inZa || ZaEntered) { if (16384 - emergencyAllocUsed >= size) { p = emergencyAlloc + emergencyAllocUsed; emergencyAllocUsed += size; return p; } fputs("Out of memory (Za)\n", stderr); fflush(stderr); exit(1); } ++ZaEntered; ZthrowOutOfMemory(size); } ZaEntered = 0; return p; } /* allocate memory with offset */ #define ZaOff(size) (Za((size) + ZOH_OFF) + ZOH_OFF) #define ZranOff(ptr, osize, nsize) (Zran((ptr) ? (void*)(ptr) - ZOH_OFF : NULL, (osize) + ZOH_OFF, (nsize) + ZOH_OFF) + ZOH_OFF) /* allocate memory */ void *ZaNm(size_t size) { void *p = NULL; if (!inZa) { inZa = 1; p = calloc(1, size); inZa = 0; } if (p == NULL) { if (inZa || ZaEntered) { if (16384 - emergencyAllocUsed >= size) { p = emergencyAlloc + emergencyAllocUsed; emergencyAllocUsed += size; return p; } fputs("Out of memory (ZaNm)\n", stderr); fflush(stderr); exit(1); } ++ZaEntered; ZthrowOutOfMemory(size); } ZaEntered = 0; return p; } void *ZaNmi(size_t size) { void *p = NULL; if (!inZa) { inZa = 1; p = calloc(1, size); inZa = 0; } if (p == NULL) { if (inZa || ZaEntered) { if (16384 - emergencyAllocUsed >= size) { p = emergencyAlloc + emergencyAllocUsed; emergencyAllocUsed += size; return p; } fputs("Out of memory (ZaNmi)\n", stderr); fflush(stderr); exit(1); } ++ZaEntered; ZthrowOutOfMemory(size); } ZaEntered = 0; return p; } /* reallocate memory */ void *Zran(void *op, size_t osize, size_t nsize) { void *p = NULL; if (!inZa && !ZaEntered) { inZa = 1; p = realloc(op, nsize); inZa = 0; if (p == NULL) { ++ZaEntered; ZthrowOutOfMemory(nsize); } ZaEntered = 0; if (nsize > osize) memset(p + osize, 0, nsize - osize); return p; } p = Za(nsize); if (op) memmove(p + ZOH_OFF, op + ZOH_OFF, nsize > osize ? osize - ZOH_OFF : nsize - ZOH_OFF); if (nsize > osize) memset(p + osize, 0, nsize - osize); return p; } void *ZranNm(void *op, size_t osize, size_t nsize) { void *p = NULL; if (!inZa && !ZaEntered) { inZa = 1; p = realloc(op, nsize); inZa = 0; if (p == NULL) { ++ZaEntered; ZthrowOutOfMemory(nsize); } if (nsize > osize) memset(p + osize, 0, nsize - osize); return p; } p = ZaNm(nsize); if (op) memmove(p, op, nsize > osize ? osize : nsize); if (nsize > osize) memset(p + osize, 0, nsize - osize); return p; } void Zfree(void *p) { if (p) free(p); } Tc *ZnewStringInit(Ti len, Tc **pp) { Ti rlen = len; int i; int n = ZOH_OFF; Tc buf[20]; Tc *res; buf[0] = (rlen & 127); rlen >>= 7; for (i = 1; rlen > 0; ++i) { buf[i] = (rlen & 127) + 128; rlen >>= 7; } res = Za(ZOH_OFF + len + i + 1); while (i > 0) res[n++] = buf[--i]; *pp = res + n; return res; } Tc *ZnewString(Tc *p, Ti len) { Tc *pp; Tc *res = ZnewStringInit(len, &pp); memmove(pp, p, len); return res; } Tc Ydmy[]="Input.zu"; Tc YCG4[]="lib/ARGModule.zu"; Tc Yt1T[]="lib/EModule.zu"; Tc Yay0[]="lib/IOModule.zu"; Tc Y76z[]="lib/LOGModule.zu"; Tc YxHL[]="lib/SETModule.zu"; Tc YyXk[]="lib/TIMEModule.zu"; Tc Y3zM[]="lib/ZModule.zu"; Tc Yeop[]="plugin/proto/EnumItem.zu"; Tc Y7gD[]="plugin/proto/FieldItem.zu"; Tc Yxbi[]="plugin/proto/MessageItem.zu"; Tc YEew[]="plugin/proto/PTokenInput.zu"; Tc Y1IY[]="plugin/proto/PTokenize.zu"; Tc YnGo[]="plugin/proto/ParseProto.zu"; Tc Y_R2[]="plugin/proto/ProtoFile.zu"; Tc YjxU[]="plugin/proto/RpcItem.zu"; Tc YGYp[]="plugin/proto/ServiceItem.zu"; Tc YFTE[]="plugin/proto/WriteZimbu.zu"; Tc YLrK[]="plugin/proto/pluginproto.zu"; Tc Y_VO[]="ARG.Bool.NEW/1()"; Tcpos ZcTbl3273[]={ {791,5}, {2,7}, {3,16}, {4,16}, {5,18}, }; Tc YImf[]="ARG.Bool.NEW__p1/1()"; Tcpos ZcTbl76644[]={ {637,5}, {1,7}, {2,9}, {4,7}, {6,9}, {8,7}, {9,20}, {11,7}, {12,19}, {14,12}, {18,7}, {19,20}, {20,19}, {23,7}, {24,9}, {25,11}, {27,9}, {29,7}, {30,9}, {31,11}, {33,9}, {34,11}, {36,9}, {38,12}, }; Tc YM2k[]="ARG.Bool.setToDefault/1()"; Tcpos ZcTbl38911[]={ {800,11}, {1,16}, }; Tc YgDO[]="ARG.Bool.throwDuplicate__p1/1()"; Tcpos ZcTbl75697[]={ {679,11}, {1,44}, {2,18}, {4,7}, }; Tc Y2cg[]="ARG.Bool.value()"; Tcpos ZcTbl61284[]={ {830,11}, {1,15}, }; Tc YPPv[]="ARG.Init()"; Tcpos ZcTbl66501[]={ {78,29}, }; Tc Ygzb[]="ARG.Int.setToDefault/1()"; Tcpos ZcTbl16350[]={ {865,11}, {1,16}, }; Tc YZNA[]="ARG.String.setToDefault/1()"; Tcpos ZcTbl86206[]={ {953,11}, {1,16}, }; Tc YRbs[]="ARG.StringList.setToDefault/1()"; Tcpos ZcTbl64478[]={ {1046,11}, {1,16}, }; Tc YEFE[]="ARG.Usage.get()"; Tcpos ZcTbl43000[]={ {600,11}, {1,23}, {2,7}, {3,17}, {5,49}, }; Tc YzK9[]="ARG.displayHelp()"; Tcpos ZcTbl29560[]={ {461,5}, {1,7}, {3,5}, {6,35}, {7,5}, {8,19}, {9,7}, {10,33}, {7,5}, {17,5}, {18,7}, {19,9}, {20,9}, {23,7}, {24,21}, {26,26}, {28,9}, {29,11}, {30,21}, {32,21}, {34,15}, {35,21}, {36,11}, {37,21}, {39,21}, {41,15}, {42,21}, {43,11}, {44,21}, {46,21}, {48,15}, {50,9}, {51,11}, {52,21}, {54,21}, {58,23}, {59,9}, {60,16}, {62,9}, {63,11}, {65,13}, {66,15}, {67,22}, {69,15}, {71,18}, {73,16}, {76,9}, {77,16}, {80,9}, {81,11}, {82,13}, {83,13}, {85,13}, {87,11}, {88,13}, {89,13}, {92,11}, {93,24}, {95,11}, {96,24}, {23,7}, {17,5}, {103,10}, }; Tc Yza4[]="ARG.error()"; Tcpos ZcTbl85295[]={ {449,5}, {1,5}, {2,7}, {4,5}, {5,7}, {7,10}, }; Tc Yh2v[]="ARG.init()"; Tcpos ZcTbl82533[]={ {259,5}, {1,7}, {3,20}, {4,19}, {6,7}, {7,9}, {9,7}, {10,9}, {9,7}, {12,7}, {13,9}, {12,7}, {16,17}, {17,22}, {19,7}, {20,9}, {22,16}, {26,22}, {27,9}, {28,11}, {29,11}, {30,21}, {33,11}, {34,21}, {39,13}, {40,37}, {41,15}, {44,17}, {48,34}, {49,15}, {50,23}, {51,26}, {54,20}, {57,15}, {58,22}, {59,17}, {60,19}, {62,30}, {63,27}, {66,26}, {72,37}, {75,34}, {76,15}, {77,23}, {78,26}, {80,17}, {82,24}, {83,19}, {86,21}, {88,23}, {89,36}, {89,36}, {90,37}, {91,32}, {92,28}, {93,33}, {96,47}, {98,29}, {99,32}, {80,17}, {105,15}, {106,17}, {107,27}, {108,22}, {111,13}, {112,15}, {113,17}, {116,15}, {117,17}, {119,15}, {120,15}, {121,30}, {121,30}, {122,17}, {123,19}, {124,35}, {125,40}, {126,35}, {128,21}, {131,33}, {133,27}, {134,17}, {135,19}, {137,36}, {137,36}, {138,31}, {139,17}, {140,19}, {139,17}, {144,17}, {146,24}, {147,19}, {148,21}, {150,25}, {152,17}, {153,31}, {153,31}, {154,19}, {156,35}, {157,21}, }; Tcpos ZcTbl82534[]={ {422,40}, {1,35}, {2,21}, {4,29}, {5,34}, {5,34}, {6,19}, {8,35}, {9,21}, {11,35}, {12,21}, {15,19}, {-144,7}, }; Tc YMnk[]="ARG.writeLead()"; Tcpos ZcTbl81798[]={ {569,5}, {2,5}, {3,7}, {2,5}, }; Tc Y5LR[]="E.BadValue.NEW__p2/2()"; Tcpos ZcTbl60593[]={ {60,5}, {1,16}, {2,12}, {4,20}, {4,24}, }; Tc Y9VX[]="E.BadValue.writeTo__p2/4()"; Tcpos ZcTbl46171[]={ {114,11}, {1,7}, {3,9}, {4,12}, {5,12}, {6,14}, {7,16}, {9,16}, {10,16}, {11,16}, {12,18}, {13,18}, {5,12}, }; Tc Y4u_[]="E.BadValue.writeTo__p2/5()"; Tcpos ZcTbl56372[]={ {87,11}, {1,7}, {2,9}, {3,9}, {6,7}, {8,9}, {9,9}, {11,9}, }; Tc Y_Qs[]="E.DivideByZero.NEW__p3/3()"; Tcpos ZcTbl73471[]={ {60,5}, {1,16}, {2,12}, {4,20}, {4,24}, }; Tc YG80[]="E.DivideByZero.writeTo__p3/6()"; Tcpos ZcTbl44130[]={ {87,11}, {1,7}, {2,9}, {3,9}, {6,7}, {8,9}, {9,9}, {11,9}, }; Tc YLzZ[]="E.DivideByZero.writeTo__p3/7()"; Tcpos ZcTbl54331[]={ {114,11}, {1,7}, {3,9}, {4,12}, {5,12}, {6,14}, {7,16}, {9,16}, {10,16}, {11,16}, {12,18}, {13,18}, {5,12}, }; Tc YgcH[]="E.Exception.writeTo()"; Tcpos ZcTbl49183[]={ {87,11}, {1,7}, {2,9}, {3,9}, {6,7}, {8,9}, {9,9}, {11,9}, }; Tc YYT9[]="E.Exception.writeTo/1()"; Tcpos ZcTbl36491[]={ {114,11}, {1,7}, {3,9}, {4,12}, {5,12}, {6,14}, {7,16}, {9,16}, {10,16}, {11,16}, {12,18}, {13,18}, {5,12}, }; Tc YTjU[]="E.Exit.writeTo/2()"; Tcpos ZcTbl92163[]={ {191,11}, {1,7}, {2,9}, {3,9}, {5,7}, {6,7}, {7,7}, {8,9}, {9,9}, }; Tc Y9aV[]="E.Exit.writeTo__p1/3()"; Tcpos ZcTbl42983[]={ {114,11}, {1,7}, {3,9}, {4,12}, {5,12}, {6,14}, {7,16}, {9,16}, {10,16}, {11,16}, {12,18}, {13,18}, {5,12}, }; Tc Y9Cv[]="E.IOError.NEW__p2/2()"; Tcpos ZcTbl48299[]={ {60,5}, {1,16}, {2,12}, {4,20}, {4,24}, }; Tc Y59h[]="E.IOError.writeTo__p2/4()"; Tcpos ZcTbl89685[]={ {114,11}, {1,7}, {3,9}, {4,12}, {5,12}, {6,14}, {7,16}, {9,16}, {10,16}, {11,16}, {12,18}, {13,18}, {5,12}, }; Tc Y0Jk[]="E.IOError.writeTo__p2/5()"; Tcpos ZcTbl99886[]={ {87,11}, {1,7}, {2,9}, {3,9}, {6,7}, {8,9}, {9,9}, {11,9}, }; Tc Y2NH[]="E.IllegalByte.NEW__p3/3()"; Tcpos ZcTbl45209[]={ {60,5}, {1,16}, {2,12}, {4,20}, {4,24}, }; Tc YALK[]="E.IllegalByte.writeTo__p3/6()"; Tcpos ZcTbl9948[]={ {87,11}, {1,7}, {2,9}, {3,9}, {6,7}, {8,9}, {9,9}, {11,9}, }; Tc YFbI[]="E.IllegalByte.writeTo__p3/7()"; Tcpos ZcTbl20149[]={ {114,11}, {1,7}, {3,9}, {4,12}, {5,12}, {6,14}, {7,16}, {9,16}, {10,16}, {11,16}, {12,18}, {13,18}, {5,12}, }; Tc Yp81[]="E.Init.NEW__p2/2()"; Tcpos ZcTbl53377[]={ {60,5}, {1,16}, {2,12}, {4,20}, {4,24}, }; Tc Yuz_[]="E.Init.NEW__p2/3()"; Tcpos ZcTbl63578[]={ {69,5}, {1,16}, {2,12}, {4,20}, {4,24}, }; Tc YMF2[]="E.Init.writeTo__p2/4()"; Tcpos ZcTbl96107[]={ {114,11}, {1,7}, {3,9}, {4,12}, {5,12}, {6,14}, {7,16}, {9,16}, {10,16}, {11,16}, {12,18}, {13,18}, {5,12}, }; Tc YR5_[]="E.Init.writeTo__p2/5()"; Tcpos ZcTbl6308[]={ {87,11}, {1,7}, {2,9}, {3,9}, {6,7}, {8,9}, {9,9}, {11,9}, }; Tc YbzA[]="E.Internal.NEW__p2/2()"; Tcpos ZcTbl78082[]={ {60,5}, {1,16}, {2,12}, {4,20}, {4,24}, }; Tc YxLq[]="E.Internal.writeTo__p2/4()"; Tcpos ZcTbl412[]={ {114,11}, {1,7}, {3,9}, {4,12}, {5,12}, {6,14}, {7,16}, {9,16}, {10,16}, {11,16}, {12,18}, {13,18}, {5,12}, }; Tc YCbo[]="E.Internal.writeTo__p2/5()"; Tcpos ZcTbl10613[]={ {87,11}, {1,7}, {2,9}, {3,9}, {6,7}, {8,9}, {9,9}, {11,9}, }; Tc Ycb9[]="E.KeyExists.NEW__p3/3()"; Tcpos ZcTbl85000[]={ {60,5}, {1,16}, {2,12}, {4,20}, {4,24}, }; Tc YhC6[]="E.KeyExists.NEW__p3/4()"; Tcpos ZcTbl95201[]={ {69,5}, {1,16}, {2,12}, {4,20}, {4,24}, }; Tc Y4SL[]="E.KeyExists.writeTo__p3/6()"; Tcpos ZcTbl14715[]={ {87,11}, {1,7}, {2,9}, {3,9}, {6,7}, {8,9}, {9,9}, {11,9}, }; Tc Y9iJ[]="E.KeyExists.writeTo__p3/7()"; Tcpos ZcTbl24916[]={ {114,11}, {1,7}, {3,9}, {4,12}, {5,12}, {6,14}, {7,16}, {9,16}, {10,16}, {11,16}, {12,18}, {13,18}, {5,12}, }; Tc YAVe[]="E.KeyNotFound.NEW__p3/3()"; Tcpos ZcTbl29585[]={ {60,5}, {1,16}, {2,12}, {4,20}, {4,24}, }; Tc Ygil[]="E.KeyNotFound.writeTo__p3/6()"; Tcpos ZcTbl43124[]={ {87,11}, {1,7}, {2,9}, {3,9}, {6,7}, {8,9}, {9,9}, {11,9}, }; Tc YlJi[]="E.KeyNotFound.writeTo__p3/7()"; Tcpos ZcTbl53325[]={ {114,11}, {1,7}, {3,9}, {4,12}, {5,12}, {6,14}, {7,16}, {9,16}, {10,16}, {11,16}, {12,18}, {13,18}, {5,12}, }; Tc YF6S[]="E.MemoryAccess.NEW__p2/2()"; Tcpos ZcTbl73580[]={ {60,5}, {1,16}, {2,12}, {4,20}, {4,24}, }; Tc Y4vu[]="E.MemoryAccess.writeTo__p2/4()"; Tcpos ZcTbl25958[]={ {114,11}, {1,7}, {3,9}, {4,12}, {5,12}, {6,14}, {7,16}, {9,16}, {10,16}, {11,16}, {12,18}, {13,18}, {5,12}, }; Tc Y_4w[]="E.MemoryAccess.writeTo__p2/5()"; Tcpos ZcTbl36159[]={ {87,11}, {1,7}, {2,9}, {3,9}, {6,7}, {8,9}, {9,9}, {11,9}, }; Tc Y1As[]="E.NilAccess.NEW__p2/2()"; Tcpos ZcTbl32086[]={ {60,5}, {1,16}, {2,12}, {4,20}, {4,24}, }; Tc YcIS[]="E.NilAccess.writeTo__p2/4()"; Tcpos ZcTbl35088[]={ {114,11}, {1,7}, {3,9}, {4,12}, {5,12}, {6,14}, {7,16}, {9,16}, {10,16}, {11,16}, {12,18}, {13,18}, {5,12}, }; Tc Y7gV[]="E.NilAccess.writeTo__p2/5()"; Tcpos ZcTbl45289[]={ {87,11}, {1,7}, {2,9}, {3,9}, {6,7}, {8,9}, {9,9}, {11,9}, }; Tc YobA[]="E.OutOfMemory.NEW/3()"; Tcpos ZcTbl80644[]={ {262,5}, {1,16}, {2,12}, {4,20}, {4,24}, }; Tc YoZS[]="E.OutOfMemory.writeTo__p2/4()"; Tcpos ZcTbl11217[]={ {114,11}, {1,7}, {3,9}, {4,12}, {5,12}, {6,14}, {7,16}, {9,16}, {10,16}, {11,16}, {12,18}, {13,18}, {5,12}, }; Tc YtpQ[]="E.OutOfMemory.writeTo__p2/5()"; Tcpos ZcTbl21418[]={ {87,11}, {1,7}, {2,9}, {3,9}, {6,7}, {8,9}, {9,9}, {11,9}, }; Tc Y99g[]="E.OutOfRange.NEW__p3/3()"; Tcpos ZcTbl56381[]={ {60,5}, {1,16}, {2,12}, {4,20}, {4,24}, }; Tc YqK0[]="E.OutOfRange.writeTo__p3/6()"; Tcpos ZcTbl52608[]={ {87,11}, {1,7}, {2,9}, {3,9}, {6,7}, {8,9}, {9,9}, {11,9}, }; Tc Ylj3[]="E.OutOfRange.writeTo__p3/7()"; Tcpos ZcTbl62809[]={ {114,11}, {1,7}, {3,9}, {4,12}, {5,12}, {6,14}, {7,16}, {9,16}, {10,16}, {11,16}, {12,18}, {13,18}, {5,12}, }; Tc YR5m[]="E.WrongType.NEW/1()"; Tcpos ZcTbl87235[]={ {514,5}, {1,16}, {2,12}, {4,20}, {4,24}, }; Tc YlgI[]="E.WrongType.writeTo__p2/4()"; Tcpos ZcTbl86818[]={ {114,11}, {1,7}, {3,9}, {4,12}, {5,12}, {6,14}, {7,16}, {9,16}, {10,16}, {11,16}, {12,18}, {13,18}, {5,12}, }; Tc YgQK[]="E.WrongType.writeTo__p2/5()"; Tcpos ZcTbl97019[]={ {87,11}, {1,7}, {2,9}, {3,9}, {6,7}, {8,9}, {9,9}, {11,9}, }; Tc YEFs[]="E.unhandledException()"; Tcpos ZcTbl15718[]={ {609,23}, {0,23}, {0,23}, }; Tc YgcM[]="E.writeToStderr()"; Tcpos ZcTbl52386[]={ {629,5}, {1,5}, {1,7}, {1,7}, {1,7}, {1,7}, {1,7}, {1,7}, {1,7}, {1,7}, {1,7}, {1,7}, {1,7}, {1,7}, {1,7}, {1,7}, {1,7}, {2,5}, }; Tc YmDz[]="EnumItem.NEW()"; Tcpos ZcTbl58121[]={ {16,3}, {1,14}, }; Tc YTU3[]="EnumItem.addValue()"; Tcpos ZcTbl89141[]={ {20,9}, {1,15}, {2,10}, {3,10}, {4,11}, {5,5}, }; Tc YLFA[]="EnumItem.checkErrors()"; Tcpos ZcTbl40190[]={ {35,9}, {1,21}, {2,18}, {3,5}, {4,7}, {5,9}, {6,13}, {8,9}, {3,5}, {11,12}, }; Tc Y5D2[]="FieldItem"; Tcpos ZcTbl90183[]={ {53,30}, }; Tc YAt2[]="FieldItem.funcName()"; Tcpos ZcTbl2571[]={ {47,9}, {1,40}, }; Tc YHJi[]="FieldItem.getType()"; Tcpos ZcTbl19772[]={ {66,7}, {1,16}, {3,25}, }; Tc YIwZ[]="FieldItem.hasMemberName()"; Tcpos ZcTbl60791[]={ {30,9}, {1,5}, {2,7}, {10,26}, {13,12}, }; Tc YBp9[]="FieldItem.memberName()"; Tcpos ZcTbl36283[]={ {24,9}, {1,18}, }; Tc Ys1a[]="IO"; Tcpos ZcTbl7452[]={ {26,8}, {3,8}, {6,8}, }; Tc YEgn[]="IO.File.close()"; Tcpos ZcTbl15755[]={ {582,11}, {1,20}, {2,7}, {6,4}, {9,4}, {12,15}, {15,14}, }; Tc YskO[]="IO.File.flush()"; Tcpos ZcTbl60567[]={ {564,11}, {1,20}, {2,7}, {4,4}, {12,14}, }; Tc Yxlj[]="IO.File.print__p1/15()"; Tcpos ZcTbl82618[]={ {230,11}, {1,15}, }; Tc YJ7z[]="IO.File.print__p1/8()"; Tcpos ZcTbl66188[]={ {184,11}, {1,7}, {2,16}, {4,14}, }; Tc Y5P_[]="IO.File.readByte()"; Tcpos ZcTbl16053[]={ {253,11}, {1,7}, {2,9}, {6,4}, {17,14}, }; Tc YHCY[]="IO.File.readChar()"; Tcpos ZcTbl46631[]={ {275,11}, {1,16}, {2,7}, {4,9}, {5,15}, {6,13}, {7,27}, {8,15}, {9,13}, {10,27}, {11,15}, {12,13}, {14,11}, {16,9}, {17,21}, {18,11}, {19,13}, {20,30}, {21,13}, {23,13}, {16,9}, {25,9}, {27,15}, {28,17}, {31,15}, {32,17}, {35,15}, {36,17}, {40,14}, }; Tc Yj_J[]="IO.File.write/8()"; Tcpos ZcTbl94823[]={ {483,11}, {3,9}, {4,11}, {6,4}, {31,14}, }; Tc YGQL[]="IO.File.write__p1/9()"; Tcpos ZcTbl59819[]={ {129,11}, {1,15}, }; Tc YrJP[]="IO.StringWriter.ToString()"; Tcpos ZcTbl64531[]={ {1431,11}, {3,9}, {4,13}, {6,4}, {17,14}, }; Tc YYk7[]="IO.StringWriter.print__p1/8()"; Tcpos ZcTbl26760[]={ {184,11}, {1,7}, {2,16}, {4,14}, }; Tc YSa1[]="IO.StringWriter.remove()"; Tcpos ZcTbl58975[]={ {1453,11}, {1,7}, {2,16}, {6,11}, {7,19}, {8,9}, {9,21}, {10,21}, {11,11}, {12,23}, {13,23}, {14,13}, {16,25}, {17,25}, {18,17}, {22,17}, {26,15}, {36,14}, }; Tc YCbR[]="IO.StringWriter.write/8()"; Tcpos ZcTbl89987[]={ {1359,11}, {1,37}, {3,9}, {4,14}, {5,11}, {6,17}, {8,11}, {10,13}, {12,11}, {13,17}, {24,14}, }; Tc Y1Ue[]="IO.StringWriter.writeChar__p1/1()"; Tcpos ZcTbl49285[]={ {175,11}, {1,7}, {2,9}, {4,15}, }; Tc YzQB[]="IO.StringWriter.write__p1/9()"; Tcpos ZcTbl72007[]={ {129,11}, {1,15}, }; Tc YTE3[]="IO.fileReader()"; Tcpos ZcTbl99838[]={ {926,4}, {5,9}, {6,4}, {16,12}, }; Tc Y5X7[]="IO.fileWriter()"; Tcpos ZcTbl81580[]={ {956,4}, {8,9}, {9,4}, {19,12}, }; Tc YN2v[]="IO.flush()"; Tcpos ZcTbl46761[]={ {1337,4}, {9,12}, }; Tc YNFk[]="IO.print()"; Tcpos ZcTbl1872[]={ {1227,37}, {1,4}, {13,12}, }; Tc Y_pS[]="IO.write()"; Tcpos ZcTbl84870[]={ {1168,4}, {13,12}, }; Tc YOoa[]="Input.NEW()"; Tcpos ZcTbl44401[]={ {32,3}, {1,9}, {2,10}, {3,16}, {4,13}, {5,5}, {6,21}, }; Tc YHM2[]="Input.get()"; Tcpos ZcTbl19887[]={ {56,9}, {2,5}, {3,9}, {4,15}, {5,16}, {6,7}, {7,11}, {9,11}, {10,9}, {11,17}, {14,7}, {15,11}, {16,17}, {18,9}, {19,11}, {20,13}, {21,15}, {22,20}, {23,13}, {24,15}, {26,15}, {27,28}, {28,13}, {29,15}, {32,7}, {14,7}, {35,5}, {36,20}, {37,7}, {40,5}, {41,7}, {44,12}, }; Tc Yq05[]="Input.push()"; Tcpos ZcTbl34047[]={ {104,9}, {1,5}, {2,7}, {3,7}, {4,18}, {5,18}, {7,17}, {9,7}, {10,9}, }; Tc YVvh[]="LOG"; Tcpos ZcTbl83326[]={ {21,14}, {2,14}, {50,20}, }; Tc YFIR[]="LOG.flush()"; Tcpos ZcTbl56555[]={ {226,5}, {1,5}, {2,7}, {4,15}, }; Tc Y8w5[]="LOG.reportStack()"; Tcpos ZcTbl84899[]={ {213,7}, {1,7}, {2,18}, {2,7}, {2,18}, {3,9}, {2,7}, }; Tc Y9QD[]="Main()"; Tcpos ZcTbl5270[]={ {29,3}, {1,5}, {2,10}, {6,27}, {7,3}, {8,5}, {9,10}, {11,28}, {12,3}, {13,5}, {14,10}, {19,36}, {21,3}, {24,5}, {25,12}, {28,3}, {30,10}, }; Tc YFwg[]="MessageItem.NEW()"; Tcpos ZcTbl39213[]={ {26,3}, {1,13}, {2,12}, {3,17}, }; Tc Ywma[]="MessageItem.addOption()"; Tcpos ZcTbl2449[]={ {32,9}, {1,5}, {2,7}, }; Tc YA9q[]="MessageItem.checkErrors()"; Tcpos ZcTbl39906[]={ {51,9}, {1,23}, {2,28}, {3,18}, {4,5}, {5,7}, {6,9}, {7,13}, {8,23}, {9,9}, {10,13}, {12,9}, {13,9}, {4,5}, {16,12}, }; Tc YU0e[]="MessageItem.findItem()"; Tcpos ZcTbl1679[]={ {38,9}, {1,5}, {2,7}, {3,16}, {1,5}, {6,5}, {7,22}, {9,12}, }; Tc Yu_S[]="PTokenInput.NEW()"; Tcpos ZcTbl44318[]={ {28,3}, {1,12}, {2,17}, }; Tc YnnL[]="PTokenInput.get()"; Tcpos ZcTbl19804[]={ {37,9}, {1,19}, }; Tc Y7nB[]="PTokenInput.getToken()"; Tcpos ZcTbl35249[]={ {48,9}, {1,5}, {2,26}, {4,22}, }; Tc YWz4[]="PTokenInput.push()"; Tcpos ZcTbl44960[]={ {42,9}, {1,5}, }; Tc YKZm[]="PTokenInput.pushToken()"; Tcpos ZcTbl20933[]={ {56,9}, {1,5}, }; Tc YWUU[]="PTokenize"; Tcpos ZcTbl50421[]={ {173,29}, }; Tc YKPD[]="PTokenize.get()"; Tcpos ZcTbl63024[]={ {19,18}, {1,18}, {4,5}, {6,18}, {7,30}, {9,16}, {10,5}, {11,7}, {13,5}, {15,18}, {17,18}, {19,18}, {21,18}, {23,18}, {25,18}, {27,18}, {29,18}, {31,18}, {34,9}, {35,18}, {37,9}, {38,13}, {39,11}, {42,11}, {43,13}, {44,13}, {47,11}, {48,15}, {49,13}, {50,15}, {53,13}, {54,15}, {55,22}, {56,15}, {57,22}, {58,15}, {60,15}, {63,13}, {37,9}, {69,13}, {70,20}, {71,11}, {72,15}, {73,13}, {75,19}, {77,19}, {79,19}, {82,11}, {83,11}, {84,13}, {85,11}, {86,13}, {92,11}, {93,13}, {97,13}, {98,20}, {100,13}, {101,13}, {102,15}, {103,17}, {101,13}, {105,13}, {108,20}, {109,11}, {110,22}, {114,15}, {115,16}, {116,12}, }; Tc Yit2[]="PTokenize.isIdChar()"; Tcpos ZcTbl41999[]={ {170,9}, }; Tc YPvQ[]="PTokenize.skipWhite()"; Tcpos ZcTbl50024[]={ {143,5}, {1,9}, {2,7}, {3,21}, {4,9}, {6,11}, {7,15}, {8,13}, {6,11}, {14,9}, {16,7}, {0,5}, {20,5}, }; Tc Ypaua[]="ParseProto.checkEof()"; Tcpos ZcTbl5070[]={ {398,5}, {1,7}, {2,14}, {4,12}, }; Tc Y0Ij[]="ParseProto.checkSemiColon()"; Tcpos ZcTbl35761[]={ {389,19}, {1,5}, {2,7}, {3,7}, }; Tc YDsz[]="ParseProto.parse()"; Tcpos ZcTbl71573[]={ {34,23}, {2,21}, {3,5}, {4,7}, {5,12}, {7,22}, {8,24}, {10,5}, {11,5}, {12,25}, {13,7}, {17,7}, {19,11}, {22,11}, {25,11}, {28,29}, {28,29}, {29,22}, {30,11}, {33,11}, {36,11}, {11,5}, {40,5}, {42,12}, }; Tc YCVw[]="ParseProto.parseEnum()"; Tcpos ZcTbl51410[]={ {344,21}, {2,19}, {3,5}, {4,7}, {6,17}, {7,9}, {8,7}, {9,9}, {11,9}, {13,13}, {14,11}, {17,11}, {20,11}, {21,13}, {23,27}, {25,13}, {26,11}, {27,13}, {30,20}, {31,11}, {33,11}, {11,9}, {36,9}, {40,12}, }; Tc YdOc[]="ParseProto.parseField()"; Tcpos ZcTbl52269[]={ {268,23}, {1,15}, {2,5}, {4,24}, {6,24}, {10,19}, {11,5}, {12,7}, {14,18}, {15,22}, {18,7}, {19,5}, {20,7}, {22,18}, {23,7}, {25,9}, {29,7}, {30,5}, {31,7}, {34,14}, {36,7}, {37,5}, {39,9}, {40,7}, {41,9}, {43,9}, {44,7}, {45,9}, {47,9}, {48,7}, {49,9}, {51,23}, {53,9}, {54,25}, {55,11}, {56,13}, {60,9}, {61,7}, {62,9}, {64,11}, {68,5}, {69,5}, {71,12}, }; Tc YJA9[]="ParseProto.parseMessage()"; Tcpos ZcTbl8550[]={ {219,24}, {2,19}, {3,5}, {4,7}, {6,17}, {7,9}, {8,7}, {9,9}, {11,9}, {12,13}, {13,11}, {16,11}, {19,11}, {23,15}, {26,33}, {26,33}, {27,26}, {28,15}, {31,15}, {34,15}, {37,15}, {11,9}, {41,7}, {44,12}, }; Tc YQ3a[]="ParseProto.parseNumber()"; Tcpos ZcTbl66510[]={ {408,19}, {1,5}, {2,7}, {4,20}, }; Tc YPIw[]="ParseProto.parseOption()"; Tcpos ZcTbl12726[]={ {95,25}, {1,19}, {2,5}, {3,7}, {5,18}, {6,19}, {8,9}, {9,7}, {10,11}, {11,9}, {12,11}, {14,23}, {15,24}, {16,11}, {18,21}, {19,9}, {22,12}, }; Tc YgZJ[]="ParseProto.parsePackage()"; Tcpos ZcTbl94525[]={ {81,19}, {1,5}, {2,7}, {3,26}, {4,7}, {6,21}, {8,5}, }; Tc YKht[]="ParseProto.parseService()"; Tcpos ZcTbl6262[]={ {134,27}, {3,19}, {4,5}, {5,7}, {7,20}, {8,9}, {9,7}, {10,9}, {12,9}, {13,13}, {14,11}, {17,11}, {21,11}, {22,13}, {24,15}, {25,13}, {26,15}, {28,29}, {29,15}, {32,17}, {33,15}, {34,17}, {36,17}, {37,15}, {38,17}, {40,33}, {42,15}, {43,19}, {44,17}, {45,19}, {48,17}, {49,15}, {50,17}, {56,17}, {58,15}, {59,30}, {60,19}, {62,15}, {63,17}, {65,34}, {67,15}, {68,19}, {69,17}, {70,19}, {74,15}, {12,9}, {80,12}, }; Tc YjO7[]="ProtoFile.NEW()"; Tcpos ZcTbl35721[]={ {27,3}, {1,15}, {2,15}, {3,14}, }; Tc Y5m_[]="ProtoFile.addItem()"; Tcpos ZcTbl3531[]={ {34,9}, {1,5}, {2,7}, {3,7}, }; Tc YcQA[]="ProtoFile.findItem()"; Tcpos ZcTbl38811[]={ {45,9}, {2,5}, {3,7}, {4,16}, {2,5}, {8,5}, {9,33}, {10,7}, {11,16}, {8,5}, {15,12}, }; Tc YViu[]="RpcItem.NEW()"; Tcpos ZcTbl57273[]={ {18,3}, {1,11}, }; Tc YYkI[]="SET.Set__t1.Init()"; Tcpos ZcTbl89012[]={ {41,13}, }; Tc YjAA[]="SET.Set__t1.NEW()"; Tcpos ZcTbl21378[]={ {45,5}, }; Tc YFAP[]="SET.Set__t1.has()"; Tcpos ZcTbl25860[]={ {88,11}, {1,20}, }; Tc YzJ7[]="SET.Set__t2.Init()"; Tcpos ZcTbl99713[]={ {41,13}, }; Tc YiL5[]="SET.Set__t2.NEW()"; Tcpos ZcTbl71979[]={ {45,5}, }; Tc YELk[]="SET.Set__t2.has()"; Tcpos ZcTbl76461[]={ {88,11}, {1,20}, }; Tc YLSX[]="ServiceItem.NEW()"; Tcpos ZcTbl36381[]={ {18,3}, {1,11}, }; Tc YM1j[]="ServiceItem.add()"; Tcpos ZcTbl55944[]={ {22,9}, {1,5}, }; Tc YYJc[]="ServiceItem.findItem()"; Tcpos ZcTbl66335[]={ {26,9}, {1,5}, {2,7}, {3,16}, {1,5}, {6,12}, }; Tc YQE_[]="TIME.Values.NEW()"; Tcpos ZcTbl5342[]={ {50,5}, {1,7}, }; Tc Y0DO[]="TIME.Values.NEW/2()"; Tcpos ZcTbl32939[]={ {64,5}, {2,4}, {23,13}, }; Tc YHWY[]="TIME.Values.ToString()"; Tcpos ZcTbl34818[]={ {111,11}, {1,27}, {2,7}, {3,7}, {4,7}, {5,7}, {6,7}, {7,7}, {8,7}, {9,7}, {10,7}, {11,7}, {12,7}, {13,16}, }; Tc YLwM[]="TIME.current()"; Tcpos ZcTbl50841[]={ {22,4}, {5,12}, }; Tc YnO0[]="WriteZimbu.hasNotRepeated()"; Tcpos ZcTbl10800[]={ {546,5}, {1,7}, {2,16}, {0,5}, {5,12}, }; Tc YIr_[]="WriteZimbu.hasRepeated()"; Tcpos ZcTbl1755[]={ {537,5}, {1,7}, {2,16}, {0,5}, {5,12}, }; Tc Yehha[]="WriteZimbu.write()"; Tcpos ZcTbl44260[]={ {24,22}, {1,5}, {2,7}, {3,12}, {5,5}, {6,5}, {7,5}, {8,5}, {9,5}, {13,5}, {14,13}, {15,21}, {16,7}, {17,15}, {20,13}, {22,19}, {23,5}, {24,13}, {26,7}, {27,5}, {28,13}, {31,11}, {32,5}, {35,5}, {36,7}, {37,27}, {37,27}, {38,9}, {39,19}, {40,25}, {40,25}, {41,9}, {42,19}, {43,31}, {43,31}, {44,9}, {46,9}, {35,5}, {50,5}, {52,5}, }; Tc Y8JY[]="WriteZimbu.writeAddGetHas()"; Tcpos ZcTbl24269[]={ {813,31}, {1,29}, {4,5}, {6,5}, {7,5}, {8,5}, {9,5}, {10,5}, {11,5}, {13,5}, {15,7}, {16,7}, {17,7}, {18,7}, {19,7}, {23,5}, {25,5}, {29,5}, {31,5}, {32,5}, {33,5}, {36,5}, {38,5}, {39,5}, {42,5}, {44,5}, {45,5}, {46,5}, {49,5}, {50,5}, {52,5}, {55,5}, {56,5}, {58,5}, {61,5}, {62,5}, {65,5}, {68,5}, {70,5}, {71,5}, {72,5}, }; Tc YjpD[]="WriteZimbu.writeClass()"; Tcpos ZcTbl1802[]={ {81,5}, {2,5}, {5,7}, {6,9}, {7,22}, {5,7}, {10,7}, {11,9}, {13,7}, {17,5}, {18,5}, {20,5}, {21,5}, {22,5}, {24,29}, {25,31}, {26,31}, {27,33}, {28,34}, {29,33}, {30,35}, {31,35}, {32,36}, {33,34}, {34,36}, {35,38}, {36,41}, {38,29}, {39,30}, {40,30}, {44,5}, {45,7}, {46,28}, {46,28}, {47,9}, {48,19}, {51,9}, {44,5}, {55,5}, {60,7}, {63,20}, {64,34}, {65,11}, {66,13}, {67,21}, {68,24}, {69,23}, {70,20}, {71,21}, {72,24}, {73,13}, {75,20}, {76,21}, {77,13}, {78,26}, {80,13}, {83,20}, {84,19}, {85,22}, {86,11}, {89,20}, {90,19}, {91,22}, {92,11}, {94,20}, {95,19}, {96,22}, {97,11}, {99,20}, {100,19}, {101,22}, {102,11}, {104,20}, {105,19}, {106,22}, {107,11}, {109,20}, {110,19}, {111,22}, {112,11}, {114,20}, {115,19}, {116,22}, {117,11}, {119,20}, {120,23}, {121,19}, {122,22}, {123,11}, {125,11}, {127,7}, {128,21}, {131,7}, {132,9}, {134,9}, {137,17}, {138,9}, {140,9}, {142,9}, {145,28}, }; Tcpos ZcTbl1803[]={ {227,9}, {1,11}, {2,11}, {5,9}, {8,7}, {11,7}, {12,9}, {-91,5}, {17,5}, {18,5}, {19,7}, {18,5}, {21,5}, {22,7}, {21,5}, {24,5}, {27,5}, {28,5}, {29,5}, {30,7}, {32,20}, {33,7}, {34,9}, {35,13}, {33,7}, {38,5}, {39,5}, {42,5}, {43,7}, {45,5}, {46,7}, {48,5}, {49,7}, {51,5}, {52,7}, {54,5}, {55,7}, {57,5}, {58,7}, {60,5}, {61,7}, {64,5}, {67,5}, {68,7}, {71,5}, {72,7}, {76,5}, {79,5}, {81,5}, {82,5}, {85,5}, {86,5}, {87,5}, {88,5}, {91,5}, {92,5}, {93,5}, {94,5}, {95,5}, {96,5}, {97,5}, {98,5}, {99,5}, {100,5}, {101,5}, {102,5}, {104,5}, {105,5}, {106,5}, {107,5}, {110,5}, {111,5}, {112,5}, {113,5}, {114,5}, {115,5}, {116,5}, {117,5}, {120,5}, {123,5}, {127,5}, {128,5}, {129,5}, {132,5}, {133,7}, {135,7}, {136,16}, {138,16}, {140,7}, {141,7}, {142,7}, {143,9}, {145,9}, {147,7}, {148,7}, {150,7}, {151,7}, {152,7}, {153,9}, {155,9}, }; Tcpos ZcTbl1804[]={ {383,9}, {-24,5}, {4,5}, {5,5}, {7,5}, {9,5}, {10,5}, {12,5}, {14,5}, {15,7}, {16,9}, {16,19}, {16,19}, {14,5}, {21,5}, {24,5}, }; Tc YyyW[]="WriteZimbu.writeCopy()"; Tcpos ZcTbl75475[]={ {654,5}, {1,29}, {2,5}, {3,5}, {4,42}, {5,26}, {6,24}, {7,7}, {8,17}, {9,9}, {10,9}, {12,7}, {13,9}, {14,9}, {15,9}, {16,9}, {17,9}, {18,11}, {21,11}, {23,9}, {24,9}, {25,9}, {26,9}, {28,9}, {30,9}, {31,11}, {32,11}, {35,11}, {37,11}, {41,7}, {42,9}, {3,5}, {45,5}, {46,5}, }; Tc YblT[]="WriteZimbu.writeEnum()"; Tcpos ZcTbl45169[]={ {934,5}, {1,5}, {2,5}, {4,7}, {2,5}, {6,5}, {9,5}, {11,5}, {12,5}, {13,7}, {12,5}, {16,5}, {18,5}, {20,5}, {21,7}, {20,5}, {24,5}, }; Tc YVKo[]="WriteZimbu.writeError()"; Tcpos ZcTbl1422[]={ {964,22}, {1,5}, {2,7}, {3,12}, {5,5}, {6,5}, }; Tc YSmP[]="WriteZimbu.writeFieldTable()"; Tcpos ZcTbl49240[]={ {720,5}, {1,5}, {2,7}, {1,5}, {8,5}, }; Tc YMb9[]="WriteZimbu.writeGetSet()"; Tcpos ZcTbl59408[]={ {415,19}, {1,22}, {5,5}, {6,7}, {8,9}, {9,9}, {10,11}, {12,9}, {13,9}, {14,9}, {15,11}, {16,13}, {17,35}, {18,13}, {19,26}, {21,13}, {22,15}, {24,35}, {25,15}, {27,15}, {14,9}, {31,9}, {32,9}, {33,9}, {36,9}, {37,11}, {38,11}, {39,13}, {41,11}, {42,11}, {43,11}, {44,11}, {45,13}, {46,37}, {47,15}, {48,28}, {50,15}, {51,15}, {44,11}, {54,11}, {55,11}, {56,11}, {61,9}, {62,18}, {63,11}, {64,11}, {65,11}, {66,11}, {67,35}, {68,13}, {69,13}, {70,15}, {72,15}, {74,13}, {75,15}, {78,22}, {79,15}, {80,25}, {81,15}, {83,34}, {84,15}, {85,17}, {87,17}, {90,13}, {66,11}, {92,11}, {93,11}, {96,11}, {97,13}, {98,13}, {99,13}, {100,13}, {101,13}, {102,37}, {103,15}, {104,15}, {105,15}, {106,17}, {108,17}, {110,15}, {111,15}, {101,13}, {113,13}, {114,13}, {5,5}, }; Tc Ynau[]="WriteZimbu.writeHasField()"; Tcpos ZcTbl85132[]={ {642,5}, {1,5}, {2,5}, {3,7}, {2,5}, {6,5}, {7,5}, {8,5}, }; Tc YtY8[]="WriteZimbu.writeService()"; Tcpos ZcTbl54137[]={ {890,5}, {2,29}, {3,5}, {5,7}, {7,7}, {12,7}, {13,7}, {14,7}, {16,44}, {17,57}, {18,7}, {19,7}, {21,7}, {22,7}, {24,7}, {25,7}, {26,7}, {28,7}, {31,7}, {32,7}, {37,7}, {3,5}, {39,5}, }; Tc YTVO[]="WriteZimbu.writeSetGetHas()"; Tcpos ZcTbl21476[]={ {735,31}, {1,29}, {2,28}, {5,5}, {7,5}, {9,7}, {11,7}, {13,5}, {14,7}, {16,5}, {17,5}, {20,5}, {21,7}, {22,7}, {23,7}, {24,7}, {28,5}, {30,5}, {31,7}, {33,7}, {35,5}, {36,7}, {37,17}, {38,7}, {39,17}, {40,7}, {41,62}, {42,7}, {44,7}, {46,5}, {48,5}, {49,7}, {51,7}, {53,5}, {56,5}, {57,5}, {58,7}, {60,7}, {62,5}, {65,5}, {67,5}, {68,5}, {69,7}, {71,5}, {72,5}, }; Tc YS9k[]="WriteZimbu.writeSize()"; Tcpos ZcTbl20075[]={ {706,5}, {1,5}, {2,5}, {3,7}, {2,5}, {7,5}, {8,5}, {9,5}, }; Tc Yqom[]="WriteZimbu.writeWriteMerge()"; Tcpos ZcTbl37411[]={ {558,19}, {1,22}, {5,5}, {6,7}, {7,9}, {8,9}, {9,11}, {11,9}, {12,9}, {13,9}, {14,11}, {15,13}, {17,13}, {18,15}, {20,13}, {13,9}, {23,9}, {24,9}, {25,9}, {27,9}, {28,11}, {30,11}, {32,9}, {33,9}, {34,11}, {35,13}, {36,13}, {37,15}, {38,15}, {39,15}, {42,15}, {33,9}, {46,9}, {47,9}, {50,9}, {51,20}, {52,11}, {53,11}, {54,11}, {55,35}, {56,11}, {57,13}, {58,13}, {59,13}, {60,13}, {61,13}, {62,15}, {63,15}, {64,15}, {65,15}, {67,15}, {69,15}, {72,13}, {56,11}, {74,11}, {75,11}, {76,11}, {5,5}, }; Tc Ym1t[]="Z.Pos.ToString()"; Tcpos ZcTbl18187[]={ {83,11}, {1,27}, {2,7}, {3,9}, {5,9}, {7,7}, {8,7}, {9,7}, {10,7}, {11,16}, }; Tc YPRm[]="Z.Pos.copy()"; Tcpos ZcTbl16020[]={ {42,11}, {1,15}, {2,14}, {3,13}, {4,14}, {5,14}, }; Tc YzF7[]="Z.Pos.nextLine()"; Tcpos ZcTbl46868[]={ {59,11}, {1,12}, {2,12}, }; Tcode ZcodeTable[]={ {412,Yt1T,YxLq,ZcTbl412}, {1422,YFTE,YVKo,ZcTbl1422}, {1679,Yxbi,YU0e,ZcTbl1679}, {1755,YFTE,YIr_,ZcTbl1755}, {1802,YFTE,YjpD,ZcTbl1802}, {1803,YFTE,YjpD,ZcTbl1803}, {1804,YFTE,YjpD,ZcTbl1804}, {1872,Yay0,YNFk,ZcTbl1872}, {2449,Yxbi,Ywma,ZcTbl2449}, {2571,Y7gD,YAt2,ZcTbl2571}, {3273,YCG4,Y_VO,ZcTbl3273}, {3531,Y_R2,Y5m_,ZcTbl3531}, {5070,YnGo,Ypaua,ZcTbl5070}, {5270,YLrK,Y9QD,ZcTbl5270}, {5342,YyXk,YQE_,ZcTbl5342}, {6262,YnGo,YKht,ZcTbl6262}, {6308,Yt1T,YR5_,ZcTbl6308}, {7452,Yay0,Ys1a,ZcTbl7452}, {8550,YnGo,YJA9,ZcTbl8550}, {9948,Yt1T,YALK,ZcTbl9948}, {10613,Yt1T,YCbo,ZcTbl10613}, {10800,YFTE,YnO0,ZcTbl10800}, {11217,Yt1T,YoZS,ZcTbl11217}, {12726,YnGo,YPIw,ZcTbl12726}, {14715,Yt1T,Y4SL,ZcTbl14715}, {15718,Yt1T,YEFs,ZcTbl15718}, {15755,Yay0,YEgn,ZcTbl15755}, {16020,Y3zM,YPRm,ZcTbl16020}, {16053,Yay0,Y5P_,ZcTbl16053}, {16350,YCG4,Ygzb,ZcTbl16350}, {18187,Y3zM,Ym1t,ZcTbl18187}, {19772,Y7gD,YHJi,ZcTbl19772}, {19804,YEew,YnnL,ZcTbl19804}, {19887,Ydmy,YHM2,ZcTbl19887}, {20075,YFTE,YS9k,ZcTbl20075}, {20149,Yt1T,YFbI,ZcTbl20149}, {20933,YEew,YKZm,ZcTbl20933}, {21378,YxHL,YjAA,ZcTbl21378}, {21418,Yt1T,YtpQ,ZcTbl21418}, {21476,YFTE,YTVO,ZcTbl21476}, {24269,YFTE,Y8JY,ZcTbl24269}, {24916,Yt1T,Y9iJ,ZcTbl24916}, {25860,YxHL,YFAP,ZcTbl25860}, {25958,Yt1T,Y4vu,ZcTbl25958}, {26760,Yay0,YYk7,ZcTbl26760}, {29560,YCG4,YzK9,ZcTbl29560}, {29585,Yt1T,YAVe,ZcTbl29585}, {32086,Yt1T,Y1As,ZcTbl32086}, {32939,YyXk,Y0DO,ZcTbl32939}, {34047,Ydmy,Yq05,ZcTbl34047}, {34818,YyXk,YHWY,ZcTbl34818}, {35088,Yt1T,YcIS,ZcTbl35088}, {35249,YEew,Y7nB,ZcTbl35249}, {35721,Y_R2,YjO7,ZcTbl35721}, {35761,YnGo,Y0Ij,ZcTbl35761}, {36159,Yt1T,Y_4w,ZcTbl36159}, {36283,Y7gD,YBp9,ZcTbl36283}, {36381,YGYp,YLSX,ZcTbl36381}, {36491,Yt1T,YYT9,ZcTbl36491}, {37411,YFTE,Yqom,ZcTbl37411}, {38811,Y_R2,YcQA,ZcTbl38811}, {38911,YCG4,YM2k,ZcTbl38911}, {39213,Yxbi,YFwg,ZcTbl39213}, {39906,Yxbi,YA9q,ZcTbl39906}, {40190,Yeop,YLFA,ZcTbl40190}, {41999,Y1IY,Yit2,ZcTbl41999}, {42983,Yt1T,Y9aV,ZcTbl42983}, {43000,YCG4,YEFE,ZcTbl43000}, {43124,Yt1T,Ygil,ZcTbl43124}, {44130,Yt1T,YG80,ZcTbl44130}, {44260,YFTE,Yehha,ZcTbl44260}, {44318,YEew,Yu_S,ZcTbl44318}, {44401,Ydmy,YOoa,ZcTbl44401}, {44960,YEew,YWz4,ZcTbl44960}, {45169,YFTE,YblT,ZcTbl45169}, {45209,Yt1T,Y2NH,ZcTbl45209}, {45289,Yt1T,Y7gV,ZcTbl45289}, {46171,Yt1T,Y9VX,ZcTbl46171}, {46631,Yay0,YHCY,ZcTbl46631}, {46761,Yay0,YN2v,ZcTbl46761}, {46868,Y3zM,YzF7,ZcTbl46868}, {48299,Yt1T,Y9Cv,ZcTbl48299}, {49183,Yt1T,YgcH,ZcTbl49183}, {49240,YFTE,YSmP,ZcTbl49240}, {49285,Yay0,Y1Ue,ZcTbl49285}, {50024,Y1IY,YPvQ,ZcTbl50024}, {50421,Y1IY,YWUU,ZcTbl50421}, {50841,YyXk,YLwM,ZcTbl50841}, {51410,YnGo,YCVw,ZcTbl51410}, {52269,YnGo,YdOc,ZcTbl52269}, {52386,Yt1T,YgcM,ZcTbl52386}, {52608,Yt1T,YqK0,ZcTbl52608}, {53325,Yt1T,YlJi,ZcTbl53325}, {53377,Yt1T,Yp81,ZcTbl53377}, {54137,YFTE,YtY8,ZcTbl54137}, {54331,Yt1T,YLzZ,ZcTbl54331}, {55944,YGYp,YM1j,ZcTbl55944}, {56372,Yt1T,Y4u_,ZcTbl56372}, {56381,Yt1T,Y99g,ZcTbl56381}, {56555,Y76z,YFIR,ZcTbl56555}, {57273,YjxU,YViu,ZcTbl57273}, {58121,Yeop,YmDz,ZcTbl58121}, {58975,Yay0,YSa1,ZcTbl58975}, {59408,YFTE,YMb9,ZcTbl59408}, {59819,Yay0,YGQL,ZcTbl59819}, {60567,Yay0,YskO,ZcTbl60567}, {60593,Yt1T,Y5LR,ZcTbl60593}, {60791,Y7gD,YIwZ,ZcTbl60791}, {61284,YCG4,Y2cg,ZcTbl61284}, {62809,Yt1T,Ylj3,ZcTbl62809}, {63024,Y1IY,YKPD,ZcTbl63024}, {63578,Yt1T,Yuz_,ZcTbl63578}, {64478,YCG4,YRbs,ZcTbl64478}, {64531,Yay0,YrJP,ZcTbl64531}, {66188,Yay0,YJ7z,ZcTbl66188}, {66335,YGYp,YYJc,ZcTbl66335}, {66501,YCG4,YPPv,ZcTbl66501}, {66510,YnGo,YQ3a,ZcTbl66510}, {71573,YnGo,YDsz,ZcTbl71573}, {71979,YxHL,YiL5,ZcTbl71979}, {72007,Yay0,YzQB,ZcTbl72007}, {73471,Yt1T,Y_Qs,ZcTbl73471}, {73580,Yt1T,YF6S,ZcTbl73580}, {75475,YFTE,YyyW,ZcTbl75475}, {75697,YCG4,YgDO,ZcTbl75697}, {76461,YxHL,YELk,ZcTbl76461}, {76644,YCG4,YImf,ZcTbl76644}, {78082,Yt1T,YbzA,ZcTbl78082}, {80644,Yt1T,YobA,ZcTbl80644}, {81580,Yay0,Y5X7,ZcTbl81580}, {81798,YCG4,YMnk,ZcTbl81798}, {82533,YCG4,Yh2v,ZcTbl82533}, {82534,YCG4,Yh2v,ZcTbl82534}, {82618,Yay0,Yxlj,ZcTbl82618}, {83326,Y76z,YVvh,ZcTbl83326}, {84870,Yay0,Y_pS,ZcTbl84870}, {84899,Y76z,Y8w5,ZcTbl84899}, {85000,Yt1T,Ycb9,ZcTbl85000}, {85132,YFTE,Ynau,ZcTbl85132}, {85295,YCG4,Yza4,ZcTbl85295}, {86206,YCG4,YZNA,ZcTbl86206}, {86818,Yt1T,YlgI,ZcTbl86818}, {87235,Yt1T,YR5m,ZcTbl87235}, {89012,YxHL,YYkI,ZcTbl89012}, {89141,Yeop,YTU3,ZcTbl89141}, {89685,Yt1T,Y59h,ZcTbl89685}, {89987,Yay0,YCbR,ZcTbl89987}, {90183,Y7gD,Y5D2,ZcTbl90183}, {92163,Yt1T,YTjU,ZcTbl92163}, {94525,YnGo,YgZJ,ZcTbl94525}, {94823,Yay0,Yj_J,ZcTbl94823}, {95201,Yt1T,YhC6,ZcTbl95201}, {96107,Yt1T,YMF2,ZcTbl96107}, {97019,Yt1T,YgQK,ZcTbl97019}, {99713,YxHL,YzJ7,ZcTbl99713}, {99838,Yay0,YTE3,ZcTbl99838}, {99886,Yt1T,Y0Jk,ZcTbl99886}, }; #ifdef SIGSEGV void Zdeadly(int nr) { ZthrowDeadly(nr); } #endif void ZthreadGC() { } Ti ZstringSizePtr(Tc *s, Tc **dp) { Tc *p; Ti len; p = s + ZOH_OFF; if ((*p & 0x80) == 0) { /* be quick for short string */ *dp = p + 1; return *p; } len = *p & 0x7f; ++p; while ((*p & 0x80) != 0) { len = (len << 7) + (*p & 0x7f); ++p; } *dp = p + 1; return (len << 7) + *p; } void ZthrowCstringNil(char *text) { YvdV(NULL, Zstr(text)); } void ZthrowThisNil() { YvdV(NULL, Zstr("THIS is NIL")); } void ZthrowCstringInit(char *text) { Y3w6(Zstr(text)); } void ZthrowOutOfMemory(Ti size) { Y1KV(size); } void ZthrowCstringOutOfRange(Ti i, char *text) { Y6NT(i, Zstr(text)); } void ZthrowCstringBadValue(char *msg) { Yaez(Zstr(msg)); } void ZthrowDeadly(int nr) { YE93((Ti)nr); } void ZthrowInternal(Tc *text) { YUSH(NULL, text); } Tc *ZintAsString(Ti n) { if (n < 0 || n > 0x10fffff) ZthrowCstringBadValue("asString(): Character must be in range 0 - 0x10ffff"); if (n <= 0x7f) { Tc *p = Za(ZOH_OFF + 3); p[ZOH_OFF] = 1; p[ZOH_OFF + 1] = n; p[ZOH_OFF + 2] = 0; return p; } if (n <= 0x7ff) { Tc *p = Za(ZOH_OFF + 4); p[ZOH_OFF] = 2; p[ZOH_OFF + 1] = 0xc0 + ((unsigned)n >> 6); p[ZOH_OFF + 2] = 0x80 + (n & 0x3f); p[ZOH_OFF + 3] = 0; return p; } if (n <= 0xffff) { Tc *p = Za(ZOH_OFF + 5); p[ZOH_OFF] = 3; p[ZOH_OFF + 1] = 0xe0 + ((unsigned)n >> 12); p[ZOH_OFF + 2] = 0x80 + (((unsigned)n >> 6) & 0x3f); p[ZOH_OFF + 3] = 0x80 + (n & 0x3f); p[ZOH_OFF + 4] = 0; return p; } Tc *p = Za(ZOH_OFF + 6); p[ZOH_OFF] = 4; p[ZOH_OFF + 1] = 0xf0 + ((unsigned)n >> 18); p[ZOH_OFF + 2] = 0x80 + (((unsigned)n >> 12) & 0x3f); p[ZOH_OFF + 3] = 0x80 + (((unsigned)n >> 6) & 0x3f); p[ZOH_OFF + 4] = 0x80 + (n & 0xef); p[ZOH_OFF + 5] = 0; return p; } int Zchar2stringBuf(Ti n, Tc *buf) { if (n < 0 || n > 0x10fffff) ZthrowCstringBadValue("asString(): Character must be in range 0 - 0x10ffff"); if (n <= 0x7f) { buf[0] = n; buf[1] = 0; return 1; } if (n <= 0x7ff) { buf[0] = 0xc0 + ((unsigned)n >> 6); buf[1] = 0x80 + (n & 0x3f); buf[2] = 0; return 2; } if (n <= 0xffff) { buf[0] = 0xe0 + ((unsigned)n >> 12); buf[1] = 0x80 + (((unsigned)n >> 6) & 0x3f); buf[2] = 0x80 + (n & 0x3f); buf[3] = 0; return 3; } buf[0] = 0xf0 + ((unsigned)n >> 18); buf[1] = 0x80 + (((unsigned)n >> 12) & 0x3f); buf[2] = 0x80 + (((unsigned)n >> 6) & 0x3f); buf[3] = 0x80 + (n & 0xef); buf[4] = 0; return 4; } /* concat string */ Tc *ZcS(Tc *l, Tc *ri) { Tc *l_p; Ti l_len; Tc *r_p; Ti r_len; Ti len; Tc *pp; Tc *r; if (l == NULL) {l_len = 3; l_p = (Tc*)"NIL";} else l_len = ZstringSizePtr(l, &l_p); if (ri == NULL) {r_len = 3; r_p = (Tc*)"NIL";} else r_len = ZstringSizePtr(ri, &r_p); len = l_len + r_len; r = ZnewStringInit(len, &pp); memmove(pp, l_p, l_len); memmove(pp + l_len, r_p, r_len); return r; } /* concat string */ Tc *ZcS3(Tc *s1, Tc *s2, Tc *s3) { Tc *p1; Ti len1; Tc *p2; Ti len2; Tc *p3; Ti len3; Ti len; Tc *pp; Tc *r; if (s1 == NULL) {len1 = 3; p1 = (Tc*)"NIL";} else len1 = ZstringSizePtr(s1, &p1); if (s2 == NULL) {len2 = 3; p2 = (Tc*)"NIL";} else len2 = ZstringSizePtr(s2, &p2); if (s3 == NULL) {len3 = 3; p3 = (Tc*)"NIL";} else len3 = ZstringSizePtr(s3, &p3); len = len1 + len2 + len3; r = ZnewStringInit(len, &pp); memmove(pp, p1, len1); memmove(pp + len1, p2, len2); memmove(pp + len1 + len2, p3, len3); return r; } /* concat string */ Tc *ZcS5(Tc *s1, Tc *s2, Tc *s3, Tc *s4, Tc *s5) { Tc *p1; Ti len1; Tc *p2; Ti len2; Tc *p3; Ti len3; Tc *p4; Ti len4; Tc *p5; Ti len5; Ti len; Tc *pp; Tc *r; if (s1 == NULL) {len1 = 3; p1 = (Tc*)"NIL";} else len1 = ZstringSizePtr(s1, &p1); if (s2 == NULL) {len2 = 3; p2 = (Tc*)"NIL";} else len2 = ZstringSizePtr(s2, &p2); if (s3 == NULL) {len3 = 3; p3 = (Tc*)"NIL";} else len3 = ZstringSizePtr(s3, &p3); if (s4 == NULL) {len4 = 3; p4 = (Tc*)"NIL";} else len4 = ZstringSizePtr(s4, &p4); if (s5 == (Tc*)1) len5 = 0; else if (s5 == NULL) {len5 = 3; p5 = (Tc*)"NIL";} else len5 = ZstringSizePtr(s5, &p5); len = len1 + len2 + len3 + len4 + len5; r = ZnewStringInit(len, &pp); memmove(pp, p1, len1); memmove(pp + len1, p2, len2); memmove(pp + len1 + len2, p3, len3); memmove(pp + len1 + len2 + len3, p4, len4); if (s5 != (Tc*)1) memmove(pp + len1 + len2 + len3 + len4, p5, len5); return r; } /* concat string */ Tc *ZcS8(Tc *s1, Tc *s2, Tc *s3, Tc *s4, Tc *s5, Tc *s6, Tc *s7, Tc *s8) { Tc *p[8]; Ti len[8]; Ti totlen = 0; Tc *pp; Tc *r; int i; if (s1 == NULL) {len[0] = 3; p[0] = (Tc*)"NIL";} else len[0] = ZstringSizePtr(s1, &p[0]); if (s2 == NULL) {len[1] = 3; p[1] = (Tc*)"NIL";} else len[1] = ZstringSizePtr(s2, &p[1]); if (s3 == NULL) {len[2] = 3; p[2] = (Tc*)"NIL";} else len[2] = ZstringSizePtr(s3, &p[2]); if (s4 == NULL) {len[3] = 3; p[3] = (Tc*)"NIL";} else len[3] = ZstringSizePtr(s4, &p[3]); if (s5 == NULL) {len[4] = 3; p[4] = (Tc*)"NIL";} else len[4] = ZstringSizePtr(s5, &p[4]); if (s6 == NULL) {len[5] = 3; p[5] = (Tc*)"NIL";} else len[5] = ZstringSizePtr(s6, &p[5]); if (s7 == (Tc*)1) len[6] = 0; else if (s7 == NULL) {len[6] = 3; p[6] = (Tc*)"NIL";} else len[6] = ZstringSizePtr(s7, &p[6]); if (s8 == (Tc*)1) len[7] = 0; else if (s8 == NULL) {len[7] = 3; p[7] = (Tc*)"NIL";} else len[7] = ZstringSizePtr(s8, &p[7]); for (i = 0; i < 8; ++i) totlen += len[i]; r = ZnewStringInit(totlen, &pp); totlen = 0; for (i = 0; i < 8; ++i) { memmove(pp + totlen, p[i], len[i]); totlen += len[i]; } return r; } /* concat string */ Tc *ZcS12(Tc *s1, Tc *s2, Tc *s3, Tc *s4, Tc *s5, Tc *s6, Tc *s7, Tc *s8, Tc *s9, Tc *s10, Tc *s11, Tc *s12) { Tc *p[12]; Ti len[12]; Ti totlen = 0; Tc *pp; Tc *r; int i; if (s1 == NULL) {len[0] = 3; p[0] = (Tc*)"NIL";} else len[0] = ZstringSizePtr(s1, &p[0]); if (s2 == NULL) {len[1] = 3; p[1] = (Tc*)"NIL";} else len[1] = ZstringSizePtr(s2, &p[1]); if (s3 == NULL) {len[2] = 3; p[2] = (Tc*)"NIL";} else len[2] = ZstringSizePtr(s3, &p[2]); if (s4 == NULL) {len[3] = 3; p[3] = (Tc*)"NIL";} else len[3] = ZstringSizePtr(s4, &p[3]); if (s5 == NULL) {len[4] = 3; p[4] = (Tc*)"NIL";} else len[4] = ZstringSizePtr(s5, &p[4]); if (s6 == NULL) {len[5] = 3; p[5] = (Tc*)"NIL";} else len[5] = ZstringSizePtr(s6, &p[5]); if (s7 == NULL) {len[6] = 3; p[6] = (Tc*)"NIL";} else len[6] = ZstringSizePtr(s7, &p[6]); if (s8 == NULL) {len[7] = 3; p[7] = (Tc*)"NIL";} else len[7] = ZstringSizePtr(s8, &p[7]); if (s9 == NULL) {len[8] = 3; p[8] = (Tc*)"NIL";} else len[8] = ZstringSizePtr(s9, &p[8]); if (s10 == (Tc*)1) len[9] = 0; else if (s10 == NULL) {len[9] = 3; p[9] = (Tc*)"NIL";} else len[9] = ZstringSizePtr(s10, &p[9]); if (s11 == (Tc*)1) len[10] = 0; else if (s11 == NULL) {len[10] = 3; p[10] = (Tc*)"NIL";} else len[10] = ZstringSizePtr(s11, &p[10]); if (s12 == (Tc*)1) len[11] = 0; else if (s12 == NULL) {len[11] = 3; p[11] = (Tc*)"NIL";} else len[11] = ZstringSizePtr(s12, &p[11]); for (i = 0; i < 12; ++i) totlen += len[i]; r = ZnewStringInit(totlen, &pp); totlen = 0; for (i = 0; i < 12; ++i) { memmove(pp + totlen, p[i], len[i]); totlen += len[i]; } return r; } Tr Zao(void *ptr, Tc **table, Ti type) { Tr tr; tr.ptr = ptr; tr.table = table; tr.type = type; return tr; } /* fill not-allocated object reference */ Tr *Znao(Tr *p, void *ptr, Tc **table, Ti type) { p->ptr = ptr; p->table = table; p->type = type; return p; } Tr ZconvertZioref(Tr orig, Tc ***table, int type, int maxType, Ti pos) { Tr p; if (orig.ptr == NULL) p.ptr = NULL; else { if (orig.type < type || orig.type >= maxType) YTuG(pos); p.ptr = orig.ptr; p.type = orig.type - type; p.table = table[p.type]; } return p; } void *Zio(int type, Ti pos, Tr *p) { void *r; if (p == NULL || p->ptr == NULL) r = NULL; else { if (p->type != type) YTuG(pos); r = p->ptr; } return r; } void *Znio(int type, Ti pos, Tr tr) { void *r; if (tr.ptr == NULL) r = NULL; else { if (tr.type != type) YTuG(pos); r = tr.ptr; } return r; } void Zexit(YkxB *pos, Ti val) { beforeExit(); exit((int)val); } Ti ZChar2ByteIdx(Tc *p, Ti len, Ti charIdx) { Ti idx = 0; Ti count = 0; while (count < charIdx) { if (idx == len) break; ++idx; if ((p[idx - 1] & 0x80) != 0) { while ((p[idx] & 0xc0) == 0x80) ++idx; } ++count; } return idx; } Ti ZfromChar(Tc *p) { if (*p <= 0x7f) return *p; if ((*p & 0xe0) == 0xc0) return ((p[0] & 0x1f) << 6) + (p[1] & 0x3f); if ((*p & 0xf0) == 0xe0) return ((p[0] & 0x0f) << 12) + ((p[1] & 0x3f) << 6) + (p[2] & 0x3f); return ((p[0] & 0x07) << 18) + ((p[1] & 0x3f) << 12) + ((p[2] & 0x3f) << 6) + (p[3] & 0x3f); } Ti ZstringGetChar(Tc *sv, Ti idx) { Ti i; Tc *p; Ti len; Ti r; if (sv == NULL) ZthrowCstringNil("using [] on NIL"); if (idx < 0) ZthrowCstringOutOfRange(idx, "using negative index"); len = ZstringSizePtr(sv, &p); i = ZChar2ByteIdx(p, len, idx); if (i >= len) ZthrowCstringOutOfRange(idx, "index too big"); r = ZfromChar(p + i); return r; } Tc *Zbool2string(Tb n) { return Zstr(n == 0 ? "FALSE" : "TRUE"); } Ti Zutf8size(Tc *sp, Ti len) { Tc *p = (Tc*)sp; Tc *pend = p + len; Ti clen = 0; while (p < pend) { if ((*p & 0xc0) != 0x80) ++clen; ++p; } return clen; } Ti ZstringSize(Tc *s) { Tc *p; Ti r; Ti len; if (s == NULL) return 0; len = ZstringSizePtr(s, &p); r = Zutf8size(p, len); return r; } Ti ZbyteStringSize(Tc *s) { Tc *p; Ti len; if (s == NULL) return 0; p = s + ZOH_OFF; if ((*p & 0x80) == 0) { return *p; /* be quick for short string */ } len = *p & 0x7f; ++p; while ((*p & 0x80) != 0) { len = (len << 7) + (*p & 0x7f); ++p; } return (len << 7) + *p; } Tc *Zint2string(Ti n) { char buf[30]; char *p; int len; sprintf(buf, ZINT_FORMAT, n); len = (int)strlen(buf); p = Za(ZOH_OFF + len + 2); p[ZOH_OFF] = len; strcpy(p + ZOH_OFF + 1, buf); return (Tc*)p; } Tc *ZintFormat(Tc *fmt, Ti n) { char fmtbuf[100]; char buf[100]; char *p; int len; int c; Tc *fmtp; if (fmt == NULL) ZthrowCstringNil("ToString(): format is NIL"); if (ZstringSizePtr(fmt, &fmtp) > 90) { ZthrowCstringBadValue("ToString(): format too long"); } c = fmtp[strlen((char*)fmtp) - 1]; if (c != 'd' && c != 'x') { ZthrowCstringBadValue("ToString(): format must end in 'd' or 'x'"); } sprintf(fmtbuf, "%%%s", fmtp); strcpy(fmtbuf + strlen(fmtbuf) - 1, (c == 'd' ? ZINT_FORMAT : ZINT_XFORMAT) + 1); sprintf(buf, fmtbuf, n); len = (int)strlen(buf); p = Za(ZOH_OFF + len + 2); p[ZOH_OFF] = len; strcpy(p + ZOH_OFF + 1, buf); return (Tc*)p; } Tc *Zenum2string(char **names, Te n) { return Zstr((n < 0 || n >= (Te)(size_t)names[0]) ? "INVALID" : names[n + 1]); } char *ZgetCstring(Tc *s) { Tc *p; if (s == NULL) return NULL; p = s + ZOH_OFF; while ((*p & 0x80) != 0) ++p; return (char *)p + 1; } Tc *ZstringToUpperAscii(Tc *ss) { Tc *r; Tc *d; Tc *s; Ti len; if (ss == NULL) return NULL; len = ZstringSizePtr(ss, &s); r = ZnewString(s, len); d = r + (s - (Tc*)ss); while (*s != 0) *d++ = toupper(*s++); *d = 0; return (Tc*)r; } Tc *ZstringToUpper(Tc *ss) { return ZstringToUpperAscii(ss); } void ZforRangeNew(Ti start, Ti last, int until, Ti step, Tfr *s) { s->idx = start; if (until) s->last = last - (step > 0 ? 1 : -1); else s->last = last; s->step = step; } void ZforRangeGetInt(Tfr *s, Ti *p) { *p = s->idx; } int ZforRangeContInt(Tfr *s) { return s->step > 0 ? (s->idx <= s->last) : (s->idx >= s->last); } void ZforRangeNextInt(Tfr *s, Ti *p) { s->idx += s->step; ZforRangeGetInt(s, p); } void ZthrowIobject(Tr eo) { YxIS(eo); } int ZstringCmp(Tc *s1, Tc *s2) { Tc *p1; Tc *p2; Ti len1; Ti len2; int r; if (s1 == NULL || s2 == NULL) { if (s1 == NULL && s2 == NULL) r = 0; else r = 1; goto end; } if (s1[ZOH_OFF] != s2[ZOH_OFF]) { r = 1; goto end; } len1 = ZstringSizePtr(s1, &p1); len2 = ZstringSizePtr(s2, &p2); if (len1 == len2) { r = memcmp(p1, p2, len1); goto end; } r = 1; end: return r; } Ti ZChar2ByteIdxEnd(Tc *p, Ti len, Ti charIdx) { Ti idx = len; Ti count = 0; while (count < charIdx) { if (idx == 0) return -1; --idx; while (idx > 0 && (p[idx] & 0xc0) == 0x80) --idx; ++count; } return idx; } Ti ZstringFindLen(Tc *big, Ti biglen, Tc *small, Ti smalllen) { Ti i; Ti ci = 0; for (i = 0; i <= biglen - smalllen; ++ci) { if (memcmp(big + i, small, smalllen) == 0) return ci; ++i; while ((big[i] & 0xc0) == 0x80 && i < biglen) ++i; } return -1; } Ti ZstringFind(Tc *big, Tc *small, int dn) { Tc *bigp; Tc *smallp; Ti biglen; Ti smalllen; Ti r; if (big == NULL) { if (!dn) ZthrowCstringNil("using find() on NIL"); r = -1; } else { if (small == NULL) ZthrowCstringNil("using find() with NIL argument"); biglen = ZstringSizePtr(big, &bigp); smalllen = ZstringSizePtr(small, &smallp); r = ZstringFindLen(bigp, biglen, smallp, smalllen); } return r; } Ti ZptrFindChar2(Tc *s, Ti slen, Ti c, Ti low) { Tc *p = s; Ti idx = 0; Ti len; Tc buf[5]; int charlen; int clen = Zchar2stringBuf(c, buf); for (len = slen; len > 0; len -= charlen) { for (charlen = 1; (p[charlen] & 0xc0) == 0x80; ++charlen) ; if (charlen == clen && memcmp(buf, p, charlen) == 0 && idx >= low) { return idx; } p += charlen; ++idx; } return -1; } Ti ZstringFindChar2(Tc *s, Ti c, Ti low, int dn) { Tc *p; int len; Ti r; if (s == NULL) { if (!dn) ZthrowCstringNil("using find() on NIL"); r = -1; } else { len = ZstringSizePtr(s, &p); r = ZptrFindChar2(p, len, c, low); } return r; } Ti ZstringFindChar(Tc *s, Ti c, int dn) { return ZstringFindChar2(s, c, 0, dn); } Tb ZstringStartsWith(Tc *big, Tc *small, int dn) { Tc *bigp; Tc *smallp; Ti biglen; Ti smalllen; Tb r = 0; if (big == NULL) { if (dn) goto end; ZthrowCstringNil("using startsWith() on NIL"); } if (small == NULL) ZthrowCstringNil("using startsWith() with NIL argument"); biglen = ZstringSizePtr(big, &bigp); smalllen = ZstringSizePtr(small, &smallp); if (smalllen <= biglen) r = memcmp(bigp, smallp, smalllen) == 0; end: return r; } Ti ZptrFindLastChar2(Tc *s, Ti slen, Ti c, Ti high) { Tc *p = s; Ti idx = 0; Ti best = -1; Ti len; Tc buf[5]; int charlen; int clen = Zchar2stringBuf(c, buf); for (len = slen; len > 0 && idx <= high; len -= charlen) { for (charlen = 1; (p[charlen] & 0xc0) == 0x80; ++charlen) ; if (charlen == clen && memcmp(buf, p, charlen) == 0) best = idx; p += charlen; ++idx; } return best; } Ti ZstringFindLastChar(Tc *s, Ti c, int dn) { Tc *p; int len; Ti r; if (s == NULL) { if (!dn) ZthrowCstringNil("using findLast() on NIL"); r = -1; } else { len = ZstringSizePtr(s, &p); r = ZptrFindLastChar2(p, len, c, len); } return r; } Tc *ZstringSlice(Tc *sv, Ti start, Ti end, int dn) { Ti is; Ti ie; Tc *p; Ti len; Tc *r; if (sv == NULL) { if (dn) return NULL; ZthrowCstringNil("using slice() on NIL"); } len = ZstringSizePtr(sv, &p); is = start < 0 ? ZChar2ByteIdxEnd(p, len, -start) : ZChar2ByteIdx(p, len, start); ie = end < 0 ? ZChar2ByteIdxEnd(p, len, -end - 1) - 1 : ZChar2ByteIdx(p, len, end + 1) - 1; if (is < 0) is = 0; if (ie < 0 || ie < is) r = ZnewString((Tc*)"", 0); else r = ZnewString(p + is, ie - is + 1); return r; } Ti ZptrToInt(Tc *s, int t, Ti def) { Ti r; char *p = (char*)s; if ((*p < '0' || *p > '9') && *p != '-') { if (t == 1) ZthrowCstringBadValue("toInt(): argument does not start with a digit or -"); return def; } sscanf(p, ZINT_FORMAT, &r); return r; } Ti ZstringToInt(Tc *p, int t, Ti def) { Tc *s; Ti r; if (p == NULL) { if (t & 2) return def; ZthrowCstringNil("using toInt() on NIL"); } (void)ZstringSizePtr(p, &s); r = ZptrToInt(s, t, def); return r; } int ZcopyItems(Tt *toType, int toSize, void *toPtr, Ti toOff, Tt *fromType, int fromSize, void *fromPtr, Ti fromOff, Ti len) { Ti i; if (toType == fromType || (toType->nr >= 100 && fromType->nr >= 100)) { memmove((char*)toPtr + toOff * toSize, (char*)fromPtr + fromOff * fromSize, len * toSize); return 1; } if (fromType->nr >= 100 || toType->nr >= 100) return 0; for (i = 0; i < len; ++i) { Ti iv; Tf fv; switch (fromType->nr) { case 0: case 24: case 25: iv = ((Ti*)fromPtr)[fromOff + i]; fv = iv; break; case 1: iv = ((char*)fromPtr)[fromOff + i]; fv = iv; break; case 2: iv = ((Ti16*)fromPtr)[fromOff + i]; fv = iv; break; case 3: iv = ((Ti32*)fromPtr)[fromOff + i]; fv = iv; break; case 10: iv = ((Tu*)fromPtr)[fromOff + i]; fv = iv; break; case 11: iv = ((Tc*)fromPtr)[fromOff + i]; fv = iv; break; case 12: iv = ((Tu16*)fromPtr)[fromOff + i]; fv = iv; break; case 13: iv = ((Tu32*)fromPtr)[fromOff + i]; fv = iv; break; case 21: case 22: case 23: iv = ((int*)fromPtr)[fromOff + i]; fv = iv; break; case 80: case 82: case 83: fv = ((Tf*)fromPtr)[fromOff + i]; iv = fv; break; case 81: fv = ((Tf32*)fromPtr)[fromOff + i]; iv = fv; break; } switch (toType->nr) { case 0: case 10: case 24: case 25: ((Ti*)toPtr)[toOff + i] = iv; break; case 1: case 11: ((char*)toPtr)[toOff + i] = iv; break; case 2: case 12: ((Ti16*)toPtr)[toOff + i] = iv; break; case 3: case 13: ((Ti32*)toPtr)[toOff + i] = iv; break; case 21: case 22: case 23: ((int*)toPtr)[toOff + i] = iv; break; case 80: case 82: case 83: ((Tf*)toPtr)[toOff + i] = fv; break; case 81: ((Tf32*)toPtr)[toOff + i] = fv; break; } } return 1; } void ZfreeArray(Ta *head) { Ti i; Ti d; if (head == NULL) return; if (head->ptr && head->ptr != head + 1) { Zfree(head->ptr - ZOH_OFF); } Zfree(head); } Ta *ZArrayInit(Ta *head, Tt *itemType, int itemSize, Ti size) { head->ptr = ZaOff(itemSize * size); head->dim = 1; head->size[0] = size; head->itemType = itemType; head->itemSize = itemSize; return head; } Ta *ZnewArray(Tt *itemType, int itemSize, Ti size) { Ta *head; size_t extra = size * itemSize; if (extra > 100) extra = 0; head = Za(sizeof(Ta) + extra); if (extra == 0) { head->ptr = ZaOff(itemSize * size); } else head->ptr = head + 1; head->dim = 1; head->size[0] = size; head->itemType = itemType; head->itemSize = itemSize; return head; } Ti ZArraySize(Ta *head) { Ti r; if (head == NULL) r = 0; else r = head->size[0]; return r; } void *ZarrayPtr(Ta *head, Ti idx) { if (head == NULL) ZthrowCstringNil("using [] on NIL array"); if (idx < 0 || idx >= head->size[0]) ZthrowCstringOutOfRange(idx, "array index out of bounds"); return head->ptr + idx * head->itemSize; } Ta *Zas(Ta *head, void *vals, int type, Ti offset) { int len; int i; if (head == NULL) ZthrowCstringNil("Invoking set() on NIL array"); if (type == 0) { /* vals is a byteString */ Tc *p; len = ZstringSizePtr(vals, &p); if (len > head->size[0] - offset) len = head->size[0] - offset; if (head->itemSize == 1) { memmove(((Tc*)head->ptr) + offset, p, len); } else if (head->itemSize == sizeof(Te)) { for (i = 0; i < len; ++i) ((Te*)head->ptr)[i + offset] = p[i]; } else { for (i = 0; i < len; ++i) ((Ti*)head->ptr)[i + offset] = p[i]; } } else if (type == 1) { /* vals is an array */ Ta *from = vals; len = from->size[0]; if (len > head->size[0] - offset) len = head->size[0] - offset; ZcopyItems(head->itemType, head->itemSize, head->ptr, offset, from->itemType, from->itemSize, from->ptr, 0, len); } else { /* vals is a list */ Tl *from = (Tl*)vals; Ti count = from->itemCount; if (count > offset + head->size[0]) count = offset + head->size[0]; ZcopyItems(head->itemType, head->itemSize, head->ptr, offset, from->itemType, from->itemSize, from->items, from->empty, count); } return head; } Ta *ZarrayResize(Ta *head, int bytes, Ti size) { if (head == NULL) ZthrowCstringNil("Invoking resize() on NIL array"); if (head->ptr == head + 1) { head->ptr = ZaOff(bytes * size); memmove(head->ptr, head + 1, size > head->size[0] ? bytes * head->size[0] : bytes * size); } else head->ptr = ZranOff(head->ptr, bytes * head->size[0], bytes * size); head->size[0] = size; return head; } Ti ZListFindIdx(Tl *head, Ti idx) { if (head == NULL) ZthrowCstringNil("Accessing NIL list"); if (idx < 0) { Ti n = head->itemCount + idx; if (n < 0) return n; return n + head->empty; } if (idx >= head->itemCount) return -1; return idx + head->empty; } void ZListSetType(Tl* head, Tt *itemType) { head->itemType = itemType; if (itemType == NULL) ZthrowCstringNil("Creating list without type"); switch (itemType->nr) { case 0: case 10: case 80: case 82: case 83: case 24: case 25: head->itemSize = 8; break; case 1: case 11: head->itemSize = 1; break; case 12: case 2: head->itemSize = 2; break; case 3: case 13: case 81: head->itemSize = 4; break; case 21: case 22: case 23: head->itemSize = sizeof(int); break; case 391: head->itemSize = sizeof(Tr); break; default: head->itemSize = sizeof(void*); break; } } Tl *ZnewList(Tt *itemType, Ti size) { int alloc = size > ((itemType->nr == 1 || itemType->nr == 11) ? 64 : 8); int extraSize = itemType != NULL && itemType->nr == 391 ? 8 * sizeof(Tr) : 64; Tl *head = Za(sizeof(Tl) + (alloc ? 0 : extraSize)); ZListSetType(head, itemType); if (alloc) { head->items = ZaOff(head->itemSize * size); head->space = size; } else { head->items = (void**)(head + 1); head->space = extraSize / head->itemSize; } return head; } void ZListGrow(Tl *head, Ti count) { Ti newsize = head->empty + head->itemCount + count; if (newsize <= head->space) return; if (newsize < 100) { newsize += (newsize >> 2) + 7; } else { newsize += newsize >> 3; } if (head->items == (void**)(head + 1)) { head->items = ZaOff(head->itemSize * newsize); memmove(head->items, head + 1, head->itemSize * head->itemCount); } else { head->items = ZranOff(head->items, head->itemSize * head->space, head->itemSize * newsize); } head->space = newsize; } Tl *ZLa(Tl *head, Ti after, Tz val) { Ti nAfter; Ti idx; Ti len; if (head == NULL) ZthrowCstringNil("Attempt to append to NIL list"); ZListGrow(head, 1); if (after < 0) { nAfter = head->itemCount + after; if (nAfter < 0) nAfter = -1; } else { nAfter = after; if (nAfter >= head->itemCount) nAfter = head->itemCount - 1; } idx = nAfter + head->empty + 1; len = head->itemCount - nAfter - 1; switch (head->itemType->nr) { case 0: case 10: case 24: case 25: if (len > 0 && idx >= head->empty) memmove(((Ti*)head->items) + idx + 1, ((Ti*)head->items) + idx, head->itemSize * len); ((Ti*)head->items)[idx] = val.ival; break; case 1: case 11: if (len > 0 && idx >= head->empty) memmove(((char*)head->items) + idx + 1, ((char*)head->items) + idx, head->itemSize * len); ((char*)head->items)[idx] = val.ival; break; case 12: case 2: if (len > 0 && idx >= head->empty) memmove(((Ti16*)head->items) + idx + 1, ((Ti16*)head->items) + idx, head->itemSize * len); ((Ti16*)head->items)[idx] = val.ival; break; case 3: case 13: if (len > 0 && idx >= head->empty) memmove(((Ti32*)head->items) + idx + 1, ((Ti32*)head->items) + idx, head->itemSize * len); ((Ti32*)head->items)[idx] = val.ival; break; case 21: case 22: case 23: if (len > 0 && idx >= head->empty) memmove(((int*)head->items) + idx + 1, ((int*)head->items) + idx, head->itemSize * len); ((int*)head->items)[idx] = val.ival; break; case 80: case 82: case 83: if (len > 0 && idx >= head->empty) memmove(((Tf*)head->items) + idx + 1, ((Tf*)head->items) + idx, head->itemSize * len); ((Tf*)head->items)[idx] = val.fval; break; case 81: if (len > 0 && idx >= head->empty) memmove(((Tf32*)head->items) + idx + 1, ((Tf32*)head->items) + idx, head->itemSize * len); ((Tf32*)head->items)[idx] = val.fval; break; default: if (len > 0 && idx >= head->empty) memmove(head->items + idx + 1, head->items + idx, head->itemSize * len); head->items[idx] = val.ptr; break; } ++head->itemCount; return head; } Tl *ZLap(Tl *head, Tz val) { return ZLa(head, -1, val); } Tl *ZLaIobj(Tl *head, Ti after, Tr val) { Ti nAfter; Ti idx; Ti len; if (head == NULL) ZthrowCstringNil("Attempt to append to NIL list"); ZListGrow(head, 1); if (after < 0) { nAfter = head->itemCount + after; if (nAfter < 0) nAfter = -1; } else { nAfter = after; if (nAfter >= head->itemCount) nAfter = head->itemCount - 1; } idx = nAfter + head->empty + 1; len = head->itemCount - nAfter - 1; if (len > 0 && idx >= head->empty) memmove((Tr*)head->items + idx + 1, (Tr*)head->items + idx, head->itemSize * len); ((Tr*)head->items)[idx] = val; ++head->itemCount; return head; } Tl *ZLapIobj(Tl *head, Tr val) { return ZLaIobj(head, -1, val); } Ti ZListSize(Tl *head) { if (head == NULL) return 0; return head->itemCount; } Ti ZListGetInt(Tl *head, Ti idx) { Ti r; Ti n = ZListFindIdx(head, idx); if (n >= 0) { switch (head->itemType->nr) { case 0: case 24: case 25: r = ((Ti*)head->items)[n]; break; case 10: r = (Ti)((Tu*)head->items)[n]; break; case 1: r = ((char*)head->items)[n]; break; case 11: r = (Ti)((Tc*)head->items)[n]; break; case 2: r = ((Ti16*)head->items)[n]; break; case 12: r = (Ti)((Tu16*)head->items)[n]; break; case 3: r = ((Ti32*)head->items)[n]; break; case 13: r = (Ti)((Tu32*)head->items)[n]; break; case 21: case 22: case 23: r = ((int*)head->items)[n]; break; } } else r = 0; return r; } Tf ZListGetFloat(Tl *head, Ti idx) { Tf r; Ti n = ZListFindIdx(head, idx); if (n >= 0) { switch (head->itemType->nr) { case 80: case 82: case 83: r = ((Tf*)head->items)[n]; break; case 81: r = (Tf)((Tf32*)head->items)[n]; break; } } else r = 0; return r; } void *ZListGetPtr(Tl *head, Ti idx) { Ti n = ZListFindIdx(head, idx); if (n >= 0) return head->items[n]; return NULL; } Ti ZListRemoveIntItem(Tl *head, Ti idx) { Ti r = 0; if (head == NULL) ZthrowCstringNil("Invoking remove() on NIL list"); Ti n = ZListFindIdx(head, idx); if (n >= 0) { Ti len = head->itemCount - (n - head->empty) - 1; switch (head->itemType->nr) { case 0: case 10: case 24: case 25: r = ((Ti*)head->items)[n]; break; case 1: case 11: r = ((char*)head->items)[n]; break; case 12: case 2: r = ((Ti16*)head->items)[n]; break; case 3: case 13: r = ((Ti32*)head->items)[n]; break; case 21: case 22: case 23: r = ((int*)head->items)[n]; break; } if (len > 0) memmove((char*)head->items + n * head->itemSize, (char*)head->items + (n + 1) * head->itemSize, len * head->itemSize); head->itemCount--; // ZListShrink(head); } return r; } void *ZListRemovePtrItem(Tl *head, Ti idx) { void *r = NULL; if (head == NULL) ZthrowCstringNil("Invoking remove() on NIL list"); Ti n = ZListFindIdx(head, idx); if (n >= 0) { Ti len = head->itemCount - (n - head->empty) - 1; r = head->items[n]; if (len > 0) memmove(head->items + n, head->items + n + 1, len * sizeof(void*)); head->itemCount--; // ZListShrink(head); } return r; } static int stringCmp(const void *p1, const void *p2) { Tc *p1p; Tc *p2p; Ti len1 = ZstringSizePtr(*(Tc **)p1, &p1p); Ti len2 = ZstringSizePtr(*(Tc **)p2, &p2p); size_t len = len1 < len2 ? len1 : len2; int r = memcmp(p1p, p2p, len); if (r == 0) return len1 - len2; return r; } static int stringCmpR(const void *p1, const void *p2) { Tc *p1p; Tc *p2p; Ti len1 = ZstringSizePtr(*(Tc **)p1, &p1p); Ti len2 = ZstringSizePtr(*(Tc **)p2, &p2p); size_t len = len1 < len2 ? len1 : len2; int r = memcmp(p2p, p1p, len); if (r == 0) return len2 - len1; return r; } Tl *ZstringListSort(Tl *head, int asc) { int i = 0; if (head == NULL) ZthrowCstringNil("Invoking sort() on NIL list"); qsort(head->items + head->empty, head->itemCount, sizeof(Tc*), asc ? stringCmp : stringCmpR); return head; } int ZforListIobjCont(Tfl *tfl) { Tl *l = tfl->l; Ti i = tfl->i; if (l == NULL || i >= l->itemCount) return 0; *(Tr*)tfl->valp = ((Tr*)l->items)[i + l->empty]; ++tfl->i; return 1; } int ZforListIntCont(Tfl *tfl) { Tl *l = tfl->l; Ti i = tfl->i; if (l == NULL || i >= l->itemCount) return 0; *(Ti*)tfl->valp = ZListGetInt(l, i); ++tfl->i; return 1; } int ZforListPtrCont(Tfl *tfl) { Tl *l = tfl->l; Ti i = tfl->i; if (l == NULL || i >= l->itemCount) return 0; *(char**)tfl->valp = l->items[i + l->empty]; ++tfl->i; return 1; } int ZDeqNr(Tz *l, Tz *r) { return l->ival == r->ival; } int ZDeqFloat(Tz *l, Tz *r) { return l->fval == r->fval; } int ZDeqStr(Tz *l, Tz *r) { Tc *p1; Tc *p2; Ti len1; Ti len2; if (r->ptr != NULL) { len1 = ZstringSizePtr(l->ptr, &p1); len2 = ZstringSizePtr(r->ptr, &p2); if (len1 == len2) return memcmp(p1, p2, len1) == 0; } return 0; } int ZDeqRef(Tz *l, Tz *r) { return l->ptr == r->ptr; } int ZDeqIobj(Tr *l, Tz *r) { return l->ptr == ((Tr*)r->ptr)->ptr; } Td *ZDictHead(Td *d, Tt *keyType, Tt *itemType, Tb ordered) { d->array = d->smallArray; d->mask = HT_INIT_SIZE - 1; d->keyType = keyType; d->itemType = itemType; if (itemType == NULL) ZthrowCstringNil("Creating dict without item type"); if (keyType == NULL) ZthrowCstringNil("Creating dict without key type"); if (ordered) d->type = DTYPE_ORDERED; if (keyType->nr < 80) d->eqfunc = (int (*)(void*, Tz*))ZDeqNr; else if (keyType->nr < 100) d->eqfunc = (int (*)(void*, Tz*))ZDeqFloat; else if (keyType == &iobj__T) d->eqfunc = (int (*)(void*, Tz*))ZDeqIobj; else if (keyType == &string__T || keyType == &byteString__T) d->eqfunc = (int (*)(void*, Tz*))ZDeqStr; else d->eqfunc = (int (*)(void*, Tz*))ZDeqRef; return d; } Td *ZDictInit(Td *d, Tt *keyType, Tt *itemType, Tb ordered) { memset(d, 0, sizeof(Td)); ZDictHead(d, keyType, itemType, ordered); return d; } Td *ZnewDict(Tt *keyType, Tt *itemType, Tb ordered) { return ZDictHead(Za(sizeof(Td)), keyType, itemType, ordered); } Zhashtype ZDictHash(Tt *keyType, Tz key) { Zhashtype hash; void *ptr; if (keyType->nr < 80) return (Zhashtype)key.ival; if (keyType->nr < 100) return (Zhashtype)key.fval; if (keyType == &iobj__T) { ptr = ((Tr*)key.ptr)->ptr; } else { ptr = key.ptr; } if (ptr == NULL) ZthrowCstringNil("dict key is NIL"); if (keyType == &string__T || keyType == &byteString__T) { Tc *p; int l = ZstringSizePtr(key.ptr, &p); if (l == 0) { hash = 0; } else { hash = *p; while (--l > 0) { hash = hash * 101 + *++p; } } } else { Tip k = (Tip)ptr; int l = sizeof(Tc*); hash = k & 0xff; while (--l > 0) { k >>= 8; hash = hash * 101 + (k & 0xff); } } return hash; } void ZthrowIntKeyNotFound(Tz key, Tc *msg) { Yxmk(key.ival, msg); } void ZthrowStringKeyNotFound(Tz key, Tc *msg) { Y5LT(key.ptr, msg); } void ZthrowIntKeyExists(Tz key, Tc *msg) { YL9Z(key.ival, msg); } void ZthrowStringKeyExists(Tz key, Tc *msg) { YEeX(key.ptr, msg); } /* #define DICT_DEBUG 1 */ CDictItem *ZDictLookup(Td *d, Tz key, Zhashtype hash) { Zhashtype perturb; CDictItem *freeitem; int idx = (int)(hash & d->mask); CDictItem *di = &d->array[idx]; if (di->flags == 0) return di; if (di->flags == CDI_FLAG_DEL) freeitem = di; else if (di->hash == hash && d->keyType == &iobj__T ? d->eqfunc(&di->iokey, &key) : d->eqfunc(&di->key, &key)) { return di; } else { freeitem = NULL; } for (perturb = hash; ; perturb >>= PERTURB_SHIFT) { idx = (int)((idx << 2) + idx + perturb + 1); di = &d->array[idx & d->mask]; if (di->flags == 0) return freeitem == NULL ? di : freeitem; if (di->hash == hash && di->flags != CDI_FLAG_DEL && d->keyType == &iobj__T ? d->eqfunc(&di->iokey, &key) : d->eqfunc(&di->key, &key)) return di; if (di->flags == CDI_FLAG_DEL && freeitem == NULL) freeitem = di; } } void ZDictResize(Td *d, int minitems) { CDictItem temparray[HT_INIT_SIZE]; CDictItem *oldarray, *newarray; CDictItem *olditem, *newitem, *nextitem; int newi; int todo; Zhashtype oldsize, newsize; Zhashtype minsize; Zhashtype newmask; Zhashtype perturb; #ifdef DICT_DEBUG printf("size: %lu, filled: %lu, used: %lu\n", d->mask + 1, d->filled, d->used); #endif if (minitems == 0) { if (d->filled < HT_INIT_SIZE - 1 && d->array == d->smallArray) { #ifdef DICT_DEBUG printf("small array not full\n"); #endif return; } oldsize = d->mask + 1; if (d->filled * 3 < oldsize * 2 && d->used > oldsize / 5) { #ifdef DICT_DEBUG printf("size OK\n"); #endif return; } if (d->used > 1000) minsize = d->used * 2; else minsize = d->used * 4; } else { if ((Zhashtype)minitems < d->used) minitems = (int)d->used; minsize = minitems * 3 / 2; } newsize = HT_INIT_SIZE; while (newsize < minsize) { newsize <<= 1; if (newsize == 0) { ZthrowInternal(Zstr("ZDictResize")); return; } } #ifdef DICT_DEBUG printf("resizing from %lu to %lu\n", d->mask + 1, newsize); #endif if (newsize == HT_INIT_SIZE) { newarray = d->smallArray; if (d->array == newarray) { memmove(temparray, newarray, sizeof(temparray)); oldarray = temparray; } else oldarray = d->array; memset(newarray, 0, (size_t)(sizeof(CDictItem) * newsize)); } else { newarray = (CDictItem *)ZaOff((sizeof(CDictItem) * newsize)); oldarray = d->array; } newmask = newsize - 1; todo = (int)d->used; for (olditem = oldarray; todo > 0; ++olditem) if (olditem->flags & CDI_FLAG_USED) { newi = (int)(olditem->hash & newmask); newitem = &newarray[newi]; if (newitem->flags != 0) for (perturb = olditem->hash; ; perturb >>= PERTURB_SHIFT) { newi = (int)((newi << 2) + newi + perturb + 1); newitem = &newarray[newi & newmask]; if (newitem->flags == 0) break; } *newitem = *olditem; if (d->type & DTYPE_ORDERED) { olditem->lprev = newitem; } --todo; } if ((d->type & DTYPE_ORDERED) && d->first) { olditem = d->first; newitem = olditem->lprev; newitem->lprev = NULL; d->first = newitem; while (olditem->lnext) { olditem = olditem->lnext; nextitem = olditem->lprev; newitem->lnext = nextitem; newitem->lnext->lprev = newitem; newitem = nextitem; } newitem->lnext = NULL; d->last = newitem; } if (d->array != d->smallArray) Zfree((void*)d->array - ZOH_OFF); d->array = newarray; d->mask = newmask; d->filled = d->used; } /* "ow" is the overwrite flag. When zero it's not allowed to overwrite an * existing entry. */ Td *ZDictAdd(int ow, Td *d, Tz key, Tz value) { Zhashtype hash = ZDictHash(d->keyType, key); CDictItem *di = ZDictLookup(d, key, hash); #ifdef DICT_DEBUG if (d->keyType->nr >= 100) printf("Adding item %s\n", (Tc*)key.ptr); else printf("Adding item %lld\n", key.ival); if (key.ptr != NULL && (strcmp(key.ptr, "ENUM") == 0 || strcmp(key.ptr, "Equal") == 0 || strcmp(key.ptr, "EXIT") == 0)) dumpdict(d); #endif if (di->flags == 0 || di->flags == CDI_FLAG_DEL || ow) { if (di->flags == 0 || di->flags == CDI_FLAG_DEL) { ++d->used; if (di->flags == 0) ++d->filled; } di->hash = hash; if (d->keyType->nr == 391) { di->iokey = *(Tr*)key.ptr; } else if (d->keyType->nr >= 100) { if (di->flags == 0 || di->flags == CDI_FLAG_DEL) { di->key = key; } } else di->key = key; if (d->itemType->nr == 391) di->ioitem = *(Tr*)value.ptr; else di->item = value; di->flags = CDI_FLAG_USED; if (d->type & DTYPE_ORDERED) { di->lprev = d->last; if (d->last) d->last->lnext = di; else d->first = di; d->last = di; di->lnext = NULL; } ZDictResize(d, 0); } else { if (d->keyType->nr >= 100) ZthrowStringKeyExists(key, Zstr("dict.add(): ")); ZthrowIntKeyExists(key, Zstr("dict.add(): ")); } return d; } Td *ZDictAddIobjTz(int ow, Td *d, Tr key, Tz value) { return ZDictAdd(ow, d, (Tz)(void*)&key, value); } Td *ZDictAddTzIobj(int ow, Td *d, Tz key, Tr value) { return ZDictAdd(ow, d, key, (Tz)(void*)&value); } Td *ZDictAddIobjIobj(int ow, Td *d, Tr key, Tr value) { return ZDictAdd(ow, d, (Tz)(void*)&key, (Tz)(void*)&value); } #ifdef DICT_DEBUG dumpdict(Td *d) { int todo = (int)d->used; CDictItem *item; int idx = 0; for (item = d->array; todo > 0; ++item) { if (item->flags & CDI_FLAG_USED) { printf("%2d: %s\n", idx, (Tc*)item->key.ptr); --todo; } else if (item->flags == 0) { printf("%2d: unused\n", idx); } else if (item->flags == CDI_FLAG_DEL) { printf("%2d: deleted\n", idx); } else { printf("%2d: invalid flags: %d\n", idx, item->flags); } ++idx; } } #endif CDictItem *ZDictFind(Td *d, Tz key) { Zhashtype hash = ZDictHash(d->keyType, key); CDictItem *di = ZDictLookup(d, key, hash); if (di->flags & CDI_FLAG_USED) return di; return NULL; } Tr *ZDictGetIobjP(Td *d, Tz key) { CDictItem *di = ZDictFind(d, key); if (di == NULL) { static Tr dummy = {0, 0, 0}; ZDictAdd(1, d, key, (Tz)(void*)&dummy); di = ZDictFind(d, key); } return &di->ioitem; } Tr ZDictGetIobj(Td *d, Tz key) { CDictItem *di = ZDictFind(d, key); if (di != NULL) { return di->ioitem; } if (d->keyType->nr >= 100) ZthrowStringKeyNotFound(key, Zstr("")); ZthrowIntKeyNotFound(key, Zstr("")); return trZero; } Tr ZDictGetIobjDef(Td *d, Tz key, Tr def) { CDictItem *di = ZDictFind(d, key); if (di != NULL) return di->ioitem; return def; } Ti *ZDictGetIntP(Td *d, Tz key) { CDictItem *di = ZDictFind(d, key); if (di == NULL) { ZDictAdd(1, d, key, (Tz)(Ti)0); di = ZDictFind(d, key); } return &di->item.ival; } Ti ZDictGetInt(Td *d, Tz key) { CDictItem *di = ZDictFind(d, key); if (di != NULL) { return di->item.ival; } if (d->keyType->nr >= 100) ZthrowStringKeyNotFound(key, Zstr("")); ZthrowIntKeyNotFound(key, Zstr("")); return 0; } Ti ZDictGetIntDef(Td *d, Tz key, Ti def) { CDictItem *di = ZDictFind(d, key); if (di != NULL) return di->item.ival; return def; } Tb ZDictHas(Td *d, Tz key) { return (ZDictFind(d, key) != NULL); } Tb ZDictHasIobj(Td *d, Tr key) { return (ZDictFind(d, (Tz)(void*)&key) != NULL); } Tl *ZDictKeys(Td *d, int dn) { Tl *l; int todo; CDictItem *di; if (d == NULL) { if (dn) return NULL; ZthrowCstringNil("Invoking keys() on NIL dict"); } l = ZnewList(d->keyType, d->used); if (d->type & DTYPE_ORDERED) { if (d->keyType == &iobj__T) for (di = d->first; di; di = di->lnext) { ZLaIobj(l, -1, di->iokey); } else for (di = d->first; di; di = di->lnext) { ZLa(l, -1, di->key); } } else { todo = d->used; for (di = d->array; todo > 0; ++di) { if (di->flags & CDI_FLAG_USED) { --todo; if (d->keyType == &iobj__T) ZLaIobj(l, -1, di->iokey); else ZLa(l, -1, di->key); } } } return l; } Ti ZDictSize(Td *d) { if (d == NULL) return 0; return d->used; } Tcode *ZtableIndex(Ti pos100) { Ti pos = pos100 / 100; int l = 0; int h = sizeof(ZcodeTable)/sizeof(Tcode) - 1; int m; while (l <= h) { m = (l + h) / 2; if (ZcodeTable[m].offset == pos) break; if (ZcodeTable[m].offset < pos) l = m + 1; else h = m - 1; } return &ZcodeTable[m]; } YkxB *MZ__callerPos(void) { Tcode *p; Zsf *tf = topFrame; if (tf == NULL) return NULL; tf = tf->prev == NULL ? tf : tf->prev; while (1) { if (tf == NULL) return NULL; if (tf->pos & POS_MASK) { p = ZtableIndex(tf->pos & POS_MASK); if (p->fileName) { return MZ__posnr2pos(NULL, tf->pos & POS_MASK); } } tf = tf->prev; } } Tl *MZ__backtrace(Ti skip, Ti limit) { Tl *head = ZnewList((Tt*)&YkxB__T, 0); int done = 0; Zsf *tf = topFrame; if (skip > 0) { int i; for (i = 0; i < skip && tf != NULL; ++i) tf = tf->prev; } while (tf != NULL) { if (tf->pos & POS_MASK) { YkxB *item = Za(sizeof(YkxB)); if (limit >= 0 && done >= limit) { item->Vfilename = Zstr("truncated"); ZLa(head, -1, (Tz)(void*)item); break; } MZ__posnr2pos(item, tf->pos & POS_MASK); ZLa(head, -1, (Tz)(void*)item); ++done; } tf = tf->prev; } return head; } YkxB *MZ__posnr2pos(YkxB *t, Ti pos) { int i; Tcode *p; Tcpos *pp; if (t == NULL) t = Za(sizeof(YkxB)); p = ZtableIndex(pos); i = pos - p->offset * 100; pp = &p->table[i]; t->Vfilename = Zstr((char*)p->fileName); t->Vtext = Zstr((char*)p->methodName); t->Vlnum = pp->line; if (i) t->Vlnum += p->table[0].line; t->Vcol = pp->col; return t; } /* * FUNCTION BODIES */ /* including TIMEModule bodies */ Ti Y9Rj() { Ti Vusec; Zsf sf; Ti r = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; Vusec = 0; sf.pos=5084100; struct timeval tv; gettimeofday(&tv, NULL); Vusec = (Ti)tv.tv_sec * 1000000 + (Ti)tv.tv_usec; sf.pos=5084101; r = Vusec; topFrame = sf.prev; return r; } Y2KX *YgaY(Y2KX *t) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=534200; t = Za(sizeof(Y2KX));} sf.pos=534201; YgaYb(t, Y9Rj()); topFrame = sf.prev; return t; } Y2KX *YgaYb(Y2KX *t, Ti Ausec) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=3293900; t = Za(sizeof(Y2KX));} sf.pos=3293901; time_t tt = Ausec / 1000000; struct tm tms; struct tm *tmsp; #ifdef __MINGW32__ tmsp = localtime(&tt); if (tmsp) tms = *tmsp; #else localtime_r(&tt, &tms); #endif t->Vsec = tms.tm_sec; t->Vmin = tms.tm_min; t->Vhour = tms.tm_hour; t->Vday = tms.tm_mday; t->Vmonth = tms.tm_mon + 1; t->Vyear = tms.tm_year + 1900; t->VweekDay = tms.tm_wday + 1; t->VyearDay = tms.tm_yday + 1; if (tms.tm_isdst > 0) t->Vdst = 2; else if (tms.tm_isdst == 0) t->Vdst = 1; sf.pos=3293902; t->Vusec = (Ausec % 1000000); topFrame = sf.prev; return t; } Tc *YYTs(Y2KX *t) { Zsf sf; Tc *r = 0; YjUM *Vw = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=3481800; ZthrowThisNil(); } sf.pos=3481801; Vw = Za(sizeof(YjUM)); sf.pos=3481802; YjUM__YHhZb(Vw, t->Vyear); sf.pos=3481803; YJqza(Vw, ((Tc*)&YV)); sf.pos=3481804; YJqza(Vw, ZintFormat(((Tc*)&Y6O7), t->Vmonth)); sf.pos=3481805; YJqza(Vw, ((Tc*)&YV)); sf.pos=3481806; YJqza(Vw, ZintFormat(((Tc*)&Y6O7), t->Vday)); sf.pos=3481807; YJqza(Vw, ((Tc*)&YG)); sf.pos=3481808; YJqza(Vw, ZintFormat(((Tc*)&Y6O7), t->Vhour)); sf.pos=3481809; YJqza(Vw, ((Tc*)&Y5)); sf.pos=3481810; YJqza(Vw, ZintFormat(((Tc*)&Y6O7), t->Vmin)); sf.pos=3481811; YJqza(Vw, ((Tc*)&Y5)); sf.pos=3481812; YJqza(Vw, ZintFormat(((Tc*)&Y6O7), t->Vsec)); sf.pos=3481813; r = YbNW(Vw); topFrame = sf.prev; return r; } To ToY2KX[] = { {0, 0}, }; Tto Y2KX__T = {390, (Tc*)&YeCO, 0, ToY2KX}; /* TIMEModule done */ /* including EModule bodies */ void YxaJ(Ytlm *t, Tr Aw) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=4918300; ZthrowThisNil(); } sf.pos=4918301; if ((t->Vpos != NULL)) { sf.pos=4918302; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(t->Vpos)); sf.pos=4918303; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); } sf.pos=4918304; if (((t->Vmessage != NULL) && (ZbyteStringSize(t->Vmessage) != 0))) { sf.pos=4918305; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YHbP)); sf.pos=4918306; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, t->Vmessage); } else { sf.pos=4918307; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YDGe)); } topFrame = sf.prev; return; } void YxaJa(Ytlm *t, Tb Averbose, Tr Aw) { Zsf sf; Tl *Zf2 = NULL; YkxB *Vpos = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=3649100; ZthrowThisNil(); } sf.pos=3649101; YxaJ(t, Aw); sf.pos=3649102; if ((Averbose && (t->Vbacktrace != NULL))) { sf.pos=3649103; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Y62e)); sf.pos=3649104; { Tfl Zf2i; Zf2 = t->Vbacktrace; Zf2i.l = Zf2; Zf2i.valp = (void*)&Vpos; Zf2i.i = 0; for (; ZforListPtrCont(&Zf2i); ) { sf.pos=3649105; if ((Vpos->Vfilename == NULL)) { sf.pos=3649106; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yv6_)); } else { sf.pos=3649107; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yk)); sf.pos=3649108; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(Vpos)); sf.pos=3649109; if ((Vpos->Vtext != NULL)) { sf.pos=3649110; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); sf.pos=3649111; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, Vpos->Vtext); } } sf.pos=3649112; } } } topFrame = sf.prev; return; } To ToYtlm[] = { {3, 0}, {0, (Tt*)&string__T}, /* message */ {0, (Tt*)&YkxB__T}, /* pos */ {0, (Tt*)&list__T}, /* backtrace */ }; Tto Ytlm__T = {390, (Tc*)&YDGe, 0, ToYtlm}; void YXHSa(YEro *t, Tr Aw) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=9216300; ZthrowThisNil(); } sf.pos=9216301; if ((t->Vpos != NULL)) { sf.pos=9216302; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(t->Vpos)); sf.pos=9216303; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); } sf.pos=9216304; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YxJ1)); sf.pos=9216305; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, Zint2string(t->Vvalue)); sf.pos=9216306; if (((t->Vmessage != NULL) && (ZbyteStringSize(t->Vmessage) != 0))) { sf.pos=9216307; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); sf.pos=9216308; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, t->Vmessage); } topFrame = sf.prev; return; } void YEro__YxaJa(YEro *t, Tb Averbose, Tr Aw) { Zsf sf; Tl *Zf2 = NULL; YkxB *Vpos = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=4298300; ZthrowThisNil(); } sf.pos=4298301; YXHSa(t, Aw); sf.pos=4298302; if ((Averbose && (t->Vbacktrace != NULL))) { sf.pos=4298303; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Y62e)); sf.pos=4298304; { Tfl Zf2i; Zf2 = t->Vbacktrace; Zf2i.l = Zf2; Zf2i.valp = (void*)&Vpos; Zf2i.i = 0; for (; ZforListPtrCont(&Zf2i); ) { sf.pos=4298305; if ((Vpos->Vfilename == NULL)) { sf.pos=4298306; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yv6_)); } else { sf.pos=4298307; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yk)); sf.pos=4298308; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(Vpos)); sf.pos=4298309; if ((Vpos->Vtext != NULL)) { sf.pos=4298310; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); sf.pos=4298311; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, Vpos->Vtext); } } sf.pos=4298312; } } } topFrame = sf.prev; return; } To ToYEro[] = { {3, 0}, {0, (Tt*)&string__T}, /* message */ {0, (Tt*)&YkxB__T}, /* pos */ {0, (Tt*)&list__T}, /* backtrace */ }; Tto YEro__T = {390, (Tc*)&YJMo, 0, ToYEro}; YKhn *YDNob(YKhn *t, Ti Asize, Ti Alimit) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=8064400; t = Za(sizeof(YKhn));} sf.pos=8064401; t->Vmessage = ZcS3(((Tc*)&YIBz), Zint2string(Asize), ((Tc*)&YDSH)); sf.pos=8064402; t->Vpos = MZ__callerPos(); sf.pos=8064403; t->Vbacktrace = (sf.pos=8064404, MZ__backtrace(1, Alimit)); topFrame = sf.prev; return t; } void YKhn__YwtA__YxaJa(YKhn *t, Tb Averbose, Tr Aw) { Zsf sf; Tl *Zf2 = NULL; YkxB *Vpos = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=1121700; ZthrowThisNil(); } sf.pos=1121701; YKhn__YwtA__YxaJ(t, Aw); sf.pos=1121702; if ((Averbose && (t->Vbacktrace != NULL))) { sf.pos=1121703; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Y62e)); sf.pos=1121704; { Tfl Zf2i; Zf2 = t->Vbacktrace; Zf2i.l = Zf2; Zf2i.valp = (void*)&Vpos; Zf2i.i = 0; for (; ZforListPtrCont(&Zf2i); ) { sf.pos=1121705; if ((Vpos->Vfilename == NULL)) { sf.pos=1121706; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yv6_)); } else { sf.pos=1121707; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yk)); sf.pos=1121708; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(Vpos)); sf.pos=1121709; if ((Vpos->Vtext != NULL)) { sf.pos=1121710; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); sf.pos=1121711; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, Vpos->Vtext); } } sf.pos=1121712; } } } topFrame = sf.prev; return; } void YKhn__YwtA__YxaJ(YKhn *t, Tr Aw) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=2141800; ZthrowThisNil(); } sf.pos=2141801; if ((t->Vpos != NULL)) { sf.pos=2141802; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(t->Vpos)); sf.pos=2141803; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); } sf.pos=2141804; if (((t->Vmessage != NULL) && (ZbyteStringSize(t->Vmessage) != 0))) { sf.pos=2141805; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YHbP)); sf.pos=2141806; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, t->Vmessage); } else { sf.pos=2141807; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YDGe)); } topFrame = sf.prev; return; } Tc *YKhn__Ytlm_I_imt[] = { (Tc*)&YKhn__T, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)0, /* MEModule__COutOfMemory.NEW - YKhn__YwtA__YRHRa */ (Tc*)0, /* MEModule__COutOfMemory.NEW - YKhn__YwtA__YRHR */ (Tc*)0, /* MEModule__COutOfMemory.ToString - YKhn__YwtA__YH0V */ (Tc*)YKhn__YwtA__YxaJa, /* MEModule__COutOfMemory.writeTo - YKhn__YwtA__YxaJa */ (Tc*)YKhn__YwtA__YxaJ, /* MEModule__COutOfMemory.writeTo - YKhn__YwtA__YxaJ */ (Tc*)0, /* MEModule__COutOfMemory.toString - YKhn__YwtA__Yoww */ (Tc*)0, /* MEModule__COutOfMemory.getMessage - YKhn__YwtA__YCzX */ (Tc*)0, /* MEModule__COutOfMemory.getPos - YKhn__YwtA__YvCK */ (Tc*)0, /* MEModule__COutOfMemory.getBacktrace - YKhn__YwtA__Y4bq */ (Tc*)0, /* Init - YKhna */ }; To ToYKhn[] = { {3, 0}, {0, (Tt*)&string__T}, /* message */ {0, (Tt*)&YkxB__T}, /* pos */ {0, (Tt*)&list__T}, /* backtrace */ }; Tto YKhn__T = {390, (Tc*)&Y9Fv, 0, ToYKhn}; void Y1KV(Ti Asize) { Tr ex; Tr t0 = {NULL}; *Znao(&ex, YDNob(NULL, Asize, 30), YKhn__Ytlm_I_imt, 4); ZthrowIobject(ex); } Y1uN *Y1uN__YwtA__YRHR(Y1uN *t, Tc *Amsg) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=3208600; t = Za(sizeof(Y1uN));} sf.pos=3208601; t->Vmessage = Amsg; sf.pos=3208602; t->Vpos = MZ__callerPos(); sf.pos=3208603; t->Vbacktrace = (sf.pos=3208604, MZ__backtrace(1, -1)); topFrame = sf.prev; return t; } void Y1uN__YwtA__YxaJa(Y1uN *t, Tb Averbose, Tr Aw) { Zsf sf; Tl *Zf2 = NULL; YkxB *Vpos = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=3508800; ZthrowThisNil(); } sf.pos=3508801; Y1uN__YwtA__YxaJ(t, Aw); sf.pos=3508802; if ((Averbose && (t->Vbacktrace != NULL))) { sf.pos=3508803; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Y62e)); sf.pos=3508804; { Tfl Zf2i; Zf2 = t->Vbacktrace; Zf2i.l = Zf2; Zf2i.valp = (void*)&Vpos; Zf2i.i = 0; for (; ZforListPtrCont(&Zf2i); ) { sf.pos=3508805; if ((Vpos->Vfilename == NULL)) { sf.pos=3508806; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yv6_)); } else { sf.pos=3508807; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yk)); sf.pos=3508808; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(Vpos)); sf.pos=3508809; if ((Vpos->Vtext != NULL)) { sf.pos=3508810; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); sf.pos=3508811; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, Vpos->Vtext); } } sf.pos=3508812; } } } topFrame = sf.prev; return; } void Y1uN__YwtA__YxaJ(Y1uN *t, Tr Aw) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=4528900; ZthrowThisNil(); } sf.pos=4528901; if ((t->Vpos != NULL)) { sf.pos=4528902; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(t->Vpos)); sf.pos=4528903; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); } sf.pos=4528904; if (((t->Vmessage != NULL) && (ZbyteStringSize(t->Vmessage) != 0))) { sf.pos=4528905; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YHbP)); sf.pos=4528906; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, t->Vmessage); } else { sf.pos=4528907; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YDGe)); } topFrame = sf.prev; return; } Tc *Y1uN__Ytlm_I_imt[] = { (Tc*)&Y1uN__T, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)0, /* MEModule__CNilAccess.NEW - Y1uN__YwtA__YRHRa */ (Tc*)Y1uN__YwtA__YRHR, /* MEModule__CNilAccess.NEW - Y1uN__YwtA__YRHR */ (Tc*)0, /* MEModule__CNilAccess.ToString - Y1uN__YwtA__YH0V */ (Tc*)Y1uN__YwtA__YxaJa, /* MEModule__CNilAccess.writeTo - Y1uN__YwtA__YxaJa */ (Tc*)Y1uN__YwtA__YxaJ, /* MEModule__CNilAccess.writeTo - Y1uN__YwtA__YxaJ */ (Tc*)0, /* MEModule__CNilAccess.toString - Y1uN__YwtA__Yoww */ (Tc*)0, /* MEModule__CNilAccess.getMessage - Y1uN__YwtA__YCzX */ (Tc*)0, /* MEModule__CNilAccess.getPos - Y1uN__YwtA__YvCK */ (Tc*)0, /* MEModule__CNilAccess.getBacktrace - Y1uN__YwtA__Y4bq */ (Tc*)0, /* Init - Y1uNa */ }; To ToY1uN[] = { {3, 0}, {0, (Tt*)&string__T}, /* message */ {0, (Tt*)&YkxB__T}, /* pos */ {0, (Tt*)&list__T}, /* backtrace */ }; Tto Y1uN__T = {390, (Tc*)&Y4wO, 0, ToY1uN}; void YvdV(YkxB *Apos, Tc *Atext) { Tr ex; Y1uN *Ve = 0; Tr t0 = {NULL}; Ve = Y1uN__YwtA__YRHR(NULL, Atext); if ((Apos != NULL)) { Ve->Vpos = Apos; } *Znao(&ex, Ve, Y1uN__Ytlm_I_imt, 5); ZthrowIobject(ex); } YAxe *YAxe__YwtA__YRHR(YAxe *t, Tc *Amsg) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=7358000; t = Za(sizeof(YAxe));} sf.pos=7358001; t->Vmessage = Amsg; sf.pos=7358002; t->Vpos = MZ__callerPos(); sf.pos=7358003; t->Vbacktrace = (sf.pos=7358004, MZ__backtrace(1, -1)); topFrame = sf.prev; return t; } void YAxe__YwtA__YxaJa(YAxe *t, Tb Averbose, Tr Aw) { Zsf sf; Tl *Zf2 = NULL; YkxB *Vpos = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=2595800; ZthrowThisNil(); } sf.pos=2595801; YAxe__YwtA__YxaJ(t, Aw); sf.pos=2595802; if ((Averbose && (t->Vbacktrace != NULL))) { sf.pos=2595803; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Y62e)); sf.pos=2595804; { Tfl Zf2i; Zf2 = t->Vbacktrace; Zf2i.l = Zf2; Zf2i.valp = (void*)&Vpos; Zf2i.i = 0; for (; ZforListPtrCont(&Zf2i); ) { sf.pos=2595805; if ((Vpos->Vfilename == NULL)) { sf.pos=2595806; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yv6_)); } else { sf.pos=2595807; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yk)); sf.pos=2595808; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(Vpos)); sf.pos=2595809; if ((Vpos->Vtext != NULL)) { sf.pos=2595810; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); sf.pos=2595811; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, Vpos->Vtext); } } sf.pos=2595812; } } } topFrame = sf.prev; return; } void YAxe__YwtA__YxaJ(YAxe *t, Tr Aw) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=3615900; ZthrowThisNil(); } sf.pos=3615901; if ((t->Vpos != NULL)) { sf.pos=3615902; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(t->Vpos)); sf.pos=3615903; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); } sf.pos=3615904; if (((t->Vmessage != NULL) && (ZbyteStringSize(t->Vmessage) != 0))) { sf.pos=3615905; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YHbP)); sf.pos=3615906; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, t->Vmessage); } else { sf.pos=3615907; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YDGe)); } topFrame = sf.prev; return; } Tc *YAxe__Ytlm_I_imt[] = { (Tc*)&YAxe__T, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)0, /* MEModule__CMemoryAccess.NEW - YAxe__YwtA__YRHRa */ (Tc*)YAxe__YwtA__YRHR, /* MEModule__CMemoryAccess.NEW - YAxe__YwtA__YRHR */ (Tc*)0, /* MEModule__CMemoryAccess.ToString - YAxe__YwtA__YH0V */ (Tc*)YAxe__YwtA__YxaJa, /* MEModule__CMemoryAccess.writeTo - YAxe__YwtA__YxaJa */ (Tc*)YAxe__YwtA__YxaJ, /* MEModule__CMemoryAccess.writeTo - YAxe__YwtA__YxaJ */ (Tc*)0, /* MEModule__CMemoryAccess.toString - YAxe__YwtA__Yoww */ (Tc*)0, /* MEModule__CMemoryAccess.getMessage - YAxe__YwtA__YCzX */ (Tc*)0, /* MEModule__CMemoryAccess.getPos - YAxe__YwtA__YvCK */ (Tc*)0, /* MEModule__CMemoryAccess.getBacktrace - YAxe__YwtA__Y4bq */ (Tc*)0, /* Init - YAxea */ }; To ToYAxe[] = { {3, 0}, {0, (Tt*)&string__T}, /* message */ {0, (Tt*)&YkxB__T}, /* pos */ {0, (Tt*)&list__T}, /* backtrace */ }; Tto YAxe__T = {390, (Tc*)&Y4QW, 0, ToYAxe}; void YE93(Ti Anr) { Tr ex; Tr t0 = {NULL}; if ((Anr == 11)) { Tr ex; *Znao(&ex, YAxe__YwtA__YRHR(NULL, ((Tc*)&YkfG)), YAxe__Ytlm_I_imt, 6); ZthrowIobject(ex); } if ((Anr == 8)) { Tr ex; *Znao(&ex, YzSI__Ylz1__YwtA__YRHR(NULL, ((Tc*)&YoEx)), YzSI__Ytlm_I_imt, 17); ZthrowIobject(ex); } if ((Anr == 7)) { Tr ex; *Znao(&ex, YAxe__YwtA__YRHR(NULL, ((Tc*)&YQNH)), YAxe__Ytlm_I_imt, 6); ZthrowIobject(ex); } *Znao(&ex, YAxe__YwtA__YRHR(NULL, ZcS(((Tc*)&YpCZ), Zint2string(Anr))), YAxe__Ytlm_I_imt, 6); ZthrowIobject(ex); } YVNj *YVNj__YwtA__YRHRa(YVNj *t, YkxB *Apos, Tc *Amsg) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=6357800; t = Za(sizeof(YVNj));} sf.pos=6357801; t->Vmessage = Amsg; sf.pos=6357802; t->Vpos = Apos; sf.pos=6357803; t->Vbacktrace = (sf.pos=6357804, MZ__backtrace(1, -1)); topFrame = sf.prev; return t; } YVNj *YVNj__YwtA__YRHR(YVNj *t, Tc *Amsg) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=5337700; t = Za(sizeof(YVNj));} sf.pos=5337701; t->Vmessage = Amsg; sf.pos=5337702; t->Vpos = MZ__callerPos(); sf.pos=5337703; t->Vbacktrace = (sf.pos=5337704, MZ__backtrace(1, -1)); topFrame = sf.prev; return t; } void YVNj__YwtA__YxaJa(YVNj *t, Tb Averbose, Tr Aw) { Zsf sf; Tl *Zf2 = NULL; YkxB *Vpos = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=9610700; ZthrowThisNil(); } sf.pos=9610701; YVNj__YwtA__YxaJ(t, Aw); sf.pos=9610702; if ((Averbose && (t->Vbacktrace != NULL))) { sf.pos=9610703; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Y62e)); sf.pos=9610704; { Tfl Zf2i; Zf2 = t->Vbacktrace; Zf2i.l = Zf2; Zf2i.valp = (void*)&Vpos; Zf2i.i = 0; for (; ZforListPtrCont(&Zf2i); ) { sf.pos=9610705; if ((Vpos->Vfilename == NULL)) { sf.pos=9610706; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yv6_)); } else { sf.pos=9610707; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yk)); sf.pos=9610708; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(Vpos)); sf.pos=9610709; if ((Vpos->Vtext != NULL)) { sf.pos=9610710; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); sf.pos=9610711; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, Vpos->Vtext); } } sf.pos=9610712; } } } topFrame = sf.prev; return; } void YVNj__YwtA__YxaJ(YVNj *t, Tr Aw) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=630800; ZthrowThisNil(); } sf.pos=630801; if ((t->Vpos != NULL)) { sf.pos=630802; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(t->Vpos)); sf.pos=630803; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); } sf.pos=630804; if (((t->Vmessage != NULL) && (ZbyteStringSize(t->Vmessage) != 0))) { sf.pos=630805; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YHbP)); sf.pos=630806; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, t->Vmessage); } else { sf.pos=630807; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YDGe)); } topFrame = sf.prev; return; } Tc *YVNj__Ytlm_I_imt[] = { (Tc*)&YVNj__T, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)YVNj__YwtA__YRHRa, /* MEModule__CInit.NEW - YVNj__YwtA__YRHRa */ (Tc*)YVNj__YwtA__YRHR, /* MEModule__CInit.NEW - YVNj__YwtA__YRHR */ (Tc*)0, /* MEModule__CInit.ToString - YVNj__YwtA__YH0V */ (Tc*)YVNj__YwtA__YxaJa, /* MEModule__CInit.writeTo - YVNj__YwtA__YxaJa */ (Tc*)YVNj__YwtA__YxaJ, /* MEModule__CInit.writeTo - YVNj__YwtA__YxaJ */ (Tc*)0, /* MEModule__CInit.toString - YVNj__YwtA__Yoww */ (Tc*)0, /* MEModule__CInit.getMessage - YVNj__YwtA__YCzX */ (Tc*)0, /* MEModule__CInit.getPos - YVNj__YwtA__YvCK */ (Tc*)0, /* MEModule__CInit.getBacktrace - YVNj__YwtA__Y4bq */ (Tc*)0, /* Init - YVNja */ }; To ToYVNj[] = { {3, 0}, {0, (Tt*)&string__T}, /* message */ {0, (Tt*)&YkxB__T}, /* pos */ {0, (Tt*)&list__T}, /* backtrace */ }; Tto YVNj__T = {390, (Tc*)&Ysqt, 0, ToYVNj}; void Y3w6(Tc *Atext) { Tr ex; Tr t0 = {NULL}; *Znao(&ex, YVNj__YwtA__YRHR(NULL, Atext), YVNj__Ytlm_I_imt, 7); ZthrowIobject(ex); } Yalz *Yalz__YwtA__YRHR(Yalz *t, Tc *Amsg) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=6059300; t = Za(sizeof(Yalz));} sf.pos=6059301; t->Vmessage = Amsg; sf.pos=6059302; t->Vpos = MZ__callerPos(); sf.pos=6059303; t->Vbacktrace = (sf.pos=6059304, MZ__backtrace(1, -1)); topFrame = sf.prev; return t; } void Yalz__YwtA__YxaJa(Yalz *t, Tb Averbose, Tr Aw) { Zsf sf; Tl *Zf2 = NULL; YkxB *Vpos = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=4617100; ZthrowThisNil(); } sf.pos=4617101; Yalz__YwtA__YxaJ(t, Aw); sf.pos=4617102; if ((Averbose && (t->Vbacktrace != NULL))) { sf.pos=4617103; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Y62e)); sf.pos=4617104; { Tfl Zf2i; Zf2 = t->Vbacktrace; Zf2i.l = Zf2; Zf2i.valp = (void*)&Vpos; Zf2i.i = 0; for (; ZforListPtrCont(&Zf2i); ) { sf.pos=4617105; if ((Vpos->Vfilename == NULL)) { sf.pos=4617106; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yv6_)); } else { sf.pos=4617107; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yk)); sf.pos=4617108; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(Vpos)); sf.pos=4617109; if ((Vpos->Vtext != NULL)) { sf.pos=4617110; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); sf.pos=4617111; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, Vpos->Vtext); } } sf.pos=4617112; } } } topFrame = sf.prev; return; } void Yalz__YwtA__YxaJ(Yalz *t, Tr Aw) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=5637200; ZthrowThisNil(); } sf.pos=5637201; if ((t->Vpos != NULL)) { sf.pos=5637202; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(t->Vpos)); sf.pos=5637203; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); } sf.pos=5637204; if (((t->Vmessage != NULL) && (ZbyteStringSize(t->Vmessage) != 0))) { sf.pos=5637205; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YHbP)); sf.pos=5637206; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, t->Vmessage); } else { sf.pos=5637207; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YDGe)); } topFrame = sf.prev; return; } Tc *Yalz__Ytlm_I_imt[] = { (Tc*)&Yalz__T, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)0, /* MEModule__CBadValue.NEW - Yalz__YwtA__YRHRa */ (Tc*)Yalz__YwtA__YRHR, /* MEModule__CBadValue.NEW - Yalz__YwtA__YRHR */ (Tc*)0, /* MEModule__CBadValue.ToString - Yalz__YwtA__YH0V */ (Tc*)Yalz__YwtA__YxaJa, /* MEModule__CBadValue.writeTo - Yalz__YwtA__YxaJa */ (Tc*)Yalz__YwtA__YxaJ, /* MEModule__CBadValue.writeTo - Yalz__YwtA__YxaJ */ (Tc*)0, /* MEModule__CBadValue.toString - Yalz__YwtA__Yoww */ (Tc*)0, /* MEModule__CBadValue.getMessage - Yalz__YwtA__YCzX */ (Tc*)0, /* MEModule__CBadValue.getPos - Yalz__YwtA__YvCK */ (Tc*)0, /* MEModule__CBadValue.getBacktrace - Yalz__YwtA__Y4bq */ (Tc*)0, /* Init - Yalza */ }; To ToYalz[] = { {3, 0}, {0, (Tt*)&string__T}, /* message */ {0, (Tt*)&YkxB__T}, /* pos */ {0, (Tt*)&list__T}, /* backtrace */ }; Tto Yalz__T = {390, (Tc*)&YEZq, 0, ToYalz}; void Yaez(Tc *Atext) { Tr ex; Tr t0 = {NULL}; *Znao(&ex, Yalz__YwtA__YRHR(NULL, Atext), Yalz__Ytlm_I_imt, 10); ZthrowIobject(ex); } Yw3O *Yw3O__Yalz__YwtA__YRHR(Yw3O *t, Tc *Amsg) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=5638100; t = Za(sizeof(Yw3O));} sf.pos=5638101; t->Vmessage = Amsg; sf.pos=5638102; t->Vpos = MZ__callerPos(); sf.pos=5638103; t->Vbacktrace = (sf.pos=5638104, MZ__backtrace(1, -1)); topFrame = sf.prev; return t; } void Yw3O__Yalz__YwtA__YxaJ(Yw3O *t, Tr Aw) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=5260800; ZthrowThisNil(); } sf.pos=5260801; if ((t->Vpos != NULL)) { sf.pos=5260802; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(t->Vpos)); sf.pos=5260803; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); } sf.pos=5260804; if (((t->Vmessage != NULL) && (ZbyteStringSize(t->Vmessage) != 0))) { sf.pos=5260805; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YHbP)); sf.pos=5260806; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, t->Vmessage); } else { sf.pos=5260807; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YDGe)); } topFrame = sf.prev; return; } void Yw3O__Yalz__YwtA__YxaJa(Yw3O *t, Tb Averbose, Tr Aw) { Zsf sf; Tl *Zf2 = NULL; YkxB *Vpos = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=6280900; ZthrowThisNil(); } sf.pos=6280901; Yw3O__Yalz__YwtA__YxaJ(t, Aw); sf.pos=6280902; if ((Averbose && (t->Vbacktrace != NULL))) { sf.pos=6280903; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Y62e)); sf.pos=6280904; { Tfl Zf2i; Zf2 = t->Vbacktrace; Zf2i.l = Zf2; Zf2i.valp = (void*)&Vpos; Zf2i.i = 0; for (; ZforListPtrCont(&Zf2i); ) { sf.pos=6280905; if ((Vpos->Vfilename == NULL)) { sf.pos=6280906; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yv6_)); } else { sf.pos=6280907; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yk)); sf.pos=6280908; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(Vpos)); sf.pos=6280909; if ((Vpos->Vtext != NULL)) { sf.pos=6280910; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); sf.pos=6280911; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, Vpos->Vtext); } } sf.pos=6280912; } } } topFrame = sf.prev; return; } Tc *Yw3O__Ytlm_I_imt[] = { (Tc*)&Yw3O__T, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)0, /* MEModule__COutOfRange.NEW - Yw3O__Yalz__YwtA__YRHRa */ (Tc*)Yw3O__Yalz__YwtA__YRHR, /* MEModule__COutOfRange.NEW - Yw3O__Yalz__YwtA__YRHR */ (Tc*)0, /* MEModule__COutOfRange.ToString - Yw3O__Yalz__YwtA__YH0V */ (Tc*)Yw3O__Yalz__YwtA__YxaJa, /* MEModule__COutOfRange.writeTo - Yw3O__Yalz__YwtA__YxaJa */ (Tc*)Yw3O__Yalz__YwtA__YxaJ, /* MEModule__COutOfRange.writeTo - Yw3O__Yalz__YwtA__YxaJ */ (Tc*)0, /* MEModule__COutOfRange.toString - Yw3O__Yalz__YwtA__Yoww */ (Tc*)0, /* MEModule__COutOfRange.getMessage - Yw3O__Yalz__YwtA__YCzX */ (Tc*)0, /* MEModule__COutOfRange.getPos - Yw3O__Yalz__YwtA__YvCK */ (Tc*)0, /* MEModule__COutOfRange.getBacktrace - Yw3O__Yalz__YwtA__Y4bq */ (Tc*)0, /* Init - Yw3Oa */ }; To ToYw3O[] = { {3, 0}, {0, (Tt*)&string__T}, /* message */ {0, (Tt*)&YkxB__T}, /* pos */ {0, (Tt*)&list__T}, /* backtrace */ }; Tto Yw3O__T = {390, (Tc*)&YFK2, 0, ToYw3O}; void Y6NT(Ti Aindex, Tc *Amsg) { Tr ex; Tr t0 = {NULL}; *Znao(&ex, Yw3O__Yalz__YwtA__YRHR(NULL, ZcS3(Amsg, ((Tc*)&YFDa), Zint2string(Aindex))), Yw3O__Ytlm_I_imt, 11); ZthrowIobject(ex); } Y2EX *Y2EX__Yalz__YwtA__YRHR(Y2EX *t, Tc *Amsg) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=2958500; t = Za(sizeof(Y2EX));} sf.pos=2958501; t->Vmessage = Amsg; sf.pos=2958502; t->Vpos = MZ__callerPos(); sf.pos=2958503; t->Vbacktrace = (sf.pos=2958504, MZ__backtrace(1, -1)); topFrame = sf.prev; return t; } void Y2EX__Yalz__YwtA__YxaJ(Y2EX *t, Tr Aw) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=4312400; ZthrowThisNil(); } sf.pos=4312401; if ((t->Vpos != NULL)) { sf.pos=4312402; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(t->Vpos)); sf.pos=4312403; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); } sf.pos=4312404; if (((t->Vmessage != NULL) && (ZbyteStringSize(t->Vmessage) != 0))) { sf.pos=4312405; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YHbP)); sf.pos=4312406; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, t->Vmessage); } else { sf.pos=4312407; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YDGe)); } topFrame = sf.prev; return; } void Y2EX__Yalz__YwtA__YxaJa(Y2EX *t, Tb Averbose, Tr Aw) { Zsf sf; Tl *Zf2 = NULL; YkxB *Vpos = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=5332500; ZthrowThisNil(); } sf.pos=5332501; Y2EX__Yalz__YwtA__YxaJ(t, Aw); sf.pos=5332502; if ((Averbose && (t->Vbacktrace != NULL))) { sf.pos=5332503; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Y62e)); sf.pos=5332504; { Tfl Zf2i; Zf2 = t->Vbacktrace; Zf2i.l = Zf2; Zf2i.valp = (void*)&Vpos; Zf2i.i = 0; for (; ZforListPtrCont(&Zf2i); ) { sf.pos=5332505; if ((Vpos->Vfilename == NULL)) { sf.pos=5332506; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yv6_)); } else { sf.pos=5332507; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yk)); sf.pos=5332508; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(Vpos)); sf.pos=5332509; if ((Vpos->Vtext != NULL)) { sf.pos=5332510; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); sf.pos=5332511; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, Vpos->Vtext); } } sf.pos=5332512; } } } topFrame = sf.prev; return; } Tc *Y2EX__Ytlm_I_imt[] = { (Tc*)&Y2EX__T, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)0, /* MEModule__CKeyNotFound.NEW - Y2EX__Yalz__YwtA__YRHRa */ (Tc*)Y2EX__Yalz__YwtA__YRHR, /* MEModule__CKeyNotFound.NEW - Y2EX__Yalz__YwtA__YRHR */ (Tc*)0, /* MEModule__CKeyNotFound.ToString - Y2EX__Yalz__YwtA__YH0V */ (Tc*)Y2EX__Yalz__YwtA__YxaJa, /* MEModule__CKeyNotFound.writeTo - Y2EX__Yalz__YwtA__YxaJa */ (Tc*)Y2EX__Yalz__YwtA__YxaJ, /* MEModule__CKeyNotFound.writeTo - Y2EX__Yalz__YwtA__YxaJ */ (Tc*)0, /* MEModule__CKeyNotFound.toString - Y2EX__Yalz__YwtA__Yoww */ (Tc*)0, /* MEModule__CKeyNotFound.getMessage - Y2EX__Yalz__YwtA__YCzX */ (Tc*)0, /* MEModule__CKeyNotFound.getPos - Y2EX__Yalz__YwtA__YvCK */ (Tc*)0, /* MEModule__CKeyNotFound.getBacktrace - Y2EX__Yalz__YwtA__Y4bq */ (Tc*)0, /* Init - Y2EXa */ }; To ToY2EX[] = { {3, 0}, {0, (Tt*)&string__T}, /* message */ {0, (Tt*)&YkxB__T}, /* pos */ {0, (Tt*)&list__T}, /* backtrace */ }; Tto Y2EX__T = {390, (Tc*)&YRiW, 0, ToY2EX}; void Yxmk(Ti Akey, Tc *Amsg) { Tr ex; Tr t0 = {NULL}; *Znao(&ex, Y2EX__Yalz__YwtA__YRHR(NULL, ZcS3(Amsg, ((Tc*)&Ym6C), Zint2string(Akey))), Y2EX__Ytlm_I_imt, 12); ZthrowIobject(ex); } void Y5LT(Tc *Akey, Tc *Amsg) { Tr ex; Tr t0 = {NULL}; *Znao(&ex, Y2EX__Yalz__YwtA__YRHR(NULL, ZcS5(Amsg, ((Tc*)&YJ3Y), Akey, ((Tc*)&YI), (Tc*)1)), Y2EX__Ytlm_I_imt, 12); ZthrowIobject(ex); } YX0i *YX0i__Yalz__YwtA__YRHRa(YX0i *t, YkxB *Apos, Tc *Amsg) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=9520100; t = Za(sizeof(YX0i));} sf.pos=9520101; t->Vmessage = Amsg; sf.pos=9520102; t->Vpos = Apos; sf.pos=9520103; t->Vbacktrace = (sf.pos=9520104, MZ__backtrace(1, -1)); topFrame = sf.prev; return t; } YX0i *YX0i__Yalz__YwtA__YRHR(YX0i *t, Tc *Amsg) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=8500000; t = Za(sizeof(YX0i));} sf.pos=8500001; t->Vmessage = Amsg; sf.pos=8500002; t->Vpos = MZ__callerPos(); sf.pos=8500003; t->Vbacktrace = (sf.pos=8500004, MZ__backtrace(1, -1)); topFrame = sf.prev; return t; } void YX0i__Yalz__YwtA__YxaJ(YX0i *t, Tr Aw) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=1471500; ZthrowThisNil(); } sf.pos=1471501; if ((t->Vpos != NULL)) { sf.pos=1471502; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(t->Vpos)); sf.pos=1471503; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); } sf.pos=1471504; if (((t->Vmessage != NULL) && (ZbyteStringSize(t->Vmessage) != 0))) { sf.pos=1471505; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YHbP)); sf.pos=1471506; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, t->Vmessage); } else { sf.pos=1471507; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YDGe)); } topFrame = sf.prev; return; } void YX0i__Yalz__YwtA__YxaJa(YX0i *t, Tb Averbose, Tr Aw) { Zsf sf; Tl *Zf2 = NULL; YkxB *Vpos = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=2491600; ZthrowThisNil(); } sf.pos=2491601; YX0i__Yalz__YwtA__YxaJ(t, Aw); sf.pos=2491602; if ((Averbose && (t->Vbacktrace != NULL))) { sf.pos=2491603; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Y62e)); sf.pos=2491604; { Tfl Zf2i; Zf2 = t->Vbacktrace; Zf2i.l = Zf2; Zf2i.valp = (void*)&Vpos; Zf2i.i = 0; for (; ZforListPtrCont(&Zf2i); ) { sf.pos=2491605; if ((Vpos->Vfilename == NULL)) { sf.pos=2491606; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yv6_)); } else { sf.pos=2491607; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yk)); sf.pos=2491608; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(Vpos)); sf.pos=2491609; if ((Vpos->Vtext != NULL)) { sf.pos=2491610; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); sf.pos=2491611; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, Vpos->Vtext); } } sf.pos=2491612; } } } topFrame = sf.prev; return; } Tc *YX0i__Ytlm_I_imt[] = { (Tc*)&YX0i__T, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)YX0i__Yalz__YwtA__YRHRa, /* MEModule__CKeyExists.NEW - YX0i__Yalz__YwtA__YRHRa */ (Tc*)YX0i__Yalz__YwtA__YRHR, /* MEModule__CKeyExists.NEW - YX0i__Yalz__YwtA__YRHR */ (Tc*)0, /* MEModule__CKeyExists.ToString - YX0i__Yalz__YwtA__YH0V */ (Tc*)YX0i__Yalz__YwtA__YxaJa, /* MEModule__CKeyExists.writeTo - YX0i__Yalz__YwtA__YxaJa */ (Tc*)YX0i__Yalz__YwtA__YxaJ, /* MEModule__CKeyExists.writeTo - YX0i__Yalz__YwtA__YxaJ */ (Tc*)0, /* MEModule__CKeyExists.toString - YX0i__Yalz__YwtA__Yoww */ (Tc*)0, /* MEModule__CKeyExists.getMessage - YX0i__Yalz__YwtA__YCzX */ (Tc*)0, /* MEModule__CKeyExists.getPos - YX0i__Yalz__YwtA__YvCK */ (Tc*)0, /* MEModule__CKeyExists.getBacktrace - YX0i__Yalz__YwtA__Y4bq */ (Tc*)0, /* Init - YX0ia */ }; To ToYX0i[] = { {3, 0}, {0, (Tt*)&string__T}, /* message */ {0, (Tt*)&YkxB__T}, /* pos */ {0, (Tt*)&list__T}, /* backtrace */ }; Tto YX0i__T = {390, (Tc*)&Y9_h, 0, ToYX0i}; void YL9Z(Ti Akey, Tc *Amsg) { Tr ex; Tr t0 = {NULL}; *Znao(&ex, YX0i__Yalz__YwtA__YRHR(NULL, ZcS3(Amsg, ((Tc*)&Y9qa), Zint2string(Akey))), YX0i__Ytlm_I_imt, 14); ZthrowIobject(ex); } void YEeX(Tc *Akey, Tc *Amsg) { Tr ex; Tr t0 = {NULL}; *Znao(&ex, YX0i__Yalz__YwtA__YRHR(NULL, ZcS5(Amsg, ((Tc*)&YMKM), Akey, ((Tc*)&YI), (Tc*)1)), YX0i__Ytlm_I_imt, 14); ZthrowIobject(ex); } YP_P *YP_P__Yalz__YwtA__YRHR(YP_P *t, Tc *Amsg) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=4520900; t = Za(sizeof(YP_P));} sf.pos=4520901; t->Vmessage = Amsg; sf.pos=4520902; t->Vpos = MZ__callerPos(); sf.pos=4520903; t->Vbacktrace = (sf.pos=4520904, MZ__backtrace(1, -1)); topFrame = sf.prev; return t; } void YP_P__Yalz__YwtA__YxaJ(YP_P *t, Tr Aw) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=994800; ZthrowThisNil(); } sf.pos=994801; if ((t->Vpos != NULL)) { sf.pos=994802; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(t->Vpos)); sf.pos=994803; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); } sf.pos=994804; if (((t->Vmessage != NULL) && (ZbyteStringSize(t->Vmessage) != 0))) { sf.pos=994805; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YHbP)); sf.pos=994806; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, t->Vmessage); } else { sf.pos=994807; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YDGe)); } topFrame = sf.prev; return; } void YP_P__Yalz__YwtA__YxaJa(YP_P *t, Tb Averbose, Tr Aw) { Zsf sf; Tl *Zf2 = NULL; YkxB *Vpos = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=2014900; ZthrowThisNil(); } sf.pos=2014901; YP_P__Yalz__YwtA__YxaJ(t, Aw); sf.pos=2014902; if ((Averbose && (t->Vbacktrace != NULL))) { sf.pos=2014903; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Y62e)); sf.pos=2014904; { Tfl Zf2i; Zf2 = t->Vbacktrace; Zf2i.l = Zf2; Zf2i.valp = (void*)&Vpos; Zf2i.i = 0; for (; ZforListPtrCont(&Zf2i); ) { sf.pos=2014905; if ((Vpos->Vfilename == NULL)) { sf.pos=2014906; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yv6_)); } else { sf.pos=2014907; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yk)); sf.pos=2014908; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(Vpos)); sf.pos=2014909; if ((Vpos->Vtext != NULL)) { sf.pos=2014910; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); sf.pos=2014911; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, Vpos->Vtext); } } sf.pos=2014912; } } } topFrame = sf.prev; return; } Tc *YP_P__Ytlm_I_imt[] = { (Tc*)&YP_P__T, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)0, /* MEModule__CIllegalByte.NEW - YP_P__Yalz__YwtA__YRHRa */ (Tc*)YP_P__Yalz__YwtA__YRHR, /* MEModule__CIllegalByte.NEW - YP_P__Yalz__YwtA__YRHR */ (Tc*)0, /* MEModule__CIllegalByte.ToString - YP_P__Yalz__YwtA__YH0V */ (Tc*)YP_P__Yalz__YwtA__YxaJa, /* MEModule__CIllegalByte.writeTo - YP_P__Yalz__YwtA__YxaJa */ (Tc*)YP_P__Yalz__YwtA__YxaJ, /* MEModule__CIllegalByte.writeTo - YP_P__Yalz__YwtA__YxaJ */ (Tc*)0, /* MEModule__CIllegalByte.toString - YP_P__Yalz__YwtA__Yoww */ (Tc*)0, /* MEModule__CIllegalByte.getMessage - YP_P__Yalz__YwtA__YCzX */ (Tc*)0, /* MEModule__CIllegalByte.getPos - YP_P__Yalz__YwtA__YvCK */ (Tc*)0, /* MEModule__CIllegalByte.getBacktrace - YP_P__Yalz__YwtA__Y4bq */ (Tc*)0, /* Init - YP_Pa */ }; To ToYP_P[] = { {3, 0}, {0, (Tt*)&string__T}, /* message */ {0, (Tt*)&YkxB__T}, /* pos */ {0, (Tt*)&list__T}, /* backtrace */ }; Tto YP_P__T = {390, (Tc*)&Ydbm, 0, ToYP_P}; YzSI *YzSI__Ylz1__YwtA__YRHR(YzSI *t, Tc *Amsg) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=7347100; t = Za(sizeof(YzSI));} sf.pos=7347101; t->Vmessage = Amsg; sf.pos=7347102; t->Vpos = MZ__callerPos(); sf.pos=7347103; t->Vbacktrace = (sf.pos=7347104, MZ__backtrace(1, -1)); topFrame = sf.prev; return t; } void YzSI__Ylz1__YwtA__YxaJ(YzSI *t, Tr Aw) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=4413000; ZthrowThisNil(); } sf.pos=4413001; if ((t->Vpos != NULL)) { sf.pos=4413002; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(t->Vpos)); sf.pos=4413003; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); } sf.pos=4413004; if (((t->Vmessage != NULL) && (ZbyteStringSize(t->Vmessage) != 0))) { sf.pos=4413005; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YHbP)); sf.pos=4413006; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, t->Vmessage); } else { sf.pos=4413007; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YDGe)); } topFrame = sf.prev; return; } void YzSI__Ylz1__YwtA__YxaJa(YzSI *t, Tb Averbose, Tr Aw) { Zsf sf; Tl *Zf2 = NULL; YkxB *Vpos = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=5433100; ZthrowThisNil(); } sf.pos=5433101; YzSI__Ylz1__YwtA__YxaJ(t, Aw); sf.pos=5433102; if ((Averbose && (t->Vbacktrace != NULL))) { sf.pos=5433103; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Y62e)); sf.pos=5433104; { Tfl Zf2i; Zf2 = t->Vbacktrace; Zf2i.l = Zf2; Zf2i.valp = (void*)&Vpos; Zf2i.i = 0; for (; ZforListPtrCont(&Zf2i); ) { sf.pos=5433105; if ((Vpos->Vfilename == NULL)) { sf.pos=5433106; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yv6_)); } else { sf.pos=5433107; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yk)); sf.pos=5433108; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(Vpos)); sf.pos=5433109; if ((Vpos->Vtext != NULL)) { sf.pos=5433110; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); sf.pos=5433111; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, Vpos->Vtext); } } sf.pos=5433112; } } } topFrame = sf.prev; return; } Tc *YzSI__Ytlm_I_imt[] = { (Tc*)&YzSI__T, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)0, /* MEModule__CDivideByZero.NEW - YzSI__Ylz1__YwtA__YRHRa */ (Tc*)YzSI__Ylz1__YwtA__YRHR, /* MEModule__CDivideByZero.NEW - YzSI__Ylz1__YwtA__YRHR */ (Tc*)0, /* MEModule__CDivideByZero.ToString - YzSI__Ylz1__YwtA__YH0V */ (Tc*)YzSI__Ylz1__YwtA__YxaJa, /* MEModule__CDivideByZero.writeTo - YzSI__Ylz1__YwtA__YxaJa */ (Tc*)YzSI__Ylz1__YwtA__YxaJ, /* MEModule__CDivideByZero.writeTo - YzSI__Ylz1__YwtA__YxaJ */ (Tc*)0, /* MEModule__CDivideByZero.toString - YzSI__Ylz1__YwtA__Yoww */ (Tc*)0, /* MEModule__CDivideByZero.getMessage - YzSI__Ylz1__YwtA__YCzX */ (Tc*)0, /* MEModule__CDivideByZero.getPos - YzSI__Ylz1__YwtA__YvCK */ (Tc*)0, /* MEModule__CDivideByZero.getBacktrace - YzSI__Ylz1__YwtA__Y4bq */ (Tc*)0, /* Init - YzSIa */ }; To ToYzSI[] = { {3, 0}, {0, (Tt*)&string__T}, /* message */ {0, (Tt*)&YkxB__T}, /* pos */ {0, (Tt*)&list__T}, /* backtrace */ }; Tto YzSI__T = {390, (Tc*)&YxFl, 0, ToYzSI}; YXKl *YXKl__YwtA__YRHR(YXKl *t, Tc *Amsg) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=4829900; t = Za(sizeof(YXKl));} sf.pos=4829901; t->Vmessage = Amsg; sf.pos=4829902; t->Vpos = MZ__callerPos(); sf.pos=4829903; t->Vbacktrace = (sf.pos=4829904, MZ__backtrace(1, -1)); topFrame = sf.prev; return t; } void YXKl__YwtA__YxaJa(YXKl *t, Tb Averbose, Tr Aw) { Zsf sf; Tl *Zf2 = NULL; YkxB *Vpos = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=8968500; ZthrowThisNil(); } sf.pos=8968501; YXKl__YwtA__YxaJ(t, Aw); sf.pos=8968502; if ((Averbose && (t->Vbacktrace != NULL))) { sf.pos=8968503; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Y62e)); sf.pos=8968504; { Tfl Zf2i; Zf2 = t->Vbacktrace; Zf2i.l = Zf2; Zf2i.valp = (void*)&Vpos; Zf2i.i = 0; for (; ZforListPtrCont(&Zf2i); ) { sf.pos=8968505; if ((Vpos->Vfilename == NULL)) { sf.pos=8968506; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yv6_)); } else { sf.pos=8968507; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yk)); sf.pos=8968508; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(Vpos)); sf.pos=8968509; if ((Vpos->Vtext != NULL)) { sf.pos=8968510; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); sf.pos=8968511; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, Vpos->Vtext); } } sf.pos=8968512; } } } topFrame = sf.prev; return; } void YXKl__YwtA__YxaJ(YXKl *t, Tr Aw) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=9988600; ZthrowThisNil(); } sf.pos=9988601; if ((t->Vpos != NULL)) { sf.pos=9988602; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(t->Vpos)); sf.pos=9988603; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); } sf.pos=9988604; if (((t->Vmessage != NULL) && (ZbyteStringSize(t->Vmessage) != 0))) { sf.pos=9988605; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YHbP)); sf.pos=9988606; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, t->Vmessage); } else { sf.pos=9988607; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YDGe)); } topFrame = sf.prev; return; } Tc *YXKl__Ytlm_I_imt[] = { (Tc*)&YXKl__T, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)0, /* MEModule__CIOError.NEW - YXKl__YwtA__YRHRa */ (Tc*)YXKl__YwtA__YRHR, /* MEModule__CIOError.NEW - YXKl__YwtA__YRHR */ (Tc*)0, /* MEModule__CIOError.ToString - YXKl__YwtA__YH0V */ (Tc*)YXKl__YwtA__YxaJa, /* MEModule__CIOError.writeTo - YXKl__YwtA__YxaJa */ (Tc*)YXKl__YwtA__YxaJ, /* MEModule__CIOError.writeTo - YXKl__YwtA__YxaJ */ (Tc*)0, /* MEModule__CIOError.toString - YXKl__YwtA__Yoww */ (Tc*)0, /* MEModule__CIOError.getMessage - YXKl__YwtA__YCzX */ (Tc*)0, /* MEModule__CIOError.getPos - YXKl__YwtA__YvCK */ (Tc*)0, /* MEModule__CIOError.getBacktrace - YXKl__YwtA__Y4bq */ (Tc*)0, /* Init - YXKla */ }; To ToYXKl[] = { {3, 0}, {0, (Tt*)&string__T}, /* message */ {0, (Tt*)&YkxB__T}, /* pos */ {0, (Tt*)&list__T}, /* backtrace */ }; Tto YXKl__T = {390, (Tc*)&YTj3, 0, ToYXKl}; YuDC *YdhH(YuDC *t) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=8723500; t = Za(sizeof(YuDC));} sf.pos=8723501; t->Vmessage = ((Tc*)&Ynjz); sf.pos=8723502; t->Vpos = MZ__callerPos(); sf.pos=8723503; t->Vbacktrace = (sf.pos=8723504, MZ__backtrace(1, -1)); topFrame = sf.prev; return t; } void YuDC__YwtA__YxaJa(YuDC *t, Tb Averbose, Tr Aw) { Zsf sf; Tl *Zf2 = NULL; YkxB *Vpos = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=8681800; ZthrowThisNil(); } sf.pos=8681801; YuDC__YwtA__YxaJ(t, Aw); sf.pos=8681802; if ((Averbose && (t->Vbacktrace != NULL))) { sf.pos=8681803; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Y62e)); sf.pos=8681804; { Tfl Zf2i; Zf2 = t->Vbacktrace; Zf2i.l = Zf2; Zf2i.valp = (void*)&Vpos; Zf2i.i = 0; for (; ZforListPtrCont(&Zf2i); ) { sf.pos=8681805; if ((Vpos->Vfilename == NULL)) { sf.pos=8681806; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yv6_)); } else { sf.pos=8681807; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yk)); sf.pos=8681808; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(Vpos)); sf.pos=8681809; if ((Vpos->Vtext != NULL)) { sf.pos=8681810; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); sf.pos=8681811; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, Vpos->Vtext); } } sf.pos=8681812; } } } topFrame = sf.prev; return; } void YuDC__YwtA__YxaJ(YuDC *t, Tr Aw) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=9701900; ZthrowThisNil(); } sf.pos=9701901; if ((t->Vpos != NULL)) { sf.pos=9701902; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(t->Vpos)); sf.pos=9701903; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); } sf.pos=9701904; if (((t->Vmessage != NULL) && (ZbyteStringSize(t->Vmessage) != 0))) { sf.pos=9701905; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YHbP)); sf.pos=9701906; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, t->Vmessage); } else { sf.pos=9701907; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YDGe)); } topFrame = sf.prev; return; } Tc *YuDC__Ytlm_I_imt[] = { (Tc*)&YuDC__T, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)0, /* MEModule__CWrongType.NEW - YuDC__YwtA__YRHRa */ (Tc*)0, /* MEModule__CWrongType.NEW - YuDC__YwtA__YRHR */ (Tc*)0, /* MEModule__CWrongType.ToString - YuDC__YwtA__YH0V */ (Tc*)YuDC__YwtA__YxaJa, /* MEModule__CWrongType.writeTo - YuDC__YwtA__YxaJa */ (Tc*)YuDC__YwtA__YxaJ, /* MEModule__CWrongType.writeTo - YuDC__YwtA__YxaJ */ (Tc*)0, /* MEModule__CWrongType.toString - YuDC__YwtA__Yoww */ (Tc*)0, /* MEModule__CWrongType.getMessage - YuDC__YwtA__YCzX */ (Tc*)0, /* MEModule__CWrongType.getPos - YuDC__YwtA__YvCK */ (Tc*)0, /* MEModule__CWrongType.getBacktrace - YuDC__YwtA__Y4bq */ (Tc*)0, /* Init - YuDCa */ }; To ToYuDC[] = { {3, 0}, {0, (Tt*)&string__T}, /* message */ {0, (Tt*)&YkxB__T}, /* pos */ {0, (Tt*)&list__T}, /* backtrace */ }; Tto YuDC__T = {390, (Tc*)&YCoZ, 0, ToYuDC}; void YTuG(Ti Apos) { Tr ex; YuDC *Ve = 0; Tr t0 = {NULL}; Ve = YdhH(NULL); Ve->Vpos = MZ__posnr2pos(NULL, Apos); *Znao(&ex, Ve, YuDC__Ytlm_I_imt, 24); ZthrowIobject(ex); } YrHq *YrHq__YwtA__YRHR(YrHq *t, Tc *Amsg) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=7808200; t = Za(sizeof(YrHq));} sf.pos=7808201; t->Vmessage = Amsg; sf.pos=7808202; t->Vpos = MZ__callerPos(); sf.pos=7808203; t->Vbacktrace = (sf.pos=7808204, MZ__backtrace(1, -1)); topFrame = sf.prev; return t; } void YrHq__YwtA__YxaJa(YrHq *t, Tb Averbose, Tr Aw) { Zsf sf; Tl *Zf2 = NULL; YkxB *Vpos = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=41200; ZthrowThisNil(); } sf.pos=41201; YrHq__YwtA__YxaJ(t, Aw); sf.pos=41202; if ((Averbose && (t->Vbacktrace != NULL))) { sf.pos=41203; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Y62e)); sf.pos=41204; { Tfl Zf2i; Zf2 = t->Vbacktrace; Zf2i.l = Zf2; Zf2i.valp = (void*)&Vpos; Zf2i.i = 0; for (; ZforListPtrCont(&Zf2i); ) { sf.pos=41205; if ((Vpos->Vfilename == NULL)) { sf.pos=41206; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yv6_)); } else { sf.pos=41207; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&Yk)); sf.pos=41208; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(Vpos)); sf.pos=41209; if ((Vpos->Vtext != NULL)) { sf.pos=41210; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); sf.pos=41211; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, Vpos->Vtext); } } sf.pos=41212; } } } topFrame = sf.prev; return; } void YrHq__YwtA__YxaJ(YrHq *t, Tr Aw) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=1061300; ZthrowThisNil(); } sf.pos=1061301; if ((t->Vpos != NULL)) { sf.pos=1061302; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, YpI_(t->Vpos)); sf.pos=1061303; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YFDa)); } sf.pos=1061304; if (((t->Vmessage != NULL) && (ZbyteStringSize(t->Vmessage) != 0))) { sf.pos=1061305; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YHbP)); sf.pos=1061306; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, t->Vmessage); } else { sf.pos=1061307; ((Ts (*)(void*, Tc*))(Aw.table[1]))(Aw.ptr, ((Tc*)&YDGe)); } topFrame = sf.prev; return; } Tc *YrHq__Ytlm_I_imt[] = { (Tc*)&YrHq__T, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)0, /* MEModule__CInternal.NEW - YrHq__YwtA__YRHRa */ (Tc*)YrHq__YwtA__YRHR, /* MEModule__CInternal.NEW - YrHq__YwtA__YRHR */ (Tc*)0, /* MEModule__CInternal.ToString - YrHq__YwtA__YH0V */ (Tc*)YrHq__YwtA__YxaJa, /* MEModule__CInternal.writeTo - YrHq__YwtA__YxaJa */ (Tc*)YrHq__YwtA__YxaJ, /* MEModule__CInternal.writeTo - YrHq__YwtA__YxaJ */ (Tc*)0, /* MEModule__CInternal.toString - YrHq__YwtA__Yoww */ (Tc*)0, /* MEModule__CInternal.getMessage - YrHq__YwtA__YCzX */ (Tc*)0, /* MEModule__CInternal.getPos - YrHq__YwtA__YvCK */ (Tc*)0, /* MEModule__CInternal.getBacktrace - YrHq__YwtA__Y4bq */ (Tc*)0, /* Init - YrHqa */ }; To ToYrHq[] = { {3, 0}, {0, (Tt*)&string__T}, /* message */ {0, (Tt*)&YkxB__T}, /* pos */ {0, (Tt*)&list__T}, /* backtrace */ }; Tto YrHq__T = {390, (Tc*)&YVki, 0, ToYrHq}; void YUSH(YkxB *Apos, Tc *Atext) { Tr ex; YrHq *Ve = 0; Tr t0 = {NULL}; Ve = YrHq__YwtA__YRHR(NULL, Atext); if ((Apos != NULL)) { Ve->Vpos = Apos; } *Znao(&ex, Ve, YrHq__Ytlm_I_imt, 26); ZthrowIobject(ex); } void YxIS(Tr Ae) { static int entered = 0; int didEnter = entered; entered = 1; if ((Ae).type == 1) { Ti VexitVal; VexitVal = ((YEro *)Znio(1, 1571802, (Ae)))->Vvalue; if (!didEnter) beforeExit(); exit(VexitVal); } else { YvL0(Ae); if (!didEnter) beforeExit(); exit(1); } return; } void YvL0(Tr Ae) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=5238600; Ylxt(); sf.pos=5238601; YQar(Ae, 1, YeNQ); sf.pos=5238617; ((Ts (*)(void*))(YeNQ.table[18]))(YeNQ.ptr); topFrame = sf.prev; return; } void YQar(Tr A0, Tb A1, Tr A2) { if (A0.ptr == NULL) ZthrowCstringNil("writeTo: object is NIL, cannot select method to invoke"); if (A2.ptr == NULL) ZthrowCstringNil("writeTo: argument 2 is NIL, cannot select method to invoke"); switch (A0.type) { case 0: YxaJa(A0.ptr,A1,ZconvertZioref(A2, YdXi__imtt, 0, 99999, 5238602)); return; case 1: YEro__YxaJa(A0.ptr,A1,ZconvertZioref(A2, YdXi__imtt, 0, 99999, 5238603)); return; case 2: return; case 3: return; case 4: YKhn__YwtA__YxaJa(A0.ptr,A1,ZconvertZioref(A2, YdXi__imtt, 0, 99999, 5238604)); return; case 5: Y1uN__YwtA__YxaJa(A0.ptr,A1,ZconvertZioref(A2, YdXi__imtt, 0, 99999, 5238605)); return; case 6: YAxe__YwtA__YxaJa(A0.ptr,A1,ZconvertZioref(A2, YdXi__imtt, 0, 99999, 5238606)); return; case 7: YVNj__YwtA__YxaJa(A0.ptr,A1,ZconvertZioref(A2, YdXi__imtt, 0, 99999, 5238607)); return; case 8: return; case 9: return; case 10: Yalz__YwtA__YxaJa(A0.ptr,A1,ZconvertZioref(A2, YdXi__imtt, 0, 99999, 5238608)); return; case 11: Yw3O__Yalz__YwtA__YxaJa(A0.ptr,A1,ZconvertZioref(A2, YdXi__imtt, 0, 99999, 5238609)); return; case 12: Y2EX__Yalz__YwtA__YxaJa(A0.ptr,A1,ZconvertZioref(A2, YdXi__imtt, 0, 99999, 5238610)); return; case 13: return; case 14: YX0i__Yalz__YwtA__YxaJa(A0.ptr,A1,ZconvertZioref(A2, YdXi__imtt, 0, 99999, 5238611)); return; case 15: YP_P__Yalz__YwtA__YxaJa(A0.ptr,A1,ZconvertZioref(A2, YdXi__imtt, 0, 99999, 5238612)); return; case 16: return; case 17: YzSI__Ylz1__YwtA__YxaJa(A0.ptr,A1,ZconvertZioref(A2, YdXi__imtt, 0, 99999, 5238613)); return; case 18: return; case 19: YXKl__YwtA__YxaJa(A0.ptr,A1,ZconvertZioref(A2, YdXi__imtt, 0, 99999, 5238614)); return; case 20: return; case 21: return; case 22: return; case 23: return; case 24: YuDC__YwtA__YxaJa(A0.ptr,A1,ZconvertZioref(A2, YdXi__imtt, 0, 99999, 5238615)); return; case 25: return; case 26: YrHq__YwtA__YxaJa(A0.ptr,A1,ZconvertZioref(A2, YdXi__imtt, 0, 99999, 5238616)); return; case 27: return; case 28: return; case 29: return; case 30: return; case 31: return; } ZthrowCstringBadValue("writeTo: cannot select method to invoke"); return; } /* EModule done */ /* including ZModule bodies */ YkxB *Ypp_(YkxB *t, Tc *Afilename) { if (t == NULL) {t = Za(sizeof(YkxB));} t->Vfilename = Afilename; t->Vlnum = 1; t->Vcol = 1; return t; } YkxB *Ypp_a(YkxB *t, Tc *Afilename, Ti Alnum, Ti Acol) { if (t == NULL) {t = Za(sizeof(YkxB));} t->Vfilename = Afilename; t->Vlnum = Alnum; t->Vcol = Acol; return t; } YkxB *Y83A(YkxB *t) { Zsf sf; YkxB *r = 0; YkxB *Vp = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=1602000; ZthrowThisNil(); } sf.pos=1602001; Vp = Ypp_(NULL, t->Vfilename); sf.pos=1602002; Vp->Vlnum = t->Vlnum; sf.pos=1602003; Vp->Vcol = t->Vcol; sf.pos=1602004; Vp->Vtext = t->Vtext; sf.pos=1602005; r = Vp; topFrame = sf.prev; return r; } void YnS4(YkxB *t) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=4686800; ZthrowThisNil(); } sf.pos=4686801; ++(t->Vlnum); sf.pos=4686802; t->Vcol = 1; topFrame = sf.prev; return; } Tc *YpI_(YkxB *t) { Zsf sf; Tc *r = 0; YjUM *Vw = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=1818700; ZthrowThisNil(); } sf.pos=1818701; Vw = Za(sizeof(YjUM)); sf.pos=1818702; if ((t->Vfilename == NULL)) { sf.pos=1818703; YJqza(Vw, ((Tc*)&YKo1)); } else { sf.pos=1818704; YJqza(Vw, t->Vfilename); } sf.pos=1818705; YJqza(Vw, ((Tc*)&YBpY)); sf.pos=1818706; YjUM__YHhZb(Vw, t->Vlnum); sf.pos=1818707; YJqza(Vw, ((Tc*)&Y8ES)); sf.pos=1818708; YjUM__YHhZb(Vw, t->Vcol); sf.pos=1818709; r = YbNW(Vw); topFrame = sf.prev; return r; } To ToYkxB[] = { {2, 0}, {0, (Tt*)&string__T}, /* filename */ {0, (Tt*)&string__T}, /* text */ }; Tto YkxB__T = {390, (Tc*)&YBCs, 0, ToYkxB}; /* ZModule done */ /* including IOModule bodies */ Tr Yd89() { Tr r = {NULL}; Tr Vfile = {NULL}; Vfile = Zao(Za(sizeof(Yw8L)), Yw8L__Yw8L_I_imt, 0); (*(FILE **)(Vfile.ptr + (size_t)Vfile.table[20])) = stdin; r = Vfile; return r; } Tr Yvyt() { Tr r = {NULL}; Tr Vfile = {NULL}; Vfile = Zao(Za(sizeof(Yw8L)), Yw8L__Yw8L_I_imt, 0); (*(FILE **)(Vfile.ptr + (size_t)Vfile.table[20])) = stdout; r = Vfile; return r; } Tr YsM3() { Tr r = {NULL}; Tr Vfile = {NULL}; Vfile = Zao(Za(sizeof(Yw8L)), Yw8L__Yw8L_I_imt, 0); (*(FILE **)(Vfile.ptr + (size_t)Vfile.table[20])) = stderr; r = Vfile; return r; } Tc **YdXi__imtt[] = { Yw8L__YdXi_imt, 0, YjUM__YdXi_imt, 0, }; Ti YFeQ(Yw8L *t) { Ti Vb; Zsf sf; Ti r = 0; Tr t0 = {NULL}; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=1605300; ZthrowThisNil(); } sf.pos=1605301; if ((t->Vfd == NULL)) { Tr ex; sf.pos=1605302; *Znao(&ex, YXKl__YwtA__YRHR(NULL, ((Tc*)&YQe8)), YXKl__Ytlm_I_imt, 19); ZthrowIobject(ex); } Vb = 0; sf.pos=1605303; Vb = fgetc(t->Vfd); sf.pos=1605304; r = Vb; topFrame = sf.prev; return r; } Ti YAPp(Yw8L *t) { Ti Vc; Zsf sf; Ti r = 0; Tr t0 = {NULL}; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=4663100; ZthrowThisNil(); } sf.pos=4663101; Vc = YFeQ(t); sf.pos=4663102; if (((Vc != Y3QJ) && (Vc >= 128))) { Ti Vlen; Vlen = 0; sf.pos=4663103; if ((((Vc & 224)) == 192)) { sf.pos=4663104; Vlen = 2; sf.pos=4663105; Vc = (Vc & 31); } else { sf.pos=4663106; if ((((Vc & 240)) == 224)) { sf.pos=4663107; Vlen = 3; sf.pos=4663108; Vc = (Vc & 15); } else { sf.pos=4663109; if ((((Vc & 248)) == 240)) { sf.pos=4663110; Vlen = 4; sf.pos=4663111; Vc = (Vc & 7); } else { Tr ex; sf.pos=4663112; *Znao(&ex, YP_P__Yalz__YwtA__YRHR(NULL, ZcS(((Tc*)&YPHa), Zint2string(Vc))), YP_P__Ytlm_I_imt, 15); ZthrowIobject(ex); } }} sf.pos=4663113; { Ti Vnr; Tfr Zf2; ZforRangeNew(2, Vlen, 0, 1, &Zf2); for (ZforRangeGetInt(&Zf2, &Vnr); ZforRangeContInt(&Zf2); ZforRangeNextInt(&Zf2, &Vnr)) { Ti Vc2; sf.pos=4663114; Vc2 = YFeQ(t); sf.pos=4663115; if ((Vc2 == Y3QJ)) { Tr ex; sf.pos=4663116; *Znao(&ex, YP_P__Yalz__YwtA__YRHR(NULL, ZcS(((Tc*)&YKzT), Zint2string(Vnr))), YP_P__Ytlm_I_imt, 15); ZthrowIobject(ex); } else { sf.pos=4663117; if ((((Vc2 & 192)) != 128)) { Tr ex; sf.pos=4663118; *Znao(&ex, YP_P__Yalz__YwtA__YRHR(NULL, ZcS3(((Tc*)&Ymwv), Zint2string(Vnr), ((Tc*)&YPfW))), YP_P__Ytlm_I_imt, 15); ZthrowIobject(ex); } } sf.pos=4663119; Vc = (((Vc << 6)) + ((Vc2 & 63))); sf.pos=4663120; } } sf.pos=4663121; switch (Vlen) { case 2: { sf.pos=4663122; if ((Vc <= 127)) { Tr ex; sf.pos=4663123; *Znao(&ex, YP_P__Yalz__YwtA__YRHR(NULL, ((Tc*)&Y8Gn)), YP_P__Ytlm_I_imt, 15); ZthrowIobject(ex); } break; } case 3: { sf.pos=4663124; if ((Vc <= 2047)) { Tr ex; sf.pos=4663125; *Znao(&ex, YP_P__Yalz__YwtA__YRHR(NULL, ((Tc*)&Y8Gn)), YP_P__Ytlm_I_imt, 15); ZthrowIobject(ex); } break; } case 4: { sf.pos=4663126; if ((Vc <= 65535)) { Tr ex; sf.pos=4663127; *Znao(&ex, YP_P__Yalz__YwtA__YRHR(NULL, ((Tc*)&Y8Gn)), YP_P__Ytlm_I_imt, 15); ZthrowIobject(ex); } break; } } } sf.pos=4663128; r = Vc; topFrame = sf.prev; return r; } Ts YwHoa(Yw8L *t, Tc *Atext) { Ts Vret; Zsf sf; Ts r = 0; Tr t0 = {NULL}; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=9482300; ZthrowThisNil(); } Vret = 0; sf.pos=9482301; if ((t->Vfd == NULL)) { Tr ex; sf.pos=9482302; *Znao(&ex, YXKl__YwtA__YRHR(NULL, ((Tc*)&YQe8)), YXKl__Ytlm_I_imt, 19); ZthrowIobject(ex); } sf.pos=9482303; { Tc *p; Ti len = ZstringSizePtr(Atext, &p); if (len == 0 || fwrite(p, (size_t)len, (size_t)1, t->Vfd) == 1) Vret = 1; else Vret = 0; } sf.pos=9482304; r = Vret; topFrame = sf.prev; return r; } Ts YGmp(Yw8L *t) { Ts Vret; Zsf sf; Ts r = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=6056700; ZthrowThisNil(); } sf.pos=6056701; Vret = 0; sf.pos=6056702; if ((t->Vfd != NULL)) { sf.pos=6056703; if (fflush(t->Vfd) == 0) Vret = 1; else Vret = 0; } sf.pos=6056704; r = Vret; topFrame = sf.prev; return r; } Ts YrF8(Yw8L *t) { Ts Vret; Zsf sf; Ts r = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=1575500; ZthrowThisNil(); } sf.pos=1575501; Vret = 0; sf.pos=1575502; if ((t->Vfd != NULL)) { sf.pos=1575503; if (fflush(t->Vfd) != 0) Vret = 0; sf.pos=1575504; if (fclose(t->Vfd) != 0) Vret = 0; sf.pos=1575505; t->Vfd = NULL; } sf.pos=1575506; r = Vret; topFrame = sf.prev; return r; } Ts Yw8L__YHhZb(Yw8L *t, Ti Anumber) { Zsf sf; Ts r = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=5981900; ZthrowThisNil(); } sf.pos=5981901; r = YwHoa(t, Zint2string(Anumber)); topFrame = sf.prev; return r; } Ts Yw8L__YRt7(Yw8L *t, Tc *Atext) { Zsf sf; Ts r = 0; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=6618800; ZthrowThisNil(); } sf.pos=6618801; if (((YwHoa(t, Atext) == 1) && (YwHoa(t, ((Tc*)&Yk)) == 1))) { sf.pos=6618802; r = 1; rt = 1; goto Y7Vd; } sf.pos=6618803; r = 0; Y7Vd: topFrame = sf.prev; return r; } Ts Yw8L__YRt7g(Yw8L *t) { Zsf sf; Ts r = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=8261800; ZthrowThisNil(); } sf.pos=8261801; r = YwHoa(t, ((Tc*)&Yk)); topFrame = sf.prev; return r; } Tc *Yw8L__Yw8L_I_imt[] = { (Tc*)&Yw8L__T, (Tc*)YwHoa, /* MIOModule__CFile.write - YwHoa */ (Tc*)0, /* MIOModule__CFile.write - Yw8L__YHhZa */ (Tc*)Yw8L__YHhZb, /* MIOModule__CFile.write - Yw8L__YHhZb */ (Tc*)0, /* MIOModule__CFile.write - Yw8L__YHhZc */ (Tc*)0, /* MIOModule__CFile.write - Yw8L__YHhZd */ (Tc*)0, /* MIOModule__CFile.write - Yw8L__YHhZe */ (Tc*)0, /* MIOModule__CFile.write - Yw8L__YHhZf */ (Tc*)0, /* MIOModule__CFile.write - Yw8L__YHhZg */ (Tc*)0, /* MIOModule__CFile.writeByte - YvfVa */ (Tc*)0, /* MIOModule__CFile.writeChar - Yw8L__Ydti */ (Tc*)Yw8L__YRt7, /* MIOModule__CFile.print - Yw8L__YRt7 */ (Tc*)0, /* MIOModule__CFile.print - Yw8L__YRt7a */ (Tc*)0, /* MIOModule__CFile.print - Yw8L__YRt7b */ (Tc*)0, /* MIOModule__CFile.print - Yw8L__YRt7c */ (Tc*)0, /* MIOModule__CFile.print - Yw8L__YRt7d */ (Tc*)0, /* MIOModule__CFile.print - Yw8L__YRt7e */ (Tc*)0, /* MIOModule__CFile.print - Yw8L__YRt7f */ (Tc*)Yw8L__YRt7g, /* MIOModule__CFile.print - Yw8L__YRt7g */ (Tc*)0, /* MIOModule__CFile.format - Yw8L__YTPv */ (Tc*)0, (Tc*)0, (Tc*)YFeQ, /* MIOModule__CFile.readByte - YFeQ */ (Tc*)YAPp, /* MIOModule__CFile.readChar - YAPp */ (Tc*)0, /* MIOModule__CFile.readAll - Yyuma */ (Tc*)0, /* MIOModule__CFile.readAll - Yyum */ (Tc*)0, /* MIOModule__CFile.readAllBytes - YVfz */ (Tc*)0, /* MIOModule__CFile.readLine - YaEh */ (Tc*)0, /* MIOModule__CFile.readLineRaw - Yn2l */ (Tc*)0, /* MIOModule__CFile.readAllLines - YCm1a */ (Tc*)0, /* MIOModule__CFile.readAllLines - YCm1 */ (Tc*)0, /* MIOModule__CFile.readAllLinesRaw - YWWFa */ (Tc*)0, /* MIOModule__CFile.readAllLinesRaw - YWWF */ (Tc*)0, /* MIOModule__CFile.writeAllLines - YZFx */ (Tc*)YGmp, /* MIOModule__CFile.flush - YGmp */ (Tc*)YrF8, /* MIOModule__CFile.close - YrF8 */ (Tc*)0, /* MIOModule__CFile.Finish - YSo_ */ (Tc*)0, /* Init - Yw8La */ }; Tc *Yw8L__YdXi_imt[] = { (Tc*)&Yw8L__T, (Tc*)YwHoa, /* MIOModule__CFile.write - YwHoa */ (Tc*)Yw8L__YRt7, /* MIOModule__CFile.print - Yw8L__YRt7 */ }; To ToYw8L[] = { {1, 0}, {0, (Tt*)&string__T}, /* name */ }; Tto Yw8L__T = {390, (Tc*)&YtTU, 0, ToYw8L}; Tr YsGz(Tc *AfileName) { Zsf sf; Tr r = {NULL}; Tr Vfile = {NULL}; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=9983800; { int fnr = open(ZgetCstring(AfileName), O_RDONLY); if (fnr >= 0) { sf.pos=9983801; Vfile = *Znao(&Vfile, Za(sizeof(Yw8L)), Yw8L__Yw8L_I_imt, 0); sf.pos=9983802; (*(FILE **)(Vfile.ptr + (size_t)Vfile.table[20])) = fdopen(fnr, "r"); } } sf.pos=9983803; r = Vfile; topFrame = sf.prev; return r; } Tr YiBk(Tc *AfileName, Tb Atruncate) { Zsf sf; Tr r = {NULL}; Tr Vfile = {NULL}; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=8158000; { int flags = O_WRONLY|O_CREAT; if (Atruncate) flags |= O_TRUNC; int fnr = open(ZgetCstring(AfileName), flags, 0666); if (fnr >= 0) { if (!Atruncate) lseek(fnr, 0, SEEK_END); sf.pos=8158001; Vfile = *Znao(&Vfile, Za(sizeof(Yw8L)), Yw8L__Yw8L_I_imt, 0); sf.pos=8158002; (*(FILE **)(Vfile.ptr + (size_t)Vfile.table[20])) = fdopen(fnr, "w"); } } sf.pos=8158003; r = Vfile; topFrame = sf.prev; return r; } Ts Yvcu(Tc *Atext) { Ts Vret; Zsf sf; Ts r = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; Vret = 0; sf.pos=8487000; { Tc *p; Ti len = ZstringSizePtr(Atext, &p); if (len == 0 || fwrite(p, (size_t)len, (size_t)1, stdout) == 1) Vret = 1; else Vret = 0; } sf.pos=8487001; r = Vret; topFrame = sf.prev; return r; } Ts Yl0k(Tc *Atext) { Ts Vret; Ti Vlen; Zsf sf; Ts r = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; Vret = 0; sf.pos=187200; Vlen = ZbyteStringSize(Atext); sf.pos=187201; if ((Vlen == 0 || fwrite(ZgetCstring(Atext), (size_t)Vlen, 1, stdout) == 1) && fputc('\n', stdout) >= 0) Vret = 1; else Vret = 0; sf.pos=187202; r = Vret; topFrame = sf.prev; return r; } Ts Ylxt() { Ts Vret; Zsf sf; Ts r = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; Vret = 0; sf.pos=4676100; if (fflush(stdout) == 0) Vret = 1; else Vret = 0; sf.pos=4676101; r = Vret; topFrame = sf.prev; return r; } Ts YJqza(YjUM *t, Tc *Atext) { Ti Vlen; Zsf sf; Ts r = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=8998700; ZthrowThisNil(); } sf.pos=8998701; Vlen = ZbyteStringSize(Atext); sf.pos=8998702; if ((t->Vs == NULL)) { sf.pos=8998703; t->Vs = ZnewArray((Tt*)&byte__T, sizeof(Tc), (Vlen + 30)); sf.pos=8998704; Zas(t->Vs, Atext, 0, 0); sf.pos=8998705; t->VsLen = Vlen; } else { sf.pos=8998706; if ((((t->VsLen + Vlen) + 1) >= ZArraySize(t->Vs))) { sf.pos=8998707; ZarrayResize(t->Vs, sizeof(Tc), (((ZArraySize(t->Vs) + (ZArraySize(t->Vs) / 8)) + Vlen) + 50)) ; } sf.pos=8998708; Zas(t->Vs, Atext, 0, t->VsLen); sf.pos=8998709; t->VsLen += Vlen; } sf.pos=8998710; r = 1; topFrame = sf.prev; return r; } Tc *YbNW(YjUM *t) { Zsf sf; Tc *r = 0; Tc *Vr = NULL; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=6453100; ZthrowThisNil(); } sf.pos=6453101; if ((t->Vs == NULL)) { sf.pos=6453102; Vr = ((Tc*)&Ya); } else { sf.pos=6453103; Vr = ZnewString(t->Vs->ptr, t->VsLen); } sf.pos=6453104; r = Vr; topFrame = sf.prev; return r; } Ti Y6jW(YjUM *t) { Ti Vc; Zsf sf; Ti r = 0; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=5897500; ZthrowThisNil(); } sf.pos=5897501; if ((t->VsLen == 0)) { sf.pos=5897502; r = Y3QJ; rt = 1; goto Ykjg; } Vc = 0; sf.pos=5897503; Vc = (*(Tc*)ZarrayPtr(t->Vs, --(t->VsLen))); sf.pos=5897504; (*(Tc*)ZarrayPtr(t->Vs, t->VsLen)) = 0; sf.pos=5897505; if (((((Vc & 192)) == 128) && (t->VsLen > 0))) { Ti Vc2; sf.pos=5897506; Vc2 = (*(Tc*)ZarrayPtr(t->Vs, --(t->VsLen))); sf.pos=5897507; (*(Tc*)ZarrayPtr(t->Vs, t->VsLen)) = 0; sf.pos=5897508; if (((((Vc2 & 192)) == 128) && (t->VsLen > 0))) { Ti Vc3; sf.pos=5897509; Vc3 = (*(Tc*)ZarrayPtr(t->Vs, --(t->VsLen))); sf.pos=5897510; (*(Tc*)ZarrayPtr(t->Vs, t->VsLen)) = 0; sf.pos=5897511; if (((((Vc3 & 192)) == 128) && (t->VsLen > 0))) { Ti Vc4; sf.pos=5897512; Vc4 = (*(Tc*)ZarrayPtr(t->Vs, --(t->VsLen))); sf.pos=5897513; (*(Tc*)ZarrayPtr(t->Vs, t->VsLen)) = 0; sf.pos=5897514; Vc = (((((((Vc4 & 7)) << 18)) + ((((Vc3 & 63)) << 12))) + ((((Vc2 & 63)) << 6))) + ((Vc & 63))); } else { sf.pos=5897515; Vc = ((((((Vc3 & 15)) << 12)) + ((((Vc2 & 63)) << 6))) + ((Vc & 63))); } } else { sf.pos=5897516; Vc = (((((Vc2 & 31)) << 6)) + ((Vc & 63))); } } sf.pos=5897517; r = Vc; Ykjg: topFrame = sf.prev; return r; } Ts YjUM__YHhZb(YjUM *t, Ti Anumber) { Zsf sf; Ts r = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=7200700; ZthrowThisNil(); } sf.pos=7200701; r = YJqza(t, Zint2string(Anumber)); topFrame = sf.prev; return r; } Ts YjUM__Ydti(YjUM *t, Ti Achar) { Zsf sf; Ts r = 0; Tr t0 = {NULL}; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=4928500; ZthrowThisNil(); } sf.pos=4928501; if (((Achar < 0) || (Achar > 1114111))) { Tr ex; sf.pos=4928502; *Znao(&ex, Yw3O__Yalz__YwtA__YRHR(NULL, ZcS(((Tc*)&Yv8w), Zint2string(Achar))), Yw3O__Ytlm_I_imt, 11); ZthrowIobject(ex); } sf.pos=4928503; r = YJqza(t, ZintAsString(Achar)); topFrame = sf.prev; return r; } Ts YjUM__YRt7(YjUM *t, Tc *Atext) { Zsf sf; Ts r = 0; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=2676000; ZthrowThisNil(); } sf.pos=2676001; if (((YJqza(t, Atext) == 1) && (YJqza(t, ((Tc*)&Yk)) == 1))) { sf.pos=2676002; r = 1; rt = 1; goto Yvkn; } sf.pos=2676003; r = 0; Yvkn: topFrame = sf.prev; return r; } Tc *YjUM__YdXi_imt[] = { (Tc*)&YjUM__T, (Tc*)YJqza, /* MIOModule__CStringWriter.write - YJqza */ (Tc*)YjUM__YRt7, /* MIOModule__CStringWriter.print - YjUM__YRt7 */ }; To ToYjUM[] = { {2, 0}, {0, (Tt*)&array__T}, /* s */ {0, (Tt*)&string__T}, /* x */ }; Tto YjUM__T = {390, (Tc*)&YE4c, 0, ToYjUM}; int JIOModule(int round) { static int round_done = -1; int done = 1; if (round_done < round) { Zsf sf; sf.prev = topFrame; sf.pos = 0; sf.frof = NULL; topFrame = &sf; round_done = round; if (round == 0) { sf.pos=745200; Y59X = Yd89(); sf.pos=745201; Yb0q = Yvyt(); sf.pos=745202; YeNQ = YsM3(); } topFrame = sf.prev; } return done; } /* IOModule done */ /* including LOGModule bodies */ void YDli(Tc *Amsg, YkxB *Apos, Tbs Aflags) { Ygkj(5, Amsg, Apos, Aflags); return; } void Y2oO(Tc *Amsg, YkxB *Apos, Tbs Aflags) { Ygkj(5, Amsg, Apos, (Aflags + 2)); return; } void Ygkj(Te Alevel, Tc *Amsg, YkxB *Apos, Tbs Aflags) { YjUM *Vw = 0; Tc *VwholeMsg = NULL; Y2KX *Vtv = 0; Tr t0 = {NULL}; Tc *t1 = NULL; Tc *t2 = NULL; int rt = 0; if ((((((Alevel == 0) && !(YuOS(YU8T)))) || (((Alevel == 1) && (Y86c__Ye9f(YlUb) < 2)))) || (((Alevel == 2) && (Y86c__Ye9f(YlUb) < 1))))) { rt = 1; goto YbRZ; } ++(*ZDictGetIntP(Ytd2, (Tz)(Ti)Alevel)); Vw = Za(sizeof(YjUM)); if ((Apos != NULL)) { YJqza(Vw, YpI_(Apos)); YJqza(Vw, ((Tc*)&YFDa)); } if ((((Aflags) & 2) >> 1)) { YJqza(Vw, ((Tc*)&YJ5p)); } switch (Alevel) { case 4: { YJqza(Vw, ((Tc*)&Yyq1)); break; } case 5: { YJqza(Vw, ((Tc*)&Y27a)); break; } case 6: { YJqza(Vw, ((Tc*)&Y3l3)); break; } case 7: { YJqza(Vw, ((Tc*)&YmM8)); break; } } YJqza(Vw, YmaW); YJqza(Vw, Amsg); if ((((Aflags) & 1))) { YwlF(*Znao(&t0, Vw, YjUM__YdXi_imt, 2)); } if (!((((Aflags) & 4) >> 2))) { YJqza(Vw, ((Tc*)&Yk)); } VwholeMsg = YbNW(Vw); Yvcu(VwholeMsg); if ((((Yz2b).ptr) != NULL)) { if (YiAD) { Vtv = YgaY(NULL); ((Ts (*)(void*, Tc*))(Yz2b.table[1]))(Yz2b.ptr, ZcS5(YYTs(Vtv), ((Tc*)&YU), (t1 = ZintFormat(((Tc*)&YwV7), Vtv->Vusec)), ((Tc*)&YG), (Tc*)1)); } ((Ts (*)(void*, Tc*))(Yz2b.table[1]))(Yz2b.ptr, VwholeMsg); } if ((Alevel >= 5)) { ++(Yrpn); Y7LJ(); } else { if (((Y9Rj() - YvW3) > YOwl)) { Y7LJ(); } } if ((Alevel == 7)) { Zexit(NULL, 10); } YbRZ: return; } void YwlF(Tr Aout) { Zsf sf; Tl *Zf1 = NULL; YkxB *Vp = 0; Tc *t0 = NULL; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=8489900; ((Ts (*)(void*, Tc*))(Aout.table[2]))(Aout.ptr, ((Tc*)&Ya)); sf.pos=8489901; ((Ts (*)(void*, Tc*))(Aout.table[2]))(Aout.ptr, ((Tc*)&YDzC)); sf.pos=8489903; { Tfl Zf1i; Zf1 = (sf.pos=8489904, MZ__backtrace(0, -1)); Zf1i.l = Zf1; Zf1i.valp = (void*)&Vp; Zf1i.i = 0; for (; ZforListPtrCont(&Zf1i); ) { sf.pos=8489905; ((Ts (*)(void*, Tc*))(Aout.table[2]))(Aout.ptr, ZcS3(YpI_(Vp), ((Tc*)&YFDa), (t0 = Vp->Vtext))); sf.pos=8489906; } } topFrame = sf.prev; return; } void Y7LJ() { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=5655500; Ylxt(); sf.pos=5655501; if ((((Yz2b).ptr) != NULL)) { sf.pos=5655502; ((Ts (*)(void*))(Yz2b.table[34]))(Yz2b.ptr); } sf.pos=5655503; YvW3 = Y9Rj(); topFrame = sf.prev; return; } int JLOGModule(int round) { static int round_done = -1; int done = 1; if (round_done < round) { Zsf sf; sf.prev = topFrame; sf.pos = 0; sf.frof = NULL; topFrame = &sf; round_done = round; if (round == 0) { sf.pos=8332600; YU8T = YttT(NULL, ((Tc*)&YLa), ((Tc*)&YGwH), 0, ((Tc*)&YhpM)); sf.pos=8332601; YlUb = YttT(NULL, ((Tc*)&Y2a), ((Tc*)&YUsn), 0, ((Tc*)&YSuP)); } if (round == 0) { sf.pos=8332602; Ytd2 = ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZnewDict((Tt*)&MLOGModule__ELevel__T, (Tt*)&int__T, 0), (Tz)(Ti)0, (Tz)(Ti)0), (Tz)(Ti)1, (Tz)(Ti)0), (Tz)(Ti)2, (Tz)(Ti)0), (Tz)(Ti)3, (Tz)(Ti)0), (Tz)(Ti)4, (Tz)(Ti)0), (Tz)(Ti)5, (Tz)(Ti)0), (Tz)(Ti)6, (Tz)(Ti)0), (Tz)(Ti)7, (Tz)(Ti)0); } topFrame = sf.prev; } return done; } /* LOGModule done */ /* including SETModule bodies */ Yhqr *Ypau(Yhqr *t) { Zsf sf; if (t == NULL) t = Za(sizeof(Yhqr)); sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=8901200; t->Vdict = ZnewDict((Tt*)&int__T, (Tt*)&bool__T, 0); topFrame = sf.prev; return t; } Yhqr *Yh95(Yhqr *t) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=2137800; t = Ypau(NULL);} topFrame = sf.prev; return t; } Tb YyHa(Yhqr *t, Ti Akey) { Zsf sf; Tb r = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=2586000; ZthrowThisNil(); } sf.pos=2586001; r = ZDictHas(t->Vdict, (Tz)(Ti)Akey); topFrame = sf.prev; return r; } Yhqr *YGMT(Yhqr *t, Ti Akey) { Yhqr *r = 0; YkxB *t0 = 0; Tc *t1 = NULL; Tr t2 = {NULL}; if (t == NULL) { ZthrowThisNil(); } if (ZDictHas(t->Vdict, (Tz)(Ti)Akey)) { Tr ex; *Znao(&ex, YX0i__Yalz__YwtA__YRHRa(NULL, (t0 = MZ__callerPos()), (t1 = ZcS(((Tc*)&YLLX), Zint2string(Akey)))), YX0i__Ytlm_I_imt, 14); ZthrowIobject(ex); } ZDictAdd(0, t->Vdict, (Tz)(Ti)Akey, (Tz)(Ti)1); r = t; return r; } To ToYhqr[] = { {1, 0}, {0, (Tt*)&dict__T}, /* dict */ }; Tto Yhqr__T = {390, (Tc*)&Yehz, 0, ToYhqr}; Ygqr *YuFZ(Ygqr *t) { Zsf sf; if (t == NULL) t = Za(sizeof(Ygqr)); sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=9971300; t->Vdict = ZnewDict((Tt*)&string__T, (Tt*)&bool__T, 0); topFrame = sf.prev; return t; } Ygqr *YGrg(Ygqr *t) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=7197900; t = YuFZ(NULL);} topFrame = sf.prev; return t; } Tb YXZk(Ygqr *t, Tc *Akey) { Zsf sf; Tb r = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=7646100; ZthrowThisNil(); } sf.pos=7646101; r = ZDictHas(t->Vdict, (Tz)(void*)Akey); topFrame = sf.prev; return r; } Ygqr *Y432(Ygqr *t, Tc *Akey) { Ygqr *r = 0; YkxB *t0 = 0; Tc *t1 = NULL; Tr t2 = {NULL}; if (t == NULL) { ZthrowThisNil(); } if (ZDictHas(t->Vdict, (Tz)(void*)Akey)) { Tr ex; *Znao(&ex, YX0i__Yalz__YwtA__YRHRa(NULL, (t0 = MZ__callerPos()), (t1 = ZcS(((Tc*)&YLLX), Akey))), YX0i__Ytlm_I_imt, 14); ZthrowIobject(ex); } ZDictAdd(0, t->Vdict, (Tz)(void*)Akey, (Tz)(Ti)1); r = t; return r; } To ToYgqr[] = { {1, 0}, {0, (Tt*)&dict__T}, /* dict */ }; Tto Ygqr__T = {390, (Tc*)&Yfhz, 0, ToYgqr}; /* SETModule done */ /* including ARGModule bodies */ Ts Ytu_() { Zsf sf; Ts r = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=6650100; r = (((Y6fX == NULL)) ? (0) : (1)); topFrame = sf.prev; return r; } Ti Yd2Z() { Ti r = 0; YY8i(); r = ZListSize(Y6fX); return r; } Tc *YtgL(Ti Aindex) { Tc *r = 0; int rt = 0; YY8i(); if (((Aindex < 0) || (Aindex >= ZListSize(Y6fX)))) { r = NULL; rt = 1; goto YJ1M; } r = ((Tc *)ZListGetPtr(Y6fX, Aindex)); YJ1M: return r; } To ToYnU5[] = { {0, 0}, }; Tto YnU5__T = {390, (Tc*)&Yr32, 0, ToYnU5}; void YY8i() { Tr t0 = {NULL}; if ((Y6fX == NULL)) { Tr ex; *Znao(&ex, YVNj__YwtA__YRHRa(NULL, MZ__callerPos(), ((Tc*)&YeBP)), YVNj__Ytlm_I_imt, 7); ZthrowIobject(ex); } return; } void YZH8() { Zsf sf; Tc *Varg = NULL; Tc *Vvalue = NULL; Tc *Vflagname = NULL; Tc *Vflagname1 = NULL; Tl *Zf2 = NULL; Tc *Vk = NULL; Tl *Zf21 = NULL; Tc *Vk1 = NULL; Tr Vflag = {NULL}; Y86c *Vbflag = 0; Y86c *Vbflag1 = 0; Y_SI *Vsflag = 0; YJQu *Viflag = 0; YzqH *Vsflag1 = 0; Tr t0 = {NULL}; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=8253300; if ((Y6fX == NULL)) { Tb VdoFlags; Tb Vskip; sf.pos=8253301; if ((Y7be == NULL)) { sf.pos=8253302; Y7be = ZnewDict((Tt*)&string__T, (Tt*)&iobj__T, 0); sf.pos=8253303; YBQy = ZnewDict((Tt*)&string__T, (Tt*)&iobj__T, 0); } sf.pos=8253304; if ((YUBd && (((ZDictSize(Y7be) > 0) || (ZDictSize(YBQy) > 0))))) { Tr ex; sf.pos=8253305; *Znao(&ex, YVNj__YwtA__YRHR(NULL, ((Tc*)&Y7T_)), YVNj__Ytlm_I_imt, 7); ZthrowIobject(ex); } sf.pos=8253306; { Tfl Zf2i; Zf2 = ZDictKeys(Y7be, 0); Zf2i.l = Zf2; Zf2i.valp = (void*)&Vk; Zf2i.i = 0; for (; ZforListPtrCont(&Zf2i); ) { Tr YXyJ = {NULL}; sf.pos=8253307; (YXyJ = ZDictGetIobj(Y7be, (Tz)(void*)Vk), ((void (*)(void*))(YXyJ.table[17]))(YXyJ.ptr)); sf.pos=8253308; } } sf.pos=8253309; { Tfl Zf21i; Zf21 = ZDictKeys(YBQy, 0); Zf21i.l = Zf21; Zf21i.valp = (void*)&Vk1; Zf21i.i = 0; for (; ZforListPtrCont(&Zf21i); ) { Tr YWyJ = {NULL}; sf.pos=8253310; (YWyJ = ZDictGetIobj(YBQy, (Tz)(void*)Vk1), ((void (*)(void*))(YWyJ.table[17]))(YWyJ.ptr)); sf.pos=8253311; } } sf.pos=8253312; Y6fX = ZnewList((Tt*)&string__T, 0); sf.pos=8253313; VdoFlags = !(YUBd); Vskip = 0; sf.pos=8253314; { Ti Vi; Tfr Zf2; ZforRangeNew(0, (ZListSize(Y1p3) - 1), 0, 1, &Zf2); for (ZforRangeGetInt(&Zf2, &Vi); ZforRangeContInt(&Zf2); ZforRangeNextInt(&Zf2, &Vi)) { sf.pos=8253315; if (Vskip) { sf.pos=8253316; Vskip = 0; rt = 4; if (rt) goto YgsM; } sf.pos=8253317; Varg = ((Tc *)ZListGetPtr(Y1p3, Vi)); sf.pos=8253318; if (((!(VdoFlags) || (ZstringGetChar(Varg, 0) != 45)) || (ZstringCmp(Varg, ((Tc*)&YT)) == 0))) { sf.pos=8253319; ZLap((Tl*)Y6fX, (Tz)(void*)Varg); sf.pos=8253320; if (YQpY) { sf.pos=8253321; VdoFlags = 0; } } else { sf.pos=8253322; if ((ZstringCmp(Varg, ((Tc*)&Y1ia)) == 0)) { sf.pos=8253323; VdoFlags = 0; } else { Vflag.ptr = NULL; Vvalue = NULL; sf.pos=8253324; if ((ZstringCmp(ZstringSlice(Varg, 0, 1, 0), ((Tc*)&Y1ia)) == 0)) { Ti Vidx; sf.pos=8253325; Vflagname = ZstringSlice(Varg, 2, -1, 0); sf.pos=8253326; if ((!(YhUP) && ((((ZstringCmp(Vflagname, ((Tc*)&YqzQ)) == 0) || (ZstringCmp(Vflagname, ((Tc*)&Y3vi)) == 0)) || (ZstringCmp(Vflagname, ((Tc*)&Yll7)) == 0))))) { sf.pos=8253327; Yfj5((ZstringCmp(Vflagname, ((Tc*)&YqzQ)) != 0)); } sf.pos=8253328; Vidx = ZstringFindChar(Vflagname, 61, 0); sf.pos=8253329; if ((Vidx > 0)) { sf.pos=8253330; Vvalue = ZstringSlice(Vflagname, (Vidx + 1), -1, 0); sf.pos=8253331; Vflagname = ZstringSlice(Vflagname, 0, (Vidx - 1), 0); } sf.pos=8253332; Vflag = ZDictGetIobjDef(YBQy, (Tz)(void*)Vflagname, trZero); sf.pos=8253333; if (((((Vflag).ptr) == NULL) && (ZstringCmp(ZstringSlice(Vflagname, 0, 1, 0), ((Tc*)&YhZb)) == 0))) { sf.pos=8253334; Vflag = ZDictGetIobjDef(YBQy, (Tz)(void*)ZstringSlice(Vflagname, 2, -1, 0), trZero); sf.pos=8253335; if ((((Vflag).ptr) != NULL)) { sf.pos=8253336; if ((Vflag).type == 0) { sf.pos=8253337; Vflagname = ZstringSlice(Vflagname, 2, -1, 0); sf.pos=8253338; Vvalue = ((Tc*)&YhZb); } else { sf.pos=8253339; Vflag = trZero; } } } } else { Ti Vidx; sf.pos=8253340; Vflagname1 = ZstringSlice(Varg, 1, -1, 0); sf.pos=8253341; Vidx = ZstringFindChar(Vflagname1, 61, 0); sf.pos=8253342; if ((Vidx > 0)) { sf.pos=8253343; Vvalue = ZstringSlice(Vflagname1, (Vidx + 1), -1, 0); sf.pos=8253344; Vflagname1 = ZstringSlice(Vflagname1, 0, (Vidx - 1), 0); } else { sf.pos=8253345; while ((ZstringSize(Vflagname1) > 1)) { sf.pos=8253346; Vflag = ZDictGetIobjDef(Y7be, (Tz)(void*)ZstringSlice(Vflagname1, 0, 0, 0), trZero); sf.pos=8253347; if ((((Vflag).ptr) == NULL)) { rt = 2; goto Yy70; } else { sf.pos=8253348; if ((Vflag).type == 0) { sf.pos=8253349; ++((*(Ti*)(Vflag.ptr + (size_t)Vflag.table[5]))); sf.pos=8253351; Vbflag = ((Y86c *)Znio(0, 8253350, (Vflag))); sf.pos=8253352; Vbflag->Vcurrent = !(Vbflag->Vdefault); sf.pos=8253353; Vflagname1 = ZstringSlice(Vflagname1, 1, -1, 0); sf.pos=8253354; Vflag = trZero; } else { sf.pos=8253355; if ((Vflag).type == 3) { rt = 2; goto YuBh; } else { sf.pos=8253356; if ((!(Y_kI) && !((*(Tb*)(Vflag.ptr + (size_t)Vflag.table[7]))))) { sf.pos=8253357; Vvalue = ZstringSlice(Vflagname1, 1, -1, 0); sf.pos=8253358; Vflagname1 = ZstringSlice(Vflagname1, 0, 0, 0); } }} YuBh: if (rt) goto Yy70; } Yy70: if (rt == 2) { rt &= 1; break; } sf.pos=8253359; } } sf.pos=8253360; if ((ZstringSize(Vflagname1) != 1)) { sf.pos=8253361; YSUO(ZcS(((Tc*)&YcW8), Varg)); } else { sf.pos=8253362; if ((((Vflag).ptr) == NULL)) { sf.pos=8253363; Vflag = ZDictGetIobjDef(Y7be, (Tz)(void*)Vflagname1, trZero); } } } sf.pos=8253364; if ((((Vflag).ptr) == NULL)) { sf.pos=8253365; if (!(YUBd)) { sf.pos=8253366; YSUO(ZcS(((Tc*)&Y2hB), Varg)); } } else { sf.pos=8253367; if ((((*(Ti*)(Vflag.ptr + (size_t)Vflag.table[5])) > 0) && !((*(Tb*)(Vflag.ptr + (size_t)Vflag.table[6]))))) { sf.pos=8253368; YSUO(ZcS(((Tc*)&YcLH), Varg)); } sf.pos=8253369; ++((*(Ti*)(Vflag.ptr + (size_t)Vflag.table[5]))); sf.pos=8253370; if ((Vflag).type == 0) { sf.pos=8253372; Vbflag1 = ((Y86c *)Znio(0, 8253371, (Vflag))); sf.pos=8253373; if ((Vvalue != NULL)) { sf.pos=8253374; if (((ZstringCmp(Vvalue, ((Tc*)&YjK7)) == 0) || (ZstringCmp(Vvalue, ((Tc*)&YsfP)) == 0))) { sf.pos=8253375; Vbflag1->Vcurrent = 1; } else { sf.pos=8253376; if (((ZstringCmp(Vvalue, ((Tc*)&YhZb)) == 0) || (ZstringCmp(Vvalue, ((Tc*)&YvpX)) == 0))) { sf.pos=8253377; Vbflag1->Vcurrent = 0; } else { sf.pos=8253378; YSUO(ZcS(((Tc*)&YHSJ), Varg)); } } } else { sf.pos=8253379; Vbflag1->Vcurrent = !(Vbflag1->Vdefault); } } else { sf.pos=8253380; if ((Vflag).type == 3) { sf.pos=8253381; if ((Vvalue != NULL)) { sf.pos=8253382; YSUO(ZcS(((Tc*)&Y6QK), Varg)); } sf.pos=8253384; Vsflag = ((Y_SI *)Znio(3, 8253383, (Vflag))); sf.pos=8253385; Vsflag->Vcurrent = ZnewList((Tt*)&string__T, 0); sf.pos=8253386; { Ti Vj; Tfr Zf7; ZforRangeNew((Vi + 1), (ZListSize(Y1p3) - 1), 0, 1, &Zf7); for (ZforRangeGetInt(&Zf7, &Vj); ZforRangeContInt(&Zf7); ZforRangeNextInt(&Zf7, &Vj)) { sf.pos=8253387; ZLap((Tl*)Vsflag->Vcurrent, (Tz)(void*)((Tc *)ZListGetPtr(Y1p3, Vj))); sf.pos=8253388; } } rt = 2; goto YxuQ; } else { sf.pos=8253389; if ((!((*(Tb*)(Vflag.ptr + (size_t)Vflag.table[8]))) && (Vvalue == NULL))) { sf.pos=8253390; Vskip = 1; sf.pos=8253391; if ((Vi == (ZListSize(Y1p3) - 1))) { sf.pos=8253392; YSUO(ZcS(((Tc*)&Y_ju), Varg)); } sf.pos=8253393; Vvalue = ((Tc *)ZListGetPtr(Y1p3, (Vi + 1))); } sf.pos=8253394; if ((Vflag).type == 1) { sf.pos=8253396; Viflag = ((YJQu *)Znio(1, 8253395, (Vflag))); sf.pos=8253397; if ((Vvalue == NULL)) { sf.pos=8253398; Viflag->Vcurrent = Viflag->Vdefault; sf.pos=8253399; ZLap((Tl*)Viflag->VtheValueList, (Tz)(Ti)Viflag->Vdefault); } else { Ti VintVal; sf.pos=8253400; VintVal = ZstringToInt(Vvalue, 1, 0); sf.pos=8253401; Viflag->Vcurrent = VintVal; sf.pos=8253402; ZLap((Tl*)Viflag->VtheValueList, (Tz)(Ti)VintVal); } } else { sf.pos=8253403; if ((Vflag).type == 2) { sf.pos=8253405; Vsflag1 = ((YzqH *)Znio(2, 8253404, (Vflag))); sf.pos=8253406; if ((Vvalue == NULL)) { sf.pos=8253407; Vsflag1->Vcurrent = Vsflag1->Vdefault; sf.pos=8253408; ZLap((Tl*)Vsflag1->VtheValueList, (Tz)(void*)Vsflag1->Vdefault); } else { sf.pos=8253409; Vsflag1->Vcurrent = Vvalue; sf.pos=8253410; ZLap((Tl*)Vsflag1->VtheValueList, (Tz)(void*)Vvalue); } } else { Tr ex; sf.pos=8253411; *Znao(&ex, YrHq__YwtA__YRHR(NULL, ((Tc*)&YjTs)), YrHq__Ytlm_I_imt, 26); ZthrowIobject(ex); } } } } YxuQ: if (rt) goto YdgD; } YdgD: if (rt) goto YOd6; } YOd6: if (rt) goto YgsM; } YgsM: if (rt == 2) { rt &= 1; break; } if (rt == 4) { rt &= 1; continue; } sf.pos=8253412; } } } topFrame = sf.prev; return; } void YSUO(Tc *Amsg) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=8529500; ((Ts (*)(void*, Tc*))(YeNQ.table[11]))(YeNQ.ptr, Amsg); sf.pos=8529501; if ((Yun4 != NULL)) { sf.pos=8529502; Yl0k(YAMW(Yun4)); } sf.pos=8529503; if (!(YhUP)) { sf.pos=8529504; ((Ts (*)(void*, Tc*))(YeNQ.table[11]))(YeNQ.ptr, ZcS3(((Tc*)&YkFE), YzvW, ((Tc*)&Y15F))); } sf.pos=8529505; Zexit(NULL, 1); topFrame = sf.prev; return; } void Yfj5(Tb Averbose) { Ti VmaxLeadLen; Zsf sf; Td *VallFlags = NULL; Tl *Zf1 = NULL; Tl *Zf2 = NULL; Tc *Vkey = NULL; Tc *VargText = NULL; Tc *Vlead = NULL; Tl *Zf11 = NULL; Tc *Vkey1 = NULL; Tr Vflag = {NULL}; Tr Vflag1 = {NULL}; Tl *t0 = NULL; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=2956000; if ((Yun4 != NULL)) { sf.pos=2956001; Yl0k(YAMW(Yun4)); } sf.pos=2956002; Yl0k(((Tc*)&YaBy)); sf.pos=2956003; VallFlags = Y7be; sf.pos=2956004; { Tfl Zf11i; Zf11 = ZDictKeys(YBQy, 0); Zf11i.l = Zf11; Zf11i.valp = (void*)&Vkey1; Zf11i.i = 0; for (; ZforListPtrCont(&Zf11i); ) { sf.pos=2956005; Vflag = ZDictGetIobj(YBQy, (Tz)(void*)Vkey1); sf.pos=2956006; if (((*(Tc**)(Vflag.ptr + (size_t)Vflag.table[1])) == NULL)) { sf.pos=2956007; *ZDictGetIobjP(VallFlags, (Tz)(void*)(*(Tc**)(Vflag.ptr + (size_t)Vflag.table[2]))) = Vflag; } sf.pos=2956008; } } VmaxLeadLen = 0; sf.pos=2956009; { Ti Vdisplay; Tfl Zf1i; Zf1 = (t0 = ZnewList((Tt*)&bool__T, 2), ZLap((Tl*)t0, (Tz)(Ti)0), ZLap((Tl*)t0, (Tz)(Ti)1)); Zf1i.l = Zf1; Zf1i.valp = (void*)&Vdisplay; Zf1i.i = 0; for (; ZforListIntCont(&Zf1i); ) { sf.pos=2956010; if (Vdisplay) { sf.pos=2956011; YTlu(((Tc*)&YwXF), VmaxLeadLen); sf.pos=2956012; Yl0k(((Tc*)&YEcf)); } sf.pos=2956013; { Tfl Zf2i; Zf2 = ZstringListSort(ZDictKeys(VallFlags, 0), 1); Zf2i.l = Zf2; Zf2i.valp = (void*)&Vkey; Zf2i.i = 0; for (; ZforListPtrCont(&Zf2i); ) { Tb Vopt; sf.pos=2956014; Vflag1 = ZDictGetIobj(VallFlags, (Tz)(void*)Vkey); sf.pos=2956015; VargText = ((Tc*)&Ya); Vopt = 0; sf.pos=2956016; if ((Vflag1).type == 1) { sf.pos=2956017; if (((*(Tc**)(Vflag1.ptr + (size_t)Vflag1.table[4])) == NULL)) { sf.pos=2956018; VargText = ((Tc*)&Yy2p); } else { sf.pos=2956019; VargText = (*(Tc**)(Vflag1.ptr + (size_t)Vflag1.table[4])); } sf.pos=2956020; Vopt = (*(Tb*)(Vflag1.ptr + (size_t)Vflag1.table[8])); } else { sf.pos=2956021; if ((Vflag1).type == 2) { sf.pos=2956022; if (((*(Tc**)(Vflag1.ptr + (size_t)Vflag1.table[4])) == NULL)) { sf.pos=2956023; VargText = ((Tc*)&YanE); } else { sf.pos=2956024; VargText = (*(Tc**)(Vflag1.ptr + (size_t)Vflag1.table[4])); } sf.pos=2956025; Vopt = (*(Tb*)(Vflag1.ptr + (size_t)Vflag1.table[8])); } else { sf.pos=2956026; if ((Vflag1).type == 3) { sf.pos=2956027; if (((*(Tc**)(Vflag1.ptr + (size_t)Vflag1.table[4])) == NULL)) { sf.pos=2956028; VargText = ((Tc*)&YDci); } else { sf.pos=2956029; VargText = ZcS((*(Tc**)(Vflag1.ptr + (size_t)Vflag1.table[4])), ((Tc*)&YulU)); } sf.pos=2956030; Vopt = 1; } }} sf.pos=2956031; if ((ZbyteStringSize(VargText) != 0)) { sf.pos=2956032; if (Vopt) { sf.pos=2956033; VargText = ZcS3(((Tc*)&YVZ), VargText, ((Tc*)&YEa)); } else { sf.pos=2956034; VargText = ZcS3(((Tc*)&Yq_), VargText, ((Tc*)&Y9a)); } } sf.pos=2956035; Vlead = ((Tc*)&Ya); sf.pos=2956036; if (((*(Tc**)(Vflag1.ptr + (size_t)Vflag1.table[1])) != NULL)) { sf.pos=2956037; Vlead = ZcS5(((Tc*)&YT), (*(Tc**)(Vflag1.ptr + (size_t)Vflag1.table[1])), VargText, ((Tc*)&YG), (Tc*)1); } sf.pos=2956038; if (((*(Tc**)(Vflag1.ptr + (size_t)Vflag1.table[2])) != NULL)) { sf.pos=2956039; if (((ZbyteStringSize(Vlead) != 0) && (ZbyteStringSize(VargText) != 0))) { sf.pos=2956040; if (Vdisplay) { sf.pos=2956041; if ((*(Tb*)(Vflag1.ptr + (size_t)Vflag1.table[6]))) { sf.pos=2956042; Vlead = ZcS(Vlead, ((Tc*)&Y_y2)); } sf.pos=2956043; Yl0k(Vlead); } sf.pos=2956044; Vlead = ((Tc*)&Ya); } sf.pos=2956045; Vlead = ZcS(Vlead, ZcS5(((Tc*)&Y1ia), (*(Tc**)(Vflag1.ptr + (size_t)Vflag1.table[2])), VargText, ((Tc*)&YG), (Tc*)1)); } sf.pos=2956046; if ((*(Tb*)(Vflag1.ptr + (size_t)Vflag1.table[6]))) { sf.pos=2956047; Vlead = ZcS(Vlead, ((Tc*)&Y2yA)); } sf.pos=2956048; if (Vdisplay) { sf.pos=2956049; if (((*(Tc**)(Vflag1.ptr + (size_t)Vflag1.table[3])) != NULL)) { sf.pos=2956050; YTlu(Vlead, VmaxLeadLen); sf.pos=2956051; Yl0k((*(Tc**)(Vflag1.ptr + (size_t)Vflag1.table[3]))); } else { sf.pos=2956052; Yl0k(Vlead); } sf.pos=2956053; if (Averbose) { sf.pos=2956054; YTlu(((Tc*)&Ya), VmaxLeadLen); sf.pos=2956055; Yl0k(ZcS(((Tc*)&Ym4c), YpI_((*(YkxB**)(Vflag1.ptr + (size_t)Vflag1.table[9]))))); } } else { sf.pos=2956056; if ((VmaxLeadLen < ZstringSize(Vlead))) { sf.pos=2956057; VmaxLeadLen = ZstringSize(Vlead); } sf.pos=2956058; if ((VmaxLeadLen > 30)) { sf.pos=2956059; VmaxLeadLen = 30; rt = 2; goto YAEw; } YAEw: if (rt) goto Yfan; } Yfan: if (rt == 2) { rt &= 1; break; } sf.pos=2956060; } } sf.pos=2956061; } } sf.pos=2956062; Zexit(NULL, YMLU); topFrame = sf.prev; return; } void YTlu(Tc *Alead, Ti AmaxLeadLen) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=8179800; Yvcu(Alead); sf.pos=8179801; { Ti Vi; Tfr Zf1; ZforRangeNew(ZstringSize(Alead), AmaxLeadLen, 0, 1, &Zf1); for (ZforRangeGetInt(&Zf1, &Vi); ZforRangeContInt(&Zf1); ZforRangeNextInt(&Zf1, &Vi)) { sf.pos=8179802; Yvcu(((Tc*)&YG)); sf.pos=8179803; } } topFrame = sf.prev; return; } Tc *YAMW(YuMQ *t) { Ti Vidx; Zsf sf; Tc *r = 0; Tc *t0 = NULL; Tc *t1 = NULL; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=4300000; ZthrowThisNil(); } sf.pos=4300001; Vidx = ZstringFind(t->Vtext, ((Tc*)&YMtG), 0); sf.pos=4300002; if ((Vidx < 0)) { sf.pos=4300003; r = t->Vtext; rt = 1; goto YZtK; } sf.pos=4300004; r = ZcS3(ZstringSlice(t->Vtext, 0, (Vidx - 1), 0), YzvW, (t0 = ZstringSlice(t->Vtext, (Vidx + 3), -1, 0))); YZtK: topFrame = sf.prev; return r; } To ToYuMQ[] = { {1, 0}, {0, (Tt*)&string__T}, /* text */ }; Tto YuMQ__T = {390, (Tc*)&Y6qT, 0, ToYuMQ}; Y86c *YttT(Y86c *t, Tc *AshortName, Tc *AlongName, Tb Adefault, Tc *Adoc) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=327300; t = Za(sizeof(Y86c));} sf.pos=327301; Y86c__YcLu(t, AshortName, AlongName, Adoc, MZ__callerPos()); sf.pos=327302; t->Vcurrent = Adefault; sf.pos=327303; t->Vdefault = Adefault; sf.pos=327304; t->VcanRepeat = 1; topFrame = sf.prev; return t; } void YEqoa(Y86c *t) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=3891100; ZthrowThisNil(); } sf.pos=3891101; t->Vcurrent = t->Vdefault; topFrame = sf.prev; return; } Tb YHoR(Y86c *t) { Tb r = 0; if (t == NULL) { ZthrowThisNil(); } YY8i(); r = t->Vcurrent; return r; } Tb YuOS(Y86c *t) { Zsf sf; Tb r = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=6128400; ZthrowThisNil(); } sf.pos=6128401; r = YHoR(t); topFrame = sf.prev; return r; } Y86c *Y86c__YcLu(Y86c *t, Tc *AshortName, Tc *AlongName, Tc *Adoc, YkxB *Apos) { Zsf sf; Tr t0 = {NULL}; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=7664400; t = Za(sizeof(Y86c));} sf.pos=7664401; if ((Y6fX != NULL)) { Tr ex; sf.pos=7664402; *Znao(&ex, YVNj__YwtA__YRHR(NULL, ((Tc*)&Yc_h)), YVNj__Ytlm_I_imt, 7); ZthrowIobject(ex); } sf.pos=7664403; if (((((AshortName == NULL) || (ZbyteStringSize(AshortName) == 0))) && (((AlongName == NULL) || (ZbyteStringSize(AlongName) == 0))))) { Tr ex; sf.pos=7664404; *Znao(&ex, YVNj__YwtA__YRHR(NULL, ((Tc*)&Y6pY)), YVNj__Ytlm_I_imt, 7); ZthrowIobject(ex); } sf.pos=7664405; if ((ZbyteStringSize(AshortName) != 0)) { sf.pos=7664406; t->VshortName = AshortName; } sf.pos=7664407; if ((ZbyteStringSize(AlongName) != 0)) { sf.pos=7664408; t->VlongName = AlongName; } sf.pos=7664409; t->Vdoc = Adoc; sf.pos=7664410; if ((Y7be == NULL)) { sf.pos=7664411; Y7be = ZnewDict((Tt*)&string__T, (Tt*)&iobj__T, 0); sf.pos=7664412; YBQy = ZnewDict((Tt*)&string__T, (Tt*)&iobj__T, 0); } sf.pos=7664413; if (((AlongName != NULL) && (ZbyteStringSize(AlongName) != 0))) { sf.pos=7664414; if (ZDictHas(YBQy, (Tz)(void*)AlongName)) { sf.pos=7664415; Y86c__YofP(t, AlongName, ZDictGetIobj(YBQy, (Tz)(void*)AlongName), Apos); } sf.pos=7664416; ZDictAddTzIobj(0, YBQy, (Tz)(void*)AlongName, *Znao(&t0, t, Y86c__YuQR_I_imt, 0)); } sf.pos=7664417; if (((AshortName != NULL) && (ZbyteStringSize(AshortName) != 0))) { sf.pos=7664418; if ((ZstringSize(AshortName) > 1)) { Tr ex; sf.pos=7664419; *Znao(&ex, YVNj__YwtA__YRHR(NULL, ((Tc*)&Y9CP)), YVNj__Ytlm_I_imt, 7); ZthrowIobject(ex); } sf.pos=7664420; if (ZDictHas(Y7be, (Tz)(void*)AshortName)) { sf.pos=7664421; Y86c__YofP(t, AshortName, ZDictGetIobj(Y7be, (Tz)(void*)AshortName), Apos); } sf.pos=7664422; ZDictAddTzIobj(0, Y7be, (Tz)(void*)AshortName, *Znao(&t0, t, Y86c__YuQR_I_imt, 0)); } sf.pos=7664423; t->Vpos = Apos; topFrame = sf.prev; return t; } void Y86c__YofP(Y86c *t, Tc *Aname, Tr Aflag, YkxB *Apos) { void *Y_CE = NULL; void *p1; Tr ex; Zsf sf; Tc *VonePos = NULL; YVNj *Ve = 0; Tr t0 = {NULL}; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=7569700; ZthrowThisNil(); } sf.pos=7569701; VonePos = ((p1 = ((Y_CE = (*(YkxB**)(Aflag.ptr + (size_t)Aflag.table[9])), Y_CE == NULL ? NULL : YpI_(Y_CE)))) == NULL ? (((Tc*)&YbbH)) : p1); sf.pos=7569702; Ve = YVNj__YwtA__YRHRa(NULL, Apos, ZcS5(((Tc*)&YtzG), Aname, ((Tc*)&YDyy), VonePos, (Tc*)1)); sf.pos=7569703; *Znao(&ex, Ve, YVNj__Ytlm_I_imt, 7); ZthrowIobject(ex); } Ti Y86c__Ye9f(Y86c *t) { Ti r = 0; if (t == NULL) { ZthrowThisNil(); } YY8i(); r = t->VsetCount; return r; } Tc *Y86c__YuQR_I_imt[] = { (Tc*)&Y86c__T, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)0, (Tc*)Y86c__YcLu, /* MARGModule__CBool.NEW - Y86c__YcLu */ (Tc*)Y86c__YofP, /* MARGModule__CBool.throwDuplicate - Y86c__YofP */ (Tc*)0, /* MARGModule__CBool.setArgName - Y86c__Y836 */ (Tc*)0, /* MARGModule__CBool.disableCompact - Y86c__YJbb */ (Tc*)0, /* MARGModule__CBool.optionalArg - Y86c__YxuH */ (Tc*)Y86c__Ye9f, /* MARGModule__CBool.presentCount - Y86c__Ye9f */ (Tc*)0, /* MARGModule__CBool.present - Y86c__Y8Dq */ (Tc*)YEqoa, /* MARGModule__CBool.setToDefault - YEqoa */ (Tc*)0, /* Init - Y86ca */ }; To ToY86c[] = { {5, 0}, {0, (Tt*)&string__T}, /* shortName */ {0, (Tt*)&string__T}, /* longName */ {0, (Tt*)&string__T}, /* doc */ {0, (Tt*)&string__T}, /* argName */ {0, (Tt*)&YkxB__T}, /* pos */ }; Tto Y86c__T = {390, (Tc*)&YZ1F, 0, ToY86c}; void Y49ga(YJQu *t) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=1635000; ZthrowThisNil(); } sf.pos=1635001; t->Vcurrent = t->Vdefault; topFrame = sf.prev; return; } To ToYJQu[] = { {6, 0}, {0, (Tt*)&list__T}, /* theValueList */ {0, (Tt*)&string__T}, /* shortName */ {0, (Tt*)&string__T}, /* longName */ {0, (Tt*)&string__T}, /* doc */ {0, (Tt*)&string__T}, /* argName */ {0, (Tt*)&YkxB__T}, /* pos */ }; Tto YJQu__T = {390, (Tc*)&YzBa, 0, ToYJQu}; void YJaza(YzqH *t) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=8620600; ZthrowThisNil(); } sf.pos=8620601; t->Vcurrent = t->Vdefault; topFrame = sf.prev; return; } To ToYzqH[] = { {8, 0}, {0, (Tt*)&string__T}, /* current */ {0, (Tt*)&string__T}, /* default */ {0, (Tt*)&list__T}, /* theValueList */ {0, (Tt*)&string__T}, /* shortName */ {0, (Tt*)&string__T}, /* longName */ {0, (Tt*)&string__T}, /* doc */ {0, (Tt*)&string__T}, /* argName */ {0, (Tt*)&YkxB__T}, /* pos */ }; Tto YzqH__T = {390, (Tc*)&YDAE, 0, ToYzqH}; void YSkKa(Y_SI *t) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=6447800; ZthrowThisNil(); } sf.pos=6447801; t->Vcurrent = t->Vdefault; topFrame = sf.prev; return; } To ToY_SI[] = { {7, 0}, {0, (Tt*)&list__T}, /* current */ {0, (Tt*)&list__T}, /* default */ {0, (Tt*)&string__T}, /* shortName */ {0, (Tt*)&string__T}, /* longName */ {0, (Tt*)&string__T}, /* doc */ {0, (Tt*)&string__T}, /* argName */ {0, (Tt*)&YkxB__T}, /* pos */ }; Tto Y_SI__T = {390, (Tc*)&Ygf5, 0, ToY_SI}; int JARGModule(int round) { static int round_done = -1; int done = 1; if (round_done < round) { Zsf sf; sf.prev = topFrame; sf.pos = 0; sf.frof = NULL; topFrame = &sf; round_done = round; if (round == 0) { done = 0; } else if (round > 2001) { if (Ytu___r == 0) { Ytu___r = Ytu_(); done &= Ytu___r; } } topFrame = sf.prev; } return done; } /* ARGModule done */ /* including ParseProto bodies */ /* including EnumItem bodies */ Y2Kp *YIur(Y2Kp *t) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=5812100; t = Za(sizeof(Y2Kp));} sf.pos=5812101; t->Vmembers = ZnewList((Tt*)&YFk1__T, 0); topFrame = sf.prev; return t; } void Y_Nc(Y2Kp *t, Tc *Aname, Ti Anr, YkxB *Apos) { Zsf sf; YFk1 *Vv = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=8914100; ZthrowThisNil(); } sf.pos=8914101; Vv = Za(sizeof(YFk1)); sf.pos=8914102; Vv->Vid = Aname; sf.pos=8914103; Vv->Vnr = Anr; sf.pos=8914104; Vv->Vpos = Apos; sf.pos=8914105; ZLap((Tl*)t->Vmembers, (Tz)(void*)Vv); topFrame = sf.prev; return; } To ToYFk1[] = { {2, 0}, {0, (Tt*)&string__T}, /* id */ {0, (Tt*)&YkxB__T}, /* pos */ }; Tto YFk1__T = {390, (Tc*)&YmNk, 0, ToYFk1}; Ts YXXO(Y2Kp *t) { Ts Vret; Zsf sf; Ts r = 0; Tl *Zf1 = NULL; Yhqr *Vused = 0; YFk1 *Vm = 0; YkxB *t0 = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=4019000; ZthrowThisNil(); } sf.pos=4019001; Vused = Yh95(NULL); sf.pos=4019002; Vret = 1; sf.pos=4019003; { Tfl Zf1i; Zf1 = t->Vmembers; Zf1i.l = Zf1; Zf1i.valp = (void*)&Vm; Zf1i.i = 0; for (; ZforListPtrCont(&Zf1i); ) { sf.pos=4019004; if (YyHa(Vused, Vm->Vnr)) { sf.pos=4019005; YDli(ZcS(((Tc*)&Y_xt), Zint2string(Vm->Vnr)), (t0 = Vm->Vpos), 0); sf.pos=4019006; Vret = 0; } else { sf.pos=4019007; YGMT(Vused, Vm->Vnr); } sf.pos=4019008; } } sf.pos=4019009; r = Vret; topFrame = sf.prev; return r; } Tc *Y2Kp__YuXI_imt[] = { (Tc*)&Y2Kp__T, (Tc*)0, }; To ToY2Kp[] = { {2, 0}, {0, (Tt*)&string__T}, /* name */ {0, (Tt*)&list__T}, /* members */ }; Tto Y2Kp__T = {390, (Tc*)&Ym3J, 0, ToY2Kp}; /* EnumItem done */ /* including MessageItem bodies */ /* including FieldItem bodies */ Tc *YULH(Y0uC *t) { Zsf sf; Tc *r = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=3628300; ZthrowThisNil(); } sf.pos=3628301; r = ZcS(((Tc*)&YliF), t->Vname); topFrame = sf.prev; return r; } Tc *YFlx(Y0uC *t) { Zsf sf; Tc *r = 0; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=6079100; ZthrowThisNil(); } sf.pos=6079101; if (!(t->Vrepeated)) { sf.pos=6079102; switch (t->Vtype) { case 9: case 10: case 18: case 11: case 19: case 6: case 7: { sf.pos=6079103; r = ZcS(((Tc*)&YZYy), t->Vname); rt = 1; goto YCIv; } YCIv: if (rt) goto YTdB; } YTdB: if (rt) goto YrvEa; } sf.pos=6079104; r = NULL; YrvEa: topFrame = sf.prev; return r; } Tc *YqGL(Y0uC *t) { Zsf sf; Tc *r = 0; Tc *t0 = NULL; Tc *t1 = NULL; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=257100; ZthrowThisNil(); } sf.pos=257101; r = ZcS((t1 = ZstringToUpper(ZstringSlice(t->Vname, 0, 0, 0))), (t0 = ZstringSlice(t->Vname, 1, -1, 0))); topFrame = sf.prev; return r; } Te YKJX(Tc *AtypeName) { Zsf sf; Te r = 0; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=1977200; if (ZDictHas(YGNu, (Tz)(void*)AtypeName)) { sf.pos=1977201; r = ZDictGetInt(YGNu, (Tz)(void*)AtypeName); rt = 1; goto Yxgy; } sf.pos=1977202; r = 0; Yxgy: topFrame = sf.prev; return r; } To ToY0uC[] = { {4, 0}, {0, (Tt*)&string__T}, /* name */ {0, (Tt*)&string__T}, /* typeName */ {0, (Tt*)&string__T}, /* default */ {0, (Tt*)&YkxB__T}, /* pos */ }; Tto Y0uC__T = {390, (Tc*)&Y5D2a, 0, ToY0uC}; int JFieldItem(int round) { static int round_done = -1; int done = 1; if (round_done < round) { Zsf sf; sf.prev = topFrame; sf.pos = 0; sf.frof = NULL; topFrame = &sf; round_done = round; if (round == 2001) { sf.pos=9018300; YGNu = ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZnewDict((Tt*)&string__T, (Tt*)&MProto__EType__T, 0), (Tz)(void*)((Tc*)&YanE), (Tz)(Ti)17), (Tz)(void*)((Tc*)&Y1Qt), (Tz)(Ti)9), (Tz)(void*)((Tc*)&YrQi), (Tz)(Ti)10), (Tz)(void*)((Tc*)&YJyN), (Tz)(Ti)18), (Tz)(void*)((Tc*)&YhVi), (Tz)(Ti)11), (Tz)(void*)((Tc*)&YzDN), (Tz)(Ti)19), (Tz)(void*)((Tc*)&Yt7n), (Tz)(Ti)6), (Tz)(void*)((Tc*)&Ygep), (Tz)(Ti)7), (Tz)(void*)((Tc*)&YtPw), (Tz)(Ti)1); } topFrame = sf.prev; } return done; } /* FieldItem done */ /* including OptionItem bodies */ /* including PToken bodies */ To ToYkeq[] = { {3, 0}, {0, (Tt*)&string__T}, /* value */ {0, (Tt*)&YkxB__T}, /* startPos */ {0, (Tt*)&YkxB__T}, /* endPos */ }; Tto Ykeq__T = {390, (Tc*)&YgVD, 0, ToYkeq}; /* PToken done */ To ToYswy[] = { {3, 0}, {0, (Tt*)&string__T}, /* name */ {0, (Tt*)&YkxB__T}, /* pos */ {0, (Tt*)&string__T}, /* value */ }; Tto Yswy__T = {390, (Tc*)&YcBr, 0, ToYswy}; /* OptionItem done */ YRAB *YI6R(YRAB *t) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=3921300; t = Za(sizeof(YRAB));} sf.pos=3921301; t->Vfields = ZnewList((Tt*)&Y0uC__T, 0); sf.pos=3921302; t->Vitems = ZnewList((Tt*)&iobj__T, 0); sf.pos=3921303; t->VoptionList = ZnewList((Tt*)&Yswy__T, 0); topFrame = sf.prev; return t; } void YNVJ(YRAB *t, Yswy *Aoption) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=244900; ZthrowThisNil(); } sf.pos=244901; if ((ZstringCmp(Aoption->Vname, ((Tc*)&YLP5)) == 0)) { sf.pos=244902; ZLap((Tl*)t->VoptionList, (Tz)(void*)Aoption); } topFrame = sf.prev; return; } Tr YBZe(YRAB *t, Tc *Aname) { Zsf sf; Tr r = {NULL}; Tl *Zf1 = NULL; Tr Vitem = {NULL}; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=167900; ZthrowThisNil(); } sf.pos=167901; { Tfl Zf1i; Zf1 = t->Vitems; Zf1i.l = Zf1; Zf1i.valp = (void*)&Vitem; Zf1i.i = 0; for (; ZforListIobjCont(&Zf1i); ) { sf.pos=167902; if ((ZstringCmp((*(Tc**)(Vitem.ptr + (size_t)Vitem.table[1])), Aname) == 0)) { sf.pos=167903; r = Vitem; rt = 1; goto YT0Y; } YT0Y: if (rt) goto YPos; sf.pos=167904; } } sf.pos=167905; if ((((t->Vparent).ptr) != NULL)) { sf.pos=167906; r = ((Tr (*)(void*, Tc*))(t->Vparent.table[1]))(t->Vparent.ptr, Aname); rt = 1; goto YPos; } sf.pos=167907; r = trZero; YPos: topFrame = sf.prev; return r; } Ts YbaL(YRAB *t) { Ts Vret; Zsf sf; Ts r = 0; Tl *Zf1 = NULL; Y0uC *Vf = 0; Yhqr *VusedNr = 0; Ygqr *VusedName = 0; YkxB *t0 = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=3990600; ZthrowThisNil(); } sf.pos=3990601; VusedNr = Yh95(NULL); sf.pos=3990602; VusedName = YGrg(NULL); sf.pos=3990603; Vret = 1; sf.pos=3990604; { Tfl Zf1i; Zf1 = t->Vfields; Zf1i.l = Zf1; Zf1i.valp = (void*)&Vf; Zf1i.i = 0; for (; ZforListPtrCont(&Zf1i); ) { sf.pos=3990605; if (YyHa(VusedNr, Vf->Vnr)) { sf.pos=3990606; YDli(ZcS(((Tc*)&YUra), Zint2string(Vf->Vnr)), (t0 = Vf->Vpos), 0); sf.pos=3990607; Vret = 0; } else { sf.pos=3990608; if (YXZk(VusedName, Vf->Vname)) { sf.pos=3990609; YDli(ZcS(((Tc*)&Yy3i), Vf->Vname), (t0 = Vf->Vpos), 0); sf.pos=3990610; Vret = 0; } else { sf.pos=3990611; YGMT(VusedNr, Vf->Vnr); sf.pos=3990612; Y432(VusedName, Vf->Vname); } } sf.pos=3990613; } } sf.pos=3990614; r = Vret; topFrame = sf.prev; return r; } Tc *YRAB__YuXI_imt[] = { (Tc*)&YRAB__T, (Tc*)0, }; Tc *YRAB__Ytv2_imt[] = { (Tc*)&YRAB__T, (Tc*)YBZe, /* CMessageItem.findItem - YBZe */ }; To ToYRAB[] = { {5, 0}, {0, (Tt*)&iobj__T}, /* parent */ {0, (Tt*)&string__T}, /* name */ {0, (Tt*)&list__T}, /* fields */ {0, (Tt*)&list__T}, /* items */ {0, (Tt*)&list__T}, /* optionList */ }; Tto YRAB__T = {390, (Tc*)&YQoy, 0, ToYRAB}; int JMessageItem(int round) { static int round_done = -1; int done = 1; if (round_done < round) { Zsf sf; sf.prev = topFrame; sf.pos = 0; sf.frof = NULL; topFrame = &sf; round_done = round; done &= JFieldItem(round); if (round == 2001) { } topFrame = sf.prev; } return done; } /* MessageItem done */ /* including ProtoFile bodies */ YP_l *Yy3W(YP_l *t) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=3572100; t = Za(sizeof(YP_l));} sf.pos=3572101; t->VitemList = ZnewList((Tt*)&iobj__T, 0); sf.pos=3572102; t->VitemDict = ZnewDict((Tt*)&string__T, (Tt*)&iobj__T, 0); sf.pos=3572103; t->Vimports = ZnewList((Tt*)&YP_l__T, 0); topFrame = sf.prev; return t; } void YhB6(YP_l *t, Tr Aitem) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=353100; ZthrowThisNil(); } sf.pos=353101; if (((*(Tc**)(Aitem.ptr + (size_t)Aitem.table[1])) != NULL)) { sf.pos=353102; ZLapIobj((Tl*)t->VitemList, Aitem); sf.pos=353103; ZDictAddTzIobj(0, t->VitemDict, (Tz)(void*)(*(Tc**)(Aitem.ptr + (size_t)Aitem.table[1])), Aitem); } topFrame = sf.prev; return; } void YYPi(YP_l *t, Yswy *Aoption) { } Tr YKwR(YP_l *t, Tc *Aname) { Zsf sf; Tr r = {NULL}; Tl *Zf1 = NULL; Tr Vitem = {NULL}; Tl *Zf11 = NULL; YP_l *Vimport = 0; Tr Vitem1 = {NULL}; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=3881100; ZthrowThisNil(); } sf.pos=3881101; { Tfl Zf1i; Zf1 = t->VitemList; Zf1i.l = Zf1; Zf1i.valp = (void*)&Vitem; Zf1i.i = 0; for (; ZforListIobjCont(&Zf1i); ) { sf.pos=3881102; if ((ZstringCmp((*(Tc**)(Vitem.ptr + (size_t)Vitem.table[1])), Aname) == 0)) { sf.pos=3881103; r = Vitem; rt = 1; goto YGnf; } YGnf: if (rt) goto YjkG; sf.pos=3881104; } } sf.pos=3881105; { Tfl Zf11i; Zf11 = t->Vimports; Zf11i.l = Zf11; Zf11i.valp = (void*)&Vimport; Zf11i.i = 0; for (; ZforListPtrCont(&Zf11i); ) { sf.pos=3881106; Vitem1 = YKwR(Vimport, Aname); sf.pos=3881107; if ((((Vitem1).ptr) != NULL)) { sf.pos=3881108; r = Vitem1; rt = 1; goto Y3Qy; } Y3Qy: if (rt) goto YjkG; sf.pos=3881109; } } sf.pos=3881110; r = trZero; YjkG: topFrame = sf.prev; return r; } Tc *YP_l__Ytv2_imt[] = { (Tc*)&YP_l__T, (Tc*)YKwR, /* CProtoFile.findItem - YKwR */ }; To ToYP_l[] = { {4, 0}, {0, (Tt*)&string__T}, /* package */ {0, (Tt*)&list__T}, /* imports */ {0, (Tt*)&list__T}, /* itemList */ {0, (Tt*)&dict__T}, /* itemDict */ }; Tto YP_l__T = {390, (Tc*)&YU8M, 0, ToYP_l}; /* ProtoFile done */ /* including ServiceItem bodies */ /* including RpcItem bodies */ YlM3 *YwLI(YlM3 *t, Tc *Aname) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=5727300; t = Za(sizeof(YlM3));} sf.pos=5727301; t->Vname = Aname; topFrame = sf.prev; return t; } Tc *YlM3__YuXI_imt[] = { (Tc*)&YlM3__T, (Tc*)0, }; To ToYlM3[] = { {3, 0}, {0, (Tt*)&string__T}, /* name */ {0, (Tt*)&string__T}, /* requestName */ {0, (Tt*)&string__T}, /* responseName */ }; Tto YlM3__T = {390, (Tc*)&YWB_, 0, ToYlM3}; /* RpcItem done */ YNW5 *Y_oR(YNW5 *t) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=3638100; t = Za(sizeof(YNW5));} sf.pos=3638101; t->Vrpcs = ZnewList((Tt*)&YlM3__T, 0); topFrame = sf.prev; return t; } void YBM3(YNW5 *t, YlM3 *Arpc) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=5594400; ZthrowThisNil(); } sf.pos=5594401; ZLap((Tl*)t->Vrpcs, (Tz)(void*)Arpc); topFrame = sf.prev; return; } Tr Y96y(YNW5 *t, Tc *Aname) { Zsf sf; Tr r = {NULL}; Tl *Zf1 = NULL; YlM3 *Vrpc = 0; Tr t0 = {NULL}; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=6633500; ZthrowThisNil(); } sf.pos=6633501; { Tfl Zf1i; Zf1 = t->Vrpcs; Zf1i.l = Zf1; Zf1i.valp = (void*)&Vrpc; Zf1i.i = 0; for (; ZforListPtrCont(&Zf1i); ) { sf.pos=6633502; if ((ZstringCmp(Vrpc->Vname, Aname) == 0)) { sf.pos=6633503; r = *Znao(&t0, Vrpc, YlM3__YuXI_imt, 3); rt = 1; goto YiOk; } YiOk: if (rt) goto Y6AE; sf.pos=6633504; } } sf.pos=6633505; r = trZero; Y6AE: topFrame = sf.prev; return r; } Tc *YNW5__YuXI_imt[] = { (Tc*)&YNW5__T, (Tc*)0, }; To ToYNW5[] = { {2, 0}, {0, (Tt*)&string__T}, /* name */ {0, (Tt*)&list__T}, /* rpcs */ }; Tto YNW5__T = {390, (Tc*)&YMK2, 0, ToYNW5}; /* ServiceItem done */ /* including PTokenInput bodies */ /* including Input bodies */ YeYq *YOdr(YeYq *t, Tr Afd, Tc *Afname, Tc *Aindent, Tb Arecord) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=4440100; t = Za(sizeof(YeYq));} sf.pos=4440101; t->Vfd = Afd; sf.pos=4440102; t->Vpos = Ypp_(NULL, Afname); sf.pos=4440103; t->VcharStack = ZnewList((Tt*)&int__T, 0); sf.pos=4440104; t->Vindent = Aindent; sf.pos=4440105; if (Arecord) { sf.pos=4440106; t->VrecordWriter = Za(sizeof(YjUM)); } topFrame = sf.prev; return t; } Ti YAit(YeYq *t) { Ti Vc; Zsf sf; Ti r = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=1988700; ZthrowThisNil(); } Vc = 0; sf.pos=1988701; if ((ZListSize(t->VcharStack) > 0)) { sf.pos=1988702; Vc = ZListRemoveIntItem((Tl*)t->VcharStack, -1); sf.pos=1988703; ++(t->Vpos->Vcol); } else { sf.pos=1988704; if ((((t->Vfd).ptr) == NULL)) { sf.pos=1988705; if ((t->VtextIdx >= ZstringSize(t->Vtext))) { sf.pos=1988706; Vc = Y3QJ; } else { sf.pos=1988707; Vc = ZstringGetChar(t->Vtext, t->VtextIdx); sf.pos=1988708; ++(t->VtextIdx); sf.pos=1988709; ++(t->Vpos->Vcol); } } else { sf.pos=1988710; for (;;) { sf.pos=1988711; Vc = ((Ti (*)(void*))(t->Vfd.table[23]))(t->Vfd.ptr); sf.pos=1988712; ++(t->Vpos->Vcol); sf.pos=1988713; if (((((Vc >= 0) && (Vc <= 31))) || (((Vc >= 127) && (Vc <= 160))))) { sf.pos=1988714; if ((Vc == 0)) { sf.pos=1988715; YDli(((Tc*)&YrKy), t->Vpos, 0); sf.pos=1988716; Vc = 32; } else { sf.pos=1988717; if ((Vc == 9)) { sf.pos=1988718; if (!(t->VallowTabs)) { sf.pos=1988719; YDli(((Tc*)&YemR), t->Vpos, 0); } sf.pos=1988720; Vc = 32; } else { sf.pos=1988721; if (((Vc != 13) && (Vc != 10))) { sf.pos=1988722; YDli(((Tc*)&Y3Pw), t->Vpos, 0); sf.pos=1988723; Vc = 32; } }} } sf.pos=1988724; if (((Vc != 13) && (Vc != 65279))) break; sf.pos=1988725; } } } sf.pos=1988726; if ((Vc == 10)) { sf.pos=1988727; t->VprevLineCol = t->Vpos->Vcol; sf.pos=1988728; YnS4(t->Vpos); } sf.pos=1988729; if (((t->VrecordWriter != NULL) && (Vc != Y3QJ))) { sf.pos=1988730; YjUM__Ydti(t->VrecordWriter, Vc); } sf.pos=1988731; r = Vc; topFrame = sf.prev; return r; } void YmK2(YeYq *t, Ti Ac) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=3404700; ZthrowThisNil(); } sf.pos=3404701; if ((Ac != Y3QJ)) { sf.pos=3404702; ZLap((Tl*)t->VcharStack, (Tz)(Ti)Ac); sf.pos=3404703; if ((Ac == 10)) { sf.pos=3404704; t->Vpos->Vcol = t->VprevLineCol; sf.pos=3404705; --(t->Vpos->Vlnum); } else { sf.pos=3404706; --(t->Vpos->Vcol); } sf.pos=3404707; if ((t->VrecordWriter != NULL)) { sf.pos=3404708; Y6jW(t->VrecordWriter); } } topFrame = sf.prev; return; } To ToYeYq[] = { {6, 0}, {0, (Tt*)&iobj__T}, /* fd */ {0, (Tt*)&string__T}, /* text */ {0, (Tt*)&YkxB__T}, /* pos */ {0, (Tt*)&list__T}, /* charStack */ {0, (Tt*)&string__T}, /* indent */ {0, (Tt*)&YjUM__T}, /* recordWriter */ }; Tto YeYq__T = {390, (Tc*)&YVUW, 0, ToYeYq}; /* Input done */ /* including PTokenize bodies */ Ykeq *Y7Z3(YuI4 *Ain) { Ti Vc; Zsf sf; Ykeq *r = 0; Ykeq *Vres = 0; YjUM *Vwriter = 0; YkxB *t0 = 0; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=6302400; Vres = Za(sizeof(Ykeq)); sf.pos=6302401; Vres->VstartPos = Y83A(Ain->Vinput->Vpos); sf.pos=6302402; YVn_(Ain); sf.pos=6302403; Vres->VstartPos = Y83A(Ain->Vinput->Vpos); sf.pos=6302404; Vwriter = Za(sizeof(YjUM)); sf.pos=6302405; Vc = YIaq(Ain); sf.pos=6302406; if ((Vc != Y3QJ)) { sf.pos=6302407; YjUM__Ydti(Vwriter, Vc); } sf.pos=6302408; switch (Vc) { case Y3QJ: { sf.pos=6302409; Vres->Vtype = 25; break; } case 59: { sf.pos=6302410; Vres->Vtype = 17; break; } case 61: { sf.pos=6302411; Vres->Vtype = 18; break; } case 40: { sf.pos=6302412; Vres->Vtype = 19; break; } case 41: { sf.pos=6302413; Vres->Vtype = 20; break; } case 123: { sf.pos=6302414; Vres->Vtype = 21; break; } case 125: { sf.pos=6302415; Vres->Vtype = 22; break; } case 91: { sf.pos=6302416; Vres->Vtype = 23; break; } case 93: { sf.pos=6302417; Vres->Vtype = 24; break; } case 34: { Ti Vi; sf.pos=6302418; Y6jW(Vwriter); sf.pos=6302419; Vres->Vtype = 16; Vi = 0; sf.pos=6302420; while (1) { sf.pos=6302421; Vc = YIaq(Ain); sf.pos=6302422; if ((Vc == 34)) { rt = 2; goto YBCw; } sf.pos=6302423; if (((Vc == 10) || (Vc == Y3QJ))) { sf.pos=6302424; YCer(Ain, Vc); sf.pos=6302425; YDli(((Tc*)&YD4M), Vres->VstartPos, 0); rt = 2; goto YBCw; } sf.pos=6302426; if ((Vc == 92)) { sf.pos=6302427; Vc = YIaq(Ain); sf.pos=6302428; if (((Vc == 10) || (Vc == Y3QJ))) { sf.pos=6302429; YDli(((Tc*)&YD4M), Vres->VstartPos, 0); rt = 2; goto Yd3y; } sf.pos=6302430; if ((Vc == 110)) { sf.pos=6302431; YjUM__Ydti(Vwriter, 10); } else { sf.pos=6302432; if ((Vc == 116)) { sf.pos=6302433; YjUM__Ydti(Vwriter, 9); } else { sf.pos=6302434; if ((Vc == 114)) { sf.pos=6302435; YjUM__Ydti(Vwriter, 13); } else { sf.pos=6302436; YjUM__Ydti(Vwriter, Vc); } }} Yd3y: if (rt) goto YBCw; } else { sf.pos=6302437; YjUM__Ydti(Vwriter, Vc); } YBCw: if (rt == 2) { rt &= 1; break; } sf.pos=6302438; } break; } case 39: { sf.pos=6302439; Vc = YIaq(Ain); sf.pos=6302440; Vres->Vtype = 15; sf.pos=6302441; if ((Vc == 92)) { sf.pos=6302442; Vc = YIaq(Ain); sf.pos=6302443; switch (Vc) { case 110: { sf.pos=6302444; Vc = 10; break; } case 114: { sf.pos=6302445; Vc = 13; break; } case 116: { sf.pos=6302446; Vc = 9; break; } } } sf.pos=6302447; Y6jW(Vwriter); sf.pos=6302448; YjUM__Ydti(Vwriter, Vc); sf.pos=6302449; Vc = YIaq(Ain); sf.pos=6302450; if ((Vc != 39)) { sf.pos=6302451; YDli(((Tc*)&YYrm), Vres->VstartPos, 0); } break; } default: { Ti Vi; Vi = 0; sf.pos=6302452; if (!(YdpE(Vc))) { sf.pos=6302453; YDli(ZcS3(((Tc*)&YtNZ), ZintAsString(Vc), ((Tc*)&YN)), (t0 = Vres->VstartPos), 0); } else { Ti Vquot; Vquot = 0; sf.pos=6302454; if (((Vc >= 48) && (Vc <= 57))) { sf.pos=6302455; Vquot = 39; } sf.pos=6302456; Y6jW(Vwriter); sf.pos=6302457; while ((YdpE(Vc) || (Vc == Vquot))) { sf.pos=6302458; YjUM__Ydti(Vwriter, Vc); sf.pos=6302459; Vc = YIaq(Ain); sf.pos=6302460; } sf.pos=6302461; YCer(Ain, Vc); } sf.pos=6302462; Vres->Vtype = ZDictGetIntDef(YwVY, (Tz)(void*)YbNW(Vwriter), 0); sf.pos=6302463; if ((Vres->Vtype == 0)) { sf.pos=6302464; Vres->Vtype = 12; } break; } } sf.pos=6302465; Vres->Vvalue = YbNW(Vwriter); sf.pos=6302466; Vres->VendPos = Y83A(Ain->Vinput->Vpos); sf.pos=6302467; r = Vres; topFrame = sf.prev; return r; } void YVn_(YuI4 *Ain) { Ti Vc; Zsf sf; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; Vc = 0; sf.pos=5002400; while (1) { sf.pos=5002401; Vc = YIaq(Ain); sf.pos=5002402; if ((Vc == 47)) { Ti Vnc; sf.pos=5002403; Vnc = YIaq(Ain); sf.pos=5002404; if ((Vnc == 47)) { sf.pos=5002405; while (1) { sf.pos=5002406; Vc = YIaq(Ain); sf.pos=5002407; if (((Vc == Y3QJ) || (Vc == 10))) { rt = 2; goto Y4bI; } Y4bI: if (rt == 2) { rt &= 1; break; } sf.pos=5002408; } rt = 4; if (rt) goto YVK1; } sf.pos=5002409; YCer(Ain, Vnc); YVK1: if (rt) goto YW6P; } sf.pos=5002410; if (((Vc != 32) && (Vc != 10))) { rt = 2; goto YW6P; } YW6P: if (rt == 2) { rt &= 1; break; } if (rt == 4) { rt &= 1; continue; } sf.pos=5002411; } sf.pos=5002412; YCer(Ain, Vc); topFrame = sf.prev; return; } Tb YdpE(Ti Ac) { Zsf sf; Tb r = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=4199900; r = ((((((Ac >= 97) && (Ac <= 122))) || (((Ac >= 65) && (Ac <= 90)))) || (((Ac >= 48) && (Ac <= 57)))) || (Ac == 95)); topFrame = sf.prev; return r; } int JPTokenize(int round) { static int round_done = -1; int done = 1; if (round_done < round) { Zsf sf; sf.prev = topFrame; sf.pos = 0; sf.frof = NULL; topFrame = &sf; round_done = round; if (round == 2001) { sf.pos=5042100; YwVY = ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZDictAdd(0, ZnewDict((Tt*)&string__T, (Tt*)&CPToken__EType__T, 0), (Tz)(void*)((Tc*)&YpLJ), (Tz)(Ti)8), (Tz)(void*)((Tc*)&Y89Q), (Tz)(Ti)3), (Tz)(void*)((Tc*)&YL0B), (Tz)(Ti)2), (Tz)(void*)((Tc*)&YXqe), (Tz)(Ti)4), (Tz)(void*)((Tc*)&Yveu), (Tz)(Ti)6), (Tz)(void*)((Tc*)&Yg9u), (Tz)(Ti)1), (Tz)(void*)((Tc*)&Ygug), (Tz)(Ti)7), (Tz)(void*)((Tc*)&YJcg), (Tz)(Ti)5), (Tz)(void*)((Tc*)&Yiu9), (Tz)(Ti)11), (Tz)(void*)((Tc*)&Yf1Q), (Tz)(Ti)10), (Tz)(void*)((Tc*)&YmU3), (Tz)(Ti)9); } topFrame = sf.prev; } return done; } /* PTokenize done */ YuI4 *YW5n(YuI4 *t, Tr Afd, Tc *Afname, Tc *Aindent) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) {sf.pos=4431800; t = Za(sizeof(YuI4));} sf.pos=4431801; t->Vinput = YOdr(NULL, Afd, Afname, Aindent, 0); sf.pos=4431802; t->VtokenStack = ZnewList((Tt*)&Ykeq__T, 0); topFrame = sf.prev; return t; } Ti YIaq(YuI4 *t) { Zsf sf; Ti r = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=1980400; ZthrowThisNil(); } sf.pos=1980401; r = YAit(t->Vinput); topFrame = sf.prev; return r; } void YCer(YuI4 *t, Ti Ac) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=4496000; ZthrowThisNil(); } sf.pos=4496001; YmK2(t->Vinput, Ac); topFrame = sf.prev; return; } Ykeq *YVoF(YuI4 *t) { Zsf sf; Ykeq *r = 0; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=3524900; ZthrowThisNil(); } sf.pos=3524901; if ((ZListSize(t->VtokenStack) > 0)) { sf.pos=3524902; r = ZListRemovePtrItem((Tl*)t->VtokenStack, -1); rt = 1; goto YiWv; } sf.pos=3524903; r = Y7Z3(t); YiWv: topFrame = sf.prev; return r; } void Y4Sj(YuI4 *t, Ykeq *Atoken) { Zsf sf; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; if (t == NULL) { sf.pos=2093300; ZthrowThisNil(); } sf.pos=2093301; ZLap((Tl*)t->VtokenStack, (Tz)(void*)Atoken); topFrame = sf.prev; return; } To ToYuI4[] = { {2, 0}, {0, (Tt*)&YeYq__T}, /* input */ {0, (Tt*)&list__T}, /* tokenStack */ }; Tto YuI4__T = {390, (Tc*)&Ytw1, 0, ToYuI4}; int JPTokenInput(int round) { static int round_done = -1; int done = 1; if (round_done < round) { Zsf sf; sf.prev = topFrame; sf.pos = 0; sf.frof = NULL; topFrame = &sf; round_done = round; done &= JPTokenize(round); if (round == 2001) { } topFrame = sf.prev; } return done; } /* PTokenInput done */ YP_l *YSOt(Tc *Afname) { Zsf sf; YP_l *r = 0; YP_l *Vpfile = 0; Tr Vfd = {NULL}; YuI4 *Vin = 0; Ykeq *Vtoken = 0; YRAB *Vmsg = 0; Tr t0 = {NULL}; YkxB *t1 = 0; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=7157300; Vpfile = Yy3W(NULL); sf.pos=7157301; Vfd = YsGz(Afname); sf.pos=7157302; if ((((Vfd).ptr) == NULL)) { sf.pos=7157303; Yl0k(ZcS(((Tc*)&YdgR), Afname)); sf.pos=7157304; Zexit(NULL, 1); return NULL; } sf.pos=7157305; Vin = YW5n(NULL, Vfd, Afname, ((Tc*)&Ya)); sf.pos=7157306; Vin->Vinput->VallowTabs = 1; sf.pos=7157307; Ylxt(); sf.pos=7157308; while (1) { sf.pos=7157309; Vtoken = YVoF(Vin); sf.pos=7157310; if ((Vtoken->Vtype == 25)) { rt = 2; goto YjCc; } sf.pos=7157311; switch (Vtoken->Vtype) { case 1: { sf.pos=7157312; YjA8(Vin, Vpfile); break; } case 4: { sf.pos=7157313; YYPi(Vpfile, YDgP(Vin)); break; } case 9: { sf.pos=7157314; YUys(Vpfile, YpkI(Vin, Vpfile)); break; } case 2: { sf.pos=7157316; Vmsg = ((YRAB *)Znio(2, 7157315, (YOrf(Vin)))); sf.pos=7157317; Vmsg->Vparent = *Znao(&t0, Vpfile, YP_l__Ytv2_imt, 1); sf.pos=7157318; YhB6(Vpfile, *Znao(&t0, Vmsg, YRAB__YuXI_imt, 2)); break; } case 3: { sf.pos=7157319; YUys(Vpfile, YCm2(Vin)); break; } default: { sf.pos=7157320; YDli(ZcS(((Tc*)&YJWm), Vtoken->Vvalue), (t1 = Vtoken->VstartPos), 0); break; } } YjCc: if (rt == 2) { rt &= 1; break; } sf.pos=7157321; } sf.pos=7157322; ((Ts (*)(void*))(Vfd.table[35]))(Vfd.ptr); sf.pos=7157323; r = Vpfile; topFrame = sf.prev; return r; } void YjA8(YuI4 *Ain, YP_l *Apfile) { Zsf sf; Ykeq *Vt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=9452500; Vt = YVoF(Ain); sf.pos=9452501; if ((Vt->Vtype != 12)) { sf.pos=9452502; YDli(((Tc*)&Y2by), Vt->VstartPos, 0); } else { sf.pos=9452503; if ((Apfile->Vpackage != NULL)) { sf.pos=9452504; YDli(((Tc*)&YHnJ), Vt->VstartPos, 0); } else { sf.pos=9452505; Apfile->Vpackage = Vt->Vvalue; } } sf.pos=9452506; YYYx(Ain); topFrame = sf.prev; return; } Yswy *YDgP(YuI4 *Ain) { Zsf sf; Yswy *r = 0; Yswy *Voption = 0; Ykeq *Vt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=1272600; Voption = Za(sizeof(Yswy)); sf.pos=1272601; Vt = YVoF(Ain); sf.pos=1272602; if ((Vt->Vtype != 12)) { sf.pos=1272603; YDli(((Tc*)&Y6FG), Vt->VstartPos, 0); } else { sf.pos=1272604; Voption->Vpos = Vt->VstartPos; sf.pos=1272605; Voption->Vname = Vt->Vvalue; sf.pos=1272606; Vt = YVoF(Ain); sf.pos=1272607; if ((Vt->Vtype == 18)) { sf.pos=1272608; Vt = YVoF(Ain); sf.pos=1272609; if (((Vt->Vtype != 16) && (Vt->Vtype != 12))) { sf.pos=1272610; YDli(((Tc*)&Y82z), Vt->VstartPos, 0); } else { sf.pos=1272611; Voption->Vtype = Vt->Vtype; sf.pos=1272612; Voption->Vvalue = Vt->Vvalue; sf.pos=1272613; YYYx(Ain); } } else { sf.pos=1272614; if ((Vt->Vtype != 17)) { sf.pos=1272615; YDli(((Tc*)&Y0Xz), Vt->VstartPos, 0); } } } sf.pos=1272616; r = Voption; topFrame = sf.prev; return r; } Tr YpkI(YuI4 *Ain, YP_l *Apfile) { Zsf sf; Tr r = {NULL}; YNW5 *Vservice = 0; Ykeq *Vt = 0; YlM3 *Vrpc = 0; Tr t0 = {NULL}; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=626200; Vservice = Y_oR(NULL); sf.pos=626201; Vt = YVoF(Ain); sf.pos=626202; if ((Vt->Vtype != 12)) { sf.pos=626203; YDli(((Tc*)&YJUj), Vt->VstartPos, 0); } else { sf.pos=626204; Vservice->Vname = Vt->Vvalue; sf.pos=626205; Vt = YVoF(Ain); sf.pos=626206; if ((Vt->Vtype != 21)) { sf.pos=626207; YDli(((Tc*)&YlMg), Vt->VstartPos, 0); } else { sf.pos=626208; while (1) { sf.pos=626209; Vt = YVoF(Ain); sf.pos=626210; if ((Vt->Vtype == 22)) { rt = 2; goto Y9kj; } sf.pos=626211; if (YtEy(Vt)) { rt = 2; goto Y9kj; } sf.pos=626212; if ((Vt->Vtype != 10)) { sf.pos=626213; YDli(((Tc*)&YT_h), Vt->VstartPos, 0); } else { sf.pos=626214; Vt = YVoF(Ain); sf.pos=626215; if ((Vt->Vtype != 12)) { sf.pos=626216; YDli(((Tc*)&YImx), Vt->VstartPos, 0); } else { Tb VhadOpenParen; sf.pos=626217; Vrpc = YwLI(NULL, Vt->Vvalue); sf.pos=626218; YBM3(Vservice, Vrpc); sf.pos=626219; Vt = YVoF(Ain); sf.pos=626220; if ((Vt->Vtype != 19)) { sf.pos=626221; YDli(((Tc*)&YZG7), Vt->VstartPos, 0); } sf.pos=626222; Vt = YVoF(Ain); sf.pos=626223; if ((Vt->Vtype != 12)) { sf.pos=626224; YDli(((Tc*)&Yq4F), Vt->VstartPos, 0); } else { sf.pos=626225; Vrpc->VrequestName = Vt->Vvalue; } sf.pos=626226; if ((Vt->Vtype != 20)) { sf.pos=626227; Vt = YVoF(Ain); sf.pos=626228; if ((Vt->Vtype != 20)) { sf.pos=626229; YDli(((Tc*)&Y_G7), Vt->VstartPos, 0); } } sf.pos=626230; Vt = YVoF(Ain); sf.pos=626231; if ((Vt->Vtype != 11)) { sf.pos=626232; YDli(((Tc*)&YMrT), Vt->VstartPos, 0); } sf.pos=626233; Vt = YVoF(Ain); VhadOpenParen = 0; sf.pos=626234; if ((Vt->Vtype == 19)) { sf.pos=626235; VhadOpenParen = 1; sf.pos=626236; Vt = YVoF(Ain); } sf.pos=626237; if ((Vt->Vtype != 12)) { sf.pos=626238; YDli(((Tc*)&YXcR), Vt->VstartPos, 0); } else { sf.pos=626239; Vrpc->VresponseName = Vt->Vvalue; } sf.pos=626240; if (VhadOpenParen) { sf.pos=626241; Vt = YVoF(Ain); sf.pos=626242; if ((Vt->Vtype != 20)) { sf.pos=626243; YDli(((Tc*)&Y_G7), Vt->VstartPos, 0); } } sf.pos=626244; YYYx(Ain); } } Y9kj: if (rt == 2) { rt &= 1; break; } sf.pos=626245; } } } sf.pos=626246; r = *Znao(&t0, Vservice, YNW5__YuXI_imt, 4); topFrame = sf.prev; return r; } Tr YOrf(YuI4 *Ain) { Zsf sf; Tr r = {NULL}; YRAB *Vitem = 0; Ykeq *Vt = 0; YRAB *Vmsg = 0; Tr t0 = {NULL}; YkxB *t1 = 0; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=855000; Vitem = YI6R(NULL); sf.pos=855001; Vt = YVoF(Ain); sf.pos=855002; if ((Vt->Vtype != 12)) { sf.pos=855003; YDli(((Tc*)&YmWM), Vt->VstartPos, 0); } else { sf.pos=855004; Vitem->Vname = Vt->Vvalue; sf.pos=855005; Vt = YVoF(Ain); sf.pos=855006; if ((Vt->Vtype != 21)) { sf.pos=855007; YDli(((Tc*)&YlMg), Vt->VstartPos, 0); } else { sf.pos=855008; while (1) { sf.pos=855009; Vt = YVoF(Ain); sf.pos=855010; if ((Vt->Vtype == 22)) { rt = 2; goto YsRb; } sf.pos=855011; if (YtEy(Vt)) { rt = 2; goto YsRb; } sf.pos=855012; switch (Vt->Vtype) { case 5: case 6: case 7: { sf.pos=855013; ZLap((Tl*)Vitem->Vfields, (Tz)(void*)YFuL(Vt, Ain)); break; } case 2: { sf.pos=855015; Vmsg = ((YRAB *)Znio(2, 855014, (YOrf(Ain)))); sf.pos=855016; Vmsg->Vparent = *Znao(&t0, Vitem, YRAB__Ytv2_imt, 0); sf.pos=855017; ZLapIobj((Tl*)Vitem->Vitems, *Znao(&t0, Vmsg, YRAB__YuXI_imt, 2)); break; } case 3: { sf.pos=855018; ZLapIobj((Tl*)Vitem->Vitems, YCm2(Ain)); break; } case 4: { sf.pos=855019; YNVJ(Vitem, YDgP(Ain)); break; } default: { sf.pos=855020; YDli(ZcS(((Tc*)&Y8wy), Vt->Vvalue), (t1 = Vt->VstartPos), 0); break; } } YsRb: if (rt == 2) { rt &= 1; break; } sf.pos=855021; } } sf.pos=855022; YbaL(Vitem); } sf.pos=855023; r = *Znao(&t0, Vitem, YRAB__YuXI_imt, 2); topFrame = sf.prev; return r; } Y0uC *YFuL(Ykeq *Atoken, YuI4 *Ain) { Zsf sf; Y0uC *r = 0; Y0uC *Vfield = 0; Ykeq *Vt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=5226900; Vfield = Za(sizeof(Y0uC)); sf.pos=5226901; Vfield->Vpos = Atoken->VstartPos; sf.pos=5226902; switch (Atoken->Vtype) { case 5: { sf.pos=5226903; Vfield->Vrequired = 1; break; } case 7: { sf.pos=5226904; Vfield->Vrepeated = 1; break; } } sf.pos=5226905; Vt = YVoF(Ain); sf.pos=5226906; if ((Vt->Vtype != 12)) { sf.pos=5226907; YDli(((Tc*)&Yhu6), Vt->VstartPos, 0); } else { sf.pos=5226908; Vfield->Vtype = YKJX(Vt->Vvalue); sf.pos=5226909; Vfield->VtypeName = Vt->Vvalue; } sf.pos=5226910; Vt = YVoF(Ain); sf.pos=5226911; if ((Vt->Vtype != 12)) { sf.pos=5226912; YDli(((Tc*)&Yoyn), Vt->VstartPos, 0); } else { sf.pos=5226913; Vfield->Vname = Vt->Vvalue; sf.pos=5226914; if (ZstringStartsWith(Vfield->Vname, ((Tc*)&YKIS), 0)) { sf.pos=5226915; YDli(((Tc*)&Ye1M), Vt->VstartPos, 0); } } sf.pos=5226916; Vt = YVoF(Ain); sf.pos=5226917; if ((Vt->Vtype != 18)) { sf.pos=5226918; YDli(((Tc*)&YHNV), Vt->VstartPos, 0); } sf.pos=5226919; Vfield->Vnr = YeT_(Ain); sf.pos=5226920; Vt = YVoF(Ain); sf.pos=5226921; if ((Vt->Vtype == 23)) { sf.pos=5226922; Vt = YVoF(Ain); sf.pos=5226923; if ((Vt->Vtype != 8)) { sf.pos=5226924; YDli(((Tc*)&YG5z), Vt->VstartPos, 0); } sf.pos=5226925; Vt = YVoF(Ain); sf.pos=5226926; if ((Vt->Vtype != 18)) { sf.pos=5226927; YDli(((Tc*)&YHNV), Vt->VstartPos, 0); } sf.pos=5226928; Vt = YVoF(Ain); sf.pos=5226929; if ((Vt->Vtype != 12)) { sf.pos=5226930; YDli(((Tc*)&Y8XM), Vt->VstartPos, 0); } else { sf.pos=5226931; Vfield->Vdefault = Vt->Vvalue; sf.pos=5226932; if ((Vfield->Vtype == 1)) { sf.pos=5226933; Vfield->Vdefault = ZstringToUpper(Vfield->Vdefault); sf.pos=5226934; if (((ZstringCmp(Vfield->Vdefault, ((Tc*)&Y2cy)) != 0) && (ZstringCmp(Vfield->Vdefault, ((Tc*)&YHoE)) != 0))) { sf.pos=5226935; YDli(((Tc*)&YItG), Vt->VstartPos, 0); } } } sf.pos=5226936; Vt = YVoF(Ain); sf.pos=5226937; if ((Vt->Vtype != 24)) { sf.pos=5226938; YDli(((Tc*)&YSLg), Vt->VstartPos, 0); } else { sf.pos=5226939; Vt = YVoF(Ain); } } sf.pos=5226940; Y4Sj(Ain, Vt); sf.pos=5226941; YYYx(Ain); sf.pos=5226942; r = Vfield; topFrame = sf.prev; return r; } Tr YCm2(YuI4 *Ain) { Zsf sf; Tr r = {NULL}; Y2Kp *Vitem = 0; Ykeq *Vt = 0; Tc *Vname = NULL; Tr t0 = {NULL}; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=5141000; Vitem = YIur(NULL); sf.pos=5141001; Vt = YVoF(Ain); sf.pos=5141002; if ((Vt->Vtype != 12)) { sf.pos=5141003; YDli(((Tc*)&YyCj), Vt->VstartPos, 0); } else { sf.pos=5141004; Vitem->Vname = Vt->Vvalue; sf.pos=5141005; Vt = YVoF(Ain); sf.pos=5141006; if ((Vt->Vtype != 21)) { sf.pos=5141007; YDli(((Tc*)&YlMg), Vt->VstartPos, 0); } else { sf.pos=5141008; while (1) { Ti Vnr; sf.pos=5141009; Vt = YVoF(Ain); sf.pos=5141010; if ((Vt->Vtype == 22)) { rt = 2; goto YHDg; } sf.pos=5141011; if (YtEy(Vt)) { rt = 2; goto YHDg; } sf.pos=5141012; if ((Vt->Vtype != 12)) { sf.pos=5141013; YDli(((Tc*)&YTWr), Vt->VstartPos, 0); } sf.pos=5141014; Vname = Vt->Vvalue; sf.pos=5141015; Vt = YVoF(Ain); sf.pos=5141016; if ((Vt->Vtype != 18)) { sf.pos=5141017; YDli(((Tc*)&YHNV), Vt->VstartPos, 0); } sf.pos=5141018; Vnr = YeT_(Ain); sf.pos=5141019; Y_Nc(Vitem, Vname, Vnr, Vt->VstartPos); sf.pos=5141020; YYYx(Ain); YHDg: if (rt == 2) { rt &= 1; break; } sf.pos=5141021; } sf.pos=5141022; YXXO(Vitem); } } sf.pos=5141023; r = *Znao(&t0, Vitem, Y2Kp__YuXI_imt, 0); topFrame = sf.prev; return r; } void YYYx(YuI4 *Ain) { Zsf sf; Ykeq *Vt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=3576100; Vt = YVoF(Ain); sf.pos=3576101; if ((Vt->Vtype != 17)) { sf.pos=3576102; YDli(((Tc*)&Ybzg), Vt->VstartPos, 0); sf.pos=3576103; Y4Sj(Ain, Vt); } topFrame = sf.prev; return; } Tb YtEy(Ykeq *At) { Zsf sf; Tb r = 0; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=507000; if ((At->Vtype == 25)) { sf.pos=507001; YDli(((Tc*)&YF0E), At->VstartPos, 0); sf.pos=507002; r = 1; rt = 1; goto YDJj; } sf.pos=507003; r = 0; YDJj: topFrame = sf.prev; return r; } Ti YeT_(YuI4 *Ain) { Zsf sf; Ti r = 0; Ykeq *Vt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=6651000; Vt = YVoF(Ain); sf.pos=6651001; if (((Vt->Vtype != 12) || !((((ZstringGetChar(Vt->Vvalue, 0) >= 48) && (ZstringGetChar(Vt->Vvalue, 0) <= 57)))))) { sf.pos=6651002; YDli(((Tc*)&YNZb), Vt->VstartPos, 0); } sf.pos=6651003; r = ZstringToInt(Vt->Vvalue, 1, 0); topFrame = sf.prev; return r; } void YUys(YP_l *A0, Tr A1) { YhB6(A0,A1); } int JParseProto(int round) { static int round_done = -1; int done = 1; if (round_done < round) { Zsf sf; sf.prev = topFrame; sf.pos = 0; sf.frof = NULL; topFrame = &sf; round_done = round; done &= JMessageItem(round); done &= JPTokenInput(round); if (round == 2001) { } topFrame = sf.prev; } return done; } /* ParseProto done */ /* including WriteZimbu bodies */ void YCCA(YP_l *Apfile, Tc *AinFileName, Tc *AoutFileName) { Ti Vi; Zsf sf; Tr Vout = {NULL}; Tc *Vmname = NULL; Tl *Zf1 = NULL; Tr Vitem = {NULL}; YRAB *Vmsg = 0; Y2Kp *Venum = 0; YNW5 *Vservice = 0; Tc *t0 = NULL; Tc *t1 = NULL; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=4426000; Vout = YiBk(AoutFileName, 1); sf.pos=4426001; if ((((Vout).ptr) == NULL)) { sf.pos=4426002; Yl0k(ZcS(((Tc*)&Y32K), AoutFileName)); sf.pos=4426003; Zexit(NULL, 1); } sf.pos=4426004; ((Ts (*)(void*, Tc*))(Vout.table[11]))(Vout.ptr, ZcS(((Tc*)&Y_ZB), AinFileName)); sf.pos=4426005; ((Ts (*)(void*))(Vout.table[18]))(Vout.ptr); sf.pos=4426006; ((Ts (*)(void*, Tc*))(Vout.table[11]))(Vout.ptr, ((Tc*)&YR1d)); sf.pos=4426007; ((Ts (*)(void*, Tc*))(Vout.table[11]))(Vout.ptr, ((Tc*)&YGq9)); sf.pos=4426008; ((Ts (*)(void*))(Vout.table[18]))(Vout.ptr); sf.pos=4426009; if ((Apfile->Vpackage == NULL)) { Ti Vi; sf.pos=4426010; Vmname = AinFileName; sf.pos=4426011; Vi = ZstringFindLastChar(Vmname, 47, 0); sf.pos=4426012; if ((Vi >= 0)) { sf.pos=4426013; Vmname = ZstringSlice(Vmname, (Vi + 1), -1, 0); } } else { sf.pos=4426014; Vmname = Apfile->Vpackage; } sf.pos=4426015; Vi = ZstringFindLastChar(Vmname, 46, 0); sf.pos=4426016; if ((Vi >= 0)) { sf.pos=4426017; Vmname = ZstringSlice(Vmname, 0, (Vi - 1), 0); } sf.pos=4426018; Vi = ZstringFindLastChar(Vmname, 46, 0); sf.pos=4426019; if ((Vi >= 0)) { sf.pos=4426020; Vmname = ZstringSlice(Vmname, (Vi + 1), -1, 0); } sf.pos=4426021; Vmname = ZcS((t1 = ZstringToUpper(ZstringSlice(Vmname, 0, 0, 0))), (t0 = ZstringSlice(Vmname, 1, -1, 0))); sf.pos=4426022; ((Ts (*)(void*, Tc*))(Vout.table[11]))(Vout.ptr, ZcS3(((Tc*)&YoyN), Vmname, ((Tc*)&Y7Qg))); sf.pos=4426023; { Tfl Zf1i; Zf1 = Apfile->VitemList; Zf1i.l = Zf1; Zf1i.valp = (void*)&Vitem; Zf1i.i = 0; for (; ZforListIobjCont(&Zf1i); ) { sf.pos=4426024; if ((Vitem).type == 2) { sf.pos=4426026; Vmsg = ((YRAB *)Znio(2, 4426025, (Vitem))); sf.pos=4426027; YxvA(Vmsg, Vout, ((Tc*)&YZY)); } else { sf.pos=4426028; if ((Vitem).type == 0) { sf.pos=4426030; Venum = ((Y2Kp *)Znio(0, 4426029, (Vitem))); sf.pos=4426031; Y8RG(Venum, Vout, ((Tc*)&YZY)); } else { sf.pos=4426032; if ((Vitem).type == 4) { sf.pos=4426034; Vservice = ((YNW5 *)Znio(4, 4426033, (Vitem))); sf.pos=4426035; Yk4Q(Vservice, Vout, ((Tc*)&YZY)); } else { sf.pos=4426036; Y2oO(((Tc*)&YoBQ), NULL, 0); } }} sf.pos=4426037; } } sf.pos=4426038; ((Ts (*)(void*, Tc*))(Vout.table[11]))(Vout.ptr, ((Tc*)&Y9a)); sf.pos=4426039; ((Ts (*)(void*))(Vout.table[35]))(Vout.ptr); topFrame = sf.prev; return; } void YxvA(YRAB *Amsg, Tr Aout, Tc *Aindent) { Zsf sf; Tl *Zf2 = NULL; Yswy *Vo = 0; Tl *VhasNames = NULL; Tl *VclearLines = NULL; Tl *VvalidItems = NULL; Tl *VmsgFields = NULL; Tl *VenumFields = NULL; Tl *VintFields = NULL; Tl *Vint32Fields = NULL; Tl *VfloatFields = NULL; Tl *VdoubleFields = NULL; Tl *VboolFields = NULL; Tl *VstringFields = NULL; Tl *VrepeatedFields = NULL; Tl *VnotRepeatedFields = NULL; Tc *Vindent2 = NULL; Tc *Vindent4 = NULL; Tc *Vindent6 = NULL; Tl *Zf1 = NULL; Tr Vitem = {NULL}; YRAB *Vnmsg = 0; Tl *Zf11 = NULL; Y0uC *Vf = 0; Tc *VtypeName = NULL; Tc *VvarTypeName = NULL; Tc *VinitVal = NULL; Tc *VdefaultVal = NULL; Tr Vitem1 = {NULL}; Tc *VhasName = NULL; Tl *Zf12 = NULL; Tc *Vl = NULL; Tl *Zf13 = NULL; Tc *Vh = NULL; Tc *Vsep = NULL; Tl *Zf21 = NULL; Tc *Vi = NULL; Tl *Zf14 = NULL; Tc *Vtype = NULL; Tc *Vreader = NULL; Tl *Zf15 = NULL; Tr Vitem2 = {NULL}; Tc *t0 = NULL; YkxB *t1 = 0; Tc *t2 = NULL; Tl *t3 = NULL; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=180200; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YB_i), (t0 = Amsg->Vname), ((Tc*)&YxMq), (Tc*)1)); sf.pos=180201; if ((ZListSize(Amsg->VoptionList) > 0)) { Tb Vextensible; Vextensible = 0; sf.pos=180202; { Tfl Zf2i; Zf2 = Amsg->VoptionList; Zf2i.l = Zf2; Zf2i.valp = (void*)&Vo; Zf2i.i = 0; for (; ZforListPtrCont(&Zf2i); ) { sf.pos=180203; if ((ZstringCmp(Vo->Vname, ((Tc*)&YLP5)) == 0)) { sf.pos=180204; Vextensible = 1; } sf.pos=180205; } } sf.pos=180206; if (Vextensible) { sf.pos=180207; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Yfgk))); } sf.pos=180208; ((Ts (*)(void*))(Aout.table[18]))(Aout.ptr); } sf.pos=180209; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YXgq))); sf.pos=180210; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YVet))); sf.pos=180211; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Yow3))); sf.pos=180212; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YlWb), (t0 = Amsg->Vname), ((Tc*)&YI), (Tc*)1)); sf.pos=180213; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YVet))); sf.pos=180214; VhasNames = ZnewList((Tt*)&string__T, 0); sf.pos=180215; VclearLines = ZnewList((Tt*)&string__T, 0); sf.pos=180216; VvalidItems = ZnewList((Tt*)&string__T, 0); sf.pos=180217; VmsgFields = ZnewList((Tt*)&Y0uC__T, 0); sf.pos=180218; VenumFields = ZnewList((Tt*)&Y0uC__T, 0); sf.pos=180219; VintFields = ZnewList((Tt*)&Y0uC__T, 0); sf.pos=180220; Vint32Fields = ZnewList((Tt*)&Y0uC__T, 0); sf.pos=180221; VfloatFields = ZnewList((Tt*)&Y0uC__T, 0); sf.pos=180222; VdoubleFields = ZnewList((Tt*)&Y0uC__T, 0); sf.pos=180223; VboolFields = ZnewList((Tt*)&Y0uC__T, 0); sf.pos=180224; VstringFields = ZnewList((Tt*)&Y0uC__T, 0); sf.pos=180225; VrepeatedFields = ZnewList((Tt*)&Y0uC__T, 0); sf.pos=180226; VnotRepeatedFields = ZnewList((Tt*)&Y0uC__T, 0); sf.pos=180227; Vindent2 = ZcS(Aindent, ((Tc*)&YZY)); sf.pos=180228; Vindent4 = ZcS(Vindent2, ((Tc*)&YZY)); sf.pos=180229; Vindent6 = ZcS(Vindent4, ((Tc*)&YZY)); sf.pos=180230; { Tfl Zf1i; Zf1 = Amsg->Vitems; Zf1i.l = Zf1; Zf1i.valp = (void*)&Vitem; Zf1i.i = 0; for (; ZforListIobjCont(&Zf1i); ) { sf.pos=180231; if ((Vitem).type == 2) { sf.pos=180233; Vnmsg = ((YRAB *)Znio(2, 180232, (Vitem))); sf.pos=180234; YxvA(Vnmsg, Aout, ZcS(Aindent, ((Tc*)&YZY))); } else { sf.pos=180235; if ((Vitem).type == 0) { } else { sf.pos=180236; Y2oO(((Tc*)&YoBQ), NULL, 0); } } sf.pos=180237; } } sf.pos=180238; { Tfl Zf11i; Zf11 = Amsg->Vfields; Zf11i.l = Zf11; Zf11i.valp = (void*)&Vf; Zf11i.i = 0; for (; ZforListPtrCont(&Zf11i); ) { VtypeName = NULL; VvarTypeName = NULL; VinitVal = NULL; VdefaultVal = NULL; sf.pos=180239; switch (Vf->Vtype) { case 0: { sf.pos=180240; VtypeName = Vf->VtypeName; sf.pos=180241; Vitem1 = YBZe(Amsg, Vf->VtypeName); sf.pos=180242; if ((((Vitem1).ptr) == NULL)) { sf.pos=180243; YDli(ZcS(((Tc*)&Ysxb), Vf->VtypeName), (t1 = Vf->Vpos), 0); sf.pos=180244; VinitVal = ((Tc*)&Ya); sf.pos=180245; VdefaultVal = ((Tc*)&Ya); } else { sf.pos=180246; if ((Vitem1).type == 2) { sf.pos=180247; Vf->Vtype = 12; sf.pos=180248; VinitVal = ((Tc*)&ZNilString); sf.pos=180249; VdefaultVal = Vf->Vdefault; sf.pos=180250; ZLap((Tl*)VmsgFields, (Tz)(void*)Vf); } else { sf.pos=180251; Vf->Vtype = 3; sf.pos=180252; VinitVal = ZcS(Vf->VtypeName, ((Tc*)&YW8X)); sf.pos=180253; if ((Vf->Vdefault != NULL)) { sf.pos=180254; VdefaultVal = ZcS3(Vf->VtypeName, ((Tc*)&Ywla), (t0 = Vf->Vdefault)); } sf.pos=180255; ZLap((Tl*)VenumFields, (Tz)(void*)Vf); } } break; } case 17: { sf.pos=180256; VtypeName = ((Tc*)&YanE); sf.pos=180257; VinitVal = ((Tc*)&ZNilString); sf.pos=180258; VdefaultVal = Vf->Vdefault; sf.pos=180259; ZLap((Tl*)VstringFields, (Tz)(void*)Vf); break; } case 9: case 11: { sf.pos=180260; VtypeName = ((Tc*)&Y1Qt); sf.pos=180261; VinitVal = ((Tc*)&YW); sf.pos=180262; VdefaultVal = Vf->Vdefault; sf.pos=180263; ZLap((Tl*)VintFields, (Tz)(void*)Vf); break; } case 10: { sf.pos=180264; VtypeName = ((Tc*)&YrQi); sf.pos=180265; VinitVal = ((Tc*)&YW); sf.pos=180266; VdefaultVal = Vf->Vdefault; sf.pos=180267; ZLap((Tl*)Vint32Fields, (Tz)(void*)Vf); break; } case 18: { sf.pos=180268; VtypeName = ((Tc*)&YDFy); sf.pos=180269; VinitVal = ((Tc*)&YW); sf.pos=180270; VdefaultVal = Vf->Vdefault; sf.pos=180271; ZLap((Tl*)VintFields, (Tz)(void*)Vf); break; } case 19: { sf.pos=180272; VtypeName = ((Tc*)&YNmG); sf.pos=180273; VinitVal = ((Tc*)&YW); sf.pos=180274; VdefaultVal = Vf->Vdefault; sf.pos=180275; ZLap((Tl*)VintFields, (Tz)(void*)Vf); break; } case 6: { sf.pos=180276; VtypeName = ((Tc*)&YdsC); sf.pos=180277; VinitVal = ((Tc*)&YW); sf.pos=180278; VdefaultVal = Vf->Vdefault; sf.pos=180279; ZLap((Tl*)VfloatFields, (Tz)(void*)Vf); break; } case 7: { sf.pos=180280; VtypeName = ((Tc*)&Yt7n); sf.pos=180281; VinitVal = ((Tc*)&YW); sf.pos=180282; VdefaultVal = Vf->Vdefault; sf.pos=180283; ZLap((Tl*)VdoubleFields, (Tz)(void*)Vf); break; } case 1: { sf.pos=180284; VtypeName = ((Tc*)&YtPw); sf.pos=180285; VvarTypeName = ((Vf->Vrepeated) ? (((Tc*)&YtPw)) : (((Tc*)&Y1Qt))); sf.pos=180286; VinitVal = ((Tc*)&YW); sf.pos=180287; VdefaultVal = Vf->Vdefault; sf.pos=180288; ZLap((Tl*)VboolFields, (Tz)(void*)Vf); break; } default: { sf.pos=180289; YDli(ZcS(((Tc*)&Yl1o), Zenum2string(MProto__EType, Vf->Vtype)), NULL, 0); break; } } sf.pos=180290; if ((VvarTypeName == NULL)) { sf.pos=180291; VvarTypeName = VtypeName; } sf.pos=180292; if (Vf->Vrepeated) { sf.pos=180293; ZLap((Tl*)VrepeatedFields, (Tz)(void*)Vf); sf.pos=180294; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Vindent2, ((Tc*)&Y9Ra), VvarTypeName, ((Tc*)&Y4Ja), (t0 = YULH(Vf)))); sf.pos=180295; VinitVal = ((Tc*)&ZNilString); sf.pos=180296; YsmR(Amsg->Vname, Vf, VtypeName, VdefaultVal, Vindent2, Aout); } else { sf.pos=180297; ZLap((Tl*)VnotRepeatedFields, (Tz)(void*)Vf); sf.pos=180298; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Vindent2, VvarTypeName, ((Tc*)&YG), (t0 = YULH(Vf)), (Tc*)1)); sf.pos=180299; VhasName = YFlx(Vf); sf.pos=180300; if ((VhasName != NULL)) { sf.pos=180301; ZLap((Tl*)VhasNames, (Tz)(void*)VhasName); sf.pos=180302; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Vindent2, ((Tc*)&Y8Y5), VhasName)); } sf.pos=180303; Y1M2(Amsg->Vname, Vf, VtypeName, VinitVal, VdefaultVal, Vindent2, Aout); } sf.pos=180304; ZLap((Tl*)VclearLines, (Tz)(void*)ZcS3(YULH(Vf), ((Tc*)&YWXt), VinitVal)); sf.pos=180305; if (Vf->Vrequired) { sf.pos=180306; ZLap((Tl*)VvalidItems, (Tz)(void*)ZcS3(((Tc*)&YG4L), YqGL(Vf), ((Tc*)&YXaa))); } sf.pos=180307; } } sf.pos=180308; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent2, ((Tc*)&YJaV))); sf.pos=180309; { Tfl Zf12i; Zf12 = VclearLines; Zf12i.l = Zf12; Zf12i.valp = (void*)&Vl; Zf12i.i = 0; for (; ZforListPtrCont(&Zf12i); ) { sf.pos=180310; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, Vl)); sf.pos=180311; } } sf.pos=180312; { Tfl Zf13i; Zf13 = VhasNames; Zf13i.l = Zf13; Zf13i.valp = (void*)&Vh; Zf13i.i = 0; for (; ZforListPtrCont(&Zf13i); ) { sf.pos=180313; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Vindent4, Vh, ((Tc*)&YRRN))); sf.pos=180314; } } sf.pos=180315; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent2, ((Tc*)&Y9a))); sf.pos=180316; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent2, ((Tc*)&Yzw4))); sf.pos=180317; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&YZ35))); sf.pos=180318; if ((ZListSize(VvalidItems) == 0)) { sf.pos=180319; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ((Tc*)&YHoE)); } else { sf.pos=180320; Vsep = ((Tc*)&Ya); sf.pos=180321; { Tfl Zf21i; Zf21 = VvalidItems; Zf21i.l = Zf21; Zf21i.valp = (void*)&Vi; Zf21i.i = 0; for (; ZforListPtrCont(&Zf21i); ) { sf.pos=180322; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS(Vsep, Vi)); sf.pos=180323; Vsep = ((Tc*)&Y4zz); sf.pos=180324; } } } sf.pos=180325; ((Ts (*)(void*))(Aout.table[18]))(Aout.ptr); sf.pos=180326; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent2, ((Tc*)&Y9a))); sf.pos=180327; if ((ZListSize(VenumFields) > 0)) { sf.pos=180328; YHzx(((Tc*)&Y89Q), ((Tc*)&Y1Qt), VenumFields, ((Tc*)&YW), Vindent2, Aout); } sf.pos=180329; if ((ZListSize(VintFields) > 0)) { sf.pos=180330; YHzx(((Tc*)&Y1Qt), ((Tc*)&Y1Qt), VintFields, ((Tc*)&YW), Vindent2, Aout); } sf.pos=180331; if ((ZListSize(Vint32Fields) > 0)) { sf.pos=180332; YHzx(((Tc*)&YrQi), ((Tc*)&YrQi), Vint32Fields, ((Tc*)&YW), Vindent2, Aout); } sf.pos=180333; if ((ZListSize(VfloatFields) > 0)) { sf.pos=180334; YHzx(((Tc*)&Yt7n), ((Tc*)&YdsC), VfloatFields, ((Tc*)&YW), Vindent2, Aout); } sf.pos=180335; if ((ZListSize(VdoubleFields) > 0)) { sf.pos=180336; YHzx(((Tc*)&Ygep), ((Tc*)&Yt7n), VdoubleFields, ((Tc*)&YW), Vindent2, Aout); } sf.pos=180337; if ((ZListSize(VboolFields) > 0)) { sf.pos=180338; YHzx(((Tc*)&YtPw), ((Tc*)&YtPw), VboolFields, ((Tc*)&Y2cy), Vindent2, Aout); } sf.pos=180339; if ((ZListSize(VstringFields) > 0)) { sf.pos=180340; YHzx(((Tc*)&YanE), ((Tc*)&YanE), VstringFields, ((Tc*)&Yd1), Vindent2, Aout); } sf.pos=180341; YwAg(VmsgFields, Vindent2, Aout); sf.pos=180342; if ((ZListSize(VnotRepeatedFields) > 0)) { sf.pos=180343; YYCV(VnotRepeatedFields, Vindent2, Aout); } sf.pos=180344; if ((ZListSize(VrepeatedFields) > 0)) { sf.pos=180345; Ycma(VrepeatedFields, Vindent2, Aout); } sf.pos=180346; Yg8t(Amsg, Vindent2, Aout); sf.pos=180347; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent2, ((Tc*)&YcBy))); sf.pos=180348; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Y1Dj))); sf.pos=180349; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent2, ((Tc*)&Y9a))); sf.pos=180350; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Vindent2, ((Tc*)&YyUd), (t0 = Amsg->Vname))); sf.pos=180351; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&YKEm))); sf.pos=180352; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Y_Lu))); sf.pos=180353; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent2, ((Tc*)&Y9a))); sf.pos=180354; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Vindent2, ((Tc*)&Y4Tv), (t0 = Amsg->Vname))); sf.pos=180355; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&YYQ8))); sf.pos=180356; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Y_Lu))); sf.pos=180357; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent2, ((Tc*)&Y9a))); sf.pos=180358; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Vindent2, ((Tc*)&YgCV), (t0 = Amsg->Vname))); sf.pos=180359; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Yew9))); sf.pos=180360; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Y_Lu))); sf.pos=180361; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent2, ((Tc*)&Y9a))); sf.pos=180362; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Vindent2, ((Tc*)&YK2S), (t0 = Amsg->Vname))); sf.pos=180363; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Y0Sk))); sf.pos=180364; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Y_Lu))); sf.pos=180365; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent2, ((Tc*)&Y9a))); sf.pos=180366; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Vindent2, ((Tc*)&YwRP), (t0 = Amsg->Vname))); sf.pos=180367; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Y4vI))); sf.pos=180368; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Y_Lu))); sf.pos=180369; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent2, ((Tc*)&Y9a))); sf.pos=180370; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Vindent2, ((Tc*)&Yk1Y), (t0 = Amsg->Vname))); sf.pos=180371; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&YwU4))); sf.pos=180372; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Y_Lu))); sf.pos=180373; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent2, ((Tc*)&Y9a))); sf.pos=180374; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Vindent2, ((Tc*)&Yevx), (t0 = Amsg->Vname))); sf.pos=180375; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&YlR1))); sf.pos=180376; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Y_Lu))); sf.pos=180377; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent2, ((Tc*)&Y9a))); sf.pos=180378; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent2, ((Tc*)&YuOB))); sf.pos=180379; YMWy(Amsg->Vfields, Vindent4, Aout); sf.pos=180380; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&YaU5))); sf.pos=180381; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Vindent6, ((Tc*)&YZ35), (t0 = Amsg->Vname), ((Tc*)&YyLL), (Tc*)1)); sf.pos=180382; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Y9a))); sf.pos=180383; { Tfl Zf14i; Zf14 = (t3 = ZnewList((Tt*)&string__T, 3), ZLap((Tl*)t3, (Tz)(void*)((Tc*)&Yjby)), ZLap((Tl*)t3, (Tz)(void*)((Tc*)&Y27q)), ZLap((Tl*)t3, (Tz)(void*)((Tc*)&Yz0N))); Zf14i.l = Zf14; Zf14i.valp = (void*)&Vtype; Zf14i.i = 0; for (; ZforListPtrCont(&Zf14i); ) { sf.pos=180384; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS3(Vindent4, ((Tc*)&Yts2), Vtype)); Vreader = NULL; sf.pos=180385; if ((ZstringCmp(Vtype, ((Tc*)&Yjby)) == 0)) { sf.pos=180386; Vreader = ((Tc*)&YIIp); } else { sf.pos=180387; Vreader = ((Tc*)&YDa5); } sf.pos=180388; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(((Tc*)&YO), Vreader, ((Tc*)&YYDR), (t0 = Amsg->Vname), (Tc*)1)); sf.pos=180389; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS5(Vindent6, ((Tc*)&YZ35), (t0 = Amsg->Vname), ((Tc*)&Yvx0), Vtype)); sf.pos=180390; if ((ZstringCmp(Vtype, ((Tc*)&Yz0N)) != 0)) { sf.pos=180391; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ((Tc*)&YPYp)); } else { sf.pos=180392; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ((Tc*)&Yqfe)); } sf.pos=180393; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Y9a))); sf.pos=180394; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Vindent4, ((Tc*)&YKhU), Vtype, ((Tc*)&YO), Vreader, ((Tc*)&Y52_), (Tc*)1, (Tc*)1)); sf.pos=180395; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Vindent6, ((Tc*)&YGO0), Vtype, ((Tc*)&Yqfe), (Tc*)1)); sf.pos=180396; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Y9a))); sf.pos=180397; if ((ZstringCmp(Vtype, ((Tc*)&Y27q)) != 0)) { sf.pos=180398; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Vindent4, ((Tc*)&YKhU), Vtype, ((Tc*)&YZix), Vreader, ((Tc*)&Y52_), (Tc*)1, (Tc*)1)); sf.pos=180399; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Vindent6, ((Tc*)&YGO0), Vtype, ((Tc*)&Yvyf), (Tc*)1)); sf.pos=180400; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Y9a))); } sf.pos=180401; } } sf.pos=180402; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Vindent4, ((Tc*)&YD3Q), (t0 = Amsg->Vname))); sf.pos=180403; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Vindent6, ((Tc*)&YZ35), (t0 = Amsg->Vname), ((Tc*)&YNfH), (Tc*)1)); sf.pos=180404; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Y9a))); sf.pos=180405; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Vindent4, ((Tc*)&Y8OQ), (t0 = Amsg->Vname))); sf.pos=180406; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Vindent6, ((Tc*)&YZ35), (t0 = Amsg->Vname), ((Tc*)&Y55l), (Tc*)1)); sf.pos=180407; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Y9a))); sf.pos=180408; { Tfl Zf15i; Zf15 = Amsg->Vitems; Zf15i.l = Zf15; Zf15i.valp = (void*)&Vitem2; Zf15i.i = 0; for (; ZforListIobjCont(&Zf15i); ) { sf.pos=180409; if ((Vitem2).type == 0) { sf.pos=180410; Y8RG(((Y2Kp *)Znio(0, 180412, (Vitem2))), Aout, Vindent4); } sf.pos=180413; } } sf.pos=180414; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent2, ((Tc*)&Y9a))); sf.pos=180415; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); topFrame = sf.prev; return; } void YHzx(Tc *Atype, Tc *AretType, Tl *Afields, Tc *Adefault, Tc *Aindent, Tr Aout) { Tb VhasRep; Tb VhasNotRep; Tb VdidSet; Zsf sf; Tl *Zf1 = NULL; Tl *Zf3 = NULL; Y0uC *Vf = 0; Tc *VmemberName = NULL; Tl *Zf4 = NULL; Y0uC *Vf1 = 0; Tc *VmemberName1 = NULL; Tl *Zf41 = NULL; Y0uC *Vf2 = 0; Tc *VmemberName2 = NULL; Tc *VhasName = NULL; Tl *Zf5 = NULL; Y0uC *Vf3 = 0; Tc *VmemberName3 = NULL; Tl *t0 = NULL; Tc *t1 = NULL; Tc *t2 = NULL; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=5940800; VhasRep = YTU9(Afields); sf.pos=5940801; VhasNotRep = YADt(Afields); VdidSet = 0; sf.pos=5940802; { Ti Vrepeated; Tfl Zf1i; Zf1 = (t0 = ZnewList((Tt*)&bool__T, 2), ZLap((Tl*)t0, (Tz)(Ti)0), ZLap((Tl*)t0, (Tz)(Ti)1)); Zf1i.l = Zf1; Zf1i.valp = (void*)&Vrepeated; Zf1i.i = 0; for (; ZforListIntCont(&Zf1i); ) { sf.pos=5940803; if ((((!(Vrepeated) && VhasNotRep)) || ((Vrepeated && VhasRep)))) { sf.pos=5940804; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YMja), Atype, ((Tc*)&YQBH), (Tc*)1)); sf.pos=5940805; if (Vrepeated) { sf.pos=5940806; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ((Tc*)&YNcD)); } sf.pos=5940807; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(((Tc*)&Ypca), AretType, ((Tc*)&YYx8))); sf.pos=5940808; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y3Rg))); sf.pos=5940809; { Tfl Zf3i; Zf3 = Afields; Zf3i.l = Zf3; Zf3i.valp = (void*)&Vf; Zf3i.i = 0; for (; ZforListPtrCont(&Zf3i); ) { sf.pos=5940810; if ((Vf->Vrepeated == Vrepeated)) { sf.pos=5940811; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&Y4Qg), (t1 = Zint2string(Vf->Vnr)), ((Tc*)&YBII), (Tc*)1)); sf.pos=5940812; VmemberName = YULH(Vf); sf.pos=5940813; if (Vrepeated) { sf.pos=5940814; VmemberName = ZcS(VmemberName, ((Tc*)&YxsN)); } sf.pos=5940815; if ((ZstringCmp(Atype, ((Tc*)&Y89Q)) == 0)) { sf.pos=5940816; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(((Tc*)&YbT7), Vf->VtypeName, ((Tc*)&Y14u), VmemberName, ((Tc*)&YEa))); } else { sf.pos=5940817; if (((ZstringCmp(Atype, ((Tc*)&YtPw)) == 0) && !(Vf->Vrepeated))) { sf.pos=5940818; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(VmemberName, ((Tc*)&Y9Ud))); } else { sf.pos=5940819; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, VmemberName); } } } sf.pos=5940820; } } sf.pos=5940821; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YVet))); sf.pos=5940822; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Aindent, ((Tc*)&YKKn), Adefault)); sf.pos=5940823; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); sf.pos=5940824; if ((ZstringCmp(Atype, ((Tc*)&Y89Q)) == 0)) { sf.pos=5940825; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YTzv))); sf.pos=5940826; if (Vrepeated) { sf.pos=5940827; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ((Tc*)&YNcD)); } sf.pos=5940828; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ((Tc*)&Y5Bw)); sf.pos=5940829; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YBXc))); sf.pos=5940830; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y3Rg))); sf.pos=5940831; { Tfl Zf4i; Zf4 = Afields; Zf4i.l = Zf4; Zf4i.valp = (void*)&Vf1; Zf4i.i = 0; for (; ZforListPtrCont(&Zf4i); ) { sf.pos=5940832; if ((Vf1->Vrepeated == Vrepeated)) { sf.pos=5940833; VmemberName1 = YULH(Vf1); sf.pos=5940834; if (Vrepeated) { sf.pos=5940835; VmemberName1 = ZcS(VmemberName1, ((Tc*)&YxsN)); } sf.pos=5940836; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&Y4Qg), (t1 = Zint2string(Vf1->Vnr)), ((Tc*)&YuV2), (Tc*)1)); sf.pos=5940837; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(VmemberName1, ((Tc*)&YgZi))); } sf.pos=5940838; } } sf.pos=5940839; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YVet))); sf.pos=5940840; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YfaF))); sf.pos=5940841; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); } sf.pos=5940842; if (!(VdidSet)) { sf.pos=5940843; VdidSet = 1; sf.pos=5940844; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YmYN), Atype, ((Tc*)&Y5KZ), (Tc*)1)); sf.pos=5940845; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(AretType, ((Tc*)&YmiC))); sf.pos=5940846; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y3Rg))); sf.pos=5940847; { Tfl Zf41i; Zf41 = Afields; Zf41i.l = Zf41; Zf41i.valp = (void*)&Vf2; Zf41i.i = 0; for (; ZforListPtrCont(&Zf41i); ) { sf.pos=5940848; VmemberName2 = YULH(Vf2); sf.pos=5940849; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&Y4Qg), (t1 = Zint2string(Vf2->Vnr)), ((Tc*)&YgFa), (Tc*)1)); sf.pos=5940850; if (Vf2->Vrepeated) { sf.pos=5940851; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS3(((Tc*)&YO9t), YqGL(Vf2), ((Tc*)&YO))); } else { sf.pos=5940852; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS(VmemberName2, ((Tc*)&YWXt))); } sf.pos=5940853; if ((ZstringCmp(Atype, ((Tc*)&Y89Q)) == 0)) { sf.pos=5940854; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS8(((Tc*)&Yxtk), Vf2->VtypeName, ((Tc*)&YoJI), ((Tc*)&Yxtk), (t1 = Vf2->VtypeName), ((Tc*)&Y9CL), (t2 = Vf2->VtypeName), ((Tc*)&YW8X))); } else { sf.pos=5940855; if (Vf2->Vrepeated) { sf.pos=5940856; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ((Tc*)&Y37y)); } else { sf.pos=5940857; if ((ZstringCmp(Atype, ((Tc*)&YtPw)) == 0)) { sf.pos=5940858; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ((Tc*)&YHfx)); } else { sf.pos=5940859; VhasName = YFlx(Vf2); sf.pos=5940860; if ((VhasName != NULL)) { sf.pos=5940861; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS3(((Tc*)&YPKf), VhasName, ((Tc*)&YKf1))); } else { sf.pos=5940862; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ((Tc*)&Y37y)); } } }} sf.pos=5940863; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ((Vf2->Vrepeated) ? (((Tc*)&YP)) : (((Tc*)&Ya)))); sf.pos=5940864; } } sf.pos=5940865; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YVet))); sf.pos=5940866; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); sf.pos=5940867; if ((ZstringCmp(Atype, ((Tc*)&Y89Q)) == 0)) { sf.pos=5940868; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, Aindent); sf.pos=5940869; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ((Tc*)&Ygbr)); sf.pos=5940870; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, Aindent); sf.pos=5940871; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ((Tc*)&Y3Rg)); sf.pos=5940872; { Tfl Zf5i; Zf5 = Afields; Zf5i.l = Zf5; Zf5i.valp = (void*)&Vf3; Zf5i.i = 0; for (; ZforListPtrCont(&Zf5i); ) { sf.pos=5940873; VmemberName3 = YULH(Vf3); sf.pos=5940874; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, Aindent); sf.pos=5940875; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS3(((Tc*)&Y4Qg), Zint2string(Vf3->Vnr), ((Tc*)&YgFa))); sf.pos=5940876; if (Vf3->Vrepeated) { sf.pos=5940877; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS3(((Tc*)&YO9t), YqGL(Vf3), ((Tc*)&YO))); } else { sf.pos=5940878; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS(VmemberName3, ((Tc*)&YWXt))); } sf.pos=5940879; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vf3->VtypeName, ((Tc*)&Y4s5))); sf.pos=5940880; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ((Vf3->Vrepeated) ? (((Tc*)&YP)) : (((Tc*)&Ya)))); sf.pos=5940881; } } sf.pos=5940882; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YVet))); sf.pos=5940883; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); } } } sf.pos=5940884; } } topFrame = sf.prev; return; } Tb YTU9(Tl *Afields) { Zsf sf; Tb r = 0; Tl *Zf1 = NULL; Y0uC *Vf = 0; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=175500; { Tfl Zf1i; Zf1 = Afields; Zf1i.l = Zf1; Zf1i.valp = (void*)&Vf; Zf1i.i = 0; for (; ZforListPtrCont(&Zf1i); ) { sf.pos=175501; if (Vf->Vrepeated) { sf.pos=175502; r = 1; rt = 1; goto Y6d1; } Y6d1: if (rt) goto Ygal; sf.pos=175503; } } sf.pos=175504; r = 0; Ygal: topFrame = sf.prev; return r; } Tb YADt(Tl *Afields) { Zsf sf; Tb r = 0; Tl *Zf1 = NULL; Y0uC *Vf = 0; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=1080000; { Tfl Zf1i; Zf1 = Afields; Zf1i.l = Zf1; Zf1i.valp = (void*)&Vf; Zf1i.i = 0; for (; ZforListPtrCont(&Zf1i); ) { sf.pos=1080001; if (!(Vf->Vrepeated)) { sf.pos=1080002; r = 1; rt = 1; goto YK5W; } YK5W: if (rt) goto YnNd; sf.pos=1080003; } } sf.pos=1080004; r = 0; YnNd: topFrame = sf.prev; return r; } void YwAg(Tl *Afields, Tc *Aindent, Tr Aout) { Tb VhasRep; Tb VhasNotRep; Tb VdidMerge; Zsf sf; Tl *Zf1 = NULL; Tl *Zf3 = NULL; Y0uC *Vf = 0; Tl *Zf31 = NULL; Y0uC *Vf1 = 0; Tc *Vindent6 = NULL; Tl *Zf4 = NULL; Y0uC *Vf2 = 0; Tl *t0 = NULL; Tc *t1 = NULL; Tc *t2 = NULL; Tc *t3 = NULL; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=3741100; VhasRep = YTU9(Afields); sf.pos=3741101; VhasNotRep = YADt(Afields); VdidMerge = 0; sf.pos=3741102; { Ti Vrepeated; Tfl Zf1i; Zf1 = (t0 = ZnewList((Tt*)&bool__T, 2), ZLap((Tl*)t0, (Tz)(Ti)0), ZLap((Tl*)t0, (Tz)(Ti)1)); Zf1i.l = Zf1; Zf1i.valp = (void*)&Vrepeated; Zf1i.i = 0; for (; ZforListIntCont(&Zf1i); ) { sf.pos=3741103; if ((((!(Vrepeated) && VhasNotRep)) || ((Vrepeated && VhasRep)))) { sf.pos=3741104; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YO3G))); sf.pos=3741105; if (Vrepeated) { sf.pos=3741106; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ((Tc*)&YNcD)); } sf.pos=3741107; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ((Tc*)&YRua)); sf.pos=3741108; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y3Rg))); sf.pos=3741109; { Tfl Zf3i; Zf3 = Afields; Zf3i.l = Zf3; Zf3i.valp = (void*)&Vf; Zf3i.i = 0; for (; ZforListPtrCont(&Zf3i); ) { sf.pos=3741110; if ((Vf->Vrepeated == Vrepeated)) { sf.pos=3741111; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&Y4Qg), (t1 = Zint2string(Vf->Vnr)), ((Tc*)&YBII), (t2 = YULH(Vf)))); sf.pos=3741112; if (Vrepeated) { sf.pos=3741113; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ((Tc*)&YxsN)); } sf.pos=3741114; ((Ts (*)(void*))(Aout.table[18]))(Aout.ptr); } sf.pos=3741115; } } sf.pos=3741116; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YVet))); sf.pos=3741117; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Yzrg))); sf.pos=3741118; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); sf.pos=3741119; if (Vrepeated) { sf.pos=3741120; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YhqR))); } else { sf.pos=3741121; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YfRA))); } sf.pos=3741122; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y3Rg))); sf.pos=3741123; { Tfl Zf31i; Zf31 = Afields; Zf31i.l = Zf31; Zf31i.valp = (void*)&Vf1; Zf31i.i = 0; for (; ZforListPtrCont(&Zf31i); ) { sf.pos=3741124; if ((Vf1->Vrepeated == Vrepeated)) { sf.pos=3741125; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&Y4Qg), (t1 = Zint2string(Vf1->Vnr)), ((Tc*)&YgFa), (Tc*)1)); sf.pos=3741126; if (Vrepeated) { sf.pos=3741127; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS3(((Tc*)&Y6y9), YULH(Vf1), ((Tc*)&YNM4))); sf.pos=3741128; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(YULH(Vf1), ((Tc*)&YI0U))); sf.pos=3741129; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YR8A), (t1 = YULH(Vf1)), ((Tc*)&YVtc), (Tc*)1)); } else { sf.pos=3741130; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(YULH(Vf1), ((Tc*)&YRyv))); } } sf.pos=3741131; } } sf.pos=3741132; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YVet))); sf.pos=3741133; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); sf.pos=3741134; if (!(VdidMerge)) { sf.pos=3741135; VdidMerge = 1; sf.pos=3741136; ((Ts (*)(void*, Tc*))(Aout.table[1]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YfXS))); sf.pos=3741137; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ((Tc*)&Yf3o)); sf.pos=3741138; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y3Rg))); sf.pos=3741139; Vindent6 = ZcS(Aindent, ((Tc*)&Ya8x)); sf.pos=3741140; { Tfl Zf4i; Zf4 = Afields; Zf4i.l = Zf4; Zf4i.valp = (void*)&Vf2; Zf4i.i = 0; for (; ZforListPtrCont(&Zf4i); ) { sf.pos=3741141; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Aindent, ((Tc*)&Y4Qg), (t1 = Zint2string(Vf2->Vnr)))); sf.pos=3741142; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Vindent6, ((Tc*)&Y6y9), (t1 = YULH(Vf2)), ((Tc*)&YgCk), (Tc*)1)); sf.pos=3741143; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Vindent6, ((Tc*)&YZY), (t1 = YULH(Vf2)), ((Tc*)&YII0), (Tc*)1)); sf.pos=3741144; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent6, ((Tc*)&Y9a))); sf.pos=3741145; if (Vf2->Vrepeated) { sf.pos=3741146; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Vindent6, Vf2->VtypeName, ((Tc*)&Yi_6))); sf.pos=3741147; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Vindent6, YULH(Vf2), ((Tc*)&YVtc))); sf.pos=3741148; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent6, ((Tc*)&Yt1y))); sf.pos=3741149; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent6, ((Tc*)&YU62))); } else { sf.pos=3741150; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Vindent6, ((Tc*)&YG9J), (t1 = YULH(Vf2)), ((Tc*)&YP), (Tc*)1)); sf.pos=3741151; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Vindent6, YULH(Vf2), ((Tc*)&YDFV))); } sf.pos=3741152; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent6, ((Tc*)&YdMU))); sf.pos=3741153; } } sf.pos=3741154; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YVet))); sf.pos=3741155; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YwAl))); sf.pos=3741156; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); } } sf.pos=3741157; } } topFrame = sf.prev; return; } void YYCV(Tl *Afields, Tc *Aindent, Tr Aout) { Zsf sf; Tl *Zf1 = NULL; Y0uC *Vf = 0; Tc *t0 = NULL; Tc *t1 = NULL; Tc *t2 = NULL; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=8513200; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YpN1))); sf.pos=8513201; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y3Rg))); sf.pos=8513202; { Tfl Zf1i; Zf1 = Afields; Zf1i.l = Zf1; Zf1i.valp = (void*)&Vf; Zf1i.i = 0; for (; ZforListPtrCont(&Zf1i); ) { sf.pos=8513203; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&Y4Qg), (t0 = Zint2string(Vf->Vnr)), ((Tc*)&YpgF), (t1 = YqGL(Vf)), ((Tc*)&YXaa), (Tc*)1, (Tc*)1)); sf.pos=8513204; } } sf.pos=8513205; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YVet))); sf.pos=8513206; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YwAl))); sf.pos=8513207; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); topFrame = sf.prev; return; } void Yg8t(YRAB *Amsg, Tc *Aindent, Tr Aout) { Zsf sf; Tc *Vindent2 = NULL; Tl *Zf1 = NULL; Y0uC *Vf = 0; Tc *VmemberName = NULL; Tc *VhasName = NULL; Tc *VindentX = NULL; Tc *t0 = NULL; Tc *t1 = NULL; Tc *t2 = NULL; Tc *t3 = NULL; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=7547500; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Aindent, ((Tc*)&YcuF), (t0 = Amsg->Vname))); sf.pos=7547501; Vindent2 = ZcS(Aindent, ((Tc*)&YZY)); sf.pos=7547502; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Vindent2, Amsg->Vname, ((Tc*)&YEsj))); sf.pos=7547503; { Tfl Zf1i; Zf1 = Amsg->Vfields; Zf1i.l = Zf1; Zf1i.valp = (void*)&Vf; Zf1i.i = 0; for (; ZforListPtrCont(&Zf1i); ) { sf.pos=7547504; VmemberName = ZstringSlice(YULH(Vf), 1, -1, 0); sf.pos=7547505; VhasName = YFlx(Vf); sf.pos=7547506; VindentX = Vindent2; sf.pos=7547507; if ((VhasName != NULL)) { sf.pos=7547508; VindentX = ZcS(VindentX, ((Tc*)&YZY)); sf.pos=7547509; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Vindent2, ((Tc*)&Y6y9), VhasName)); sf.pos=7547510; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(VindentX, ((Tc*)&Y2C2), (t0 = ZstringSlice(VhasName, 1, -1, 0)), ((Tc*)&YKf1), (Tc*)1)); } sf.pos=7547511; if (Vf->Vrepeated) { sf.pos=7547512; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(VindentX, ((Tc*)&YGbi))); sf.pos=7547513; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(VindentX, ((Tc*)&YiHe), (t0 = YULH(Vf)), ((Tc*)&Y2Nk), (Tc*)1)); sf.pos=7547514; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(VindentX, ((Tc*)&Y5Fk), VmemberName, ((Tc*)&YII0), (Tc*)1)); sf.pos=7547515; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(VindentX, ((Tc*)&YAGs), (t0 = YULH(Vf)))); sf.pos=7547516; if ((Vf->Vtype == 12)) { sf.pos=7547517; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(VindentX, ((Tc*)&YO9y), VmemberName, ((Tc*)&YR9A), (Tc*)1)); } else { sf.pos=7547518; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(VindentX, ((Tc*)&YO9y), VmemberName, ((Tc*)&Yvnc), (Tc*)1)); } sf.pos=7547519; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(VindentX, ((Tc*)&Y6my))); sf.pos=7547520; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(VindentX, ((Tc*)&YVet))); sf.pos=7547521; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(VindentX, ((Tc*)&Yc7A))); sf.pos=7547522; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(VindentX, ((Tc*)&YhLg), VmemberName, ((Tc*)&YWXt), (t0 = YULH(Vf)))); sf.pos=7547523; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(VindentX, ((Tc*)&Y9a))); } else { sf.pos=7547524; if ((Vf->Vtype == 12)) { sf.pos=7547525; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(VindentX, ((Tc*)&Y6y9), (t0 = YULH(Vf)), ((Tc*)&Y2Nk), (Tc*)1)); sf.pos=7547526; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(VindentX, ((Tc*)&YhLg), VmemberName, ((Tc*)&YRQE), (t0 = YULH(Vf)), ((Tc*)&Ybf2), (t2 = YULH(Vf)), (Tc*)1)); sf.pos=7547527; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(VindentX, ((Tc*)&Y9a))); } else { sf.pos=7547528; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(VindentX, ((Tc*)&Y2C2), VmemberName, ((Tc*)&YWXt), (t0 = YULH(Vf)))); } } sf.pos=7547529; if ((VhasName != NULL)) { sf.pos=7547530; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent2, ((Tc*)&Y9a))); } sf.pos=7547531; } } sf.pos=7547532; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent2, ((Tc*)&Yxe8))); sf.pos=7547533; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); topFrame = sf.prev; return; } void Ycma(Tl *Afields, Tc *Aindent, Tr Aout) { Zsf sf; Tl *Zf1 = NULL; Y0uC *Vf = 0; Tc *t0 = NULL; Tc *t1 = NULL; Tc *t2 = NULL; Tc *t3 = NULL; Tc *t4 = NULL; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=2007500; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YvCR))); sf.pos=2007501; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y3Rg))); sf.pos=2007502; { Tfl Zf1i; Zf1 = Afields; Zf1i.l = Zf1; Zf1i.valp = (void*)&Vf; Zf1i.i = 0; for (; ZforListPtrCont(&Zf1i); ) { sf.pos=2007503; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&Y4Qg), (t0 = Zint2string(Vf->Vnr)), ((Tc*)&YBII), (t1 = YULH(Vf)), ((Tc*)&YG_R), (t3 = YULH(Vf)), ((Tc*)&YZY7))); sf.pos=2007504; } } sf.pos=2007505; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YVet))); sf.pos=2007506; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Yc_G))); sf.pos=2007507; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); topFrame = sf.prev; return; } void YMWy(Tl *Afields, Tc *Aindent, Tr Aout) { Zsf sf; Tl *Zf1 = NULL; Y0uC *Vfield = 0; Tc *t0 = NULL; Tc *t1 = NULL; Tc *t2 = NULL; Tc *t3 = NULL; Tc *t4 = NULL; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=4924000; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YMvm))); sf.pos=4924001; { Tfl Zf1i; Zf1 = Afields; Zf1i.l = Zf1; Zf1i.valp = (void*)&Vfield; Zf1i.i = 0; for (; ZforListPtrCont(&Zf1i); ) { sf.pos=4924002; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS12(Aindent, ((Tc*)&YQgq), (t0 = Vfield->Vname), ((Tc*)&YwFy), (t1 = Zint2string(Vfield->Vnr)), ((Tc*)&YqQF), (t2 = Zenum2string(MProto__EType, Vfield->Vtype)), ((Tc*)&Ydha), (t4 = Zbool2string(Vfield->Vrepeated)), ((Tc*)&YBca), (Tc*)1, (Tc*)1)); sf.pos=4924003; } } sf.pos=4924004; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YEa))); topFrame = sf.prev; return; } void Y1M2(Tc *Aclass, Y0uC *Afield, Tc *Atype, Tc *AinitVal, Tc *AdefaultVal, Tc *Aindent, Tr Aout) { Zsf sf; Tc *VmemberName = NULL; Tc *VfuncName = NULL; Tc *VhasName = NULL; Tc *t0 = NULL; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=2147600; VmemberName = YULH(Afield); sf.pos=2147601; VfuncName = YqGL(Afield); sf.pos=2147602; VhasName = YFlx(Afield); sf.pos=2147603; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&Yctj), VfuncName, ((Tc*)&YO), Atype, ((Tc*)&YxgQ), Aclass, ((Tc*)&YNOm))); sf.pos=2147604; if ((ZstringCmp(Atype, ((Tc*)&YtPw)) == 0)) { sf.pos=2147605; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YZY), VmemberName, ((Tc*)&Ybd2), (Tc*)1)); } else { sf.pos=2147606; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YZY), VmemberName, ((Tc*)&Y_yv), (Tc*)1)); } sf.pos=2147607; if ((VhasName != NULL)) { sf.pos=2147608; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YZY), VhasName, ((Tc*)&YKf1), (Tc*)1)); } sf.pos=2147609; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YYwn))); sf.pos=2147610; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); sf.pos=2147611; if ((Afield->Vtype == 12)) { sf.pos=2147612; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YEC6), VfuncName, ((Tc*)&Ye0N), Atype)); sf.pos=2147613; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YZY), VmemberName, ((Tc*)&YII0), (Tc*)1)); sf.pos=2147614; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Aindent, ((Tc*)&YKKn), VmemberName)); sf.pos=2147615; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); } sf.pos=2147616; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&Y9CPa), VfuncName, ((Tc*)&Ye0N), Atype, ((Tc*)&YNOm), (Tc*)1, (Tc*)1)); sf.pos=2147617; if ((VhasName != NULL)) { sf.pos=2147618; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Aindent, ((Tc*)&YwS1), VhasName)); } else { sf.pos=2147619; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YiHe), VmemberName, ((Tc*)&Y7gw), AinitVal)); } sf.pos=2147620; if ((Afield->Vdefault != NULL)) { sf.pos=2147621; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Aindent, ((Tc*)&YG_k), AdefaultVal)); } else { sf.pos=2147622; if ((ZstringCmp(Atype, ((Tc*)&YtPw)) == 0)) { sf.pos=2147623; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YQIB))); } else { sf.pos=2147624; if ((ZstringCmp(Atype, ((Tc*)&YanE)) == 0)) { sf.pos=2147625; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YJGx))); } else { sf.pos=2147626; if (((((ZstringCmp(Atype, ((Tc*)&Y1Qt)) == 0) || (ZstringCmp(Atype, ((Tc*)&YrQi)) == 0)) || (ZstringCmp(Atype, ((Tc*)&YNmG)) == 0)) || (ZstringCmp(Atype, ((Tc*)&YDFy)) == 0))) { sf.pos=2147627; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YzWb))); } else { sf.pos=2147628; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YdiJ), (t0 = Afield->Vname), ((Tc*)&YTKi), (Tc*)1)); } }}} sf.pos=2147629; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YVet))); sf.pos=2147630; if ((ZstringCmp(Atype, ((Tc*)&YtPw)) == 0)) { sf.pos=2147631; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YKKn), VmemberName, ((Tc*)&Y9Ud), (Tc*)1)); } else { sf.pos=2147632; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Aindent, ((Tc*)&YKKn), VmemberName)); } sf.pos=2147633; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); sf.pos=2147634; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YE5R), VfuncName, ((Tc*)&YBMj), (Tc*)1)); sf.pos=2147635; if ((VhasName != NULL)) { sf.pos=2147636; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Aindent, ((Tc*)&YKKn), VhasName)); } else { sf.pos=2147637; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YKKn), VmemberName, ((Tc*)&Yljn), AinitVal)); } sf.pos=2147638; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); sf.pos=2147639; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&YnyF), VfuncName, ((Tc*)&Ye0N), Aclass, ((Tc*)&YNOm), (Tc*)1, (Tc*)1)); sf.pos=2147640; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YZY), VmemberName, ((Tc*)&YWXt), AinitVal)); sf.pos=2147641; if ((VhasName != NULL)) { sf.pos=2147642; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YZY), VhasName, ((Tc*)&YRRN), (Tc*)1)); } sf.pos=2147643; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YYwn))); sf.pos=2147644; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); topFrame = sf.prev; return; } void YsmR(Tc *Aclass, Y0uC *Afield, Tc *Atype, Tc *AdefaultVal, Tc *Aindent, Tr Aout) { Zsf sf; Tc *VmemberName = NULL; Tc *VfuncName = NULL; Tc *t0 = NULL; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=2426900; VmemberName = YULH(Afield); sf.pos=2426901; VfuncName = YqGL(Afield); sf.pos=2426902; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&YMaA), VfuncName, ((Tc*)&YO), Atype, ((Tc*)&YxgQ), Aclass, (Tc*)1)); sf.pos=2426903; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YiHe), VmemberName, ((Tc*)&YgCk), (Tc*)1)); sf.pos=2426904; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YW_j), VmemberName, ((Tc*)&YII0), (Tc*)1)); sf.pos=2426905; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YVet))); sf.pos=2426906; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YZY), VmemberName, ((Tc*)&YlIc), (Tc*)1)); sf.pos=2426907; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YYwn))); sf.pos=2426908; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); sf.pos=2426909; if ((Afield->Vtype == 12)) { sf.pos=2426910; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YEnH), VfuncName, ((Tc*)&Ye0N), Atype)); sf.pos=2426911; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YZY), Atype, ((Tc*)&Y0_k), (Tc*)1)); sf.pos=2426912; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&Y2hI), VfuncName, ((Tc*)&YPYP), (Tc*)1)); sf.pos=2426913; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y5YG))); sf.pos=2426914; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); } sf.pos=2426915; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&Y9CPa), VfuncName, ((Tc*)&Y7in), Atype, ((Tc*)&YNOm), (Tc*)1, (Tc*)1)); sf.pos=2426916; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&YD5t), VmemberName, ((Tc*)&YAGJ), VmemberName, ((Tc*)&YZY7), (Tc*)1, (Tc*)1)); sf.pos=2426917; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YOn3), (t0 = Afield->Vname), ((Tc*)&YEpL), (Tc*)1)); sf.pos=2426918; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YVet))); sf.pos=2426919; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YKKn), VmemberName, ((Tc*)&YLJU), (Tc*)1)); sf.pos=2426920; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); sf.pos=2426921; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&Y9CPa), VfuncName, ((Tc*)&Ynjc), Atype, ((Tc*)&Yp5Q), (Tc*)1, (Tc*)1)); sf.pos=2426922; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Aindent, ((Tc*)&YKKn), VmemberName)); sf.pos=2426923; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); sf.pos=2426924; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&Yctj), VfuncName, ((Tc*)&YCj9), Atype, ((Tc*)&YWFy), Aclass, ((Tc*)&YNOm))); sf.pos=2426925; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YZY), VmemberName, ((Tc*)&YQyv), (Tc*)1)); sf.pos=2426926; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YYwn))); sf.pos=2426927; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); sf.pos=2426928; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YgyZ), VfuncName, ((Tc*)&Y3FL), (Tc*)1)); sf.pos=2426929; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&YKKn), VmemberName, ((Tc*)&YG_R), VmemberName, ((Tc*)&YZY7), (Tc*)1, (Tc*)1)); sf.pos=2426930; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); sf.pos=2426931; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YE5R), VfuncName, ((Tc*)&YBMj), (Tc*)1)); sf.pos=2426932; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&YKKn), VmemberName, ((Tc*)&YIgG), VmemberName, ((Tc*)&YW_F), (Tc*)1, (Tc*)1)); sf.pos=2426933; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); sf.pos=2426934; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YE5R), VfuncName, ((Tc*)&YwnZ), (Tc*)1)); sf.pos=2426935; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&YBWs), VmemberName, ((Tc*)&YEqC), VmemberName, ((Tc*)&YZY7), (Tc*)1, (Tc*)1)); sf.pos=2426936; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); sf.pos=2426937; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&YnyF), VfuncName, ((Tc*)&Ye0N), Aclass, ((Tc*)&YNOm), (Tc*)1, (Tc*)1)); sf.pos=2426938; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YZY), VmemberName, ((Tc*)&YsTa), (Tc*)1)); sf.pos=2426939; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YYwn))); sf.pos=2426940; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); topFrame = sf.prev; return; } void Yk4Q(YNW5 *Aservice, Tr Aout, Tc *Aindent) { Zsf sf; Tc *Vindent4 = NULL; Tl *Zf1 = NULL; YlM3 *Vrpc = 0; Tc *VdotName = NULL; Tc *Vcall = NULL; Tc *t0 = NULL; Tc *t1 = NULL; Tc *t2 = NULL; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=5413700; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(((Tc*)&Y9d4), ZstringToUpper(ZstringSlice(Aservice->Vname, 0, 0, 0)), (t0 = ZstringSlice(Aservice->Vname, 1, -1, 0)), ((Tc*)&Y7Qg), (Tc*)1)); sf.pos=5413701; Vindent4 = ZcS(Aindent, ((Tc*)&YW_j)); sf.pos=5413702; { Tfl Zf1i; Zf1 = Aservice->Vrpcs; Zf1i.l = Zf1; Zf1i.valp = (void*)&Vrpc; Zf1i.i = 0; for (; ZforListPtrCont(&Zf1i); ) { sf.pos=5413703; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&YZZg), (t0 = Vrpc->Vname), ((Tc*)&YO), (t1 = Vrpc->VrequestName), ((Tc*)&YOlD), (t2 = Vrpc->VresponseName), (Tc*)1)); sf.pos=5413704; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&YHny), (t0 = Vrpc->Vname), ((Tc*)&YO), (t1 = Vrpc->VrequestName), ((Tc*)&Y8Bf), ((Tc*)&YJ4N), ((Tc*)&Y84u))); sf.pos=5413705; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&YclF))); sf.pos=5413706; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Yzrg))); sf.pos=5413707; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Y9a))); sf.pos=5413708; VdotName = ZcS3(Aservice->Vname, ((Tc*)&YU), (t0 = Vrpc->Vname)); sf.pos=5413709; Vcall = ZcS3(((Tc*)&YI05), VdotName, ((Tc*)&YnFL)); sf.pos=5413710; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&YQuz))); sf.pos=5413711; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Vindent4, Vcall, (t0 = Vrpc->VresponseName), ((Tc*)&Y9Ba), (Tc*)1)); sf.pos=5413712; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&YKC8))); sf.pos=5413713; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Vindent4, Vcall, ((Tc*)&YZeO), (t0 = Vrpc->VresponseName), ((Tc*)&YihP))); sf.pos=5413714; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Yuso))); sf.pos=5413715; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Yzrg))); sf.pos=5413716; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Vindent4, ((Tc*)&Y9a))); sf.pos=5413717; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YVet))); sf.pos=5413718; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YIzR))); sf.pos=5413719; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS12(Vindent4, ((Tc*)&Yhls), (t0 = Vrpc->Vname), ((Tc*)&YBI0), VdotName, ((Tc*)&YwFy), (t1 = Vrpc->VrequestName), ((Tc*)&YJQW), (t2 = Vrpc->VresponseName), ((Tc*)&YNbo), (Tc*)1, (Tc*)1)); sf.pos=5413720; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YVet))); sf.pos=5413721; } } sf.pos=5413722; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ((Tc*)&YVet)); topFrame = sf.prev; return; } void Y8RG(Y2Kp *Aenum, Tr Aout, Tc *Aindent) { Zsf sf; Tl *Zf1 = NULL; Tl *Zf11 = NULL; Tl *Zf12 = NULL; YFk1 *Vm = 0; YFk1 *Vm1 = 0; YFk1 *Vm2 = 0; Tc *t0 = NULL; Tc *t1 = NULL; Tc *t2 = NULL; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=4516900; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&Ywwj), (t0 = Aenum->Vname), ((Tc*)&YAId), (Tc*)1)); sf.pos=4516901; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YXRY))); sf.pos=4516902; { Tfl Zf1i; Zf1 = Aenum->Vmembers; Zf1i.l = Zf1; Zf1i.valp = (void*)&Vm; Zf1i.i = 0; for (; ZforListPtrCont(&Zf1i); ) { sf.pos=4516903; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS3(Aindent, ((Tc*)&Yxet), (t0 = Vm->Vid))); sf.pos=4516904; } } sf.pos=4516905; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&Y9a))); sf.pos=4516906; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&Yfpd), (t0 = Aenum->Vname), ((Tc*)&Yj9U), (t1 = Aenum->Vname), ((Tc*)&Y9UL), (Tc*)1, (Tc*)1)); sf.pos=4516907; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS5(Aindent, ((Tc*)&YZY), (t0 = Aenum->Vname), ((Tc*)&Yu8y), (Tc*)1)); sf.pos=4516908; { Tfl Zf11i; Zf11 = Aenum->Vmembers; Zf11i.l = Zf11; Zf11i.valp = (void*)&Vm1; Zf11i.i = 0; for (; ZforListPtrCont(&Zf11i); ) { sf.pos=4516909; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&YZY), (t0 = Aenum->Vname), ((Tc*)&Ywla), (t1 = Vm1->Vid), ((Tc*)&YFDa), (t2 = Zint2string(Vm1->Vnr)), ((Tc*)&YS))); sf.pos=4516910; } } sf.pos=4516911; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YEa))); sf.pos=4516912; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&Yxa6), (t0 = Aenum->Vname), ((Tc*)&Y9oy), (t1 = Aenum->Vname), ((Tc*)&Yzyv), (Tc*)1, (Tc*)1)); sf.pos=4516913; { Tfl Zf12i; Zf12 = Aenum->Vmembers; Zf12i.l = Zf12; Zf12i.valp = (void*)&Vm2; Zf12i.i = 0; for (; ZforListPtrCont(&Zf12i); ) { sf.pos=4516914; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS8(Aindent, ((Tc*)&YZY), (t0 = Zint2string(Vm2->Vnr)), ((Tc*)&YFDa), (t1 = Aenum->Vname), ((Tc*)&Ywla), (t2 = Vm2->Vid), ((Tc*)&YS))); sf.pos=4516915; } } sf.pos=4516916; ((Ts (*)(void*, Tc*))(Aout.table[11]))(Aout.ptr, ZcS(Aindent, ((Tc*)&YEa))); topFrame = sf.prev; return; } void YCOQ(Tc *AinFileName, Tc *AoutFileName) { Zsf sf; Tr Vout = {NULL}; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; sf.pos=142200; Vout = YiBk(AoutFileName, 1); sf.pos=142201; if ((((Vout).ptr) == NULL)) { sf.pos=142202; Yl0k(ZcS(((Tc*)&Y32K), AoutFileName)); sf.pos=142203; Zexit(NULL, 1); } sf.pos=142204; ((Ts (*)(void*, Tc*))(Vout.table[11]))(Vout.ptr, ZcS(((Tc*)&YK3s), AinFileName)); sf.pos=142205; ((Ts (*)(void*))(Vout.table[35]))(Vout.ptr); topFrame = sf.prev; return; } /* WriteZimbu done */ /* * INIT IMT */ void ZimtInit(void) { { Ytlm *p = 0; ToYtlm[1].off = (int)((Tc*)&p->Vmessage - (Tc*)p); ToYtlm[2].off = (int)((Tc*)&p->Vpos - (Tc*)p); ToYtlm[3].off = (int)((Tc*)&p->Vbacktrace - (Tc*)p); } { YEro *p = 0; ToYEro[1].off = (int)((Tc*)&p->Vmessage - (Tc*)p); ToYEro[2].off = (int)((Tc*)&p->Vpos - (Tc*)p); ToYEro[3].off = (int)((Tc*)&p->Vbacktrace - (Tc*)p); } { YKhn *p = 0; YKhn__Ytlm_I_imt[1] = (Tc*)((Tc*)&p->Vmessage - (Tc*)p); YKhn__Ytlm_I_imt[2] = (Tc*)((Tc*)&p->Vpos - (Tc*)p); YKhn__Ytlm_I_imt[3] = (Tc*)((Tc*)&p->Vbacktrace - (Tc*)p); ToYKhn[1].off = (int)((Tc*)&p->Vmessage - (Tc*)p); ToYKhn[2].off = (int)((Tc*)&p->Vpos - (Tc*)p); ToYKhn[3].off = (int)((Tc*)&p->Vbacktrace - (Tc*)p); } { Y1uN *p = 0; Y1uN__Ytlm_I_imt[1] = (Tc*)((Tc*)&p->Vmessage - (Tc*)p); Y1uN__Ytlm_I_imt[2] = (Tc*)((Tc*)&p->Vpos - (Tc*)p); Y1uN__Ytlm_I_imt[3] = (Tc*)((Tc*)&p->Vbacktrace - (Tc*)p); ToY1uN[1].off = (int)((Tc*)&p->Vmessage - (Tc*)p); ToY1uN[2].off = (int)((Tc*)&p->Vpos - (Tc*)p); ToY1uN[3].off = (int)((Tc*)&p->Vbacktrace - (Tc*)p); } { YAxe *p = 0; YAxe__Ytlm_I_imt[1] = (Tc*)((Tc*)&p->Vmessage - (Tc*)p); YAxe__Ytlm_I_imt[2] = (Tc*)((Tc*)&p->Vpos - (Tc*)p); YAxe__Ytlm_I_imt[3] = (Tc*)((Tc*)&p->Vbacktrace - (Tc*)p); ToYAxe[1].off = (int)((Tc*)&p->Vmessage - (Tc*)p); ToYAxe[2].off = (int)((Tc*)&p->Vpos - (Tc*)p); ToYAxe[3].off = (int)((Tc*)&p->Vbacktrace - (Tc*)p); } { YVNj *p = 0; YVNj__Ytlm_I_imt[1] = (Tc*)((Tc*)&p->Vmessage - (Tc*)p); YVNj__Ytlm_I_imt[2] = (Tc*)((Tc*)&p->Vpos - (Tc*)p); YVNj__Ytlm_I_imt[3] = (Tc*)((Tc*)&p->Vbacktrace - (Tc*)p); ToYVNj[1].off = (int)((Tc*)&p->Vmessage - (Tc*)p); ToYVNj[2].off = (int)((Tc*)&p->Vpos - (Tc*)p); ToYVNj[3].off = (int)((Tc*)&p->Vbacktrace - (Tc*)p); } { Yalz *p = 0; Yalz__Ytlm_I_imt[1] = (Tc*)((Tc*)&p->Vmessage - (Tc*)p); Yalz__Ytlm_I_imt[2] = (Tc*)((Tc*)&p->Vpos - (Tc*)p); Yalz__Ytlm_I_imt[3] = (Tc*)((Tc*)&p->Vbacktrace - (Tc*)p); ToYalz[1].off = (int)((Tc*)&p->Vmessage - (Tc*)p); ToYalz[2].off = (int)((Tc*)&p->Vpos - (Tc*)p); ToYalz[3].off = (int)((Tc*)&p->Vbacktrace - (Tc*)p); } { Yw3O *p = 0; Yw3O__Ytlm_I_imt[1] = (Tc*)((Tc*)&p->Vmessage - (Tc*)p); Yw3O__Ytlm_I_imt[2] = (Tc*)((Tc*)&p->Vpos - (Tc*)p); Yw3O__Ytlm_I_imt[3] = (Tc*)((Tc*)&p->Vbacktrace - (Tc*)p); ToYw3O[1].off = (int)((Tc*)&p->Vmessage - (Tc*)p); ToYw3O[2].off = (int)((Tc*)&p->Vpos - (Tc*)p); ToYw3O[3].off = (int)((Tc*)&p->Vbacktrace - (Tc*)p); } { Y2EX *p = 0; Y2EX__Ytlm_I_imt[1] = (Tc*)((Tc*)&p->Vmessage - (Tc*)p); Y2EX__Ytlm_I_imt[2] = (Tc*)((Tc*)&p->Vpos - (Tc*)p); Y2EX__Ytlm_I_imt[3] = (Tc*)((Tc*)&p->Vbacktrace - (Tc*)p); ToY2EX[1].off = (int)((Tc*)&p->Vmessage - (Tc*)p); ToY2EX[2].off = (int)((Tc*)&p->Vpos - (Tc*)p); ToY2EX[3].off = (int)((Tc*)&p->Vbacktrace - (Tc*)p); } { YX0i *p = 0; YX0i__Ytlm_I_imt[1] = (Tc*)((Tc*)&p->Vmessage - (Tc*)p); YX0i__Ytlm_I_imt[2] = (Tc*)((Tc*)&p->Vpos - (Tc*)p); YX0i__Ytlm_I_imt[3] = (Tc*)((Tc*)&p->Vbacktrace - (Tc*)p); ToYX0i[1].off = (int)((Tc*)&p->Vmessage - (Tc*)p); ToYX0i[2].off = (int)((Tc*)&p->Vpos - (Tc*)p); ToYX0i[3].off = (int)((Tc*)&p->Vbacktrace - (Tc*)p); } { YP_P *p = 0; YP_P__Ytlm_I_imt[1] = (Tc*)((Tc*)&p->Vmessage - (Tc*)p); YP_P__Ytlm_I_imt[2] = (Tc*)((Tc*)&p->Vpos - (Tc*)p); YP_P__Ytlm_I_imt[3] = (Tc*)((Tc*)&p->Vbacktrace - (Tc*)p); ToYP_P[1].off = (int)((Tc*)&p->Vmessage - (Tc*)p); ToYP_P[2].off = (int)((Tc*)&p->Vpos - (Tc*)p); ToYP_P[3].off = (int)((Tc*)&p->Vbacktrace - (Tc*)p); } { YzSI *p = 0; YzSI__Ytlm_I_imt[1] = (Tc*)((Tc*)&p->Vmessage - (Tc*)p); YzSI__Ytlm_I_imt[2] = (Tc*)((Tc*)&p->Vpos - (Tc*)p); YzSI__Ytlm_I_imt[3] = (Tc*)((Tc*)&p->Vbacktrace - (Tc*)p); ToYzSI[1].off = (int)((Tc*)&p->Vmessage - (Tc*)p); ToYzSI[2].off = (int)((Tc*)&p->Vpos - (Tc*)p); ToYzSI[3].off = (int)((Tc*)&p->Vbacktrace - (Tc*)p); } { YXKl *p = 0; YXKl__Ytlm_I_imt[1] = (Tc*)((Tc*)&p->Vmessage - (Tc*)p); YXKl__Ytlm_I_imt[2] = (Tc*)((Tc*)&p->Vpos - (Tc*)p); YXKl__Ytlm_I_imt[3] = (Tc*)((Tc*)&p->Vbacktrace - (Tc*)p); ToYXKl[1].off = (int)((Tc*)&p->Vmessage - (Tc*)p); ToYXKl[2].off = (int)((Tc*)&p->Vpos - (Tc*)p); ToYXKl[3].off = (int)((Tc*)&p->Vbacktrace - (Tc*)p); } { YuDC *p = 0; YuDC__Ytlm_I_imt[1] = (Tc*)((Tc*)&p->Vmessage - (Tc*)p); YuDC__Ytlm_I_imt[2] = (Tc*)((Tc*)&p->Vpos - (Tc*)p); YuDC__Ytlm_I_imt[3] = (Tc*)((Tc*)&p->Vbacktrace - (Tc*)p); ToYuDC[1].off = (int)((Tc*)&p->Vmessage - (Tc*)p); ToYuDC[2].off = (int)((Tc*)&p->Vpos - (Tc*)p); ToYuDC[3].off = (int)((Tc*)&p->Vbacktrace - (Tc*)p); } { YrHq *p = 0; YrHq__Ytlm_I_imt[1] = (Tc*)((Tc*)&p->Vmessage - (Tc*)p); YrHq__Ytlm_I_imt[2] = (Tc*)((Tc*)&p->Vpos - (Tc*)p); YrHq__Ytlm_I_imt[3] = (Tc*)((Tc*)&p->Vbacktrace - (Tc*)p); ToYrHq[1].off = (int)((Tc*)&p->Vmessage - (Tc*)p); ToYrHq[2].off = (int)((Tc*)&p->Vpos - (Tc*)p); ToYrHq[3].off = (int)((Tc*)&p->Vbacktrace - (Tc*)p); } { YkxB *p = 0; ToYkxB[1].off = (int)((Tc*)&p->Vfilename - (Tc*)p); ToYkxB[2].off = (int)((Tc*)&p->Vtext - (Tc*)p); } { Yw8L *p = 0; Yw8L__Yw8L_I_imt[20] = (Tc*)((Tc*)&p->Vfd - (Tc*)p); Yw8L__Yw8L_I_imt[21] = (Tc*)((Tc*)&p->Vname - (Tc*)p); ToYw8L[1].off = (int)((Tc*)&p->Vname - (Tc*)p); } { YjUM *p = 0; ToYjUM[1].off = (int)((Tc*)&p->Vs - (Tc*)p); ToYjUM[2].off = (int)((Tc*)&p->Vx - (Tc*)p); } { Yhqr *p = 0; ToYhqr[1].off = (int)((Tc*)&p->Vdict - (Tc*)p); } { Ygqr *p = 0; ToYgqr[1].off = (int)((Tc*)&p->Vdict - (Tc*)p); } { YuMQ *p = 0; ToYuMQ[1].off = (int)((Tc*)&p->Vtext - (Tc*)p); } { Y86c *p = 0; Y86c__YuQR_I_imt[1] = (Tc*)((Tc*)&p->VshortName - (Tc*)p); Y86c__YuQR_I_imt[2] = (Tc*)((Tc*)&p->VlongName - (Tc*)p); Y86c__YuQR_I_imt[3] = (Tc*)((Tc*)&p->Vdoc - (Tc*)p); Y86c__YuQR_I_imt[4] = (Tc*)((Tc*)&p->VargName - (Tc*)p); Y86c__YuQR_I_imt[5] = (Tc*)((Tc*)&p->VsetCount - (Tc*)p); Y86c__YuQR_I_imt[6] = (Tc*)((Tc*)&p->VcanRepeat - (Tc*)p); Y86c__YuQR_I_imt[7] = (Tc*)((Tc*)&p->VnoCompactVal - (Tc*)p); Y86c__YuQR_I_imt[8] = (Tc*)((Tc*)&p->VargOpt - (Tc*)p); Y86c__YuQR_I_imt[9] = (Tc*)((Tc*)&p->Vpos - (Tc*)p); ToY86c[1].off = (int)((Tc*)&p->VshortName - (Tc*)p); ToY86c[2].off = (int)((Tc*)&p->VlongName - (Tc*)p); ToY86c[3].off = (int)((Tc*)&p->Vdoc - (Tc*)p); ToY86c[4].off = (int)((Tc*)&p->VargName - (Tc*)p); ToY86c[5].off = (int)((Tc*)&p->Vpos - (Tc*)p); } { YJQu *p = 0; ToYJQu[1].off = (int)((Tc*)&p->VtheValueList - (Tc*)p); ToYJQu[2].off = (int)((Tc*)&p->VshortName - (Tc*)p); ToYJQu[3].off = (int)((Tc*)&p->VlongName - (Tc*)p); ToYJQu[4].off = (int)((Tc*)&p->Vdoc - (Tc*)p); ToYJQu[5].off = (int)((Tc*)&p->VargName - (Tc*)p); ToYJQu[6].off = (int)((Tc*)&p->Vpos - (Tc*)p); } { YzqH *p = 0; ToYzqH[1].off = (int)((Tc*)&p->Vcurrent - (Tc*)p); ToYzqH[2].off = (int)((Tc*)&p->Vdefault - (Tc*)p); ToYzqH[3].off = (int)((Tc*)&p->VtheValueList - (Tc*)p); ToYzqH[4].off = (int)((Tc*)&p->VshortName - (Tc*)p); ToYzqH[5].off = (int)((Tc*)&p->VlongName - (Tc*)p); ToYzqH[6].off = (int)((Tc*)&p->Vdoc - (Tc*)p); ToYzqH[7].off = (int)((Tc*)&p->VargName - (Tc*)p); ToYzqH[8].off = (int)((Tc*)&p->Vpos - (Tc*)p); } { Y_SI *p = 0; ToY_SI[1].off = (int)((Tc*)&p->Vcurrent - (Tc*)p); ToY_SI[2].off = (int)((Tc*)&p->Vdefault - (Tc*)p); ToY_SI[3].off = (int)((Tc*)&p->VshortName - (Tc*)p); ToY_SI[4].off = (int)((Tc*)&p->VlongName - (Tc*)p); ToY_SI[5].off = (int)((Tc*)&p->Vdoc - (Tc*)p); ToY_SI[6].off = (int)((Tc*)&p->VargName - (Tc*)p); ToY_SI[7].off = (int)((Tc*)&p->Vpos - (Tc*)p); } { YFk1 *p = 0; ToYFk1[1].off = (int)((Tc*)&p->Vid - (Tc*)p); ToYFk1[2].off = (int)((Tc*)&p->Vpos - (Tc*)p); } { Y2Kp *p = 0; Y2Kp__YuXI_imt[1] = (Tc*)((Tc*)&p->Vname - (Tc*)p); ToY2Kp[1].off = (int)((Tc*)&p->Vname - (Tc*)p); ToY2Kp[2].off = (int)((Tc*)&p->Vmembers - (Tc*)p); } { Y0uC *p = 0; ToY0uC[1].off = (int)((Tc*)&p->Vname - (Tc*)p); ToY0uC[2].off = (int)((Tc*)&p->VtypeName - (Tc*)p); ToY0uC[3].off = (int)((Tc*)&p->Vdefault - (Tc*)p); ToY0uC[4].off = (int)((Tc*)&p->Vpos - (Tc*)p); } { Ykeq *p = 0; ToYkeq[1].off = (int)((Tc*)&p->Vvalue - (Tc*)p); ToYkeq[2].off = (int)((Tc*)&p->VstartPos - (Tc*)p); ToYkeq[3].off = (int)((Tc*)&p->VendPos - (Tc*)p); } { Yswy *p = 0; ToYswy[1].off = (int)((Tc*)&p->Vname - (Tc*)p); ToYswy[2].off = (int)((Tc*)&p->Vpos - (Tc*)p); ToYswy[3].off = (int)((Tc*)&p->Vvalue - (Tc*)p); } { YRAB *p = 0; YRAB__YuXI_imt[1] = (Tc*)((Tc*)&p->Vname - (Tc*)p); ToYRAB[1].off = (int)((Tc*)&p->Vparent - (Tc*)p); ToYRAB[2].off = (int)((Tc*)&p->Vname - (Tc*)p); ToYRAB[3].off = (int)((Tc*)&p->Vfields - (Tc*)p); ToYRAB[4].off = (int)((Tc*)&p->Vitems - (Tc*)p); ToYRAB[5].off = (int)((Tc*)&p->VoptionList - (Tc*)p); } { YP_l *p = 0; ToYP_l[1].off = (int)((Tc*)&p->Vpackage - (Tc*)p); ToYP_l[2].off = (int)((Tc*)&p->Vimports - (Tc*)p); ToYP_l[3].off = (int)((Tc*)&p->VitemList - (Tc*)p); ToYP_l[4].off = (int)((Tc*)&p->VitemDict - (Tc*)p); } { YlM3 *p = 0; YlM3__YuXI_imt[1] = (Tc*)((Tc*)&p->Vname - (Tc*)p); ToYlM3[1].off = (int)((Tc*)&p->Vname - (Tc*)p); ToYlM3[2].off = (int)((Tc*)&p->VrequestName - (Tc*)p); ToYlM3[3].off = (int)((Tc*)&p->VresponseName - (Tc*)p); } { YNW5 *p = 0; YNW5__YuXI_imt[1] = (Tc*)((Tc*)&p->Vname - (Tc*)p); ToYNW5[1].off = (int)((Tc*)&p->Vname - (Tc*)p); ToYNW5[2].off = (int)((Tc*)&p->Vrpcs - (Tc*)p); } { YeYq *p = 0; ToYeYq[1].off = (int)((Tc*)&p->Vfd - (Tc*)p); ToYeYq[2].off = (int)((Tc*)&p->Vtext - (Tc*)p); ToYeYq[3].off = (int)((Tc*)&p->Vpos - (Tc*)p); ToYeYq[4].off = (int)((Tc*)&p->VcharStack - (Tc*)p); ToYeYq[5].off = (int)((Tc*)&p->Vindent - (Tc*)p); ToYeYq[6].off = (int)((Tc*)&p->VrecordWriter - (Tc*)p); } { YuI4 *p = 0; ToYuI4[1].off = (int)((Tc*)&p->Vinput - (Tc*)p); ToYuI4[2].off = (int)((Tc*)&p->VtokenStack - (Tc*)p); } } /* * INIT GLOBALS */ int ZglobInit(int round) { int done = 1; Zsf sf; sf.prev = topFrame; sf.pos = 0; sf.frof = NULL; topFrame = &sf; done &= JIOModule(round); done &= JLOGModule(round); done &= JARGModule(round); done &= JParseProto(round); if (round == 2001) { } topFrame = sf.prev; return done; } /* * MAIN */ #if defined(__MINGW32__) || defined(_MSC_VER) # define CATCH_SIG(sig, func) signal(sig, func) typedef struct SEH_EXCEPTION_REGISTRATION_S SEH_EXCEPTION_REGISTRATION; struct SEH_EXCEPTION_REGISTRATION_S { SEH_EXCEPTION_REGISTRATION *prev; PEXCEPTION_HANDLER handler; }; static EXCEPTION_DISPOSITION exception_handler(PEXCEPTION_RECORD pRecord, SEH_EXCEPTION_REGISTRATION *pReg, PCONTEXT pContext, PEXCEPTION_RECORD pRecord2) { Zdeadly(11); return ExceptionContinueSearch; } #else # define CATCH_SIG(sig, func) catch_sig(sig, func) void catch_sig(int sig, void *func) { struct sigaction act; act.sa_handler = func; sigemptyset(&act.sa_mask); act.sa_flags = SA_NODEFER; sigaction(sig, &act, NULL); } #endif int Fmain(void); int main(int argc, char **argv) { int r = 0; int round = 0; #if defined(__MINGW32__) || defined(_MSC_VER) SEH_EXCEPTION_REGISTRATION seh_er; seh_er.handler = (PEXCEPTION_HANDLER)(exception_handler); asm volatile ("movl %%fs:0, %0" : "=r" (seh_er.prev)); asm volatile ("movl %0, %%fs:0" : : "r" (&seh_er)); #else # ifdef SIGSEGV CATCH_SIG(SIGSEGV, Zdeadly); # endif # ifdef SIGBUS CATCH_SIG(SIGBUS, Zdeadly); # endif # ifdef SIGFPE CATCH_SIG(SIGFPE, Zdeadly); # endif #endif #if defined(__MINGW32__) || defined(_MSC_VER) # ifdef __MINGW32__ _fmode = _O_BINARY; # else _set_fmode(_O_BINARY); # endif _setmode(_fileno(stdin), _O_BINARY); _setmode(_fileno(stdout), _O_BINARY); _setmode(_fileno(stderr), _O_BINARY); #endif emergencyAlloc = malloc(16384); ZimtInit(); ZglobInit(round++); YzvW = Zstr(argv[0]); Y1p3 = ZnewList(&string__T, 0); { int i; for (i = 1; i < argc; ++i) { ZLa(Y1p3, -1, (Tz)(void*)Zstr(argv[i])); } } ZglobInit(round++); while (!ZglobInit(round++)) { if (round == 1002) ZthrowCstringInit("Early initialization not done within 1000 rounds"); } YZH8(); round = 2001; ZglobInit(round++); while (!ZglobInit(round++)) { if (round == 3002) ZthrowCstringInit("Initialization not done within 1000 rounds"); } r = Fmain(); beforeExit(); if (topFrame != NULL) fprintf(stderr, "INTERNAL: topFrame not NULL\n"); return r; } int Fmain(void) { Zsf sf; Ti r = 0; Tc *VinFileName = NULL; Tc *VoutFileName = NULL; YP_l *Vprotofile = 0; int rt = 0; sf.prev = topFrame; sf.pos = 0; topFrame = &sf; r = 0; sf.pos=527000; if ((Yd2Z() != 2)) { sf.pos=527001; Yl0k(ZcS3(((Tc*)&YZVC), YzvW, ((Tc*)&YWbL))); sf.pos=527002; Zexit(NULL, 1); return 0; } sf.pos=527003; VinFileName = YtgL(0); sf.pos=527004; if ((ZstringCmp(ZstringSlice(VinFileName, -6, -1, 0), ((Tc*)&YnKK)) != 0)) { sf.pos=527005; Yl0k(ZcS(((Tc*)&YwwA), VinFileName)); sf.pos=527006; Zexit(NULL, 1); return 0; } sf.pos=527007; VoutFileName = YtgL(1); sf.pos=527008; if ((ZstringCmp(ZstringSlice(VoutFileName, -3, -1, 0), ((Tc*)&YYv4)) != 0)) { sf.pos=527009; Yl0k(ZcS(((Tc*)&YIhh), VoutFileName)); sf.pos=527010; Zexit(NULL, 1); return 0; } sf.pos=527011; Vprotofile = YSOt(VinFileName); sf.pos=527012; if ((Yrpn > 0)) { sf.pos=527013; YCOQ(VinFileName, VoutFileName); sf.pos=527014; r = 1; rt = 1; goto YtK3; } sf.pos=527015; YCCA(Vprotofile, VinFileName, VoutFileName); sf.pos=527016; r = 0; YtK3: topFrame = sf.prev; return r; }
22.518012
605
0.573007
[ "object" ]
cca866e2df6b2d2360011935f8044e45d1627903
6,818
h
C
src/chrome/browser/signin/signin_manager_base.h
jxjnjjn/chromium
435c1d02fd1b99001dc9e1e831632c894523580d
[ "Apache-2.0" ]
9
2018-09-21T05:36:12.000Z
2021-11-15T15:14:36.000Z
src/chrome/browser/signin/signin_manager_base.h
jxjnjjn/chromium
435c1d02fd1b99001dc9e1e831632c894523580d
[ "Apache-2.0" ]
null
null
null
src/chrome/browser/signin/signin_manager_base.h
jxjnjjn/chromium
435c1d02fd1b99001dc9e1e831632c894523580d
[ "Apache-2.0" ]
3
2018-11-28T14:54:13.000Z
2020-07-02T07:36:07.000Z
// Copyright (c) 2012 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. // // The signin manager encapsulates some functionality tracking // which user is signed in. // // **NOTE** on semantics of SigninManager: // // Once a signin is successful, the username becomes "established" and will not // be cleared until a SignOut operation is performed (persists across // restarts). Until that happens, the signin manager can still be used to // refresh credentials, but changing the username is not permitted. // // On Chrome OS, because of the existence of other components that handle login // and signin at a higher level, all that is needed from a SigninManager is // caching / handling of the "authenticated username" field, and TokenService // initialization, so that components that depend on these two things // (i.e on desktop) can continue using it / don't need to change. For this // reason, SigninManagerBase is all that exists on Chrome OS. For desktop, // see signin/signin_manager.h. #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_BASE_H_ #define CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_BASE_H_ #include <string> #include "base/compiler_specific.h" #include "base/gtest_prod_util.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/observer_list.h" #include "base/prefs/pref_change_registrar.h" #include "base/prefs/pref_member.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_keyed_service.h" #include "chrome/browser/signin/signin_internals_util.h" class CookieSettings; class ProfileIOData; class PrefService; class SigninGlobalError; // Details for the Notification type GOOGLE_SIGNIN_SUCCESSFUL. // A listener might use this to make note of a username / password // pair for encryption keys. struct GoogleServiceSigninSuccessDetails { GoogleServiceSigninSuccessDetails(const std::string& in_username, const std::string& in_password) : username(in_username), password(in_password) {} std::string username; std::string password; }; // Details for the Notification type NOTIFICATION_GOOGLE_SIGNED_OUT. struct GoogleServiceSignoutDetails { explicit GoogleServiceSignoutDetails(const std::string& in_username) : username(in_username) {} std::string username; }; class SigninManagerBase : public ProfileKeyedService { public: // Returns true if the cookie policy for the given profile allows cookies // for the Google signin domain. static bool AreSigninCookiesAllowed(Profile* profile); static bool AreSigninCookiesAllowed(CookieSettings* cookie_settings); // Returns true if the username is allowed based on the policy string. static bool IsAllowedUsername(const std::string& username, const std::string& policy); SigninManagerBase(); virtual ~SigninManagerBase(); // If user was signed in, load tokens from DB if available. void Initialize(Profile* profile); bool IsInitialized() const; // Returns true if the passed username is allowed by policy. Virtual for // mocking in tests. virtual bool IsAllowedUsername(const std::string& username) const; // Returns true if a signin to Chrome is allowed (by policy or pref). bool IsSigninAllowed() const; // Checks if signin is allowed for the profile that owns |io_data|. This must // be invoked on the IO thread, and can be used to check if signin is enabled // on that thread. static bool IsSigninAllowedOnIOThread(ProfileIOData* io_data); // If a user has previously established a username and SignOut has not been // called, this will return the username. // Otherwise, it will return an empty string. const std::string& GetAuthenticatedUsername() const; // Sets the user name. Note: |username| should be already authenticated as // this is a sticky operation (in contrast to StartSignIn). // TODO(tim): Remove this in favor of passing username on construction by // (by platform / depending on StartBehavior). Bug 88109. void SetAuthenticatedUsername(const std::string& username); // Sign a user out, removing the preference, erasing all keys // associated with the user, and canceling all auth in progress. // TODO(tim): Remove SignOut here, it belongs in the derived class. // Bug 174927. virtual void SignOut(); // Returns true if there's a signin in progress. virtual bool AuthInProgress() const; SigninGlobalError* signin_global_error() { return signin_global_error_.get(); } const SigninGlobalError* signin_global_error() const { return signin_global_error_.get(); } // ProfileKeyedService implementation. virtual void Shutdown() OVERRIDE; // Methods to register or remove SigninDiagnosticObservers void AddSigninDiagnosticsObserver( signin_internals_util::SigninDiagnosticsObserver* observer); void RemoveSigninDiagnosticsObserver( signin_internals_util::SigninDiagnosticsObserver* observer); protected: // Lets different platforms initialize TokenService in their own way. virtual void InitTokenService(); // Pointer to parent profile (protected so FakeSigninManager can access // it). Profile* profile_; // Used to show auth errors in the wrench menu. The SigninGlobalError is // different than most GlobalErrors in that its lifetime is controlled by // SigninManager (so we can expose a reference for use in the wrench menu). scoped_ptr<SigninGlobalError> signin_global_error_; // Helper methods to notify all registered diagnostics observers with. void NotifyDiagnosticsObservers( const signin_internals_util::UntimedSigninStatusField& field, const std::string& value); void NotifyDiagnosticsObservers( const signin_internals_util::TimedSigninStatusField& field, const std::string& value); private: friend class FakeSigninManagerBase; friend class FakeSigninManager; void OnGoogleServicesUsernamePatternChanged(); void OnSigninAllowedPrefChanged(); // Helper object to listen for changes to signin preferences stored in non- // profile-specific local prefs (like kGoogleServicesUsernamePattern). PrefChangeRegistrar local_state_pref_registrar_; // Helper object to listen for changes to the signin allowed preference. BooleanPrefMember signin_allowed_; // Actual username after successful authentication. std::string authenticated_username_; // The list of SigninDiagnosticObservers. ObserverList<signin_internals_util::SigninDiagnosticsObserver, true> signin_diagnostics_observers_; base::WeakPtrFactory<SigninManagerBase> weak_pointer_factory_; DISALLOW_COPY_AND_ASSIGN(SigninManagerBase); }; #endif // CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_BASE_H_
38.303371
79
0.76518
[ "object" ]
ccbb439f2dfa3f46c5e82b224881981873c50f8e
32,080
h
C
src/include/common/Grid.h
neo-bolea/procedurally
449d583dc09f3779617490b26d4af469b31ec414
[ "MIT" ]
4
2019-11-19T17:05:44.000Z
2020-03-30T20:09:53.000Z
src/include/common/Grid.h
neo-bolea/procedurally
449d583dc09f3779617490b26d4af469b31ec414
[ "MIT" ]
5
2019-12-07T18:07:30.000Z
2020-03-23T10:47:41.000Z
src/include/common/Grid.h
neo-bolea/procedurally
449d583dc09f3779617490b26d4af469b31ec414
[ "MIT" ]
null
null
null
#pragma once #include "Common/Debug.h" #include "Math/MathExt.h" #include "Common/Templates.h" #include "Common/Vec.h" #include <algorithm> #include <assert.h> #include <functional> #include <queue> #include <set> #include <stack> #include <unordered_map> using IntVector2 = iVec2; #define GRID_TEMPLATE_SIGNATURE template<typename T, size_t N, BorderPolicy Policy> #define GRID_SGN Grid<T, N, Policy> //TODO: Allow [] operator to work with vectors. //TODO: Add Fill function (and possibly other utility functions). //TODO: Make Proxy more readably by using decltype(auto) (remember how it returned all arguments as references...). enum class BorderPolicy { Undefined, Clamp, Value }; template<typename T, BorderPolicy Policy, typename Enable = void> class GridBase; template<typename T, BorderPolicy Policy> class GridBase<T, Policy, std::enable_if_t<Policy == BorderPolicy::Undefined>> {}; template<typename T, BorderPolicy Policy> class GridBase<T, Policy, std::enable_if_t<Policy == BorderPolicy::Clamp>> {}; template<typename T, BorderPolicy Policy> class GridBase<T, Policy, std::enable_if_t<Policy == BorderPolicy::Value>> { T BorderValue; }; template<typename T, size_t N = 2, BorderPolicy Policy = BorderPolicy::Clamp> class Grid : public GridBase<T, Policy> { public: using CoordType = size_t; using Coords = Vec<CoordType, N>; using Dimensions = Coords; template<size_t CurN> struct Proxy; //// Constructors //// GRID_SGN(); template<typename ...Args> GRID_SGN(Args ...dimensions); GRID_SGN(Dimensions dimensions); GRID_SGN(const GRID_SGN &arr); //// Indexing //// template<typename ...Args> const T &operator()(Args ...coords) const; template<typename ...Args> T &operator()(Args ...coords); const T &operator()(const Coords &coords) const; T &operator()(const Coords &coords); const Proxy<1> operator[](CoordType coord) const; Proxy<1> operator[](CoordType coord); void operator =(const GRID_SGN &other); void operator =(GRID_SGN &&other); //// Functions //// T EvaluateBorder(const Coords &coords); void ForAll(function_view<void(Coords)> func); //// Data //// std::vector<T> v; Dimensions Size; private: template<size_t Depth> void forAll(function_view<void(Coords)> &func, Coords &coords); }; GRID_TEMPLATE_SIGNATURE template<size_t CurN> struct GRID_SGN::Proxy { GRID_SGN *grid; CoordType index; CoordType curMult; struct RefWrap { T &ref; void operator =(const T &value) { ref = value; } operator T &() { return ref; } }; auto operator[](size_t coord) { curMult /= grid->Size[CurN]; if constexpr (CurN + 1 == N) { return RefWrap{ grid->v[index + coord * curMult] }; } else { assert(0 <= coord && coord <= grid->Size[CurN]); return Proxy<CurN + 1>{ grid, index + coord * curMult, curMult }; } } }; //// Constructors //// GRID_TEMPLATE_SIGNATURE GRID_SGN::Grid() : Size{} {} GRID_TEMPLATE_SIGNATURE template<typename ...Args> GRID_SGN::Grid(Args ...dimensions) : Size{ static_cast<CoordType>(dimensions)... } { v.resize(std::accumulate(Size.e.begin(), Size.e.end(), 1, std::multiplies<double>())); } GRID_TEMPLATE_SIGNATURE GRID_SGN::Grid(Dimensions dimensions) : Size{ dimensions } { v.resize(std::accumulate(Size.e.begin(), Size.e.end(), 1, std::multiplies<double>())); } GRID_TEMPLATE_SIGNATURE GRID_SGN::Grid(const GRID_SGN &arr) : Size{ arr.Size } { this->v = arr.v; } //// Indexing //// GRID_TEMPLATE_SIGNATURE template<typename ...Args> const T &GRID_SGN::operator()(Args ...coords) const { return this->operator()(coords); } GRID_TEMPLATE_SIGNATURE template<typename ...Args> T &GRID_SGN::operator()(Args ...coords) { static_assert(!(sizeof...(Args) < N), "Grid cannot be accessed with less coordinates than dimensions."); static_assert(!(sizeof...(Args) > N), "Grid cannot be accessed with more coordinates than dimensions."); return this->operator()({ static_cast<CoordType>(coords)... }); } GRID_TEMPLATE_SIGNATURE const T &GRID_SGN::operator()(const Coords &coords) const { return this->operator()(coords); } GRID_TEMPLATE_SIGNATURE T &GRID_SGN::operator()(const Coords &coords) { CoordType index = 0; CoordType currMult = v.size(); for (size_t i = 0; i < N; i++) { currMult /= Size[i]; if(0 <= coords[i] && coords[i] < Size[i]) { index += coords[i] * currMult; } else { T value = EvaluateBorder(coords); return value; } } return v[index]; } GRID_TEMPLATE_SIGNATURE const GRID_SGN::Proxy<1> GRID_SGN::operator[](CoordType coord) const { return this->operator[](coord); } GRID_TEMPLATE_SIGNATURE GRID_SGN::Proxy<1> GRID_SGN::operator[](CoordType coord) { assert(0 <= coord && coord <= (Size[0] - 1)); CoordType curMult = v.size() / Size[0]; return { this, coord * curMult, curMult }; } GRID_TEMPLATE_SIGNATURE void GRID_SGN::operator =(const GRID_SGN &other) { v = other.v; Size = other.Size; } GRID_TEMPLATE_SIGNATURE void GRID_SGN::operator =(GRID_SGN &&other) { v = std::move(other.v); Size = std::move(other.Size); } //// Functions //// GRID_TEMPLATE_SIGNATURE T GRID_SGN::EvaluateBorder(const Coords &coords) { if constexpr (Policy == BorderPolicy::Undefined) { Debug::Log("Grid->operator(): Indices are out of range.", Debug::Error); return T(); } else if constexpr (Policy == BorderPolicy::Clamp) { Coords clampedCoords; for (size_t i = 0; i < N; i++) { clampedCoords[i] = Math::Clamp(coords[i], CoordType(0), Size[i] - 1); } return this->operator()(clampedCoords); } else if constexpr (Policy == BorderPolicy::Value) { return BorderValue; } else { UNDEFINED_CODE_PATH; } } GRID_TEMPLATE_SIGNATURE void GRID_SGN::ForAll(function_view<void(Coords)> func) { Coords coords{}; forAll<0>(func, coords); } GRID_TEMPLATE_SIGNATURE template<size_t Depth> void GRID_SGN::forAll(function_view<void(Coords)> &func, Coords &coords) { if constexpr (Depth == N) { func(coords); } else { for (size_t i = 0; i < Size[Depth]; i++, coords[Depth]++) { forAll<Depth + 1>(func, coords); } coords[Depth] = 0; } } //namespace Grid //{ // // template<typename T> // static Array2D<T> BoxBlur(const UnlimitedArray2D<T> &grid, int distance = 1, int iterations = 1) // { // Array2D<T> newGrid(grid.Length[0], grid.Length[1]); // // for(int i = 0; i < iterations; i++) // { // grid.ForAll([&grid, &newGrid, distance](int x, int y) // { // T result = T(); // result += grid(x - distance, y); //W // result += grid(x - distance, y - distance); //SW // result += grid(x, y - distance); //S // result += grid(x + distance, y - distance); //SE // result += grid(x + distance, y); //E // result += grid(x + distance, y + distance); //NE // result += grid(x, y + distance); //N // result += grid(x - distance, y + distance); //NW // // newGrid(x, y) = result / 8.f; // }); // } // // return newGrid; // } // // template<typename O, typename I> // static Array2D<O> Cast(const Array2D<I> &grid) // { // Array2D<O> out(grid.Length[0], grid.Length[1]); // for(uint i = 0; i < grid.v.size(); i++) { out.v[i] = (O)grid.v[i]; } // // return out; // } // // template<typename T> // static IntVector2 Centroid(const std::vector<IntVector2> &collection) // { // IntVector2 result; // for(int i = 0; i < collection.size(); i++) { result += collection[i]; } // // return IntVector2(result.x / collection.size(), result.y / collection.size()); // } // // /// <summary> Creates a grid with dimensions width and height, with each value generated by func. </summary> // /// <param name="func"> The function with which to generate the grid. Signature: (int, int)->T </param> // template<typename T, typename Func> // static Array2D<T> Create(uint width, uint height, Func func) // { // Array2D<T> grid(width, height); // grid.ForAll([&grid, func](int x, int y) { grid(x, y) = func(x, y); }); // // return grid; // } // // //See https://stackoverflow.com/questions/14465297/connected-component-labelling for more information. //#pragma region Connected Component Labelling // namespace // { // /* // static void LabelCell(const Array2D<T> &grid, Array2D<int> &labels, std::deque<std::tuple<short, short>> &stack, std::function<bool(float)> getCondition, int startX, int startY, int current_label) // { // stack.push_front({ startX, startY }); // while(!stack.empty()) // { // short x = std::get<0>(stack.front()), y = std::get<1>(stack.front()); // stack.pop_front(); // // if(x < 0 || x == grid.Length[0]) continue; // out of bounds // if(y < 0 || y == grid.Length[1]) continue; // out of bounds // if(labels(x, y) || !getCondition(grid(x, y))) continue; // already labeled or not marked with 1 in m // // // mark the current cell // labels(x, y) = current_label; // // stack.push_front({x - 1, y}); // stack.push_front({x, y - 1}); // stack.push_front({x + 1, y}); // stack.push_front({x, y + 1}); // } // } // */ // // template<typename T, typename Func > // static void LabelCellRecursive(const Array2D<T> &grid, Array2D<int> &labels, Func fullCondition, int x, int y, int current_label) // { // if(x < 0 || x == grid.Length[0] || y < 0 || y == grid.Length[1]) return; // out of bounds // if(labels(x, y) || !fullCondition(grid(x, y))) return; // already labeled or not marked with 1 in m // // // mark the current cell // labels(x, y) = current_label; // // // recursively mark the neighbors // LabelCellRecursive(grid, labels, fullCondition, x - 1, y, current_label); // LabelCellRecursive(grid, labels, fullCondition, x, y - 1, current_label); // LabelCellRecursive(grid, labels, fullCondition, x + 1, y, current_label); // LabelCellRecursive(grid, labels, fullCondition, x, y + 1, current_label); // } // } // // struct CCLOut { std::vector<std::vector<IntVector2>> ConnectedComponents; Array2D<int> LabelledGrid; }; // // /// <param name="fullCondition"> A function to know what cells count as empty/full. Signature: T->bool </param> // template<typename T, typename Func> // static CCLOut ConnectedComponentLabelling(const Array2D<T> &grid, bool generateCCL = false, Func fullCondition = [](T f) { return f; }) // { // CCLOut out; // auto &LabelledGrid = out.LabelledGrid; // std::deque<std::tuple<short, short>> stack; // // //LabelledGrid // LabelledGrid = Array2D<int>(grid.Length[0], grid.Length[1]); // int component = 0; // for(int x = 0; x < grid.Length[0]; x++) // { // for(int y = 0; y < grid.Length[1]; y++) // { // if(!LabelledGrid(x, y) && fullCondition(grid(x, y))) LabelCellRecursive(grid, LabelledGrid, fullCondition, x, y, ++component); // } // } // // if(!generateCCL) { return out; } // // //CCL // for(int x = 0; x < grid.Length[0]; x++) // { // for(int y = 0; y < grid.Length[1]; y++) // { // if(!LabelledGrid(x, y) || !fullCondition(grid(x, y))) { continue; } // // int label = LabelledGrid(x, y); // if(out.ConnectedComponents.size() < label) // { // out.ConnectedComponents.resize(label); // } // // out.ConnectedComponents[label - 1].push_back(IntVector2(x, y)); // } // } // // return out; // } //#pragma endregion // //#pragma region Distance Transform and Voronoi // //TODO: Voronoi doesn't work // template<typename T, typename Func> // static Array2D<T> DistanceTransform(const Array2D<T> &grid, Array2D<IntVector2> &voronoiGrid = Array2D<IntVector2>::Null(), Func fullCondition = [&grid](float f) { return f > 0.f; }) // { // return VoronoiDiagram::DistanceTransform(grid, voronoiGrid, fullCondition); // } // // //See https://github.com/983/df (code) and http://fab.cba.mit.edu/classes/S62.12/docs/Meijster_distance.pdf (algorithm) for more information. // // namespace // { // class VoronoiDiagram // { // template<typename T> // static T Distance(T x0, T dy0, T x) // { // T dx0 = x - x0; // return dx0 * dx0 + dy0 * dy0; // } // // public: // template<typename T, typename Func> // static Array2D<T> DistanceTransform(const Array2D<T> &grid, Array2D<IntVector2> &closestPoints, Func fullCondition) // { // int x, y, width = grid.Length[0], height = grid.Length[1]; // // //There are at most n parabolas and n + 1 intersections between consecutive parabolas. // std::vector<int> parabolaX(width); // std::vector<T> xIntersections(width); // std::vector<T> tempRowDistances(width); // std::vector<IntVector2> tempClosest(width); // // bool pointsIsNull = Array2D<IntVector2>::IsNull(closestPoints); // // if(!pointsIsNull) // { // closestPoints = Array2D<IntVector2>(width, height); // for(y = 0; y < height; y++) // { // for(x = 0; x < width; x++) // { // closestPoints(x, y) = IntVector2(x, y); // } // } // } // // Array2D<T> distances = Create<T>(grid.Length[0], grid.Length[1], [&grid, fullCondition](int x, int y) { return fullCondition(grid(x, y)) ? 0 : INFINITY; }); // //Find minimum distance in columns. // for(x = 0; x < width; x++) // { // for(y = 1; y < height; y++) // { // if(distances(x, y) > distances(x, y - 1) + 1.f) // { // distances(x, y) = distances(x, y - 1) + 1.f; // if(!pointsIsNull) closestPoints(x, y) = closestPoints(x, y - 1); // } // } // // for(y = height - 2; y >= 0; y--) // { // if(distances(x, y) > distances(x, y + 1) + 1.f) // { // distances(x, y) = distances(x, y + 1) + 1.f; // if(!pointsIsNull) closestPoints(x, y) = closestPoints(x, y + 1); // } // } // } // // //Find minimum distance in rows by finding lower envelope of parabolas. // for(y = 0; y < height; y++) // { // int n = 0; // parabolaX[0] = 0; // // //Find first parabola with finite distance. // for(x = 0; x < width; x++) // { // if(distances(x, y) < INFINITY) // { // parabolaX[0] = x; // break; // } // } // // for(x = x + 1; x < width; x++) // { // //Load parabola (x1, dy1). // float dy1 = distances(x, y); // // //Infinite parabolas are not part of the lower envelope. // if(dy1 == INFINITY) continue; // // while(true) // { // //Load old parabola (x0, dy0). // int x0 = parabolaX[n]; // float dy0 = distances(x0, y); // // //If the old parabola (x0, dy0) is above the parabola (x1, dy1) at the point of the last intersection // if(n > 0 && // Distance<T>((T)x0, (T)dy0, (T)xIntersections[n - 1]) > // Distance<T>((T)x, (T)dy1, (T)xIntersections[n - 1])) // { // //it will not be in the lower envelope and is discarded. // n--; // } // else // { // //Otherwise, add parabola and its intersection. // xIntersections[n] = 0.5f / (x - x0) * (x * x + dy1 * dy1 - x0 * x0 - dy0 * dy0); // n++; // parabolaX[n] = x; // break; // } // } // } // // //Fill in distance values based on lower envelopes // for(x = width - 1; x >= 0; x--) // { // int x0; // T dy0; // //Go to next parabola. // while(n > 0 && x < xIntersections[(decltype(xIntersections)::size_type)n - 1]) n--; // // x0 = parabolaX[n]; // dy0 = distances(x0, y); // //Can not write directly because we also read from same array. // tempRowDistances[x] = Distance<T>((T)x0, (T)dy0, (T)x); // if(!pointsIsNull) { tempClosest[x] = closestPoints(x0, y); } // } // // //Copy back temporary values. // for(x = 0; x < width; x++) // { // distances(x, y) = tempRowDistances[x]; // if(!pointsIsNull) closestPoints(x, y) = tempClosest[x]; // } // } // // return distances; // } // }; // } //#pragma endregion // // template<typename T> // static Array2D<T> DrawCircle(const Array2D<T> &grid, int cx, int cy, float radius, T fillValue) // { // Array2D<T> result(grid); // // IntVector2 minP(std::max<int>(cx - radius + 1, 0), std::max<int>(cy - radius + 1, 0)); // IntVector2 maxP(std::min<int>(cx + radius - 1, grid.Length[0] - 1), std::min<int>(cy + radius - 1, grid.Length[1] - 1)); // // for(int y = minP.y; y <= maxP.y; y++) // { // for(int x = minP.x; x <= maxP.x; x++) // { // if(((x - cx) * (x - cx) + (y - cy) * (y - cy)) <= radius * radius - 1.f) { result(x, y) = fillValue; } // } // } // // return result; // } // // //TODO: Maybe https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4813928/ is faster? // //TODO: Understand and personalize this code! // // This is a conversion to C# of the algorithm which is implemented at: // // https://www.eriksmistad.no/moore-neighbor-contour-tracing-algorithm-in-c/ // // http://www.imageprocessingplace.com/downloads_V3/root_downloads/tutorials/contour_tracing_Abeer_George_Ghuneim/moore.html // // This gets all boundaries in the given pixels. // // It assumes you're looking for boundaries between non-transparent shapes on a transparent background // // (using the isTransparent property); // // but you could modify this, to pass in a predicate to say what background color you're looking for (e.g. White). // /*static std::vector<std::vector<IntVector2>> FindBorders(std::vector<float> grid, float threshold = 0f, bool bordersAreSolid = true) // { // IntVector2 size = IntVector2(grid.Length, grid[0].Length); // HashSet<IntVector2> found = HashSet<IntVector2>(); // std::vector<IntVector2> list = null; // std::vector<std::vector<IntVector2>> lists = std::vector<std::vector<IntVector2>>(); // bool inside = false; // // // Defines the neighborhood offset position from current position and the neighborhood // // position we want to check next if we find a border at checkLocationNr. // int width = size.x; // auto neighborhood = Tuple<Func<IntVector2, IntVector2>, int>[] // { // Tuple<Func<IntVector2, IntVector2>, int>(point = > IntVector2(point.x - 1, point.y), 7), // Tuple<Func<IntVector2, IntVector2>, int>(point = > IntVector2(point.x - 1, point.y - 1), 7), // Tuple<Func<IntVector2, IntVector2>, int>(point = > IntVector2(point.x, point.y - 1), 1), // Tuple<Func<IntVector2, IntVector2>, int>(point = > IntVector2(point.x + 1, point.y - 1), 1), // Tuple<Func<IntVector2, IntVector2>, int>(point = > IntVector2(point.x + 1, point.y), 3), // Tuple<Func<IntVector2, IntVector2>, int>(point = > IntVector2(point.x + 1, point.y + 1), 3), // Tuple<Func<IntVector2, IntVector2>, int>(point = > IntVector2(point.x, point.y + 1), 5), // Tuple<Func<IntVector2, IntVector2>, int>(point = > IntVector2(point.x - 1, point.y + 1), 5) // }; // // for(int y = 0; y < size.y; ++y) // { // for(int x = 0; x < size.x; ++x) // { // IntVector2 point = IntVector2(x, y); // // Scan for non-transparent pixel // if(found.Contains(point) && !inside) // { // // Entering an already discovered border // inside = true; // continue; // } // bool isSolid = grid[point.x][point.y] >= threshold; // if(isSolid && inside) // { // // Already discovered border point // continue; // } // if(!isSolid && inside) // { // // Leaving a border // inside = false; // continue; // } // if(isSolid && !inside) // { // lists.Add(list = std::vector<IntVector2>()); // // // Undiscovered border point // found.Add(point); list.Add(point); // Mark the start pixel // int checkLocationNr = 1; // The neighbor number of the location we want to check for a border point // IntVector2 startPos = point; // Set start position // int counter = 0; // Counter is used for the jacobi stop criterion // int counter2 = 0; // Counter2 is used to determine if the point we have discovered is one single point // // // Trace around the neighborhood // while(true) // { // // The corresponding absolute array address of checkLocationNr // IntVector2 checkPosition = neighborhood[checkLocationNr - 1].Item1(point); // // autoiable that holds the neighborhood position we want to check if we find a border at checkLocationNr // int CheckLocationNr = neighborhood[checkLocationNr - 1].Item2; // // bool outsideGrid = (checkPosition.x >= size.x || checkPosition.y >= size.y); // if(bordersAreSolid) { isSolid = outsideGrid || grid[checkPosition.x][checkPosition.y] >= threshold; } // else { isSolid = !outsideGrid && grid[checkPosition.x][checkPosition.y] >= threshold; } // // if(isSolid) // { // // Next border point found // if(checkPosition == startPos) // { // counter++; // // // Stopping criterion (jacob) // if(CheckLocationNr == 1 || counter >= 3) // { // // Close loop // inside = true; // Since we are starting the search at were we first started we must set inside to true // break; // } // } // // checkLocationNr = CheckLocationNr; // Update which neighborhood position we should check next // point = checkPosition; // counter2 = 0; // Reset the counter that keeps track of how many neighbors we have visited // found.Add(point); list.Add(point); // Set the border pixel // } // else // { // // Rotate clockwise in the neighborhood // checkLocationNr = 1 + (checkLocationNr % 8); // if(counter2 > 8) // { // // If counter2 is above 8 we have traced around the neighborhood and // // therefor the border is a single black pixel and we can exit // counter2 = 0; // list = null; // break; // } // else // { // counter2++; // } // } // } // // } // } // } // return lists; // } // // // This gets the longest boundary (i.e. list of points), if you don't want all boundaries. // static std::vector<IntVector2> getPoints(std::vector<std::vector<IntVector2>> lists) // { // lists.Sort((x, y) = > x.Count.CompareTo(y.Count)); // return lists.Last(); // } // // */ //#pragma region FloodFill // //See http://will.thimbleby.net/scanline-flood-fill/ for more information. // // //TODO: Fix broken FloodFill (or delete if unnecessary) // /// <summary> // /// Flood fills a grid starting from cell, and replaces all grid cells with replacementValue. // /// </summary> // /// <param name="cell">The cell to start filling at.</param> // /// <param name="replacementValue">The value to replace filled grid points with.</param> // /// <param name="fillCondition">The function to evaluate whether to fill a cell or not. By default it evaluates whether the grid cell equals the targetValue.</param> // /// <param name="targetValue">The value to compare to the grid number as the 3rd parameter of fillCondition. By default it takes the starting cell's value.</param> // template<typename T> // static Array2D<T> FloodFill(Array2D<T> grid, int x, int y, T replacementValue, T targetValue = 0, std::function<bool(T, T)> fillCondition = [](int a, int b) { return a == b; }) // { // if(targetValue == 0) { targetValue = grid(x, y); } // if(grid(x, y) == replacementValue) { return grid; } // // std::stack<IntVector2> cells; // // cells.push(IntVector2(x, y)); // while(cells.size() != 0) // { // IntVector2 temp = cells.top(); // cells.pop(); // int x1 = temp.x; // int y1 = temp.y; // while(y1 >= 0 && fillCondition(grid(x1, y1), targetValue)) { y1--; } // y1++; // bool spanLeft = false; // bool spanRight = false; // while(y1 < grid.Length[1] && fillCondition(grid(x1, y1), targetValue)) // { // grid(x1, y1) = replacementValue; // // if(!spanLeft && x1 > 0 && fillCondition(grid(x1 - 1, y1), targetValue)) // { // cells.push(IntVector2(x1 - 1, y1)); // spanLeft = true; // } // else if(spanLeft && x1 - 1 == 0 && !fillCondition(grid(x1 - 1, y1), targetValue)) // { // spanLeft = false; // } // if(!spanRight && x1 < grid.Length[0] - 1 && fillCondition(grid(x1 + 1, y1), targetValue)) // { // cells.push(IntVector2(x1 + 1, y1)); // spanRight = true; // } // else if(spanRight && x1 < grid.Length[0] - 1 && !fillCondition(grid(x1 + 1, y1), targetValue)) // { // spanRight = false; // } // y1++; // } // } // // return grid; // } // //#pragma endregion // // template<typename T> // static Array2D<T> Lerp(const Array2D<T> &a, const Array2D<T> &b, float t) // { // assert(a.Length[0] == b.Length[0] && a.Length[1] && b.Length[1]); // return Create<T>(a.Length[0], a.Length[1], [&a, &b, t](int x, int y) { return a(x, y) * (1 - t) + b(x, y) * t; }); // } // // /// <summary> Linearly interpolates grid with another grid generated by func. </summary> // /// <param name="func"> The function to generate the second grid with which to interpolate. Signature: (int, int)->T </param> // /// <param name="strength"> How much of an influence the function genereated grid has on the result. 0: original grid; 1: generated grid </param> // template<typename T, typename Func > // static Array2D<T> Manipulate(const Array2D<T> &grid, Func func, float strength) // { // Array2D<T> result(grid.Length[0], grid.Length[1]); // result = Create<T>(grid.Length[0], grid.Length[1], func); // result = Lerp(grid, result, strength); // // return grid; // } // // /// <summary> Masks the given grid, conserving the original values of the grid contained in conservedCells, and setting all others to maskValue. </summary> // template<typename T> // static Array2D<T> Mask(const Array2D<T> &grid, const std::vector<IntVector2> &conservedCells, float maskValue = 0) // { // Array2D<T> result(grid.Length[0], grid.Length[1]); // if(maskValue != 0) { std::fill(result.v.begin(), result.v.end(), maskValue); } // //for(auto iv : conservedCells) { result(iv.x, iv.y) = grid(iv.x, iv.y); } // // return result; // } // // /// <summary> // /// Masks the given grid, setting maskValue for cells contained in maskedCells, and setting all others to the origianl values. // /// </summary> // template<typename T> // static Array2D<T> MaskSubtract(const Array2D<T> &grid, const std::vector<IntVector2> &maskedCells, float maskValue = 0) // { // Array2D<T> result = grid; // for(auto iv : maskedCells) { result(iv.x, iv.y) = maskValue; } // // return result; // } // // /// <summary> // /// Masks the given grid, setting fillValue for cells contained in conservedCells, and setting all others to maskValue. // /// </summary> // template<typename T> // static Array2D<T> MaskFilled(const Array2D<T> &grid, const std::vector<IntVector2> &conservedCells, float fillValue = 1, float maskValue = 0) // { // Array2D<T> result(grid.Length[0], grid.Length[1]); // if(maskValue != 0) { std::fill(result.v.begin(), result.v.end(), maskValue); } // for(auto iv : conservedCells) { result(iv.x, iv.y) = fillValue; } // // return result; // } // // //TODO: Make NearestPointsInCollection not neccessarily have to create a Voronoi diagram, if the user already has one. Problem: The user doesn't know which collection's Voronoi diagram is needed. // //TODO: Make NearestPointsInCollection work on a grid the size of the bounding box of collectionA and collectionB, instead of the whole grid they are based on (and check whether it's more efficient!). // //TODO: Make Mask's maskValue and the DistanceTransform's minValueThreshold be non-hard-coded (is this really neccessary? <- Neo from the far future). // // //This algorithm works by getting the Voronoi diagram of the larger collectionA, // //looking at all the Voronoi regions that touch collectionB, and comparing (brute-force) // //all those regions' seeds* to all points of collectionB to find the smallest distance. // //See Vobarkun's answer on https://math.stackexchange.com/questions/2399957/shortest-distance-between-two-digital-blobs for more information. // //*seed: the point a Voronoi region refers to. See https://en.wikipedia.org/wiki/Voronoi_diagram. // // /// <summary> // /// Returns the two closest points that are from two different collections of points. // /// </summary> // static std::array<IntVector2, 2> NearestPointsInCollections(int gridWidth, int gridHeight, std::vector<IntVector2> collectionA, std::vector<IntVector2> collectionB) // {//TODO: Voronoi: Add getCondition // //Voronoi Diagram // Array2D<IntVector2> voronoi; // //We should create the Voronoi diagram of the largest collection of the two, as the Voronoi's efficiency // //is mostly independant on the collection's size, the brute-force comparison afterwards isn't. // if(collectionA.size() < collectionB.size()) // { // std::vector<IntVector2> collectionTemp = collectionA; // collectionA = collectionB; // collectionB = collectionTemp; // } // // //Create a grid with only collectionA and get it's Voronoi diagram. // Array2D<float> collectionAGrid(gridWidth, gridHeight); // collectionAGrid = Mask(collectionAGrid, collectionA, -2); // // DistanceTransform(collectionAGrid, voronoi, [&collectionAGrid](float f) { return f > -1.f; }); // // //Find all regions of the diagram, which contain seeds* that are possible nearest points of collectionB. // std::vector<IntVector2> closeSeeds; // for(int i = 0; i < collectionB.size(); i++) // { // IntVector2 collectionPoint = collectionB[i]; // IntVector2 closeSeed = voronoi(collectionPoint.x, collectionPoint.y); // if(std::find(closeSeeds.begin(), closeSeeds.end(), closeSeed) != closeSeeds.end()) // { // closeSeeds.push_back(closeSeed); // } // } // // //Brute-force the distance between all points of collectionB and the remaining points of collectionA. // float minDistance = INFINITY; // int nearestIA = -1, nearestIB = -1; // for(int iB = 0; iB < collectionB.size(); iB++) // { // IntVector2 b = collectionB[iB]; // for(int iA = 0; iA < closeSeeds.size(); iA++) // { // IntVector2 a = closeSeeds[iA]; // IntVector2 diff = b - a; // float Distance = (float)(diff.x * diff.x + diff.y * diff.y); // // if(Distance < minDistance) // { // minDistance = Distance; // nearestIA = iA; // nearestIB = iB; // } // } // } // return { IntVector2(), IntVector2() }; // //return { closeSeeds[nearestIA], collectionB[nearestIB] }; // } // //#undef min //#undef max // template<typename T> // static Array2D<T> Normalize(const Array2D<T> &grid, T maxValue = 1.f) // { // T max = std::numeric_limits<T>::min(); // for(uint i = 0; i < grid.v.size(); i++) // { // max = (grid.v[i] > max) ? grid.v[i] : max; // } // // return Create<T>(grid.Length[0], grid.Length[1], [&grid, max](int x, int y) { return grid(x, y) / max; }); // } // // //See https://rosettacode.org/wiki/Bilinear_interpolation for more information. // template<typename T> // static Array2D<T> ScaleBy(const ClampedArray2D<T> &grid, float scaleX, float scaleY) // { // int newWidth = (int)grid.Length[0] * scaleX; // int newHeight = (int)grid.Length[1] * scaleY; // // Array2D<T> result(newWidth, newHeight); // // for(uint y = 0; y < newHeight; y++)//1: Make changes here // { // for(uint x = 0; x < newWidth; x++)//1: Make changes here // { // float gx = x / (float)(newWidth) * (grid.Length[0]);//2: Make changes here // float gy = y / (float)(newHeight) * (grid.Length[1]);//2: Make changes here // // int gxi = (int)gx; // int gyi = (int)gy; // T c00 = grid(gxi, gyi); // T c10 = grid(gxi + 1, gyi); /*TODO: Currently, ScaledBy has to sample 1 pixel over the right/upper border of the grid, is there any way of preventing this? (see comment 1 and 2)*/ // T c01 = grid(gxi, gyi + 1); // T c11 = grid(gxi + 1, gyi + 1); // result(x, y) = Math::BiLerp(c00, c10, c01, c11, gx - gxi, gy - gyi); // } // } // // return result; // } // // template<typename T> // static Array2D<T> ScaleBy(const Array2D<T> &grid, float scale) { return ScaleBy<T>(grid, scale, scale); } // template<typename T> // static Array2D<T> ScaleTo(const Array2D<T> &grid, int width, int height) // { // float scaleX = (float)width / grid.Length[0]; // float scaleY = (float)height / grid.Length[1]; // // return ScaleBy<T>(grid, scaleX, scaleY); // } //}; //
34.055202
203
0.624221
[ "vector", "transform" ]
ccbcdfbcda5ae88e73f097fd2020ddeb5fcbae46
2,502
h
C
granary/client.h
Granary/granary
f9ac2b6af0864f420b93917dc21a38041905b3aa
[ "BSD-3-Clause" ]
37
2015-03-13T08:29:46.000Z
2022-03-04T06:54:29.000Z
granary/client.h
Granary/granary
f9ac2b6af0864f420b93917dc21a38041905b3aa
[ "BSD-3-Clause" ]
null
null
null
granary/client.h
Granary/granary
f9ac2b6af0864f420b93917dc21a38041905b3aa
[ "BSD-3-Clause" ]
3
2015-10-16T21:18:01.000Z
2022-03-04T06:54:31.000Z
/* Copyright 2012-2013 Peter Goodman, all rights reserved. */ /* * client.h * * Created on: 2013-02-05 * Author: pag */ #ifndef GRANARY_CLIENT_H_ #define GRANARY_CLIENT_H_ #include "granary/globals.h" #ifndef IF_CONFIG_FEATURE_CLIENT_HANDLE_INTERRUPT # if CONFIG_FEATURE_CLIENT_HANDLE_INTERRUPT # define IF_CONFIG_FEATURE_CLIENT_HANDLE_INTERRUPT(...) __VA_ARGS__ # else # define IF_CONFIG_FEATURE_CLIENT_HANDLE_INTERRUPT(...) # endif #endif #ifndef GRANARY_DONT_INCLUDE_CSTDLIB # include "granary/state.h" # include "granary/instruction.h" # include "granary/policy.h" # include "granary/detach.h" # include "granary/emit_utils.h" # include "granary/register.h" # include "granary/printf.h" # include "granary/dynamorio.h" # include "granary/code_cache.h" # include "granary/basic_block.h" # define DECLARE_POLICY(policy_name, auto_instrument_host) \ struct policy_name : public granary::instrumentation_policy { \ public: \ \ enum { \ AUTO_INSTRUMENT_HOST = auto_instrument_host \ }; \ \ granary::instrumentation_policy visit_app_instructions( \ granary::cpu_state_handle, \ granary::basic_block_state &, \ granary::instruction_list &ls \ ) ; \ \ granary::instrumentation_policy visit_host_instructions( \ granary::cpu_state_handle, \ granary::basic_block_state &, \ granary::instruction_list & \ ) ; \ \ IF_CONFIG_FEATURE_CLIENT_HANDLE_INTERRUPT( \ granary::interrupt_handled_state handle_interrupt( \ granary::cpu_state_handle, \ granary::thread_state_handle, \ granary::basic_block_state &, \ granary::interrupt_stack_frame &, \ granary::interrupt_vector \ ) ; ) \ } namespace client { # if CONFIG_FEATURE_CLIENT_HANDLE_INTERRUPT /// Handle an interrupt in kernel code. granary::interrupt_handled_state handle_kernel_interrupt( granary::cpu_state_handle cpu, granary::thread_state_handle thread, granary::interrupt_stack_frame &isf, granary::interrupt_vector vector ) ; # endif } #else # define DECLARE_POLICY(policy_name, auto_instrument_host) #endif #endif /* GRANARY_CLIENT_H_ */
31.670886
73
0.627498
[ "vector" ]
ccbfdecf2f62b1a45c880437921dff4b13b14d50
11,867
c
C
src/LLDA/lib/OnlineLDA_ParticleFilter/learn.c
mirelasilva/Lumen-Framework
33c1aed07da7df92be14f561c81250a32fcf50c5
[ "BSD-3-Clause" ]
null
null
null
src/LLDA/lib/OnlineLDA_ParticleFilter/learn.c
mirelasilva/Lumen-Framework
33c1aed07da7df92be14f561c81250a32fcf50c5
[ "BSD-3-Clause" ]
null
null
null
src/LLDA/lib/OnlineLDA_ParticleFilter/learn.c
mirelasilva/Lumen-Framework
33c1aed07da7df92be14f561c81250a32fcf50c5
[ "BSD-3-Clause" ]
null
null
null
/* learn.c */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <math.h> #include "MT.h" #include "learn.h" #include "feature.h" #include "imatrix.h" #include "dmatrix.h" #include "util.h" void ldapf_learn(document *data, double alpha, double beta, int ndocs, int nclass, int nlex, int dlenmax, int nparticle, int ess, int rejuvenation, int **n_zw, double **theta){ document *dp; int *n_z; int word_index; int word_num; double *left; double *right; double *p_z; double sum_p_z; double *cum_sum_p_z; double sampling; double **temp_theta; int ***particles_z; int **particles_n_mz; int ***particles_n_zw; int **particles_n_z; double *weights; double sum_weights; double sum_square_weights; double effective_sample_size; int z; int word_counter; int m, w, p, i, j, k, r; int random_word; int random_word_index; int random_word_num; int random_word_num_random; int previous_z; // count data length for(dp = data, ndocs = 0;(dp->len) != -1;dp++, ndocs++) ; // initialize buffers if((n_z = calloc(nclass,sizeof(int))) == NULL){ fprintf(stderr,"ldapf_learn:: cannot allocate n_z.\n"); return; } for(k = 0;k < nclass;k++) for(i = 0;i < nlex;i++) n_z[k] += n_zw[k][i]; if((left = calloc(nclass,sizeof(double))) == NULL){ fprintf(stderr,"ldapf_learn:: cannot allocate left.\n"); return; } if((right = calloc(nclass,sizeof(double))) == NULL){ fprintf(stderr,"ldapf_learn:: cannot allocate right.\n"); return; } if((p_z = calloc(nclass,sizeof(double))) == NULL){ fprintf(stderr,"ldapf_learn:: cannot allocate p_z.\n"); return; } if((cum_sum_p_z = calloc((nclass+1),sizeof(double))) == NULL){ fprintf(stderr,"ldapf_learn:: cannot allocate cum_sum_p_z.\n"); return; } if((temp_theta = dmatrix(ndocs, nclass)) == NULL){ fprintf(stderr,"ldapf_learn:: cannot allocate temp_theta.\n"); exit(1); } printf("Number of new documents = %d\n",ndocs); printf("Number of words = %d\n",nlex); printf("Number of latent classes = %d\n",nclass); printf("Number of particles = %d\n",nparticle); printf("Rejuvenation steps = %d\n",rejuvenation); printf("Effective sample size = %d\n",ess); init_genrand(time(NULL)); // each document for(dp = data, m = 0;(dp->len) != -1;dp++,m++){ printf("document %2d / %3d..\n",m+1,ndocs); if(((particles_z = calloc(nparticle,sizeof(int **))) == NULL) || ((particles_n_mz = calloc(nparticle,sizeof(int *))) == NULL) || ((particles_n_zw = calloc(nparticle,sizeof(int **))) == NULL) || ((particles_n_z = calloc(nparticle,sizeof(int *))) == NULL) || ((weights = calloc(nparticle,sizeof(double))) == NULL)){ fprintf(stderr,"cannot allocate particles.\n"); return; } for(p = 0;p < nparticle;p++){ if((particles_z[p] = calloc((dp->len),sizeof(int *))) == NULL){ fprintf(stderr,"cannot allocate particles_z.\n"); return; } if((particles_n_mz[p] = calloc(nclass,sizeof(int))) == NULL){ fprintf(stderr,"cannot allocate particles_n_mz.\n"); return; } if((particles_n_zw[p] = calloc(nclass,sizeof(int *))) == NULL){ fprintf(stderr,"cannot allocate particles_n_zw.\n"); return; } for(k = 0;k < nclass;k++){ if((particles_n_zw[p][k] = calloc(nlex,sizeof(int))) == NULL){ fprintf(stderr,"cannot allocate particles_n_zw.\n"); return; } } for(k = 0;k < nclass;k++) for(i = 0;i < nlex;i++) particles_n_zw[p][k][i] = n_zw[k][i]; if((particles_n_z[p] = calloc(nclass,sizeof(int))) == NULL){ fprintf(stderr,"cannot allocate particles_n_z.\n"); return; } for(k = 0;k < nclass;k++) particles_n_z[p][k] = n_z[k]; } // initialize weights for(p = 0;p < nparticle;p++) weights[p] = 1.0 / (double)nparticle; // each word in each document word_counter = 0; for(w = 0;w < (dp->len);w++){ printf("\tword %2d / %3d..\r",w+1,(dp->len)); fflush(stdout); word_index = dp->id[w]; word_num = dp->cnt[w]; for(p = 0;p < nparticle;p++){ if((particles_z[p][w] = calloc(word_num,sizeof(int))) == NULL){ fprintf(stderr,"cannot allocate particles_z.\n"); return; } } // each individual word for(i = 0;i < word_num;i++){ // each particle for(p = 0;p < nparticle;p++){ // p_z left for(k = 0;k < nclass;k++){ left[k] = (double)particles_n_mz[p][k] + alpha; left[k] /= ((double)word_counter + (double)nclass * alpha); } // p_z right for(k = 0;k < nclass;k++){ right[k] = (double)particles_n_zw[p][k][word_index] + beta; right[k] /= ((double)particles_n_z[p][k] + (double)nlex * beta); } // conditional distribution p_z sum_p_z = 0.0; for(k = 0;k < nclass;k++){ p_z[k] = left[k] * right[k]; sum_p_z += left[k] * right[k]; } for(k = 0;k < nclass;k++){ p_z[k] /= sum_p_z; // normalize to obtain probabilities } // random sampling from p_z cum_sum_p_z[0] = 0.0; for(k = 0;k < nclass;k++){ cum_sum_p_z[k+1] = cum_sum_p_z[k] + p_z[k]; } sampling = genrand_real3(); for(k = 0;k < nclass;k++){ if((sampling >= cum_sum_p_z[k]) && (sampling < cum_sum_p_z[k+1])){ z = k; break; } } // update buffers particles_n_z[p][z] += 1; particles_n_mz[p][z] += 1; particles_n_zw[p][z][word_index] += 1; particles_z[p][w][i] = z; // update weights weights[p] *= sum_p_z; } // normalize weights sum_weights = 0.0; for(p = 0;p < nparticle;p++) sum_weights += weights[p]; for(p = 0;p < nparticle;p++) weights[p] /= sum_weights; for(p = 0;p < nparticle;p++) temp_theta[m][particles_z[p][w][i]] += weights[p]; // check effective sample size sum_square_weights = 0.0; for(p = 0;p < nparticle;p++) sum_square_weights += weights[p] * weights[p]; effective_sample_size = 1.0 / sum_square_weights; // rejuvenation. if(word_counter > rejuvenation && effective_sample_size < (double)ess){ for(r = 0;r < rejuvenation;r++){ if(w == 0) break; random_word = genrand_int32() % w; // random selection of previous words random_word_index = dp->id[random_word]; random_word_num = dp->cnt[random_word]; if(random_word_num == 0) continue; random_word_num_random = genrand_int32() % random_word_num; for(p = 0;p < nparticle;p++){ previous_z = particles_z[p][random_word][random_word_num_random]; // remove assignment particles_n_z[p][previous_z] -= 1; particles_n_mz[p][previous_z] -= 1; particles_n_zw[p][previous_z][random_word_index] -= 1; //p_z left for(k = 0;k < nclass;k++){ left[k] = (double)particles_n_mz[p][k] + alpha; left[k] /= ((double)word_counter + (double)nclass * alpha); } // p_z right for(k = 0;k < nclass;k++){ right[k] = (double)particles_n_zw[p][k][random_word_index] + beta; right[k] /= ((double)particles_n_z[p][k] + (double)nlex * beta); } // conditional distribution p_z sum_p_z = 0.0; for(k = 0;k < nclass;k++){ p_z[k] = left[k] * right[k]; sum_p_z += left[k] * right[k]; } for(k = 0;k < nclass;k++){ p_z[k] /= sum_p_z; // normalize to obtain probabilities } // random sampling from p_z cum_sum_p_z[0] = 0.0; for(k = 0;k < nclass;k++){ cum_sum_p_z[k+1] = cum_sum_p_z[k] + p_z[k]; } sampling = genrand_real3(); for(k = 0;k < nclass;k++){ if((sampling >= cum_sum_p_z[k]) && (sampling < cum_sum_p_z[k+1])){ z = k; break; } } // update buffers particles_n_z[p][z] += 1; particles_n_mz[p][z] += 1; particles_n_zw[p][z][random_word_index] += 1; particles_z[p][random_word][random_word_num_random] = z; } } for(p = 0;p < nparticle;p++) weights[p] = 1.0 / (double)nparticle; } word_counter += 1; } } printf("\n"); // free for(p = 0;p < nparticle;p++){ for(w = 0;w < (dp->len);w++) free(particles_z[p][w]); free(particles_z[p]); free(particles_n_mz[p]); for(k = 0;k < nclass;k++){ free(particles_n_zw[p][k]); } free(particles_n_zw[p]); free(particles_n_z[p]); } free(particles_z); free(particles_n_mz); free(particles_n_zw); free(particles_n_z); free(weights); } normalize_matrix_row(theta, temp_theta, ndocs, nclass); free(n_z); free(left); free(right); free(p_z); free(cum_sum_p_z); free_dmatrix(temp_theta, ndocs); return; }
41.493007
177
0.429005
[ "3d" ]
ccc0e049d77e40954917b3908541c15397b0d0fc
6,483
h
C
YAX/include/Graphics/GraphicsDevice.h
Swillis57/YAX
cc366b99af9bbce1d1a3a3580fad9f6c50bbfb4e
[ "MS-PL" ]
1
2015-01-29T01:58:56.000Z
2015-01-29T01:58:56.000Z
YAX/include/Graphics/GraphicsDevice.h
Swillis57/YAX
cc366b99af9bbce1d1a3a3580fad9f6c50bbfb4e
[ "MS-PL" ]
1
2015-03-27T11:21:08.000Z
2015-03-27T11:21:08.000Z
YAX/include/Graphics/GraphicsDevice.h
Swillis57/YAX
cc366b99af9bbce1d1a3a3580fad9f6c50bbfb4e
[ "MS-PL" ]
null
null
null
#ifndef _GRAPHICS_DEVICE_H #define _GRAPHICS_DEVICE_H #include <array> #include <memory> #include <type_traits> #include <vector> #include "BlendState.h" #include "DepthStencilState.h" #include "DisplayMode.h" #include "PresentationParameters.h" #include "RasterizerState.h" #include "RenderTargetBinding.h" #include "SamplerStateCollection.h" #include "TextureCollection.h" #include "VertexBufferBinding.h" #include "VertexDeclaration.h" #include "Viewport.h" #include "../Utils.h" #include "../Color.h" #include "../Rectangle.h" struct GLFWwindow; namespace YAX { enum class GraphicsProfile : ui32; enum class PrimitiveType : ui32; enum class ClearOptions : ui32; enum class RenderTargetUsage : ui32; class GameWindow; class GraphicsAdapter; class IndexBuffer; class RenderTarget2D; class RenderTargetCube; struct Vector4; class VertexDeclaration; class VertexBuffer; class GraphicsDevice { friend class GraphicsDeviceManager; public: #pragma region Properties GraphicsDevice(GraphicsAdapter&, GraphicsProfile, const YAX::PresentationParameters&); const GraphicsAdapter* Adapter() const; Color BlendFactor() const; void BlendFactor(Color); YAX::BlendState* BlendState(); void BlendState(const YAX::BlendState&); YAX::DepthStencilState* DepthStencilState(); void DepthStencilState(const YAX::DepthStencilState&); YAX::DisplayMode DisplayMode() const; YAX::GraphicsProfile GraphicsProfile() const; IndexBuffer* Indicies(); void Indicies(IndexBuffer&); i32 MultiSampleMask() const; void MultiSampleMask(i32); YAX::PresentationParameters& PresentationParameters(); YAX::RasterizerState RasterizerState() const; void RasterizerState(const YAX::RasterizerState&); i32 ReferenceStencil() const; void ReferenceStencil(i32); Rectangle ScissorRectangle() const; void ScissorRectangle(Rectangle); SamplerStateCollection& Samplers(); TextureCollection& Textures(); YAX::Viewport Viewport() const; void Viewport(YAX::Viewport); #pragma endregion void Clear(const Color& clearColor) const; void Clear(ClearOptions options, const Color& clearColor, float depthVal, i32 stencilVal) const; void Clear(ClearOptions options, const Vector4& clearColor, float depthVal, i32 stencilVal) const; void DrawIndexedPrimitives(PrimitiveType, i32 baseVertex, i32 minVertIdx, i32 numVerts, i32 startIdx, i32 primCount); void DrawInstancedPrimitives(PrimitiveType, i32 baseVertex, i32 minVertIdx, i32 numVerts, i32 startIdx, i32 primCount, i32 instCount); void DrawPrimitives(PrimitiveType, i32 startVert, i32 primCount); private: //The templated Draw functions need to see these declarations void UpdateVertexAttribs(const VertexDeclaration&); void UpdateMultiBufferVertexAttribs(i32 baseVert); void UpdateState(bool = false); public: template<typename T, typename = std::enable_if<std::is_base_of<IVertexType, T>::value>::type> void DrawUserIndexedPrimitives(PrimitiveType, const std::vector<T>& vertData, i32 vertOffset, i32 numVerts, const std::vector<i16>& idxData, i32 idxOffset, i32 primCount) const { } template<typename T> void DrawUserIndexedPrimitives(PrimitiveType, const std::vector<T>&, i32, i32, const std::vector<i16>&, i32, i32, const VertexDeclaration&) const; template<typename T> void DrawUserIndexedPrimitives(PrimitiveType, const std::vector<T>&, i32, i32, const std::vector<i32>&, i32, i32) const; template<typename T> void DrawUserIndexedPrimitives(PrimitiveType, const std::vector<T>&, i32, i32, const std::vector<i32>&, i32, i32, const VertexDeclaration&) const; template<typename T> void DrawUserPrimitives(PrimitiveType, std::vector<T>&, i32, i32) const; template<typename T> void DrawUserPrimitives(PrimitiveType, std::vector<T>&, i32, i32, const VertexDeclaration&) const; template<typename T> void GetBackBufferData(std::unique_ptr<Rectangle>, std::vector<T>&, i32, i32) const; template<typename T> void GetBackBufferData(std::vector<T>&) const; template<typename T> void GetBackBufferData(std::vector<T>&, i32, i32) const; std::vector<RenderTargetBinding>* GetRenderTargets() const; std::vector<VertexBufferBinding>* GetVertexBuffers() const; void Present() const; void Present(Rectangle*, Rectangle*, GLFWwindow*) const; void Reset() const; void Reset(const YAX::PresentationParameters&) const; void Reset(const YAX::PresentationParameters&, const GraphicsAdapter&) const; void SetRenderTarget(const RenderTarget2D&); void SetRenderTarget(const RenderTargetCube&, CubeMapFace); void SetRenderTargets(const std::vector<RenderTargetBinding>&); void SetVertexBuffer(const VertexBuffer&); void SetVertexBuffer(const VertexBuffer&, i32); void SetVertexBuffers(const std::vector<VertexBufferBinding>&); private: bool _vertBindingsChanged; GraphicsAdapter* _adapter; YAX::BlendState _blendStateOld, _blendState; YAX::DepthStencilState _depthStencilStateOld, _depthStencilState; YAX::DisplayMode _displayMode; YAX::GraphicsProfile _graphicsProfile; GLuint _vao; IndexBuffer* _indices; i32 _msMaskOld, _msMask, _refStencilOld, _refStencil; YAX::PresentationParameters _presParams; YAX::RasterizerState _rasterStateOld, _rasterState; RenderTargetBinding* _boundRenderTarget; std::vector<RenderTargetBinding>* _renderTargets; std::vector<VertexBufferBinding>* _vertexBuffers; Rectangle _scissorRectOld, _scissorRect; SamplerStateCollection _samplers;//, _vertSamplerStates; Is this distinction needed in OpenGL? TextureCollection _textures;//, _vertTextures; The standard requires support for at least 24 combined units const VertexDeclaration* _lastUsedDecl; YAX::Viewport _viewportOld, _viewport; void ApplyFullscreen(GameWindow*); i32 CalcPrimTypeVertices(PrimitiveType, i32); }; } #endif
37.69186
184
0.697671
[ "vector" ]
ccc81a5f6443e3339edc66205bf7cbfd2cf1c81b
3,970
h
C
src/classes/Blockchain/Blockchain.h
zygisau/Blockchain_project
b50ee2fb9408a1064256edbc441e4109f356dcb5
[ "MIT" ]
null
null
null
src/classes/Blockchain/Blockchain.h
zygisau/Blockchain_project
b50ee2fb9408a1064256edbc441e4109f356dcb5
[ "MIT" ]
null
null
null
src/classes/Blockchain/Blockchain.h
zygisau/Blockchain_project
b50ee2fb9408a1064256edbc441e4109f356dcb5
[ "MIT" ]
null
null
null
// // Created by zygim on 2019-10-17. // #ifndef BLOCKCHAIN_BLOCKCHAIN_H #define BLOCKCHAIN_BLOCKCHAIN_H #include "../Block/Block.h" #include "../../functions.h" class Blockchain { private: list<Block> blocks; int nextVersion = 0; int sizeOfTransactionsInBlock = 100; int difficulty = 4; list<Transaction> pickTransactions(list<Transaction>& transPool) { list<Transaction> pickedTransactions; for (int i = 1; i <= sizeOfTransactionsInBlock && !transPool.empty(); i++) { auto it = select_randomly(transPool.begin(), transPool.end()); pickedTransactions.emplace_back(*it); transPool.erase(it); } return pickedTransactions; } Block generateAndMine(list<Transaction>& transactions, string* prevBlock) { int nonce = 0; Block newBlock(prevBlock, nextVersion++, nonce, difficulty, transactions); string blockHash = hashBlock(newBlock); while (!isHashValid(blockHash, difficulty)) { nonce++; newBlock.getHeader()->incNonce(); newBlock.getHeader()->setTimeout(); blockHash = hashBlock(newBlock); } newBlock.setHash(blockHash); return newBlock; } void updateBlockInfo(vector<Block>::iterator block) { block->getHeader()->setPreviousHash(blocks.back().getBlockHashPtr()); block->getHeader()->setVersion(nextVersion); } public: void generateGenesisBlock(list<Transaction>& transPool) { cout << "Picking transactions from the pool" << endl; list<Transaction> transactions = pickTransactions(transPool); if(!transactions.empty()) { cout << "Mining" << endl; Block block = generateAndMine(transactions, nullptr); blocks.push_back(block); cout << "Genesis block created" << endl; } } void generateBlocks(list<Transaction>& transPool) { if (!transPool.empty()) { cout << "Picking 500 transactions" << endl; vector<Block> blockPool = generateBlockPool(transPool, nextVersion, difficulty, sizeOfTransactionsInBlock, blocks.back()); nextVersion++; bool mined; int times = 10; int tries; string blockHash; auto blockIt = select_randomly(blockPool.begin(), blockPool.end()); vector<vector<Block>::iterator> usedBlocks; usedBlocks.reserve(5); cout << "Preparing to mine (prev block hash)" << endl << *(blockIt->getHeader()->getPrevBlock()) << endl; while (!transPool.empty() || blockIt != blockPool.end()) { mined = false; usedBlocks.push_back(blockIt); blockHash = ""; tries = 0; while (tries != times) { blockHash = hashBlock(*blockIt); if (!isHashValid(blockHash, difficulty)) { blockIt->getHeader()->incNonce(); blockIt->getHeader()->setTimeout(); tries++; } else { mined = true; blockIt->setHash(blockHash); blocks.push_back(*blockIt); nextVersion++; cout << "Block mined in " << tries << " tries" << endl << endl; break; } } if (mined) { moveUnusedTransToPool(blockIt, blockPool, transPool); blockIt = blockPool.end(); if (!transPool.empty()) { blockPool = generateBlockPool(transPool, nextVersion, difficulty, sizeOfTransactionsInBlock, blocks.back()); nextVersion++; cout << "Selecting random block" << endl; blockIt = select_randomly(blockPool.begin(), blockPool.end()); updateBlockInfo(blockIt); cout << "Preparing to mine (prev block hash)" << endl << *(blockIt->getHeader()->getPrevBlock()) << endl; } } else { if (usedBlocks.size() < 5) { cout << "TIMEOUT" << "\t" << "Selecting other block" << endl; blockIt = selectRemainingBlock(usedBlocks, blockPool); updateBlockInfo(blockIt); } else { cout << "TIMEOUT" << "\t" << "Making bigger counter" << endl; usedBlocks.clear(); times += 10; blockIt = select_randomly(blockPool.begin(), blockPool.end()); updateBlockInfo(blockIt); } } } } } size_t getBlockchainSize() { return blocks.size(); } }; #endif //BLOCKCHAIN_BLOCKCHAIN_H
30.305344
109
0.656675
[ "vector" ]
cccae884e5048152164356ef02eb0baa3c6628ec
1,736
c
C
pset5/jpg/recover.c
AlexandreSato/CC50
d8438106611fe224c3334265ab30c72786588ebd
[ "MIT" ]
null
null
null
pset5/jpg/recover.c
AlexandreSato/CC50
d8438106611fe224c3334265ab30c72786588ebd
[ "MIT" ]
null
null
null
pset5/jpg/recover.c
AlexandreSato/CC50
d8438106611fe224c3334265ab30c72786588ebd
[ "MIT" ]
null
null
null
/* ************************************************************************************** * recover.c * * Programa para recuperar fotos jpg de um cartão FAT (512bytes por bloco) * * Curso CC50 por Gabriel Lima Guimarães, traduzido do original CS 50 (Harvard) de David J. Malan * Pset 5 * * Aluno: Alexandre Nobuharu Sato e Tabata em Ribeirão Pires - SP, 2 de abril de 2021 * *************************************************************************************/ #include <stdio.h> #include <stdint.h> #include <unistd.h> #define MAGIC_NUMBER 55551 //0xd8ff is jpg and 0x4d42 is bmp typedef uint8_t BYTE; typedef uint16_t WORD; typedef struct { WORD magicNumber; BYTE padding[510]; }__attribute__((__packed__)) BUFFER; int main(void) { FILE *fp = fopen("card.raw", "r"); if (fp == NULL) { printf("Could not open %s.\n", fp); return 1; } //Getting fp size fseek(fp, 0L, SEEK_END); int size = ftell(fp); fseek(fp, 0L, SEEK_SET); int count = 0; for(int i = 0; i < (size / sizeof(BUFFER)); i++) { BUFFER buffer; fread(&buffer, sizeof(BUFFER), 1, fp); if (buffer.magicNumber == MAGIC_NUMBER) { printf("Encontrei %2d em i:%3d\n", ++count, i); char outfile[8]; sprintf (outfile, "%03d.jpg", count); FILE *outptr = fopen(outfile, "w"); if (outptr == NULL) { fprintf(stderr, "Could not create %s.\n", outfile); return 2; } fwrite(&buffer, sizeof(BUFFER), 1, outptr); fread(&buffer, sizeof(BUFFER), 1, fp); do { fwrite(&buffer, sizeof(BUFFER), 1, outptr); fread(&buffer, sizeof(BUFFER), 1, fp); i++; } while (buffer.magicNumber != MAGIC_NUMBER && i < (size / sizeof(BUFFER))); fseek(fp, -sizeof(BUFFER), SEEK_CUR); } } return 0; }
21.432099
97
0.567396
[ "3d" ]
f2d3df3538c6b09c71dfc9ba7b23c0a882642934
14,038
h
C
include/LuaBridge/detail/Stack.h
RobertIndie/smark
1786ae127f1bee73e3d6e949e21244f9279a6003
[ "Apache-2.0" ]
1
2020-05-05T03:24:43.000Z
2020-05-05T03:24:43.000Z
include/LuaBridge/detail/Stack.h
RobertIndie/smark
1786ae127f1bee73e3d6e949e21244f9279a6003
[ "Apache-2.0" ]
18
2020-04-25T07:21:18.000Z
2020-06-21T14:24:32.000Z
include/LuaBridge/detail/Stack.h
RobertIndie/smark
1786ae127f1bee73e3d6e949e21244f9279a6003
[ "Apache-2.0" ]
4
2020-05-08T10:33:57.000Z
2020-05-13T07:39:10.000Z
//------------------------------------------------------------------------------ /* https://github.com/vinniefalco/LuaBridge Copyright 2019, Dmitry Tarakanov Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com> Copyright 2007, Nathan Reed License: The MIT License (http://www.opensource.org/licenses/mit-license.php) 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. */ //============================================================================== #pragma once #include <LuaBridge/detail/LuaHelpers.h> #include <LuaBridge/detail/Userdata.h> #include <string> namespace luabridge { template <class T> struct Stack; template <> struct Stack<void> { static void push(lua_State* L) { (void)L; } }; //------------------------------------------------------------------------------ /** Receive the lua_State* as an argument. */ template <> struct Stack<lua_State*> { static lua_State* get(lua_State* L, int) { return L; } }; //------------------------------------------------------------------------------ /** Push a lua_CFunction. */ template <> struct Stack<lua_CFunction> { static void push(lua_State* L, lua_CFunction f) { lua_pushcfunction(L, f); } static lua_CFunction get(lua_State* L, int index) { return lua_tocfunction(L, index); } static bool isInstance(lua_State* L, int index) { return lua_iscfunction(L, index); } }; //------------------------------------------------------------------------------ /** Stack specialization for `int`. */ template <> struct Stack<int> { static void push(lua_State* L, int value) { lua_pushinteger(L, static_cast<lua_Integer>(value)); } static int get(lua_State* L, int index) { return static_cast<int>(luaL_checkinteger(L, index)); } static bool isInstance(lua_State* L, int index) { return lua_type(L, index) == LUA_TNUMBER; } }; //------------------------------------------------------------------------------ /** Stack specialization for `unsigned int`. */ template <> struct Stack<unsigned int> { static void push(lua_State* L, unsigned int value) { lua_pushinteger(L, static_cast<lua_Integer>(value)); } static unsigned int get(lua_State* L, int index) { return static_cast<unsigned int>(luaL_checkinteger(L, index)); } static bool isInstance(lua_State* L, int index) { return lua_type(L, index) == LUA_TNUMBER; } }; //------------------------------------------------------------------------------ /** Stack specialization for `unsigned char`. */ template <> struct Stack<unsigned char> { static void push(lua_State* L, unsigned char value) { lua_pushinteger(L, static_cast<lua_Integer>(value)); } static unsigned char get(lua_State* L, int index) { return static_cast<unsigned char>(luaL_checkinteger(L, index)); } static bool isInstance(lua_State* L, int index) { return lua_type(L, index) == LUA_TNUMBER; } }; //------------------------------------------------------------------------------ /** Stack specialization for `short`. */ template <> struct Stack<short> { static void push(lua_State* L, short value) { lua_pushinteger(L, static_cast<lua_Integer>(value)); } static short get(lua_State* L, int index) { return static_cast<short>(luaL_checkinteger(L, index)); } static bool isInstance(lua_State* L, int index) { return lua_type(L, index) == LUA_TNUMBER; } }; //------------------------------------------------------------------------------ /** Stack specialization for `unsigned short`. */ template <> struct Stack<unsigned short> { static void push(lua_State* L, unsigned short value) { lua_pushinteger(L, static_cast<lua_Integer>(value)); } static unsigned short get(lua_State* L, int index) { return static_cast<unsigned short>(luaL_checkinteger(L, index)); } static bool isInstance(lua_State* L, int index) { return lua_type(L, index) == LUA_TNUMBER; } }; //------------------------------------------------------------------------------ /** Stack specialization for `long`. */ template <> struct Stack<long> { static void push(lua_State* L, long value) { lua_pushinteger(L, static_cast<lua_Integer>(value)); } static long get(lua_State* L, int index) { return static_cast<long>(luaL_checkinteger(L, index)); } static bool isInstance(lua_State* L, int index) { return lua_type(L, index) == LUA_TNUMBER; } }; //------------------------------------------------------------------------------ /** Stack specialization for `unsigned long`. */ template <> struct Stack<unsigned long> { static void push(lua_State* L, unsigned long value) { lua_pushinteger(L, static_cast<lua_Integer>(value)); } static unsigned long get(lua_State* L, int index) { return static_cast<unsigned long>(luaL_checkinteger(L, index)); } static bool isInstance(lua_State* L, int index) { return lua_type(L, index) == LUA_TNUMBER; } }; //------------------------------------------------------------------------------ /** * Stack specialization for `long long`. */ template <> struct Stack<long long> { static void push(lua_State* L, long long value) { lua_pushinteger(L, static_cast<lua_Integer>(value)); } static long long get(lua_State* L, int index) { return static_cast<long long>(luaL_checkinteger(L, index)); } static bool isInstance(lua_State* L, int index) { return lua_type(L, index) == LUA_TNUMBER; } }; //------------------------------------------------------------------------------ /** * Stack specialization for `unsigned long long`. */ template <> struct Stack<unsigned long long> { static void push(lua_State* L, unsigned long long value) { lua_pushinteger(L, static_cast<lua_Integer>(value)); } static unsigned long long get(lua_State* L, int index) { return static_cast<unsigned long long>(luaL_checkinteger(L, index)); } static bool isInstance(lua_State* L, int index) { return lua_type(L, index) == LUA_TNUMBER; } }; //------------------------------------------------------------------------------ /** Stack specialization for `float`. */ template <> struct Stack<float> { static void push(lua_State* L, float value) { lua_pushnumber(L, static_cast<lua_Number>(value)); } static float get(lua_State* L, int index) { return static_cast<float>(luaL_checknumber(L, index)); } static bool isInstance(lua_State* L, int index) { return lua_type(L, index) == LUA_TNUMBER; } }; //------------------------------------------------------------------------------ /** Stack specialization for `double`. */ template <> struct Stack<double> { static void push(lua_State* L, double value) { lua_pushnumber(L, static_cast<lua_Number>(value)); } static double get(lua_State* L, int index) { return static_cast<double>(luaL_checknumber(L, index)); } static bool isInstance(lua_State* L, int index) { return lua_type(L, index) == LUA_TNUMBER; } }; //------------------------------------------------------------------------------ /** Stack specialization for `bool`. */ template <> struct Stack<bool> { static void push(lua_State* L, bool value) { lua_pushboolean(L, value ? 1 : 0); } static bool get(lua_State* L, int index) { return lua_toboolean(L, index) ? true : false; } static bool isInstance(lua_State* L, int index) { return lua_isboolean(L, index); } }; //------------------------------------------------------------------------------ /** Stack specialization for `char`. */ template <> struct Stack<char> { static void push(lua_State* L, char value) { lua_pushlstring(L, &value, 1); } static char get(lua_State* L, int index) { return luaL_checkstring(L, index)[0]; } static bool isInstance(lua_State* L, int index) { return lua_type(L, index) == LUA_TSTRING; } }; //------------------------------------------------------------------------------ /** Stack specialization for `const char*`. */ template <> struct Stack<char const*> { static void push(lua_State* L, char const* str) { if (str != 0) lua_pushstring(L, str); else lua_pushnil(L); } static char const* get(lua_State* L, int index) { return lua_isnil(L, index) ? 0 : luaL_checkstring(L, index); } static bool isInstance(lua_State* L, int index) { return lua_isnil(L, index) || lua_type(L, index) == LUA_TSTRING; } }; //------------------------------------------------------------------------------ /** Stack specialization for `std::string`. */ template <> struct Stack<std::string> { static void push(lua_State* L, std::string const& str) { lua_pushlstring(L, str.data(), str.size()); } static std::string get(lua_State* L, int index) { size_t len; if (lua_type(L, index) == LUA_TSTRING) { const char* str = lua_tolstring(L, index, &len); return std::string(str, len); } // Lua reference manual: // If the value is a number, then lua_tolstring also changes the actual value in the stack to // a string. (This change confuses lua_next when lua_tolstring is applied to keys during a // table traversal.) lua_pushvalue(L, index); const char* str = lua_tolstring(L, -1, &len); std::string string(str, len); lua_pop(L, 1); // Pop the temporary string return string; } static bool isInstance(lua_State* L, int index) { return lua_type(L, index) == LUA_TSTRING; } }; template <class T> struct StackOpSelector<T&, false> { typedef T ReturnType; static void push(lua_State* L, T& value) { Stack<T>::push(L, value); } static ReturnType get(lua_State* L, int index) { return Stack<T>::get(L, index); } static bool isInstance(lua_State* L, int index) { return Stack<T>::isInstance(L, index); } }; template <class T> struct StackOpSelector<const T&, false> { typedef T ReturnType; static void push(lua_State* L, const T& value) { Stack<T>::push(L, value); } static ReturnType get(lua_State* L, int index) { return Stack<T>::get(L, index); } static bool isInstance(lua_State* L, int index) { return Stack<T>::isInstance(L, index); } }; template <class T> struct StackOpSelector<T*, false> { typedef T ReturnType; static void push(lua_State* L, T* value) { Stack<T>::push(L, *value); } static ReturnType get(lua_State* L, int index) { return Stack<T>::get(L, index); } static bool isInstance(lua_State* L, int index) { return Stack<T>::isInstance(L, index); } }; template <class T> struct StackOpSelector<const T*, false> { typedef T ReturnType; static void push(lua_State* L, const T* value) { Stack<T>::push(L, *value); } static ReturnType get(lua_State* L, int index) { return Stack<T>::get(L, index); } static bool isInstance(lua_State* L, int index) { return Stack<T>::isInstance(L, index); } }; template <class T> struct Stack<T&> { typedef StackOpSelector<T&, IsUserdata<T>::value> Helper; typedef typename Helper::ReturnType ReturnType; static void push(lua_State* L, T& value) { Helper::push(L, value); } static ReturnType get(lua_State* L, int index) { return Helper::get(L, index); } }; template <class T> struct Stack<const T&> { typedef StackOpSelector<const T&, IsUserdata<T>::value> Helper; typedef typename Helper::ReturnType ReturnType; static void push(lua_State* L, const T& value) { Helper::push(L, value); } static ReturnType get(lua_State* L, int index) { return Helper::get(L, index); } }; template <class T> struct Stack<T*> { typedef StackOpSelector<T*, IsUserdata<T>::value> Helper; typedef typename Helper::ReturnType ReturnType; static void push(lua_State* L, T* value) { Helper::push(L, value); } static ReturnType get(lua_State* L, int index) { return Helper::get(L, index); } }; template <class T> struct Stack<const T*> { typedef StackOpSelector<const T*, IsUserdata<T>::value> Helper; typedef typename Helper::ReturnType ReturnType; static void push(lua_State* L, const T* value) { Helper::push(L, value); } static ReturnType get(lua_State* L, int index) { return Helper::get(L, index); } }; //------------------------------------------------------------------------------ /** * Push an object onto the Lua stack. */ template <class T> inline void push(lua_State* L, T t) { Stack<T>::push(L, t); } //------------------------------------------------------------------------------ /** * Check whether an object on the Lua stack is of type T. */ template <class T> inline bool isInstance(lua_State* L, int index) { return Stack<T>::isInstance(L, index); } } // namespace luabridge
34.4914
99
0.581992
[ "object" ]