Skip to content

Commit

Permalink
Add contrib directory with contributed wrappers by @ethindp. Manual m…
Browse files Browse the repository at this point in the history
…erge of #7.
  • Loading branch information
dkager committed Jan 27, 2017
1 parent e0c967d commit 21276cc
Show file tree
Hide file tree
Showing 6 changed files with 482 additions and 0 deletions.
38 changes: 38 additions & 0 deletions contrib/java-iodine/ConsoleApp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import System.*;
import DavyKager.*;

public class ConsoleApp
{
public static void Main()
{
Console.WriteLine("Tolk -- C# Console App Example");
Console.WriteLine("Initializing Tolk...");
Tolk.Load();
Console.WriteLine("Querying for the active screen reader driver...");
String name = Tolk.DetectScreenReader();
if (name != null)
{
Console.WriteLine("The active screen reader driver is: {0}", name);
}
else
{
Console.WriteLine("None of the supported screen readers is running");
}
if (Tolk.HasSpeech())
{
Console.WriteLine("This screen reader driver supports speech");
}
if (Tolk.HasBraille())
{
Console.WriteLine("This screen reader driver supports braille");
}
Console.WriteLine("Let\'s output some text...");
if (!Tolk.Output("Hello, World!"))
{
Console.WriteLine("Failed to output text");
}
Console.WriteLine("Finalizing Tolk...");
Tolk.Unload();
Console.WriteLine("Done!");
}
}
125 changes: 125 additions & 0 deletions contrib/java-iodine/Tolk.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package DavyKager;

import System.*;
import System.Runtime.InteropServices.*;

public final class Tolk
{
@DllImport("Tolk.dll", CharSet.Unicode, CallingConvention.Cdecl)
private static extern void Tolk_Load();

@DllImport("Tolk.dll", CharSet.Unicode, CallingConvention.Cdecl)
@MarshalAs(UnmanagedType.I1)
private static extern boolean Tolk_IsLoaded();

@DllImport("Tolk.dll", CharSet.Unicode, CallingConvention.Cdecl)
private static extern void Tolk_Unload();

@DllImport("Tolk.dll", CharSet.Unicode, CallingConvention.Cdecl)
private static extern void Tolk_TrySAPI(boolean trySAPI);

@DllImport("Tolk.dll", CharSet.Unicode, CallingConvention.Cdecl)
private static extern void Tolk_PreferSAPI(boolean preferSAPI);

@DllImport("Tolk.dll", CharSet.Unicode, CallingConvention.Cdecl)
private static extern IntPtr Tolk_DetectScreenReader();

@DllImport("Tolk.dll", CharSet.Unicode, CallingConvention.Cdecl)
@MarshalAs(UnmanagedType.I1)
private static extern boolean Tolk_HasSpeech();

@DllImport("Tolk.dll", CharSet.Unicode, CallingConvention.Cdecl)
@MarshalAs(UnmanagedType.I1)
private static extern boolean Tolk_HasBraille();

@DllImport("Tolk.dll", CharSet.Unicode, CallingConvention.Cdecl)
@MarshalAs(UnmanagedType.I1)
private static extern boolean Tolk_Output(String str, boolean interrupt);

@DllImport("Tolk.dll", CharSet.Unicode, CallingConvention.Cdecl)
@MarshalAs(UnmanagedType.I1)
private static extern boolean Tolk_Speak(String str, boolean interrupt);

@DllImport("Tolk.dll", CharSet.Unicode, CallingConvention.Cdecl)
@MarshalAs(UnmanagedType.I1)
private static extern boolean Tolk_Braille(String str);

@DllImport("Tolk.dll", CharSet.Unicode, CallingConvention.Cdecl)
@MarshalAs(UnmanagedType.I1)
private static extern boolean Tolk_IsSpeaking();

@DllImport("Tolk.dll", CharSet.Unicode, CallingConvention.Cdecl)
@MarshalAs(UnmanagedType.I1)
private static extern boolean Tolk_Silence();

// Prevent construction
private Tolk()
{
}

public static void Load()
{
Tolk_Load();
}

public static boolean IsLoaded()
{
return Tolk_IsLoaded();
}

public static void Unload()
{
Tolk_Unload();
}

public static void TrySAPI(boolean trySAPI)
{
Tolk_TrySAPI(trySAPI);
}

public static void PreferSAPI(boolean preferSAPI)
{
Tolk_PreferSAPI(preferSAPI);
}

// Prevent the marshaller from freeing the unmanaged string
public static String DetectScreenReader()
{
return Marshal.PtrToStringUni(Tolk_DetectScreenReader());
}

public static boolean HasSpeech()
{
return Tolk_HasSpeech();
}

public static boolean HasBraille()
{
return Tolk_HasBraille();
}

public static boolean Output(String str, boolean interrupt)
{
return Tolk_Output(str, interrupt);
}

public static boolean Speak(String str, boolean interrupt)
{
return Tolk_Speak(str, interrupt);
}

public static boolean Braille(String str)
{
return Tolk_Braille(str);
}

public static boolean IsSpeaking()
{
return Tolk_IsSpeaking();
}

public static boolean Silence()
{
return Tolk_Silence();
}
}
45 changes: 45 additions & 0 deletions contrib/oxygene/ConsoleApp.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
namespace;

interface

uses
System,
DavyKager;

type
ConsoleApp = public class
public
class method Main;
end;

implementation

class method ConsoleApp.Main;
begin
Console.WriteLine('Tolk -- C# Console App Example');
Console.WriteLine('Initializing Tolk...');
Tolk.Load();
Console.WriteLine('Querying for the active screen reader driver...');
var name: String := Tolk.DetectScreenReader();
if assigned(name) then begin
Console.WriteLine('The active screen reader driver is: {0}', name);
end
else begin
Console.WriteLine('None of the supported screen readers is running');
end;
if Tolk.HasSpeech() then begin
Console.WriteLine('This screen reader driver supports speech');
end;
if Tolk.HasBraille() then begin
Console.WriteLine('This screen reader driver supports braille');
end;
Console.WriteLine('Let''s output some text...');
if not Tolk.Output('Hello, World!') then begin
Console.WriteLine('Failed to output text');
end;
Console.WriteLine('Finalizing Tolk...');
Tolk.Unload();
Console.WriteLine('Done!');
end;

end.
136 changes: 136 additions & 0 deletions contrib/oxygene/Tolk.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
namespace DavyKager;

interface

uses
System,
System.Runtime.InteropServices;

type
Tolk = public sealed class
private
[DllImport('Tolk.dll', CharSet.Unicode, CallingConvention.Cdecl)]
class method Tolk_Load; external;
[DllImport('Tolk.dll', CharSet.Unicode, CallingConvention.Cdecl)]
[MarshalAs(UnmanagedType.I1)]
class method Tolk_IsLoaded: Boolean; external;
[DllImport('Tolk.dll', CharSet.Unicode, CallingConvention.Cdecl)]
class method Tolk_Unload; external;
[DllImport('Tolk.dll', CharSet.Unicode, CallingConvention.Cdecl)]
class method Tolk_TrySAPI(trySAPI: Boolean); external;
[DllImport('Tolk.dll', CharSet.Unicode, CallingConvention.Cdecl)]
class method Tolk_PreferSAPI(preferSAPI: Boolean); external;
[DllImport('Tolk.dll', CharSet.Unicode, CallingConvention.Cdecl)]
class method Tolk_DetectScreenReader: IntPtr; external;
[DllImport('Tolk.dll', CharSet.Unicode, CallingConvention.Cdecl)]
[MarshalAs(UnmanagedType.I1)]
class method Tolk_HasSpeech: Boolean; external;
[DllImport('Tolk.dll', CharSet.Unicode, CallingConvention.Cdecl)]
[MarshalAs(UnmanagedType.I1)]
class method Tolk_HasBraille: Boolean; external;
[DllImport('Tolk.dll', CharSet.Unicode, CallingConvention.Cdecl)]
[MarshalAs(UnmanagedType.I1)]
class method Tolk_Output(str: String; interrupt: Boolean): Boolean; external;
[DllImport('Tolk.dll', CharSet.Unicode, CallingConvention.Cdecl)]
[MarshalAs(UnmanagedType.I1)]
class method Tolk_Speak(str: String; interrupt: Boolean): Boolean; external;
[DllImport('Tolk.dll', CharSet.Unicode, CallingConvention.Cdecl)]
[MarshalAs(UnmanagedType.I1)]
class method Tolk_Braille(str: String): Boolean; external;
[DllImport('Tolk.dll', CharSet.Unicode, CallingConvention.Cdecl)]
[MarshalAs(UnmanagedType.I1)]
class method Tolk_IsSpeaking: Boolean; external;
[DllImport('Tolk.dll', CharSet.Unicode, CallingConvention.Cdecl)]
[MarshalAs(UnmanagedType.I1)]
class method Tolk_Silence: Boolean; external;
// Prevent construction
constructor;
public
class method Load;
class method IsLoaded: Boolean;
class method Unload;
class method TrySAPI(trySAPI: Boolean);
class method PreferSAPI(preferSAPI: Boolean);
// Prevent the marshaller from freeing the unmanaged string
class method DetectScreenReader: String;
class method HasSpeech: Boolean;
class method HasBraille: Boolean;
class method Output(str: String; interrupt: Boolean := false): Boolean;
class method Speak(str: String; interrupt: Boolean := false): Boolean;
class method Braille(str: String): Boolean;
class method IsSpeaking: Boolean;
class method Silence: Boolean;
end;

implementation

constructor Tolk;
begin
end;

class method Tolk.Load;
begin
Tolk_Load();
end;

class method Tolk.IsLoaded: Boolean;
begin
exit Tolk_IsLoaded();
end;

class method Tolk.Unload;
begin
Tolk_Unload();
end;

class method Tolk.TrySAPI(trySAPI: Boolean);
begin
Tolk_TrySAPI(trySAPI);
end;

class method Tolk.PreferSAPI(preferSAPI: Boolean);
begin
Tolk_PreferSAPI(preferSAPI);
end;

class method Tolk.DetectScreenReader: String;
begin
exit Marshal.PtrToStringUni(Tolk_DetectScreenReader());
end;

class method Tolk.HasSpeech: Boolean;
begin
exit Tolk_HasSpeech();
end;

class method Tolk.HasBraille: Boolean;
begin
exit Tolk_HasBraille();
end;

class method Tolk.Output(str: String; interrupt: Boolean := false): Boolean;
begin
exit Tolk_Output(str, interrupt);
end;

class method Tolk.Speak(str: String; interrupt: Boolean := false): Boolean;
begin
exit Tolk_Speak(str, interrupt);
end;

class method Tolk.Braille(str: String): Boolean;
begin
exit Tolk_Braille(str);
end;

class method Tolk.IsSpeaking: Boolean;
begin
exit Tolk_IsSpeaking();
end;

class method Tolk.Silence: Boolean;
begin
exit Tolk_Silence();
end;

end.
30 changes: 30 additions & 0 deletions contrib/swift-silver/ConsoleApp.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import System
import DavyKager

public class ConsoleApp {
public static func Main() {
Console.WriteLine("Tolk -- C# Console App Example")
Console.WriteLine("Initializing Tolk...")
Tolk.Load()
Console.WriteLine("Querying for the active screen reader driver...")
var name: String! = Tolk.DetectScreenReader()
if name != nil {
Console.WriteLine("The active screen reader driver is: {0}", name)
} else {
Console.WriteLine("None of the supported screen readers is running")
}
if Tolk.HasSpeech() {
Console.WriteLine("This screen reader driver supports speech")
}
if Tolk.HasBraille() {
Console.WriteLine("This screen reader driver supports braille")
}
Console.WriteLine("Let\'s output some text...")
if !Tolk.Output("Hello, World!") {
Console.WriteLine("Failed to output text")
}
Console.WriteLine("Finalizing Tolk...")
Tolk.Unload()
Console.WriteLine("Done!")
}
}
Loading

0 comments on commit 21276cc

Please sign in to comment.