Class: CType::Pointer

Inherits:
Object
  • Object
show all
Includes:
BaseReference, Qualifiers
Defined in:
lib/dbc/ctype.rb

Overview

Base

Instance Attribute Summary

Attributes included from BaseReference

#base_type

Instance Method Summary collapse

Methods included from Qualifiers

#add_qualifier

Constructor Details

#initialize(type_qualifiers = []) ⇒ Pointer

Returns a new instance of Pointer.



349
350
351
352
353
354
355
356
# File 'lib/dbc/ctype.rb', line 349

def initialize(type_qualifiers=[])
	@const = false
	@volatile = false
	@base_type = nil
	type_qualifiers.each do |q|
		add_qualifier(q)
	end # do
end

Instance Method Details

#evaluate(identifier) ⇒ Object



358
359
360
361
362
363
364
365
366
367
# File 'lib/dbc/ctype.rb', line 358

def evaluate(identifier)
	return self if identifier.empty?
	if identifier =~ /\A->/
		self.base_type.evaluate('.' + $')
	elsif identifier =~ /\A\[.+?\]/
		self.base_type.evaluate($')
	else
		CType.evaluation_error(identifier)
	end
end

#to_init_s(ident = nil) ⇒ Object



372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# File 'lib/dbc/ctype.rb', line 372

def to_init_s(ident=nil)
	str = '*'
	str << ' const' if @const
	str << ' volatile' if @volatile
	str << ' ' << ident if ident
	if @base_type.class == Type and (@base_type.function? or @base_type.array?)
		# then parens are required
		str[0,0] = '('
		str << ')'
	end
	if @base_type
		@base_type.to_init_s(str)
	else
		str
	end
end

#to_sObject



369
370
371
# File 'lib/dbc/ctype.rb', line 369

def to_s
	to_init_s()
end