Пример #1
0
String
duration_to_string(
	std::chrono::duration<Rep,Period> const &d,
	ProtoExpression const &expression_tree)
{
	FCPPT_PP_PUSH_WARNING
	FCPPT_PP_DISABLE_GCC_WARNING(-Wold-style-cast)
	BOOST_MPL_ASSERT((boost::proto::matches<ProtoExpression, grammar>));
	FCPPT_PP_POP_WARNING

	return
		boost::proto::eval(
			expression_tree,
			context<std::chrono::duration<Rep,Period>,String>(
				d));
}
Пример #2
0
typename boost::enable_if<
	sge::sprite::config::is_texture_level_count<
		Levels
	>,
	void
>::type
apply_texture_levels(
	Function const &_function
)
{
FCPPT_PP_PUSH_WARNING
#if defined(FCPPT_CONFIG_GNU_GCC_COMPILER)
FCPPT_PP_DISABLE_GCC_WARNING(-Wzero-as-null-pointer-constant)
#endif
	boost::mpl::for_each<
		typename sge::sprite::detail::make_texture_levels<
			Levels
		>::type
	>(
		_function
	);

FCPPT_PP_POP_WARNING
}
Пример #3
0
int
main(
	int argc,
	char **argv
)
{
	if(
		argc <= 0
	)
		return EXIT_FAILURE;

	if(
		argc != 2
		&& argc != 3
	)
	{
		fcppt::io::cerr()
			<< FCPPT_TEXT("Usage: ")
			<< fcppt::from_std_string(
				argv[0]
			)
			<< FCPPT_TEXT(" <build_dir> [src_dir]\n");

		return EXIT_FAILURE;
	}

	boost::filesystem::path const build_dir(
		fcppt::from_std_string(
			argv[1]
		)
	);

	boost::filesystem::path const temp_dir(
		build_dir
		/ FCPPT_TEXT("temp_make_headers")
	);

	boost::filesystem::path const make_file(
		temp_dir
		/ FCPPT_TEXT("Makefile")
	);

	boost::filesystem::path const log_file(
		temp_dir
		/ FCPPT_TEXT("log.txt")
	);

	boost::filesystem::remove(
		log_file
	);

	fcppt::string const source_subdir(
		argc == 3
		?
			fcppt::from_std_string(
				argv[2]
			)
		:
			FCPPT_TEXT("src")
	);

	if(
		!boost::filesystem::exists(
			temp_dir
		)
		&&
		!boost::filesystem::create_directory(
			temp_dir
		)
	)
	{
		fcppt::io::cerr()
			<< FCPPT_TEXT("Cannot create ")
			<< temp_dir
			<< FCPPT_TEXT('\n');

		return EXIT_FAILURE;
	}

	for(
		boost::filesystem::recursive_directory_iterator
			dir_it(
				FCPPT_TEXT("include")
			),
			end_it;
		dir_it != end_it;
		++dir_it
	)
	{
		boost::filesystem::path const &path(
			dir_it->path()
		);

		if(
			fcppt::filesystem::extension(
				path
			)
			!= FCPPT_TEXT(".hpp")
		)
			continue;

		if(
			std::find(
				path.begin(),
				path.end(),
				fcppt::string(
					FCPPT_TEXT("impl")
				)
			)
			!= path.end()
		)
			continue;

		boost::filesystem::path::iterator path_it(
			path.begin()
		);

		if(
			path_it
			== path.end()
		)
			continue;

		// skip include/
		++path_it;

		if(
			path_it
			== path.end()
		)
			continue;

		boost::filesystem::path const include_file(
			::make_path_from_iter(
				path_it,
				path.end()
			)
		);

		// skip project name
		++path_it;

		if(
			path_it
			== path.end()
		)
			continue;

		// descend into the build dir as far as possible
		boost::filesystem::path make_path(
			build_dir
			/
			source_subdir
		);

		while(
			boost::filesystem::exists(
				make_path
			)
		)
			make_path /= *path_it++;

		make_path =
			make_path.parent_path()
			/
			FCPPT_TEXT("CMakeFiles");

		if(
			!boost::filesystem::exists(
				make_path
			)
		)
		{
			fcppt::io::cerr()
				<< make_path
				<< FCPPT_TEXT(" does not exist.\n");

			continue;
		}

		optional_path const cmake_dir(
			::find_cmake_dir(
				make_path
			)
		);

		if(
			!cmake_dir
		)
		{
			fcppt::io::cerr()
				<< FCPPT_TEXT("No *.dir found in ")
				<< make_path
				<< FCPPT_TEXT('\n');

			continue;
		}

		boost::filesystem::path const flags_file(
			*cmake_dir
			/ FCPPT_TEXT("flags.make")
		);

		if(
			!boost::filesystem::exists(
				flags_file
			)
		)
		{
			fcppt::io::cerr()
				<< flags_file
				<< FCPPT_TEXT(" does not exist!\n");

			continue;
		}

		boost::filesystem::path const source_file(
			temp_dir
			/
			boost::algorithm::replace_all_copy(
				fcppt::filesystem::path_to_string(
					fcppt::filesystem::replace_extension(
						include_file,
						FCPPT_TEXT("cpp")
					)
				),
				FCPPT_TEXT("/"),
				FCPPT_TEXT("_")
			)
		);

		if(
			!::write_file(
				make_file,
				FCPPT_TEXT("include ")
				+ fcppt::filesystem::path_to_string(
					flags_file
				)
				+ FCPPT_TEXT("\n\n")
				+ FCPPT_TEXT("check-syntax:\n")
				+ FCPPT_TEXT("\tg++ -o /dev/null ${CXX_FLAGS} ${CXX_DEFINES} -S ")
				+ fcppt::filesystem::path_to_string(
					source_file
				)
				+ FCPPT_TEXT(" -fsyntax-only\n\n")
				+ FCPPT_TEXT(".PHONY: check-syntax*/\n")
			)
		)
			return EXIT_FAILURE;

		if(
			!::write_file(
				source_file,
				FCPPT_TEXT("#include <")
				+ fcppt::filesystem::path_to_string(
					include_file
				)
				+ FCPPT_TEXT(">\n")
			)
		)
			return EXIT_FAILURE;

		int const system_ret(
			std::system(
				(
					std::string(
						"make -f "
					)
					+
					fcppt::to_std_string(
						fcppt::filesystem::path_to_string(
							make_file
						)
					)
					+
					" 2>>"
					+
					fcppt::to_std_string(
						fcppt::filesystem::path_to_string(
							log_file
						)
					)
					+
					" 1>/dev/null"
				).c_str()
			)
		);

FCPPT_PP_PUSH_WARNING
FCPPT_PP_DISABLE_GCC_WARNING(-Wcast-qual)
FCPPT_PP_DISABLE_GCC_WARNING(-Wold-style-cast)
		if(
			system_ret == -1
			||
			(
				WIFSIGNALED(
					system_ret
				)
				&&
				(
					WTERMSIG(
						system_ret
					)
					== SIGINT
					||
					WTERMSIG(
						system_ret
					)
					== SIGQUIT
				)
			)
		)
			return EXIT_FAILURE;
FCPPT_PP_POP_WARNING
	}
}
Пример #4
0
int
main()
{
	typedef
	std::map<
		int,
		int
	>
	int_int_map;

	static_assert(
		fcppt::algorithm::detail::optimize_map<
			int_vector,
			int_vector
		>::value,
		"map from vector to vector not optimized"
	);

	static_assert(
		fcppt::algorithm::detail::has_size<
			int_vector
		>::value,
		"vector::size() not detected"
	);

	static_assert(
		fcppt::algorithm::detail::has_reserve<
			int_vector
		>::value,
		"vector::reserve() not detected"
	);

	static_assert(
		!fcppt::algorithm::detail::has_reserve<
			int_int_map
		>::value,
		"map does not have reserve"
	);

	static_assert(
		fcppt::algorithm::detail::has_size<
			int_int_map
		>::value,
		"map::size() not detected"
	);

	static_assert(
		fcppt::algorithm::detail::optimize_map<
			int_vector,
			int_int_map
		>::value,
		"map from map to vector not optimized"
	);

	static_assert(
		!fcppt::algorithm::detail::optimize_map<
			int_int_map,
			int_vector
		>::value,
		"map from vector to map cannot be optimized"
	);

	FCPPT_PP_PUSH_WARNING
	#if defined(FCPPT_CONFIG_CLANG_COMPILER)
	FCPPT_PP_DISABLE_GCC_WARNING(-Wunneeded-member-function)
	FCPPT_PP_DISABLE_GCC_WARNING(-Wunused-member-function)
	#endif
	FCPPT_PP_DISABLE_VC_WARNING(4822)

	struct ra_range
	{
		typedef
		int_vector::iterator
		iterator;

		iterator
		begin() const;

		iterator
		end() const;
	};

	static_assert(
		source_optimized<
			ra_range
		>::value,
		"random access iterator not detected"
	);

	struct bi_range
	{
		typedef
		std::list<
			int
		>::iterator
		iterator;

		iterator
		begin() const;

		iterator
		end() const;
	};

	static_assert(
		!source_optimized<
			bi_range
		>::value,
		"random access iterator not detected"
	);

	FCPPT_PP_POP_WARNING

	enum class test_enum
	{
		test1,
		fcppt_maximum = test1
	};

	static_assert(
		source_optimized<
			fcppt::enum_range<
				test_enum
			>
		>::value,
		"enum range not optimized"
	);

	static_assert(
		source_optimized<
			fcppt::int_range<
				int
			>
		>::value,
		"int range not optimized"
	);

	static_assert(
		source_optimized<
			fcppt::container::grid::pos_range<
				unsigned,
				2
			>
		>::value,
		"grid::pos_range not optimized"
	);

	static_assert(
		source_optimized<
			fcppt::container::grid::pos_ref_range<
				fcppt::container::grid::object<
					unsigned,
					2
				>
			>
		>::value,
		"grid::pos_ref_range not optimized"
	);

}