45
45
import com .oracle .graal .python .annotations .ArgumentClinic ;
46
46
import com .oracle .graal .python .builtins .Builtin ;
47
47
import com .oracle .graal .python .builtins .CoreFunctions ;
48
+ import com .oracle .graal .python .builtins .Python3Core ;
48
49
import com .oracle .graal .python .builtins .PythonBuiltins ;
49
50
import com .oracle .graal .python .builtins .PythonOS ;
50
51
import com .oracle .graal .python .builtins .objects .exception .OSErrorEnum ;
51
52
import com .oracle .graal .python .nodes .function .PythonBuiltinBaseNode ;
53
+ import com .oracle .graal .python .nodes .function .builtins .PythonBinaryBuiltinNode ;
52
54
import com .oracle .graal .python .nodes .function .builtins .PythonQuaternaryClinicBuiltinNode ;
53
55
import com .oracle .graal .python .nodes .function .builtins .clinic .ArgumentClinicProvider ;
54
56
import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
@@ -63,6 +65,18 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
63
65
return WinregModuleBuiltinsFactory .getFactories ();
64
66
}
65
67
68
+ private static final int HKEY_CURRENT_USER = 1 ;
69
+ private static final int HKEY_LOCAL_MACHINE = 2 ;
70
+ private static final int HKEY_CLASSES_ROOT = 3 ;
71
+
72
+ @ Override
73
+ public void initialize (Python3Core core ) {
74
+ super .initialize (core );
75
+ addBuiltinConstant ("HKEY_CURRENT_USER" , HKEY_CURRENT_USER );
76
+ addBuiltinConstant ("HKEY_LOCAL_MACHINE" , HKEY_LOCAL_MACHINE );
77
+ addBuiltinConstant ("HKEY_CLASSES_ROOT" , HKEY_CLASSES_ROOT );
78
+ }
79
+
66
80
@ Builtin (name = "OpenKey" , minNumOfPositionalArgs = 2 , parameterNames = {"key" , "sub_key" , "reserved" , "access" })
67
81
@ ArgumentClinic (name = "reserved" , defaultValue = "0" )
68
82
@ ArgumentClinic (name = "access" , defaultValue = "131097" )
@@ -76,6 +90,21 @@ protected ArgumentClinicProvider getArgumentClinic() {
76
90
@ SuppressWarnings ("unused" )
77
91
@ Specialization
78
92
Object openKey (VirtualFrame frame , Object key , Object subKey , Object reserved , Object access ) {
93
+ if (key instanceof Integer intKey ) {
94
+ if (intKey == HKEY_CLASSES_ROOT ) {
95
+ return factory ().createLock ();
96
+ }
97
+ }
98
+ throw raiseOSError (frame , OSErrorEnum .ENOENT );
99
+ }
100
+ }
101
+
102
+ @ Builtin (name = "EnumKey" , minNumOfPositionalArgs = 2 , parameterNames = {"key" , "index" })
103
+ @ GenerateNodeFactory
104
+ public abstract static class EnumKeyNode extends PythonBinaryBuiltinNode {
105
+ @ SuppressWarnings ("unused" )
106
+ @ Specialization
107
+ Object enumKey (VirtualFrame frame , Object key , Object index ) {
79
108
throw raiseOSError (frame , OSErrorEnum .ENOENT );
80
109
}
81
110
}
0 commit comments