<commit_before>#include <stingray/toolkit/Factory.h>

#include <stingray/toolkit/any.h>

#include <stingray/app/RecordErrors.h>
#include <stingray/app/activation_manager/ActivationIntent.h>
#include <stingray/app/application_context/AppChannel.h>
#include <stingray/app/application_context/ChannelList.h>
#include <stingray/app/scheduler/ScheduledEvents.h>
#include <stingray/app/tests/AutoFilter.h>
#include <stingray/ca/BasicSubscription.h>
#include <stingray/ca/BissConditionalAccess.h>
#include <stingray/ca/DreSubscription.h>
#include <stingray/crypto/DefaultCertificateExtension.h>
#include <stingray/crypto/PlainCipherKey.h>
#include <stingray/details/IReceiverTrait.h>
#include <stingray/hdmi/IHDMI.h>
#include <stingray/media/ImageFileMediaData.h>
#include <stingray/media/MediaInfoBase.h>
#include <stingray/media/Mp3MediaInfo.h>
#include <stingray/media/formats/flv/MediaInfo.h>
#include <stingray/media/formats/mp4/MediaInfo.h>
#include <stingray/media/formats/mp4/Stream.h>
#include <stingray/media/formats/mp4/SubstreamDescriptors.h>
#include <stingray/mpeg/ContentDescription.h>
#include <stingray/mpeg/PvrDescription.h>
#include <stingray/mpeg/Stream.h>
#include <stingray/net/DHCPInterfaceConfiguration.h>
#include <stingray/net/IgnoredInterfaceConfiguration.h>
#include <stingray/net/LinkLocalInterfaceConfiguration.h>
#include <stingray/net/ManualInterfaceConfiguration.h>
#include <stingray/parentalcontrol/AgeRating.h>
#ifdef PLATFORM_EMU
#	include <stingray/platform/emu/scanner/Channel.h>
#endif
#ifdef PLATFORM_EMU
#	include <stingray/platform/emu/scanner/EmuScanPerformerFactory.h>
#endif
#ifdef PLATFORM_MSTAR
#	include <stingray/platform/mstar/crypto/HardwareCipherKey.h>
#endif
#ifdef PLATFORM_OPENSSL
#	include <stingray/platform/openssl/crypto/Certificate.h>
#endif
#ifdef PLATFORM_OPENSSL
#	include <stingray/platform/openssl/crypto/CertificateRevocationList.h>
#endif
#ifdef PLATFORM_OPENSSL
#	include <stingray/platform/openssl/crypto/EvpKey.h>
#endif
#ifdef PLATFORM_STAPI
#	include <stingray/platform/stapi/crypto/HardwareCipherKey.h>
#endif
#include <stingray/pushvod/pushvod_emu/PushVODEmulationMovie.h>
#include <stingray/records/FileSystemRecord.h>
#include <stingray/rpc/UrlObjectId.h>
#include <stingray/scanner/DVBServiceId.h>
#include <stingray/scanner/DefaultDVBTBandInfo.h>
#include <stingray/scanner/DefaultMpegService.h>
#include <stingray/scanner/DefaultMpegSubstreamDescriptor.h>
#include <stingray/scanner/DefaultScanParams.h>
#include <stingray/scanner/DefaultScanPerformerFactory.h>
#include <stingray/scanner/DreCasGeographicRegion.h>
#include <stingray/scanner/LybidScanParams.h>
#include <stingray/scanner/LybidScanPerformerFactory.h>
#include <stingray/scanner/TerrestrialScanParams.h>
#include <stingray/scanner/TricolorGeographicRegion.h>
#include <stingray/scanner/TricolorScanParams.h>
#include <stingray/scanner/TricolorScanPerformerFactory.h>
#include <stingray/scanner/lybid/LybidServiceMetaInfo.h>
#include <stingray/scanner/terrestrial/TerrestrialServiceMetaInfo.h>
#include <stingray/scanner/tricolor/TricolorServiceMetaInfo.h>
#include <stingray/stats/StatisticChannelInfo.h>
#include <stingray/streams/PlaybackStreamContent.h>
#include <stingray/streams/RecordStreamContent.h>
#include <stingray/streams/RecordStreamMetaInfo.h>
#include <stingray/time/TransportsTimeSourceObtainer.h>
#include <stingray/tuners/TunerState.h>
#include <stingray/tuners/dvbs/Antenna.h>
#include <stingray/tuners/dvbs/DefaultDVBSTransport.h>
#include <stingray/tuners/dvbs/Satellite.h>
#include <stingray/tuners/dvbt/DVBTTransport.h>
#include <stingray/tuners/ip/TsOverIpTransport.h>
#include <stingray/update/VersionRequirement.h>
#include <stingray/update/system/CopyFile.h>
#include <stingray/update/system/EraseFlashPartition.h>
#include <stingray/update/system/MountFilesystem.h>
#include <stingray/update/system/MoveFile.h>
#include <stingray/update/system/RemoveFile.h>
#include <stingray/update/system/UnmountFilesystem.h>
#include <stingray/update/system/WriteFlashPartition.h>

/* WARNING! This is autogenerated file, DO NOT EDIT! */

namespace stingray { namespace Detail
{
	void Factory::RegisterTypes()
	{
#ifdef BUILD_SHARED_LIB
		/*nothing*/
#else
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::NoSubscriptionRecordError);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::SimpleRecordError);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ActivationKeyIntent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::PersonalCodeIntent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::PlatformNameIntent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ReceiverTraitIntent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::AppChannel);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ChannelList);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::CinemaHallScheduledViewing);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ContinuousScheduledEvent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::DeferredStandby);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::InfiniteScheduledEvent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ScheduledEvent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ScheduledRecord);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ScheduledViewing);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::AutoFilter);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(BasicSubscription);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(BasicSubscriptionProvider);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(BissSubscriptionClass);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(Dre4SubscriptionClass);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultCertificateExtension);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(PlainCipherKey);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBCReceiverTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBSReceiverTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBTReceiverTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(HouseholdClientTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(HouseholdServerTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LybidOperatorTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TricolorOperatorTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(HDMIConfig);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(ImageFileMediaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(ImageFileMediaPreview);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(InMemoryImageMediaPreview);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MediaInfoBase);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(Mp3MediaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(flv::MediaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mp4::MediaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mp4::Stream);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mp4::Mp4MediaAudioSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mp4::Mp4MediaVideoSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mpeg::ContentDescription);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mpeg::PvrDescription);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mpeg::Stream);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DHCPInterfaceConfiguration);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(IgnoredInterfaceConfiguration);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LinkLocalInterfaceConfiguration);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(ManualInterfaceConfiguration);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(AgeRating);
#ifdef PLATFORM_EMU
		TOOLKIT_REGISTER_CLASS_EXPLICIT(emu::EmuServiceId);
#endif
#ifdef PLATFORM_EMU
		TOOLKIT_REGISTER_CLASS_EXPLICIT(emu::RadioChannel);
#endif
#ifdef PLATFORM_EMU
		TOOLKIT_REGISTER_CLASS_EXPLICIT(emu::SubstreamDescriptor);
#endif
#ifdef PLATFORM_EMU
		TOOLKIT_REGISTER_CLASS_EXPLICIT(emu::TVChannel);
#endif
#ifdef PLATFORM_EMU
		TOOLKIT_REGISTER_CLASS_EXPLICIT(emu::EmuScanPerformerFactory);
#endif
#ifdef PLATFORM_MSTAR
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mstar::HardwareCipherKey);
#endif
#ifdef PLATFORM_OPENSSL
		TOOLKIT_REGISTER_CLASS_EXPLICIT(openssl::Certificate);
#endif
#ifdef PLATFORM_OPENSSL
		TOOLKIT_REGISTER_CLASS_EXPLICIT(openssl::CertificateRevocationList);
#endif
#ifdef PLATFORM_OPENSSL
		TOOLKIT_REGISTER_CLASS_EXPLICIT(openssl::EvpKey);
#endif
#ifdef PLATFORM_STAPI
		TOOLKIT_REGISTER_CLASS_EXPLICIT(stapi::HardwareCipherKey);
#endif
		TOOLKIT_REGISTER_CLASS_EXPLICIT(PushVODEmulationMovie);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(FileSystemRecord);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(rpc::UrlObjectId);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBServiceId);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultDVBTBandInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultMpegRadioChannel);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultMpegService);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultMpegTVChannel);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegAudioSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegDataCarouselSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegPcrSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegSubtitlesSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegTeletextBasedSubtitlesSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegTeletextSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegVideoSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultScanParams);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultScanPerformerFactory);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DreCasGeographicRegion);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LybidScanParams);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LybidScanPerformerFactory);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TerrestrialScanParams);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TricolorGeographicRegion);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TricolorScanParams);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TricolorScanPerformerFactory);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LybidServiceMetaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TerrestrialServiceMetaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TricolorServiceMetaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(Detail::any::ObjectHolder<stingray::StatisticChannelInfo>);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(PlaybackStreamContent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(RecordStreamContent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(RecordStreamMetaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TransportTimeOffset);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(CircuitedTunerState);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LockedTunerState);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(UnlockedTunerState);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(Antenna);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultDVBSTransport);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(Satellite);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBTTransport);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TsOverIpTransport);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(VersionRequirement);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(CopyFile);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(EraseFlashPartition);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MountFilesystem);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MoveFile);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(RemoveFile);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(UnmountFilesystem);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(WriteFlashPartition);
#endif
	}
}}
<commit_msg>moved mp3 related classes into formats/mp3<commit_after>#include <stingray/toolkit/Factory.h>

#include <stingray/toolkit/any.h>

#include <stingray/app/RecordErrors.h>
#include <stingray/app/activation_manager/ActivationIntent.h>
#include <stingray/app/application_context/AppChannel.h>
#include <stingray/app/application_context/ChannelList.h>
#include <stingray/app/scheduler/ScheduledEvents.h>
#include <stingray/app/tests/AutoFilter.h>
#include <stingray/ca/BasicSubscription.h>
#include <stingray/ca/BissConditionalAccess.h>
#include <stingray/ca/DreSubscription.h>
#include <stingray/crypto/DefaultCertificateExtension.h>
#include <stingray/crypto/PlainCipherKey.h>
#include <stingray/details/IReceiverTrait.h>
#include <stingray/hdmi/IHDMI.h>
#include <stingray/media/ImageFileMediaData.h>
#include <stingray/media/MediaInfoBase.h>
#include <stingray/media/formats/flv/MediaInfo.h>
#include <stingray/media/formats/mp3/Mp3MediaInfo.h>
#include <stingray/media/formats/mp4/MediaInfo.h>
#include <stingray/media/formats/mp4/Stream.h>
#include <stingray/media/formats/mp4/SubstreamDescriptors.h>
#include <stingray/mpeg/ContentDescription.h>
#include <stingray/mpeg/PvrDescription.h>
#include <stingray/mpeg/Stream.h>
#include <stingray/net/DHCPInterfaceConfiguration.h>
#include <stingray/net/IgnoredInterfaceConfiguration.h>
#include <stingray/net/LinkLocalInterfaceConfiguration.h>
#include <stingray/net/ManualInterfaceConfiguration.h>
#include <stingray/parentalcontrol/AgeRating.h>
#ifdef PLATFORM_EMU
#	include <stingray/platform/emu/scanner/Channel.h>
#endif
#ifdef PLATFORM_EMU
#	include <stingray/platform/emu/scanner/EmuScanPerformerFactory.h>
#endif
#ifdef PLATFORM_MSTAR
#	include <stingray/platform/mstar/crypto/HardwareCipherKey.h>
#endif
#ifdef PLATFORM_OPENSSL
#	include <stingray/platform/openssl/crypto/Certificate.h>
#endif
#ifdef PLATFORM_OPENSSL
#	include <stingray/platform/openssl/crypto/CertificateRevocationList.h>
#endif
#ifdef PLATFORM_OPENSSL
#	include <stingray/platform/openssl/crypto/EvpKey.h>
#endif
#ifdef PLATFORM_STAPI
#	include <stingray/platform/stapi/crypto/HardwareCipherKey.h>
#endif
#include <stingray/pushvod/pushvod_emu/PushVODEmulationMovie.h>
#include <stingray/records/FileSystemRecord.h>
#include <stingray/rpc/UrlObjectId.h>
#include <stingray/scanner/DVBServiceId.h>
#include <stingray/scanner/DefaultDVBTBandInfo.h>
#include <stingray/scanner/DefaultMpegService.h>
#include <stingray/scanner/DefaultMpegSubstreamDescriptor.h>
#include <stingray/scanner/DefaultScanParams.h>
#include <stingray/scanner/DefaultScanPerformerFactory.h>
#include <stingray/scanner/DreCasGeographicRegion.h>
#include <stingray/scanner/LybidScanParams.h>
#include <stingray/scanner/LybidScanPerformerFactory.h>
#include <stingray/scanner/TerrestrialScanParams.h>
#include <stingray/scanner/TricolorGeographicRegion.h>
#include <stingray/scanner/TricolorScanParams.h>
#include <stingray/scanner/TricolorScanPerformerFactory.h>
#include <stingray/scanner/lybid/LybidServiceMetaInfo.h>
#include <stingray/scanner/terrestrial/TerrestrialServiceMetaInfo.h>
#include <stingray/scanner/tricolor/TricolorServiceMetaInfo.h>
#include <stingray/stats/StatisticChannelInfo.h>
#include <stingray/streams/PlaybackStreamContent.h>
#include <stingray/streams/RecordStreamContent.h>
#include <stingray/streams/RecordStreamMetaInfo.h>
#include <stingray/time/TransportsTimeSourceObtainer.h>
#include <stingray/tuners/TunerState.h>
#include <stingray/tuners/dvbs/Antenna.h>
#include <stingray/tuners/dvbs/DefaultDVBSTransport.h>
#include <stingray/tuners/dvbs/Satellite.h>
#include <stingray/tuners/dvbt/DVBTTransport.h>
#include <stingray/tuners/ip/TsOverIpTransport.h>
#include <stingray/update/VersionRequirement.h>
#include <stingray/update/system/CopyFile.h>
#include <stingray/update/system/EraseFlashPartition.h>
#include <stingray/update/system/MountFilesystem.h>
#include <stingray/update/system/MoveFile.h>
#include <stingray/update/system/RemoveFile.h>
#include <stingray/update/system/UnmountFilesystem.h>
#include <stingray/update/system/WriteFlashPartition.h>

/* WARNING! This is autogenerated file, DO NOT EDIT! */

namespace stingray { namespace Detail
{
	void Factory::RegisterTypes()
	{
#ifdef BUILD_SHARED_LIB
		/*nothing*/
#else
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::NoSubscriptionRecordError);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::SimpleRecordError);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ActivationKeyIntent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::PersonalCodeIntent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::PlatformNameIntent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ReceiverTraitIntent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::AppChannel);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ChannelList);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::CinemaHallScheduledViewing);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ContinuousScheduledEvent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::DeferredStandby);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::InfiniteScheduledEvent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ScheduledEvent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ScheduledRecord);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ScheduledViewing);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::AutoFilter);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(BasicSubscription);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(BasicSubscriptionProvider);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(BissSubscriptionClass);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(Dre4SubscriptionClass);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultCertificateExtension);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(PlainCipherKey);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBCReceiverTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBSReceiverTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBTReceiverTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(HouseholdClientTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(HouseholdServerTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LybidOperatorTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(SatIpClientTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TricolorOperatorTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(HDMIConfig);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(ImageFileMediaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(ImageFileMediaPreview);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(InMemoryImageMediaPreview);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MediaInfoBase);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(flv::MediaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(Mp3MediaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mp4::MediaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mp4::Stream);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mp4::Mp4MediaAudioSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mp4::Mp4MediaVideoSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mpeg::ContentDescription);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mpeg::PvrDescription);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mpeg::Stream);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DHCPInterfaceConfiguration);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(IgnoredInterfaceConfiguration);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LinkLocalInterfaceConfiguration);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(ManualInterfaceConfiguration);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(AgeRating);
#ifdef PLATFORM_EMU
		TOOLKIT_REGISTER_CLASS_EXPLICIT(emu::EmuServiceId);
#endif
#ifdef PLATFORM_EMU
		TOOLKIT_REGISTER_CLASS_EXPLICIT(emu::RadioChannel);
#endif
#ifdef PLATFORM_EMU
		TOOLKIT_REGISTER_CLASS_EXPLICIT(emu::SubstreamDescriptor);
#endif
#ifdef PLATFORM_EMU
		TOOLKIT_REGISTER_CLASS_EXPLICIT(emu::TVChannel);
#endif
#ifdef PLATFORM_EMU
		TOOLKIT_REGISTER_CLASS_EXPLICIT(emu::EmuScanPerformerFactory);
#endif
#ifdef PLATFORM_MSTAR
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mstar::HardwareCipherKey);
#endif
#ifdef PLATFORM_OPENSSL
		TOOLKIT_REGISTER_CLASS_EXPLICIT(openssl::Certificate);
#endif
#ifdef PLATFORM_OPENSSL
		TOOLKIT_REGISTER_CLASS_EXPLICIT(openssl::CertificateRevocationList);
#endif
#ifdef PLATFORM_OPENSSL
		TOOLKIT_REGISTER_CLASS_EXPLICIT(openssl::EvpKey);
#endif
#ifdef PLATFORM_STAPI
		TOOLKIT_REGISTER_CLASS_EXPLICIT(stapi::HardwareCipherKey);
#endif
		TOOLKIT_REGISTER_CLASS_EXPLICIT(PushVODEmulationMovie);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(FileSystemRecord);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(rpc::UrlObjectId);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBServiceId);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultDVBTBandInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultMpegRadioChannel);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultMpegService);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultMpegTVChannel);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegAudioSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegDataCarouselSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegPcrSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegSubtitlesSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegTeletextBasedSubtitlesSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegTeletextSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegVideoSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultScanParams);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultScanPerformerFactory);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DreCasGeographicRegion);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LybidScanParams);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LybidScanPerformerFactory);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TerrestrialScanParams);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TricolorGeographicRegion);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TricolorScanParams);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TricolorScanPerformerFactory);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LybidServiceMetaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TerrestrialServiceMetaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TricolorServiceMetaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(Detail::any::ObjectHolder<stingray::StatisticChannelInfo>);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(PlaybackStreamContent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(RecordStreamContent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(RecordStreamMetaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TransportTimeOffset);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(CircuitedTunerState);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LockedTunerState);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(UnlockedTunerState);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(Antenna);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultDVBSTransport);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(Satellite);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBTTransport);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TsOverIpTransport);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(VersionRequirement);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(CopyFile);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(EraseFlashPartition);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MountFilesystem);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MoveFile);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(RemoveFile);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(UnmountFilesystem);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(WriteFlashPartition);
#endif
	}
}}
<|endoftext|>


<commit_before><commit_msg>regression test for fdo#53814<commit_after><|endoftext|>


<commit_before>/*
 * This file is part of meego-keyboard
 *
 * Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
 *
 * Contact: Mohammad Anwari <Mohammad.Anwari@nokia.com>
 *
 * 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 Nokia Corporation nor the names of its contributors may be
 * used to endorse or promote products derived from this software without specific
 * prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 */

#include "mimsnapshotpixmapitem.h"
#include "mplainwindow.h"
#include "panparameters.h"

#include <MNamespace>
#include <QDebug>
#include <MScene>
#include <MSceneManager>

namespace
{
}

MImSnapshotPixmapItem::MImSnapshotPixmapItem(const QPixmap &pixmap,
                                             QGraphicsItem* parent)
    : QObject(),
      QGraphicsPixmapItem(pixmap, parent)
{
}

MImSnapshotPixmapItem::MImSnapshotPixmapItem(QGraphicsItem *parent)
    : QObject(),
      QGraphicsPixmapItem(parent)
{
}

MImSnapshotPixmapItem::~MImSnapshotPixmapItem()
{
    connectPanParameters(0);
}

void MImSnapshotPixmapItem::grabScreen(const QRect &rect)
{
    QPixmap pixmap = QPixmap::grabWidget(scene()->views().at(0), rect);

    if (MPlainWindow::instance()->sceneManager()->orientation() == M::Portrait) {
        QTransform portraitTransform;
        portraitTransform.rotate(90);
        pixmap = pixmap.transformed(portraitTransform);
    }

    setPixmap(pixmap);
}

void MImSnapshotPixmapItem::grabWidgets(const QList<QPointer<QGraphicsWidget> > &widgets)
{
    if (widgets.count() == 0) {
        // clear by setting empty pixmap
        setPixmap(QPixmap());
        return;
    }

    const QSize &visibleSceneSize(MPlainWindow::instance()->visibleSceneSize(M::Landscape));
    const bool isPortrait((MPlainWindow::instance()->sceneManager()->orientation() == M::Portrait));
    const QRectF &screenRect(QRectF(QPoint(0, 0), visibleSceneSize));

    QRectF rect;
    foreach (const QGraphicsWidget *widget, widgets) {
        rect |= (widget->sceneBoundingRect() & screenRect);
    }

    qreal posY = 0;
    if (isPortrait) {
        posY = visibleSceneSize.width() - rect.width();
        rect = QRectF(0, 0, rect.height(), rect.width());
    } else {
        posY = visibleSceneSize.height() - rect.height();
    }

    const QPointF pos(0, posY);
    QPixmap pixmap(rect.width(), rect.height());
    pixmap.fill(Qt::transparent);
    QPainter painter(&pixmap);
    foreach (QGraphicsWidget *widget, widgets) {
        QPixmap tp(widget->size().toSize());
        QPainter p(&tp);
        // The children must be inside parent widget, otherwise it only
        // grab children content in side parent widget to the pixmap.
        foreach (QGraphicsItem *item, widget->childItems())
            item->paint(&p, 0, 0);
        widget->paint(&p, 0, 0);

        if (isPortrait) {
            painter.drawPixmap(QPointF(0, widget->scenePos().x() - pos.y()),
                               tp);
        } else {
            painter.drawPixmap(QPointF(widget->scenePos() - pos), tp);
        }
    }

    setPixmap(pixmap);
}

void MImSnapshotPixmapItem::grabPixmaps(const QMap<QPixmap*, QPoint > &pixmaps)
{
    qDebug() << __PRETTY_FUNCTION__ << " with pixmaps:" <<  pixmaps.count();
    if (pixmaps.isEmpty()) {
        // clear by setting empty pixmap
        setPixmap(QPixmap());
        return;
    }

    const bool isPortrait =
        (MPlainWindow::instance()->sceneManager()->orientation() == M::Portrait);

    QRect rect;
    QMap<QPixmap*, QPoint>::const_iterator it = pixmaps.constBegin();
    QPoint basePos = it.value();

    for (it = pixmaps.constBegin(); it != pixmaps.constEnd(); it++) {
        if (!it.key())
            continue;
        rect |= QRect(it.value(), it.key()->size());
        basePos.setX(qMin(it.value().x(), basePos.x()));
        basePos.setY(qMin(it.value().y(), basePos.y()));
    }

    const QSize size = isPortrait ? QSize(rect.height(), rect.width()) : rect.size();
    QPixmap pixmap(size);
    QPainter painter(&pixmap);

    if (isPortrait) {
        QTransform portraitTransform;
        portraitTransform.rotate(90);
        for (it = pixmaps.constBegin(); it != pixmaps.constEnd(); it++) {
            if (!it.key())
                continue;
            painter.drawPixmap(QPointF(it.value() - basePos),
                               QPixmap(*it.key()).transformed(portraitTransform));
        }
    } else {
        for (it = pixmaps.constBegin(); it != pixmaps.constEnd(); it++) {
            if (!it.key())
                continue;
            painter.drawPixmap(QPointF(it.value() - basePos),
                               *it.key());
        }
    }

    setPixmap(pixmap);
}

void MImSnapshotPixmapItem::updatePos(const QPointF &pos)
{
    setPos(pos);
}

void MImSnapshotPixmapItem::updateOpacity(qreal opacity)
{
    setOpacity(opacity);
}

void MImSnapshotPixmapItem::updateScale(qreal scale)
{
    setScale(scale);
}

void MImSnapshotPixmapItem::connectPanParameters(PanParameters *parameters)
{
    if (!mParameters.isNull()) {
        disconnect(mParameters.data(), 0, this, 0);
    }
    mParameters = parameters;

    if (!mParameters.isNull())  {
        connect(parameters, SIGNAL(positionChanged(QPointF)),
                this,       SLOT(updatePos(QPointF)));

        connect(parameters, SIGNAL(opacityChanged(qreal)),
                this,       SLOT(updateOpacity(qreal)));

        connect(parameters, SIGNAL(scaleChanged(qreal)),
                this,       SLOT(updateScale(qreal)));
    }
}
<commit_msg>Fixes: For shapshot item, use single painter instance and blit directly onto target pixmap<commit_after>/*
 * This file is part of meego-keyboard
 *
 * Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
 *
 * Contact: Mohammad Anwari <Mohammad.Anwari@nokia.com>
 *
 * 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 Nokia Corporation nor the names of its contributors may be
 * used to endorse or promote products derived from this software without specific
 * prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 */

#include "mimsnapshotpixmapitem.h"
#include "mplainwindow.h"
#include "panparameters.h"

#include <MNamespace>
#include <QDebug>
#include <MScene>
#include <MSceneManager>

namespace
{
}

MImSnapshotPixmapItem::MImSnapshotPixmapItem(const QPixmap &pixmap,
                                             QGraphicsItem* parent)
    : QObject(),
      QGraphicsPixmapItem(pixmap, parent)
{
}

MImSnapshotPixmapItem::MImSnapshotPixmapItem(QGraphicsItem *parent)
    : QObject(),
      QGraphicsPixmapItem(parent)
{
}

MImSnapshotPixmapItem::~MImSnapshotPixmapItem()
{
    connectPanParameters(0);
}

void MImSnapshotPixmapItem::grabScreen(const QRect &rect)
{
    QPixmap pixmap = QPixmap::grabWidget(scene()->views().at(0), rect);

    if (MPlainWindow::instance()->sceneManager()->orientation() == M::Portrait) {
        QTransform portraitTransform;
        portraitTransform.rotate(90);
        pixmap = pixmap.transformed(portraitTransform);
    }

    setPixmap(pixmap);
}

void MImSnapshotPixmapItem::grabWidgets(const QList<QPointer<QGraphicsWidget> > &widgets)
{
    if (widgets.count() == 0) {
        // clear by setting empty pixmap
        setPixmap(QPixmap());
        return;
    }

    const QSize &visibleSceneSize(MPlainWindow::instance()->visibleSceneSize(M::Landscape));
    const bool isPortrait((MPlainWindow::instance()->sceneManager()->orientation() == M::Portrait));
    const QRectF &screenRect(QRectF(QPoint(0, 0), visibleSceneSize));

    QRectF rect;
    foreach (const QGraphicsWidget *widget, widgets) {
        rect |= (widget->sceneBoundingRect() & screenRect);
    }

    qreal posY = 0;
    if (isPortrait) {
        posY = visibleSceneSize.width() - rect.width();
        rect = QRectF(0, 0, rect.height(), rect.width());
    } else {
        posY = visibleSceneSize.height() - rect.height();
    }

    const QPointF pos(0, posY);
    QPixmap pixmap(rect.width(), rect.height());
    pixmap.fill(Qt::transparent);
    QPainter painter(&pixmap);
    foreach (QGraphicsWidget *widget, widgets) {
        const QPointF tp(isPortrait ? QPointF(0, widget->scenePos().x() - pos.y())
                                    : widget->scenePos() - pos);

        QTransform t;
        t.translate(tp.x(), tp.y());
        painter.setTransform(t);

        foreach (QGraphicsItem *item, widget->childItems())
            item->paint(&painter, 0, 0);

        widget->paint(&painter, 0, 0);
    }

    setPixmap(pixmap);
}

void MImSnapshotPixmapItem::grabPixmaps(const QMap<QPixmap*, QPoint > &pixmaps)
{
    qDebug() << __PRETTY_FUNCTION__ << " with pixmaps:" <<  pixmaps.count();
    if (pixmaps.isEmpty()) {
        // clear by setting empty pixmap
        setPixmap(QPixmap());
        return;
    }

    const bool isPortrait =
        (MPlainWindow::instance()->sceneManager()->orientation() == M::Portrait);

    QRect rect;
    QMap<QPixmap*, QPoint>::const_iterator it = pixmaps.constBegin();
    QPoint basePos = it.value();

    for (it = pixmaps.constBegin(); it != pixmaps.constEnd(); it++) {
        if (!it.key())
            continue;
        rect |= QRect(it.value(), it.key()->size());
        basePos.setX(qMin(it.value().x(), basePos.x()));
        basePos.setY(qMin(it.value().y(), basePos.y()));
    }

    QPixmap pixmap(isPortrait ? QSize(rect.height(), rect.width())
                              : rect.size());
    QPainter painter(&pixmap);

    if (isPortrait) {
        QTransform portraitTransform;
        portraitTransform.rotate(90);
        for (it = pixmaps.constBegin(); it != pixmaps.constEnd(); it++) {
            if (!it.key())
                continue;
            painter.drawPixmap(QPointF(it.value() - basePos),
                               QPixmap(*it.key()).transformed(portraitTransform));
        }
    } else {
        for (it = pixmaps.constBegin(); it != pixmaps.constEnd(); it++) {
            if (!it.key())
                continue;
            painter.drawPixmap(QPointF(it.value() - basePos),
                               *it.key());
        }
    }

    setPixmap(pixmap);
}

void MImSnapshotPixmapItem::updatePos(const QPointF &pos)
{
    setPos(pos);
}

void MImSnapshotPixmapItem::updateOpacity(qreal opacity)
{
    setOpacity(opacity);
}

void MImSnapshotPixmapItem::updateScale(qreal scale)
{
    setScale(scale);
}

void MImSnapshotPixmapItem::connectPanParameters(PanParameters *parameters)
{
    if (!mParameters.isNull()) {
        disconnect(mParameters.data(), 0, this, 0);
    }
    mParameters = parameters;

    if (!mParameters.isNull())  {
        connect(parameters, SIGNAL(positionChanged(QPointF)),
                this,       SLOT(updatePos(QPointF)));

        connect(parameters, SIGNAL(opacityChanged(qreal)),
                this,       SLOT(updateOpacity(qreal)));

        connect(parameters, SIGNAL(scaleChanged(qreal)),
                this,       SLOT(updateScale(qreal)));
    }
}
<|endoftext|>


<commit_before><commit_msg>Revert to increase one deleteion and one indexation, it's still just one operation<commit_after><|endoftext|>


<commit_before>// Copyright © 2013 Lénaïc Bagnères, hnc@singularity.fr

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <iostream>
#include <fstream>
#include <string>

#include <hnc/geometry/is_in_rectangle.hpp>
#include <hnc/test.hpp>
#include <hnc/to_string.hpp>

int main()
{
	int nb_test = 0;

	nb_test += 14;
	{
		hnc::geometry::rectangle<int> r(5, 7, 10, 3);
		std::cout << r << std::endl;

		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5, 7, r), "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5 + 10, 7, r), "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5, 7 + 3, r), "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5 + 10, 7 + 3, r), "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");

		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(6, 8, r), "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5, 7, r), "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");

		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5 - 1, 7, r) == false, "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5 + 10 + 1, 7, r) == false, "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5 - 1, 7 + 3, r) == false, "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5 + 10 + 1, 7 + 3, r) == false, "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");

		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5, 7 - 1, r) == false, "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5 + 10, 7 - 1, r) == false, "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5, 7 + 3 + 1, r) == false, "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5 + 10, 7 + 3 + 1, r) == false, "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");

		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle({ 5, 7 }, r), "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle({ 5, 7 - 1 }, r) == false, "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
	}

	std::cout << std::endl;

	hnc::test::warning(nb_test == 0, "hnc::geometry::is_in_rectangle: " + hnc::to_string(nb_test) + " test fail!\n");

	return nb_test;
}
<commit_msg>Fix tests/geometry_is_in_rectangle.cpp<commit_after>// Copyright © 2013 Lénaïc Bagnères, hnc@singularity.fr

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <iostream>
#include <fstream>
#include <string>

#include <hnc/geometry/is_in_rectangle.hpp>
#include <hnc/test.hpp>
#include <hnc/to_string.hpp>

int main()
{
	int nb_test = 0;

	nb_test += 16;
	{
		hnc::geometry::rectangle<int> r(5, 7, 10, 3);
		std::cout << r << std::endl;

		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5, 7, r), "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5 + 10, 7, r), "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5, 7 + 3, r), "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5 + 10, 7 + 3, r), "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");

		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(6, 8, r), "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5, 7, r), "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");

		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5 - 1, 7, r) == false, "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5 + 10 + 1, 7, r) == false, "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5 - 1, 7 + 3, r) == false, "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5 + 10 + 1, 7 + 3, r) == false, "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");

		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5, 7 - 1, r) == false, "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5 + 10, 7 - 1, r) == false, "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5, 7 + 3 + 1, r) == false, "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle(5 + 10, 7 + 3 + 1, r) == false, "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");

		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle({ 5, 7 }, r), "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
		nb_test -= hnc::test::warning(hnc::geometry::is_in_rectangle({ 5, 7 - 1 }, r) == false, "hnc::geometry::is_in_rectangle " + hnc::to_string(r) + " fails\n");
	}

	std::cout << std::endl;

	hnc::test::warning(nb_test == 0, "hnc::geometry::is_in_rectangle: " + hnc::to_string(nb_test) + " test fail!\n");

	return nb_test;
}
<|endoftext|>


<commit_before>
/*----------------------------------------------------------------*/
//		local info related routines
/*----------------------------------------------------------------*/

//#define USE_WINDOWS_API		// WINDOWS APIgp

#ifdef USE_WINDOWS_API
#include <windows.h>
#endif

#ifdef HSPLINUX
#include <sys/time.h>
#include <time.h>
#endif

#include <stdio.h>
#include <string.h>
#include "localinfo.h"

//-------------------------------------------------------------
//		Interfaces
//-------------------------------------------------------------

CLocalInfo::CLocalInfo()
{
}

CLocalInfo::~CLocalInfo()
{
}

//-------------------------------------------------------------
//		Routines
//-------------------------------------------------------------

int CLocalInfo::GetTime( int index )
{
/*
	Get system time entries
	index :
	    0 wYear
	    1 wMonth
	    2 wDayOfWeek
	    3 wDay
	    4 wHour
	    5 wMinute
	    6 wSecond
	    7 wMilliseconds
*/
#ifdef USE_WINDOWS_API
	SYSTEMTIME st;
	short *a;
	GetLocalTime( &st );
	a=(short *)&st;
	return (int)(a[index]);
#endif
#ifdef HSPLINUX
	struct timeval tv;
	struct tm *lt;

	gettimeofday( &tv, NULL );	// MinGWVerɂĒʂ܂
	lt = localtime( &tv.tv_sec );

	switch( index ) {
	case 0:
		return lt->tm_year+1900;
	case 1:
		return lt->tm_mon+1;
	case 2:
		return lt->tm_wday;
	case 3:
		return lt->tm_mday;
	case 4:
		return lt->tm_hour;
	case 5:
		return lt->tm_min;
	case 6:
		return lt->tm_sec;
	case 7:
		return (int)tv.tv_usec/10000;
	case 8:
		/*	ꉞ}CNb܂Ŏ	*/
		return (int)tv.tv_usec%10000;
	}
#endif
	return 0;
}

char *CLocalInfo::CurrentTime( void )
{
	sprintf( curtime, "\"%02d:%02d:%02d\"",
		GetTime(4),GetTime(5),GetTime(6) );
	return curtime;
}

char *CLocalInfo::CurrentDate( void )
{
	sprintf( curdate, "\"%04d/%02d/%02d\"",
		GetTime(0),GetTime(1),GetTime(3) );
	return curdate;
}

<commit_msg>Windows で __DATE__, __TIME__ が有効でないのを修正<commit_after>
/*----------------------------------------------------------------*/
//		local info related routines
/*----------------------------------------------------------------*/

#ifdef HSPWIN
#define USE_WINDOWS_API		// WINDOWS APIgp
#endif

#ifdef USE_WINDOWS_API
#include <windows.h>
#endif

#ifdef HSPLINUX
#include <sys/time.h>
#include <time.h>
#endif

#include <stdio.h>
#include <string.h>
#include "localinfo.h"

//-------------------------------------------------------------
//		Interfaces
//-------------------------------------------------------------

CLocalInfo::CLocalInfo()
{
}

CLocalInfo::~CLocalInfo()
{
}

//-------------------------------------------------------------
//		Routines
//-------------------------------------------------------------

int CLocalInfo::GetTime( int index )
{
/*
	Get system time entries
	index :
	    0 wYear
	    1 wMonth
	    2 wDayOfWeek
	    3 wDay
	    4 wHour
	    5 wMinute
	    6 wSecond
	    7 wMilliseconds
*/
#ifdef USE_WINDOWS_API
	SYSTEMTIME st;
	short *a;
	GetLocalTime( &st );
	a=(short *)&st;
	return (int)(a[index]);
#endif
#ifdef HSPLINUX
	struct timeval tv;
	struct tm *lt;

	gettimeofday( &tv, NULL );	// MinGWVerɂĒʂ܂
	lt = localtime( &tv.tv_sec );

	switch( index ) {
	case 0:
		return lt->tm_year+1900;
	case 1:
		return lt->tm_mon+1;
	case 2:
		return lt->tm_wday;
	case 3:
		return lt->tm_mday;
	case 4:
		return lt->tm_hour;
	case 5:
		return lt->tm_min;
	case 6:
		return lt->tm_sec;
	case 7:
		return (int)tv.tv_usec/10000;
	case 8:
		/*	ꉞ}CNb܂Ŏ	*/
		return (int)tv.tv_usec%10000;
	}
#endif
	return 0;
}

char *CLocalInfo::CurrentTime( void )
{
	sprintf( curtime, "\"%02d:%02d:%02d\"",
		GetTime(4),GetTime(5),GetTime(6) );
	return curtime;
}

char *CLocalInfo::CurrentDate( void )
{
	sprintf( curdate, "\"%04d/%02d/%02d\"",
		GetTime(0),GetTime(1),GetTime(3) );
	return curdate;
}

<|endoftext|>


<commit_before>// RUN: %clang_cc1 -verify -Wno-return-type -Wno-main -std=c++11 -emit-llvm -triple %itanium_abi_triple -o - %s | FileCheck %s
// expected-no-diagnostics

namespace test1 {
int x;
template <int& D> class T { };
// CHECK: void @_ZN5test12f0ENS_1TIL_ZNS_1xEEEE(
void f0(T<x> a0) {}
}

namespace test1 {
// CHECK: void @_ZN5test12f0Ef
void f0(float) {}
template<void (&)(float)> struct t1 {};
// CHECK: void @_ZN5test12f1ENS_2t1IL_ZNS_2f0EfEEE(
void f1(t1<f0> a0) {}
}

namespace test2 {
// CHECK: void @_ZN5test22f0Ef
void f0(float) {}
template<void (*)(float)> struct t1 {};
// FIXME: Fails because we don't treat as an expression.
// CHECK-FIXME: void @_ZN5test22f1ENS_2t1IXadL_ZNS_2f0EfEEEE(
void f1(t1<f0> a0) {}
}

namespace test3 {
// CHECK: void @test3_f0
extern "C" void test3_f0(float) {}
template<void (&)(float)> struct t1 {};
// CHECK: void @_ZN5test32f1ENS_2t1IL_Z8test3_f0EEE(
void f1(t1<test3_f0> a0) {}
}

namespace test4 {
// CHECK: void @test4_f0
extern "C" void test4_f0(float) {}
template<void (*)(float)> struct t1 {};
// CHECK: void @_ZN5test42f1ENS_2t1IXadL_Z8test4_f0EEEE(
void f1(t1<test4_f0> a0) {}
}

// CHECK: void @test5_f0
extern "C" void test5_f0(float) {}
int main(int) {}

namespace test5 {
template<void (&)(float)> struct t1 {};
// CHECK: void @_ZN5test52f1ENS_2t1IL_Z8test5_f0EEE(
void f1(t1<test5_f0> a0) {}

template<int (&)(int)> struct t2 {};
// CHECK: void @_ZN5test52f2ENS_2t2IL_Z4mainEEE
void f2(t2<main> a0) {}
}

// FIXME: This fails.
namespace test6 {
struct A { void im0(float); };
// CHECK: void @_ZN5test61A3im0Ef
void A::im0(float) {}
template <void(A::*)(float)> class T { };
// FIXME: Fails because we don't treat as an expression.
// CHECK-FAIL: void @_ZN5test62f0ENS_1TIXadL_ZNS_1A3im0EfEEEE(
void f0(T<&A::im0> a0) {}
}

namespace test7 {
  template<typename T>
  struct meta {
    static const unsigned value = sizeof(T);
  };

  template<unsigned> struct int_c {
    typedef float type;
  };

  template<typename T>
  struct X {
    template<typename U>
    X(U*, typename int_c<(meta<T>::value + meta<U>::value)>::type *) { }
  };

  // CHECK: define weak_odr {{.*}} @_ZN5test71XIiEC1IdEEPT_PNS_5int_cIXplL_ZNS_4metaIiE5valueEEsr4metaIS3_EE5valueEE4typeE(
  template X<int>::X(double*, float*);
}

namespace test8 {
  template<typename T>
  struct meta {
    struct type {
      static const unsigned value = sizeof(T);
    };
  };

  template<unsigned> struct int_c {
    typedef float type;
  };

  template<typename T>
  void f(int_c<meta<T>::type::value>) { }

  // CHECK-LABEL: define weak_odr void @_ZN5test81fIiEEvNS_5int_cIXsr4metaIT_E4typeE5valueEEE(
  template void f<int>(int_c<sizeof(int)>);
}

namespace test9 {
  template<typename T>
  struct supermeta {
    template<typename U>
    struct apply {
      typedef T U::*type;
    };
  };

  struct X { };

  template<typename T, typename U>
  typename supermeta<T>::template apply<U>::type f();

  void test_f() {
    // CHECK: @_ZN5test91fIiNS_1XEEENS_9supermetaIT_E5applyIT0_E4typeEv()
    // Note: GCC incorrectly mangles this as
    // _ZN5test91fIiNS_1XEEENS_9supermetaIT_E5apply4typeEv, while EDG
    // gets it right.
    f<int, X>();
  }
}

namespace test10 {
  template<typename T>
  struct X {
    template<typename U>
    struct definition {
    };
  };

  // CHECK: _ZN6test101fIidEENS_1XIT_E10definitionIT0_EES2_S5_
  template<typename T, typename U>
  typename X<T>::template definition<U> f(T, U) { }

  void g(int i, double d) {
    f(i, d);
  }
}

// Report from cxx-abi-dev, 2012.01.04.
namespace test11 {
  int cmp(char a, char b);
  template <typename T, int (*cmp)(T, T)> struct A {};
  template <typename T> void f(A<T,cmp> &) {}
  template void f<char>(A<char,cmp> &);
  // CHECK: @_ZN6test111fIcEEvRNS_1AIT_L_ZNS_3cmpEccEEE(
}

namespace test12 {
  // Make sure we can mangle non-type template args with internal linkage.
  static int f() {}
  const int n = 10;
  template<typename T, T v> void test() {}
  void use() {
    // CHECK-LABEL: define internal void @_ZN6test124testIFivEXadL_ZNS_L1fEvEEEEvv(
    test<int(), &f>();
    // CHECK-LABEL: define internal void @_ZN6test124testIRFivEL_ZNS_L1fEvEEEvv(
    test<int(&)(), f>();
    // CHECK-LABEL: define internal void @_ZN6test124testIPKiXadL_ZNS_L1nEEEEEvv(
    test<const int*, &n>();
    // CHECK-LABEL: define internal void @_ZN6test124testIRKiL_ZNS_L1nEEEEvv(
    test<const int&, n>();
  }
}

// rdar://problem/12072531
// Test the boundary condition of minimal signed integers.
namespace test13 {
  template <char c> char returnChar() { return c; }
  template char returnChar<-128>();
  // CHECK: @_ZN6test1310returnCharILcn128EEEcv()

  template <short s> short returnShort() { return s; }
  template short returnShort<-32768>();
  // CHECK: @_ZN6test1311returnShortILsn32768EEEsv()
}

namespace test14 {
  template <typename> inline int inl(bool b) {
    if (b) {
      static struct {
        int field;
      } a;
      // CHECK: @_ZZN6test143inlIvEEibE1a

      return a.field;
    } else {
      static struct {
        int field;
      } a;
      // CHECK: @_ZZN6test143inlIvEEibE1a_0

      return a.field;
    }
  }

  int call(bool b) { return inl<void>(b); }
}
<commit_msg>Itanium ABI: Restore disabled tests which are correctly mangled<commit_after>// RUN: %clang_cc1 -verify -Wno-return-type -Wno-main -std=c++11 -emit-llvm -triple %itanium_abi_triple -o - %s | FileCheck %s
// expected-no-diagnostics

namespace test1 {
int x;
template <int& D> class T { };
// CHECK: void @_ZN5test12f0ENS_1TIL_ZNS_1xEEEE(
void f0(T<x> a0) {}
}

namespace test1 {
// CHECK: void @_ZN5test12f0Ef
void f0(float) {}
template<void (&)(float)> struct t1 {};
// CHECK: void @_ZN5test12f1ENS_2t1IL_ZNS_2f0EfEEE(
void f1(t1<f0> a0) {}
}

namespace test2 {
// CHECK: void @_ZN5test22f0Ef
void f0(float) {}
template<void (*)(float)> struct t1 {};
// CHECK: void @_ZN5test22f1ENS_2t1IXadL_ZNS_2f0EfEEEE(
void f1(t1<f0> a0) {}
}

namespace test3 {
// CHECK: void @test3_f0
extern "C" void test3_f0(float) {}
template<void (&)(float)> struct t1 {};
// CHECK: void @_ZN5test32f1ENS_2t1IL_Z8test3_f0EEE(
void f1(t1<test3_f0> a0) {}
}

namespace test4 {
// CHECK: void @test4_f0
extern "C" void test4_f0(float) {}
template<void (*)(float)> struct t1 {};
// CHECK: void @_ZN5test42f1ENS_2t1IXadL_Z8test4_f0EEEE(
void f1(t1<test4_f0> a0) {}
}

// CHECK: void @test5_f0
extern "C" void test5_f0(float) {}
int main(int) {}

namespace test5 {
template<void (&)(float)> struct t1 {};
// CHECK: void @_ZN5test52f1ENS_2t1IL_Z8test5_f0EEE(
void f1(t1<test5_f0> a0) {}

template<int (&)(int)> struct t2 {};
// CHECK: void @_ZN5test52f2ENS_2t2IL_Z4mainEEE
void f2(t2<main> a0) {}
}

namespace test6 {
struct A { void im0(float); };
// CHECK: void @_ZN5test61A3im0Ef
void A::im0(float) {}
template <void(A::*)(float)> class T { };
// CHECK: void @_ZN5test62f0ENS_1TIXadL_ZNS_1A3im0EfEEEE(
void f0(T<&A::im0> a0) {}
}

namespace test7 {
  template<typename T>
  struct meta {
    static const unsigned value = sizeof(T);
  };

  template<unsigned> struct int_c {
    typedef float type;
  };

  template<typename T>
  struct X {
    template<typename U>
    X(U*, typename int_c<(meta<T>::value + meta<U>::value)>::type *) { }
  };

  // CHECK: define weak_odr {{.*}} @_ZN5test71XIiEC1IdEEPT_PNS_5int_cIXplL_ZNS_4metaIiE5valueEEsr4metaIS3_EE5valueEE4typeE(
  template X<int>::X(double*, float*);
}

namespace test8 {
  template<typename T>
  struct meta {
    struct type {
      static const unsigned value = sizeof(T);
    };
  };

  template<unsigned> struct int_c {
    typedef float type;
  };

  template<typename T>
  void f(int_c<meta<T>::type::value>) { }

  // CHECK-LABEL: define weak_odr void @_ZN5test81fIiEEvNS_5int_cIXsr4metaIT_E4typeE5valueEEE(
  template void f<int>(int_c<sizeof(int)>);
}

namespace test9 {
  template<typename T>
  struct supermeta {
    template<typename U>
    struct apply {
      typedef T U::*type;
    };
  };

  struct X { };

  template<typename T, typename U>
  typename supermeta<T>::template apply<U>::type f();

  void test_f() {
    // CHECK: @_ZN5test91fIiNS_1XEEENS_9supermetaIT_E5applyIT0_E4typeEv()
    // Note: GCC incorrectly mangles this as
    // _ZN5test91fIiNS_1XEEENS_9supermetaIT_E5apply4typeEv, while EDG
    // gets it right.
    f<int, X>();
  }
}

namespace test10 {
  template<typename T>
  struct X {
    template<typename U>
    struct definition {
    };
  };

  // CHECK: _ZN6test101fIidEENS_1XIT_E10definitionIT0_EES2_S5_
  template<typename T, typename U>
  typename X<T>::template definition<U> f(T, U) { }

  void g(int i, double d) {
    f(i, d);
  }
}

// Report from cxx-abi-dev, 2012.01.04.
namespace test11 {
  int cmp(char a, char b);
  template <typename T, int (*cmp)(T, T)> struct A {};
  template <typename T> void f(A<T,cmp> &) {}
  template void f<char>(A<char,cmp> &);
  // CHECK: @_ZN6test111fIcEEvRNS_1AIT_L_ZNS_3cmpEccEEE(
}

namespace test12 {
  // Make sure we can mangle non-type template args with internal linkage.
  static int f() {}
  const int n = 10;
  template<typename T, T v> void test() {}
  void use() {
    // CHECK-LABEL: define internal void @_ZN6test124testIFivEXadL_ZNS_L1fEvEEEEvv(
    test<int(), &f>();
    // CHECK-LABEL: define internal void @_ZN6test124testIRFivEL_ZNS_L1fEvEEEvv(
    test<int(&)(), f>();
    // CHECK-LABEL: define internal void @_ZN6test124testIPKiXadL_ZNS_L1nEEEEEvv(
    test<const int*, &n>();
    // CHECK-LABEL: define internal void @_ZN6test124testIRKiL_ZNS_L1nEEEEvv(
    test<const int&, n>();
  }
}

// rdar://problem/12072531
// Test the boundary condition of minimal signed integers.
namespace test13 {
  template <char c> char returnChar() { return c; }
  template char returnChar<-128>();
  // CHECK: @_ZN6test1310returnCharILcn128EEEcv()

  template <short s> short returnShort() { return s; }
  template short returnShort<-32768>();
  // CHECK: @_ZN6test1311returnShortILsn32768EEEsv()
}

namespace test14 {
  template <typename> inline int inl(bool b) {
    if (b) {
      static struct {
        int field;
      } a;
      // CHECK: @_ZZN6test143inlIvEEibE1a

      return a.field;
    } else {
      static struct {
        int field;
      } a;
      // CHECK: @_ZZN6test143inlIvEEibE1a_0

      return a.field;
    }
  }

  int call(bool b) { return inl<void>(b); }
}
<|endoftext|>


<commit_before>/*
  ==============================================================================

    ADSR.cpp
    Created: 5 Dec 2014 4:16:24pm
    Author:  Penguinum-tea

  ==============================================================================
*/

#include "ADSR.h"
#include <stdio.h>

namespace homu {

void ADSR::start() {
    state = attackState;
    current_sample = 0;
}

void ADSR::setAttack(float a) { attack = int(a * sample_rate * 0.5 + 1); }

void ADSR::setDecay(float d) { decay = int(d * sample_rate * 0.5 + 1); }

void ADSR::setSustain(float s) { sustain = s; }

void ADSR::setRelease(float r) { release = int(r * sample_rate * 0.5 + 1); }

float ADSR::nextSample() {
    const int cur_state = state;
    switch (cur_state) {
    case attackState:
        last_value = float(current_sample) / float(attack);
        if (current_sample >= attack) {
            state++;
            current_sample = 0;
        }
        break;
    case decayState:
        last_value = 1 - (1 - sustain) * float(current_sample) / float(decay);
        if (current_sample >= decay) {
            state++;
            current_sample = 0;
        }
        break;
    case sustainState:
        last_value = sustain;
        break;
    case releaseState:
        last_value =
            release_max - release_max * float(current_sample) / float(release);
        if (current_sample >= release) {
            state = finalState;
        }
        break;
    default:
        last_value = 0;
        break;
    }
    current_sample++;
    return last_value;
}

void ADSR::stopSustain() {
    if (state < releaseState) {
        state = releaseState;
        release_max = last_value;
        current_sample = 0;
    }
}

bool ADSR::finished() const {
    return (state == finalState);
}

}
<commit_msg>ADSR logic fix<commit_after>/*
  ==============================================================================

    ADSR.cpp
    Created: 5 Dec 2014 4:16:24pm
    Author:  Penguinum-tea

  ==============================================================================
*/

#include "ADSR.h"
#include <stdio.h>

namespace homu {

void ADSR::start() {
    state = attackState;
    current_sample = 0;
}

void ADSR::setAttack(float a) { attack = int(a * sample_rate); }

void ADSR::setDecay(float d) { decay = int(d * sample_rate); }

void ADSR::setSustain(float s) { sustain = s; }

void ADSR::setRelease(float r) { release = int(r * sample_rate); }

float ADSR::nextSample() {
    const int cur_state = state;
    switch (cur_state) {
    case attackState:
        if (attack == 0) {
            last_value = 1;
            state++;
        } else {
            last_value = float(current_sample) / float(attack);
            if (current_sample >= attack) {
                state++;
                current_sample = 0;
            }
        }
        break;
    case decayState:
        if (decay == 0) {
            last_value = sustain;
            state++;
        } else {
            last_value =
                1 - (1 - sustain) * float(current_sample) / float(decay);
            if (current_sample >= decay) {
                state++;
                current_sample = 0;
            }
        }
        break;
    case sustainState:
        last_value = sustain;
        break;
    case releaseState:
        if (release == 0) {
            last_value = 0;
            state++;
        } else {
            last_value = release_max -
                         release_max * float(current_sample) / float(release);
            if (current_sample >= release) {
                state = finalState;
            }
        }
        break;
    default:
        last_value = 0;
        break;
    }
    current_sample++;
    return last_value;
}

void ADSR::stopSustain() {
    if (state < releaseState) {
        state = releaseState;
        release_max = last_value;
        current_sample = 0;
    }
}

bool ADSR::finished() const {
    return (state == finalState);
}

}
<|endoftext|>


<commit_before>/****************************************************************************
 *
 *   Copyright (c) 2018 PX4 Development Team. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 * 3. Neither the name PX4 nor the names of its contributors may be
 *    used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 ****************************************************************************/

/**
 * @file SMBus.cpp
 * SMBus v2.0 protocol implementation.
 *
 * @author Jacob Dahl <dahl.jakejacob@gmail.com>
 *
 * TODO
 *  - Enable SMBus mode at the NuttX level. This may be tricky sharing the bus with i2c.
 *  	i.e STM32f4 see platforms/nuttx/Nuttx/nuttx/arch/arm/src/stm32/stm32f40xxx_i2c.c
 *  - Add remaining SMBus protocol messages as needed
 */

#include "SMBus.hpp"

SMBus::SMBus(int bus_num, uint16_t address) :
	I2C("BATT_SMBUS_I2C", nullptr, bus_num, address, 100000)
{
}

int SMBus::read_word(const uint8_t cmd_code, uint16_t &data)
{
	uint8_t buf[6];
	// 2 data bytes + pec byte
	int result = transfer(&cmd_code, 1, buf + 3, 3);

	if (result == PX4_OK) {
		data = buf[3] | ((uint16_t)buf[4] << 8);
		// Check PEC.
		uint8_t addr = get_device_address() << 1;
		buf[0] = addr | 0x00;
		buf[1] = cmd_code;
		buf[2] = addr | 0x01;

		uint8_t pec = get_pec(buf, sizeof(buf) - 1);

		if (pec != buf[sizeof(buf) - 1]) {
			result = -EINVAL;
		}
	}

	return result;
}

int SMBus::write_word(const uint8_t cmd_code, uint16_t data)
{
	// 2 data bytes + pec byte
	uint8_t buf[5];
	buf[0] = (get_device_address() << 1) | 0x10;
	buf[1] = cmd_code;
	buf[2] = data & 0xff;
	buf[3] = (data >> 8) & 0xff;

	buf[4] = get_pec(buf, 4);

	int result = transfer(&buf[1], 4, nullptr, 0);

	return result;
}

int SMBus::block_read(const uint8_t cmd_code, void *data, const uint8_t length, bool use_pec)
{
	unsigned byte_count = 0;
	// addr(wr), cmd_code, addr(r), byte_count, data (32 bytes max), pec
	uint8_t rx_data[32 + 5];

	int result = transfer(&cmd_code, 1, (uint8_t *)&rx_data[3], length + 2);

	uint8_t device_address = get_device_address();
	rx_data[0] = (device_address << 1) | 0x00;
	rx_data[1] = cmd_code;
	rx_data[2] = (device_address << 1) | 0x01;
	byte_count = rx_data[3];

	memcpy(data, &rx_data[4], byte_count);

	if (use_pec) {
		uint8_t pec = get_pec(rx_data, byte_count + 4);

		if (pec != rx_data[byte_count + 4]) {
			result = -EINVAL;
		}
	}

	return result;
}

int SMBus::block_write(const uint8_t cmd_code, void *data, uint8_t byte_count, bool use_pec)
{
	// cmd code[1], byte count[1], data[byte_count] (32max), pec[1] (optional)
	uint8_t buf[32 + 2];

	buf[0] = cmd_code;
	buf[1] = (uint8_t)byte_count;
	memcpy(&buf[2], data, byte_count);

	if (use_pec) {
		uint8_t pec = get_pec(buf, byte_count + 2);
		buf[byte_count + 2] = pec;
		byte_count++;
	}

	unsigned i = 0;
	int result = 0;

	// If block_write fails, try up to 10 times.
	while (i < 10 && ((result = transfer((uint8_t *)buf, byte_count + 2, nullptr, 0)) != PX4_OK)) {
		i++;
	}

	if (i == 10 || result) {
		PX4_WARN("Block_write failed %d times", i);
		result = -EINVAL;
	}

	return result;
}

uint8_t SMBus::get_pec(uint8_t *buff, const uint8_t len)
{
	// Initialise CRC to zero.
	uint8_t crc = 0;
	uint8_t shift_register = 0;
	bool invert_crc;

	// Calculate crc for each byte in the stream.
	for (uint8_t i = 0; i < len; i++) {
		// Load next data byte into the shift register
		shift_register = buff[i];

		// Calculate crc for each bit in the current byte.
		for (uint8_t j = 0; j < 8; j++) {
			invert_crc = (crc ^ shift_register) & 0x80;
			crc <<= 1;
			shift_register <<= 1;

			if (invert_crc) {
				crc ^= SMBUS_PEC_POLYNOMIAL;
			}
		}
	}

	return crc;
}
<commit_msg>smbus return with error if failed transfer<commit_after>/****************************************************************************
 *
 *   Copyright (c) 2018 PX4 Development Team. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 * 3. Neither the name PX4 nor the names of its contributors may be
 *    used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 ****************************************************************************/

/**
 * @file SMBus.cpp
 * SMBus v2.0 protocol implementation.
 *
 * @author Jacob Dahl <dahl.jakejacob@gmail.com>
 *
 * TODO
 *  - Enable SMBus mode at the NuttX level. This may be tricky sharing the bus with i2c.
 *  	i.e STM32f4 see platforms/nuttx/Nuttx/nuttx/arch/arm/src/stm32/stm32f40xxx_i2c.c
 *  - Add remaining SMBus protocol messages as needed
 */

#include "SMBus.hpp"

SMBus::SMBus(int bus_num, uint16_t address) :
	I2C("BATT_SMBUS_I2C", nullptr, bus_num, address, 100000)
{
}

int SMBus::read_word(const uint8_t cmd_code, uint16_t &data)
{
	uint8_t buf[6];
	// 2 data bytes + pec byte
	int result = transfer(&cmd_code, 1, buf + 3, 3);

	if (result == PX4_OK) {
		data = buf[3] | ((uint16_t)buf[4] << 8);
		// Check PEC.
		uint8_t addr = get_device_address() << 1;
		buf[0] = addr | 0x00;
		buf[1] = cmd_code;
		buf[2] = addr | 0x01;

		uint8_t pec = get_pec(buf, sizeof(buf) - 1);

		if (pec != buf[sizeof(buf) - 1]) {
			result = -EINVAL;
		}
	}

	return result;
}

int SMBus::write_word(const uint8_t cmd_code, uint16_t data)
{
	// 2 data bytes + pec byte
	uint8_t buf[5];
	buf[0] = (get_device_address() << 1) | 0x10;
	buf[1] = cmd_code;
	buf[2] = data & 0xff;
	buf[3] = (data >> 8) & 0xff;

	buf[4] = get_pec(buf, 4);

	int result = transfer(&buf[1], 4, nullptr, 0);

	return result;
}

int SMBus::block_read(const uint8_t cmd_code, void *data, const uint8_t length, bool use_pec)
{
	unsigned byte_count = 0;
	// addr(wr), cmd_code, addr(r), byte_count, data (32 bytes max), pec
	uint8_t rx_data[32 + 5];

	int result = transfer(&cmd_code, 1, (uint8_t *)&rx_data[3], length + 2);

	if (result != PX4_OK) {
		return result;
	}

	uint8_t device_address = get_device_address();
	rx_data[0] = (device_address << 1) | 0x00;
	rx_data[1] = cmd_code;
	rx_data[2] = (device_address << 1) | 0x01;
	byte_count = rx_data[3];

	memcpy(data, &rx_data[4], byte_count);

	if (use_pec) {
		uint8_t pec = get_pec(rx_data, byte_count + 4);

		if (pec != rx_data[byte_count + 4]) {
			result = -EINVAL;
		}
	}

	return result;
}

int SMBus::block_write(const uint8_t cmd_code, void *data, uint8_t byte_count, bool use_pec)
{
	// cmd code[1], byte count[1], data[byte_count] (32max), pec[1] (optional)
	uint8_t buf[32 + 2];

	buf[0] = cmd_code;
	buf[1] = (uint8_t)byte_count;
	memcpy(&buf[2], data, byte_count);

	if (use_pec) {
		uint8_t pec = get_pec(buf, byte_count + 2);
		buf[byte_count + 2] = pec;
		byte_count++;
	}

	unsigned i = 0;
	int result = 0;

	// If block_write fails, try up to 10 times.
	while (i < 10 && ((result = transfer((uint8_t *)buf, byte_count + 2, nullptr, 0)) != PX4_OK)) {
		i++;
	}

	if (i == 10 || result) {
		PX4_WARN("Block_write failed %d times", i);
		result = -EINVAL;
	}

	return result;
}

uint8_t SMBus::get_pec(uint8_t *buff, const uint8_t len)
{
	// Initialise CRC to zero.
	uint8_t crc = 0;
	uint8_t shift_register = 0;
	bool invert_crc;

	// Calculate crc for each byte in the stream.
	for (uint8_t i = 0; i < len; i++) {
		// Load next data byte into the shift register
		shift_register = buff[i];

		// Calculate crc for each bit in the current byte.
		for (uint8_t j = 0; j < 8; j++) {
			invert_crc = (crc ^ shift_register) & 0x80;
			crc <<= 1;
			shift_register <<= 1;

			if (invert_crc) {
				crc ^= SMBUS_PEC_POLYNOMIAL;
			}
		}
	}

	return crc;
}
<|endoftext|>