Add utility function to create SWIGTYPE_p objects
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14923 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
b869290bae
commit
1ef9b8e716
|
@ -58,6 +58,7 @@
|
|||
<Compile Include="PluginManager.cs" />
|
||||
<Compile Include="ScriptPluginManager.cs" />
|
||||
<Compile Include="swig.cs" />
|
||||
<Compile Include="Util.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
@ -4,7 +4,7 @@ clean:
|
|||
rm -fr FreeSWITCH.Managed.dll
|
||||
|
||||
FreeSWITCH.Managed.dll: AssemblyInfo.cs Extensions.cs Loader.cs Log.cs ManagedSession.cs PluginInterfaces.cs PluginManager.cs ScriptPluginManager.cs swig.cs
|
||||
gmcs -target:library -out:FreeSWITCH.Managed.dll AssemblyInfo.cs Extensions.cs Loader.cs Log.cs ManagedSession.cs PluginInterfaces.cs PluginManager.cs ScriptPluginManager.cs ChannelVariables.cs swig.cs
|
||||
gmcs -target:library -out:FreeSWITCH.Managed.dll AssemblyInfo.cs Extensions.cs Loader.cs Log.cs ManagedSession.cs PluginInterfaces.cs PluginManager.cs ScriptPluginManager.cs ChannelVariables.cs Util.cs swig.cs
|
||||
|
||||
install: FreeSWITCH.Managed.dll
|
||||
$(INSTALL) FreeSWITCH.Managed.dll $(DESTDIR)$(MODINSTDIR)
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - mod_managed
|
||||
* Copyright (C) 2008, Michael Giagnocavo <mgg@giagnocavo.net>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - mod_managed
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Michael Giagnocavo <mgg@giagnocavo.net>
|
||||
* Portions created by the Initial Developer are Copyright (C)
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Michael Giagnocavo <mgg@giagnocavo.net>
|
||||
*
|
||||
* Util.cs - misc functions
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Reflection;
|
||||
|
||||
namespace FreeSWITCH {
|
||||
public static class FSUtil {
|
||||
// IntPtr cPtr, bool futureUse
|
||||
static readonly Type[] swigConstructorTypes = new [] { typeof(IntPtr), typeof(bool) };
|
||||
public static T CreateSwigTypePointer<T>(this IntPtr cPtr) {
|
||||
var ty = typeof(T);
|
||||
var bflags = BindingFlags.Default | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance;
|
||||
var cons = ty.GetConstructor(bflags, null, swigConstructorTypes, null);
|
||||
if (cons == null) throw new ArgumentException(ty.Name + " constructor not found.");
|
||||
return (T)cons.Invoke(new object[] { cPtr, false });
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue