2 * (c) Oleg Puchinin 2007
3 * graycardinalster@gmail.com
7 * --cgrep and --grep for C should work correctly with C#
14 #include <gclib/gclib.h>
15 #include <gclib/gclib_c.h>
22 extern "C" DArray
* plugin_init (struct env_t
*env
);
25 // At the first operation cycle of options.
26 char csharp_opt (DArray
* d_opts
, int * pos
)
31 if (! d_opts
|| ! pos
)
34 count
= d_opts
->get_size ();
35 S
= d_opts
->get (*pos
);
36 if (EQ (S
, "--csharp")) {
37 ENV
->language
= "csharp";
41 /* if (EQ (S, "--other-option")) {
42 // if (++(*pos) >= count) // For an option the parameter is necessary.
51 // At the second operation cycle of options.
52 char csharp_opt2 (DArray
* d_opts
, int * pos
)
54 if (! d_opts
|| ! pos
)
57 if (NE (ENV
->language
, "charp"))
60 if (EQ (d_opts
->get (*pos
), "--files")) {
61 /* unlink ("./csharp_files");
62 sblib_find ("./", "*.cs", "./csharp_files");
64 fprintf (stderr
, "Option not supported currently\n");
72 /// It is carried out for each file
73 /// $ bob --csharp <files> --make-ctags
74 int csharp_make_ctags (char * f_name
, FILE * of
)
81 // To find all C# files. (see sblib_find sblib/Sblib.cpp)
87 tt
->loadFile (f_name
);
90 // Cycle of pass on operators
92 op
= tt
->nextOperator ();
96 tt->line (); // Current line
97 tt->ch; // Closing symbol of the operator ( {,},;,\n)
98 tt->bracketDepth; // Degree of an enclosure {/}
100 // See also (sblib/sblib.cxx) :
101 // DArray * split_to_words (char * d_op);
102 // int words_count (char *S);
103 // char * ww_last_word (char *d_op); */
105 // To deduce a line in "of" for each found tag.
106 // line format : <tagname>\t<file>\t<line>\n"
107 printf ("OP: %s\n", op
);
114 // It is carried out at start $ bob - plugins-info
115 void csharp_plugin_short_info ()
117 printf ("C# plugin.");
120 void csharp_plugin_long_info ()
122 printf ("C# plugin.\n");
123 printf ("Version: 0.1\n");
124 printf ("options: --csharp\n");
127 DArray
* plugin_init (struct env_t
*env
)
130 struct mod_language
* ml
;
131 struct mod_feature
* mf
;
133 ml
= new mod_language
;
134 mf
= new mod_feature
;
135 Ret
= new DArray (2);
137 memset (ml
, 0, sizeof (mod_language
));
138 memset (mf
, 0, sizeof (mod_feature
));
141 ml
->mod
.Type
= TYPE_LANGUAGE
;
142 ml
->mod
.Version
= strdup ("0.1");
143 ml
->mod
.short_info
= csharp_plugin_short_info
;
144 ml
->mod
.long_info
= csharp_plugin_long_info
;
145 ml
->language
= strdup ("csharp");
146 ml
->the
= THE_TT::do_tt_file
;
147 ml
->make_ctags
= csharp_make_ctags
;
150 mf
->mod
.Type
= TYPE_FEATURE
;
151 mf
->mod
.Version
= strdup ("0.1");
152 mf
->opt
= csharp_opt
;
153 mf
->opt2
= csharp_opt2
;
155 Ret
->add (LPCHAR (ml
));
156 Ret
->add (LPCHAR (mf
));
158 ENV
->listOptions
->add ("--csharp");
159 // ENV->listOptions->add ("--other-option");
160 ENV
->listOptions
->add ("--files");