| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 015502e commit 787f061
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,5 @@ | |||
| 1 | - <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| 1 | + <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | + <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> | ||
| 2 | 3 | <PropertyGroup> | |
| 3 | 4 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |
| 4 | 5 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |
@@ -14,20 +15,20 @@ | |||
| 14 | 15 | <DebugType>full</DebugType> | |
| 15 | 16 | <Optimize>true</Optimize> | |
| 16 | 17 | <OutputPath>.\bin\Debug\</OutputPath> | |
| 17 | - <DefineConstants>TRACE;DEBUG;PYTHON26,UCS2</DefineConstants> | ||
| 18 | + <DefineConstants>TRACE;DEBUG;PYTHON27,UCS2</DefineConstants> | ||
| 18 | 19 | <AllowUnsafeBlocks>true</AllowUnsafeBlocks> | |
| 19 | 20 | </PropertyGroup> | |
| 20 | 21 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |
| 21 | 22 | <DebugType>pdbonly</DebugType> | |
| 22 | 23 | <Optimize>true</Optimize> | |
| 23 | 24 | <OutputPath>.\bin\Release\</OutputPath> | |
| 24 | - <DefineConstants>TRACE;PYTHON26,UCS2</DefineConstants> | ||
| 25 | + <DefineConstants>TRACE;PYTHON27, UCS2</DefineConstants> | ||
| 25 | 26 | <AllowUnsafeBlocks>true</AllowUnsafeBlocks> | |
| 26 | 27 | </PropertyGroup> | |
| 27 | 28 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'EmbeddingTest|AnyCPU' "> | |
| 28 | 29 | <DebugSymbols>true</DebugSymbols> | |
| 29 | 30 | <OutputPath>bin\EmbeddingTest\</OutputPath> | |
| 30 | - <DefineConstants>TRACE;DEBUG;PYTHON26,UCS2</DefineConstants> | ||
| 31 | + <DefineConstants>TRACE;DEBUG;PYTHON27,UCS2</DefineConstants> | ||
| 31 | 32 | <AllowUnsafeBlocks>true</AllowUnsafeBlocks> | |
| 32 | 33 | <Optimize>true</Optimize> | |
| 33 | 34 | <DebugType>full</DebugType> | |
@@ -36,7 +37,7 @@ | |||
| 36 | 37 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'UnitTests|AnyCPU' "> | |
| 37 | 38 | <DebugSymbols>true</DebugSymbols> | |
| 38 | 39 | <OutputPath>bin\UnitTests\</OutputPath> | |
| 39 | - <DefineConstants>TRACE;DEBUG;PYTHON26,UCS2</DefineConstants> | ||
| 40 | + <DefineConstants>TRACE;DEBUG;PYTHON27,UCS2</DefineConstants> | ||
| 40 | 41 | <AllowUnsafeBlocks>true</AllowUnsafeBlocks> | |
| 41 | 42 | <Optimize>true</Optimize> | |
| 42 | 43 | <DebugType>full</DebugType> | |
@@ -149,6 +150,9 @@ | |||
| 149 | 150 | <None Include="x64\clrmodule-platform.il" /> | |
| 150 | 151 | <None Include="x86\clrmodule-platform.il" /> | |
| 151 | 152 | </ItemGroup> | |
| 153 | + <ItemGroup> | ||
| 154 | + <Content Include="python-clear.ico" /> | ||
| 155 | + </ItemGroup> | ||
| 152 | 156 | <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> | |
| 153 | 157 | <ProjectExtensions> | |
| 154 | 158 | <VisualStudio AllowExistingFolder="true" /> | |
@@ -161,4 +165,4 @@ copy "$(TargetDir)clr.pyd" "$(SolutionDir)" | |||
| 161 | 165 | </PostBuildEvent> | |
| 162 | 166 | <PreBuildEvent>del "$(TargetDir)clr.pyd"</PreBuildEvent> | |
| 163 | 167 | </PropertyGroup> | |
| 164 | - </Project> | ||
| 168 | + </Project> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,37 +30,7 @@ exit /b 1 | |||
| 30 | 30 | ||
| 31 | 31 | :BUILD_CLR_MODULE | |
| 32 | 32 | if not exist %INPUT_PATH% goto ERROR_MISSING_INPUT | |
| 33 | - %windir%\Microsoft.NET\Framework\v2.0.50727\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH% | ||
| 34 | - :: Call with buildclrmodule.bat <AnyCPU|x64> <INPUT_DIRECTORY> <OUTPUT_PATH> | ||
| 35 | - | ||
| 36 | - @echo off | ||
| 37 | - | ||
| 38 | - set TARGET_PLATFORM=%1 | ||
| 39 | - set INPUT_DIRECTORY=%~2 | ||
| 40 | - set INPUT_PATH="%INPUT_DIRECTORY%\clrmodule.il" | ||
| 41 | - set OUTPUT_PATH=%3 | ||
| 42 | - | ||
| 43 | - if %TARGET_PLATFORM%==AnyCPU goto SETUP32 | ||
| 44 | - if %TARGET_PLATFORM%==x64 goto SETUP64 | ||
| 45 | - goto ERROR_BAD_PLATFORM | ||
| 46 | - | ||
| 47 | - :SETUP32 | ||
| 48 | - set INCLUDE_PATH="%INPUT_DIRECTORY%\x86" | ||
| 49 | - goto BUILD_CLR_MODULE | ||
| 33 | + %windir%\Microsoft.NET\Framework\v4.0.30319\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH% | ||
| 50 | 34 | ||
| 51 | - :SETUP64 | ||
| 52 | - set INCLUDE_PATH="%INPUT_DIRECTORY%\x64" | ||
| 53 | - set ILASM_EXTRA_ARGS=/pe64 /x64 | ||
| 54 | - goto BUILD_CLR_MODULE | ||
| 55 | - | ||
| 56 | - :ERROR_BAD_PLATFORM | ||
| 57 | - echo Unknown target platform: %TARGET_PLATFORM% | ||
| 58 | - exit /b 1 | ||
| 59 | - | ||
| 60 | - :ERROR_MISSING_INPUT | ||
| 61 | - echo Can't find input file: %INPUT_PATH% | ||
| 62 | - exit /b 1 | ||
| 63 | - | ||
| 64 | - :BUILD_CLR_MODULE | ||
| 65 | - if not exist %INPUT_PATH% goto ERROR_MISSING_INPUT | ||
| 66 | - %windir%\Microsoft.NET\Framework\v2.0.50727\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH% | ||
| 35 | + ::: 2.0 | ||
| 36 | + :::%windir%\Microsoft.NET\Framework\v2.0.50727\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH% | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,13 +32,13 @@ | |||
| 32 | 32 | .assembly extern mscorlib | |
| 33 | 33 | { | |
| 34 | 34 | .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) | |
| 35 | - .ver 2:0:0:0 | ||
| 35 | + .ver 4:0:0:0 | ||
| 36 | 36 | } | |
| 37 | 37 | ||
| 38 | 38 | .assembly clr | |
| 39 | 39 | { | |
| 40 | 40 | .hash algorithm 0x00008004 | |
| 41 | - .ver 2:0:0:2 | ||
| 41 | + .ver 2:4:2:7 | ||
| 42 | 42 | } | |
| 43 | 43 | ||
| 44 | 44 | .module clr.dll | |
@@ -208,6 +208,10 @@ | |||
| 208 | 208 | #ifdef DEBUG_PRINT | |
| 209 | 209 | ldstr "Success!" | |
| 210 | 210 | call void [mscorlib]System.Console::WriteLine(string) | |
| 211 | + | ||
| 212 | + ldloc pythonRuntime | ||
| 213 | + callvirt instance string [mscorlib]System.Reflection.Assembly::get_CodeBase() | ||
| 214 | + call void [mscorlib]System.Console::WriteLine(string) | ||
| 211 | 215 | #endif | |
| 212 | 216 | leave.s LOADED_PYTHON_RUNTIME | |
| 213 | 217 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -64,11 +64,22 @@ public ManagedType GetAttribute(string name, bool guess) { | |||
| 64 | 64 | return cached; | |
| 65 | 65 | } | |
| 66 | 66 | ||
| 67 | - string qname = (_namespace == String.Empty) ? name : | ||
| 68 | - _namespace + "." + name; | ||
| 69 | - | ||
| 70 | 67 | ModuleObject m; | |
| 71 | 68 | ClassBase c; | |
| 69 | + Type type; | ||
| 70 | + | ||
| 71 | + //if (AssemblyManager.IsValidNamespace(name)) | ||
| 72 | + //{ | ||
| 73 | + // IntPtr py_mod_name = Runtime.PyString_FromString(name); | ||
| 74 | + // IntPtr modules = Runtime.PyImport_GetModuleDict(); | ||
| 75 | + // IntPtr module = Runtime.PyDict_GetItem(modules, py_mod_name); | ||
| 76 | + // if (module != IntPtr.Zero) | ||
| 77 | + // return (ManagedType)this; | ||
| 78 | + // return null; | ||
| 79 | + //} | ||
| 80 | + | ||
| 81 | + string qname = (_namespace == String.Empty) ? name : | ||
| 82 | + _namespace + "." + name; | ||
| 72 | 83 | ||
| 73 | 84 | // If the fully-qualified name of the requested attribute is | |
| 74 | 85 | // a namespace exported by a currently loaded assembly, return | |
@@ -84,7 +95,7 @@ public ManagedType GetAttribute(string name, bool guess) { | |||
| 84 | 95 | // includes types, delegates, enums, interfaces and structs. | |
| 85 | 96 | // Only public namespace members are exposed to Python. | |
| 86 | 97 | ||
| 87 | - Type type = AssemblyManager.LookupType(qname); | ||
| 98 | + type = AssemblyManager.LookupType(qname); | ||
| 88 | 99 | if (type != null) { | |
| 89 | 100 | if (!type.IsPublic) { | |
| 90 | 101 | return null; | |
@@ -100,7 +111,8 @@ public ManagedType GetAttribute(string name, bool guess) { | |||
| 100 | 111 | // of the steps in the qualified name, then try it again. | |
| 101 | 112 | bool fromFile; | |
| 102 | 113 | if (AssemblyManager.LoadImplicit(qname, out fromFile)) { | |
| 103 | - if (true == fromFile) { | ||
| 114 | + bool ignore = name.StartsWith("__"); | ||
| 115 | + if (true == fromFile && (!ignore)) { | ||
| 104 | 116 | string deprWarning = String.Format("\nThe module was found, but not in a referenced namespace.\n" + | |
| 105 | 117 | "Implicit loading is deprecated. Please use clr.AddReference(\"{0}\").", qname); | |
| 106 | 118 | Exceptions.deprecation(deprWarning); | |
@@ -311,6 +323,9 @@ internal class CLRModule : ModuleObject | |||
| 311 | 323 | protected static bool hacked = false; | |
| 312 | 324 | protected static bool interactive_preload = true; | |
| 313 | 325 | internal static bool preload; | |
| 326 | + // XXX Test performance of new features // | ||
| 327 | + internal static bool _SuppressDocs = false; | ||
| 328 | + internal static bool _SuppressOverloads = false; | ||
| 314 | 329 | ||
| 315 | 330 | public CLRModule() : base("clr") { | |
| 316 | 331 | _namespace = String.Empty; | |
@@ -358,6 +373,18 @@ public static void setPreload(bool preloadFlag) | |||
| 358 | 373 | preload = preloadFlag; | |
| 359 | 374 | } | |
| 360 | 375 | ||
| 376 | + //[ModulePropertyAttribute] | ||
| 377 | + public static bool SuppressDocs { | ||
| 378 | + get { return _SuppressDocs; } | ||
| 379 | + set { _SuppressDocs = value; } | ||
| 380 | + } | ||
| 381 | + | ||
| 382 | + //[ModulePropertyAttribute] | ||
| 383 | + public static bool SuppressOverloads { | ||
| 384 | + get { return _SuppressOverloads; } | ||
| 385 | + set { _SuppressOverloads = value; } | ||
| 386 | + } | ||
| 387 | + | ||
| 361 | 388 | [ModuleFunctionAttribute()] | |
| 362 | 389 | [ForbidPythonThreadsAttribute()] | |
| 363 | 390 | public static Assembly AddReference(string name) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -152,8 +152,10 @@ public static void InitExt() { | |||
| 152 | 152 | "import traceback\n" + | |
| 153 | 153 | "for item in traceback.extract_stack():\n" + | |
| 154 | 154 | " line = item[3]\n" + | |
| 155 | - " if line is not None:\n" + | ||
| 155 | + " if line is not None:\n" + | ||
| 156 | 156 | " if line.startswith('import CLR') or \\\n" + | |
| 157 | + " line.startswith('import clr') or \\\n" + | ||
| 158 | + " line.startswith('from clr') or \\\n" + | ||
| 157 | 159 | " line.startswith('from CLR'):\n" + | |
| 158 | 160 | " exec line\n" + | |
| 159 | 161 | " break\n"; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -122,7 +122,10 @@ public void Dispose() { | |||
| 122 | 122 | IntPtr gs = PythonEngine.AcquireLock(); | |
| 123 | 123 | Runtime.Decref(_pyType); | |
| 124 | 124 | Runtime.Decref(_pyValue); | |
| 125 | - Runtime.Decref(_pyTB); | ||
| 125 | + // XXX Do we ever get TraceBack? // | ||
| 126 | + if (_pyTB != IntPtr.Zero) { | ||
| 127 | + Runtime.Decref(_pyTB); | ||
| 128 | + } | ||
| 126 | 129 | PythonEngine.ReleaseLock(gs); | |
| 127 | 130 | } | |
| 128 | 131 | GC.SuppressFinalize(this); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -337,23 +337,23 @@ internal unsafe static void Decref(IntPtr op) { | |||
| 337 | 337 | Py_DecRef(op); | |
| 338 | 338 | return; | |
| 339 | 339 | #else | |
| 340 | - void *p = (void *)op; | ||
| 341 | - if ((void *)0 != p) { | ||
| 342 | - if (is32bit) { --(*(int *)p); } | ||
| 343 | - else { --(*(long *)p); } | ||
| 344 | - if ((*(int *)p) == 0) { | ||
| 345 | - // PyObject_HEAD: struct _typeobject *ob_type | ||
| 346 | - void *t = is32bit ? (void *)(*((uint *)p + 1)) : | ||
| 347 | - (void *)(*((ulong *)p + 1)); | ||
| 348 | - // PyTypeObject: destructor tp_dealloc | ||
| 349 | - void* f = is32bit ? (void*)(*((uint*)t + 6)) : | ||
| 350 | - (void*)(*((ulong*)t + 6)); | ||
| 351 | - if ((void *)0 == f) { | ||
| 352 | - return; | ||
| 340 | + void* p = (void*) op; | ||
| 341 | + if ((void*) 0 != p) { | ||
| 342 | + if (is32bit) { --(*(int*) p); } | ||
| 343 | + else { --(*(long*) p); } | ||
| 344 | + if ((*(int*) p) == 0) { | ||
| 345 | + // PyObject_HEAD: struct _typeobject *ob_type | ||
| 346 | + void* t = is32bit ? (void*) (*((uint*) p + 1)) : | ||
| 347 | + (void*) (*((ulong*) p + 1)); | ||
| 348 | + // PyTypeObject: destructor tp_dealloc | ||
| 349 | + void* f = is32bit ? (void*) (*((uint*) t + 6)) : | ||
| 350 | + (void*) (*((ulong*) t + 6)); | ||
| 351 | + if ((void*) 0 == f) { | ||
| 352 | + return; | ||
| 353 | + } | ||
| 354 | + NativeCall.Impl.Void_Call_1(new IntPtr(f), op); | ||
| 355 | + return; | ||
| 353 | 356 | } | |
| 354 | - NativeCall.Impl.Void_Call_1(new IntPtr(f), op); | ||
| 355 | - return; | ||
| 356 | - } | ||
| 357 | 357 | } | |
| 358 | 358 | #endif | |
| 359 | 359 | } | |
@@ -1021,7 +1021,7 @@ internal static bool PyUnicode_Check(IntPtr ob) { | |||
| 1021 | 1021 | return PyObject_TYPE(ob) == Runtime.PyUnicodeType; | |
| 1022 | 1022 | } | |
| 1023 | 1023 | ||
| 1024 | - #if (!UCS4) | ||
| 1024 | + #if (UCS2) | ||
| 1025 | 1025 | [DllImport(Runtime.dll, CallingConvention=CallingConvention.Cdecl, | |
| 1026 | 1026 | EntryPoint="PyUnicodeUCS2_FromObject", | |
| 1027 | 1027 | ExactSpelling=true, CharSet=CharSet.Unicode)] | |
| Back | FazBrowse Home | New Git URL |
0 commit comments