Skip to content

Commit c396b40

Browse files
committed
Update the VBERuntime implementations to include the needed functions
1 parent 280b1b1 commit c396b40

File tree

4 files changed

+229
-16
lines changed

4 files changed

+229
-16
lines changed
Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
namespace Rubberduck.VBEditor.VBERuntime
1+
using System;
2+
3+
namespace Rubberduck.VBEditor.VBERuntime
24
{
35
public interface IVBERuntime
46
{
5-
float Timer();
7+
string DllName { get; }
68
int DoEvents();
9+
float GetTimer();
10+
void GetDateVar(out object retval);
11+
void GetPresentDate(out object retVal);
12+
double Shell(IntPtr pathname, short windowstyle);
13+
void GetTimeVar(out object retVal);
14+
void ChangeDir(IntPtr path);
15+
void ChangeDrive(IntPtr driveletter);
16+
void KillFiles(IntPtr pathname);
17+
void MakeDir(IntPtr path);
18+
void RemoveDir(IntPtr path);
19+
void Beep();
720
}
821
}
Lines changed: 79 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,97 @@
1-
using System.Runtime.InteropServices;
1+
using System;
2+
using System.Runtime.InteropServices;
23

34
namespace Rubberduck.VBEditor.VBERuntime
45
{
56
internal class VBERuntime6 : IVBERuntime
67
{
7-
private const string DllName = "vbe6.dll";
8+
private const string _dllName = "vbe6.dll";
89

9-
[DllImport(DllName)]
10+
public string DllName => _dllName;
11+
12+
[DllImport(_dllName)]
1013
private static extern int rtcDoEvents();
1114
public int DoEvents()
1215
{
1316
return rtcDoEvents();
1417
}
1518

16-
[DllImport(DllName)]
19+
[DllImport(_dllName, SetLastError = true)]
20+
[return: MarshalAs(UnmanagedType.R4)]
1721
private static extern float rtcGetTimer();
18-
public float Timer()
22+
public float GetTimer()
1923
{
2024
return rtcGetTimer();
2125
}
26+
27+
[DllImport(_dllName, SetLastError = true)]
28+
private static extern void rtcGetDateVar(out object retVal);
29+
public void GetDateVar(out object retval)
30+
{
31+
rtcGetDateVar(out retval);
32+
}
33+
34+
[DllImport(_dllName, SetLastError = true)]
35+
private static extern void rtcGetPresentDate(out object retVal);
36+
public void GetPresentDate(out object retVal)
37+
{
38+
rtcGetPresentDate(out retVal);
39+
}
40+
41+
[DllImport(_dllName, SetLastError = true)]
42+
private static extern double rtcShell(IntPtr pathname, short windowstyle);
43+
public double Shell(IntPtr pathname, short windowstyle)
44+
{
45+
return rtcShell(pathname, windowstyle);
46+
}
47+
48+
[DllImport(_dllName, SetLastError = true)]
49+
private static extern void rtcGetTimeVar(out object retVal);
50+
public void GetTimeVar(out object retVal)
51+
{
52+
rtcGetTimeVar(out retVal);
53+
}
54+
55+
[DllImport(_dllName, SetLastError = true)]
56+
private static extern void rtcChangeDir(IntPtr path);
57+
public void ChangeDir(IntPtr path)
58+
{
59+
rtcChangeDir(path);
60+
}
61+
62+
[DllImport(_dllName, SetLastError = true)]
63+
private static extern void rtcChangeDrive(IntPtr driveletter);
64+
public void ChangeDrive(IntPtr driveletter)
65+
{
66+
rtcChangeDrive(driveletter);
67+
}
68+
69+
[DllImport(_dllName, SetLastError = true)]
70+
private static extern void rtcKillFiles(IntPtr pathname);
71+
public void KillFiles(IntPtr pathname)
72+
{
73+
rtcKillFiles(pathname);
74+
}
75+
76+
[DllImport(_dllName, SetLastError = true)]
77+
private static extern void rtcMakeDir(IntPtr path);
78+
public void MakeDir(IntPtr path)
79+
{
80+
rtcMakeDir(path);
81+
}
82+
83+
[DllImport(_dllName, SetLastError = true)]
84+
private static extern void rtcRemoveDir(IntPtr path);
85+
public void RemoveDir(IntPtr path)
86+
{
87+
rtcRemoveDir(path);
88+
}
89+
90+
[DllImport(_dllName, SetLastError = true)]
91+
private static extern void rtcBeep();
92+
public void Beep()
93+
{
94+
rtcBeep();
95+
}
2296
}
2397
}
Lines changed: 79 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,97 @@
1-
using System.Runtime.InteropServices;
1+
using System;
2+
using System.Runtime.InteropServices;
23

34
namespace Rubberduck.VBEditor.VBERuntime
45
{
56
internal class VBERuntime7 : IVBERuntime
67
{
7-
private const string DllName = "vbe7.dll";
8+
private const string _dllName = "vbe7.dll";
89

9-
[DllImport(DllName)]
10+
public string DllName => _dllName;
11+
12+
[DllImport(_dllName)]
1013
private static extern int rtcDoEvents();
1114
public int DoEvents()
1215
{
1316
return rtcDoEvents();
1417
}
1518

16-
[DllImport(DllName)]
19+
[DllImport(_dllName, SetLastError = true)]
20+
[return: MarshalAs(UnmanagedType.R4)]
1721
private static extern float rtcGetTimer();
18-
public float Timer()
22+
public float GetTimer()
1923
{
2024
return rtcGetTimer();
2125
}
26+
27+
[DllImport(_dllName, SetLastError = true)]
28+
private static extern void rtcGetDateVar(out object retVal);
29+
public void GetDateVar(out object retval)
30+
{
31+
rtcGetDateVar(out retval);
32+
}
33+
34+
[DllImport(_dllName, SetLastError = true)]
35+
private static extern void rtcGetPresentDate(out object retVal);
36+
public void GetPresentDate(out object retVal)
37+
{
38+
rtcGetPresentDate(out retVal);
39+
}
40+
41+
[DllImport(_dllName, SetLastError = true)]
42+
private static extern double rtcShell(IntPtr pathname, short windowstyle);
43+
public double Shell(IntPtr pathname, short windowstyle)
44+
{
45+
return rtcShell(pathname, windowstyle);
46+
}
47+
48+
[DllImport(_dllName, SetLastError = true)]
49+
private static extern void rtcGetTimeVar(out object retVal);
50+
public void GetTimeVar(out object retVal)
51+
{
52+
rtcGetTimeVar(out retVal);
53+
}
54+
55+
[DllImport(_dllName, SetLastError = true)]
56+
private static extern void rtcChangeDir(IntPtr path);
57+
public void ChangeDir(IntPtr path)
58+
{
59+
rtcChangeDir(path);
60+
}
61+
62+
[DllImport(_dllName, SetLastError = true)]
63+
private static extern void rtcChangeDrive(IntPtr driveletter);
64+
public void ChangeDrive(IntPtr driveletter)
65+
{
66+
rtcChangeDrive(driveletter);
67+
}
68+
69+
[DllImport(_dllName, SetLastError = true)]
70+
private static extern void rtcKillFiles(IntPtr pathname);
71+
public void KillFiles(IntPtr pathname)
72+
{
73+
rtcKillFiles(pathname);
74+
}
75+
76+
[DllImport(_dllName, SetLastError = true)]
77+
private static extern void rtcMakeDir(IntPtr path);
78+
public void MakeDir(IntPtr path)
79+
{
80+
rtcMakeDir(path);
81+
}
82+
83+
[DllImport(_dllName, SetLastError = true)]
84+
private static extern void rtcRemoveDir(IntPtr path);
85+
public void RemoveDir(IntPtr path)
86+
{
87+
rtcRemoveDir(path);
88+
}
89+
90+
[DllImport(_dllName, SetLastError = true)]
91+
private static extern void rtcBeep();
92+
public void Beep()
93+
{
94+
rtcBeep();
95+
}
2296
}
2397
}

Rubberduck.VBEEditor/VBERuntime/VBERuntimeAccessor.cs

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ private static IVBERuntime DetermineVersion()
4848
try
4949
{
5050
runtime = new VBERuntime7();
51-
runtime.Timer();
51+
runtime.GetTimer();
5252
_version = DllVersion.Vbe7;
5353
}
5454
catch
5555
{
5656
try
5757
{
5858
runtime = new VBERuntime6();
59-
runtime.Timer();
59+
runtime.GetTimer();
6060
_version = DllVersion.Vbe6;
6161
}
6262
catch
@@ -69,14 +69,66 @@ private static IVBERuntime DetermineVersion()
6969
return _version != DllVersion.Unknown ? runtime : null;
7070
}
7171

72-
public float Timer()
72+
public string DllName => _runtime.DllName;
73+
74+
public float GetTimer()
75+
{
76+
return _runtime.GetTimer();
77+
}
78+
79+
public void GetDateVar(out object retval)
80+
{
81+
_runtime.GetDateVar(out retval);
82+
}
83+
84+
public void GetPresentDate(out object retVal)
85+
{
86+
_runtime.GetPresentDate(out retVal);
87+
}
88+
89+
public double Shell(IntPtr pathname, short windowstyle)
90+
{
91+
return _runtime.Shell(pathname, windowstyle);
92+
}
93+
94+
public void GetTimeVar(out object retVal)
95+
{
96+
_runtime.GetTimeVar(out retVal);
97+
}
98+
99+
public void ChangeDir(IntPtr path)
73100
{
74-
return _runtime.Timer();
101+
_runtime.ChangeDir(path);
102+
}
103+
104+
public void ChangeDrive(IntPtr driveletter)
105+
{
106+
_runtime.ChangeDrive(driveletter);
107+
}
108+
109+
public void KillFiles(IntPtr pathname)
110+
{
111+
_runtime.KillFiles(pathname);
112+
}
113+
114+
public void MakeDir(IntPtr path)
115+
{
116+
_runtime.MakeDir(path);
117+
}
118+
119+
public void RemoveDir(IntPtr path)
120+
{
121+
_runtime.RemoveDir(path);
75122
}
76123

77124
public int DoEvents()
78125
{
79126
return _runtime.DoEvents();
80127
}
128+
129+
public void Beep()
130+
{
131+
_runtime.Beep();
132+
}
81133
}
82134
}

0 commit comments

Comments
 (0)