| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,7 @@ internal class AssemblyManager { | |||
| 30 | 30 | static ResolveEventHandler rhandler; | |
| 31 | 31 | static Dictionary<string, int> probed; | |
| 32 | 32 | static List<Assembly> assemblies; | |
| 33 | - static List<string> pypath; | ||
| 33 | + internal static List<string> pypath; | ||
| 34 | 34 | ||
| 35 | 35 | private AssemblyManager() {} | |
| 36 | 36 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,9 +38,6 @@ internal CLRObject(Object ob, IntPtr tp) : base() { | |||
| 38 | 38 | this.pyHandle = py; | |
| 39 | 39 | this.gcHandle = gc; | |
| 40 | 40 | inst = ob; | |
| 41 | - | ||
| 42 | - //DebugUtil.DumpInst(py); | ||
| 43 | - | ||
| 44 | 41 | } | |
| 45 | 42 | ||
| 46 | 43 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,6 +22,7 @@ internal class ImportHook { | |||
| 22 | 22 | static IntPtr py_import; | |
| 23 | 23 | static ModuleObject root; | |
| 24 | 24 | static MethodWrapper hook; | |
| 25 | + static ClrModule clr; | ||
| 25 | 26 | static int preload; | |
| 26 | 27 | ||
| 27 | 28 | //=================================================================== | |
@@ -45,7 +46,9 @@ internal static void Initialize() { | |||
| 45 | 46 | ||
| 46 | 47 | root = new ModuleObject(""); | |
| 47 | 48 | Runtime.PyDict_SetItemString(dict, "CLR", root.pyHandle); | |
| 48 | - Runtime.PyDict_SetItemString(dict, "clr", root.pyHandle); | ||
| 49 | + | ||
| 50 | + clr = new ClrModule("clr"); | ||
| 51 | + Runtime.PyDict_SetItemString(dict, "clr", clr.pyHandle); | ||
| 49 | 52 | preload = -1; | |
| 50 | 53 | } | |
| 51 | 54 | ||
@@ -99,11 +102,16 @@ public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw) { | |||
| 99 | 102 | ||
| 100 | 103 | string mod_name = Runtime.GetManagedString(py_mod_name); | |
| 101 | 104 | ||
| 102 | - if (mod_name == "CLR" || mod_name == "clr") { | ||
| 105 | + if (mod_name == "CLR") { | ||
| 103 | 106 | Runtime.Incref(root.pyHandle); | |
| 104 | 107 | return root.pyHandle; | |
| 105 | 108 | } | |
| 106 | 109 | ||
| 110 | + if (mod_name == "clr") { | ||
| 111 | + Runtime.Incref(clr.pyHandle); | ||
| 112 | + return clr.pyHandle; | ||
| 113 | + } | ||
| 114 | + | ||
| 107 | 115 | string realname = mod_name; | |
| 108 | 116 | if (mod_name.StartsWith("CLR.")) { | |
| 109 | 117 | realname = mod_name.Substring(4); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,8 +30,14 @@ public PythonMethodAttribute() {} | |||
| 30 | 30 | ||
| 31 | 31 | [Serializable()] | |
| 32 | 32 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Delegate)] | |
| 33 | - internal class ModuleMethodAttribute : Attribute { | ||
| 34 | - public ModuleMethodAttribute() {} | ||
| 33 | + internal class ModuleFunctionAttribute : Attribute { | ||
| 34 | + public ModuleFunctionAttribute() {} | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + [Serializable()] | ||
| 38 | + [AttributeUsage(AttributeTargets.Property)] | ||
| 39 | + internal class ModulePropertyAttribute : Attribute { | ||
| 40 | + public ModulePropertyAttribute() {} | ||
| 35 | 41 | } | |
| 36 | 42 | ||
| 37 | 43 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -187,6 +187,12 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw, | |||
| 187 | 187 | int count = pi.Length; | |
| 188 | 188 | int outs = 0; | |
| 189 | 189 | ||
| 190 | + | ||
| 191 | + // if ((nargs > count) && (pi[count].ParameterType.IsArray)) { | ||
| 192 | + // // See if we can map to a params signature | ||
| 193 | + | ||
| 194 | + // } | ||
| 195 | + | ||
| 190 | 196 | if ( nargs == count ) { | |
| 191 | 197 | Object[] margs = new Object[count]; | |
| 192 | 198 | ||
@@ -219,7 +225,6 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw, | |||
| 219 | 225 | ||
| 220 | 226 | return new Binding(mi, target, margs, outs); | |
| 221 | 227 | } | |
| 222 | - | ||
| 223 | 228 | } | |
| 224 | 229 | return null; | |
| 225 | 230 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,9 +25,10 @@ internal class ModuleObject : ExtensionType { | |||
| 25 | 25 | ||
| 26 | 26 | Dictionary<string, ManagedType> cache; | |
| 27 | 27 | internal string moduleName; | |
| 28 | + internal IntPtr dict; | ||
| 28 | 29 | string _namespace; | |
| 29 | 30 | static bool hacked; | |
| 30 | - IntPtr dict; | ||
| 31 | + | ||
| 31 | 32 | ||
| 32 | 33 | public ModuleObject(string name) : base() { | |
| 33 | 34 | moduleName = (name == String.Empty) ? "CLR" : name; | |
@@ -254,6 +255,8 @@ public static IntPtr tp_repr(IntPtr ob) { | |||
| 254 | 255 | return Runtime.PyString_FromString(s); | |
| 255 | 256 | } | |
| 256 | 257 | ||
| 258 | + | ||
| 259 | + | ||
| 257 | 260 | } | |
| 258 | 261 | ||
| 259 | 262 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -79,6 +79,34 @@ public Type[] TestNullArrayConversion(Type [] v) { | |||
| 79 | 79 | return v; | |
| 80 | 80 | } | |
| 81 | 81 | ||
| 82 | + public static string[] TestStringParamsArg(params string[] args) { | ||
| 83 | + return args; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + public static object[] TestObjectParamsArg(params object[] args) { | ||
| 87 | + return args; | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + public static int[] TestValueParamsArg(params int[] args) { | ||
| 91 | + return args; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + public static int[] TestOneArgWithParams(string s, params int[] args) { | ||
| 95 | + return args; | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + public static int[] TestTwoArgWithParams(string s, string x, | ||
| 99 | + params int[] args) { | ||
| 100 | + return args; | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + public static int[] TestOverloadedParams(string v, params int[] args) { | ||
| 104 | + return args; | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + public static int[] TestOverloadedParams(int v, int[] args) { | ||
| 108 | + return args; | ||
| 109 | + } | ||
| 82 | 110 | ||
| 83 | 111 | public static bool TestStringOutParams (string s, out string s1) { | |
| 84 | 112 | s1 = "output string"; | |
@@ -128,6 +156,8 @@ public static void TestVoidSingleRefParam (ref int i) { | |||
| 128 | 156 | i = 42; | |
| 129 | 157 | } | |
| 130 | 158 | ||
| 159 | + | ||
| 160 | + | ||
| 131 | 161 | // overload selection test support | |
| 132 | 162 | ||
| 133 | 163 | public static bool Overloaded(bool v) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -243,6 +243,51 @@ def testNullArrayConversion(self): | |||
| 243 | 243 | self.failUnless(r == None) | |
| 244 | 244 | ||
| 245 | 245 | ||
| 246 | + def testStringParamsArgs(self): | ||
| 247 | + """Test use of string params.""" | ||
| 248 | + result = MethodTest.TestStringParamsArg('one', 'two', 'three') | ||
| 249 | + self.failUnless(len(result) == 3) | ||
| 250 | + self.failUnless(result[0] == 'one') | ||
| 251 | + self.failUnless(result[1] == 'two') | ||
| 252 | + self.failUnless(result[2] == 'three') | ||
| 253 | + | ||
| 254 | + result = MethodTest.TestStringParamsArg(['one', 'two', 'three']) | ||
| 255 | + self.failUnless(len(result) == 3) | ||
| 256 | + self.failUnless(result[0] == 'one') | ||
| 257 | + self.failUnless(result[1] == 'two') | ||
| 258 | + self.failUnless(result[2] == 'three') | ||
| 259 | + | ||
| 260 | + | ||
| 261 | + def testObjectParamsArgs(self): | ||
| 262 | + """Test use of object params.""" | ||
| 263 | + result = MethodTest.TestObjectParamsArg('one', 'two', 'three') | ||
| 264 | + self.failUnless(len(result) == 3) | ||
| 265 | + self.failUnless(result[0] == 'one') | ||
| 266 | + self.failUnless(result[1] == 'two') | ||
| 267 | + self.failUnless(result[2] == 'three') | ||
| 268 | + | ||
| 269 | + result = MethodTest.TestObjectParamsArg(['one', 'two', 'three']) | ||
| 270 | + self.failUnless(len(result) == 3) | ||
| 271 | + self.failUnless(result[0] == 'one') | ||
| 272 | + self.failUnless(result[1] == 'two') | ||
| 273 | + self.failUnless(result[2] == 'three') | ||
| 274 | + | ||
| 275 | + | ||
| 276 | + def testValueParamsArgs(self): | ||
| 277 | + """Test use of value type params.""" | ||
| 278 | + result = MethodTest.TestValueParamsArg(1, 2, 3) | ||
| 279 | + self.failUnless(len(result) == 3) | ||
| 280 | + self.failUnless(result[0] == 1) | ||
| 281 | + self.failUnless(result[1] == 2) | ||
| 282 | + self.failUnless(result[2] == 3) | ||
| 283 | + | ||
| 284 | + result = MethodTest.TestValueParamsArg([1, 2, 3]) | ||
| 285 | + self.failUnless(len(result) == 3) | ||
| 286 | + self.failUnless(result[0] == 1) | ||
| 287 | + self.failUnless(result[1] == 2) | ||
| 288 | + self.failUnless(result[2] == 3) | ||
| 289 | + | ||
| 290 | + | ||
| 246 | 291 | def testStringOutParams(self): | |
| 247 | 292 | """Test use of string out-parameters.""" | |
| 248 | 293 | result = MethodTest.TestStringOutParams("hi", "there") | |
| Back | FazBrowse Home | New Git URL |
0 commit comments