<commit_before>// VVVV.js -- Visual Web Client Programming
// (c) 2011 <NAME>
// VVVV.js is freely distributable under the MIT license.
// Additional authors of sub components are mentioned at the specific code locations.

VVVV.Types = {}

VVVV.MousePositions = {'_all': {'x': 0.0, 'y': 0.0, 'wheel': 0.0, 'lb': 0.0, 'mb': 0.0, 'rb': 0.0}}

VVVV.Types.Color = function(r, g, b, a) {
  this.rgba = [r, g, b, a];
  
  this.toString = function() {
    return "r="+(r*100)+"% "+"g="+(g*100)+"% "+"b="+(b*100)+"% "+"a="+(a*100)+"%";
  }
}

var PinDirection = { Input : 0,Output : 1,Configuration : 2 };

VVVV.PinTypes.Generic = {
  typeName: "Generic",
  defaultValue: undefined
}

VVVV.Core = {	
  
  Pin: function(pinname,direction, init_values, node, reset_on_disconnect, type) {
    this.direction = direction;
    this.pinname = pinname;
    this.links = [];
    this.values = [];
    this.node = node;
    this.changed = true;
    this.active = false;
    this.reset_on_disconnect = reset_on_disconnect || false;
    this.slavePin = undefined;
    this.masterPin = undefined;
    this.connectionChangedHandlers = {};
    
    this.getValue = function(i, binSize) {
      if (!binSize || binSize==1)
        return this.values[i%this.values.length];
      var ret = [];
      for (var j=0; j<binSize; j++) {
        ret.push(this.values[(i*binSize+j)%this.values.length]);
      }
      return ret;
    }
    
    this.setValue = function(i, v) {
      this.values[i] = v;
      this.changed = true;
      this.node.dirty = true;
      var that = this;
      var linkCount = this.links.length;
      for (var j=0; j<linkCount; j++) {
        if (this.links[j].toPin==that) break;
        this.links[j].toPin.setValue(i, v);
      }
      if (this.slavePin) {
        this.slavePin.setValue(i, v);
      }
      if (this.node.isIOBox && this.pinname=='Descriptive Name') {
        if (this.node.parentPatch.domInterface)
          this.node.parentPatch.domInterface.connect(this.node);
        else if (this.node.parentPatch.parentPatch)
          this.node.registerInterfacePin();
      }
    }
    
    this.markPinAsChanged = function() {
      this.changed = true;
      this.node.dirty = true;
      var that = this;
      var linkCount = this.links.length;
      for (var i=0; i<linkCount; i++) {
        if (this.links[i].toPin==that) break;
        this.links[i].toPin.markPinAsChanged();
      }
      if (this.slavePin) {
        this.slavePin.markPinAsChanged();
      }
    }
    
    this.pinIsChanged = function() {
      var ret = this.changed;
      this.changed = false;
      return ret;
    }
	
    this.isConnected = function() {
      return (this.links.length > 0 || (this.masterPin && this.masterPin.isConnected()));
    }
    
    this.getSliceCount = function() {
      return this.values.length;
    }
	
    this.setSliceCount = function(len) {
      if (this.values.length==len)
        return;
      this.values.length = len;
      this.changed = true;	  
      this.node.dirty = true; 
	    var linkCount = this.links.length;
      for (var i=0; i<linkCount; i++) {
        this.links[i].toPin.values.length = len;
        this.links[i].toPin.changed = true;
        this.links[i].toPin.node.dirty = true;
      }
      if (this.slavePin) {
        this.slavePin.setSliceCount(len);
      }
    }
    
    this.setType = function(newType) {
      if (newType.typeName == this.typeName)
        return;
      var that = this;
      delete this.connectionChangedHandlers['nodepin'];
      delete this.connectionChangedHandlers['webglresource'];
      _(newType.connectionChangedHandlers).each(function(handler, key) {
        that.connectionChangedHandlers[key] = newType.connectionChangedHandlers[key];
      });
      this.typeName = newType.typeName;
      this.defaultValue = newType.defaultValue;
      
      if (this.direction == PinDirection.Input && this.defaultValue) {
        this.setValue(0, this.defaultValue());
        this.setSliceCount(1);
      }
      <commit_msg>fixes bug where decreasing slice count has not been forwarded to subpatch<commit_after>// VVVV.js -- Visual Web Client Programming
// (c) 2011 <NAME>
// VVVV.js is freely distributable under the MIT license.
// Additional authors of sub components are mentioned at the specific code locations.

VVVV.Types = {}

VVVV.MousePositions = {'_all': {'x': 0.0, 'y': 0.0, 'wheel': 0.0, 'lb': 0.0, 'mb': 0.0, 'rb': 0.0}}

VVVV.Types.Color = function(r, g, b, a) {
  this.rgba = [r, g, b, a];
  
  this.toString = function() {
    return "r="+(r*100)+"% "+"g="+(g*100)+"% "+"b="+(b*100)+"% "+"a="+(a*100)+"%";
  }
}

var PinDirection = { Input : 0,Output : 1,Configuration : 2 };

VVVV.PinTypes.Generic = {
  typeName: "Generic",
  defaultValue: undefined
}

VVVV.Core = {	
  
  Pin: function(pinname,direction, init_values, node, reset_on_disconnect, type) {
    this.direction = direction;
    this.pinname = pinname;
    this.links = [];
    this.values = [];
    this.node = node;
    this.changed = true;
    this.active = false;
    this.reset_on_disconnect = reset_on_disconnect || false;
    this.slavePin = undefined;
    this.masterPin = undefined;
    this.connectionChangedHandlers = {};
    
    this.getValue = function(i, binSize) {
      if (!binSize || binSize==1)
        return this.values[i%this.values.length];
      var ret = [];
      for (var j=0; j<binSize; j++) {
        ret.push(this.values[(i*binSize+j)%this.values.length]);
      }
      return ret;
    }
    
    this.setValue = function(i, v) {
      this.values[i] = v;
      this.changed = true;
      this.node.dirty = true;
      var that = this;
      if (this.direction==PinDirection.Output) {
        var linkCount = this.links.length;
        for (var j=0; j<linkCount; j++) {
          this.links[j].toPin.setValue(i, v);
        }
      }
      if (this.slavePin) {
        this.slavePin.setValue(i, v);
      }
      if (this.node.isIOBox && this.pinname=='Descriptive Name') {
        if (this.node.parentPatch.domInterface)
          this.node.parentPatch.domInterface.connect(this.node);
        else if (this.node.parentPatch.parentPatch)
          this.node.registerInterfacePin();
      }
    }
    
    this.markPinAsChanged = function() {
      this.changed = true;
      this.node.dirty = true;
      var that = this;
      if (this.direction==PinDirection.Output) {
        var linkCount = this.links.length;
        for (var i=0; i<linkCount; i++) {
          this.links[i].toPin.markPinAsChanged();
        }
      }
      if (this.slavePin) {
        this.slavePin.markPinAsChanged();
      }
    }
    
    this.pinIsChanged = function() {
      var ret = this.changed;
      this.changed = false;
      return ret;
    }
	
    this.isConnected = function() {
      return (this.links.length > 0 || (this.masterPin && this.masterPin.isConnected()));
    }
    
    this.getSliceCount = function() {
      return this.values.length;
    }
	
    this.setSliceCount = function(len) {
      if (this.values.length==len)
        return;
      this.values.length = len;
      this.changed = true;	  
      this.node.dirty = true;
      if (this.direction==PinDirection.Output) {
  	    var linkCount = this.links.length;
        for (var i=0; i<linkCount; i++) {
          this.links[i].toPin.setSliceCount(len);
        }
      }
      if (this.slavePin) {
        this.slavePin.setSliceCount(len);
      }
    }
    
    this.setType = function(newType) {
      if (newType.typeName == this.typeName)
        return;
      var that = this;
      delete this.connectionChangedHandlers['nodepin'];
      delete this.connectionChangedHandlers['webglresource'];
      _(newType.connectionChangedHandlers).each(function(handler, key) {
        that.connectionChangedHandlers[key] = newType.connectionChangedHandlers[key];
      });
      this.typeName = newType.typeName;
      this.defaultValue = newType.defaultValue;
      
      if (this.direction == PinDirection.Input && this.defaultValue) {
        this.setValue(0, this.defaultValue());
        this.setSliceCount(1);
      }
      
{'fraction_non_alphanumeric': 0.14870210135970333, 'fraction_numerical': 0.009641532756489494, 'mean_word_length': 2.429843153878762, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7202187', 'n_tokens_mistral': 2741, 'n_tokens_neox': 2672, 'n_words': 520}