⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 createobj.m

📁 这是一个关于MATLAB的函数
💻 M
📖 第 1 页 / 共 2 页
字号:
function symtab = createobj(cc,sname,opt)
% CREATEOBJ Creates a link to an embedded symbol.
% 	O = CREATEOBJ(CC,SYMBOL) - returns an object handle O to the embedded symbol SYMBOL. 
% 	SYMBOL can be any variable name. By default, the embedded variable within scope is created.
% 	
% 	O = CREATEOBJ(CC,SYMBOL,OPT) - returns an object handle O to the embedded symbol SYMBOL, 
% 	the scope of which is specified by OPT. OPT can be 'local', 'global' or 'static'.
% 	
% 	Depending on the type and storage device of the symbol, object O created can be fall on any 
% 	of four major object classes:
% 	
% 	I.  MEMORYOBJ
%         Any symbol that resides in the DSP memory.
%         
%         Derived Classes:
% 		1.  NUMERIC class       -       handle to a primitive datatype (float,int,short,...)
%             
%           Derived Classes:
% 			a.  POINTER class   -       handle to a pointer datatype (unsigned int)
% 			b.  ENUM class      -       handle to an enumerated datatype (int)
% 			c.  STRING class    -       handle to a string datatype (char)
%             
% 		2.  BITFIELD class      -       handle to a bitfield datatype
% 	
% 	II. REGISTEROBJ
%         Any symbol that resides in a DSP register.
%         
%         Derived Class
% 		  RNUMERIC class        -       handle to a primitive datatype (float,int,short,...)
%             
%           Derived Classes:
% 			a.  RPOINTER class  -       handle to a pointer datatype (unsigned int)
% 			b.  RENUM class     -       handle to an enumerated datatype (int)
% 			c.  RSTRING class   -       handle to a string datatype (char)
%             
% 	III.STRUCTURE
% 		Container class for MEMORYOBJ and/or REGISTEROBJ objects.
%         - C struct type
%         - C union type.
% 	
% 	See LIST.

% Copyright 2002 The MathWorks, Inc.
% $Revision: 1.19 $ $Date: 2002/05/20 19:10:37 $

error(nargchk(1,3,nargin));
if ~ishandle(cc),
    error('First Parameter must be a CCSDSP Handle.');
end
if ~ischar(sname) & ~isstruct(sname)
	error('Second Parameter must be a string');
end

if nargin==2 & isstruct(sname) % Private use.
	% SNAME is a structure for creating an object. 
	% Used for dereferencing pointers, on @function/createinput, on @function/createoutput 
else
	% Used for creating objects from symbol name
    if nargin==2 | (nargin==3 & strcmpi(opt,'local')),
        si = list(cc,'variable',sname);
    elseif nargin==3 & strmatch(opt,{'global','static'}),
        si = list(cc,'globalvar',sname);
    end
    sname = char( fieldnames(si) );
    sname = si.(sname); % set structure info to SNAME
end

% If symbol is a structure, check if it is recursive (pts to itself)
sname  = checkIfRecursivePointer(sname);
% Create object from info - sname
symtab = dispatch(cc,sname);

% ----------------------------------------------------------------------------
function symtab = dispatch(cc,si),

% Check if UDD class is valid/supported
uci = strmatch(si.uclass,{  
        'numeric'   ,'pointer'   ,'enum'   ,'bitfield'  ,'string'  , ...
        'rnumeric'  ,'rpointer'  ,'renum'  ,'rbitfield' ,'rstring' , ...
        'structure' ,'union'     , ...
        'function'  , ...
        'reference'   ...
        }, 'exact');

if uci==13, % function
    error('Unsupported class : Function ');
end
if isempty(uci),
    warning(['Unsupported symbol type: ' si.uclass ]);
    symtab = [];
    return;
end

% Add more info to SI
si       = SetEmptyName(si);
[uci,si] = CheckIfChar(uci,si);
[si,bitspersu,r_bitspersu,storeunitperval] = SetProcSpecificValues(cc.subfamily,si);
si       = SetEndianValue(info(cc),si);

% Call constructor
switch uci
   
% MEMORY OBJECTS -------------------------------------------------

case 1,  % numeric (->memoryobj)
    % if strcmpi( si.type,    % by default, treat char as C strings.
    symtab = ccs.numeric(  'name'               ,si.name, ...
                           'address'            ,si.address, ...
                           'size'               ,si.size, ...  
                           'bitsperstorageunit' ,bitspersu, ...  
                           'endianness'         ,si.dspendian, ...  
                           'timeout'            ,cc.timeout, ...  
                           'procsubfamily'      ,si.procsubfamily, ...
                           'link'               ,cc);
    symtab.convert(si.type);
    
case 2,  % pointer (->numeric->memoryobj)
    symtab = ccs.pointer(  'name'                   ,si.name, ...
                           'address'                ,si.address, ...
                           'size'                   ,si.size, ...  
                           'bitsperstorageunit'     ,bitspersu, ...  
                           'endianness'             ,si.dspendian, ...  
                           'timeout'                ,cc.timeout, ...  
                           'procsubfamily'          ,si.procsubfamily, ...
                           'storageunitspervalue'   ,storeunitperval, ...       
                           'reftype'                ,si.type, ...
                           'isrecursive'            ,si.member_pts_to_same_struct, ...
                           'referent'               ,si.referent, ...
                           'link'                   ,cc);
    
case 3,  % enumerated type (->numeric->memoryobj)
    symtab = ccs.enum(    'name'                ,si.name, ...
                          'label'               ,si.label, ...
						  'value'               ,si.value, ...
						  'address'             ,si.address, ...  
						  'size'                ,si.size, ...  
						  'bitsperstorageunit'  ,bitspersu, ...  
						  'endianness'          ,si.dspendian, ...  
                          'procsubfamily'       ,si.procsubfamily, ...
						  'timeout'             ,cc.timeout, ...
						  'link'                ,cc);
  
case 4,  % bitfield (-> memoryobj)
    symtab = ccs.bitfield( 'name'               ,si.name, ...
                           'address'            ,si.address, ... 
                           'endianness'         ,si.dspendian, ...
                           'location'           ,si.bitinfo, ...
                           'size'               ,1, ...
                           'procsubfamily'      ,si.procsubfamily, ...
                           'timeout'            ,cc.timeout, ...
                           'link'               ,cc);
	convert(symtab,si.type);

case 5,  % string (-> numeric -> memoryobj )
    symtab = ccs.string(  'name'                ,si.name, ...
						  'address'             ,si.address, ...
						  'size'                ,si.size, ...  
						  'bitsperstorageunit'  ,bitspersu, ...  
						  'endianness'          ,si.dspendian, ...  
                          'procsubfamily'       ,si.procsubfamily, ...
						  'timeout'             ,cc.timeout, ...
						  'link'                ,cc);

% REGISTER OBJECTS -------------------------------------------------

case 6, % rnumeric (->registerobj)
    symtab = ccs.rnumeric( ...
                           'link'               ,cc, ...
                           'name'               ,si.name, ...
                           'reginfo'            ,si.location, ...
                           'size'               ,si.size, ...  
                           'bitsperstorageunit' ,r_bitspersu, ...  
                           'endianness'         ,si.dspendian, ...  
                           'timeout'            ,cc.timeout, ...  
                           'procsubfamily'      ,si.procsubfamily ...
                       );

    symtab.convert(si.type);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -