ARSperl

 view release on metacpan or  search on metacpan

StructDef.pl  view on Meta::CPAN

#	type => {
#		_type => 'unsigned int',
#		_data => 'p->type',
#	},
#
#	_switch => 'p->reference.dataType',
#	_map => 'dataType',
#	_case => {
#		ARREF_DATA_ARSREF => {
#			'name' => {
#				_type => 'ARNameType',
#				_data => 'p->reference.u.name',
#			},
#		},
#		ARREF_DATA_EXTREF => {
#			'extRef' => {
#				_type => 'ARExtReferenceStruct',
#				_data => 'p->reference.u.extRef',
#			},
#		},
#	},
#},
#ARExtReferenceStruct => {
#	permittedGroups => {
#		_type => 'ARInternalIdList',
#		_data => 'p->permittedGroups',
#	},
#	value => {
#		_type => 'ARValueStruct',
#		_data => 'p->value',
#	},
#},


# Structures from "ardbc.h":
#ARVendorFieldList => {
#	_num  => 'p->numItems',
#	_list => 'p->fieldList',
#	_type => 'ARVendorFieldStruct',
#},
#ARVendorFieldStruct => {
#	fieldName => {
#		_type => 'ARNameType',
#		_data => 'p->fieldName',
#	},
#	fieldId => {
#		_type => 'ARInternalId',
#		_data => 'p->fieldId',
#	},
#	dataType => {
#		_type => 'int',
#		_data => 'p->dataType',
#	},
#},


);



# perl C:\usr\perl_install\5.8.8\ARSperl\TS\printStructTemplate.pl AR...
#
#	x => {
#		_type => '',
#		_data => '',
#	},

# s/.*/$& => {\n\t_type => '',\n\t_data => 'p->u.',\n},/


%TEMPLATES = (
	_copy => [
		'ARValueStruct'   => 'rev_%T( ctrl, h, k, "dataType", &(%L) )',
		'ARValueStruct\*' => '%L = MALLOCNN(sizeof(%B)); rev_%B( ctrl, h, k, "dataType", %L )',
		'AR\w+'   => 'rev_%T( ctrl, h, k, &(%L) )',
		'AR\w+\*' => '%L = MALLOCNN(sizeof(%B)); rev_%B( ctrl, h, k, %L )',
		'(int|long|unsigned\s+int|unsigned\s+long)' => '%L = SvIV(%R)',
		'(float|double)'                            => '%L = SvNV(%R)',
		'unsigned\s+char'                           => '%L = (char) SvIV(%R)',
		'char\s*\*' => '%L = strdup( SvPV_nolen(%R) )',
		'char\[.+]' => 'strncpy( %L, SvPV_nolen(%R), sizeof(%L) )',
		'ARInternalId\[(\w+)\]' => 'copyUIntArray( %1, %L, %R )',
		'int\[(\w+)\]'          => 'copyIntArray( %1, %L, %R )',
	],
	_perl => [
		'ARInternalId\[\]'     => '*** unknown ***',     # ???
		'ARInternalId\[\w+\]'  => '*** unknown ***',     # ???
		'int\[\w+\]'           => '*** unknown ***',     # ???
		'unsigned\s+char'      => '%L = newSVnv( %R )',  # ???
		
		'AR\w+'   => '%L = perl_%T( ctrl, &(%R) )',
		'AR\w+\*' => '%L = perl_%B( ctrl, %R )',
		'(int|long|unsigned\s+int|unsigned\s+long)' => '%L = newSViv( %R )',
		'(float|double)'                            => '%L = newSVnv( %R )',
		'char\s*\*' => '%L = newSVpv( %R, 0 )',
		'char\[.+]' => '%L = newSVpv( %R, 0 )',
	],
);



#print evalTemplate( 'COPY', 'char[10]', 'p->charVal', 'buffer' ), "\n";
#print evalTemplate( 'COPY', 'unsigned char', 'p->unique', 'buffer' ), "\n";


#ARIntegerLimitsStruct intLimits;
#ARRealLimitsStruct    realLimits;
#ARCharLimitsStruct    charLimits;
#ARDiaryLimitsStruct   diaryLimits;
#AREnumLimitsStruct    enumLimits;
#AREnumLimitsStruct    maskLimits;
#ARAttachLimitsStruct  attachLimits;
#ARTableLimitsStruct   tableLimits;
#ARColumnLimitsStruct  columnLimits;
#ARDecimalLimitsStruct decimalLimits;
#ARViewLimits          viewLimits;
#ARDisplayLimits       displayLimits;
#ARDateLimitsStruct    dateLimits;
#ARCurrencyLimitsStruct currencyLimits;





( run in 0.485 second using v1.01-cache-2.11-cpan-d8267643d1d )