/*!
Adds an enumeration
424142
function addEnumeration( $element )
    {
        $enumvalue = eZEnumValue::create( $this->ClassAttributeID, $this->ClassAttributeVersion, $element );
        $enumvalue->store();
        $this->Enumerations = eZEnumValue::fetchAllElements( $this->ClassAttributeID, $this->ClassAttributeVersion );
    }
1279976
function mod($data, $op = null) {
		if (!($this->data instanceof Expr)) {
			$this->data = new Expr($this->name);
		}
		
		if ($data instanceof Expr) {
			$this->data->add($data);
		} elseif (!isset($op) && is_numeric($data)) {
			$this->data->add(new Expr("+ $data"));
		} else {
			$this->data->add(new Expr("%s %s", isset($op) ? $op : "||", $data));
		}
		
		return $this;
	}
206346
public static function enumeratorError($attributeName, $annotationName, $context, $available, $given)
	{
		return new self(sprintf(
		    '[Enum Error] Attribute "%s" of @%s declared on %s accept only [%s], but got %s.',
		    $attributeName,
		    $annotationName,
		    $context,
		    implode(', ', $available),
		    is_object($given) ? get_class($given) : $given
		));
	}
89219
function enumFill(path, t, id) {
  const x = translateEnumValues(path, t);
  const assignments = x.map(([memberName, memberValue]) =>
    buildEnumMember(t.isStringLiteral(memberValue), {
      ENUM: t.cloneNode(id),
      NAME: memberName,
      VALUE: memberValue,
    }),
  );

  return buildEnumWrapper({
    ID: t.cloneNode(id),
    ASSIGNMENTS: assignments,
  });
}
1316388
function addIfNotExist(set, item) {
  if (set.has(item)) return true;
  set.add(item);
  return false;
}
958234
public function addValue($value)
    {
        if ($this->getValue($value) === null) {
            // issue #177, rare case: a struct and an enum has the same name and the enum is not detected by the SoapClient,
            // then we need to create the enumeration struct in order to deduplicate the two structs
            // this is why enumerations has to be parsed before any other elements by the WSDL parsers
            if (0 < $this->countOwnAttributes()) {
                $enum = new static($this->getGenerator(), $this->getName(), true, true);
                $enum
                    ->setInheritance(self::DEFAULT_ENUM_TYPE)
                    ->getValues()->add(new StructValue($enum->getGenerator(), $value, $enum->getValues()->count(), $enum));
                $this->getGenerator()->getStructs()->add($enum);
                return $enum;
            } else {
                $this
                    ->setStruct(true)
                    ->setRestriction(true)
                    ->values->add(new StructValue($this->getGenerator(), $value, $this->getValues()->count(), $this));
            }
        }
        return $this;
    }
170073
protected function addValueSetColumnAttributes(&$script)
    {
        $script .= "
    /** The enumerated values for this table */
    protected static \$enumValueSets = array(";
        foreach ($this->getTable()->getColumns() as $col) {
            if ($col->isValueSetType()) {
                $script .= "
                {$col->getFQConstantName()} => array(
                ";
                foreach ($col->getValueSet() as $value) {
                    $script .= "            self::" . $col->getConstantName() . '_' . $this->getValueSetConstant($value) . ",
";
                }
                $script .= "        ),";
            }
        }
        $script .= "
    );
";
    }
1287177
function addArray($arr, &$n, $name=""){
		foreach ($arr as $key => $val){
			if (is_int($key)){
				if (strlen($name)>1){
					$newKey = blib_grammar::singular($name); //substr($name, 0, strlen($name)-1);
				}else{
					$newKey="item";
				}
			}else{
				$newKey = $key;
			}

			$node = $this->doc->createElement($newKey);
			if (is_array($val)){
				$this->addArray($arr[$key], $node, $key);
			}else{
				$nodeText = $this->doc->createTextNode($val);
				$node->appendChild($nodeText);
			}
			$n->appendChild($node);
		}
	}
1232912
def _add_enum_member(enum, name, value, bitmask=DEFMASK):
    """"""
    error = idaapi.add_enum_member(enum, name, value, bitmask)

    if error:
        raise _enum_member_error(error, enum, name, value, bitmask)
380327
private function LoadEnumerationsFromJson()
    {
        $enumerations_def = Json::Decode(
            file_get_contents($this->definitions_path . "enumerations.json")
        );

        foreach($enumerations_def as $header => $namespaces)
        {
            $this->symbols->AddHeader($header);
            
            foreach($namespaces as $namespace => $enumerations)
            {
                foreach($enumerations as $enumeration_name => $enumeration_data)
                {
                    if(!isset($enumeration_data["description"]))
                        $enumeration_data["description"] = "";
                    
                    $enumeration = new Element\Enumeration(
                        $enumeration_name,
                        $enumeration_data["options"],
                        $enumeration_data["description"]
                    );

                    $this->symbols->headers[$header]->AddEnumeration(
                        $enumeration,
                        $namespace
                    );
                }
            }
        }

        unset($enumerations_def);
    }
1174621
function addNumeratorsTogether(node) {
  const newNode = clone(node);

  newNode.args[0] = Node.Creator.constant(newNode.args[0].eval());
  return Node.Status.nodeChanged(
    ChangeTypes.ADD_NUMERATORS, node, newNode);
}
447840
public function addEnum(string $enumClass): void
    {
        $constantOriginalList = $this->getConstantList($enumClass);
        $constantCombineList = array_combine($constantOriginalList, $constantOriginalList);
        $constantCombineNormalizeList = array_change_key_case($constantCombineList, CASE_LOWER);

        $this->enumList[$enumClass] = [
            self::TYPE_ORIGINAL => $constantOriginalList,
            self::TYPE_COMBINE => $constantCombineList,
            self::TYPE_COMBINE_NORMALIZE => $constantCombineNormalizeList,
        ];
    }
242942
private function SaveEnumerationsToPHP()
    {
        $output_file = fopen(
            $this->definitions_path . "enumerations.php", 
            "w"
        );
        
        fwrite($output_file, "<?php\n\n");
        
        fwrite($output_file, "use Peg\Lib\Definitions\Element\Enumeration;\n");
        
        foreach($this->symbols->headers as $header)
        {
            if(!$header->HasEnumerations())
                continue;
            
            foreach($header->namespaces as $namespace)
            {
                if(!$namespace->HasEnumerations())
                    continue;
                
                foreach($namespace->enumerations as $enumeration)
                {
                    $description = addslashes($enumeration->description);
                    $namespace_name = addslashes($namespace->name);
                    
                    $output = "\n";
                    $output .= '$symbols->AddEnumeration(' . "\n";
                    $output .= '    new Enumeration(' . "\n";
                    $output .= '        "'.$enumeration->name.'",' . "\n";
                    
                    $output .= '        [' . "\n";
                    foreach($enumeration->options as $option)
                    {
                        $output .= '            "'.$option.'",' . "\n";
                    }
                    $output = rtrim($output, ",\n") . "\n";
                    $output .= '        ],' . "\n";
                    
                    $output .= '        "'.$description.'"' . "\n";
                    $output .= '    ),' . "\n";
                    $output .= '    "'.$header->name.'",' . "\n";
                    $output .= '    "'.$namespace_name.'"' . "\n";
                    $output .= ');' . "\n";
                    
                    fwrite($output_file, $output);
                }
            }
        }
        
        fclose($output_file);
    }
538927
function nestingLevelFix(&$dom) {
        $startingNestingLevel = $this->parent->nestingLevel();
        foreach($dom['.SimplOn.Element, .SimplOn.Data'] as $node) {
            $domNode = pq($node);
            $classes = explode(' ', $domNode->attr('class'));
            if(substr($classes[2], 0, 4) == 'SNL-') {
                $nestingLevel = substr($classes[2], 4) + $startingNestingLevel;
                $classes[2] = 'SNL-' . $nestingLevel;
                $domNode->attr('class', implode(' ', $classes));
            }
        }
    }
65531
public function set($key, $value)
    {
        if (!is_null($key)
            && is_scalar($key)
        ) {
            return $this->_items[$key] = $value;
        } else {
            // given index name is not valid
            throw new EnumeratorException('Element could not be added to list. Index is not valid.', E_NOTICE);
        }
    }
828185
@ReplacedBy("com.google.common.collect.Iterators#addAll(Collection, com.google.common.collect.Iterators#forEnumeration(Enumeration))")
    public static <T, C extends Collection<T>> C addAll (C col, Enumeration<? extends T> enm)
    {
        while (enm.hasMoreElements()) {
            col.add(enm.nextElement());
        }
        return col;
    }
342335
public static <T> void addAll(Collection<T> col, Enumeration<T> e) {
		while (e.hasMoreElements())
			col.add(e.nextElement());
	}