Ejemplo n.º 1
0
  void BasicArrayFS<T, ARRAY_TYPE>::copyToArray(
    size_t uiStart,
    size_t uiEnd,
    T* destArray,
    size_t uiDestOffset) const {
      checkValidity(UIMA_MSG_ID_EXCON_GETTING_FS_FROM_ARRAY);
      checkArraySize(iv_tyFS, iv_cas->getHeap(), uiEnd - uiStart - 1 , UIMA_MSG_ID_EXCON_GETTING_FS_FROM_ARRAY);
      uima::lowlevel::TyFSType typecode = iv_cas->getHeap()->getType(iv_tyFS);

	  size_t srcOffset = uiStart;
	  size_t numelements = uiEnd-uiStart;
	  size_t destOffset = uiDestOffset;

	  if (typecode== uima::internal::gs_tyIntArrayType || 
		  typecode== uima::internal::gs_tyFloatArrayType   ) {
			  iv_cas->getHeap()->copyToArray( srcOffset,iv_tyFS,(uima::lowlevel::TyHeapCell*) destArray,destOffset,numelements);
	  } else if(typecode== uima::internal::gs_tyByteArrayType || 
		        typecode== uima::internal::gs_tyBooleanArrayType) {
		  iv_cas->getHeap()->copyToArray( srcOffset,iv_tyFS,(char*) destArray,destOffset,numelements);
	  } else if(typecode== uima::internal::gs_tyShortArrayType ) {
		  iv_cas->getHeap()->copyToArray( srcOffset,iv_tyFS,(short*) destArray,destOffset,numelements);
      } else if(typecode== uima::internal::gs_tyLongArrayType || 
		        typecode== uima::internal::gs_tyDoubleArrayType) {
		  iv_cas->getHeap()->copyToArray( srcOffset,iv_tyFS,(INT64*) destArray,destOffset,numelements);
      } else {
      assertWithMsg(false, "Not yet implemented");
      UIMA_EXC_THROW_NEW(NotYetImplementedException,
                 UIMA_ERR_NOT_YET_IMPLEMENTED,
                 UIMA_MSG_ID_EXC_NOT_YET_IMPLEMENTED,
                 ErrorMessage(UIMA_MSG_ID_EXCON_UNKNOWN_CONTEXT),
                 ErrorInfo::unrecoverable
                );
      }
  }
Ejemplo n.º 2
0
static orl_return       addToSymbolTable( omf_file_handle ofh, omf_symbol_handle sym )
{
    omf_sec_handle      sh;

    assert( ofh );
    assert( sym );

    sh = ofh->symbol_table;
    if( !sh ) {
        sh = newSection( ofh, OMF_SEC_SYM_TABLE_INDEX, ORL_SEC_TYPE_SYM_TABLE );
        if( !sh )
            return( ORL_OUT_OF_MEMORY );
        ofh->symbol_table = sh;
        sh->flags |= ORL_SEC_FLAG_REMOVE;
        sh->assoc.sym.hash_tab = ORLHashTableCreate( ofh->omf_hnd->funcs, 257, ORL_HASH_STRING, (orl_hash_comparison_func)stricmp );
        if( !sh->assoc.sym.hash_tab ) {
            return( ORL_OUT_OF_MEMORY );
        }
    }
    assert( sh->assoc.sym.hash_tab );

    sh->assoc.sym.syms = checkArraySize( ofh, sh->assoc.sym.syms,
                                         sh->assoc.sym.num, STD_INC,
                                         sizeof( omf_symbol_handle ) );
    if( !sh->assoc.sym.syms )
        return( ORL_OUT_OF_MEMORY );

    sh->assoc.sym.syms[sh->assoc.sym.num] = sym;
    sh->assoc.sym.num++;
    return( ORLHashTableInsert( sh->assoc.sym.hash_tab, sym->name.string, sym ) );
}
Ejemplo n.º 3
0
static orl_return       addReloc( omf_file_handle ofh, omf_reloc_handle orh )
{
    omf_sec_handle      sh;

    assert( ofh );
    assert( orh );

    if( !ofh->relocs ) {
        ofh->relocs = newSection( ofh, OMF_SEC_RELOC_INDEX, ORL_SEC_TYPE_RELOCS );
        if( !ofh->relocs )
            return( ORL_OUT_OF_MEMORY );
        ofh->relocs->flags |= ORL_SEC_FLAG_REMOVE;
    }

    sh = ofh->relocs;
    sh->assoc.reloc.relocs = checkArraySize( ofh, sh->assoc.reloc.relocs,
                                             sh->assoc.reloc.num, STD_INC,
                                             sizeof( omf_reloc_handle ) );
    if( !sh->assoc.reloc.relocs )
        return( ORL_OUT_OF_MEMORY );

    sh->assoc.reloc.relocs[sh->assoc.reloc.num] = orh;
    sh->assoc.reloc.num++;

    return( ORL_OKAY );
}
Ejemplo n.º 4
0
static orl_return       addString( omf_sec_handle sh, char *buffer, omf_string_len len )
{
    omf_string_struct   *str;
    omf_file_handle     ofh;

    assert( sh );
    assert( buffer );

    ofh = sh->omf_file_hnd;

    /* Check if we need to allocate more string table
     */
    sh->assoc.string.strings = checkArraySize( ofh, sh->assoc.string.strings,
                                               sh->assoc.string.num, STD_INC,
                                               sizeof( omf_string_struct * ) );
    if( !sh->assoc.string.strings )
        return( ORL_OUT_OF_MEMORY );

    str = _ClientAlloc( ofh, sizeof( omf_string_struct ) + len );
    if( str == NULL )
        return( ORL_OUT_OF_MEMORY );

    memset( str, 0, sizeof( omf_string_struct ) + len );
    memcpy( str->string, buffer, len );
    str->string[len] = '\0';
    str->len = len;

    sh->assoc.string.strings[sh->assoc.string.num] = str;
    sh->assoc.string.num++;
    return( ORL_OKAY );
}
Ejemplo n.º 5
0
  void BasicArrayFS<T, ARRAY_TYPE>::set(size_t n, T const & val) {
    checkValidity(UIMA_MSG_ID_EXCON_GETTING_FS_FROM_ARRAY);
    checkArraySize(iv_tyFS, iv_cas->getHeap(), n, UIMA_MSG_ID_EXCON_GETTING_FS_FROM_ARRAY);
    uima::lowlevel::TyFSType typecode = iv_cas->getHeap()->getType(iv_tyFS);
    if (typecode == uima::internal::gs_tyIntArrayType ||
        typecode == uima::internal::gs_tyFloatArrayType  ||
        typecode == uima::internal::gs_tyStringArrayType ||
        typecode == uima::internal::gs_tyFSArrayType) {
      lowlevel::TyHeapCell* pArray = iv_cas->getHeap()->getCArrayFromFS(iv_tyFS);
      uima::lowlevel::TyHeapCell result = uima::internal::toHeapCellTempl(val, *iv_cas->getHeap(),0);
      pArray[n] = result;
    } else {
      size_t pos = iv_cas->getHeap()->getArrayOffset(iv_tyFS) + n;
      uima::lowlevel::TyHeapCell result = uima::internal::toHeapCellTempl(val, *iv_cas->getHeap(),pos);
    }

  }
Ejemplo n.º 6
0
 T BasicArrayFS<T, ARRAY_TYPE>::get(size_t n) const {
     checkValidity(UIMA_MSG_ID_EXCON_GETTING_FS_FROM_ARRAY);
     checkArraySize(iv_tyFS, iv_cas->getHeap(), n, UIMA_MSG_ID_EXCON_GETTING_FS_FROM_ARRAY);
     uima::lowlevel::TyFSType typecode = iv_cas->getHeap()->getType(iv_tyFS);
     T result;
     if (typecode == uima::internal::gs_tyIntArrayType ||
         typecode == uima::internal::gs_tyFloatArrayType  ||
         typecode == uima::internal::gs_tyStringArrayType ||
         typecode == uima::internal::gs_tyFSArrayType) {
       lowlevel::TyHeapCell* pArray = iv_cas->getHeap()->getCArrayFromFS(iv_tyFS);
       uima::internal::fromHeapCellTempl(pArray[n], *iv_cas, result );
     } else {
       size_t pos = iv_cas->getHeap()->getArrayOffset(iv_tyFS) + n;
       uima::internal::fromHeapCellTempl(pos, *iv_cas, result );
     }
     return result;
   }
Ejemplo n.º 7
0
static omf_sec_handle   newSegSection( omf_file_handle ofh, orl_sec_type typ )
{
    omf_sec_handle      sh;

    assert( ofh );

    ofh->segs = checkArraySize( ofh, ofh->segs, ofh->num_segs, STD_INC,
                                sizeof( omf_sec_handle ) );
    if( !ofh->segs ) return( NULL );

    sh = newSection( ofh, OMF_SEC_NEXT_AVAILABLE, typ );
    if( !sh ) return( sh );

    ofh->segs[ofh->num_segs] = sh;
    ofh->num_segs++;
    sh->assoc.seg.seg_id = ofh->num_segs;

    return( sh );
}
Ejemplo n.º 8
0
static omf_sec_handle   newComDatSection( omf_file_handle ofh )
{
    omf_sec_handle      sh;

    assert( ofh );

    ofh->comdats = checkArraySize( ofh, ofh->comdats, ofh->num_comdats, STD_INC,
                                sizeof( omf_sec_handle ) );
    if( !ofh->comdats ) return( NULL );

    sh = newSection( ofh, OMF_SEC_NEXT_AVAILABLE, ORL_SEC_TYPE_PROG_BITS );
    if( !sh ) return( sh );

    ofh->comdats[ofh->num_comdats] = sh;
    ofh->num_comdats++;
    sh->assoc.seg.seg_id = ofh->num_comdats;

    return( sh );
}
Ejemplo n.º 9
0
static omf_grp_handle   newGroup( omf_file_handle ofh )
{
    omf_grp_handle      gr;

    assert( ofh );

    ofh->groups = checkArraySize( ofh, ofh->groups, ofh->num_groups, STD_INC,
                                sizeof( omf_grp_handle ) );
    if( !ofh->groups ) return( NULL );

    gr = _ClientAlloc( ofh, sizeof( omf_grp_handle_struct ) );
    if( !gr ) return( gr );
    memset( gr, 0, sizeof( omf_grp_handle_struct ) );

    ofh->groups[ofh->num_groups] = gr;
    ofh->num_groups++;
    gr->id = ofh->num_groups;
    gr->file_format = ORL_OMF;
    gr->omf_file_hnd = ofh;

    return( gr );
}
Ejemplo n.º 10
0
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER


PreviewImage::PreviewImage (unsigned int width,
			    unsigned int height,
			    const PreviewRgba pixels[])
{
    _width = width;
    _height = height;
    _pixels = new PreviewRgba
        [checkArraySize (uiMult (_width, _height), sizeof (PreviewRgba))];

    if (pixels)
    {
	for (unsigned int i = 0; i < _width * _height; ++i)
	    _pixels[i] = pixels[i];
    }
    else
    {
	for (unsigned int i = 0; i < _width * _height; ++i)
	    _pixels[i] = PreviewRgba();
    }
}