+ rmake ruby script
[opsoft.git] / silentbob / plugins / plugin_csharp.cxx
blob15178e6f46b0a4d2e1414f5d29514055bb39fd3d
1 /*
2 * (c) Oleg Puchinin 2007
3 * graycardinalster@gmail.com
5 * (??? :) )
7 * --cgrep and --grep for C should work correctly with C#
8 */
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <unistd.h>
13 #include <fcntl.h>
14 #include <gclib/gclib.h>
15 #include <gclib/gclib_c.h>
16 #include <mod.h>
17 #include <head.h>
18 #include <dbg.h>
19 #include <the_tt.h>
20 #include <TT.h>
22 extern "C" DArray * plugin_init (struct env_t *env);
23 struct env_t *ENV;
25 // At the first operation cycle of options.
26 char csharp_opt (DArray * d_opts, int * pos)
28 int count;
29 char * S;
31 if (! d_opts || ! pos)
32 return 0;
34 count = d_opts->get_size ();
35 S = d_opts->get (*pos);
36 if (EQ (S, "--csharp")) {
37 ENV->language = "csharp";
38 return 1;
41 /* if (EQ (S, "--other-option")) {
42 // if (++(*pos) >= count) // For an option the parameter is necessary.
43 // return 0;
45 return 1;
46 } */
48 return 0;
51 // At the second operation cycle of options.
52 char csharp_opt2 (DArray * d_opts, int * pos)
54 if (! d_opts || ! pos)
55 return 0;
57 if (NE (ENV->language, "charp"))
58 return 0;
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");
65 exit (0);
68 return 0;
72 /// It is carried out for each file
73 /// $ bob --csharp <files> --make-ctags
74 int csharp_make_ctags (char * f_name, FILE * of)
76 TT * tt;
77 char * op;
78 int m_type;
80 if (! f_name) {
81 // To find all C# files. (see sblib_find sblib/Sblib.cpp)
83 return 0;
86 tt = new TT;
87 tt->loadFile (f_name);
88 tt->init ();
90 // Cycle of pass on operators
91 while (true) {
92 op = tt->nextOperator ();
93 if (tt->ch == 0)
94 break;
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);
110 delete tt;
111 return 0;
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)
129 DArray * Ret;
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));
139 ENV = env;
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;
148 // ml->call_tags =
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");
163 return Ret;