public class Vala.CCodeFile {
- public CCodeFileType cfile_type { get; set; }
+ public CCodeFileType file_type { get; private set; }
public weak SourceFile? file { get; private set; }
CCodeFragment constant_declaration = new CCodeFragment ();
CCodeFragment type_member_definition = new CCodeFragment ();
- public CCodeFile (SourceFile? source_file = null) {
+ public CCodeFile (CCodeFileType type = CCodeFileType.SOURCE, SourceFile? source_file = null) {
file = source_file;
- if (source_file != null) {
- cfile_type = CCodeFileType.SOURCE;
- }
+ file_type = type;
}
public bool add_declaration (string name) {
return false;
}
- if (cfile_type == CCodeFileType.SOURCE) {
+ if (file_type == CCodeFileType.SOURCE) {
writer.line_directives = line_directives;
comments.write (writer);
gtk_widget_type = (Class) gtk_ns.scope.lookup ("Widget");
}
- header_file = new CCodeFile ();
- header_file.cfile_type = CCodeFileType.PUBLIC_HEADER;
- internal_header_file = new CCodeFile ();
- internal_header_file.cfile_type = CCodeFileType.INTERNAL_HEADER;
+ header_file = new CCodeFile (CCodeFileType.PUBLIC_HEADER);
+ internal_header_file = new CCodeFile (CCodeFileType.INTERNAL_HEADER);
/* we're only interested in non-pkg source files */
var source_files = context.get_source_files ();
}
public bool add_symbol_declaration (CCodeFile decl_space, Symbol sym, string name) {
- bool in_generated_header = CodeContext.get ().use_header
- && (decl_space.cfile_type != CCodeFileType.PUBLIC_HEADER && !sym.is_internal_symbol ());
+ bool in_generated_header = context.header_filename != null
+ && (decl_space.file_type != CCodeFileType.PUBLIC_HEADER && !sym.is_internal_symbol ());
if (decl_space.add_declaration (name)) {
return true;
}
}
public override void visit_source_file (SourceFile source_file) {
- cfile = new CCodeFile (source_file);
+ cfile = new CCodeFile (CCodeFileType.SOURCE, source_file);
user_marshal_set = new HashSet<string> (str_hash, str_equal);
// Custom unref-methods need to be emitted before G_DEFINE_AUTOPTR_CLEANUP_FUNC,
// so we guard against that special case and handle it in generate_method_declaration.
if (!(base_class.is_compact && is_reference_counting (base_class))
- && (!context.use_header || decl_space.cfile_type == CCodeFileType.PUBLIC_HEADER
- || (decl_space.cfile_type == CCodeFileType.INTERNAL_HEADER && base_class.is_internal_symbol()))) {
+ && (context.header_filename == null|| decl_space.file_type == CCodeFileType.PUBLIC_HEADER
+ || (decl_space.file_type == CCodeFileType.INTERNAL_HEADER && base_class.is_internal_symbol()))) {
string autoptr_cleanup_func;
if (is_reference_counting (base_class)) {
autoptr_cleanup_func = get_ccode_unref_function (base_class);
// in addition to the non-ref-countable case in generate_class_declaration.
unowned Class? cl = m.parent_symbol as Class;
if (cl != null && cl.is_compact && get_ccode_unref_function (cl) == get_ccode_name (m)
- && (!context.use_header || decl_space.cfile_type == CCodeFileType.PUBLIC_HEADER
- || (decl_space.cfile_type == CCodeFileType.INTERNAL_HEADER && cl.is_internal_symbol()))) {
+ && (context.header_filename == null || decl_space.file_type == CCodeFileType.PUBLIC_HEADER
+ || (decl_space.file_type == CCodeFileType.INTERNAL_HEADER && cl.is_internal_symbol()))) {
decl_space.add_type_member_declaration (new CCodeIdentifier ("G_DEFINE_AUTOPTR_CLEANUP_FUNC (%s, %s)".printf (get_ccode_name (cl), get_ccode_name (m))));
decl_space.add_type_member_declaration (new CCodeNewline ());
}
static bool ccode_only;
static bool abi_stability;
static string header_filename;
- static bool use_header;
static string internal_header_filename;
static string internal_vapi_filename;
static string fast_vapi_filename;
{ "api-version", 0, 0, OptionArg.NONE, ref api_version, "Display API version number", null },
{ "ccode", 'C', 0, OptionArg.NONE, ref ccode_only, "Output C code", null },
{ "header", 'H', 0, OptionArg.FILENAME, ref header_filename, "Output C header file", "FILE" },
- { "use-header", 0, 0, OptionArg.NONE, ref use_header, "Use C header file", null },
+ { "use-header", 0, OptionFlags.OPTIONAL_ARG | OptionFlags.NO_ARG, OptionArg.CALLBACK, (void*) option_deprecated, "Use C header file (DEPRECATED AND IGNORED)", null },
{ "includedir", 0, 0, OptionArg.FILENAME, ref includedir, "Directory used to include the C header file", "DIRECTORY" },
{ "internal-header", 'h', 0, OptionArg.FILENAME, ref internal_header_filename, "Output internal C header file", "FILE" },
{ "internal-vapi", 0, 0, OptionArg.FILENAME, ref internal_vapi_filename, "Output vapi with internal api", "FILE" },
context.abi_stability = abi_stability;
context.compile_only = compile_only;
context.header_filename = header_filename;
- if (header_filename == null && use_header) {
- Report.error (null, "--use-header may only be used in combination with --header");
- }
- context.use_header = use_header;
context.internal_header_filename = internal_header_filename;
context.symbols_filename = symbols_filename;
context.includedir = includedir;
*/
public string? internal_header_filename { get; set; }
- public bool use_header { get; set; }
-
/**
* Base directory used for header_filename in the VAPIs.
*/