• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

The MinGW.org Installation Manager Tool


Commit MetaInfo

修訂f3a84d2203e0d164fe3148753c487420a15d7722 (tree)
時間2020-06-22 19:44:57
作者Keith Marshall <keith@user...>
CommiterKeith Marshall

Log Message

Support options interpretation from an unborn options object.

Change Summary

差異

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
1+2020-06-22 Keith Marshall <keith@users.osdn.me>
2+
3+ Support options interpretation from an unborn options object.
4+
5+ * src/pkgopts.h (pkgOpts::Test, pkgOpts::IsSet, pkgOpts::GetValue)
6+ (pkgOpts::GetString, pkgOpts::SetFlags): Delegate then to static class
7+ methods, with inline wrappers passing "this" pointer explicitly.
8+
9+ * src/pkgopts.cpp (pkgOpts::Test, pkgOpts::IsSet, pkgOpts::GetValue)
10+ (pkgOpts::GetString, pkgOpts::SetFlags): Implement the static methods.
11+ (pkgPreferenceEvaluator::PresetScriptHook) [! pkgOptions()]: Do not
12+ evaluate pkgOptions()->IsSet(); assume that it would implicitly return
13+ false, thus suppressing all dependent processing, including subsequent
14+ evaluation of pkgOptions()->GetString().
15+
116 2020-06-21 Keith Marshall <keith@users.osdn.me>
217
318 Declare functions as void when return value is immaterial.
--- a/src/pkgopts.cpp
+++ b/src/pkgopts.cpp
@@ -3,8 +3,8 @@
33 *
44 * $Id$
55 *
6- * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
7- * Copyright (C) 2012, 2013, MinGW.org Project
6+ * Written by Keith Marshall <keith@users.osdn.me>
7+ * Copyright (C) 2012, 2013, 2020, MinGW.org Project
88 *
99 *
1010 * Implementation of XML interpreter for configuation of preferences.
@@ -231,7 +231,8 @@ void pkgPreferenceEvaluator::PresetScriptHook( int index, const char *key, ... )
231231 * and initialise associated environment variable hooks, such
232232 * that they override XML preference settings.
233233 */
234- if( pkgOptions()->IsSet( index ) && (key != NULL) && (*key != '\0') )
234+ pkgOpts *options = pkgOptions();
235+ if( options && options->IsSet( index ) && (key != NULL) && (*key != '\0') )
235236 {
236237 /* The indexed command line option has been specified, and
237238 * it is associated with a viable environment variable name;
@@ -241,7 +242,7 @@ void pkgPreferenceEvaluator::PresetScriptHook( int index, const char *key, ... )
241242 va_list argv;
242243 va_start( argv, key );
243244 const char *value = va_arg( argv, const char * );
244- const char *preset = pkgOptions()->GetString( index );
245+ const char *preset = options->GetString( index );
245246 if( (value = SetOptions( SetName( value ), argv, preset )) != NULL )
246247 {
247248 /* ...initialise the environment variable accordingly,
@@ -378,4 +379,51 @@ void pkgXmlDocument::EstablishPreferences( const char *client )
378379 }
379380 }
380381
382+unsigned pkgOpts::IsSet( pkgOpts *ref, int index )
383+{
384+ return ref
385+ ? ref->flags[OPTION_ASSIGNED_FLAGS].numeric & OPTION_ASSIGNED(index)
386+ : 0;
387+}
388+
389+unsigned pkgOpts::Test( pkgOpts *ref, unsigned mask, int index )
390+{
391+ /* Test the state of specified bits within
392+ * a bit-mapped numeric data (flags) entry.
393+ */
394+ return ref ? ref->flags[index].numeric & mask : 0;
395+}
396+
397+unsigned pkgOpts::GetValue( pkgOpts *ref, int index )
398+{
399+ /* Retrieve the value of a numeric data entry.
400+ */
401+ return ref ? ref->flags[index & 0xFFF].numeric : 0;
402+}
403+
404+const char *pkgOpts::GetString( pkgOpts *ref, int index )
405+{
406+ /* Retrieve a pointer to a string data entry.
407+ */
408+ return ref ? ref->flags[index & 0xFFF].string : NULL;
409+}
410+
411+void pkgOpts::SetFlags( pkgOpts *ref, unsigned value )
412+{
413+ /* This is a mask and store operation, to set a specified
414+ * bit-field within the first pair of flags slots; it mimics
415+ * the options setting operation performed in the CLI start-up
416+ * code, where the input value represents a 12-bit flag code,
417+ * packaged with a 12-bit combining mask, and an alignment
418+ * shift count between 0 and 52, in 4-bit increments.
419+ */
420+ if( ref )
421+ { unsigned shift;
422+ if( (shift = (value & OPTION_SHIFT_MASK) >> 22) < 53 )
423+ { *(uint64_t *)(ref->flags) &= ~((uint64_t)((value & 0xfff000) >> 12) << shift);
424+ *(uint64_t *)(ref->flags) |= (uint64_t)(value) << shift;
425+ }
426+ }
427+}
428+
381429 /* $RCSfile$: end of file */
--- a/src/pkgopts.h
+++ b/src/pkgopts.h
@@ -1,11 +1,10 @@
1-#ifndef PKGOPTS_H
21 /*
32 * pkgopts.h
43 *
54 * $Id$
65 *
7- * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
8- * Copyright (C) 2011, 2012, MinGW Project
6+ * Written by Keith Marshall <keith@users.osdn.me>
7+ * Copyright (C) 2011, 2012, 2020, MinGW Project
98 *
109 *
1110 * Public declarations of the data structures, values and functions
@@ -26,6 +25,7 @@
2625 * arising from the use of this software.
2726 *
2827 */
28+#ifndef PKGOPTS_H
2929 #define PKGOPTS_H 1
3030
3131 #include <stdint.h> /* required for uint64_t typedef */
@@ -126,48 +126,20 @@ class pkgOpts : protected pkgopts
126126 /* A derived "convenience" class, associating a collection
127127 * of utility methods with the pkgopts structure.
128128 */
129+ private:
130+ static unsigned IsSet( pkgOpts *, int );
131+ static unsigned GetValue( pkgOpts *, int );
132+ static const char *GetString( pkgOpts *, int );
133+ static unsigned Test( pkgOpts *, unsigned, int );
134+ static void SetFlags( pkgOpts *, unsigned );
135+
129136 public:
130- inline unsigned IsSet( int index )
131- {
132- return this
133- ? flags[OPTION_ASSIGNED_FLAGS].numeric & OPTION_ASSIGNED(index)
134- : 0;
135- }
136- inline unsigned GetValue( int index )
137- {
138- /* Retrieve the value of a numeric data entry.
139- */
140- return this ? (flags[index & 0xFFF].numeric) : 0;
141- }
142- inline const char *GetString( int index )
143- {
144- /* Retrieve a pointer to a string data entry.
145- */
146- return this ? (flags[index & 0xFFF].string) : NULL;
147- }
137+ inline unsigned IsSet( int index ){ return IsSet( this, index ); }
138+ inline unsigned GetValue( int index ){ return GetValue( this, index ); }
139+ inline const char *GetString( int index ){ return GetString( this, index ); }
140+ inline void SetFlags( unsigned value ){ SetFlags( this, value ); }
148141 inline unsigned Test( unsigned mask, int index = OPTION_FLAGS )
149- {
150- /* Test the state of specified bits within
151- * a bit-mapped numeric data (flags) entry.
152- */
153- return this ? (flags[index].numeric & mask) : 0;
154- }
155- inline void SetFlags( unsigned value )
156- {
157- /* This is a mask and store operation, to set a specified
158- * bit-field within the first pair of flags slots; it mimics
159- * the options setting operation performed in the CLI start-up
160- * code, where the input value represents a 12-bit flag code,
161- * packaged with a 12-bit combining mask, and an alignment
162- * shift count between 0 and 52, in 4-bit increments.
163- */
164- unsigned shift;
165- if( (shift = (value & OPTION_SHIFT_MASK) >> 22) < 53 )
166- {
167- *(uint64_t *)(flags) &= ~((uint64_t)((value & 0xfff000) >> 12) << shift);
168- *(uint64_t *)(flags) |= (uint64_t)(value) << shift;
169- }
170- }
142+ { return Test( this, mask, index ); }
171143 };
172144
173145 /* Access modes for the following global options accessor function.