Example #1
0
function proc($key, $vals)
{
    $sum = 0;
    foreach ($vals as $val) {
        $sum += intval($val);
    }
    emit($page_id, $sum);
}
Example #2
0
function yylex()
{
    global $yytext, $yych, $yycursor, $yylimit;
    global $O;
    while ($yych = yynext()) {
        if ($yych == '/' && yypeek('/')) {
            consumeToEOL();
        } else {
            if ($yych == '[') {
                emit('LOOP {');
                indent(1);
            } else {
                if ($yych == ']') {
                    indent(-1);
                    emit('}');
                } else {
                    if ($yych == ',') {
                        emit(GET);
                    } else {
                        if ($yych == '.') {
                            emit(PUT);
                        } else {
                            if ($yych == '#') {
                                /* debug */
                            } else {
                                $count = $O['combine'] ? consumeChar($yych) : 1;
                                $cmd = false;
                                switch ($yych) {
                                    case '+':
                                        $cmd = INC;
                                        break;
                                    case '-':
                                        $cmd = DEC;
                                        break;
                                    case '<':
                                        $cmd = MOVL;
                                        break;
                                    case '>':
                                        $cmd = MOVR;
                                        break;
                                }
                                if ($cmd) {
                                    if ($count > 1) {
                                        emit($cmd, "(", $count, ")");
                                    } else {
                                        emit($cmd . '1');
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Example #3
0
 public function setForce($force)
 {
     if ($force < 0) {
         $force = 0;
     }
     if ($this->currentForce == $force) {
         return;
     }
     $this->currentForce = $force;
     emit($this->forceChanged($this->currentForce));
 }
Example #4
0
function proc($key, $val)
{
    incCounter("Users", "Total");
    if (empty($val['pages'])) {
        return;
    }
    incCounter("Users", "NumPages", count($val['pages']));
    foreach ($val['pages'] as $page_id => $val) {
        emit($page_id, 1);
    }
}
Example #5
0
 public function setAngle($angle)
 {
     if ($angle < 5) {
         $angle = 5;
     }
     if ($angle > 70) {
         $angle = 70;
     }
     if ($this->currentAngle == $angle) {
         return;
     }
     $this->currentAngle = $angle;
     $this->update();
     emit($this->angleChanged($this->currentAngle));
 }
Example #6
0
 /**
  * tests of emitting signals
  * - emitting a signal defined in PHP: testSignal() -> testSlot()
  * - emitting a signal defined in PHP that calls a C++ slot: testSignal() -> show()
  * - emitting a C++ signal that calls a PHP slot: testSignalSignal() -> clicked()
  * - emitting a C++ signal that calls a C++ slot: clicked() -> toggle()
  * - emitting a C++ signal that emits a PHP signal: pressed() -> testSignalSignal()
  * - emitting a C++ signal that emits a C++ signal: released() -> pressed()
  * - emitting a C++ signal with a primitive argument: clicked(true) -> setChecked(bool)
  */
 public function testEmitSignal()
 {
     $m = new MyButton();
     echo "testing emitting a PHP signal ";
     emit($m->testSignal());
     $this->assertEquals($m->slotTester, "slot called", "Signal could not be emitted or testSlot() could not be called\n");
     echo "done\n";
     $m->slotTester = "";
     // reset
     echo "testing emitting a PHP signal that calls a C++ slot ";
     emit($m->testSignal());
     echo "done\n";
     // emitting a C++ signal that calls a PHP slot
     echo "testing emitting a PHP signal that emits a C++ signal: testSignalSignal() -> clicked() ";
     emit($m->testSignalSignal());
     echo "done\n";
     // emitting a C++ signal that calls a C++ slot
     echo "testing emitting a C++ signal that calls a C++ slot: clicked() -> toggle() ";
     emit($m->clicked());
     echo "done\n";
     echo "testing emitting a C++ signal that emits a PHP signal: pressed() -> testSignalSignal() ";
     emit($m->pressed());
     echo "done\n";
     echo "testing emitting a C++ signal that emits a C++ signal: released() -> pressed() ";
     emit($m->released());
     echo "done\n";
     // calling signal/slots using basic type arguments
     echo "testing emitting a C++ signal with a boolean argument clicked(true) -> setChecked(bool) ";
     emit($m->clicked(true));
     $this->assertTrue($m->isChecked(), "Could not emit signal with boolean argument");
     echo "done\n";
     // calling signal/slots using basic type arguments
     echo "testing emitting a C++ signal with a boolean argument clicked(false) -> setChecked(bool) ";
     emit($m->clicked(false));
     $this->assertFalse($m->isChecked(), "Could not emit signal with boolean argument");
     echo "done\n";
     // TODO calling signal/slots using object type arguments
 }
Example #7
0
 function pragma($type, $args)
 {
     switch ($type) {
         case 'left':
             $this->left_assoc($args);
             break;
         case 'right':
             $this->right_assoc($args);
             break;
         case 'nonassoc':
             $this->non_assoc($args);
             break;
         case 'start':
             $this->start_symbol_set = $args;
             break;
         case 'class':
             $this->parser_class = $args[0];
             break;
             // Added
         // Added
         case 'extends':
             $this->parser_extends = $args[0];
             break;
         default:
             emit(sprintf("Bad Parser Pragma: (%s)", $type));
             exit(1);
     }
 }
function generateAtomInterfaces($interface, $atom, $isTopLevelInterface = false)
{
    /* if $interface is a top-level interface, we only generate for $interface itself
     * otherwise, we generate for its subinterfaces 
     * 
     *  <Atom atom='atom name'>
     *   <AtomName>atom name</AtomName>
     *   <InterfaceList>
     *     ..
     *     for each subInterface in $interface: generateInterface($interface, $atom)        (or $interface, if $isTopLevelInterface)
     *     ..
     *   </InterfaceList>
     * </Atom>
     * 
     * if $atom is null, we are presenting a template. Because ""==null and "" denotes an empty atom, we check with === (since "" !== null)
     */
    global $selectedRoleNr;
    global $allInterfaceObjects;
    $html = "";
    $subInterfaceIsRef = false;
    if ($isTopLevelInterface) {
        $subInterfaces = array($interface);
    } else {
        if (isset($interface['boxSubInterfaces'])) {
            $subInterfaces = $interface['boxSubInterfaces'];
        } else {
            if (isset($interface['refSubInterface'])) {
                $subInterfaces = array($allInterfaceObjects[$interface['refSubInterface']]);
                $subInterfaceIsRef = true;
            } else {
                $subInterfaces = array();
            }
        }
    }
    // note that the assignments below are about interfaces for the atom, not about the subinterfaces
    $nrOfInterfaces = count(getTopLevelInterfacesForConcept($interface['tgtConcept'], $selectedRoleNr));
    $hasInterfaces = $nrOfInterfaces == 0 ? '' : ' hasInterface=' . ($nrOfInterfaces == 1 ? 'single' : 'multiple');
    emit($html, '<div class=Atom atom=' . showHtmlAttrStr($atom) . $hasInterfaces . ' status=' . ($atom !== null ? 'unchanged' : 'new') . ' atomic=' . showHtmlAttrBool(count($subInterfaces) == 0) . '>');
    $atomName = showViewAtom($atom, $interface['tgtConcept']);
    // TODO: can be done more efficiently if we query the concept atoms once for each concept
    emit($html, "<div class=AtomName>" . $atomName . '</div>');
    if (count($subInterfaces) > 0) {
        emit($html, '<div class=InterfaceList>');
        foreach ($subInterfaces as $interface) {
            emit($html, generateInterface($interface, $atom, $subInterfaceIsRef));
        }
        emit($html, '</div>');
        // div class=InterfaceList
    }
    emit($html, '</div>');
    // div class=Atom
    return $html;
}
Example #9
0
 /**
  * Recollect all items
  *
  * @param bool $fresh (optional)
  *
  * @return bool
  */
 public function recollect(bool $fresh = true) : bool
 {
     if (!cache()->clear()) {
         return false;
     }
     $this->collectorsIncluded = false;
     foreach (array_keys(app()->getCollectorList($fresh)) as $entry) {
         $this->collect($entry, $fresh);
     }
     emit('system.collect');
     return true;
 }
Example #10
0
 function pragma($type, $args)
 {
     switch ($type) {
         case 'left':
             $this->left_assoc($args);
             break;
         case 'right':
             $this->right_assoc($args);
             break;
         case 'nonassoc':
             $this->non_assoc($args);
             break;
         case 'start':
             $this->start_symbol_set = $args;
             break;
         case 'class':
             $this->parser_class = $args[0];
             break;
         case 'expect':
             if (!ctype_digit($args[0])) {
                 emit(sprintf('Bad expect pragma: %s', $args[0]));
                 exit(1);
             }
             $this->expect_conflicts = $args[0];
             break;
         case 'token':
             $this->sym($args[0], @$args[1]);
             break;
         default:
             emit(sprintf('Bad Parser Pragma: (%s)', $type));
             exit(1);
     }
 }
Example #11
0
	public function markInbound(&$nodes)
	{
		foreach($this->triples as $triple)
		{
			if($this->shouldSkip($triple->predicate))
			{
				continue;
			}
			if(!($triple->object instanceof RDFURI))
			{
				continue;
			}
			$obj = strval($triple->object);
			if(!strncmp($obj, '#', 1) || !strncmp($obj, '_:', 2))
			{
				if(!isset($nodes[$obj]))
				{
					emit('Failed to locate ' . $obj);
					$triple->object->value = '!dangling!';
					$triple->object->dangling = true;
					continue;
				}
				$inboundValue = '<' . $triple->predicate . '> ' . $this->nonDeterministicHash;
				emit('Adding ' . $inboundValue . ' to ' . $obj . ' from ' . $this->subject);
				$nodes[$obj]->inbound[] = $inboundValue;
			}
		}
	}
Example #12
0
function main()
{
    session_start();
    global $CONFIG, $_REQUEST, $_SESSION, $authmask, $db;
    $params = array_merge($CONFIG, $_REQUEST, $_SESSION);
    $params = array_merge($params, login($db, $params));
    $cmd = check_cmd_auth($params);
    $meth = sprintf("do_%s", $cmd);
    $ret = $meth($db, $params);
    emit($ret);
}