class Clangc::File

A particular source file that is part of a translation unit

Public Instance Methods

clangc::File#is_equal(file) → true or false click to toggle source

Returns true if the file1 and file2 point to the same file, or both null. Two ruby objects Clangc::File can be different but can hold the same File_t data.

VALUE
c_File_is_equal(VALUE self, VALUE file)
{
    File_t *f1;
    File_t *f2;
    Data_Get_Struct(self, File_t, f1);
    CHECK_ARG_TYPE(file, File);
    Data_Get_Struct(file, File_t, f2);
    return NOT_0_2_RVAL(clang_File_isEqual(f1->data, f2->data));
}
Clangc::File#is_multiple_include_guarded → true or false click to toggle source

Determine whether the given header is guarded against multiple inclusions, either with the conventional #ifndef/#define/#endif macro guards or with #pragma once.

VALUE
c_File_is_multiple_include_guarded(VALUE self)
{
    File_t *f;
    Data_Get_Struct(self, File_t, f);
    TranslationUnit_t *t;
    Data_Get_Struct(f->parent, TranslationUnit_t, t);
    unsigned int ret = clang_isFileMultipleIncludeGuarded(t->data, f->data);
    return NOT_0_2_RVAL(ret);
}
Clangc::File#mtime → Time click to toggle source

Retrieve the last modification time of the given file.

VALUE
c_File_get_mtime(VALUE self)
{
    File_t *f;
    VALUE mtime = Qnil;
    Data_Get_Struct(self, File_t, f);
    mtime = rb_time_new(clang_getFileTime(f->data), 0);
    return mtime;
}
Clangc::File#name → String click to toggle source

Retrieve the complete file and path name of the given file. Returns Qnil if the CXFile pointer is NULL (this can happen)

VALUE
c_File_get_name(VALUE self)
{
    File_t *f;
    VALUE name = Qnil;
    Data_Get_Struct(self, File_t, f);
    if (f->data != NULL)
    {
        name = CXSTR_2_RVAL(clang_getFileName(f->data));
    }
    else
        name = Qnil;
    return name;
}