Remove loading certs from native Windows cert store.
[ryzomcore.git] / tool / visual_studio_macros / nevrax_macros.dsm
blob0c4d03a8101e3c112442b593e74ae0237ba98a80
1 ' nevrax_macros.dsm\r
2 '\r
3 ' Copyright (C) 2000-2005 Nevrax. All rights reserved.\r
4 '\r
5 ' The redistribution, use and modification in source or binary forms of\r
6 ' this software is subject to the conditions set forth in the copyright\r
7 ' document ("Copyright") included with this distribution.\r
8 '\r
9 '------------------------------------------------------------------------------\r
10 ' FILE DESCRIPTION: Nevrax Visual Studio macro file\r
11 ' $Id: nevrax_macros.dsm,v 1.22 2005/01/03 14:46:02 cado Exp $\r
12 '------------------------------------------------------------------------------\r
15 ' *** NevraxNewClass ***\r
18 ' NevraxInsertFileHeader\r
19 ' Utility Sub for NevraxNewClass()\r
20 ' Author : Olivier Cado\r
21 Sub NevraxInsertFileHeader( filename, productname )\r
22         ActiveDocument.Selection.StartOfDocument\r
23         ActiveDocument.Selection = _\r
24                 "/** \file " + filename + vbLf + _\r
25                 " *" + vbLf + _\r
26                 " */" + vbLf + vbLf\r
27 End Sub\r
30 Function IsUpCase( str )\r
31         IsUpcase = ( str = Ucase(str) )\r
32 End Function\r
35 ' NevraxClassNameToFileName\r
36 ' Utility Function for NevraxNewClass()\r
37 ' 1/08/2000 : now analyses the first character\r
38 ' Author : Olivier Cado\r
39 Function NevraxClassNameToFileName( classname )\r
40         beginningpos = 1\r
41         first = left(classname,1)\r
42         if ((first="C") or (first="E") or (first="I")) then\r
43                 if len(classname)>1 then\r
44                         if IsUpCase( mid(classname,2,1) ) then\r
45                                 beginningpos = 2\r
46                         end if\r
47                 end if\r
48         end if\r
49         filename = lcase(mid(classname,beginningpos,1))\r
50         for i = beginningpos+1 to len( classname )\r
51                 charact = mid(classname,i,1 )\r
52                 if IsUpCase( charact ) then\r
53                         if i+1 <= len( classname ) then\r
54                                 if not IsUpCase( mid(classname,i+1,1) ) then\r
55                                         filename = filename + "_"\r
56                                 end if\r
57                         else\r
58                                 filename = filename + "_"\r
59                         end if\r
60                 end if\r
61                 filename = filename + lcase(charact)\r
62         next\r
63         NevraxClassNameToFileName = filename\r
64 End Function\r
67 ' NevraxProjectOpen\r
68 ' Utility Function for NevraxNewClass()\r
69 ' Author : Olivier Cado\r
70 Function NevraxProjectOpen( projname )\r
71         found = 0\r
72         dim proj\r
73         for i = 1 to Projects.Count\r
74                 if Projects(i).Name = projname then\r
75                         found = i\r
76                         exit for\r
77                 end if\r
78         next\r
79         NevraxProjectOpen = found\r
80 End Function\r
83 ' Global variable\r
84 Dim CurrentDirectoryName\r
85 Dim CurrentProgrammerName\r
88 ' NevraxNewClass\r
89 ' DESCRIPTION: Wizard for new class creation\r
90 ' 1/08/2000 : added input boxes for directories\r
91 ' 7/09/2000 : added programmer's name dialog and test for file existence (dirs & files)\r
92 ' 18/09/2000 : namespace, programmer's name saved in a file, file added to the right project\r
93 ' 12/10/2000 : modified output\r
94 ' Weird things :\r
95 ' - CreateObject( Scripting.FileSystemObject ) doesn't work on Win 98, but on 2000\r
96 ' - Projects.Item( string ) doesn't work. Using number instead\r
97 ' Author : Olivier Cado\r
98 Sub NevraxNewClass()\r
100         ' ** Input class name and file name\r
101         ClassName = InputBox( "Bienvenue dans l'assistant de création de classe." + vbLf + vbLf + _\r
102                 "Nom de la nouvelle classe :", "Nouvelle classe (1)" )\r
103         if ClassName = "" then\r
104                 Exit Sub\r
105         end if\r
106         Filename = NevraxClassNameToFileName( ClassName )\r
107         ' Warning: do not enter an existing filename, or MsDev will crash when attempting to save\r
108         Filename = InputBox( "Nom de fichier sans l'extension:", "Nouvelle classe (2)", Filename )\r
109         if Filename = "" then\r
110                 Exit Sub\r
111         end if\r
112         UniqueName = "NL_" + UCase( Filename ) + "_H"\r
113         HFilename = Filename + ".h"\r
114         CppFilename = Filename + ".cpp"\r
116         ' Load configuration\r
117         dim fso\r
118         set fso = CreateObject("Scripting.FileSystemObject")\r
119         ConfigFileName = "R:\code\tool\visual_studio_macros\nevrax_new_class.cfg"\r
120         if fso.FileExists( ConfigFileName ) then\r
121                 set f = fso.OpenTextFile( ConfigFileName, 1 ) ' 1 = ForReading\r
122                 'if CurrentProgrammerName = "" then\r
123                         CurrentProgrammerName = f.ReadLine\r
124                 'else\r
125                 '       CurrentProgrammerName = "Richard Stallman"\r
126                 'end if\r
127                 SrcDirectory = f.ReadLine\r
128                 IncDirectory = f.ReadLine\r
129                 f.Close\r
130         end if\r
132         ' ** Directories (NB: input boxes cannot be canceled in this part)\r
133         SrcDirectory = InputBox( "Répertoire racine (existant) des sources (.cpp)" + vbLf + "(ex: R:\code\nel\src pour NeL) :","Nouvelle classe (3)", SrcDirectory )\r
134         if SrcDirectory <> "" then\r
135                 if right(SrcDirectory,1)<>"\" then\r
136                         SrcDirectory = SrcDirectory + "\"\r
137                 end if\r
138         else\r
139                 IncDirectory = ""\r
140         end if\r
141         IncDirectory = InputBox( "Répertoire racine (existant) des include (.h)" + vbLf + "(ex: R:\code\nel\include\nel pour NeL ; chaîne vide pour le même répertoire que les fichiers source ) :","Nouvelle classe (4)", IncDirectory )\r
142         if IncDirectory = "" then\r
143                 IncDirectory = SrcDirectory\r
144         else\r
145                 if (right(IncDirectory,1)<>"\") then\r
146                         IncDirectory = IncDirectory + "\"\r
147                 end if\r
148         end if\r
149         CurrentDirectoryName = InputBox( "Nom du répertoire de travail (ex: misc)" + vbLf + "(existant dans " + SrcDirectory + _\r
150                 " et dans " + IncDirectory + ")" + vbLf + "Ce nom restera mémorisé" + vbLf + "(chaîne vide pour pour un projet hors-NeL).", "Nouvelle classe (5)", CurrentDirectoryName )\r
151         if CurrentDirectoryName<>"" then\r
152                 CurrentDirectoryDir = CurrentDirectoryName + "\"\r
153                 Namesp = "NL" + ucase(CurrentDirectoryName)\r
154         end if\r
155         If InStr( IncDirectory, "nel" ) then\r
156                 ProdName = "NEL"\r
157                 ShortIncDir = "nel/" + CurrentDirectoryName + "/"\r
158         else\r
159                 ProdName = "NeL Network Services" ' not Distributed Toolkit Components System anymore\r
160         end if\r
162         ' ** Check for file existence\r
163         FinalCPPdir = SrcDirectory + CurrentDirectoryDir\r
164         FinalHdir = IncDirectory + CurrentDirectoryDir\r
165         if not fso.FolderExists( FinalHdir ) then\r
166                 MsgBox "Erreur : le répertoire " + FinalHdir + " n'existe pas !", vbExclamation\r
167                 Exit Sub\r
168         end if\r
169         if not fso.FolderExists( FinalCPPdir ) then\r
170                 MsgBox "Erreur : le répertoire " + FinalCPPdir + " n'existe pas !", vbExclamation\r
171                 Exit Sub\r
172         end if\r
173         FinalCPPfilename = FinalCPPdir + CppFilename\r
174         FinalHfilename = FinalHdir + HFilename\r
175         if fso.FileExists( FinalHfilename ) then\r
176                 MsgBox "Erreur : le fichier " + FinalHfilename + " existe déjà !", vbExclamation\r
177                 Exit Sub\r
178         end if\r
179         if fso.FileExists( FinalCPPfilename ) then\r
180                 MsgBox "Erreur : le fichier " + FinalCPPfilename + " existe déjà !", vbExclamation\r
181                 Exit Sub\r
182         end if\r
184         ' ** Check for open project\r
185         if CurrentDirectoryName=""      then\r
186                 AddToProject = 0\r
187         else\r
188                 AddToProject = NevraxProjectOpen( CurrentDirectoryName )\r
189         end if\r
191         ' ** Programmer's name\r
192         CurrentProgrammerName = InputBox( "Votre prénom et votre nom (qui restera mémorisé dans un fichier) :", "Nouvelle classe (6)", CurrentProgrammerName )\r
193         if CurrentProgrammerName = "" then\r
194                 Exit Sub\r
195         end if\r
197         ' Save configuration\r
198         set f = fso.OpenTextFile( ConfigFileName, 2, true ) ' 2 = ForWriting\r
199         f.WriteLine CurrentProgrammerName\r
200         f.WriteLine SrcDirectory\r
201         f.WriteLine IncDirectory\r
202         f.Close\r
204         ' ** Input ancestor class name and file name\r
205         NoAncestor = "NO BASE CLASS"\r
206         AncClassName = InputBox( "Nom de la classe de base :", "Nouvelle classe (7)", NoAncestor )\r
207         if AncClassName = "" then\r
208                 Exit Sub\r
209         else\r
210                 if AncClassName = NoAncestor then\r
211                         AncClassName = ""\r
212                 else\r
213                         AncFilename = InputBox( "Nom de fichier (avec chemin) sans l'extension (ex: nel/misc/toto) :", "Nouvelle classe (8)" )\r
214                         if AncFileName = "" then\r
215                                 Exit Sub\r
216                         end if\r
217                         AncHFilename = AncFilename + ".h"\r
218                         'if not fso.FileExists( AncHFilename ) then\r
219                         '       MsgBox "Attention : le fichier " + AncHFilename + " n'existe pas encore.", vbInformation\r
220                         'end if\r
221                 end if\r
222         end if\r
224         ' ** Now write .cpp\r
225         Documents.Add( "Text" )\r
226         NevraxInsertFileHeader CppFilename, ProdName\r
227         ActiveDocument.Selection = vbLf + "#include """ + ShortIncDir + HFilename + """" + vbLf + vbLf + vbLf\r
228         if ( CurrentDirectoryName<>"" ) then\r
229                 ActiveDocument.Selection = "namespace " + Namesp + " {" + vbLf + vbLf + vbLf\r
230         end if\r
231         ActiveDocument.Selection = "/*" + vbLf + _\r
232                 " * Constructor" + vbLf + _\r
233                 " */" + vbLf + _\r
234                 ClassName + "::" + ClassName + "()" + vbLf + _\r
235                 "{" + vbLf + _\r
236                 "}" + vbLf + vbLf + vbLf\r
237         if ( CurrentDirectoryName<>"" ) then\r
238                 ActiveDocument.Selection = "} // " + Namesp + vbLf\r
239         end if\r
240         ' Warning: ActiveDocument.Save raises an "Unknown error" if the directory does not exist"\r
241         ActiveDocument.Save( FinalCPPfilename )\r
242         if AddToProject=0 then\r
243                 ActiveProject.AddFile( FinalCPPfilename )\r
244         else\r
245                 Projects(AddToProject).AddFile( FinalCPPfilename )\r
246         end if\r
248         ' ** Now write .h\r
249         Documents.Add( "Text" )\r
250         NevraxInsertFileHeader HFilename, ProdName\r
251         ActiveDocument.Selection = vbLf + "#ifndef " + UniqueName + vbLf + _\r
252                 "#define " + UniqueName + vbLf + vbLf\r
253         ActiveDocument.Selection = "#include ""nel/misc/types_nl.h""" + vbLf\r
254         if AncClassName <> "" then\r
255                 ActiveDocument.Selection = "#include """ + AncHFilename + """" + vbLf\r
256         end if\r
257         if ( CurrentDirectoryName<>"" ) then\r
258                 ActiveDocument.Selection = vbLf + vbLf + "namespace " + Namesp + " {" + vbLf\r
259         end if\r
260         ActiveDocument.Selection = vbLf + vbLf + _\r
261                 "/**" + vbLf + _\r
262                 " * <Class description>" + vbLf + _\r
263                 " * \author " + CurrentProgrammerName + vbLf + _\r
264                 " * \author Nevrax France" + vbLf + _\r
265                 " * \date 2005" + vbLf + _\r
266                 " */" + vbLf + _\r
267                 "class " + ClassName\r
268         if AncClassName <> "" then\r
269                 ActiveDocument.Selection = " : public " + AncClassName\r
270         end if\r
271         ActiveDocument.Selection = vbLf + _\r
272                 "{" + vbLf + _\r
273                 "public:" + vbLf + vbLf + _\r
274                 "       /// Constructor" + vbLf + _\r
275                 "       " + ClassName + "();" + vbLf + vbLf + _\r
276                 "};" + vbLf + vbLf\r
277         if ( CurrentDirectoryName<>"" ) then\r
278                 ActiveDocument.Selection = vbLf + "} // " + Namesp + vbLf + vbLf\r
279         end if\r
280         ActiveDocument.Selection = vbLf + "#endif // " + UniqueName + vbLf\r
281         ActiveDocument.Selection = vbLf + "/* End of " + HFilename + " */" + vbLf\r
282         ' Warning: ActiveDocument.Save raises an "Unknown error" if the directory does not exist"\r
283         ActiveDocument.Save( FinalHfilename )\r
284         if AddToProject=0 then\r
285                 ActiveProject.AddFile( FinalHfilename )\r
286         else\r
287                 Projects(AddToProject).AddFile( FinalHfilename )\r
288         end if\r
290 End Sub\r
292 ' *** End of NevraxNewClass ***\r
295 ' ** NevraxToggleHCPP\r
297 ' NevraxToggleHCPP\r
298 ' DESCRIPTION: Opens the .cpp or .h file (toggles) for the current document.\r
299 ' TIP: Bind this macro to Ctrl+<\r
300 ' Last modification : 22/05/2001\r
301 ' Author : Olivier Cado\r
302 Sub NevraxToggleHCPP()\r
304         ' ** Get filename extension and ensure it is .h or .cpp\r
305         ActFilename = ActiveDocument.FullName\r
306         pos = InstrRev( ActFilename, "." )\r
307         if ( pos <> 0 ) then\r
308                 Ext = mid(ActFilename,pos)              \r
309                 if (Ext<>".h" and Ext<>".cpp") then\r
310                         msgbox( "Error : Active document is not a .cpp or .h file" )\r
311                         exit sub\r
312                 end if\r
313         else\r
314                 exit sub\r
315         end if\r
316         \r
317         ' ** Build the alternative filename\r
319         ' The module name is the word between the two last backslashes of the path\filename\r
320         ModuleDir = left( ActFilename, InstrRev(ActFilename,"\")-1 )\r
321         ModuleDir = mid( ModuleDir, InstrRev(ModuleDir, "\")+1 ) + "\"\r
323         dim SearchDirs (4)\r
324         if ( Ext = ".cpp" ) then\r
325                 SearchDirs(1) = "R:\code\nel\include\nel\" + ModuleDir\r
326                 SearchDirs(2) = "R:\code\nel\include_private\nel\" + ModuleDir\r
327                 SearchDirs(3) = left( ActFilename, InstrRev(ActFilename,"\") ) 'dir of the current file\r
328                 NbDirs = 3\r
329                 Ext = "h"\r
330         else\r
331                 SearchDirs(1) = "R:\code\nel\src\" + ModuleDir\r
332                 SearchDirs(2) = left( ActFilename, InstrRev(ActFilename,"\") ) 'dir of the current file\r
333                 NbDirs = 2\r
334                 Ext = "cpp"\r
335         end if\r
336         DirIndex = 1\r
337         FileFound = False\r
338         Dirs = ""\r
339         while (DirIndex <= NbDirs) and (FileFound = False)\r
340                 ' NeL directory scheme\r
341                 if InStr(ActFilename,"nel")<>0 then\r
342                         ' Add the search path and the filename\r
343                         NewFilename = SearchDirs(DirIndex)\r
344                         ShortFilenameDot = mid( ActFilename, InstrRev(ActFilename,"\")+1 )\r
345                 else\r
346                         ' The complete filename\r
347                         ShortFilenameDot = ActFilename\r
348                 end if\r
349                 ShortFilenameDot = left( ShortFilenameDot, Instr(ShortFilenameDot,".") )\r
350                 NewFilename = NewFilename + ShortFilenameDot + Ext\r
351  \r
352                 ' ** Open the alternative file\r
353                 dim fso\r
354                 set fso = CreateObject("Scripting.FileSystemObject")\r
355                 if fso.FileExists( NewFilename ) then\r
356                         Documents.Open( NewFilename )\r
357                         FileFound = True\r
358                 else\r
359                         Dirs = Dirs + SearchDirs(DirIndex) + vbLf\r
360                         DirIndex = DirIndex + 1\r
361                 end if\r
362         wend\r
363         if FileFound <> True then\r
364                 MsgBox "There is no file " + ShortFilenameDot + Ext + " in " + vbLf + Dirs\r
365         end if\r
366 End Sub\r
369 ' ** NevraxToggleHCPP\r
372 ' NevraxFormatMethodHeader\r
373 ' DESCRIPTION: Edit a Doxygen .h style method header for a .cpp file.\r
374 ' The caret must be a the beginning of the first line of the header.\r
375 ' Author : Olivier Cado\r
376 Sub NevraxFormatMethodHeader()\r
377         ActiveDocument.Selection.Delete\r
378         ActiveDocument.Selection.CharRight\r
379         ActiveDocument.Selection.Delete 2\r
380         ActiveDocument.Selection = "*" + vbLf + " *"\r
381         ActiveDocument.Selection.EndOfLine\r
382         ActiveDocument.Selection = vbLf + " */"\r
383         ActiveDocument.Selection.LineDown\r
384         ActiveDocument.Selection.Delete\r
385         ActiveDocument.Selection.EndOfLine\r
386         ActiveDocument.Selection.Backspace\r
387         ActiveDocument.Selection = vbLf + "{" + vbLf + vbLf + "}" + vbLf\r
388         ActiveDocument.Selection.LineDown dsMove,2\r
389 End Sub\r