Browse Source

Now do it right.

Neal Wilson 11 years ago
parent
commit
b3f21183fd
1 changed files with 9 additions and 8 deletions
  1. 9
    8
      src/typica.w

+ 9
- 8
src/typica.w View File

@@ -6437,11 +6437,18 @@ QScriptValue constructDAQ(QScriptContext *context, QScriptEngine *engine);
6437 6437
 QScriptValue DAQ_newChannel(QScriptContext *context, QScriptEngine *engine);
6438 6438
 void setDAQProperties(QScriptValue value, QScriptEngine *engine);
6439 6439
 
6440
-@ First we make these functions known to the scripting engine.
6440
+@ First we make these functions known to the scripting engine. We also add
6441
+the values from |Units::Unit| as this was widely used in configurations
6442
+before this enumeration was removed from the |DAQ| class. As these properties
6443
+must be available without an instance, the properties must be added here.
6441 6444
 
6442 6445
 @<Set up the scripting engine@>=
6443 6446
 constructor = engine->newFunction(constructDAQ);
6444 6447
 value = engine->newQMetaObject(&DAQ::staticMetaObject, constructor);
6448
+value.setProperty("Fahrenheit", Units::Fahrenheit);
6449
+value.setProperty("Celsius", Units::Celsius);
6450
+value.setProperty("Kelvin", Units::Kelvin);
6451
+value.setProperty("Rankine", Units::Rankine);
6445 6452
 engine->globalObject().setProperty("DAQ", value);
6446 6453
 
6447 6454
 @ When creating a new |DAQ|, we make sure that it is owned by the script engine.
@@ -6477,19 +6484,13 @@ QScriptValue constructDAQ(QScriptContext *context, QScriptEngine *engine)
6477 6484
 }
6478 6485
 
6479 6486
 @ As |DAQ| inherits |QObject|, we add the |newChannel()| property after adding
6480
-any |QObject| properties. We also add the values from |Units::Unit| as this was
6481
-widely used in configurations before this enumeration was removed from the
6482
-|DAQ| class.
6487
+any |QObject| properties.
6483 6488
 
6484 6489
 @<Functions for scripting@>=
6485 6490
 void setDAQProperties(QScriptValue value, QScriptEngine *engine)
6486 6491
 {
6487 6492
 	setQObjectProperties(value, engine);
6488 6493
 	value.setProperty("newChannel", engine->newFunction(DAQ_newChannel));
6489
-	value.setProperty("Fahrenheit", Units::Fahrenheit);
6490
-	value.setProperty("Celsius", Units::Celsius);
6491
-	value.setProperty("Kelvin", Units::Kelvin);
6492
-	value.setProperty("Rankine", Units::Rankine);
6493 6494
 }
6494 6495
 
6495 6496
 @ The |newChannel()| method method also requires that two arguments are provided

Loading…
Cancel
Save