~ubuntu-branches/ubuntu/utopic/geany/utopic

« back to all changes in this revision

Viewing changes to tagmanager/c.c

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2011-12-10 07:43:26 UTC
  • mfrom: (3.3.7 sid)
  • Revision ID: package-import@ubuntu.com-20111210074326-s8yqbew5i20h33tf
Tags: 0.21-1ubuntu1
* Merge from Debian Unstable, remaining changes:
  - debian/patches/20_use_evince_viewer.patch:
     + use evince as viewer for pdf and dvi files
  - debian/patches/20_use_x_terminal_emulator.patch:
     + use x-terminal-emulator as terminal
  - debian/control
     + Add breaks on geany-plugins-common << 0.20
* Also fixes bugs:
  - Filter for MATLAB/Octave files filters everythign (LP: 885505)

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
#include <string.h>
18
18
#include <setjmp.h>
 
19
#include <mio/mio.h>
19
20
 
20
21
#include "entry.h"
21
22
#include "get.h"
180
181
        keywordId               keyword;
181
182
        vString*                name;                   /* the name of the token */
182
183
        unsigned long   lineNumber;             /* line number of tag */
183
 
        fpos_t                  filePosition;   /* file position of line containing name */
184
 
        int                             bufferPosition; /* buffer position of line containing name */
 
184
        MIOPos                  filePosition;   /* file position of line containing name */
185
185
} tokenInfo;
186
186
 
187
187
typedef enum eImplementation
602
602
        token->type                     = TOKEN_NONE;
603
603
        token->keyword          = KEYWORD_NONE;
604
604
        token->lineNumber       = getSourceLineNumber();
605
 
        if (useFile())
606
 
                token->filePosition   = getInputFilePosition();
607
 
        else
608
 
                token->bufferPosition = getInputBufferPosition();
 
605
        token->filePosition     = getInputFilePosition();
609
606
        vStringClear(token->name);
610
607
}
611
608
 
664
661
 
665
662
static const char *accessString (const accessType laccess)
666
663
{
667
 
        static const char *const names [] ={
 
664
        static const char *const names [] = {
668
665
                "?", "private", "protected", "public", "default"
669
666
        };
670
667
        Assert (sizeof (names) / sizeof (names [0]) == ACCESS_COUNT);
674
671
 
675
672
static const char *implementationString (const impType imp)
676
673
{
677
 
        static const char *const names [] ={
 
674
        static const char *const names [] = {
678
675
                "?", "abstract", "virtual", "pure virtual"
679
676
        };
680
677
        Assert (sizeof (names) / sizeof (names [0]) == IMP_COUNT);
694
691
{
695
692
        static const char *const names [] = {
696
693
                "none", "args", "}", "{", "comma", "double colon", "keyword", "name",
697
 
                "package", "paren-name", "semicolon", "specifier", "*", "[]", "count"
 
694
                "package", "paren-name", "semicolon", "specifier", "*", "[]"
698
695
        };
699
696
        Assert (sizeof (names) / sizeof (names [0]) == TOKEN_COUNT);
700
697
        Assert ((int) type < TOKEN_COUNT);
713
710
 
714
711
static const char *declString (const declType declaration)
715
712
{
716
 
                static const char *const names [] = {
717
 
                        "?", "base", "class", "enum", "function", "ignore", "interface",
718
 
                        "namespace", "no mangle", "package", "struct", "union",
719
 
                };
720
 
                Assert (sizeof (names) / sizeof (names [0]) == DECL_COUNT);
721
 
                Assert ((int) declaration < DECL_COUNT);
722
 
                return names[(int) declaration];
 
713
        static const char *const names [] = {
 
714
                "?", "base", "class", "enum", "event", "signal", "function",
 
715
                "function template", "ignore", "interface", "module", "namespace",
 
716
                "no mangle", "package", "struct", "union",
 
717
        };
 
718
        Assert (sizeof (names) / sizeof (names [0]) == DECL_COUNT);
 
719
        Assert ((int) declaration < DECL_COUNT);
 
720
        return names[(int) declaration];
723
721
}
724
722
 
725
723
static const char *keywordString (const keywordId keyword)
956
954
        initToken (st->blockName);
957
955
        vStringClear (st->parentClasses);
958
956
 
959
 
        /*  Init member info.
960
 
         */
 
957
        /* Init member info. */
961
958
        if (! partial)
962
959
                st->member.access = st->member.accessDefault;
963
960
 
984
981
        st->parent = parent;
985
982
        initMemberInfo (st);
986
983
        reinitStatement (st, FALSE);
987
 
        if(parent)
 
984
        if (parent)
988
985
        {
989
986
                const tokenInfo *const src = activeToken (parent);
990
987
                tokenInfo *const dst = activeToken (st);
1185
1182
static void addOtherFields (tagEntryInfo* const tag, const tagType type,
1186
1183
                                                        const statementInfo *const st, vString *const scope)
1187
1184
{
1188
 
    /*  For selected tag types, append an extension flag designating the
1189
 
     *  parent object in which the tag is defined.
1190
 
     */
1191
 
    switch (type)
1192
 
    {
 
1185
        /*  For selected tag types, append an extension flag designating the
 
1186
         *  parent object in which the tag is defined.
 
1187
         */
 
1188
        switch (type)
 
1189
        {
1193
1190
                default: break;
1194
1191
 
1195
1192
                case TAG_CLASS:
1218
1215
                        if ((type == TAG_CLASS  ||  type == TAG_INTERFACE  ||
1219
1216
                                 type == TAG_STRUCT) && vStringLength (st->parentClasses) > 0)
1220
1217
                        {
1221
 
 
1222
1218
                                tag->extensionFields.inheritance =
1223
1219
                                                vStringValue (st->parentClasses);
1224
1220
                        }
1236
1232
            if ((TRUE == st->gotArgs) && (TRUE == Option.extensionFields.argList) &&
1237
1233
                                ((TAG_FUNCTION == type) || (TAG_METHOD == type) || (TAG_PROTOTYPE == type)))
1238
1234
                        {
1239
 
                                if (useFile())
1240
 
                                {
1241
 
                                        tag->extensionFields.arglist = getArglistFromFilePos(
 
1235
                                tag->extensionFields.arglist = getArglistFromFilePos(
1242
1236
                                                tag->filePosition, tag->name);
1243
 
                                }
1244
 
                                else
1245
 
                                {
1246
 
                                        tag->extensionFields.arglist = getArglistFromBufferPos(
1247
 
                                                tag->bufferPosition, tag->name);
1248
 
                                }
1249
1237
                        }
1250
1238
                        break;
1251
1239
                }
1424
1412
                initTagEntry (&e, vStringValue (token->name));
1425
1413
 
1426
1414
                e.lineNumber    = token->lineNumber;
1427
 
                if (useFile())
1428
 
                        e.filePosition  = token->filePosition;
1429
 
                else
1430
 
                        e.bufferPosition = token->bufferPosition;
 
1415
                e.filePosition  = token->filePosition;
1431
1416
                e.isFileScope = isFileScope;
1432
1417
                e.kindName      = tagName (type);
1433
1418
                e.kind          = tagLetter (type);
1561
1546
                        else if (st->scope == SCOPE_GLOBAL  ||  st->scope == SCOPE_STATIC)
1562
1547
                                makeTag (nameToken, st, TRUE, TAG_MEMBER);
1563
1548
                }
1564
 
                else if (isLanguage (Lang_java) || isLanguage (Lang_csharp) || isLanguage (Lang_vala));
 
1549
                else if (isLanguage (Lang_java) || isLanguage (Lang_csharp) || isLanguage (Lang_vala))
 
1550
                        ;
1565
1551
                else
1566
1552
                {
1567
1553
                        if (st->scope == SCOPE_EXTERN  ||  ! st->haveQualifyingName)
1894
1880
{
1895
1881
        dest->type         = src->type;
1896
1882
        dest->keyword      = src->keyword;
1897
 
        if (useFile())
1898
 
                dest->filePosition = src->filePosition;
1899
 
        else
1900
 
                dest->bufferPosition = src->bufferPosition;
 
1883
        dest->filePosition = src->filePosition;
1901
1884
        dest->lineNumber   = src->lineNumber;
1902
1885
        vStringCopy (dest->name, src->name);
1903
1886
}
2485
2468
                skipToMatch ("()");
2486
2469
                --depth;
2487
2470
        }
2488
 
                if (st->argEndPosition == 0)
2489
 
                {
2490
 
                        if (useFile())
2491
 
                                st->argEndPosition = ftell(File.fp);
2492
 
                        else
2493
 
                                /* FIXME File.fpBufferPosition is wrong here, this breaks function signatures and
2494
 
                                 * so Geany's calltips */
2495
 
                                st->argEndPosition = File.fpBufferPosition;
2496
 
                }
 
2471
        if (st->argEndPosition == 0)
 
2472
                st->argEndPosition = mio_tell (File.mio);
2497
2473
 
2498
2474
        if (! info->isNameCandidate)
2499
2475
                initToken (token);
2541
2517
                        token->type = TOKEN_NAME;
2542
2518
                        processName (st);
2543
2519
                        st->gotParenName = TRUE;
2544
 
                        if (isLanguage(Lang_d) && c == '(' && isType (prev, TOKEN_NAME)) {
 
2520
                        if (isLanguage(Lang_d) && c == '(' && isType (prev, TOKEN_NAME))
 
2521
                        {
2545
2522
                                st->declaration = DECL_FUNCTION_TEMPLATE;
2546
2523
                                copyToken (st->blockName, prev);
2547
2524
                        }
2876
2853
 
2877
2854
static void tagCheck (statementInfo *const st)
2878
2855
{
2879
 
    const tokenInfo *const token = activeToken (st);
2880
 
    const tokenInfo *const prev  = prevToken (st, 1);
2881
 
    const tokenInfo *const prev2 = prevToken (st, 2);
 
2856
        const tokenInfo *const token = activeToken (st);
 
2857
        const tokenInfo *const prev  = prevToken (st, 1);
 
2858
        const tokenInfo *const prev2 = prevToken (st, 2);
2882
2859
 
2883
 
    switch (token->type)
2884
 
    {
 
2860
        switch (token->type)
 
2861
        {
2885
2862
                case TOKEN_NAME:
2886
2863
                {
2887
2864
                        if (insideEnumBody (st))
2913
2890
                        else if (isContextualStatement (st))
2914
2891
                        {
2915
2892
                                tokenInfo *name_token = (tokenInfo *)prev;
 
2893
                                boolean free_name_token = FALSE;
2916
2894
 
2917
2895
                                if (isType (name_token, TOKEN_NAME))
2918
2896
                                {
2949
2927
                                                char buffer[64];
2950
2928
 
2951
2929
                                                name_token = newToken ();
 
2930
                                                free_name_token = TRUE;
2952
2931
                                                copyToken (name_token, contextual_token);
2953
2932
 
2954
2933
                                                sprintf(buffer, "anon_%s_%d", name_token->name->buffer, contextual_fake_count++);
2967
2946
                                        }
2968
2947
                                }
2969
2948
                                qualifyBlockTag (st, name_token);
 
2949
                                if (free_name_token)
 
2950
                                        deleteToken (name_token);
2970
2951
                        }
2971
2952
                        break;
2972
2953
                }
3044
3025
        exception_t exception;
3045
3026
        boolean retry;
3046
3027
 
 
3028
        contextual_fake_count = 0;
 
3029
 
3047
3030
        Assert (passCount < 3);
3048
3031
        cppInit ((boolean) (passCount > 1), isLanguage (Lang_csharp));
3049
3032
 
3082
3065
 
3083
3066
static void initializeCParser (const langType language)
3084
3067
{
3085
 
        contextual_fake_count = 0;
3086
3068
        Lang_c = language;
3087
3069
        buildKeywordHash (language, 0);
3088
3070
}
3089
3071
 
3090
3072
static void initializeCppParser (const langType language)
3091
3073
{
3092
 
        contextual_fake_count = 0;
3093
3074
        Lang_cpp = language;
3094
3075
        buildKeywordHash (language, 1);
3095
3076
}
3096
3077
 
3097
3078
static void initializeJavaParser (const langType language)
3098
3079
{
3099
 
        contextual_fake_count = 0;
3100
3080
        Lang_java = language;
3101
3081
        buildKeywordHash (language, 3);
3102
3082
}
3103
3083
 
3104
3084
static void initializeDParser (const langType language)
3105
3085
{
3106
 
        contextual_fake_count = 0;
3107
3086
        Lang_d = language;
3108
3087
        buildKeywordHash (language, 6);
3109
3088
}
3110
3089
 
3111
3090
static void initializeGLSLParser (const langType language)
3112
3091
{
3113
 
        contextual_fake_count = 0;
3114
3092
        Lang_glsl = language;
3115
3093
        buildKeywordHash (language, 0); /* C keywords */
3116
3094
}
3117
3095
 
3118
3096
static void initializeFeriteParser (const langType language)
3119
3097
{
3120
 
        contextual_fake_count = 0;
3121
3098
        Lang_ferite = language;
3122
3099
        buildKeywordHash (language, 1); /* C++ keywords */
3123
3100
}
3124
3101
 
3125
3102
static void initializeCsharpParser (const langType language)
3126
3103
{
3127
 
        contextual_fake_count = 0;
3128
3104
        Lang_csharp = language;
3129
3105
        buildKeywordHash (language, 2);
3130
3106
}
3131
3107
 
3132
3108
static void initializeValaParser (const langType language)
3133
3109
{
3134
 
        contextual_fake_count = 0;
3135
3110
        Lang_vala = language;
3136
3111
        buildKeywordHash (language, 5);
3137
3112
}