/*
For a given uniform's type, return the proper setter function
186604
function getUniformSetter( type, location, gl, context ){
  switch( type ){
    case gl.FLOAT_MAT2  :
    case gl.FLOAT_MAT3  :
    case gl.FLOAT_MAT4  :
      return getMatrixSetFunction( type, location, gl, context );

    case gl.SAMPLER_2D  :
    case gl.SAMPLER_CUBE:
    case 0x8B62 : //gl.SAMPLER_2D_SHADOW:
    case 0x8B5F : //gl.SAMPLER_3D:
      return getSamplerSetFunction( type, location, gl, context );

    default  :
      return getUniformSetFunction( type, location, gl, context );
  }
}
454658
function setInstanceFromTypeValue(node)
		{
			if(node.type == "undefined")
			{	
				node.instance = undefined;
			}
			else if(node.type === "boolean")
			{
				node.instance = Boolean(node.value);
			}
			else if (node.type === "number")
			{
				node.instance = Number(node.value);
			}
			else if (node.type === "string")
			{
				node.instance = node.value;
			}
			else if (node.type === "symbol")
			{
				node.instance = Symbol(node.value);
			}
			else if(node.type === "function")
			{
				var fn;
				eval("fn = " + node.value);
				node.instance = fn;
			}
			else if(node.type === "null")
			{
				node.instance = null;
			}
			else if(node.type === "date")
			{
				node.instance = new Date(Number(node.value))
			}
			else if(node.type === "array")
			{
				node.instance = [];
			}
			else if(node.type === "empty")
			{
				node.instance = {};
			}
			else 
			{
				/* $lab:coverage:off$ */
				if(node.type !== "object")
					throw new Error("object expected");
				/* $lab:coverage:on$ */
				
				node.instance = {};
			}			

		}
1005283
function setValue1f( gl, v ) {

	var cache = this.cache;

	if ( cache[ 0 ] === v ) return;

	gl.uniform1f( this.addr, v );

	cache[ 0 ] = v;

}
883681
def p_set_type(self, p):
        ''''''
        p[0] = ast.SetType(value_type=p[3], annotations=p[5])
696002
function generateProp(type, defaultVal) {
        if ( type === void 0 ) type = [Boolean, String, Number];
        if ( defaultVal === void 0 ) defaultVal = null;

        return {
            default: defaultVal,
            type: type
        }
    }
578106
function EnumSet(iter) {
    var p = {};
    priv.set(this, p);
    var newIter = iter;
    if (Array.isArray(iter)) {
      newIter = Array.prototype.map.call(iter, function(x) {
        return [x, x];
      });
    } else if(iter && typeof iter.entries === 'function') {
      if (iter instanceof EnumMap) {
        newIter = {
          entries: function() {
            var pi = priv.get(iter);
            return new Iterator(pi.sequence.sequence, undefined, function(x) {
              return [x, x];
            });
          }
        };
      }
    }
    p.sequence = new Sequence(newIter);
  }
375457
private Iterable<? extends JSType> getTypeAlternatives(JSType type) {
    if (type.isUnionType()) {
      return type.getUnionMembers();
    } else {
      ObjectType objType = type.toMaybeObjectType();
      FunctionType constructor = objType != null ? objType.getConstructor() : null;
      if (constructor != null && constructor.isInterface()) {
        List<JSType> list = new ArrayList<>();
        for (FunctionType impl : constructor.getDirectSubTypes()) {
          list.add(impl.getInstanceType());
        }
        return list.isEmpty() ? null : list;
      } else {
        return null;
      }
    }
  }
813945
function getGetterSetter(object, name, kind) {
  if (hasProperty(object, name)) {
    const descriptor = descriptorOf(object, name);
    return descriptor[kind] ?  Maybe.Just(descriptor[kind])
    :      /* otherwise */     Maybe.Nothing();
  } else {
    return Maybe.Nothing();
  }
}
1321472
function getSamplerSetFunction( type, location, gl, context ){
  var unit = context.texIndex++;
  return function(){
    if( arguments.length === 1 ) {
      if( arguments[0].bind !== undefined ){ // is texture
        arguments[0].bind( unit );
        gl.uniform1i( location, unit );
      } else {
        gl.uniform1i( location, arguments[0] );
      }
    }
    return location;
  };
}
388353
function setType(object, type) {
    Object.defineProperty(object, '_ethersType', { configurable: false, value: type, writable: false });
}
717841
function setInflectType (inflect, types) {
  // use inflections if set as object else start fresh
  const out = typeof inflect === 'boolean' ? {} : inflect

  // if inflect is boolean use it for all types,
  // else use default for unset types
  const setInflect = typeof inflect === 'boolean' ? inflect : inflectTypeDef

  // For each Type set inflection, if not set
  for (const t of types) {
    const plural = inflection.transform(t, typeInflections[1])
    if (!(t in out))
      out[t] = setInflect

    // allow checking on pluralized too
    if (!(plural in out))
      out[plural] = out[t]
  }

  return out
}
263141
function setVersion(type, ver) {

  const idx = verMap[type];
  let cur = verArr[idx];
  let next = cur + 1;

  if (isTruthy(ver))
    next = ver;

  if (isTruthy(ver)) {
    verArr[idx] = ver;
  }

  else {
    if (type === 'patch') {
      if (next > maxPatch) {
        // zero current stepping
        // up to minor.
        verArr[idx] = 0;
        return setVersion('minor');
      }
      else {
        verArr[idx] = next;
      }
    }
    else if (type === 'minor') {
      if (next > maxMinor) {
        // zero current stepping
        // up to major.
        verArr[idx] = 0;
        return setVersion('major');
      }
      else {
        verArr[idx] = next;
      }
    }
    else {
      verArr[idx] = next;
    }
  }

}
289392
def type_map(gtype, fn):
    """"""

    cb = ffi.callback('VipsTypeMap2Fn', fn)
    return vips_lib.vips_type_map(gtype, cb, ffi.NULL, ffi.NULL)
869435
function (symbol, value) {
        if (value === undefined) {
            console.warn('Uniform value "' + symbol + '" is undefined');
        }
        var uniform = this.uniforms[symbol];
        if (uniform) {

            if (typeof value === 'string') {
                // Try to parse as a color. Invalid color string will return null.
                value = parseColor$1(value) || value;
            }

            uniform.value = value;

            if (this.autoUpdateTextureStatus && uniform.type === 't') {
                if (value) {
                    this.enableTexture(symbol);
                }
                else {
                    this.disableTexture(symbol);
                }
            }
        }
    }
87926
function computeStyle(elem, prop) {
        if (!win.getComputedStyle) {
          win.getComputedStyle = function(el, pseudo) {
            this.el = el;
            this.getPropertyValue = function(prop) {
              var re = /(\-([a-z]){1})/g;
              if (prop == 'float') prop = 'styleFloat';
              if (re.test(prop)) {
                prop = prop.replace(re, function() {
                  return arguments[2].toUpperCase();
                });
              }
              return el.currentStyle && el.currentStyle[prop] ? el.currentStyle[prop] : null;
            };
            return this;
          };
        }

        return win.getComputedStyle(elem, null).getPropertyValue(prop);
      }
972207
function(TYPE){
  var IS_MAP   = TYPE == 1
    , IS_EVERY = TYPE == 4;
  return function(object, callbackfn, that /* = undefined */){
    var f      = ctx(callbackfn, that, 3)
      , O      = toIObject(object)
      , result = IS_MAP || TYPE == 7 || TYPE == 2
          ? new (typeof this == 'function' ? this : Dict) : undefined
      , key, val, res;
    for(key in O)if(has(O, key)){
      val = O[key];
      res = f(val, key, object);
      if(TYPE){
        if(IS_MAP)result[key] = res;            // map
        else if(res)switch(TYPE){
          case 2: result[key] = val; break;     // filter
          case 3: return true;                  // some
          case 5: return val;                   // find
          case 6: return key;                   // findKey
          case 7: result[res[0]] = res[1];      // mapPairs
        } else if(IS_EVERY)return false;        // every
      }
    }
    return TYPE == 3 || IS_EVERY ? IS_EVERY : result;
  };
}
451527
def load_uniforms_generic(uniforms)
      uniforms.each do |(uniform, location)|
        # needs_update property is not added to all uniforms.
        next if uniform.needs_update == false || location == -1

        type = uniform.type
        value = uniform.value

        # AAAAAHHHHH!!!!! \o/ *flips table*
        case type
        when :int
          glUniform1i(location, value)
        when :ivec2
          glUniform2i(location, value[0], value[1])
        when :ivec3
          glUniform3i(location, value[0], value[1], value[2])
        when :ivec4
          glUniform4i(location, value[0], value[1], value[2], value[3])
        when :float
          glUniform1f(location, value)
        when :vec2
          glUniform2f(location, value[0], value[1])
        when :vec3, :color
          glUniform3f(location, value[0], value[1], value[2])
        when :vec4
          glUniform4f(location, value[0], value[1], value[2], value[3])
        when :'int[]'
          glUniform1iv(location, value.length, array_to_ptr_easy(value))
        when :'ivec2[]'
          glUniform2iv(location, value.length / 2, array_to_ptr_easy(value))
        when :'ivec3[]'
          glUniform3iv(location, value.length / 3, array_to_ptr_easy(value))
        when :'ivec4[]'
          glUniform4iv(location, value.length / 4, array_to_ptr_easy(value))
        when :'float[]'
          glUniform1fv(location, value.length, array_to_ptr_easy(value))
        when :'vec2[]'
          if value[0].is_a? Vector2
            uniform.array ||= value.flat_map(&:to_a) # TODO: Float32Array
            glUniform2fv(location, value.length, array_to_ptr_easy(uniform.array))
          else
            glUniform2fv(location, value.length / 2, array_to_ptr_easy(value))
          end
        when :'vec3[]', :'color[]'
          if value.first.is_a?(Vector3) || value.first.is_a?(Color)
            uniform.array ||= value.flat_map(&:to_a) # TODO: Float32Array
            glUniform3fv(location, value.length, array_to_ptr_easy(uniform.array))
          else
            glUniform3fv(location, value.length / 3, array_to_ptr_easy(value))
          end
        when :'vec4[]'
          if value.first.is_a? Vector4
            uniform.array ||= value.flat_map(&:to_a) # TODO: Float32Array
            glUniform4fv(location, value.length, array_to_ptr_easy(uniform.array))
          else
            glUniform4fv(location, value.length / 4, array_to_ptr_easy(value))
          end
        when :mat3
          glUniformMatrix3fv(location, 1, GL_FALSE, array_to_ptr_easy(value.to_a))
        when :mat4
          glUniformMatrix4fv(location, 1, GL_FALSE, array_to_ptr_easy(value.to_a))
        when :'mat3[]'
          if value.first.is_a? Matrix3
            uniform.array ||= Array.new(9 * value.length) # Float32Array

            value.each_with_index do |v, i|
              value[i].flatten_to_array_offset(uniform.array, i * 9)
            end

            glUniformMatrix3fv(location, value.length, GL_FALSE, array_to_ptr_easy(uniform.array))
          else
            glUniformMatrix3fv(location, value.length / 9, GL_FALSE, array_to_ptr_easy(value))
          end
        when :'mat4[]'
          if value.first.is_a? Matrix4
            uniform.array ||= Array.new(16 * value.length) # Float32Array

            value.each_with_index do |v, i|
              value[i].flatten_to_array_offset(uniform.array, i * 16)
            end

            glUniformMatrix4fv(location, value.length, GL_FALSE, array_to_ptr_easy(uniform.array))
          else
            glUniformMatrix4fv(location, value.length / 16, GL_FALSE, array_to_ptr_easy(value))
          end
        when :texture
          # single Mittsu::Texture (2d or cube)
          texture = value
          texture_unit = get_texture_unit

          glUniform1i(location, texture_unit)

          next unless texture

          texture.set(texture_unit, self)
          # TODO: when OpenGLRenderTargetCube is defined
          # elsif texture.is_a?(OpenGLRenderTargetCube)
            # set_cube_texture_dynamic(texture, texture_unit)
        when :'texture[]'
          # array of Mittsu::Texture (2d)
          uniform.array ||= []

          uniform.value.each_index do |i|
            uniform.array[i] = get_texture_unit
          end

          glUniform1iv(location, uniform.array.length, array_to_ptr_easy(uniform.array))

          uniform.value.each_with_index do |tex, i|
            tex_unit = uniform.array[i]

            next unless tex

            tex.set(tex_unit, self)
          end
        else
          puts "WARNING: Mittsu::OpenGLRenderer: Unknown uniform type: #{type}"
        end
      end
    end