// Explicit tagnums int IDLStruct::MakeTagDefs( IDL_VPTR structvptr, vector<IDL_MEMINT>& tagnums, TAG_INFO_STRUCT& taginfo, IDL_STRUCT_TAG_DEF_SAFE& stagdefs) { int status=0; IDL_MEMINT ntags = (IDL_MEMINT) tagnums.size(); // Note last one is null stagdefs.tagdefs.resize(ntags+1); stagdefs.tagdims.resize(ntags); if (M_DEBUG) cout<<endl<<"Making a substruct tag defs vector"<<endl; for (IDL_MEMINT i=0; i < ntags; i++) { IDL_MEMINT tagnum = tagnums[i]; stagdefs.tagdefs[i].name = IDL_StructTagNameByIndex(structvptr->value.s.sdef, tagnum, IDL_MSG_INFO, NULL); if (M_DEBUG) cout<<" Sub Tag: "<<stagdefs.tagdefs[i].name<<endl; stagdefs.tagdefs[i].type = (void *) (( IDL_MEMINT ) taginfo.TagDesc[tagnum]->type); stagdefs.tagdefs[i].flags = 0; // Store actual dims memory in a vector to make memory management // automatic if ((taginfo.TagDesc[tagnum]->flags & IDL_V_ARR) != 0) { IDL_MEMINT n_dim = taginfo.TagDesc[tagnum]->value.arr->n_dim; stagdefs.tagdims[i].dims.resize(n_dim+1); stagdefs.tagdims[i].dims[0] = n_dim; for (IDL_MEMINT j=1; j<n_dim+1; j++) stagdefs.tagdims[i].dims[j] = taginfo.TagDesc[tagnum]->value.arr->dim[j-1]; // Now just set this to point at our vector whose memory is // safe stagdefs.tagdefs[i].dims = &stagdefs.tagdims[i].dims[0]; } } status=1; return(status); }
idl_tag_info *pgsql_get_idl_tag_info(IDL_STRUCT_TAG_DEF *tagdefs) { idl_tag_info *ti; int32 i, tag; char *tagName; ti = (idl_tag_info *) calloc(1, sizeof(idl_tag_info)); ti->sdef = (IDL_StructDefPtr) IDL_MakeStruct(0, tagdefs); /* get offsets and descriptions */ ti->ntags = IDL_StructNumTags(ti->sdef); ti->tagOffsets = calloc(ti->ntags, sizeof(IDL_MEMINT)); ti->tagDesc = calloc(ti->ntags, sizeof(IDL_VPTR)); ti->tagNelts = calloc(ti->ntags, sizeof(int32)); i=0; for (tag=0; tag< ti->ntags; tag++) { tagName = IDL_StructTagNameByIndex(ti->sdef, tag, IDL_MSG_INFO, NULL); ti->tagOffsets[tag] = IDL_StructTagInfoByIndex(ti->sdef, tag, IDL_MSG_LONGJMP, &(ti->tagDesc[tag]) ); if (VERBOSE) printf(" Tag %d = \"%s\" ", tag, tagName); /* Is this an array? */ if ( (ti->tagDesc[tag]->flags & IDL_V_ARR) != 0) { ti->tagNelts[tag] = ti->tagDesc[tag]->value.arr->n_elts; if (VERBOSE) printf(" ARRAY[%d] ", ti->tagNelts[tag]); } else { ti->tagNelts[tag] = 1; if (VERBOSE) printf(" SCALAR "); } if (VERBOSE) printf("\n"); } return(ti); }
int IDLStruct::assign(IDL_VPTR st) { // constructor int i; IDL_VPTR desc; char *struct_name; // point at the idl structure idlStruct = st; n_elements = idlStruct->value.arr->n_elts; num_tags = IDL_StructNumTags(idlStruct->value.s.sdef); // allocate the vectors tag_names.resize(num_tags); tag_offsets.resize(num_tags); tag_desc.resize(num_tags); for(i=0;i<num_tags;i++) { tag_names[i] = IDL_StructTagNameByIndex(idlStruct->value.s.sdef, i, IDL_MSG_LONGJMP, &struct_name); tagIndexHash[tag_names[i]] = i; tagOffsetsHash[tag_names[i]] = IDL_StructTagInfoByIndex(idlStruct->value.s.sdef, i, IDL_MSG_LONGJMP, &desc); tagDescHash[tag_names[i]] = desc; tag_offsets[i] = tagOffsetsHash[tag_names[i]]; tag_desc[i] = desc; } idlStructName = struct_name; //aoffset = // getTagInfoFromIDLStruct(idlStruct, "A", IDL_TYP_FLOAT, // adesc); return(1); }
// // idlpgr_SetProperty // // Write property values to camera // // Reference: FlyCapture2Defs_C.h // void IDL_CDECL idlpgr_SetProperty(int argc, IDL_VPTR argv[]) { fc2Error error; fc2Context context; fc2Property property; char *sname; context = (fc2Context) IDL_ULong64Scalar(argv[0]); IDL_ENSURE_STRUCTURE(argv[1]); IDL_StructTagNameByIndex(argv[1]->value.s.sdef, 0, IDL_MSG_LONGJMP, &sname); if (strcmp(sname, "fc2Property")) IDL_MessageFromBlock(msgs, M_IDLPGR_ERROR, IDL_MSG_LONGJMP, "Argument is not of type fc2Property."); memcpy((char *) &property, (char *) argv[1]->value.s.arr->data, sizeof(fc2Property)); error = fc2SetProperty(context, &property); if (error) IDL_MessageFromBlock(msgs, M_IDLPGR_ERRORCODE, IDL_MSG_LONGJMP, "Could not set requested property", error); }
int IDLStruct::MakeTagInfo( IDL_VPTR structvptr, TAG_INFO_STRUCT& taginfo) { int status=0; if (structvptr->type != IDL_TYP_STRUCT) { IDL_Message(IDL_M_NAMED_GENERIC, IDL_MSG_INFO, "The input variable must be a structure"); return(status); } IDL_STRING *tptr; //------------------------------------------------------------------ // Initialize the tag info structure // structvptr points to the input structdef //------------------------------------------------------------------ taginfo.NumTags = IDL_StructNumTags(structvptr->value.s.sdef); mNtags = taginfo.NumTags; taginfo.TagNames.resize(taginfo.NumTags); taginfo.TagOffsets.resize(taginfo.NumTags); taginfo.TagDesc.resize(taginfo.NumTags); taginfo.TagBytes.resize(taginfo.NumTags); taginfo.TagNelts.resize(taginfo.NumTags); taginfo.BytesPerRow = 0; taginfo.NStrings=0; //--------------------------------------------------------------------------- // Get the tag info //--------------------------------------------------------------------------- for (IDL_MEMINT tag=0; tag<taginfo.NumTags; tag++) { // Get tag name taginfo.TagNames[tag] = IDL_StructTagNameByIndex(structvptr->value.s.sdef, tag, IDL_MSG_INFO, NULL); taginfo.TagMap[taginfo.TagNames[tag]] = tag; // Get tag offsets and the tag description variable (a copy?) taginfo.TagOffsets[tag] = IDL_StructTagInfoByIndex(structvptr->value.s.sdef, tag, IDL_MSG_LONGJMP, &(taginfo.TagDesc[tag]) ); if (M_DEBUG) { cout <<" Tag "<<tag<<" = "<<taginfo.TagNames[tag].c_str(); cout <<" TagMap[\"" << taginfo.TagNames[tag] << "\"] = " << taginfo.TagMap[ taginfo.TagNames[tag] ] << endl; } // Deal with arrays if ( (taginfo.TagDesc[tag]->flags & IDL_V_ARR) != 0) { // this is just for convenience taginfo.TagNelts[tag] = taginfo.TagDesc[tag]->value.arr->n_elts; if (M_DEBUG) cout<<" ARRAY["<<taginfo.TagNelts[tag]<<"] "; } else { taginfo.TagNelts[tag] = 1; if (M_DEBUG) cout<<" SCALAR "; } // Number of bytes for this variable type. if (taginfo.TagDesc[tag]->type == IDL_TYP_STRING) { // WARNING: This assumes that the elements in string arrays are all // the same size tptr = (IDL_STRING *) (structvptr->value.s.arr->data + taginfo.TagOffsets[tag]); taginfo.TagBytes[tag] = tptr->slen; taginfo.NStrings++; } else taginfo.TagBytes[tag] = IDLTypeNbytes(taginfo.TagDesc[tag]->type); // Bytes in each row taginfo.BytesPerRow += taginfo.TagBytes[tag]*taginfo.TagNelts[tag]; if (M_DEBUG) { PrintIdlType(taginfo.TagDesc[tag]->type); cout<<" "<<taginfo.TagBytes[tag]<<" bytes"; } if (M_DEBUG) cout<<endl; } // Add the tag defs for use creating a new struct or substruct MakeTagDefs(structvptr, taginfo, taginfo.stagdefs); status=1; return(status); }