1// Copyright 2017 The Fuchsia Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#pragma once 6 7#include <map> 8#include <string> 9#include <vector> 10 11#include "generator.h" 12 13/* Generates header files. */ 14class HeaderGenerator : public Generator { 15public: 16 // A prefix on the syscall name, and a predicate that returns 17 // true if it should be omitted from the header. 18 using name_prefix_map = 19 std::vector<std::pair<std::string, bool (*)(const Syscall&)>>; 20 21 HeaderGenerator(const std::string& function_prefix, 22 const name_prefix_map& name_prefixes, 23 const std::string& no_args_type, 24 bool allow_pointer_wrapping, 25 const std::map<std::string, std::string>& attributes) 26 : function_prefix_(function_prefix), 27 name_prefixes_(name_prefixes), 28 no_args_type_(no_args_type), 29 attributes_(attributes), 30 allow_pointer_wrapping_(allow_pointer_wrapping) {} 31 32 bool syscall(std::ofstream& os, const Syscall& sc) override; 33 34private: 35 const std::string function_prefix_; 36 const name_prefix_map name_prefixes_; 37 const std::string no_args_type_; 38 const std::map<std::string, std::string> attributes_; 39 const bool allow_pointer_wrapping_; 40}; 41 42HeaderGenerator kernel_header_generator(); 43HeaderGenerator user_header_generator(); 44HeaderGenerator vdso_header_generator(); 45