Skip to content

Commit

Permalink
main: introduce lxpath.h
Browse files Browse the repository at this point in the history
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed Dec 29, 2016
1 parent 6e839be commit 0061bd0
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 54 deletions.
68 changes: 68 additions & 0 deletions main/lxpath.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright (c) 2016, Masatake YAMATO
* Copyright (c) 2016, Red Hat, Inc.
*
* This source code is released for free distribution under the terms of the
* GNU General Public License version 2 or (at your option) any later version.
*
* Xpath based parer API
*/
#ifndef CTAGS_LXPATH_PARSE_H
#define CTAGS_LXPATH_PARSE_H

#include "general.h" /* must always come first */
#include "types.h"

#ifdef HAVE_LIBXML
#include <libxml/xpath.h>
#include <libxml/tree.h>
#else
#define xmlNode void
#define xmlXPathCompExpr void
#define xmlXPathContext void
#endif

typedef struct sTagXpathMakeTagSpec {
int kind;
int role;
/* If make is NULL, just makeTagEntry is used instead. */
void (*make) (xmlNode *node,
const struct sTagXpathMakeTagSpec *spec,
tagEntryInfo *tag,
void *userData);
} tagXpathMakeTagSpec;

typedef struct sTagXpathRecurSpec {
void (*enter) (xmlNode *node,
const struct sTagXpathRecurSpec *spec,
xmlXPathContext *ctx,
void *userData);

int nextTable; /* A parser can use this field any purpose.
main/lxpath part doesn't touch this. */

} tagXpathRecurSpec;

typedef struct sTagXpathTable
{
const char *const xpath;
enum { LXPATH_TABLE_DO_MAKE, LXPATH_TABLE_DO_RECUR } specType;
union {
tagXpathMakeTagSpec makeTagSpec;
tagXpathRecurSpec recurSpec;
} spec;
xmlXPathCompExpr* xpathCompiled;
} tagXpathTable;

typedef struct sTagXpathTableTable {
tagXpathTable *table;
unsigned int count;
} tagXpathTableTable;

/* Xpath interface */
extern void findXMLTags (xmlXPathContext *ctx, xmlNode *root,
const tagXpathTableTable *xpathTableTable,
const kindOption* const kinds, void *userData);
extern void addTagXpath (const langType language, tagXpathTable *xpathTable);

#endif /* CTAGS_LXPATH_PARSE_H */
55 changes: 1 addition & 54 deletions main/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,11 @@
#include "dependency.h"
#include "field.h"
#include "kind.h"
#include "lxpath.h"
#include "param.h"
#include "parsers.h" /* contains list of parsers */
#include "strlist.h"

#ifdef HAVE_LIBXML
#include <libxml/xpath.h>
#include <libxml/tree.h>
#else
#define xmlNode void
#define xmlXPathCompExpr void
#define xmlXPathContext void
#endif

/*
* MACROS
*/
Expand Down Expand Up @@ -81,44 +73,6 @@ typedef struct {
bool *disabled;
} tagRegexTable;

typedef struct sTagXpathMakeTagSpec {
int kind;
int role;
/* If make is NULL, just makeTagEntry is used instead. */
void (*make) (xmlNode *node,
const struct sTagXpathMakeTagSpec *spec,
tagEntryInfo *tag,
void *userData);
} tagXpathMakeTagSpec;

typedef struct sTagXpathRecurSpec {
void (*enter) (xmlNode *node,
const struct sTagXpathRecurSpec *spec,
xmlXPathContext *ctx,
void *userData);

int nextTable; /* A parser can use this field any purpose.
main/lxpath part doesn't touch this. */

} tagXpathRecurSpec;

typedef struct sTagXpathTable
{
const char *const xpath;
enum { LXPATH_TABLE_DO_MAKE, LXPATH_TABLE_DO_RECUR } specType;
union {
tagXpathMakeTagSpec makeTagSpec;
tagXpathRecurSpec recurSpec;
} spec;
xmlXPathCompExpr* xpathCompiled;
} tagXpathTable;

typedef struct sTagXpathTableTable {
tagXpathTable *table;
unsigned int count;
} tagXpathTableTable;


typedef struct {
const char *name;
const int id;
Expand Down Expand Up @@ -310,13 +264,6 @@ extern void freeXcmdResources (void);
extern void useXcmdMethod (const langType language);
extern void notifyAvailabilityXcmdMethod (const langType language);

/* Xpath interface */
extern void findXMLTags (xmlXPathContext *ctx, xmlNode *root,
const tagXpathTableTable *xpathTableTable,
const kindOption* const kinds, void *userData);
extern void addTagXpath (const langType language, tagXpathTable *xpathTable);


extern bool makeKindSeparatorsPseudoTags (const langType language,
const ptagDesc *pdesc);
extern bool makeKindDescriptionsPseudoTags (const langType language,
Expand Down
1 change: 1 addition & 0 deletions source.mak
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ MAIN_HEADS = \
main/interactive.h \
main/keyword.h \
main/kind.h \
main/lxpath.h \
main/main.h \
main/mbcs.h \
main/nestlevel.h \
Expand Down
1 change: 1 addition & 0 deletions win32/ctags_vs2013.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@
<ClInclude Include="..\main\options.h" />
<ClInclude Include="..\main\param.h" />
<ClInclude Include="..\main\parse.h" />
<ClInclude Include="..\main\lxpath.h" />
<ClInclude Include="..\main\parsers.h" />
<ClInclude Include="..\main\ptag.h" />
<ClInclude Include="..\main\read.h" />
Expand Down
3 changes: 3 additions & 0 deletions win32/ctags_vs2013.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@
<ClInclude Include="..\main\parse.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\main\lxpath.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\main\parsers.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down

0 comments on commit 0061bd0

Please sign in to comment.