Skip to content

Commit

Permalink
operator: add operators for accessing end: field
Browse files Browse the repository at this point in the history
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed May 2, 2021
1 parent faa5197 commit c19ead2
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 6 deletions.
8 changes: 4 additions & 4 deletions Tmain/list-fields-fixed-field-handling.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ S signature no NONE s-- no rw Signature of rou
T epoch no NONE -i- no -- the last modified time of the input file (only for F/file kind tag)
Z scope no NONE s-- no rw [tags output] prepend "scope:" key to s/scope field output, [xref and json output] the same as s/ field
a access no NONE s-- no -- Access (or export) of class members
e end no NONE -i- no -- end lines of various items
e end no NONE -i- no rw end lines of various items
f file no NONE --b no -- File-restricted scoping
i inherits no NONE s-b no -- Inheritance information
k NONE no NONE s-- no -- Kind of tag in one-letter form
Expand All @@ -37,7 +37,7 @@ S signature no NONE s-- no rw Signature of rou
T epoch no NONE -i- no -- the last modified time of the input file (only for F/file kind tag)
Z scope no NONE s-- no rw [tags output] prepend "scope:" key to s/scope field output, [xref and json output] the same as s/ field
a access no NONE s-- no -- Access (or export) of class members
e end no NONE -i- no -- end lines of various items
e end no NONE -i- no rw end lines of various items
f file no NONE --b no -- File-restricted scoping
i inherits no NONE s-b no -- Inheritance information
k NONE no NONE s-- no -- Kind of tag in one-letter form
Expand All @@ -63,7 +63,7 @@ S signature no NONE s-- no rw Signature of rou
T epoch no NONE -i- no -- the last modified time of the input file (only for F/file kind tag)
Z scope no NONE s-- no rw [tags output] prepend "scope:" key to s/scope field output, [xref and json output] the same as s/ field
a access no NONE s-- no -- Access (or export) of class members
e end no NONE -i- no -- end lines of various items
e end no NONE -i- no rw end lines of various items
f file no NONE --b no -- File-restricted scoping
i inherits no NONE s-b no -- Inheritance information
k NONE no NONE s-- no -- Kind of tag in one-letter form
Expand All @@ -89,7 +89,7 @@ S signature no NONE s-- no rw Signature of rou
T epoch no NONE -i- no -- the last modified time of the input file (only for F/file kind tag)
Z scope no NONE s-- no rw [tags output] prepend "scope:" key to s/scope field output, [xref and json output] the same as s/ field
a access no NONE s-- no -- Access (or export) of class members
e end no NONE -i- no -- end lines of various items
e end no NONE -i- no rw end lines of various items
f file no NONE --b no -- File-restricted scoping
i inherits no NONE s-b no -- Inheritance information
k NONE no NONE s-- no -- Kind of tag in one-letter form
Expand Down
2 changes: 1 addition & 1 deletion Tmain/list-fields-with-prefix.d/stdout-expected.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
E UCTAGSextras no NONE s-- no r- Extra tag type information
T UCTAGSepoch yes NONE -i- no -- the last modified time of the input file (only for F/file kind tag)
Z UCTAGSscope no NONE s-- no rw [tags output] prepend "scope:" key to s/scope field output, [xref and json output] the same as s/ field
e UCTAGSend no NONE -i- no -- end lines of various items
e UCTAGSend no NONE -i- no rw end lines of various items
p UCTAGSscopeKind no NONE s-- no -- [tags output] no effect, [xref and json output] kind of scope in long-name form
r UCTAGSroles no NONE s-- no r- Roles
x UCTAGSxpath no NONE s-- no -- xpath for the tag
Expand Down
2 changes: 1 addition & 1 deletion Tmain/list-fields.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ S signature no NONE s-- no rw Signature of routine (e.g. prototype or parameter
T epoch yes NONE -i- no -- the last modified time of the input file (only for F/file kind tag)
Z scope no NONE s-- no rw [tags output] prepend "scope:" key to s/scope field output, [xref and json output] the same as s/ field
a access no NONE s-- no -- Access (or export) of class members
e end no NONE -i- no -- end lines of various items
e end no NONE -i- no rw end lines of various items
f file yes NONE --b no -- File-restricted scoping
i inherits no NONE s-b no -- Inheritance information
k NONE yes NONE s-- no -- Kind of tag in one-letter form
Expand Down
17 changes: 17 additions & 0 deletions Units/optscript.r/op-end.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--fields=+en

--langdef=X
--map-X=.unknown
--kinddef-X=d,def,definitions

--regex-X=/[ \t]*def ([a-z])/\1/d/{exclusive}{{
. _scopetop { scope: } if
. _scopeset
}}

--regex-X=/[ \t]*(end)//{{
_scopetop {
1 _matchloc end:
_scopepop
} if
}}
4 changes: 4 additions & 0 deletions Units/optscript.r/op-end.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
a input.unknown /^def a$/;" d line:1 end:9
b input.unknown /^ def b$/;" d line:2 def:a end:4
c input.unknown /^ def c$/;" d line:5 def:a end:8
d input.unknown /^ def d$/;" d line:6 def:a.c end:7
11 changes: 11 additions & 0 deletions Units/optscript.r/op-end.d/input.unknown
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def a
def b
...
end
def c
def d
end
end
end

end
42 changes: 42 additions & 0 deletions main/field.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ static EsObject* getFieldValueForExtras (const tagEntryInfo *, const fieldDefini
static EsObject* getFieldValueForSignature (const tagEntryInfo *, const fieldDefinition *);
static EsObject* setFieldValueForSignature (tagEntryInfo *, const fieldDefinition *, const EsObject *);
static EsObject* getFieldValueForRoles (const tagEntryInfo *, const fieldDefinition *);
static EsObject* getFieldValueForEnd (const tagEntryInfo *, const fieldDefinition *);
static EsObject* checkFieldValueForEnd (const fieldDefinition *, const EsObject *);
static EsObject* setFieldValueForEnd (tagEntryInfo *, const fieldDefinition *, const EsObject *);

#define WITH_DEFUALT_VALUE(str) ((str)?(str):FIELD_NULL_LETTER_STRING)

Expand Down Expand Up @@ -401,6 +404,12 @@ static fieldDefinition fieldDefinitionsUniversal [] = {
.doesContainAnyChar = NULL,
.isValueAvailable = isEndFieldAvailable,
.dataType = FIELDTYPE_INTEGER,
.getterValueType = "int",
.getValueObject = getFieldValueForEnd,
.setterValueType = "matchlok|int",
.checkValueForSetter= checkFieldValueForEnd,
.setValueObject = setFieldValueForEnd,

},
[FIELD_EPOCH - FIELD_ROLES] = {
.letter = 'T',
Expand Down Expand Up @@ -1720,3 +1729,36 @@ static EsObject* getFieldValueForRoles (const tagEntryInfo *tag, const fieldDefi
}
return a;
}

static EsObject* getFieldValueForEnd (const tagEntryInfo *tag, const fieldDefinition *fdef)
{
return ((int)tag->extensionFields.endLine == 0)
? es_nil
: es_integer_new ((int)tag->extensionFields.endLine);
}

static EsObject* checkFieldValueForEnd (const fieldDefinition *fdef, const EsObject *obj)
{
return es_false;
}

static EsObject* setFieldValueForEnd (tagEntryInfo *tag, const fieldDefinition *fdef, const EsObject *obj)
{
int l;
if (es_object_get_type (obj) == OPT_TYPE_MATCHLOC)
{
matchLoc *loc = es_pointer_get (obj);
l = loc->line;
}
else if (es_integer_p (obj))
{
l = es_integer_get (obj);
if (l < 1)
return OPT_ERR_RANGECHECK;
}
else
return OPT_ERR_TYPECHECK;

tag->extensionFields.endLine = l;
return es_false;
}

0 comments on commit c19ead2

Please sign in to comment.