PageRenderTime 52ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/Main/GStreamer/Source/gstreamer-sharp/gstreamer-sharp/glib-sharp/List.cs

http://ossbuild.googlecode.com/
C# | 97 lines | 57 code | 21 blank | 19 comment | 2 complexity | 6b0ed5695eaf81031c6f25037f798366 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, GPL-2.0, AGPL-1.0, LGPL-2.1, LGPL-2.0, GPL-3.0, LGPL-3.0, CC-BY-SA-3.0
  1. // List.cs - GList class wrapper implementation
  2. //
  3. // Authors: Mike Kestner <mkestner@speakeasy.net>
  4. //
  5. // Copyright (c) 2002 Mike Kestner
  6. //
  7. // This program is free software; you can redistribute it and/or
  8. // modify it under the terms of version 2 of the Lesser GNU General
  9. // Public License as published by the Free Software Foundation.
  10. //
  11. // This program is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. // Lesser General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU Lesser General Public
  17. // License along with this program; if not, write to the
  18. // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. // Boston, MA 02111-1307, USA.
  20. namespace Gst.GLib {
  21. using System;
  22. using System.Runtime.InteropServices;
  23. public class List : ListBase {
  24. [DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
  25. static extern IntPtr g_list_copy (IntPtr l);
  26. public override object Clone ()
  27. {
  28. return new List (g_list_copy (Handle));
  29. }
  30. [DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
  31. static extern int g_list_length (IntPtr l);
  32. internal override int Length (IntPtr list)
  33. {
  34. return g_list_length (list);
  35. }
  36. [DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
  37. static extern void g_list_free(IntPtr l);
  38. internal override void Free (IntPtr list)
  39. {
  40. if (list != IntPtr.Zero)
  41. g_list_free (list);
  42. }
  43. [DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
  44. static extern IntPtr g_list_append (IntPtr l, IntPtr raw);
  45. internal override IntPtr Append (IntPtr list, IntPtr raw)
  46. {
  47. return g_list_append (list, raw);
  48. }
  49. [DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
  50. static extern IntPtr g_list_prepend (IntPtr l, IntPtr raw);
  51. internal override IntPtr Prepend (IntPtr list, IntPtr raw)
  52. {
  53. return g_list_prepend (list, raw);
  54. }
  55. [DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
  56. static extern IntPtr g_list_nth_data (IntPtr l, uint n);
  57. internal override IntPtr NthData (uint n)
  58. {
  59. return g_list_nth_data (Handle, n);
  60. }
  61. public List (IntPtr raw) : this (raw, null) {}
  62. public List (System.Type element_type) : this (IntPtr.Zero, element_type) {}
  63. public List (IntPtr raw, System.Type element_type) : this (raw, element_type, false, false) {}
  64. public List (IntPtr raw, System.Type element_type, bool owned, bool elements_owned) : base (raw, element_type, owned, elements_owned) {}
  65. public List (object[] elements, System.Type element_type, bool owned, bool elements_owned) : this (IntPtr.Zero, element_type, owned, elements_owned)
  66. {
  67. foreach (object o in elements)
  68. Append (o);
  69. }
  70. public List (Array elements, System.Type element_type, bool owned, bool elements_owned) : this (IntPtr.Zero, element_type, owned, elements_owned)
  71. {
  72. foreach (object o in elements)
  73. Append (o);
  74. }
  75. }
  76. }