entry: Sync initTagEntry() code

For now use "source" instead of "input" for various functions inside
read.c which we need as we don't initialize "input" yet.
This commit is contained in:
Jiří Techet 2016-10-09 16:49:13 +02:00
parent f23b56b027
commit 00920360da
4 changed files with 99 additions and 10 deletions

View File

@ -504,17 +504,75 @@ out:
return r; return r;
} }
extern void initTagEntry (tagEntryInfo *const e, const char *const name, const kindOption *kind) extern void initTagEntry (tagEntryInfo *const e, const char *const name,
const kindOption *kind)
{ {
Assert (File.source.name != NULL); initTagEntryFull(e, name,
getInputLineNumber (),
getInputLanguageName (),
getInputFilePosition (),
getInputFileTagPath (),
kind,
ROLE_INDEX_DEFINITION,
getSourceFileTagPath(),
getSourceLanguageName(),
getSourceLineNumber() - getInputLineNumber ());
}
extern void initRefTagEntry (tagEntryInfo *const e, const char *const name,
const kindOption *kind, int roleIndex)
{
initTagEntryFull(e, name,
getInputLineNumber (),
getInputLanguageName (),
getInputFilePosition (),
getInputFileTagPath (),
kind,
roleIndex,
getSourceFileTagPath(),
getSourceLanguageName(),
getSourceLineNumber() - getInputLineNumber ());
}
extern void initTagEntryFull (tagEntryInfo *const e, const char *const name,
unsigned long lineNumber,
const char* language,
MIOPos filePosition,
const char *inputFileName,
const kindOption *kind,
int roleIndex,
const char *sourceFileName,
const char* sourceLanguage,
long sourceLineNumberDifference)
{
int i;
Assert (getInputFileName() != NULL);
memset (e, 0, sizeof (tagEntryInfo)); memset (e, 0, sizeof (tagEntryInfo));
e->lineNumberEntry = (bool) (Option.locate == EX_LINENUM); e->lineNumberEntry = (bool) (Option.locate == EX_LINENUM);
e->lineNumber = getSourceLineNumber (); e->lineNumber = lineNumber;
e->language = getSourceLanguageName (); /* e->boundaryInfo = getNestedInputBoundaryInfo (lineNumber); */
e->filePosition = getInputFilePosition (); e->language = language;
e->sourceFileName = getSourceFileTagPath (); e->filePosition = filePosition;
e->name = name; e->inputFileName = inputFileName;
e->kind = kind; e->name = name;
e->extensionFields.scopeIndex = CORK_NIL;
e->kind = kind;
Assert (roleIndex >= ROLE_INDEX_DEFINITION);
Assert (kind == NULL || roleIndex < kind->nRoles);
e->extensionFields.roleIndex = roleIndex;
if (roleIndex > ROLE_INDEX_DEFINITION)
markTagExtraBit (e, XTAG_REFERENCE_TAGS);
e->sourceLanguage = sourceLanguage;
e->sourceFileName = sourceFileName;
e->sourceLineNumberDifference = sourceLineNumberDifference;
e->usedParserFields = 0;
for ( i = 0; i < PRE_ALLOCATED_PARSER_FIELDS; i++ )
e->parserFields[i].ftype = FIELD_UNKNOWN;
} }
extern void setTagWriter (tagWriter *t) extern void setTagWriter (tagWriter *t)

View File

@ -114,7 +114,20 @@ extern const char *tagFileName (void);
extern void openTagFile (void); extern void openTagFile (void);
extern void closeTagFile (const bool resize); extern void closeTagFile (const bool resize);
extern int makeTagEntry (const tagEntryInfo *const tag); extern int makeTagEntry (const tagEntryInfo *const tag);
extern void initTagEntry (tagEntryInfo *const e, const char *const name, const kindOption *kind); extern void initTagEntry (tagEntryInfo *const e, const char *const name,
const kindOption *kind);
extern void initRefTagEntry (tagEntryInfo *const e, const char *const name,
const kindOption *kind, int roleIndex);
extern void initTagEntryFull (tagEntryInfo *const e, const char *const name,
unsigned long lineNumber,
const char* language,
MIOPos filePosition,
const char *inputFileName,
const kindOption *kind,
int roleIndex,
const char *sourceFileName,
const char* sourceLanguage,
long sourceLineNumberDifference);
extern unsigned long numTagsAdded(void); extern unsigned long numTagsAdded(void);
extern void setNumTagsAdded (unsigned long nadded); extern void setNumTagsAdded (unsigned long nadded);

View File

@ -35,6 +35,21 @@ static MIOPos StartOfLine; /* holds deferred position of start of line */
* FUNCTION DEFINITIONS * FUNCTION DEFINITIONS
*/ */
extern langType getInputLanguage (void)
{
return File.source.language;
}
extern const char *getInputLanguageName (void)
{
return getLanguageName (getInputLanguage());
}
extern const char *getInputFileTagPath (void)
{
return vStringValue (File.source.tagPath);
}
extern kindOption *getInputLanguageFileKind (void) extern kindOption *getInputLanguageFileKind (void)
{ {
return getLanguageFileKind (File.input.language); return getLanguageFileKind (File.input.language);

View File

@ -98,6 +98,9 @@ extern inputFile File;
*/ */
/* InputFile: reading from fp in inputFile with updating fields in input fields */ /* InputFile: reading from fp in inputFile with updating fields in input fields */
extern langType getInputLanguage (void);
extern const char *getInputLanguageName (void);
extern const char *getInputFileTagPath (void);
extern kindOption *getInputLanguageFileKind (void); extern kindOption *getInputLanguageFileKind (void);
extern void freeSourceFileResources (void); extern void freeSourceFileResources (void);