origen 0.33.0 → 0.33.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4bbe04ff06fc71620ec53701cfda0b4ea651b44a
4
- data.tar.gz: 3515abaaad4c9e9779dd3064182d17b62abb9990
3
+ metadata.gz: ea3de179e5091905ff3b66188f8401c3cfff2188
4
+ data.tar.gz: 6e3c6bd9aba7ef3b6708c808c23698e26b9eb09a
5
5
  SHA512:
6
- metadata.gz: fe7b6df198be766746adfdd12d9c2fb2c49d7808f20c595785adf03816929376bbbd5252efaec7edd5d8db70905187fdc79229ab76c4eb4ea8a37606edf8e436
7
- data.tar.gz: 1d27cf5f647ab632461e78c45ab91fb572d06ac80a6cdccb066f34e5b7136355fb77b76163526212cd98c4f28e782045ed2c9dfc7b0c7335086594d77c0bf9e2
6
+ metadata.gz: a1e8f905773712b62081c45d718b2cf73eea2b2658b33e5d01bea258454ba913286992ccf9253f15c5accc37981d0a44a2e7479f5c76c566e89ae7f0cba7aa49
7
+ data.tar.gz: 089977506d24231885841260a7d6b5610b9e6b2db41bda63940b14f930cbfc7869f1c22c7ab8cd8b1cc2271f89cbce160e1a324aad3537db7481eb17eafc941c
@@ -1,7 +1,7 @@
1
1
  module Origen
2
2
  MAJOR = 0
3
3
  MINOR = 33
4
- BUGFIX = 0
4
+ BUGFIX = 1
5
5
  DEV = nil
6
6
 
7
7
  VERSION = [MAJOR, MINOR, BUGFIX].join(".") + (DEV ? ".pre#{DEV}" : '')
@@ -26,6 +26,9 @@ ORIGEN_COMMAND_ALIASES = {
26
26
  @command = ORIGEN_COMMAND_ALIASES[@command] || @command
27
27
  @global_commands = []
28
28
 
29
+ # Moved here so boot.rb file can know the current command
30
+ Origen.send :current_command=, @command
31
+
29
32
  # Don't log to file during the save command since we need to preserve the last log,
30
33
  # this is done as early in the process as possible so any deprecation warnings during
31
34
  # load don't trigger a new log
@@ -91,7 +94,6 @@ require 'origen/global_methods'
91
94
  include Origen::GlobalMethods
92
95
 
93
96
  Origen.lsf.current_command = @command
94
- Origen.send :current_command=, @command
95
97
 
96
98
  if ARGV.delete('-d') || ARGV.delete('--debug')
97
99
  begin
@@ -384,11 +384,7 @@ module Origen
384
384
  opts = {}
385
385
 
386
386
  # merge the given options with any that are overriden with the block.
387
- if block_given?
388
- collector = Origen::Utility::Collector.new
389
- yield collector
390
- options.merge!(collector.store)
391
- end
387
+ options = Origen::Utility.collector(hash: options, merge_method: :keep_hash, &block).to_h
392
388
 
393
389
  # go through the options one by one now and make sure that each element is either an array to be split
394
390
  # by the instances, or is a single object. If not one of these two, complain.
@@ -417,11 +413,7 @@ module Origen
417
413
  end
418
414
  instances
419
415
  else
420
- if block_given?
421
- collector = Origen::Utility::Collector.new
422
- yield collector
423
- options.merge!(collector.store)
424
- end
416
+ options = Origen::Utility.collector(hash: options, merge_method: :keep_hash, &block).to_h
425
417
  { name => options }
426
418
  end
427
419
  end
@@ -443,11 +435,7 @@ module Origen
443
435
  parent: parent
444
436
  }.merge(options)
445
437
 
446
- if block_given?
447
- collector = Origen::Utility::Collector.new
448
- yield collector
449
- options.merge!(collector.store)
450
- end
438
+ options = Origen::Utility.collector(hash: options, merge_method: :keep_hash, &block).to_h
451
439
 
452
440
  # Instantiate the class. This will place the object in the @_componentable_container at the indicated name
453
441
  _instantiate_class(name, options)
@@ -4,6 +4,7 @@ module Origen
4
4
  attr_accessor :top_level
5
5
 
6
6
  def create(options = {}, &block)
7
+ Origen.deprecated 'Origen core will no longer support program generation in v1, add the origen_testers plugin to your application to fix this warning'
7
8
  # Refresh the target to start all settings from scratch each time
8
9
  # This is an easy way to reset all registered values
9
10
  Origen.app.reload_target!
@@ -219,7 +219,7 @@ module Origen
219
219
  def current_mode=(id)
220
220
  @current_mode = id.is_a?(ChipMode) ? id.id : id
221
221
  Origen.app.listeners_for(:on_mode_changed).each do |listener|
222
- listener.on_mode_changed(mode: @current_mode)
222
+ listener.on_mode_changed(mode: @current_mode, instance: self)
223
223
  end
224
224
  @current_mode
225
225
  end
@@ -93,7 +93,7 @@ module Origen
93
93
  if block_given?
94
94
  collector = Origen::Utility::Collector.new
95
95
  yield collector
96
- Origen::Registers.reg_metadata[:global].merge!(collector.store)
96
+ Origen::Registers.reg_metadata[:global].merge!(collector.to_h)
97
97
  end
98
98
  Origen::Registers.reg_metadata[:global]
99
99
  end
@@ -109,7 +109,7 @@ module Origen
109
109
  if block_given?
110
110
  collector = Origen::Utility::Collector.new
111
111
  yield collector
112
- Origen::Registers.bit_metadata[:global].merge!(collector.store)
112
+ Origen::Registers.bit_metadata[:global].merge!(collector.to_h)
113
113
  end
114
114
  Origen::Registers.bit_metadata[:global]
115
115
  end
@@ -424,7 +424,7 @@ module Origen
424
424
  if block_given?
425
425
  collector = Origen::Utility::Collector.new
426
426
  yield collector
427
- Origen::Registers.reg_metadata[self.class].merge!(collector.store)
427
+ Origen::Registers.reg_metadata[self.class].merge!(collector.to_h)
428
428
  end
429
429
  Origen::Registers.reg_metadata[self.class]
430
430
  end
@@ -435,7 +435,7 @@ module Origen
435
435
  if block_given?
436
436
  collector = Origen::Utility::Collector.new
437
437
  yield collector
438
- Origen::Registers.bit_metadata[self.class].merge!(collector.store)
438
+ Origen::Registers.bit_metadata[self.class].merge!(collector.to_h)
439
439
  end
440
440
  Origen::Registers.bit_metadata[self.class]
441
441
  end
@@ -96,5 +96,9 @@ module Origen
96
96
  end
97
97
  end
98
98
  end
99
+
100
+ def self.collector(options = {}, &block)
101
+ Origen::Utility::Collector.new(options, &block)
102
+ end
99
103
  end
100
104
  end
@@ -1,14 +1,78 @@
1
1
  module Origen
2
2
  module Utility
3
3
  class Collector
4
- attr_reader :store
4
+ attr_reader :_hash_
5
+ attr_reader :merge_method
5
6
 
6
- def initialize
7
- @store = {}
7
+ # Need to keep a seperate methods list so we know what's been added by method missing instead of what's
8
+ # been added either by the hash or by method missing.
9
+ # Only overwriting a value in the block should cause an error. Overriding a value from the hash depends on
10
+ # the merge method's setting.
11
+ attr_reader :_methods_
12
+
13
+ def initialize(options = {}, &block)
14
+ @merge_method = options[:merge_method] || :keep_hash
15
+ @fail_on_empty_args = options[:fail_on_empty_args]
16
+ unless [:keep_hash, :keep_block, :fail].include?(@merge_method)
17
+ fail Origen::OrigenError, "Origen::Utility::Collector cannot merge with method :#{@merge_method} (of class #{@merge_method.class}). Known merge methods are :keep_hash (default), :keep_block, or :fail"
18
+ end
19
+
20
+ @_hash_ = options.key?(:hash) ? options[:hash].clone : {}
21
+ @_methods_ = []
22
+
23
+ if block_given?
24
+ yield self
25
+ end
26
+ end
27
+
28
+ # Legacy store method.
29
+ def store
30
+ Origen.log.deprecate 'Collector::store method was used. Please use the Ruby-centric Collector::to_h or Collector::to_hash method instead' \
31
+ " Called from: #{caller[0]}"
32
+ @_hash_
33
+ end
34
+
35
+ def to_hash
36
+ @_hash_
8
37
  end
38
+ alias_method :to_h, :to_hash
9
39
 
10
40
  def method_missing(method, *args, &_block)
11
- @store[method.to_s.sub('=', '').to_sym] = args.first
41
+ key = method.to_s.sub('=', '').to_sym
42
+
43
+ # Check that the arguments are correct
44
+ if block_given? && !args.empty?
45
+ # raise Origen::OrigenError, "Origen::Utility::Collector detected both the hash and block attempting to set :#{key} (merge_method set to :fail)"
46
+ fail ArgumentError, "Origen::Utility::Collector cannot accept both an argument list and block simultaneously for :#{key}. Please use one or the other."
47
+ elsif block_given?
48
+ val = _block
49
+ elsif args.size == 0
50
+ # Set any empty argument to nil
51
+ val = nil
52
+ elsif args.size > 1
53
+ fail ArgumentError, "Origen::Utility::Collector does not allow method :#{key} more than 1 argument. Received 3 arguments."
54
+ else
55
+ val = args.first
56
+ end
57
+
58
+ # Check if we've already added this key via a method
59
+ if _methods_.include?(key)
60
+ fail Origen::OrigenError, "Origen::Utility::Collector does not allow method :#{key} to be set more than a single time. :#{key} is set to #{_hash_[key]}, tried to set it again to #{val}"
61
+ end
62
+
63
+ # indicate that we've seen this method, and decide whether or not to add the new value
64
+ _methods_ << key
65
+
66
+ # Merge the value (or don't, depending on what is set)
67
+ if merge_method == :keep_block || !_hash_.key?(key)
68
+ _hash_[key] = val
69
+ elsif merge_method == :fail
70
+ fail Origen::OrigenError, "Origen::Utility::Collector detected both the hash and block attempting to set :#{key} (merge_method set to :fail)"
71
+ end
72
+ # store[key] = val if !store.key?(key) || (store.key?(key) && merge_method == :keep_block)
73
+
74
+ # Return self instead of the key value to allow for one-line collector statements
75
+ self
12
76
  end
13
77
  end
14
78
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: origen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.33.0
4
+ version: 0.33.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen McGinty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-19 00:00:00.000000000 Z
11
+ date: 2018-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -352,6 +352,20 @@ dependencies:
352
352
  - - "~>"
353
353
  - !ruby/object:Gem::Version
354
354
  version: 0.8.1
355
+ - !ruby/object:Gem::Dependency
356
+ name: nokogiri
357
+ requirement: !ruby/object:Gem::Requirement
358
+ requirements:
359
+ - - ">="
360
+ - !ruby/object:Gem::Version
361
+ version: 1.7.2
362
+ type: :runtime
363
+ prerelease: false
364
+ version_requirements: !ruby/object:Gem::Requirement
365
+ requirements:
366
+ - - ">="
367
+ - !ruby/object:Gem::Version
368
+ version: 1.7.2
355
369
  description:
356
370
  email:
357
371
  - stephen.f.mcginty@gmail.com