Permalink
Browse files

Synchronized the python parser with the geany tagmanager, including t…

…he following geany commits:

r3788: nestlevel.c and some other stuff
r3804: Parse Python import statements to get symbol completion for the imported module names.
r3809: Parse Python calltips.
r3831: Fix grouping functions/classes under a nested function.

Many thanks to the geany devs!
  • Loading branch information...
1 parent ca63130 commit 431e41bbdb1d73cf3207496f4b422c060b26c1c7 @allefant allefant committed Jul 5, 2009
Showing with 247 additions and 72 deletions.
  1. +80 −0 nestlevel.c
  2. +54 −0 nestlevel.h
  3. +108 −69 python.c
  4. +3 −1 source.mak
  5. +2 −2 testing.mak
View
@@ -0,0 +1,80 @@
+/*
+* $Id: nestlevel.c 3788 2009-05-12 15:55:13Z ntrel $
+*
+* Copyright (c) 1999-2002, Darren Hiebert
+* Copyright 2009 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
+*
+* This source code is released for free distribution under the terms of the
+* GNU General Public License.
+*
+* Defines external interface to scope nesting levels for tags.
+*/
+
+/*
+* INCLUDE FILES
+*/
+#include "general.h" /* must always come first */
+
+#include "main.h"
+#include "nestlevel.h"
+#include "debug.h"
+#include "routines.h"
+
+/*
+* FUNCTION DEFINITIONS
+*/
+
+extern NestingLevels *nestingLevelsNew(void)
+{
+ NestingLevels *nls = xCalloc (1, NestingLevels);
+ return nls;
+}
+
+extern void nestingLevelsFree(NestingLevels *nls)
+{
+ int i;
+ for (i = 0; i < nls->allocated; i++)
+ vStringDelete(nls->levels[i].name);
+ if (nls->levels) eFree(nls->levels);
+ eFree(nls);
+}
+
+extern void nestingLevelsPush(NestingLevels *nls,
+ const vString *name, int type)
+{
+ NestingLevel *nl = NULL;
+
+ if (nls->n >= nls->allocated)
+ {
+ nls->allocated++;
+ nls->levels = xRealloc(nls->levels,
+ nls->allocated, NestingLevel);
+ nls->levels[nls->n].name = vStringNew();
+ }
+ nl = &nls->levels[nls->n];
+ nls->n++;
+
+ vStringCopy(nl->name, name);
+ nl->type = type;
+}
+
+extern void nestingLevelsPop(NestingLevels *nls)
+{
+ const NestingLevel *nl = nestingLevelsGetCurrent(nls);
+
+ Assert (nl != NULL);
+ vStringClear(nl->name);
+ nls->n--;
+}
+
+extern NestingLevel *nestingLevelsGetCurrent(NestingLevels *nls)
+{
+ Assert (nls != NULL);
+
+ if (nls->n < 1)
+ return NULL;
+
+ return &nls->levels[nls->n - 1];
+}
+
+/* vi:set tabstop=4 shiftwidth=4: */
View
@@ -0,0 +1,54 @@
+/*
+* $Id: nestlevel.h 3788 2009-05-12 15:55:13Z ntrel $
+*
+* Copyright (c) 1999-2002, Darren Hiebert
+* Copyright 2009 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
+*
+* This source code is released for free distribution under the terms of the
+* GNU General Public License.
+*
+* Defines external interface to scope nesting levels for tags.
+*/
+#ifndef _NESTLEVEL_H
+#define _NESTLEVEL_H
+
+/*
+* INCLUDE FILES
+*/
+#include "general.h" /* must always come first */
+
+#include "vstring.h"
+
+/*
+* DATA DECLARATIONS
+*/
+typedef struct NestingLevel NestingLevel;
+typedef struct NestingLevels NestingLevels;
+
+struct NestingLevel
+{
+ int indentation;
+ vString *name;
+ int type;
+};
+
+struct NestingLevels
+{
+ NestingLevel *levels;
+ int n; /* number of levels in use */
+ int allocated;
+};
+
+/*
+* FUNCTION PROTOTYPES
+*/
+extern NestingLevels *nestingLevelsNew(void);
+extern void nestingLevelsFree(NestingLevels *nls);
+extern void nestingLevelsPush(NestingLevels *nls,
+ const vString *name, int type);
+extern void nestingLevelsPop(NestingLevels *nls);
+extern NestingLevel *nestingLevelsGetCurrent(NestingLevels *nls);
+
+#endif /* _NESTLEVEL_H */
+
+/* vi:set tabstop=4 shiftwidth=4: */
Oops, something went wrong.

0 comments on commit 431e41b

Please sign in to comment.