Beispiel #1
0
static PHB_ITEM hbamf_cls_externalizable_instance( PHB_ITEM pClassFuncStr )
{
   PHB_DYNS pSymbol = hb_dynsymGet( hb_itemGetCPtr( pClassFuncStr ) );

   if( pSymbol )
   {
      PHB_ITEM pRetCopy = hb_itemNew( NULL );
      PHB_ITEM pNewItem = hb_itemNew( NULL );
      hb_itemMove( pRetCopy, hb_stackReturnItem() );

      hb_vmPushDynSym( pSymbol );
      hb_vmPushNil();
      hb_vmDo( 0 );

      hb_objSendMsg( hb_stackReturnItem(), "NEW", 0 );

      hb_itemMove( pNewItem, hb_stackReturnItem() );
      hb_itemMove( hb_stackReturnItem(), pRetCopy );

      hb_itemRelease( pRetCopy );

      if( pNewItem )
      {
         if( ! HB_IS_OBJECT( pNewItem ) )
         {
            hb_itemRelease( pNewItem );
            pNewItem = NULL;
         }
      }

      return pNewItem;
   }

   return NULL;
}
Beispiel #2
0
HB_BOOL hbamf_is_cls_externalizable( HB_USHORT uiClass )
{
    PHB_DYNS pSymbol = hb_dynsymGet( "__CLSMSGTYPE" );
    HB_BOOL  result  = HB_FALSE;

    /* as far as i know, there is no exported Harbour C level api for this */

    if( uiClass && pSymbol )
    {
        PHB_ITEM pRetCopy = hb_itemNew( NULL );

        hb_itemMove( pRetCopy, hb_stackReturnItem() );

        hb_vmPushDynSym( pSymbol );
        hb_vmPushNil();
        hb_vmPushInteger( uiClass );
        hb_vmPushString( "EXTERNALIZABLE", 14 );
        hb_vmDo( 2 );

        if( hb_itemGetNI( hb_stackReturnItem() ) == HB_OO_MSG_CLASSDATA )
            result = HB_TRUE;

        hb_itemMove( hb_stackReturnItem(), pRetCopy );
        hb_itemRelease( pRetCopy );
    }

    return result;
}
Beispiel #3
0
static PHB_FILE s_fileOpen( PHB_FILE_FUNCS pFuncs, const char * pszName,
                            const char * pszDefExt, HB_USHORT uiExFlags,
                            const char * pPaths, PHB_ITEM pError )
{
   PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs;
   PHB_FILE pFile = NULL;
   PHB_ITEM pFileItm;

   s_pushMethod( pIO, IOUSR_OPEN );
   hb_vmPushString( pszName, strlen( pszName ) );
   if( pszDefExt )
      hb_vmPushString( pszDefExt, strlen( pszDefExt ) );
   else
      hb_vmPushNil();
   hb_vmPushInteger( uiExFlags );
   if( pPaths )
      hb_vmPushString( pPaths, strlen( pPaths ) );
   else
      hb_vmPushNil();
   if( pError )
      hb_vmPush( pError );
   else
      hb_vmPushNil();

   hb_vmDo( 5 );

   pFileItm = hb_stackReturnItem();
   if( ! HB_IS_NIL( pFileItm ) )
      pFile = s_fileNew( pIO, hb_itemNew( pFileItm ) );

   return pFile;
}
Beispiel #4
0
static void hb_hrbDo( PHRB_BODY pHrbBody, int iPCount, PHB_ITEM * pParams )
{
   PHB_ITEM pRetVal = NULL;
   int i;

   hb_hrbInit( pHrbBody, iPCount, pParams );

   /* May not have a startup symbol, if first symbol was an INIT Symbol (was executed already). */
   if( pHrbBody->lSymStart >= 0 && hb_vmRequestQuery() == 0 )
   {
      hb_vmPushSymbol( &pHrbBody->pSymRead[ pHrbBody->lSymStart ] );
      hb_vmPushNil();

      for( i = 0; i < iPCount; i++ )
         hb_vmPush( pParams[ i ] );

      hb_vmProc( ( HB_USHORT ) iPCount );

      pRetVal = hb_itemNew( NULL );
      hb_itemMove( pRetVal, hb_stackReturnItem() );
   }

   if( pRetVal )
      hb_itemReturnRelease( pRetVal );
}
Beispiel #5
0
PHB_ITEM hb_itemDoC( const char * szFunc, HB_ULONG ulPCount, ... )
{
   PHB_ITEM pResult = NULL;

   HB_TRACE( HB_TR_DEBUG, ( "hb_itemDoC(%s, %lu, ...)", szFunc, ulPCount ) );

   if( szFunc )
   {
      PHB_DYNS pDynSym = hb_dynsymFindName( szFunc );

      if( pDynSym )
      {
         if( hb_vmRequestReenter() )
         {
            hb_vmPushSymbol( pDynSym->pSymbol );
            hb_vmPushNil();
            if( ulPCount )
            {
               HB_ULONG ulParam;
               va_list va;
               va_start( va, ulPCount );
               for( ulParam = 1; ulParam <= ulPCount; ulParam++ )
                  hb_vmPush( va_arg( va, PHB_ITEM ) );
               va_end( va );
            }
            hb_vmProc( ( HB_USHORT ) ulPCount );
            pResult = hb_itemNew( hb_stackReturnItem() );
            hb_vmRequestRestore();
         }
      }
   }

   return pResult;
}
Beispiel #6
0
void
hbgi_hb_itemReturnRelease(PHB_ITEM pItem)
{
   if (pItem != hb_stackReturnItem())
   {
      hb_itemReturnRelease(pItem);
   }
}
Beispiel #7
0
static PHB_ITEM s_fileDirectory( PHB_FILE_FUNCS pFuncs, const char * pszDirSpec, const char * pszAttr )
{
   PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs;

   s_pushMethod( pIO, IOUSR_DIRECTORY );
   hb_vmPushString( pszDirSpec, strlen( pszDirSpec ) );
   hb_vmPushString( pszAttr, strlen( pszAttr ) );
   hb_vmDo( 2 );

   return hb_itemNew( hb_stackReturnItem() );
}
Beispiel #8
0
void hb_errInit( void )
{
   HB_TRACE( HB_TR_DEBUG, ( "hb_errInit()" ) );

   /* error function */
   hb_dynsymNew( &s_symErrorNew );

   /* Create error class and base object */
   s_pError = hb_itemNew( NULL );
   hb_clsAssociate( hb_errClassCreate() );
   hb_itemMove( s_pError, hb_stackReturnItem() );
}
Beispiel #9
0
PHB_ITEM hb_evalLaunch( PHB_EVALINFO pEvalInfo )
{
   PHB_ITEM pResult = NULL;

   HB_TRACE( HB_TR_DEBUG, ( "hb_evalLaunch(%p)", pEvalInfo ) );

   if( pEvalInfo )
   {
      PHB_ITEM pItem = pEvalInfo->pItems[ 0 ];
      PHB_SYMB pSymbol = NULL;

      if( HB_IS_STRING( pItem ) )
      {
         PHB_DYNS pDynSym = hb_dynsymFindName( pItem->item.asString.value );

         if( pDynSym )
         {
            pSymbol = pDynSym->pSymbol;
            pItem = NULL;
         }
      }
      else if( HB_IS_SYMBOL( pItem ) )
      {
         pSymbol = pItem->item.asSymbol.value;
         pItem = NULL;
      }
      else if( HB_IS_BLOCK( pItem ) )
      {
         pSymbol = &hb_symEval;
      }

      if( pSymbol )
      {
         HB_USHORT uiParam = 0;

         hb_vmPushSymbol( pSymbol );
         if( pItem )
            hb_vmPush( pItem );
         else
            hb_vmPushNil();
         while( uiParam < pEvalInfo->paramCount )
            hb_vmPush( pEvalInfo->pItems[ ++uiParam ] );
         if( pItem )
            hb_vmSend( uiParam );
         else
            hb_vmProc( uiParam );
         pResult = hb_itemNew( hb_stackReturnItem() );
      }
   }

   return pResult;
}
Beispiel #10
0
static HRESULT STDMETHODCALLTYPE classCreateInstance( IClassFactory * lpThis,
                                                      IUnknown * punkOuter,
                                                      REFIID riid,
                                                      void ** ppvObj )
{
   HRESULT hr;

   HB_SYMBOL_UNUSED( lpThis );

   *ppvObj = NULL;

   if( punkOuter )
      hr = CLASS_E_NOAGGREGATION;
   else
   {
      PHB_ITEM pAction = NULL;
      HB_BOOL fGuids = HB_FALSE;

      if( s_pAction )
      {
         if( HB_IS_EVALITEM( s_pAction ) )
         {
            if( hb_vmRequestReenter() )
            {
               hb_vmPushEvalSym();
               hb_vmPush( s_pAction );
               hb_vmProc( 0 );
               pAction = hb_itemNew( hb_stackReturnItem() );
               hb_vmRequestRestore();
            }
         }
         else if( HB_IS_HASH( s_pAction ) )
         {
            if( s_fHashClone )
               pAction = hb_itemClone( s_pAction );
            else if( ! s_pMsgHash && s_hashWithNumKeys( s_pAction ) )
               fGuids = HB_TRUE;
         }
      }
      hr = s_createHbOleObject( riid, ppvObj, pAction, fGuids );
   }
   return hr;
}
Beispiel #11
0
HB_USHORT
hbgi_hb_clsNew(const char *szClassName, int nDatas, PHB_ITEM pSuperArray)
{
   if (!s_pDyns__CLSNEW) {
      hbgihb_init(NULL);
   }
   hb_vmPushDynSym(s_pDyns__CLSNEW);
   hb_vmPushNil();
   hb_vmPushString(szClassName, strlen(szClassName));
   hb_vmPushNumInt(nDatas);
   if (!pSuperArray)
   {
      hb_vmPushNil();
   }
   else
   {
      hb_vmPush(pSuperArray);
   }
   hb_vmProc(3);
   return hb_itemGetNI(hb_stackReturnItem());
}
Beispiel #12
0
void hb_cairo_ret( cairo_t * pCairo )
{
   hb_cairoItemPut( hb_stackReturnItem(), pCairo );
}
Beispiel #13
0
void hb_cairo_path_ret( cairo_path_t * pPath )
{
   hb_cairoPathItemPut( hb_stackReturnItem(), pPath );
}
Beispiel #14
0
void hb_cairo_surface_ret( cairo_surface_t * pSurface )
{
   hb_cairoSurfaceItemPut( hb_stackReturnItem(), pSurface );
}
Beispiel #15
0
PHB_ITEM
hbgi_hb_clsInst(HB_USHORT uiClass)
{
   hb_clsAssociate(uiClass);
   return hb_stackReturnItem();
}
Beispiel #16
0
static void mxml_node_ret( mxml_node_t * node, int iNew )
{
   if( node )
      hb_itemPutPtrGC( hb_stackReturnItem(), mxml_node_new( node, iNew ) );
}
Beispiel #17
0
static void mxml_index_ret( mxml_index_t * index )
{
   hb_itemPutPtrGC( hb_stackReturnItem(), mxml_index_new( index ) );
}
Beispiel #18
0
void hb_cairo_pattern_ret( cairo_pattern_t * pPattern )
{
   hb_cairoPatternItemPut( hb_stackReturnItem(), pPattern );
}
Beispiel #19
0
PHB_ITEM hb_itemDo( PHB_ITEM pItem, HB_ULONG ulPCount, ... )
{
   PHB_ITEM pResult = NULL;

   HB_TRACE( HB_TR_DEBUG, ( "hb_itemDo(%p, %lu, ...)", pItem, ulPCount ) );

   if( pItem )
   {
      PHB_SYMB pSymbol = NULL;

      if( HB_IS_STRING( pItem ) )
      {
         PHB_DYNS pDynSym = hb_dynsymFindName( pItem->item.asString.value );

         if( pDynSym )
         {
            pSymbol = pDynSym->pSymbol;
            pItem = NULL;
         }
      }
      else if( HB_IS_SYMBOL( pItem ) )
      {
         pSymbol = pItem->item.asSymbol.value;
         pItem = NULL;
      }
      else if( HB_IS_BLOCK( pItem ) )
      {
         pSymbol = &hb_symEval;
      }

      if( pSymbol )
      {
         if( hb_vmRequestReenter() )
         {
            hb_vmPushSymbol( pSymbol );
            if( pItem )
               hb_vmPush( pItem );
            else
               hb_vmPushNil();

            if( ulPCount )
            {
               HB_ULONG ulParam;
               va_list va;
               va_start( va, ulPCount );
               for( ulParam = 1; ulParam <= ulPCount; ulParam++ )
                  hb_vmPush( va_arg( va, PHB_ITEM ) );
               va_end( va );
            }
            if( pItem )
               hb_vmSend( ( HB_USHORT ) ulPCount );
            else
               hb_vmProc( ( HB_USHORT ) ulPCount );

            pResult = hb_itemNew( hb_stackReturnItem() );
            hb_vmRequestRestore();
         }
      }
   }

   return pResult;
}