summaryrefslogtreecommitdiff
path: root/TAO/bin/ADDIDL.DSM
blob: b53ea3eb63655443bdcc6444e38e4514c0c5ac6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
'
'**********************************************************************
' $Header$
' $NoKeywords: $
'
' @doc AddIDL 
'
' Macros for Microsoft Visual Studio.
'
' @comm To install this file go to Tools->Customize->Macro Files->Browse...
'
'**********************************************************************
'


'@bsub Add an IDL file into all build projects in the current workspace.
'@comm This routine also sets up the custom build options require for the TAO
'CORBA implementation. The use can select to create a new file or just add a reference
'to the project (e.g. if a file already exists).If a new file is created, then a
'basic outline for an OMG module or interface declaration is inserted. Note that the inline
'file extension is defined by INLINE_EXTENSION.
'
Sub AddIDLFile()
'DESCRIPTION: Add new IDL File with TAO custom build entries to all build projects in the workspace. 

	On Error Resume Next

	'Define the extension used for inline files here
	INLINE_EXTENSION = "inl"

	WkSpaceDir = Application.CurrentDirectory
	ModuleName = InputBox("module (namespace or extensionless IDL filename):")
	FileName = ModuleName
	WkSpaceDir=InputBox("Directory for IDL file: ","Output Directory",WkSpaceDir)
	
	if WkSpaceDir="" then
		Exit Sub
	end if

	if Right(WkSpaceDir,1) <> "\" then
		WkSpaceDir=WkSpaceDir+"\"
	end if

	IDLFile = WkSpaceDir+FileName +".idl"

	'Try to a file with this path/name
	Documents.Open IDLFile

	'If such a file already exists then it should now be the active doc
	if ActiveDocument.Fullname = IDLFile then

		if msgbox("Overwrite the existing file ?",vbYesNo) = vbNo then 
			NewFile = 0
		else
			'Close the file before we modify it
			ActiveDocument.Close
			NewFile = 1
		end if
	else
		NewFile =1
	end if

	'If NewFile is set to 1 then create the outline for a OMG IDL module
	if NewFile = 1 then
		InterfaceName = InputBox("interface:")

		if msgbox("Include a module ("+ ModuleName+") declaration",vbYesNo) = vbYes then 
			Descr = vbLF + vbLF + "#if !defined (_" + UCase(ModuleName) + "_IDL)" + vbLF + _
			"#define _" + UCase(ModuleName) + "_IDL" + vbLF +vbLF + _
			"//"+vbLF+"//" +vbLF + "module " + ModuleName + " {" +vbLF + _
			"	//" + vbLF + _
			"	interface " + InterfaceName + "{"+vbLF + _
			"		//Definitions"+ vbLF + vbLF+ vbLF + _
			"		//Operations"+ vbLF + vbLF+ vbLF + _
			"		//Properties"+ vbLF+ vbLF + _
			"	};"+vbLF + "};"+vbLF +vbLF + _
			"#endif /* _"+ UCase(ModuleName) +"_IDL */"+vbLF
		else
			Descr = vbLF + vbLF + "#if !defined (_" + UCase(ModuleName) + "_IDL)" + vbLF + _
			"#define _" + UCase(ModuleName) + "_IDL" + vbLF +vbLF + _
			"	//" + vbLF + _
			"	//" + vbLF + _
			"	interface " + InterfaceName + "{"+vbLF + _
			"		//Definitions"+ vbLF + vbLF+ vbLF + _
			"		//Operations"+ vbLF + vbLF+ vbLF + _
			"		//Properties"+ vbLF+ vbLF + _
			"	};"+vbLF +vbLF + _
			"#endif /* _"+ UCase(ModuleName) +"_IDL */"+vbLF
		end if

		CreateCppFile IDLFile, Descr
	end if

		Dim proj
		' Add the files to each project
		'Note that the inline files do not need to be added
		for each proj in Projects
			if msgbox("Add "+ IDLFile +" and the IDL compiler output files to "+ proj +" ?",vbYesNo) = vbYes then
				ProjectPath= Left(proj.FullName,InStrRev(proj.FullName,"\")-1)

				proj.AddFile IDLFile
				proj.AddFile WkSpaceDir+ModuleName + "C.cpp"
				proj.AddFile WkSpaceDir+ModuleName + "C.h"
				proj.AddFile WkSpaceDir+ModuleName + "S.cpp"
				proj.AddFile WkSpaceDir+ModuleName + "S.h"
				proj.AddFile WkSpaceDir+ModuleName + "S_T.cpp"
				proj.AddFile WkSpaceDir+ModuleName + "S_T.h"

				Dim cfg
				' Add the custom build for each configuration in each project
				If proj.Type = "Build" Then
					Commands="%ACE_ROOT%\bin\tao_idl.exe -ci C."+ INLINE_EXTENSION +" -si S.inl -st S_T."+ INLINE_EXTENSION +" " + IDLFile
					Output =	"$(InputName)C.cpp"		+ vbLF + _
								"$(InputName)C.h"		+ vbLF + _
								"$(InputName)C."+ INLINE_EXTENSION +""		+ vbLF + _
								"$(InputName)S.cpp"		+ vbLF + _
								"$(InputName)S.h"		+ vbLF + _
								"$(InputName)S."+ INLINE_EXTENSION +""		+ vbLF + _
								"$(InputName)S_T.cpp"	+ vbLF + _
								"$(InputName)S_T.h"		+ vbLF + _
								"$(InputName)S_T."+ INLINE_EXTENSION +""

					for each cfg in proj.Configurations
						cfg.AddCustomBuildStepToFile IDLFile, Commands, Output, "Running the TAO IDL Compiler on $(InputPath)..."
					next
				End If
			end if
		next
End Sub





'@bsub Creates a C/C++ file.
'@comm This routine will create a C or C++ source file f, with content c. 
'The new file will become the active doc.
'
Function CreateCppFile(byval f, byval c)
'DESCRIPTION: Creates a .cpp file. 

	On Error Resume Next
    Documents.Add "Text"
    ActiveDocument.Language = "C/C++"
    ActiveDocument.Selection = c
    ActiveDocument.Selection.NewLine
    ActiveDocument.Save f

End Function