Skip to content

Commit

Permalink
Add and cleanup comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud Champion authored and photron committed Nov 10, 2010
1 parent 17c96a8 commit 5030184
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 113 deletions.
3 changes: 3 additions & 0 deletions Connect.cs
Expand Up @@ -11,6 +11,9 @@

namespace Libvirt
{
/// <summary>
/// The Connect class expose all connection related methods
/// </summary>
public class Connect
{
private const int MaxStringLength = 1024;
Expand Down
5 changes: 4 additions & 1 deletion Domain.cs
Expand Up @@ -11,6 +11,9 @@

namespace Libvirt
{
/// <summary>
/// The Domain class expose the domains related methods
/// </summary>
public class Domain
{
/// <summary>
Expand Down Expand Up @@ -314,7 +317,7 @@ public class Domain
/// Path to the interface.
/// </param>
/// <param name="stats">
/// A <see cref="virDomainInterfaceStatsStruct"/>network interface stats (returned).
/// A <see cref="DomainInterfaceStatsStruct"/>network interface stats (returned).
/// </param>
/// <param name="size">
/// Size of stats structure.
Expand Down
14 changes: 7 additions & 7 deletions Errors.cs
Expand Up @@ -38,7 +38,7 @@ public class Errors
/// A <see cref="IntPtr"/>pointer to the user data provided in the handler callback.
/// </param>
/// <param name="handler">
/// A <see cref="virErrorFunc"/>function to get called in case of error or NULL
/// A <see cref="ErrorFunc"/>function to get called in case of error or NULL
/// </param>
[DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virConnSetErrorFunc")]
public static extern void ConnSetErrorFunc(IntPtr conn, IntPtr userData, [MarshalAs(UnmanagedType.FunctionPtr)] ErrorFunc handler);
Expand All @@ -49,7 +49,7 @@ public class Errors
/// One will need to free the result with virResetError().
/// </summary>
/// <param name="to">
/// A <see cref="virError"/> target to receive the copy.
/// A <see cref="Error"/> target to receive the copy.
/// </param>
/// <returns>
/// 0 if no error was found and the error code otherwise and -1 in case of parameter error.
Expand All @@ -61,7 +61,7 @@ public class Errors
/// Default routine reporting an error to stderr.
/// </summary>
/// <param name="err">
/// A <see cref="virError"/> pointer to the error.
/// A <see cref="Error"/> pointer to the error.
/// </param>
[DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virDefaultErrorFunc")]
public static extern void DefaultErrorFunc([In] Error err);
Expand All @@ -70,7 +70,7 @@ public class Errors
/// Resets and frees the given error.
/// </summary>
/// <param name="err">
/// A <see cref="virError"/> error to free.
/// A <see cref="Error"/> error to free.
/// </param>
[DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virFreeError")]
public static extern void FreeError(Error err); // Does not work, anybody know why?
Expand All @@ -89,7 +89,7 @@ public class Errors
/// Reset the error being pointed to.
/// </summary>
/// <param name="err">
/// A <see cref="virError"/> pointer to the to clean up.
/// A <see cref="Error"/> pointer to the to clean up.
/// </param>
[DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virResetError")]
public static extern void ResetError(Error err);
Expand All @@ -105,7 +105,7 @@ public class Errors
/// Save the last error into a new error object.
/// </summary>
/// <returns>
/// A <see cref="virError"/> pointer to the copied error or NULL if allocation failed.
/// A <see cref="Error"/> pointer to the copied error or NULL if allocation failed.
/// It is the caller's responsibility to free the error with virFreeError().
/// </returns>
[DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virSaveLastError")]
Expand All @@ -119,7 +119,7 @@ public class Errors
/// A <see cref="IntPtr"/>pointer to the user data provided in the handler callback.
/// </param>
/// <param name="handler">
/// A <see cref="virErrorFunc"/>function to get called in case of error or NULL.
/// A <see cref="ErrorFunc"/>function to get called in case of error or NULL.
/// </param>
[DllImport("libvirt-0.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "virSetErrorFunc")]
public static extern void SetErrorFunc(IntPtr userData, [MarshalAs(UnmanagedType.FunctionPtr)] ErrorFunc handler);
Expand Down
3 changes: 3 additions & 0 deletions Event.cs
Expand Up @@ -10,6 +10,9 @@

namespace Libvirt
{
/// <summary>
/// The Event class expose all the event related methods
/// </summary>
public class Event
{
///<summary>
Expand Down
3 changes: 3 additions & 0 deletions Interface.cs
Expand Up @@ -8,6 +8,9 @@

namespace Libvirt
{
/// <summary>
/// The Interface class expose all interface related methods
/// </summary>
public class Interface
{
// TODO virInterfaceCreate
Expand Down
3 changes: 3 additions & 0 deletions Library.cs
Expand Up @@ -10,6 +10,9 @@

namespace Libvirt
{
/// <summary>
/// The Library class expose all libvirt library related methods
/// </summary>
public class Library
{
/// <summary>
Expand Down
22 changes: 20 additions & 2 deletions MarshalHelper.cs
Expand Up @@ -11,8 +11,17 @@

namespace Libvirt
{
/// <summary>
/// The MarshalHelper class provide some methods that simplify marshaling
/// </summary>
public class MarshalHelper
{
/// <summary>
/// Convert an IntPtr to a string array
/// </summary>
/// <param name="stringPtr">The pointer to the first element of the array</param>
/// <param name="stringCount">The number of elements in the array</param>
/// <returns>The string array</returns>
public static string[] ptrToStringArray(IntPtr stringPtr, int stringCount)
{
string[] members = new string[stringCount];
Expand All @@ -23,13 +32,22 @@ public static string[] ptrToStringArray(IntPtr stringPtr, int stringCount)
}
return members;
}

/// <summary>
/// Convert an IntPtr to a string
/// </summary>
/// <param name="stringPtr">The pointer</param>
/// <returns>The string</returns>
public static string ptrToString(IntPtr stringPtr)
{
IntPtr s = Marshal.ReadIntPtr(stringPtr, IntPtr.Size);
return Marshal.PtrToStringAnsi(s);
}

/// <summary>
/// Shift a pointer by offset (32 or 64 bits pointer)
/// </summary>
/// <param name="src">The pointer</param>
/// <param name="offset">The offset in bytes</param>
/// <returns>the shifted pointer</returns>
public static IntPtr IntPtrOffset(IntPtr src, int offset)
{
switch (IntPtr.Size)
Expand Down
11 changes: 8 additions & 3 deletions NativeFunctions.cs
Expand Up @@ -7,16 +7,21 @@
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace Libvirt
{
/// <summary>
/// The class expose some useful native functions
/// </summary>
public class NativeFunctions
{
// TODO : this is a temporary workaround for virConnectOpenAuth callback, this should be removed
/// <summary>
/// duplicate a string. The strdup function shall return a pointer to a new string, which is a duplicate of the string pointed to by s1.
/// </summary>
/// <param name="strSource">Pointer to the string that should be duplicated</param>
/// <returns>a pointer to a new string on success. Otherwise, it shall return a null pointer</returns>
[DllImport("msvcrt.dll", EntryPoint = "_strdup", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr StrDup(IntPtr strSource);

Expand Down
3 changes: 3 additions & 0 deletions Network.cs
Expand Up @@ -11,6 +11,9 @@

namespace Libvirt
{
/// <summary>
/// The Network clas expose all libvirt network related functions
/// </summary>
public class Network
{
/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions Node.cs
Expand Up @@ -11,6 +11,9 @@

namespace Libvirt
{
/// <summary>
/// The Node class expose all libvirt node related functions
/// </summary>
public class Node
{
private const int MaxStringLength = 1024;
Expand Down
3 changes: 3 additions & 0 deletions Secret.cs
Expand Up @@ -8,6 +8,9 @@

namespace Libvirt
{
/// <summary>
/// The Secret class expose all libvirt secret related functions
/// </summary>
public class Secret
{
// TODO virSecretDefineXML
Expand Down
5 changes: 4 additions & 1 deletion StoragePool.cs
Expand Up @@ -11,6 +11,9 @@

namespace Libvirt
{
/// <summary>
/// The StoragePool class expose all libvirt storage pool related functions
/// </summary>
public class StoragePool
{
private const int MaxStringLength = 1024;
Expand Down Expand Up @@ -90,7 +93,7 @@ public class StoragePool
/// A <see cref="IntPtr"/>pointer to storage pool.
/// </param>
/// <param name="flags">
/// A <see cref="virStoragePoolDeleteFlags"/>flags for obliteration process.
/// A <see cref="StoragePoolDeleteFlags"/>flags for obliteration process.
/// </param>
/// <returns>
/// 0 on success, or -1 if it could not be obliterate.
Expand Down

0 comments on commit 5030184

Please sign in to comment.