Commit 5a7fb3d9 authored by Martin Finkel's avatar Martin Finkel

some renaming

parent 46109c23
......@@ -2,20 +2,20 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using libvlc;
using libvlcsharp;
namespace Sample
{
public class Instance
{
private LibvlcInstanceT _instance;
private libvlcsharp.Instance _instance;
public Instance(int argc, string[] args)
{
unsafe
{
if (args == null || !args.Any())
_instance = libvlc.libvlc.LibvlcNew(argc, null);
_instance = libvlc.LibvlcNew(argc, null);
else
{
fixed (byte* arg0 = Encoding.ASCII.GetBytes(args[0]),
......@@ -25,14 +25,14 @@ namespace Sample
sbyte*[] arr = { (sbyte*)arg0, (sbyte*)arg1, (sbyte*)arg2 };
fixed (sbyte** argv = arr)
{
_instance = libvlc.libvlc.LibvlcNew(argc, argv);
_instance = libvlc.LibvlcNew(argc, argv);
}
}
}
}
}
public LibvlcInstanceT NativeReference => _instance;
public libvlcsharp.Instance NativeReference => _instance;
}
}
using System;
using libvlc;
using libvlcsharp;
namespace Sample
{
......
......@@ -84,7 +84,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Instance.cs" />
<Compile Include="libvlc.cs" />
<Compile Include="libvlcsharp.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
......
This diff is collapsed.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using CppSharp;
using CppSharp.Generators;
using CppSharp.Parser;
......@@ -13,20 +15,105 @@ namespace libvlcsharp
static void Main(string[] args)
{
ConsoleDriver.Run(new LibVLC());
//Console.ReadKey();
Console.ReadKey();
}
class LibVLC : ILibrary
{
public void Preprocess(Driver driver, ASTContext ctx)
{
}
public void Postprocess(Driver driver, ASTContext ctx)
{
// FIXME
ctx.IgnoreHeadersWithName("libvlc_events.h");
// TODO: rename LibvlcCallbackT to VLCCallback
CustomizeClasses(ctx);
CustomizeEnums(ctx);
}
private void CustomizeClasses(ASTContext ctx)
{
void Rename(string originalName, string newName)
{
ctx.FindClass(originalName).Single().Name = newName;
}
Rename("LibvlcInstanceT", "Instance");
Rename("LibvlcEventManagerT", "EventManager");
Rename("LibvlcModuleDescriptionT", "ModuleDescription");
Rename("LibvlcMediaTrackT", "MediaTrack");
Rename("LibvlcMediaPlayerT", "MediaPlayer");
Rename("LibvlcEqualizerT", "Equalizer");
Rename("LibvlcTrackDescriptionT", "TrackDescription");
Rename("VlcLogT", "Log");
Rename("LibvlcRendererItemT", "RendererItem");
Rename("LibvlcRendererDiscovererT", "RendererDiscoverer");
Rename("LibvlcRdDescriptionT", "RendererDiscovererDescription");
Rename("LibvlcMediaT", "Media");
Rename("LibvlcMediaListT", "MediaList");
Rename("LibvlcMediaStatsT", "MediaStats");
Rename("LibvlcMediaTrackInfoT", "MediaTrackInfo");
Rename("LibvlcAudioTrackT", "AudioTrack");
Rename("LibvlcVideoTrackT", "VideoTrack");
Rename("LibvlcSubtitleTrackT", "SubtitleTrack");
Rename("LibvlcMediaSlaveT", "MediaSlave");
Rename("LibvlcTitleDescriptionT", "TitleDescription");
Rename("LibvlcChapterDescriptionT", "ChapterDescription");
Rename("LibvlcAudioOutputT", "AudioOutput");
Rename("LibvlcAudioOutputDeviceT", "AudioOutputDevice");
Rename("LibvlcVideoViewpointT", "VideoViewpoint");
Rename("LibvlcMediaDiscovererT", "MediaDiscoverer");
Rename("LibvlcMediaDiscovererDescriptionT", "MediaDiscovererDescription");
}
private void CustomizeEnums(ASTContext ctx)
{
Rename("LibvlcLogLevel", "LogLevel", true, "LIBVLC_");
Rename("LibvlcStateT", "VLCState", strip: "Libvlc");
Rename("LibvlcMediaOption", "MediaOption", strip: "LibvlcMediaOption");
Rename("LibvlcTrackTypeT", "TrackType", strip: "LibvlcTrack");
Rename("LibvlcVideoOrientT", "VideoOrientation", strip: "LibvlcVideoOrient");
Rename("LibvlcVideoProjectionT", "VideoProjection", strip: "LibvlcVideoProjection");
Rename("LibvlcMetaT", "MetadataType", strip: "LibvlcMeta");
Rename("LibvlcMediaTypeT", "MediaType", strip: "LibvlcMediaType");
Rename("LibvlcMediaParseFlagT", "MediaParseOptions", strip: "LibvlcMedia");
Rename("LibvlcMediaParsedStatusT", "MediaParsedStatus", strip: "LibvlcMediaParsedStatus");
Rename("LibvlcMediaSlaveTypeT", "MediaSlaveType", strip: "LibvlcMediaSlaveType");
Rename("LibvlcTitle", "Title", strip: "LibvlcTitle");
Rename("LibvlcVideoMarqueeOptionT", "VideoMarqueeOption", strip: "LibvlcMarquee");
Rename("LibvlcNavigateModeT", "NavigationMode", strip: "LibvlcNavigate");
Rename("LibvlcPositionT", "Position", strip: "LibvlcPosition");
Rename("LibvlcTeletextKeyT", "TeletextKey", strip: "LibvlcTeletextKey");
Rename("LibvlcVideoLogoOptionT", "VideoLogoOption", strip: "LibvlcLogo");
Rename("LibvlcVideoAdjustOptionT", "VideoAdjustOption", strip: "LibvlcAdjust");
Rename("LibvlcAudioOutputDeviceTypesT", "AudioOutputDeviceType", strip: "LibvlcAudioOutput");
Rename("LibvlcAudioOutputChannelT", "AudioOutputChannel", strip: "LibvlcAudioChannel");
Rename("LibvlcMediaPlayerRole", "MediaPlayerRole", strip: "LibvlcRole");
Rename("LibvlcPlaybackModeT", "PlaybackMode", strip: "LibvlcPlaybackMode");
Rename("LibvlcMediaDiscovererCategoryT", "MediaDiscovererCategory", strip: "LibvlcMediaDiscoverer");
Rename("LibvlcDialogQuestionType", "DialogQuestionType", true, "LIBVLC_DIALOG_QUESTION_");
void Rename(string originalName, string newName, bool formatValues = false, string strip = null)
{
var match = ctx.FindEnum(originalName).Single();
match.Name = newName;
if (string.IsNullOrEmpty(strip)) return;
match.Items.ForEach(item =>
{
var name = item.Name.Replace(strip, string.Empty);
item.Name = formatValues
? CultureInfo.CurrentCulture.TextInfo.ToTitleCase(name.ToLower())
: name;
});
}
}
public void Setup(Driver driver)
......@@ -40,29 +127,17 @@ namespace libvlcsharp
driver.ParserOptions = new ParserOptions
{
IncludeDirs = new List<string> { libvlcHeaders, libvlcPluginsHeaders, h },
Verbose = true
//Verbose = true
};
var options = driver.Options;
options.GeneratorKind = GeneratorKind.CSharp;
options.CompileCode = true;
options.CheckSymbols = true;
options.OutputDir = Path.Combine(rootPath, "..\\Sample\\");
var module = options.AddModule("libvlc");
var module = options.AddModule("libvlcsharp");
module.Headers.Add("vlc.h");
//module.Libraries.Add("libvlc.dll");
//module.SharedLibraryName = "libvlc";
//module.SymbolsLibraryName = "libvlc";
//module.LibraryName = "libvlc";
//module.LibraryDirs.Add(Path.Combine(rootPath, "..\\Sample\\bin\\Debug\\"));
module.LibraryDirs.Add(libFolder);
module.Libraries.Add("libvlc.dll");
module.Libraries.AddRange(new[] { "libvlc.lib", "libvlccore.lib" });
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment