Skip to content

Commit 97f23a2

Browse files
committed
Rename internalAttributes to moduleState
1 parent c030c60 commit 97f23a2

File tree

12 files changed

+83
-87
lines changed

12 files changed

+83
-87
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ReadlineModuleBuiltins.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ private static final class LocalData {
9898
@Override
9999
public void postInitialize(Python3Core core) {
100100
super.postInitialize(core);
101-
core.lookupBuiltinModule(T_READLINE).setInternalAttributes(new LocalData());
101+
core.lookupBuiltinModule(T_READLINE).setModuleState(new LocalData());
102102
}
103103

104104
@Builtin(name = "get_completer", minNumOfPositionalArgs = 1, declaresExplicitSelf = true)
105105
@GenerateNodeFactory
106106
abstract static class GetCompleterNode extends PythonUnaryBuiltinNode {
107107
@Specialization
108108
static Object getCompleter(PythonModule self) {
109-
LocalData data = self.getInternalAttributes();
109+
LocalData data = self.getModuleState();
110110
if (data.completer != null) {
111111
return data.completer;
112112
} else {
@@ -120,7 +120,7 @@ static Object getCompleter(PythonModule self) {
120120
abstract static class SetCompleterNode extends PythonBinaryBuiltinNode {
121121
@Specialization
122122
PNone setCompleter(PythonModule self, Object callable) {
123-
LocalData data = self.getInternalAttributes();
123+
LocalData data = self.getModuleState();
124124
data.completer = callable;
125125
return PNone.NONE;
126126
}
@@ -134,7 +134,7 @@ abstract static class ParseAndBindNode extends PythonBinaryBuiltinNode {
134134
PNone setCompleter(PythonModule self, TruffleString tspec) {
135135
String spec = tspec.toJavaStringUncached();
136136
if (spec.startsWith("tab:")) {
137-
LocalData data = self.getInternalAttributes();
137+
LocalData data = self.getModuleState();
138138
data.bindings.put("tab", spec.split(":")[1].trim());
139139
return PNone.NONE;
140140
} else {
@@ -159,7 +159,7 @@ abstract static class GetHistoryLengthNode extends PythonUnaryBuiltinNode {
159159
@Specialization
160160
@TruffleBoundary
161161
int setCompleter(PythonModule self) {
162-
LocalData data = self.getInternalAttributes();
162+
LocalData data = self.getModuleState();
163163
return data.history.size();
164164
}
165165
}
@@ -170,7 +170,7 @@ abstract static class SetHistoryLengthNode extends PythonBinaryBuiltinNode {
170170
@Specialization
171171
@TruffleBoundary
172172
TruffleString setCompleter(PythonModule self, int index) {
173-
LocalData data = self.getInternalAttributes();
173+
LocalData data = self.getModuleState();
174174
try {
175175
return data.history.get(index);
176176
} catch (IndexOutOfBoundsException e) {
@@ -192,7 +192,7 @@ TruffleString setCompleter(PythonModule self, int index, PString string,
192192
@Specialization
193193
@TruffleBoundary
194194
TruffleString setCompleter(PythonModule self, int index, TruffleString string) {
195-
LocalData data = self.getInternalAttributes();
195+
LocalData data = self.getModuleState();
196196
try {
197197
return data.history.set(index, string);
198198
} catch (IndexOutOfBoundsException e) {
@@ -207,7 +207,7 @@ abstract static class DeleteItemNode extends PythonBinaryBuiltinNode {
207207
@Specialization
208208
@TruffleBoundary
209209
TruffleString setCompleter(PythonModule self, int index) {
210-
LocalData data = self.getInternalAttributes();
210+
LocalData data = self.getModuleState();
211211
try {
212212
return data.history.remove(index);
213213
} catch (IndexOutOfBoundsException e) {
@@ -229,7 +229,7 @@ static PNone addHistory(PythonModule self, PString item,
229229
@Specialization
230230
@TruffleBoundary
231231
static PNone addHistory(PythonModule self, TruffleString item) {
232-
LocalData data = self.getInternalAttributes();
232+
LocalData data = self.getModuleState();
233233
data.history.add(item);
234234
return PNone.NONE;
235235
}
@@ -249,7 +249,7 @@ PNone setCompleter(PythonModule self, PString path,
249249
@TruffleBoundary
250250
@SuppressWarnings("try")
251251
PNone setCompleter(PythonModule self, TruffleString path) {
252-
LocalData data = self.getInternalAttributes();
252+
LocalData data = self.getModuleState();
253253
try (GilNode.UncachedRelease gil = GilNode.uncachedRelease()) {
254254
BufferedReader reader = getContext().getEnv().getPublicTruffleFile(path.toJavaStringUncached()).newBufferedReader();
255255
String line;
@@ -277,7 +277,7 @@ PNone setCompleter(PythonModule self, PString path,
277277
@Specialization
278278
@TruffleBoundary
279279
PNone setCompleter(PythonModule self, TruffleString path) {
280-
LocalData data = self.getInternalAttributes();
280+
LocalData data = self.getModuleState();
281281
try {
282282
BufferedWriter writer = getContext().getEnv().getPublicTruffleFile(path.toJavaStringUncached()).newBufferedWriter(StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
283283
for (TruffleString l : data.history) {
@@ -298,7 +298,7 @@ abstract static class ClearNode extends PythonUnaryBuiltinNode {
298298
@Specialization
299299
@TruffleBoundary
300300
static PNone setCompleter(PythonModule self) {
301-
LocalData data = self.getInternalAttributes();
301+
LocalData data = self.getModuleState();
302302
data.history.clear();
303303
return PNone.NONE;
304304
}
@@ -327,7 +327,7 @@ static PNone setCompleter() {
327327
abstract static class GetAutoHistoryNode extends PythonUnaryBuiltinNode {
328328
@Specialization
329329
static boolean setCompleter(PythonModule self) {
330-
LocalData data = self.getInternalAttributes();
330+
LocalData data = self.getModuleState();
331331
return data.autoHistory;
332332
}
333333
}
@@ -337,7 +337,7 @@ static boolean setCompleter(PythonModule self) {
337337
abstract static class SetAutoHistoryNode extends PythonBinaryBuiltinNode {
338338
@Specialization
339339
static PNone setCompleter(PythonModule self, boolean enabled) {
340-
LocalData data = self.getInternalAttributes();
340+
LocalData data = self.getModuleState();
341341
data.autoHistory = enabled;
342342
return PNone.NONE;
343343
}
@@ -348,7 +348,7 @@ static PNone setCompleter(PythonModule self, boolean enabled) {
348348
abstract static class SetCompleterDelimsNode extends PythonBinaryBuiltinNode {
349349
@Specialization
350350
static PNone setCompleterDelims(PythonModule self, TruffleString completerDelims) {
351-
LocalData data = self.getInternalAttributes();
351+
LocalData data = self.getModuleState();
352352
data.completerDelims = completerDelims;
353353
return PNone.NONE;
354354
}
@@ -359,7 +359,7 @@ static PNone setCompleterDelims(PythonModule self, TruffleString completerDelims
359359
abstract static class GetCompleterDelimsNode extends PythonBuiltinNode {
360360
@Specialization
361361
static Object getCompleterDelims(PythonModule self) {
362-
LocalData data = self.getInternalAttributes();
362+
LocalData data = self.getModuleState();
363363
return (data.completerDelims != null) ? data.completerDelims : PNone.NONE;
364364
}
365365
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SignalModuleBuiltins.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void postInitialize(Python3Core core) {
135135

136136
PythonModule signalModule = core.lookupBuiltinModule(T__SIGNAL);
137137
ModuleData moduleData = new ModuleData();
138-
signalModule.setInternalAttributes(moduleData);
138+
signalModule.setModuleState(moduleData);
139139

140140
core.getContext().registerAsyncAction(() -> {
141141
SignalTriggerAction poll = moduleData.signalQueue.poll();
@@ -160,7 +160,7 @@ public void postInitialize(Python3Core core) {
160160
}
161161

162162
public static void resetSignalHandlers(PythonModule mod) {
163-
ModuleData data = mod.getInternalAttributes();
163+
ModuleData data = mod.getModuleState();
164164
if (data != null) {
165165
for (Map.Entry<Integer, SignalHandler> entry : data.defaultSignalHandlers.entrySet()) {
166166
Signals.setSignalHandler(entry.getKey(), entry.getValue());
@@ -227,7 +227,7 @@ abstract static class AlarmNode extends PythonBinaryClinicBuiltinNode {
227227
@TruffleBoundary
228228
int alarm(PythonModule module, int seconds) {
229229
int remaining = 0;
230-
ModuleData data = module.getInternalAttributes();
230+
ModuleData data = module.getModuleState();
231231
Signals.Alarm currentAlarm = data.currentAlarm;
232232
if (currentAlarm != null) {
233233
if (currentAlarm.isRunning()) {
@@ -277,7 +277,7 @@ abstract static class GetSignalNode extends PythonBinaryClinicBuiltinNode {
277277
@Specialization
278278
@TruffleBoundary
279279
static Object getsignal(PythonModule mod, int signum) {
280-
ModuleData data = mod.getInternalAttributes();
280+
ModuleData data = mod.getModuleState();
281281
return handlerToPython(Signals.getCurrentSignalHandler(signum), signum, data);
282282
}
283283

@@ -305,7 +305,7 @@ abstract static class SignalNode extends PythonTernaryBuiltinNode {
305305
@TruffleBoundary
306306
static Object signalHandler(PythonModule self, Object signal, Object handler,
307307
@Bind("this") Node inliningTarget) {
308-
ModuleData data = self.getInternalAttributes();
308+
ModuleData data = self.getModuleState();
309309
int signum = PyNumberAsSizeNode.executeExactUncached(signal);
310310
if (PyCallableCheckNode.executeUncached(handler)) {
311311
return signal(inliningTarget, signum, handler, data);
@@ -424,7 +424,7 @@ Object doIt(VirtualFrame frame, PythonModule self, int which, Object seconds, Ob
424424
@Cached PyTimeFromObjectNode timeFromObjectNode,
425425
@Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode,
426426
@Cached PythonObjectFactory factory) {
427-
ModuleData moduleData = self.getInternalAttributes();
427+
ModuleData moduleData = self.getModuleState();
428428
long usDelay = toMicroseconds(frame, inliningTarget, seconds, timeFromObjectNode);
429429
long usInterval = toMicroseconds(frame, inliningTarget, interval, timeFromObjectNode);
430430
if (which != ITIMER_REAL) {
@@ -492,7 +492,7 @@ static Object doIt(VirtualFrame frame, PythonModule self, int which,
492492
@Bind("this") Node inliningTarget,
493493
@Cached PConstructAndRaiseNode.Lazy constructAndRaiseNode,
494494
@Cached PythonObjectFactory factory) {
495-
ModuleData moduleData = self.getInternalAttributes();
495+
ModuleData moduleData = self.getModuleState();
496496
if (which != ITIMER_REAL) {
497497
throw constructAndRaiseNode.get(inliningTarget).raiseOSError(frame, OSErrorEnum.EINVAL);
498498
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SocketModuleBuiltins.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public void initialize(Python3Core core) {
188188
@Override
189189
public void postInitialize(Python3Core core) {
190190
PythonModule module = core.lookupBuiltinModule(T__SOCKET);
191-
module.setInternalAttributes(-1L);
191+
module.setModuleState(-1L);
192192
if (PosixSupportLibrary.getUncached().getBackend(core.getContext().getPosixSupport()).toJavaStringUncached().equals("java")) {
193193
module.setAttribute(toTruffleStringUncached(PosixConstants.AF_UNIX.name), PNone.NO_VALUE);
194194
}
@@ -231,7 +231,7 @@ public Object varArgExecute(VirtualFrame frame, Object self, Object[] arguments,
231231
public abstract static class GetDefaultTimeoutNode extends PythonUnaryBuiltinNode {
232232
@Specialization
233233
static Object get(PythonModule module) {
234-
long timeout = module.getInternalAttributes();
234+
long timeout = module.getModuleState();
235235
return timeout < 0 ? PNone.NONE : TimeUtils.pyTimeAsSecondsDouble(timeout);
236236
}
237237
}
@@ -244,7 +244,7 @@ static Object set(VirtualFrame frame, PythonModule module, Object value,
244244
@Bind("this") Node inliningTarget,
245245
@Cached SocketNodes.ParseTimeoutNode parseTimeoutNode) {
246246
long timeout = parseTimeoutNode.execute(frame, inliningTarget, value);
247-
module.setInternalAttributes(timeout);
247+
module.setModuleState(timeout);
248248
return PNone.NONE;
249249
}
250250
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ThreadModuleBuiltins.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
106106
public void initialize(Python3Core core) {
107107
addBuiltinConstant("error", core.lookupType(PythonBuiltinClassType.RuntimeError));
108108
addBuiltinConstant("TIMEOUT_MAX", TIMEOUT_MAX);
109-
core.lookupBuiltinModule(T__THREAD).setInternalAttributes(0);
109+
core.lookupBuiltinModule(T__THREAD).setModuleState(0);
110110
super.initialize(core);
111111
}
112112

@@ -177,7 +177,7 @@ abstract static class GetThreadCountNode extends PythonUnaryBuiltinNode {
177177
@Specialization
178178
@TruffleBoundary
179179
long getCount(PythonModule self) {
180-
return (int) self.getInternalAttributes();
180+
return self.<Integer> getModuleState();
181181
}
182182
}
183183

@@ -230,8 +230,8 @@ long start(VirtualFrame frame, Object cls, Object callable, Object args, Object
230230
TruffleThreadBuilder threadBuilder = env.newTruffleThreadBuilder(() -> {
231231
try (GilNode.UncachedAcquire gil = GilNode.uncachedAcquire()) {
232232
// the increment is protected by the gil
233-
int curCount = threadModule.getInternalAttributes();
234-
threadModule.setInternalAttributes(curCount + 1);
233+
int curCount = threadModule.getModuleState();
234+
threadModule.setModuleState(curCount + 1);
235235
try {
236236
// n.b.: It is important to pass 'null' frame here because each thread has
237237
// its own stack and if we would pass the current frame, this would be
@@ -246,8 +246,8 @@ long start(VirtualFrame frame, Object cls, Object callable, Object args, Object
246246
}
247247
// SystemExit is silently ignored (see _threadmodule.c: thread_run)
248248
} finally {
249-
curCount = threadModule.getInternalAttributes();
250-
threadModule.setInternalAttributes(curCount - 1);
249+
curCount = threadModule.getModuleState();
250+
threadModule.setModuleState(curCount - 1);
251251
}
252252
}
253253
}).context(env.getContext()).threadGroup(context.getThreadGroup());

0 commit comments

Comments
 (0)